MEMORY_BASIC_INFORMATION这个结构中的两个成员的区别:
typedef struct _MEMORY_BASIC_INFORMATION {
PVOID BaseAddress;
PVOID AllocationBase;
DWORD AllocationProtect;
SIZE_T RegionSize;
DWORD State;
DWORD Protect;
DWORD Type;
} MEMORY_BASIC_INFORMATION, *PMEMORY_BASIC_INFORMATION;
以下引用csdn论坛的观点,我认为这解释地比较清楚了:
PVOID BaseAddress; //该页的基地址,是VirtualQuery(Ex)第一个参数下舍入下一个页面的边界的值
页的边界启始地址. 在地址形式上类似: 0xXXXXX000(X86,页大小为4KB)
PVOID AllocationBase;
在进程中为了使用内存,必须保留(Reserved)内存和占有内存(Committed) -使用VirtualAlloc()函数. VirtualAlloc分配的内存称为区域(Region)- 一片连续的页. 为了分配效率(?) Windows会以64-KB为边界计算区域的启始地址,所以区域的启始地址在形式上类似: 0xXXXX0000,这里的64KB页就是所谓的分配粒度,因此 AllocationBase正是一个区域(Region)的启始地址
另外,BaseAddress一定在AllocationBase地址范围之内
(The page pointed to by the BaseAddress member is contained within this allocation range)
以下是我在应用VirtualQuery函数时MEMORY_BASIC_INFORMATION结构里面的
PVOID BaseAddress;
PVOID AllocationBase;两个成员的返回值
=================================
BaseAddress AllocationBase
0x00401000 0x00400000
0x00401700 0x00400000
0x00401800 0x00400000
0x00401a00 0x00400000
=================================
BaseAddress - the address of the queried memory page ( VirtualQuery(LPCVOID lpAddress,... ).
AllocationBase - the beginning of the allocated memory block. It is used for deallocation. BaseAddress >= AllocationBase.
If you are querying stack then AllocationBase will be the lowest address of the stack (the stack top)