Solved C++ HOW TO HACK any game TUTORIAL Pt 7 Trainer Final AmmoCrash

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

Spamer

Banned
Silenced
Feb 3, 2014
29
157
0
When I'm pressing F1 game Falls down.

When I'm pressing F2 Health changes and everything is ok.
The Debugger shows that it is falling when we are writing to memory ( WriteProcessMemory(hProcHandle,(BYTE*)AddressToWrite,&AmmoValue,sizeof(AmmoValue),NULL); )

Here is the code
C++:
#include <iostream>
#include <Windows.h>
#include <string>
#include <ctime>

DWORD FindDmaAddy(int PointerLevel, HANDLE hProcHandle, DWORD Offset[], DWORD BaseAddres);
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 = 0x00508B74;
DWORD AmmoOffsets[] = {0x384,0x14,0x0};

//Health Vars
bool HealthStatus;
BYTE HealthValue[] = {0x39,0x5,0x0,0x0};
DWORD HealthBaseAddress = 0x00508B74;
DWORD HealthOffsets[] = {0xF8};

int main()
{
	HWND hGameWindow = NULL;
	int timeSinceLastUpdate = clock();
	int GameAvailTIMER = clock();
	int onePressTIMER = clock();
	DWORD dwProcID = NULL;
	HANDLE hProcHandle = NULL;
	UpdateOnNextRun = true;
	std::string sAmmoStatus = "OFF";
	std::string sHealthStatus = "OFF";

	while(!GetAsyncKeyState(VK_INSERT))
	{
		if(clock() - GameAvailTIMER > 100)
		{
			GameAvailTIMER = clock();

			IsGameAvail = false;
			hGameWindow = FindWindow(NULL,LGameWindow);

			if(LGameWindow)
			{
				GetWindowThreadProcessId(hGameWindow,&dwProcID);
				if(dwProcID)
				{
					hProcHandle = OpenProcess(PROCESS_ALL_ACCESS,NULL,dwProcID);
					if(hProcHandle == INVALID_HANDLE_VALUE || hProcHandle == NULL)
					{
						GameStatus = "Failed to open process fod valid handle";
					}
					else
					{
						GameStatus = "AssaultCube Ready to hack";
						IsGameAvail = true;

					}
				}
				else
				{
					GameStatus = "Failed to get process ID ";
				}
			}
			else
			{
				GameStatus = "AssaultCube not found";
			}

			if(UpdateOnNextRun || clock() - timeSinceLastUpdate > 5000)
			{
				system("cls");
				std::cout << ".................................................." << std::endl;
				std::cout << "              AssaultCube memory Hacker"<<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;
				
				UpdateOnNextRun = false;
				timeSinceLastUpdate = clock();

			}
			
			if(IsGameAvail)
			{
				WriteTomemory(hProcHandle);
			}

		}
		if(clock() - onePressTIMER > 400)
		{
			//ammo
			if(GetAsyncKeyState(VK_F1))
			{
				onePressTIMER = clock();
				AmmoStatus = !AmmoStatus;
				UpdateOnNextRun = true;
				if(AmmoStatus) 
					sAmmoStatus= "ON";
				else sAmmoStatus = "OFF";
			}
			//health
			if(GetAsyncKeyState(VK_F2))
			{
				onePressTIMER = clock();
				HealthStatus = !HealthStatus;
				UpdateOnNextRun = true;
				if(HealthStatus) 
					sHealthStatus= "ON";
				else sHealthStatus = "OFF";
			}
		}
	}
	//CloseHandle(hProcHandle);
	//CloseHandle(hGameWindow);
	return 0;
}
DWORD FindDmaAddy(int PointerLevel, HANDLE hProcHandle, DWORD Offset[], DWORD BaseAddres)
{
	DWORD pointer = BaseAddres;
	DWORD pTemp;

	DWORD pointerAddr;
	for(int c = 0 ; c < PointerLevel ; c++)
	{
		if(c == 0)
		{
			ReadProcessMemory(hProcHandle,(LPCVOID)pointer,&pTemp,sizeof(pTemp),NULL);
		}
		pointerAddr = pTemp+Offset[c];
		ReadProcessMemory(hProcHandle,(LPCVOID)pointer,&pTemp,sizeof(pTemp),NULL);

	}
	return pointerAddr;
}
void WriteTomemory(HANDLE hProcHandle)
{
	DWORD AddressToWrite;
	
	if(AmmoStatus)
	{
		AddressToWrite = FindDmaAddy(3,hProcHandle,AmmoOffsets,AmmoBaseAddress);
		WriteProcessMemory(hProcHandle,(BYTE*)AddressToWrite,&AmmoValue,sizeof(AmmoValue),NULL);

	}
	if(HealthStatus)
	{
		AddressToWrite = FindDmaAddy(1,hProcHandle,HealthOffsets,HealthBaseAddress);
		WriteProcessMemory(hProcHandle,(BYTE*)AddressToWrite,&HealthValue,sizeof(HealthValue),NULL);
	}
}
 

SASteve

Newbie
Feb 6, 2014
3
374
0
Have you tried running it with a different compiler? If not, try compiling the code with Dev C++.
 

Cyrion

Coder
Dank Tier Donator
Nobleman
Dec 31, 2013
107
618
7
Why do you use a "OnePressTimer" ? Just make your condition like this " if(GetAsyncKeyState(VK_F1) &1)"
 
Last edited:
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods