1

I'm trying to change the value of an address in solitaire which provides the time.

Given the code below, the baseaddress + offset 0x97074 should point to another address with offset 0x50 and finally this address should point to the final address with offset x0C to change the timevalue.

However, solitaire crashes when I'm executing this operation.

HMODULE hModule = GetModuleHandle(nullptr);
sstream << std::hex << reinterpret_cast<unsigned int>(hModule);
str = sstream.str();
BaseAddress = reinterpret_cast<DWORD>(str.c_str());

//MessageBox(NULL, (LPCSTR) BaseAddress, "Adress", MB_OK); just some reminder
*(*(*(*(DWORD *) BaseAddress + (DWORD *) BASE_OFS_DEF ) + (DWORD *)TIME_OFS1_DEF ) + (DWORD *)TIME_OFS2_DEF) = 500;
4

1 回答 1

1

逻辑是错误的,您在添加偏移量并将偏移量转换为指针之前取消引用您的指针!我这就是你想要的

*(DWORD*)(*(DWORD*)(*(DWORD*)(BaseAddress + BASE_OFS_DEF) + TIME_OFS1_DEF) + TIME_OFS2_DEF) = 500;

但是你真的应该把它分解一下以帮助理解发生了什么,例如

DWORD temp1 = *(DWORD*)(BaseAddress + BASE_OFS_DEF);
DWORD temp2 = *(DWORD*)(temp1 + TIME_OFS1_DEF);
*(DWORD*)(temp2 + TIME_OFS2_DEF) = 500;
于 2013-10-04T06:57:11.977 回答