所以我是 C++ 新手(非常新),我一直在尝试使用这段代码 7 个小时,我不知道它为什么不起作用,它编译得很好,但看起来它写到了错误的地址,我有一种感觉我有问题,谢谢。
#include<iostream>
#include<windows.h>
#include<stdlib.h>
using namespace std;
int main() {
DWORD id;
HANDLE handle;
HWND wnd;
unsigned int baseadd = {0x021da060};
unsigned int ptemp;
unsigned int pointer;
unsigned int newdata = 5000;
wnd = FindWindow(NULL, "AssaultCube");
GetWindowThreadProcessId(wnd,&id);
handle = OpenProcess(PROCESS_ALL_ACCESS,FALSE,id);
ReadProcessMemory(handle,(LPVOID)baseadd,&ptemp,sizeof(ptemp),0);
pointer =ptemp + 0x384;
ReadProcessMemory(handle,(LPVOID)pointer,&ptemp,sizeof(ptemp),0);
pointer =ptemp + 0x14;
ReadProcessMemory(handle,(LPVOID)baseadd,&ptemp,sizeof(ptemp),0);
pointer =ptemp + 0x0;
cout << &pointer; // just to check if it was the right address , its not
WriteProcessMemory(handle,(LPVOID)pointer,&newdata,sizeof(newdata),NULL);
}