The macro is defined as:
#define MAKEINTRESOURCEA(i) ((LPSTR)((ULONG_PTR)((WORD)(i))))
#define MAKEINTRESOURCEW(i) ((LPWSTR)((ULONG_PTR)((WORD)(i))))
How come this can be used to indicate either a resource ID (a 16-bit unsigned int) or its name (a pointer to an array of char)?
Doesn’t this effectively limit the address space (on a 32-bit system) to 16-bit? Otherwise how does the system know whether I’m using an ID or a name?
This works because Windows doesn’t allow mapping pages for the first 64 KB of the address space. To catch null pointer references. But I think also to catch pointer bugs in programs that were converted from the 16-bit version of Windows.
A side-effect is that this allows to reliably distinguish resource IDs packed into a pointer value since they’ll always point to non-mappable memory.