When using the API VirtualAllocto distribute and fix a region of virtual memory with a capacity of two page border sizes, for example:
void* address = VirtualAlloc(0, 0x10000, MEM_COMMIT, PAGE_READWRITE);
It seems to be addressin alignment of 64 KB, and not just the page border, which in my case is 4 KB.
Question: Is this alignment reliable and prescribed, or is it just a coincidence? Documents claim that it is guaranteed to be on the page border, but does not affect the behavior that I see. I ask because later I wanted to take an arbitrary pointer (provided by the pool allocator that uses this piece), and determine which piece of 64 KB it belongs to, something like:
void* chunk = (void*)((uintptr_t)ptr & 0xFFFF0000);
source
share