One question, do you even know what any of this code does?
And make sure to post it in [code] tags.
i am trying to make a external trainer that just overwrite the current address , everything goes very well till the writing part
every time i press F1 i get a fatel error =D and F2 doesnt work i got the static address and offsets and iam sure that they are 100% for a game called "AssaultCube" so Here's my code:
#include <iostream>
#include <Windows.h>
#include <ctime>
#include <string>
using namespace std;
void WritetoMemory(HANDLE hProcess);
DWORD find(int PointerLevel, HANDLE hProcess, DWORD offset[], DWORD BaseAddress);
string GameName = "AssaultCube";
LPCSTR LGameWindow = "AssaultCube";
string GameStatus;
bool isgameavail;
bool updateonNextrun;
//Ammo
bool AmmoStatus;
BYTE AmmoValue[] = { 0xA4, 0x1C, 0x0, 0x0 };
DWORD AmmoOFFsets[] = { 0x384,0x14,0x0 };
DWORD AmmoBaseAddress = { 0x00509B74 };
//HP
bool HPStatus;
BYTE HPValue[] = { 0x39, 0x5, 0x0, 0x0 };
DWORD HPOFFsets[] = { 0xF8 };
DWORD HPBaseAddress = { 0x0050F4F4 };
int main(){
system("Color B");
HWND hGameWindow = NULL;
HANDLE hProcess = NULL;
DWORD pid = NULL;
int isgameavailTMR = clock();
int onepressTMR = clock();
int timeSinceLastUpdate = clock();
updateonNextrun = true;
string sAmmo = "OFF";
string sHP = "OFF";
while (!GetAsyncKeyState(VK_INSERT)){
if (clock() - isgameavailTMR > 100){
isgameavailTMR = clock();
isgameavail = false;
hGameWindow = FindWindow(NULL, LGameWindow);
if (hGameWindow){
GetWindowThreadProcessId(hGameWindow, &pid);
if (pid != 0){
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
if (hProcess == INVALID_HANDLE_VALUE || hProcess == NULL){
GameStatus = "No Process Found\n";
}
else{
GameStatus ="Game is Ready for Hack\n";
isgameavail = true;
}
}
else{
GameStatus = "Invalid Process\n";
}
}
else{
GameStatus = " Game: NOT FOUND!!\n";
}
if (updateonNextrun || clock() - timeSinceLastUpdate > 5000){
system("cls");
cout << "===============================" << endl;
cout << " AssaultCube " << endl;
cout << "===============================" << endl;
cout << "GameStatus" << GameStatus << endl;
cout << "[F1] Unlimited Ammo -> " << sAmmo << " <-" << endl;
cout << "[F2] HP -> " << sHP << " <-" << endl;
cout << "[INSERT] Exit" << endl;
updateonNextrun = false;
timeSinceLastUpdate = clock();
}
if (isgameavail){
WritetoMemory(hProcess);
}
}
if (clock() - onepressTMR > 400){
if (isgameavail){
if (GetAsyncKeyState(VK_F1)){
onepressTMR = clock();
AmmoStatus = !AmmoStatus;
updateonNextrun = true;
if (AmmoStatus) sAmmo = "ON";
else sAmmo = "OFF";
}
if (GetAsyncKeyState(VK_F2)){
onepressTMR = clock();
HPStatus = !HPStatus;
updateonNextrun = true;
if (HPStatus) sHP = "ON";
else sHP = "OFF";
}
}
}
}
return ERROR_SUCCESS;
}
DWORD find(int PointerLevel, HANDLE hProcess,DWORD OFFsets[], DWORD BaseAddress){
DWORD Pointer = BaseAddress;
DWORD ptemp;
DWORD Pointeraddr;
for (int i = 0; i < PointerLevel; i++){
if (i == 0){
ReadProcessMemory(hProcess, (LPCVOID)Pointer, &ptemp, sizeof(ptemp), NULL);
}
Pointeraddr = Pointer + OFFsets[i];
ReadProcessMemory(hProcess, (LPCVOID)Pointeraddr,&ptemp, sizeof(ptemp), NULL);
}
return Pointeraddr;
}
void WritetoMemory(HANDLE hProcess){
DWORD AddresstoWrite;
if (AmmoStatus){
AddresstoWrite = find(3, hProcess,AmmoOFFsets ,AmmoBaseAddress);
WriteProcessMemory(hProcess, (BYTE*)AddresstoWrite, &AmmoValue, sizeof(AmmoValue), NULL);
}
if (HPStatus){
AddresstoWrite = find(1, hProcess, HPOFFsets, HPBaseAddress);
WriteProcessMemory(hProcess, (BYTE*)AddresstoWrite, &HPValue,sizeof(HPValue), NULL);
}
}
One question, do you even know what any of this code does?
And make sure to post it in [code] tags.
u need to know what the whole code means? ...
from int main()
its basically checking every 5 seconds whether the game is opened or not
closes when i press insert button
(clock() - onepressTMR > 400)
is the timer of the ON or OFF every 4 milliseconds when i press F1 or F2 so that the console doesnt crush
ofc hProcess = GetWindowThreadProcessId is to get the pid of the game when u press Alt + crtl + delete in the process tab
DWORD find function is to read address with OFFSETS which maybe i have an error with it
and last WritetoMemory function is to write on it =D thats the summary of the code + iam here for solutions not explaining my code...