1

I was wondering if it's possible to determine if a virtual address (pointer) belongs to a previous VirtualAlloc call or not (if possible without writing to the page). Since VirtualFree can automatically set the dwSize value if you use it with MEM_RELEASE.

4

1 回答 1

2

Something like this or I don't understand the question?

MEMORY_BASIC_INFORMATION mbi;
void* p = NULL;
VirtualQuery(p, &mbi, sizeof(mbi));
BOOL bWasUsed = (mbi.State==MEM_FREE)? FALSE: TRUE; 
于 2013-02-19T06:36:38.177 回答