I am new to this forum so please excuse any errors i make! I have recently started programming in c++ and one of my first projects is making a console trainer for AssaultCube (FPS Game). I have some errors and have not been able to fix them.
Here is the code
#include <iostream>
#include <Windows.h>
#include <string>
#include <ctime>
DWORD FindDmaAddy(int PointerLevel, HANDLE hProcHandle, DWORD Offsets [], DWORD BaseAddress);
void WriteToMemory(HANDLE hProcHandle);
std::string GameName="AssaultCube";
LPCSTR LGameWindow="AssaultCube";
std::string GameStatus;
bool IsGameAvail;
bool UpdateOnNextRun;
//AMMO VARS
bool AmmoStatus;
BYTE AmmoValue [] = {0XA3, 0X1C, 0X0, 0X0};
DWORD AmmoBaseAddress = {0x004DF73C};
DWORD AmmoOffsets[] = {0x378, 0x14, 0x0};
//HEALTH VARS
bool HealthStatus;
BYTE HealthValue [] = {0x39, 0x5, 0X0, 0X0};
DWORD HealthBaseAddress = {0x004DF73C};
DWORD HealthOffsets[] = {0xF4};
int main() //on startup
{
HWND hGameWindow = NULL;
int timeSinceLastUpdate = clock();
int GameAvailTMR = clock();
int onePressTMR = clock ();
DWORD dwProcID = NULL;
HANDLE hProcHandle = NULL;
UpdateOnNextRun = true;
std::string sAmmoStatus = "OFF";
std::string sHealthStatus = "OFF";
while(!GetAsyncKeyState(VK_INSERT))
{
if (clock() = GameAvailTMR > 100)
{
GameAvailTMR = clock ();
IsGameAvail = false;
hGameWindow = FindWindow(NULL, LGameWindow);
if(hGameWindow)
{
GetWindowThreadProcessId(hGameWindow, &dwProcID);
if (dwProcID !=0)
{
hProcHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcID);
if(hProcHandle == INVALID_HANDLE_VALUE || hProcHandle == NULL)
{
GameStatus = "Failed to open process for handle value...Too Bad you didn't buy the warranty cause this ain't workin";
}
else
{
GameStatus = "I Hope your ready to start hacking";
IsGameAvail = true;
}
}
else
{
GameStatus = "You Broke it...Nah just kidding, Failed to get proccess id, Check the warranty number on the back of the purchase box for full details on receiving a refund.";
}
}
else
{
GameStatus = "You need to load AssaultCube before you hack it! DUUUUHHHHHH!";
}
if(UpdateOnNextRun || clock() - timeSinceLastUpdate > 5000)
{ //Top-down console interface
//Remember "cout" is "print" equivalent
//Dont forget legal Thingy
system("cls");
std::cout << "-----------------------------------------------------"; << std::endl;
std::cout << " AssaultCube Hacker® ™Created By Miles Bench©"; << std::endl;
std::cout << "-----------------------------------------------------"; << std::endl << std::endl;
std::cout << "GAME STATUS:" << GameStatus << std::endl << std::endl;
std::cout << "[F1] Unlimited Ammo -> " <<sAmmoStatus << " <- " << std::endl << std::endl;
std::cout << "[F2] Unlimited Health -> " <<sHealthStatus << " <- " << std::endl << std::endl;
std::cout << "[INSERT] Exit" << std::endl;
std::cout << " If you encounter any problems, bugs, crashes, issues etc. please contact nobodycares@fixityourself.com to have your problem resolved :) "; << std::endl;
UpdateOnNextRun = false;
timeSinceLastUpdate = clock ();
}
if(IsGameAvail)
{
//write to memory
}
}
if(clock() - onePressTMR > 400)
{ // line 108 - "if that didnt happen"
if(IsGameAvail)
{
if(GetAsyncKeyState(VK_F1))
{ //Ammo
onePressTMR = clock();
AmmoStatus = !AmmoStatus;
UpdateOnNextRun = true;
if(AmmoStatus)sAmmoStatus = "ON";
else sAmmoStatus = "OFF";
}
else if(GetAsyncKeyState(VK_F2))
{ //Health
onePressTMR = clock();
HealthStatus = !HealthStatus;
UpdateOnNextRun = true;
if(HealthStatus)sHealthStatus = "ON";
else sHealthStatus = "OFF";
}
}
}
}
CloseHandle(hProcHandle);
CloseHandle(hGameWindow);
return ERROR_SUCCESS;
}
DWORD FindDmaAddy(int PointerLevel, HANDLE hProcHandle, DWORD Offsets [], DWORD BaseAddress);
{
DWORD pointer = BaseAddress;
DWORD = pTemp;
DWORD pointerAddr;
for(int c = 0; c < PointerLevel; c++)
{
if(c === 0)
{
ReadProcessMemory(hProcHandle, (LPCVOID) pointer, &pTemp, sizeof(pTemp), NULL);
}
PointerAddr = pTemp + Offsets[c];
ReadProcessMemory(hProcHandle, (LPCVOID) PointerAddr, &pTemp, sizeof(pTemp), NULL)
}
return pointerAddr;
}
}
void WriteToMemory(HANDLE hProcHandle);
{
DWORD AddressToWrite;
if(AmmoStatus)
{
AddressToWrite = FindDmaAdddy(3, hProcHandle, AmmoOffsets, AmmoBaseAdress);
WriteProcessMemory(hProcHandle, (BYTE^)AddressToWrite, &AmmoValue, sizeof(AmmoValue), NULL;
}
if(HealthStatus)
{
AddressToWrite = FindDmaAdddy(3, hProcHandle, AmmoOffsets, AmmoBaseAdress);
WriteProcessMemory(hProcHandle, (BYTE^)AddressToWrite, &HealthValue, sizeof(HealthValue), NULL;
}
}
Here are the errors
main.cpp(45): error C2106: '=' : left operand must be l-value
main.cpp(140): error C2447: '{' : missing function header (old-style formal list?)
main.cpp(165): error C2447: '{' : missing function header (old-style formal list?)
If i haven't properly inserted the code or haven't provided enough information please tell me and i will fix it immediately.
I really appreciate any help you can give me! :)
Thanks so much!