c++,读写内存,
c++, read and write memory,
所以我是 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);
}
问题可能是您实际上并没有打印 pointer
变量的值,而是打印了它的位置。地址运算符 &
returns 指向变量的指针。
所以我是 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);
}
问题可能是您实际上并没有打印 pointer
变量的值,而是打印了它的位置。地址运算符 &
returns 指向变量的指针。