我正在制作外部hack代码,但我不能(不知道)如何写地址 EX:0x0471604 偏移量为0x14 如果有人能教我,我会欣喜若狂 这是我的代码示例,因此大家都可以指出我出了错的地方:
#include <iostream>
#include <string>
#include <cstring>
#include <Windows.h>
DWORD Ammo = 0x028FA348;
DWORD AmmoOffsets[] = {0x348,0x14,0x0};
DWORD PointedAmmo;
int ModdedAmmo = 1000;
void AmmoMod()
{
HANDLE ProccessHandle =
OpenProcess(PROCESS_ALL_ACCESS, FALSE, GameProcessID);
ReadProcessMemory(ProccessHandle, (LPCVOID)(Ammo + AmmoOffsets), &PointedAmmo, sizeof(PointedAmmo), 0);
WriteProcessMemory(ProccessHandle, (LPCVOID)PointedAmmo, &ModdedAmmo, sizeof(ModdedAmmo), 0);
}
答案 0 :(得分:1)
(gimp-edit-copy inLayer)
从技术上讲,这是使用“偏移量”访问“地址”的方式。当然,这很可能会在99%的时间给您带来段错误,但这是一种解决方法。
答案 1 :(得分:0)
要获取指针链的最终地址,ammo变量的地址,可以使用此函数,然后只需在ammoAddr上调用WriteProcessMemory。
uintptr_t FindDMAAddy(HANDLE hProc, uintptr_t ptr, std::vector<unsigned int> offsets)
{
uintptr_t addr = ptr;
for (unsigned int i = 0; i < offsets.size(); ++i)
{
ReadProcessMemory(hProc, (BYTE*)addr, &addr, sizeof(addr), 0);
addr += offsets[i];
}
return addr;
}
uintptr_t ammoAddr = FindDMAAddy(hProcess, dynamicPtrBaseAddr, { 0x374, 0x14, 0x0 });
WriteProcessMemory(ProccessHandle, (LPCVOID)ammoAddr, &ModdedAmmo, sizeof(ModdedAmmo), 0);