【发布时间】:2025-12-13 17:15:02
【问题描述】:
我正在使用DWORD BaseAddress = (DWORD)GetModuleHandle("example.exe"); 来获取附加进程的基地址。我使用的所有地址都是 DWORD 类型,我在地址号之前使用 0x,所以它是十六进制而不是十进制。我正在使用 x64 计算机。我正在阅读的这两个地址都包含一个文本值。
此代码适用于静态地址:
ReadProcessMemory(pHandle, (LPVOID)Address1, (LPVOID)&Address1Value, sizeof(Address1Value)*3, 0);
char PlayerNameBuffer[13] = {0};
snprintf(Address1Buffer, sizeof(Address1Value)*3, "%s", (LPVOID)&Address1Value);
ImprovedSetWindowText(Address1DisplayLabel, Address1Buffer);
那么为什么这不适用于动态地址呢?:
DWORD Address2 = BaseAddress + Addres2Offset;
ReadProcessMemory(pHandle, (LPVOID)Address2, (LPVOID)&Address2Value, sizeof(Address2Value)*3, 0);
char LocationNameBuffer[13] = {0};
_snprintf(Address2Buffer, sizeof(Address2Value)*3, "%s", (LPVOID)&Address2Value);
ImprovedSetWindowText(Address2DisplayLabel, Address2Buffer);
【问题讨论】:
-
如何获得
Address2Offset?我认为这并不重要,但从技术上讲,如果您的进程是 64 位的,您应该使用 64 位类型来保存地址。 DWORD 为 32 位宽。 -
我逆向工程并找到了它。我知道这对于 100% 的事实是正确的,因为我使用另一个软件来输入地址和偏移量以显示值是什么,但是我在 c++ 中使用它时遇到了麻烦。另外我将 DWORD 更改为 DWORD64 并没有区别,我认为问题与变量类型无关。
-
我的问题已经解决,GetModuleHandle 使用不当。
标签: c++ readprocessmemory