Solved hey whats the problem with this code

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

programmer

Jr.Coder
Full Member
Nobleman
Jul 15, 2012
46
422
2
can any buddy help me fix this code pls :-\ :-\ :-\ :

C++:
#include <iostream>
#include <Windows.h>
#include <string>
#include <ctime>


std::string gamename = "AssaultCube";
LPCSTR LGameWindow = "AssaultCube";
std::string GameStatus;

bool IsGameAvail;
bool UpdateOnNextRun;

//AMMO VARS
bool AmmoStatus;
BYTE AmmoValue[] = {0xA3, 0X3C, 0X0, 0X0};
DWORD AmmoBaseAdress = {0x004DF73C};
DWORD AmmoOffsets[] = {0x378, 0x14, 0x0};

//HEALTH VARS
bool HealthStatus;
BYTE HealthValue[] = {0x39, 0X5, 0X0, 0X0};
DWORD HealthBaseAdress = {0x004DF73C};
DWORD HealthOffsets[] = {0xF4};

//GRENADE VARS
bool GrenadeStatus;
BYTE GrenadeValue[] = {0x39, 0X5, 0X0, 0X0};
DWORD GrenadeBaseAdress = {0x004DF73C};
DWORD GrenadeOffsets[] = {0x387, 0x14, 0x0};

int main()
{
	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";
	std::string sGrenadeStatus = "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 = "Faild To Open Process For Valid Handle";
					}
					else
					{
						GameStatus = "AssaultCube Ready To Hack";
						IsGameAvail = true;
					}
				}
				else
				{
					GameStatus = "Faild 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 By Foad [Version 1.0]" << 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 << "[F3] Unlimited Grenades --->" <<sGrenadeStatus << "<---" <<std::endl << std::endl;
				std::cout << "[Insert] Exit" << std::endl;
				UpdateOnNextRun = false;
				TimeSinceLastUpdate = clock();
			}
			if(IsGameAvail)
			{
				//WRITE TO MEMORY
			}
		}
		if(clock() - onePressTMR > 400)
		{
			if(IsGameAvail)
			{
				//Ammo
				if(GetAsyncKeyState(VK_F1))
				{
				onePressTMR = clock();
				AmmoStatus = !AmmoStatus;
				UpdateOnNextRun = true;
				if(AmmoStatus)sAmmoStatus = "On";
				else sAmmoStatus = "Off";
				}
				//Health
				if(GetAsyncKeyState(VK_F2))
				{
				onePressTMR = clock();
				HealthStatus = !HealthStatus;
				UpdateOnNextRun = true;
				if(HealthStatus)sHealthStatus = "On";
				else sHealthStatus = "Off";
				}
				//Grenade
				if(GetAsyncKeyState(VK_F3))
				{
				onePressTMR = clock();
				GrenadeStatus = !GrenadeStatus;
				UpdateOnNextRun = true;
				if(GrenadeStatus)sGrenadeStatus = "On";
				else sGrenadeStatus = "Off";
				}
			}
		}
	}
	CloseHandle(hProcHandle);
	CloseHandle(hGameWindow);

	return ERROR_SUCCESS;


}


DWORD FindOnAddy(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 = FindOnAddy(1, hProcHandle, AmmoOffsets, AmmoBaseAdress);
		WriteProcessMemory(hProcHandle,(BYTE*)AddressToWrite, &AmmoValue, sizeof(AmmoValue), NULL);
	}

	if(HealthStatus)
	{
		AddressToWrite = FindOnAddy(1, hProcHandle, HealthOffsets, HealthBaseAdress);
			WriteProcessMemory(hProcHandle,(BYTE*)AddressToWrite, &HealthValue, sizeof(HealthValue), NULL);


	}
	if(GrenadeStatus)
	{
		AddressToWrite = FindOnAddy(1, hProcHandle, GrenadeOffsets, GrenadeBaseAdress);
			WriteProcessMemory(hProcHandle,(BYTE*)AddressToWrite, &GrenadeValue, sizeof(GrenadeValue), NULL);
	}
}
 

programmer

Jr.Coder
Full Member
Nobleman
Jul 15, 2012
46
422
2
I think that every buddy is just copying the code and dont leave a code of how to fix it
 

programmer

Jr.Coder
Full Member
Nobleman
Jul 15, 2012
46
422
2
It loads very good but when i get in the game i press F1 it says unlimited ammo : on but its not .

It should give 7000+ ammo and stay on 7000+ ammo when you shot but in this program it isnt giving 7000+ ammo and its not unlimited
 

Helios

Coder
Meme Tier VIP
May 24, 2012
207
1,113
4
Where did you get that piece of code? I corrected something very similar to this for someone some time ago.

C++:
#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()
{
  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 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::cout << "GAME STATUS:" << GameStatus << std::endl << std::endl;
      std::cout << "[F1] Unlimited ammo ->" <<sAmmoStatus << " <- " << std::endl;
      std::cout << "[F2] Unlimited health ->" <<sHealthStatus << " <- " << std::endl;
      std::cout << "[INSERT] Exit" << std::endl;
      UpdateOnNextRun = false;
      timeSinceLastUpdate = clock();
     }

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

   if(clock() - onePressTMR > 400)
   {
     if(IsGameAvail)
     {
      //ammo
      if(GetAsyncKeyState(VK_F1))
      {

        onePressTMR = clock();
        AmmoStatus = !AmmoStatus;
        UpdateOnNextRun = true;
        if(AmmoStatus)sAmmoStatus = "ON";
        else sAmmoStatus = "OFF";
      }
      //health
      if(GetAsyncKeyState(VK_F1))
      {
        onePressTMR = clock();
        HealthStatus = !HealthStatus;
        UpdateOnNextRun = true;
        if(HealthStatus)sHealthStatus = "ON";
        else sHealthStatus = "OFF";
      }

     }
   }


  }

  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)
{
  if(AmmoStatus)
  {
   DWORD AddressToWrite = FindDmaAddy(3, hProcHandle, AmmoOffsets, AmmoBaseAddress);
   WriteProcessMemory(hProcHandle, (BYTE*)AddressToWrite, &AmmoValue, sizeof(AmmoValue), NULL);
  }
  if(HealthStatus)
  {
   DWORD AddressToWrite = FindDmaAddy(1, hProcHandle, HealthOffsets, HealthBaseAddress);
   WriteProcessMemory(hProcHandle, (BYTE*)AddressToWrite, &HealthValue, sizeof(HealthValue), NULL);
  }


}
 
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.

Similar threads

Community Mods