C++ 获取分配节的基地址

标签 c++ winapi memory virtualalloc

由于我之前不清楚,我将重写我的问题。

我需要获取使用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 docsVirtualQuery() 返回 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/

相关文章:

c++ - 类中的指针/释放内存

c++ - 何时使用 Malloc 而不是 New

c++ - 使用 {} 报告未使用变量的统一初始化

windows - PrintWindow 位图不同于 PrintScreen Key 位图

c - Winapi win32编程-选项卡控件不显示

java - PHP 数组是连续的内存块吗?

c++ - 返回类型自动扣除的好友函数模板无法访问私有(private)成员

c++ - Visual Studio 吐出 .lib 而不是 .dll

c++ - Visual Studio 线程 - afxwin 还是 C++11 线程?

java - 为什么将 ""附加到字符串可以节省内存?