webowner47
Programmer
hello i want to get the base address of my application, so that i can write to it's memory, here is my code below:
The Problem is that every time i launch my application i see different address (always change) not pointing to the desired address that i found in cheat engine(which is static address), but i already got a base pointer to that address in cheat engine,
can you help me please?
Code:
DWORD dwGetModuleBaseAddress(TCHAR *lpszModuleName, DWORD ProcessID) {
DWORD dwModuleBaseAddress = 0;
MODULEENTRY32 ModuleEntry32 = {0};
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, ProcessID);
ModuleEntry32.dwSize = sizeof(MODULEENTRY32);
if ( Module32First(hSnapshot, &ModuleEntry32) )
{
do
{
if ( _tcscmp(ModuleEntry32.szModule, lpszModuleName) == 0 ) {
dwModuleBaseAddress = (DWORD)ModuleEntry32.modBaseAddr;
break;
}
} while( Module32Next(hSnapshot, &ModuleEntry32) );
}
CloseHandle(hSnapshot);
return dwModuleBaseAddress;
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
DWORD ProcessID;
DWORD off1, off2, off3;
DWORD BaseAddr;
// Get Handles
HWND HalfLife2 = FindWindowA(0, "AssaultCube");
GetWindowThreadProcessId(HalfLife2, &ProcessID);
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, false, ProcessID);
// Get Client Base Address
DWORD ClientBaseAddress = dwGetModuleBaseAddress(L"ac_client.exe", ProcessID);
ReadProcessMemory( hProcess, (LPCVOID)(ClientBaseAddress + 0x00109B74), &BaseAddr, sizeof(BaseAddr), 0 );
CheatReturnStatus1->Caption = BaseAddr;
}
The Problem is that every time i launch my application i see different address (always change) not pointing to the desired address that i found in cheat engine(which is static address), but i already got a base pointer to that address in cheat engine,
can you help me please?