You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何读取EXE进程的内存地址值?读取SonicAdventureDXPC戒指数异常怎么解决

读取SonicAdventureDXPC进程戒指数异常问题

问题表现

我尝试通过读取内存地址的方式,输出运行中的SonicAdventureDXPC.exe程序的戒指数量。我已经找到了存储戒指数的地址,但运行代码时总是输出-1082988699(哪怕戒指数为1或更高)。
我编写的代码如下:

#include <windows.h>
#include <iostream>
DWORD ADDR = 0x370F0E4;
DWORD PID;

int main(int argc, char* argv[]) {
    HWND Window = FindWindow(0, "SonicAdventureDXPC");
    if (Window == 0) {
        std::cout << "Can't find the window"<< std::endl;
    }
    else {
        GetWindowThreadProcessId(Window, &PID);
        HANDLE Process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, PID);
        if (Process != 0) {
            int Read_V;
            ReadProcessMemory(Process, (LPVOID)ADDR, &Read_V, sizeof(Read_V), 0);
            std::cout << "Rings: " <<  Read_V << std::endl;
            system("PAUSE");
        }
    }
    return 0;
}

问题原因与修复方案

代码本身逻辑没有问题,仅为低级笔误。使用Cheat Engine排查后发现地址变量填写错误:

  • 错误地址:0x03F0F0E4
  • 正确地址:0x03B0F0E4

二者仅差一个字符,把十六进制的B错写成了F,导致读取到无效内存地址的垃圾值,也就是输出的异常负数-1082988699。
只需要修改地址定义行即可修复问题:

// 原错误写法
// DWORD ADDR = 0x370F0E4;
// 修正后写法
DWORD ADDR = 0x03B0F0E4;

内容的提问来源于stack exchange,提问作者Chins man

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.28 11:06:02