GetSystemInfo:頁大小、用戶/內核地址邊界、CPU 數。GlobalMemoryStatus:物理/虛擬/頁文件 總量與可用量、使用率。CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS) 遍歷進程。OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ) 獲取句柄。VirtualQueryEx 從 lpMinimumApplicationAddress 遞增掃描至 lpMaximumApplicationAddress,步長 RegionSize。輸出 BaseAddress、AllocationProtect、Type。DWORD dwCurPos = (DWORD)si.lpMinimumApplicationAddress;
while (dwCurPos < (DWORD)si.lpMaximumApplicationAddress) {
MEMORY_BASIC_INFORMATION mbi;
VirtualQueryEx(hProcess, (LPVOID)dwCurPos, &mbi, sizeof(mbi));
printf("0x%x %u %u\n", mbi.BaseAddress, mbi.AllocationProtect, mbi.Type);
dwCurPos = (DWORD)mbi.BaseAddress + mbi.RegionSize;
}
可用於調試、內存分析、惡意代碼掃描等場景。