63178249 发表于 2022-3-11 15:09

求助 ReadProcessMemory读不到内存

代码如下
HWND hWnd = FindWindow(L"MainWindow", L"Plants vs. Zombies");
    DWORD PID = GetWindowThreadProcessId(hWnd, &PID);
    HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, PID);
    DWORD Addr = 0x28701A38;
    DWORD temp3 = 8888;
    DWORD temp = 0;
    cout << (bool)ReadProcessMemory(hProcess, (LPVOID)Addr, &temp, sizeof(DWORD), 0) << endl;
    CloseHandle(hProcess);

only998 发表于 2022-3-11 15:50

检查 hProcess 是否获取正常,0x28701A38 看起来像是一个dll地址?如果是dll的话需要需要用基址+偏移
某些程序会有 OpenProcess 权限过滤,论坛里应该有教程,没研究过,挺复杂。

gunxsword 发表于 2022-3-11 16:42

DWORD PID = GetWindowThreadProcessId(hWnd, &PID);
改为
DWORD PID ;
GetWindowThreadProcessId(hWnd, &PID);

63178249 发表于 2022-3-11 16:47

gunxsword 发表于 2022-3-11 16:42
DWORD PID = GetWindowThreadProcessId(hWnd, &PID);
改为
DWORD PID ;


感谢大佬
页: [1]
查看完整版本: 求助 ReadProcessMemory读不到内存