-1

所以我是 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);
}
4

1 回答 1

1

问题可能是您实际上并没有打印pointer变量的值,而是打印了它的位置。address-of 运算符&返回一个指向变量的指针。

于 2015-08-21T14:25:19.570 回答