C++ dll Problem [Help Request]
So I wanna do some dll hacking and I came to a problem...
So I want to hack Command & Conquer RA3 but that doesnt really matter.
I have already found out the adress and the offset of the pointer (to get money)
But I dont know why It isnt working...
So the adress is 0x10D791D0 and the offset is 4.
So this is a Part of the code:
Code
DWORD WINAPI HackThread( LPVOID )
{
while(1)
{
try
{
DWORD dwMoney = MemoryTools::ReadMemory<DWORD>(0x10D791D0, 0);
dwMoney = MemoryTools::ReadMemory<DWORD>(dwMoney, 0x04);
DWORD Current = MemoryTools::ReadMemory<DWORD>(dwMoney, 0);
if (Current == 1)
{
MemoryTools::WriteMemory<int>(dwMoney , 500);
}
}
catch (DWORD)
{
}
Sleep(100);
}
So a Part of the MemoryTools.h is
Code2
template <class T> static T ReadMemory(DWORD, WORD);
template <class T> static bool WriteMemory(DWORD, T value);
Code3
T MemoryTools::ReadMemory(DWORD address, WORD Offset)
{
DWORD OldProtect;
if (VirtualProtect((LPVOID)address, sizeof(T), PAGE_READWRITE, &OldProtect))
{
T result = *(T*)(address + Offset);
if (OldProtect != PAGE_READWRITE) VirtualProtect((LPVOID)address, sizeof(T), OldProtect, &OldProtect);
return result;
}
throw address;
}
template <class T>
bool MemoryTools::WriteMemory(DWORD address, T value)
{
DWORD OldProtect;
if (VirtualProtect((LPVOID)address, sizeof(T), PAGE_READWRITE, &OldProtect))
{
*(T*)address = value;
if (OldProtect != PAGE_READWRITE) VirtualProtect((LPVOID)address, sizeof(T), OldProtect, &OldProtect);
return true;
}
return false;
}
I dont understand why its not working, can someone help me? (I am still a newbie)