#include <iostream>
#include <Windows.h>
#include <string>
#include <ctime>
void WriteToMemory(HANDLE hProcHandle);
DWORD FindAdd(int PointerLevel, HANDLE hProcHandle, DWORD Offsets[], DWORD BaseAddress);
bool AmmoStatus = true;
BYTE AmmoValue[] = {0xA3,0x1C,0x0,0x0};
DWORD AmmoBaseAddress = {0x004DF73C};
DWORD AmmoOffsets[] = {0x378, 0x14, 0x0}; //3 LEVEL pointer
bool HealthStatus = true;
BYTE HealthValue[] ={0x39,0x5,0x0,0x0};
DWORD HealthBaseAddress = {0x004DF73C};
DWORD HealthOffsets[] = {0xF4};
HWND hGameWindow = NULL;
DWORD dwProcId = NULL;
HANDLE hProcHandle = NULL;
std::string sAmmoStatus;
std::string sHealthStatus;
int main()
{
hGameWindow = FindWindow( NULL, L"AssaultCube");
if(hGameWindow)
{
GetWindowThreadProcessId( hGameWindow, &dwProcId );
if( dwProcId != 0 )
{
// Get Process Handle
hProcHandle = OpenProcess( PROCESS_ALL_ACCESS, FALSE, dwProcId );
if( hProcHandle == INVALID_HANDLE_VALUE || hProcHandle == NULL )
{
WriteToMemory(hProcHandle);
}
}
else{
std::cout << "AssaultCube not found!" << std::endl;
}
}
DWORD FindAdd(int PointerLevel, HANDLE hProcHandle, DWORD Offsets[], DWORD BaseAddress){
//DECLARE BASE ADDRESS
DWORD pointer = BaseAddress; // Declare a pointer of DWORD
//USED TO output the contents in the pointer
DWORD pTemp;
DWORD pointerAddr;
for(int i = 0; i < PointerLevel; i ++)
{
if(i == 0)
{
ReadProcessMemory(hProcHandle, (LPCVOID)pointer, &pTemp, 4, NULL);
}
//add first offset to that address
pointerAddr = pTemp + Offsets[i]; // Set p1 to content of p + offset
//Read memory one more time and exit the loop
ReadProcessMemory(hProcHandle, (LPCVOID)pointerAddr, &pTemp, 4, NULL);
}
return pointerAddr;
}
void WriteToMemory(HANDLE hProcHandle)
{
if(AmmoStatus)
{
DWORD AmmoAddressToWrite = FindDmaAddy(3, hProcHandle, AmmoOffsets, AmmoBaseAddress);
WriteProcessMemory( hProcHandle, (BYTE*)AmmoAddressToWrite, &AmmoValue, sizeof(AmmoValue), NULL);
}
if(HealthStatus)
{
//because health address is only one pointer in we send only to FindDmaAddy
DWORD HealthAddressToWrite = FindDmaAddy(1, hProcHandle, HealthOffsets, HealthBaseAddress);
WriteProcessMemory( hProcHandle, (BYTE*)HealthAddressToWrite, &HealthValue, sizeof(HealthValue), NULL);
}
}