初识内存,打印进程内存分布


#include "stdafx.h"
#include 
#include 
using namespace std;

int main(int argc, char* argv[])
{
   SYSTEM_INFO systemInfo;  
   GetSystemInfo(&systemInfo); 
   printf("处理器个数: %d\n",systemInfo.dwNumberOfProcessors);
   printf("处理器分页大小: %d\n",systemInfo.dwPageSize);
   printf("最小寻址单元: %.8X\n",systemInfo.lpMinimumApplicationAddress);
   printf("最大寻址单元: %.8X\n",systemInfo.lpMaximumApplicationAddress);
   
   DWORD dwPid = 1992;//进程id
   HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS,0,dwPid);
   MEMORY_BASIC_INFORMATION stuMemoryInfo;
   LPCVOID addr = systemInfo.lpMinimumApplicationAddress;
   vector list;  
   while(addr < systemInfo.lpMaximumApplicationAddress)
   {
       VirtualQueryEx(hProcess,addr,&stuMemoryInfo,sizeof(stuMemoryInfo));
       list.push_back(stuMemoryInfo);
       addr = (LPCVOID) ((DWORD)addr+stuMemoryInfo.RegionSize);
   }
   
   //TODO循环填充到list控件中
   
   for (int i=0;i
初识内存,打印进程内存分布_第1张图片
image.png

你可能感兴趣的:(初识内存,打印进程内存分布)