Making C++ Hacks

Posts 1–15 of 29 · Page 1 of 2
Making C++ Hacks
Basics of a C++ Cheat
Note: Sorry if I have some mistakes, also you should read everything so you'll be able to fix stuff in case of errors.

Code:
#include <iostream>
#include <windows.h>
This is pretty much all we're going to need for a simple console program, even if you want to add some other stuff, it's probably already in one of these two. Also, you will need to also include "stdafx.h" if you're using visual studio.

Code:
int main(){
We're using this because we will eventually have to return some integer values too, else we would just use void main.

Code:
SetConsoleTitle(L"Whatever_You_Like");
This is used to set the title of our console program (that means the name you see at the top) to something else. The L before the string is there for compatibility reasons and as long as you don't use any numbers, everything should go well.

Code:
HWND Window = FindWindow(NULL, L"Game");
With this code, we are getting the handle of a specific window, which is "Game" (you can of course change it with whatever your game's window name is) and remember, it's not case-sensitive (If your window says "Battlefield" you can use "battlefield" too).

Code:
	if (!Window){
		return 0;
	}
If the window (the one used above) has not been found (that's why the '!' is there), it closes the console (return 0);

Code:
else{
                DWORD Pid;
		GetWindowThreadProcessId(Window, &Pid);
		HANDLE ProcessHandle= OpenProcess(PROCESS_ALL_ACCESS, FALSE, Pid);
Pretty understandable from the code itself, we are getting a handle on the process itself to be able to edit its memory, of course.

Code:
		if(!ProcessHandle){
			return 0;
		}
Again, if the program can't attach to it or maybe the process is stopping this from happening it will close your program.

Code:
else{
This is where the actual hack begins, if all goes well.

Code:
for(;;){
This is a not-so-very popular way to create a loop, while(0){ can be used too. A loop basically means it will keep running trough the code and see if anything change or actually change something. Basically think it as freezing an address in cheat engine (though that's not the only thing we'll use it for.

Code:
if(GetAsyncKeyState(VK_F2)){
This check if a key has been pressed, in this example we're using the F2 key. The added & 0x8000 you probably have seen before refers to the key being held, as far as I know, but it's really just useless in this example, you just want it to be pressed.

Code:
UINT_PTR FByteAddress= 0x01182A74;
float FloatAddress = 0x011A5B90;
int ValueForReading = NULL;
double DoubleAddress = 0x00FDB0F0;
It's not very common that I see people use UINT_PTR, but it's basically a replacement for stuff including DWORD and is made especially for the 64 bit addressing and also able to hold more information. We also declared the integer 'ValueForReading' to hold the value for ReadProcessMemory (what's below)

Code:
ReadProcessMemory(ProcessHandle, reinterpret_cast<void*>(FByteAddress), &ValueForReading, sizeof(ValueForReading ), nullptr)
We are basically reading 4ByteAddress' or 0x01182A74's value and storing it in the ValueForReading integer. You may also be un-familiar with nullptr which can also be overloaded, which you can use NULL (which is an integer with the value 0), but sadly if you use an old compiler, you may actually need to use NULL.

Code:
std::cout << "Value of 4Byte: " << ValueForReading << ".\n";
Here we actually print ValueForReading's value just to check. Also, the "\n" is an alternative to std::endl or endl.

Code:
UINT_PTR Offsets[] = {0x4c, 0x3b};
Here we're defining the offsets of our address (let's pretend we have offsets) and remember to write them in reverse of how they are in cheat engine (bottom to top).

Code:
WriteProcessMemory(ProcessHandle, reinterpret_cast<void*>(FByteAddress), &Offsets, 2, nullptr);
Here we wrote the value '2' to that address basically, but let's move onto something like writing bytes.

Code:
WriteProcessMemory(ProcessHandle, reinterpret_cast<void*>(FByteAddress), "/0x90/, 1, nullptr);
Here we wrote a nop which translates into 90 bytes (This shows into the Memory Viewer in Cheat Engine).



That is where you will get your bytes from. I won't go too much into detail on Assembly as it's not what I wanted to focus on. A full code can be found down below.

Code:
#include <iostream>
#include <windows.h>

int main(){
	SetConsoleTitle(L"djihjninjinjmu");
	HWND Window = FindWindow(NULL, L"csgo");
	if (!Window){
		return 0;
	}
	else{
		DWORD pID;
		GetWindowThreadProcessId(Window, &pID);
		HANDLE Hproc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pID);
		if(!Hproc){
			return 0;
		}
		else{
			std::cout << "Press F3 to activate.\n";
			for(;;){
				if(GetAsyncKeyState(VK_F3)){
					float Crosshair;
					UINT_PTR CrosshairAddress = 0x44ABC04;
					UINT_PTR Shoot = 0x5C4BB;
					ReadProcessMemory(Hproc, reinterpret_cast<void*>(CrosshairAddress), &Crosshair, sizeof(Crosshair), nullptr);
					if(Crosshair == 0){
						WriteProcessMemory(Hproc, reinterpret_cast<void*>(Shoot), "0x32/0x8B/0x90/0x20/0x01/", 5, nullptr);
						//This writes a special asm code that makes it shoot (it's just like changing its value from 0 to 1 but I preffer using this)
					}
					else if(Crosshair == 1){
						WriteProcessMemory(Hproc, reinterpret_cast<void*>(Shoot), "0x32/0x8B/0x90/0x20/0x00/", 5, nullptr);
						//It doesn't shoot from here
					}
				}
				
			}
		}
	}
}
Quote Originally Posted by Tightmarrow View Post
Basics of a C++ Cheat
Note: Sorry if I have some mistakes, also you should read everything so you'll be able to fix stuff in case of errors.

Code:
#include <iostream>
#include <windows.h>
This is pretty much all we're going to need for a simple console program, even if you want to add some other stuff, it's probably already in one of these two. Also, you will need to also include "stdafx.h" if you're using visual studio.

Code:
int main(){
We're using this because we will eventually have to return some integer values too, else we would just use void main.

Code:
SetConsoleTitle(L"Whatever_You_Like");
This is used to set the title of our console program (that means the name you see at the top) to something else. The L before the string is there for compatibility reasons and as long as you don't use any numbers, everything should go well.

Code:
HWND Window = FindWindow(NULL, L"Game");
With this code, we are getting the handle of a specific window, which is "Game" (you can of course change it with whatever your game's window name is) and remember, it's not case-sensitive (If your window says "Battlefield" you can use "battlefield" too).

Code:
	if (!Window){
		return 0;
	}
If the window (the one used above) has not been found (that's why the '!' is there), it closes the console (return 0);

Code:
else{
                DWORD Pid;
		GetWindowThreadProcessId(Window, &Pid);
		HANDLE ProcessHandle= OpenProcess(PROCESS_ALL_ACCESS, FALSE, Pid);
Pretty understandable from the code itself, we are getting a handle on the process itself to be able to edit its memory, of course.

Code:
		if(!ProcessHandle){
			return 0;
		}
Again, if the program can't attach to it or maybe the process is stopping this from happening it will close your program.

Code:
else{
This is where the actual hack begins, if all goes well.

Code:
for(;;){
This is a not-so-very popular way to create a loop, while(0){ can be used too. A loop basically means it will keep running trough the code and see if anything change or actually change something. Basically think it as freezing an address in cheat engine (though that's not the only thing we'll use it for.

Code:
if(GetAsyncKeyState(VK_F2)){
This check if a key has been pressed, in this example we're using the F2 key. The added & 0x8000 you probably have seen before refers to the key being held, as far as I know, but it's really just useless in this example, you just want it to be pressed.

Code:
UINT_PTR FByteAddress= 0x01182A74;
float FloatAddress = 0x011A5B90;
int ValueForReading = NULL;
double DoubleAddress = 0x00FDB0F0;
It's not very common that I see people use UINT_PTR, but it's basically a replacement for stuff including DWORD and is made especially for the 64 bit addressing and also able to hold more information. We also declared the integer 'ValueForReading' to hold the value for ReadProcessMemory (what's below)

Code:
ReadProcessMemory(ProcessHandle, reinterpret_cast<void*>(FByteAddress), &ValueForReading, sizeof(ValueForReading ), nullptr)
We are basically reading 4ByteAddress' or 0x01182A74's value and storing it in the ValueForReading integer. You may also be un-familiar with nullptr which can also be overloaded, which you can use NULL (which is an integer with the value 0), but sadly if you use an old compiler, you may actually need to use NULL.

Code:
std::cout << "Value of 4Byte: " << ValueForReading << ".\n";
Here we actually print ValueForReading's value just to check. Also, the "\n" is an alternative to std::endl or endl.

Code:
UINT_PTR Offsets[] = {0x4c, 0x3b};
Here we're defining the offsets of our address (let's pretend we have offsets) and remember to write them in reverse of how they are in cheat engine (bottom to top).

Code:
WriteProcessMemory(ProcessHandle, reinterpret_cast<void*>(FByteAddress), &Offsets, 2, nullptr);
Here we wrote the value '2' to that address basically, but let's move onto something like writing bytes.

Code:
WriteProcessMemory(ProcessHandle, reinterpret_cast<void*>(FByteAddress), "/0x90/, 1, nullptr);
Here we wrote a nop which translates into 90 bytes (This shows into the Memory Viewer in Cheat Engine).



That is where you will get your bytes from. I won't go too much into detail on Assembly as it's not what I wanted to focus on. A full code can be found down below.

Code:
#include <iostream>
#include <windows.h>

int main(){
	SetConsoleTitle(L"djihjninjinjmu");
	HWND Window = FindWindow(NULL, L"csgo");
	if (!Window){
		return 0;
	}
	else{
		DWORD pID;
		GetWindowThreadProcessId(Window, &pID);
		HANDLE Hproc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pID);
		if(!Hproc){
			return 0;
		}
		else{
			std::cout << "Press F3 to activate.\n";
			for(;;){
				if(GetAsyncKeyState(VK_F3)){
					float Crosshair;
					UINT_PTR CrosshairAddress = 0x44ABC04;
					UINT_PTR Shoot = 0x5C4BB;
					ReadProcessMemory(Hproc, reinterpret_cast<void*>(CrosshairAddress), &Crosshair, sizeof(Crosshair), nullptr);
					if(Crosshair == 0){
						WriteProcessMemory(Hproc, reinterpret_cast<void*>(Shoot), "0x32/0x8B/0x90/0x20/0x01/", 5, nullptr);
						//This writes a special asm code that makes it shoot (it's just like changing its value from 0 to 1 but I preffer using this)
					}
					else if(Crosshair == 1){
						WriteProcessMemory(Hproc, reinterpret_cast<void*>(Shoot), "0x32/0x8B/0x90/0x20/0x00/", 5, nullptr);
						//It doesn't shoot from here
					}
				}
				
			}
		}
	}
}
Could you help me in creating a hack?
Is an online game without much security and the hack is something simple.
Quote Originally Posted by DaniielSanchez View Post
Could you help me in creating a hack?
Is an online game without much security and the hack is something simple.
Sure, tell me the game's name.

Quote Originally Posted by Creative! View Post
This is quite helpful for a beginner like myself. Thanks!
I'm glad
Quote Originally Posted by Tightmarrow View Post
Sure, tell me the game's name.



I'm glad
can you make a hack in RF Omni Server?
Quote Originally Posted by Tightmarrow View Post
Sure, tell me the game's name.



I'm glad


The game is called gunz

And the hack I want to do is this. (This dll no longer works, and I have searched for many dlls of this same but no longer come out)
http://www.mpgh.net/forum/showthread...butterfly-hack



The video explains better what I want to do. (I am looking forward to your response)
Quote Originally Posted by DaniielSanchez View Post
The game is called gunz

And the hack I want to do is this. (This dll no longer works, and I have searched for many dlls of this same but no longer come out)



The video explains better what I want to do. (I am looking forward to your response)
It's pretty hard to tell how to do something just from a video, but you may need assembly for that.

Quote Originally Posted by killingspree888 View Post
This is very informative and gives beginners a good starting point. This is well-structured and detailed.
Thanks, I actually though it was kind of messy, I'm not the best at writing tutorials
Quote Originally Posted by Tightmarrow View Post
It's pretty hard to tell how to do something just from a video, but you may need assembly for that.



Thanks, I actually though it was kind of messy, I'm not the best at writing tutorials
you have Skype? To explain myself better?
This is quite helpful for a beginner like myself. Thanks!
This is very informative and gives beginners a good starting point. This is well-structured and detailed.
Yo im interested in making a undetectable esp hack for csgo. I have really no experience in coding and i didnt know if you could show me the basics. I just want to be able to make a working esp and dont know if that would be possible. If anyone can provide any help PLEASE message me
You should add compiling & injecting.
Otherwise awesome tutorial!
How do i get my code to read my games health and mana bars? i want to be able to keypress at a certain percent of hp/ mana point. Im assuming i create a math equation that converts it to percentages but i really dont know how to code any of this. I am very new but basically i am learning to create a key pressing trainer for an rpg game, buffs on timers, potions at certain percentages and, keypresses to attack. Any help would be greatly appreciated!! i am new, and have no friends that can code.
Quote Originally Posted by Timbojh21 View Post
How do i get my code to read my games health and mana bars? i want to be able to keypress at a certain percent of hp/ mana point. Im assuming i create a math equation that converts it to percentages but i really dont know how to code any of this. I am very new but basically i am learning to create a key pressing trainer for an rpg game, buffs on timers, potions at certain percentages and, keypresses to attack. Any help would be greatly appreciated!! i am new, and have no friends that can code.
You should open cheat engine and:
- Search in 4Byte for an Unknown Initial Value
- Lose HP
- Scan for Changed value
- Don't lose any more HP
- Search for Unchanged Value like 10 times
- Lose HP
- Search for Changed value
And so on, until you get the right address. Then, you can follow this tutorial and do.

for(;{
UINT_PTR HPAddress = 0xaddress;
int HPValue;
if(GetAsyncKeyState(VK_F3)){ // if you pressed f3
ReadProcessMemory(hProc, reinterpret_cast<void*>(HPAddress), &HPValue, sizeof(HPValue), nullptr);
}
}

or something like that
Quote Originally Posted by Tightmarrow View Post
You should open cheat engine and:
- Search in 4Byte for an Unknown Initial Value
- Lose HP
- Scan for Changed value
- Don't lose any more HP
- Search for Unchanged Value like 10 times
- Lose HP
- Search for Changed value
And so on, until you get the right address. Then, you can follow this tutorial and do.

for(;{
UINT_PTR HPAddress = 0xaddress;
int HPValue;
if(GetAsyncKeyState(VK_F3)){ // if you pressed f3
ReadProcessMemory(hProc, reinterpret_cast<void*>(HPAddress), &HPValue, sizeof(HPValue), nullptr);
}
}

or something like that
so i get the address of my health, how do i then convert my health to a percentage?

i would like to have it press a key when my health reaches a certain percentage, or even create a gui that allows me to do it at different percentages. Very helpful though!!!!
Quote Originally Posted by Timbojh21 View Post
so i get the address of my health, how do i then convert my health to a percentage?

i would like to have it press a key when my health reaches a certain percentage, or even create a gui that allows me to do it at different percentages. Very helpful though!!!!
Considering that you already got the right address, you should:

- Right click the address
- Select "Find What Writes to this address"
- Lose HP
- Get the first address you find there and write

WriteProcessMemory(hProc, reinterpret_cast<void*>(HPAddress), "/0x90/, nullptr, nullptr);

I can't tell how that game works and it's really done but putting a nop instruction (0x90 or 90) to the address could stop it from going down.
Posts 1–15 of 29 · Page 1 of 2

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us