我想获取 页面状态为MEM_COMMIT和 页面属性为 MEM_PRIVATE 的另一个进程的数据 我在该网站上看到一片文章 可是 我写的代码 不对啊 请问怎么改呢
PROCESSENTRY32 pe32;//...
pe32.dwSize=sizeof(pe32);//..
BOOL bMore = 1;
HANDLE hProcessSnap=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);//...
if(hProcessSnap==INVALID_HANDLE_VALUE)//...
{
MessageBox("df");
}
while(bMore)
{
bMore=Process32Next(hProcessSnap,&pe32);//...
if( strcmp( "QQ.EXE", pe32.szExeFile)==0 )
{
DWORD id=pe32.th32ProcessID;
CString strID;
strID.Format("qq进程id=%d",id);
m_list.AddString(strID);
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, false,id) ;
strID.Format("进程句柄=%d",hProcess);
m_list.AddString(strID);
//LPSYSTEM_INFO *lpSystemInfo=new LPSYSTEM_INFO;
SYSTEM_INFO sysInfo;
GetSystemInfo(&sysInfo);
CString s;
s.Format("%d",sysInfo.lpMinimumApplicationAddress);
SetDlgItemText(IDC_EDIT1,s);
s.Format("%d",sysInfo.lpMaximumApplicationAddress);
SetDlgItemText(IDC_EDIT2,s);
int int_min=GetDlgItemInt(IDC_EDIT1);
int int_max=GetDlgItemInt(IDC_EDIT2);
MEMORY_BASIC_INFORMATION lpBuffer;//
while(int_min {
// MessageBox("fg");
VirtualQueryEx(hProcess,(LPCVOID)int_min, &lpBuffer, sizeof(lpBuffer));
if(lpBuffer.Type==MEM_PRIVATE &&
lpBuffer.State==MEM_COMMIT &&
lpBuffer.AllocationProtect==PAGE_READWRITE)
{
DWORD dwWantRead=1024,dwHaveRead;
LPBYTE lpBuff=new BYTE[dwWantRead];
ReadProcessMemory(hProcess,// 被读取进程的句柄
lpBuffer.AllocationBase, // 读的起始地址
lpBuff, // 存放读取数据缓冲区
dwWantRead,// 一次读取的字节数
&dwHaveRead);// 实际读取的字节数
}
int_min+=lpBuffer.RegionSize;
}
}
}
CloseHandle(hProcessSnap);
}
--------------------next---------------------
阅读(1350) | 评论(0) | 转发(0) |