![](/img/trans.png)
[英]what does it mean when WriteProcessMemory returns 487 ERROR_INVALID_ADDRESS?
[英]WriteProcessMemory() returns 487? Value found using CheatEngine
正如上面所寫的 (^),我遇到了 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++。
有關 GetLastError 代碼含義的說明,請參閱此鏈接。
在這種情況下ERROR_INVALID_ADDRESS
,嘗試訪問無效地址。
這是因為您正在寫入“隨機”內存地址。 你不能只取一個數字就希望這個地址的其他進程有內存。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.