Is MAXIMUM_WAIT_OBJECTS really 64?

Solution 1:

Yes, it's really 64. Since it's a #define, it can't change without recompiling programs, so it pretty much can never change.

Since STATUS_ABANDONED_WAIT_63 is defined as 0xBF and STATUS_USER_APC is defined as 0xC0, if you incremented MAXIMUM_WAIT_OBJECTS by even just one, there would be no way to tell the difference between the 65th handle being abandoned and your wait being terminated by an APC. Properly changing MAXIMUM_WAIT_OBJECTS would require renumbering the status codes, which would require recompiling every Win32 program in existence.

Also, a program compiled with MAXIMUM_WAIT_OBJECTS defined as 65 would fail on an OS where it's defined as 64.

Solution 2:

Yes, that's really the value of that macro.

Whether that's really the maximum number of objects that the function is capable of waiting on at once is an internal implementation detail. But if I were writing that function, I'd check the given array length to make sure it was within the documented bounds before proceeding, even if the rest of the code happened to be capable of waiting for more, because I wouldn't want consumers of the API to use more than the documented maximum and then come to rely on such undocumented behavior, thus placing requirements on any potential implementations of the function in future releases of the OS