本帖最后由 Ishin 于 2021-10-9 15:07 编辑
ReadProcessMemory和WriteProcessMemory
#include<iostream>
#include<windows.h>
using namespace std;
int main(){
HWND hwnd = FindWindow(NULL,"This is the Title");
if(!hwnd){
cout << "Cannot find the window!" << endl;
Sleep(3000);
exit(-1);
} else{//找到窗口句柄
cout << "Window Found!" << endl; }
DWORD proId;
GetWindowThreadProcessId(hwnd,&proId);
HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS,FALSE,proId);
if(proId == 0){
cout << "Cannot obtain process" << endl;
Sleep(3000);
exit(-2);
} else{
cout << "obtain the process!"<< endl;
int readValue = 0;
long long address = 0x7FF687599008;
cout << "Reading the memory of the process!" << endl;
ReadProcessMemory(handle,(LPVOID)&address,&readValue,sizeof(address),0);
cout << " the value is: "<<readValue << endl;
//输出的值readValue总是0?!!!
}
}
}
!!问题来了!!:
为什么我去读取地址的值的时候,cout输出的值总是0?我到底哪一步做错了?
小弟先在此谢谢各位!很疑惑。
|