It can't, the code explicitly casts handle to unsigned before the shift.
It's cast to a 64-bit unsigned, so the upper 32 bits are kept for the shift
One of the pointers passed in was: 0xffffff000026a8
after the shift, it became: 0xffffff000026a8 => 0x3fffffc00009aa
When assigned to the 32-bit i, the upper 32 bits were clipped out: 0x3fffffc00009aa => 0xc00009aa
The HandleToUlong() has an additional cast to ULONG32 that drops the upper 32 bits before the shift. Alternatively, I could have just added the cast but I noticed that macro was used elsewhere when converting handles
I'll admit that the upper 32 bits being set was because of a quirk in our C++ code, but similar values passed to Windows worked
Thanks daniel