由于我之前不清楚,我将重写我的问题。
我需要获取使用VirtualAllocEx()
分配的一段内存的绝对基地址。
例如,如果我分配 0x20000 字节并获取地址 0x5000000。
我需要一种使用值 0x5015000 获取地址 0x5000000 的方法。
VirtualQuery() 返回值 0x5015000 所在的页面地址,而不是已分配内存部分的基地址。
所以我需要一种不同的方法来查找任何分配的内存部分的基地址。
最佳答案
免责声明:这里没有任何 WinAPI 经验。
VirtualQuery() returns the page address that the value 0x5015000 resides in and not the base address of the allocated section of memory.
据我了解the docs ,VirtualQuery()
返回 structure包含多条信息,包括...
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.
您是否只检查了BaseAddress
而没有检查AllocationBase
?因为后者听起来完全像你正在寻找的东西......
关于C++ 获取分配节的基地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31539648/