64,637
社区成员
发帖
与我相关
我的任务
分享
#include <Windows.h>
#include <iostream>
using namespace std;
int main()
{
string rValue="";
DWORD pid=0;
DWORD tAddr=0;
DWORD mAddr=0;
cout<<"读取string类型实验"<<endl;
cout<<"请输入进程ID:"<<endl;
cin>>pid;
HANDLE hProc =OpenProcess(PROCESS_ALL_ACCESS,false,pid);
cout<<"进程句柄:"<<hProc<<endl;
cout<<"地址ox:"<<endl;
//转换成16进制
cin>>hex>>mAddr;
BOOL flag= ReadProcessMemory(hProc,(PCVOID)mAddr,&tAddr,4,NULL);
cout<<flag<<endl;
if(!flag)
{
cout<<"读取内存失败"<<endl;
}
else{
cout<<"读取出地址值10进制:"<<tAddr<<endl;
cout<<"读取出地址值16进制:"<<hex<<tAddr<<endl;
}
//读取出string类型
flag =ReadProcessMemory(hProc,(PCVOID)(&tAddr+0),&rValue,20,NULL);
if(!flag)
{
cout<<"读取string类型数据失败"<<endl;
}
else{
cout<<"读取string类型数据成功:"<<rValue<<endl;
}
system("pause");
}