指定窗口查询内存信息 - VirtualQueryEx
函数简介
查询指定的内存信息。
接口名称
VirtualQueryEx
DLL调用
long VirtualQueryEx(long instance, long hwnd, long addr, long pmbi);
参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| hwnd | 长整数型 | 窗口句柄或进程ID |
| addr | 长整数型 | 要查询的内存地址 |
| pmbi | 长整数型 | 内存信息结构体指针 |
示例
C++
long instance = CreateCOLAPlugInterFace();
// hwnd 为目标窗口句柄
// 查询指定地址的内存信息
long strPtr = VirtualQueryEx(instance, hwnd, 0x12345678, 0);
char* info = GetStringFromPtr(strPtr);
printf("内存信息: %s\n", info); // BaseAddress,AllocationBase,AllocationProtect,RegionSize,State,Protect,Type
FreeStringPtr(strPtr);
Python
# 待补充
返回值
返回字符串的指针,内容为"BaseAddress,AllocationBase,AllocationProtect,RegionSize,State,Protect,Type",数值都是10进制表达。
注意事项
- 返回的字符串指针需调用 FreeStringPtr 释放内存。
- 结构体定义如下:
// 32位
typedef struct _MEMORY_BASIC_INFORMATION32 {
DWORD BaseAddress;
DWORD AllocationBase;
DWORD AllocationProtect;
DWORD RegionSize;
DWORD State;
DWORD Protect;
DWORD Type;
} MEMORY_BASIC_INFORMATION32;
// 64位
typedef struct DECLSPEC_ALIGN(16) _MEMORY_BASIC_INFORMATION64 {
ULONGLONG BaseAddress;
ULONGLONG AllocationBase;
DWORD AllocationProtect;
DWORD __alignment1;
ULONGLONG RegionSize;
DWORD State;
DWORD Protect;
DWORD Type;
DWORD __alignment2;
} MEMORY_BASIC_INFORMATION64;
