Reputation: 6268
Since I was not clear before I will rewrite my question.
I need to get the absolute base address of a section of memory that was allocated with VirtualAllocEx()
.
For example, if I allocate 0x20000 bytes and get the address 0x5000000.
I need a method of getting the address 0x5000000 using the value 0x5015000.
VirtualQuery() returns the page address that the value 0x5015000 resides in and not the base address of the allocated section of memory.
So I need a different method to find the base address of any allocated section of memory.
Upvotes: 2
Views: 2142
Reputation: 70243
Disclaimer: no WinAPI experience here whatsoever.
VirtualQuery() returns the page address that the value 0x5015000 resides in and not the base address of the allocated section of memory.
As far as I understood the docs, VirtualQuery()
returns a structure containing multiple pieces of information, including...
BaseAddress
A pointer to the base address of the region of pages.
AllocationBase
A pointer to the base address of a range of pages allocated by the
VirtualAlloc
function. The page pointed to by the BaseAddress member is contained within this allocation range.
Could it be that you checked only BaseAddress
and not AllocationBase
? Because the latter sounds exactly like what you're looking for...
Upvotes: 3