正如上面所写的 (^),我遇到了 C++ 和 WriteProcessMemory() 的问题。我打开了 Windows-Calc.exe,存储了一个数字并打开了 CheatEngine。我找到了这个数字(改变了它等等)并将它放在这个程序中:(注意:我是德国人;“Rechner”等于“Calculator”)
#include <iostream>
#include <Windows.h>
using namespace std;
int main (){
int Value = 500;
HWND hWnd = FindWindow(0, L"Rechner");
if (!hWnd) {
cerr << "Can't find window" << endl;
return 0;
}
DWORD PID;
GetWindowThreadProcessId(hWnd, &PID);
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, PID);
if (!hProcess) {
cerr << "Process handle error" << endl;
return 0;
}
int iSuccess = WriteProcessMemory(hProcess, (LPVOID)0x899FC6F60C , &Value, (DWORD)sizeof(Value), NULL);
int i = 0;
while (iSuccess == 0){
i = i+1;
cerr << "Failed " << i << " Error: " << GetLastError() << endl;
iSuccess = WriteProcessMemory(hProcess, (LPVOID)0x899FC6F60C , &Value, (DWORD)sizeof(Value), NULL); //Here all begins
}
clog << "Done" << endl;
CloseHandle(hProcess);
return 0;
}
找到了窗口,找到了进程(那里没有错误..)但是,“//这里一切开始”行返回 0,并将 GetLastError() 设置为 487。就像以下所有内容一样。如果你知道,我做错了什么,请描述它对菜鸟友好,我昨天开始使用 C++。