winapi - What is the range of a Windows HANDLE on a 64 bits application? -


on winapi, handle type defined void*, on 64 bit application handle value may range 0 18446744073709551615. true in practice? documentation specify integral range of such handle?

if instance 1 wants store handle int32_t on 32 bit application that's fine, on 64 bit application doubts sticks.

msdn states:

64-bit versions of windows use 32-bit handles interoperability. when sharing handle between 32-bit , 64-bit applications, lower 32 bits significant, safe truncate handle (when passing 64-bit 32-bit) or sign-extend handle (when passing 32-bit 64-bit). handles can shared include handles user objects such windows (hwnd), handles gdi objects such pens , brushes (hbrush , hpen), , handles named objects such mutexes, semaphores, , file handles.

it's worth noting comment added on page:

the proper way share such handles across process boundaries zero-extending 32 bits handles 64 bits, or vice versa truncating 64 bits handles 32 bits discarding top bits.

note distinction between "sign-extending" handle versus "zero-extending" handle.

edit: judging discussion seen in deleted answer question, suppose significance of sign-extending 32-bit handle arrive @ 64-bit handle instead of zero-extending retain proper treatment of invalid_handle_value value handle.

https://msdn.microsoft.com/en-us/library/windows/desktop/aa384203%28v=vs.85%29.aspx


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -