Source Code ExternalHack

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

Syntax Error

Coder
Silenced
Meme Tier VIP
Nov 6, 2014
239
2,928
6
Here's the beta version of my ExternalHack class. If you have any suggestions on how I can improve it please let me know.

The constructor takes a string as it's argument.
The memoryManipulation function takes four (DWORD theBaseAddress, WORD theOffsetsAsAnArray[], int theTotalNumberOfOffsets, int theValueYouWant). It will return true if it runs successfully and false otherwise. I did this so if you'd like to display error messages you could.
Theres also the getWindowHandle function that I don't think you will ever need to call but its there. It takes no arguments and returns a handle to game window....

Here's a very crude example of how you can implement it.
C++:
#include <iostream>
#include <Windows.h>
#include "ExternalHack.h"

int main()
{
	DWORD pistolBase = 0x509B74;        // static address
	WORD  pistolOffset[] = { 0x114 };   // the offsets if any
	int   pistolTotalOffsets = 1;       // the total number of offsets
	int   pistolValue = 1000;           // the value you wish to have

	ExternalHack ac("AssaultCube");     // create an instance of the class and pass
	                                    // it the window name

	std::cout << "F1. For hack." << std::endl; // beastie menu

	while (1) { // loop indefinetly
		if (GetAsyncKeyState(VK_F1) & 1) {  // F1 will supply you with 1000 bullets
			if (ac.memoryManipulation(pistolBase, pistolOffset, pistolTotalOffsets, pistolValue)) // call memoryManipulation
				std::cout << "Ammunition has been supplied." << std::endl;  // if it worked display this
			else                                                            
				std::cout << "Something went wrong..." << std::endl;        // otherwise display this
		}
		else if (GetAsyncKeyState(VK_INSERT) & 1) // press insert to exit the program
			break;

		Sleep(200); // let your cpu chill for a bit
	}
	return 0;
}

If your game doesn't have any offsets COD for example, don't fret.
WORD offset[] = { 0x00 }; and your problem is solved.

C++:
#ifndef EXTERNAL_HACK_H
#define EXTERNAL_HACK_H

#include <string>
#include <Windows.h>

class ExternalHack {

	private:
		const std::string GAME_NAME;

		// returns the current location in memory that the value is stored
		DWORD getDynamicAddress(HANDLE &hProc, DWORD &baseAddress, WORD offsets[], const unsigned int &totalOffsets);

	public:
		// constructor is passed the gameName and assigns it to GAME_NAME
		ExternalHack(const std::string gameName) : GAME_NAME(gameName) { };  
		// searches for a running instance of the game and it returns a handle to it
		HWND getWindowHandle();    
		// writes the newValue into the memory location specified.
		bool memoryManipulation(DWORD &baseAddress, WORD offsets[], const unsigned int &totalOffsets, const int &newValue);       
};

#endif // EXTERNAL_HACK_H

C++:
#include "ExternalHack.h"

/*
=======================================================================================
This is used to ensure there is a running instance of the game before we try 
manipulating the memory in it's address space.
=======================================================================================
*/
HWND ExternalHack::getWindowHandle()
{
	HWND hWnd = FindWindow(0, GAME_NAME.c_str());
	return hWnd; // if found returns handle to game; else it returns null
}

/*
=======================================================================================
This is the function that does the "hacking" it writes to the games memory
space. It returns true if everything went according to plan and false otherwise.
=======================================================================================
*/
bool ExternalHack::memoryManipulation(DWORD &baseAddress, WORD offsets[], const unsigned int &totalOffsets, const int &newValue)
{
	if (getWindowHandle()){  // game must be running
		DWORD pId;
		GetWindowThreadProcessId(getWindowHandle(), &pId);            // Get the process ID and store it in pId
		HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, false, pId);   // allows us to read/write data into/from the game

		if (hProc) { // ensure that we have access before attempting to do anything
			DWORD currentAddress = getDynamicAddress(hProc, baseAddress, offsets, totalOffsets); // store the dynamic address
			bool isSuccessful = WriteProcessMemory(hProc, (LPVOID)currentAddress, &newValue, static_cast<DWORD>(sizeof(newValue)), false); // change the the values stored in the dynamic address
			return isSuccessful;
		}
		CloseHandle(hProc);
	}
	return false; // we couldn't get access to the running process
}

/*
=======================================================================================
This is used to get the dynamic address of value we're trying to modify.
=======================================================================================
*/
DWORD ExternalHack::getDynamicAddress(HANDLE &hProc, DWORD &baseAddress, WORD offsets[], unsigned const int &totalOffsets)
{
	DWORD currentAddress, temp;

	ReadProcessMemory(hProc, (LPCVOID)baseAddress, &temp, static_cast<DWORD>(sizeof(temp)), false);
	for (int i = 0; i < totalOffsets; ++i) {
		// add our offsers to the address
		currentAddress = temp + offsets[i];
		// continue reading into temp
		ReadProcessMemory(hProc, (LPCVOID)currentAddress, &temp, static_cast<DWORD>(sizeof(temp)), false);
	}
	return currentAddress;
}





If you need me to explain anything feel free to ask... so yeah... thats it.

Edit.
Special thanks to Krampus and AnomanderRake for always answering my dumbass questions. :]
 
Last edited:

Solaire

Respected Hacker
Dank Tier VIP
Dec 15, 2013
1,051
16,353
62
Cool stuff, thanks for sharing! :D

EDIT:
Try having the handle as a variable in the class, same as anything else you can to keep the number of parameters lower on your functions. Just have the user either enter them, or have the grabHandle funct store it in the handle.
 
Last edited:

Solaire

Respected Hacker
Dank Tier VIP
Dec 15, 2013
1,051
16,353
62
would this work if i put it as a dll?
If you're injecting, you can directly access memory. It'd be much faster to directly read what you need through pointers than to use ReadProcessMemory. That being said, I'd guess that it would work in a DLL.
 

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,164
78,998
2,398
Cool! I totally fell asleep while testing your code last night I guess you must have fixed your problem?
 
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