Hi guys,
in this tutorial I will be trying to let newbies understand how to start into game hacking!
Here I will be using Microsoft Visual Studio 2015, so in my code there a header ( "stdafx.h" ) which won't be used by Eclipse users for example.
Let's suppose we are playing TeknoMW3 and we wanna have a C++ code which allows us to have the custom classes: we could be in a iSnipe lobby without the possibilities to play with normal guns ( obviously ). This could be the situation:
http://imgur.com/fenprC9
As you can see I have only iSnipe classes and the custom classes are locked.
I basically want to unlock them using a C++ code done by myself.
We will have to act into an address which can be found somehow, but this ain't the goal of this tutorial so I will just tell you that the right address is 06BCE724 and the normal value ( classes locked is ) 1.401298464E-45 [ FLOAT ] and the value to have the classes unlocked is 0 [ FLOAT ].
However, here starts the tutorial, which ( I remember ) is for newbies ( pro hexors won't take much advantages here ):
Code:
#include "stdafx.h"
#include <iostream>
#include <Windows.h>
using namespace std;
This the " starting package " needed to be able to code our hack and, if you are watching this tutorial, you are supposed to be at least informed about those stuffs.
-----------------------------------------------------------------------------------------------------------------------------------------
Here starts our program, saying " int " we define that a value will return.
-----------------------------------------------------------------------------------------------------------------------------------------
Code:
HWND Window = FindWindow(NULL, L"Call of Duty®: Modern Warfare® 3 Multiplayer");
In order to know where we are going to act, our program must know the name of the window; here, for our example, we will choose " Call of Duty®: Modern Warfare® 3 Multiplayer ", but we could've chosen also " Minecraft " or " CS:GO "; it depends on what we are coding for. The L before the name is for compatibilities reasons, for the moment just put it and everything will work fine.
-----------------------------------------------------------------------------------------------------------------------------------------
Code:
if (!Window) {
cout << "Cannot find the window." << endl;
return 0;
}
Well, What if I run my program without having the right window opened? This code is very useful for us because I say to my code: if the window defined with " FindWindow " is NULL, or zero, it means that Visual Studio has not been able to find it, so, in this case, I will have an output which makes me notice it. If I had not written anything but return 0, my program would have stopped without giving any reason: this is the meaning for that " cout<<.. ".
-----------------------------------------------------------------------------------------------------------------------------------------
Code:
else {
DWORD pID;
GetWindowThreadProcessId(Window, &pID);
HANDLE Hproc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pID);
To be honest, we are mostly interested on what the code does if he does find the window requested, so we define the " else " part of the previous if ( " If the value of Window is not zero .. " ). In particular here we define a process which will be recognised by his own ID, then we want to handle this process.
-----------------------------------------------------------------------------------------------------------------------------------------
Code:
if (!Hproc) {
cout << "Cannot open the process." << endl;
return 0;
}
As well as the window also Hproc ( the process ) could be unfindable, so we do the same thing that we did before: " if the process is NULL, or zero, stop the debugging and tell me the reason ( I can not open the process ) ".
-----------------------------------------------------------------------------------------------------------------------------------------
Code:
else {
cout << "Press F5 to activate/deactivate the FORCE CLASS." << endl;
cout << "Press F7 to exit from the FORCE CLASS program." << endl;
while(1) {
Well, here we are going to start our hack: in particular everything starts with a " else ", because, as well as we did with the Window, if we find the process, we must do something else. What we are going to do effectively is to give an output, in order to let the user know what he has to do to use our hack; in particular I tell him to press F5 to active, or deactivate ( if it had previously been activated ), the program; moreover he can also press F7 to stop the program. The last command is " while(1) ", which is a loop that allows the program to run endless, or at least till the user press F7.
-----------------------------------------------------------------------------------------------------------------------------------------
Code:
if (GetAsyncKeyState(VK_F5)) {
float ForceClass;
float ClassesForced = 0;
float ClassesUnforced = 1.401298464E-45;
UINT_PTR ForceClassAddress = 0X06BCE724;
" GetAsyncKeyState ", sostantially allows us to know if he is pressing F5; so, if he presses it, the program does what there is inside this block. So, we define what we need: the operative values are float, in fact at the beginning I told you two float values that we would've used later ( now ). We don't know the value of ForceClass ( we want to find it ) but we know that when the classes are locked, our address ( ForceClassAddress ) has a value of 1.401298464E-45, while if the classes are forced it has a value of 0.
-----------------------------------------------------------------------------------------------------------------------------------------
Code:
ReadProcessMemory(Hproc, (LPVOID)(ForceClassAddress), &ForceClass, sizeof(ForceClass), NULL);
Here we find out what is the value inside our address, so we will be able to understand if the classes are locked or unlocked, so if we have to lock them or to unlock them; in order to do it we use " ReadProcessMemory ", which acts in our process ( Hproc ) and put the value of our address into the variable ForceClass.
-----------------------------------------------------------------------------------------------------------------------------------------
Code:
if (ForceClass == ClassesUnforced)
WriteProcessMemory(Hproc, (LPVOID)ForceClassAddress, &ClassesForced, sizeof(ClassesForced), NULL);
After have putted a value in it, if ForceClass embodies the value of ClassUnforced ( which means that the class are still locked ) we want to unlock them, so we write in the memory ( using " WriteProcessMemory " ) that the value inside ForceClassAddress must be the same of ClassForced ( we are effetively forcing the classes now ), so we are activating our hack.
-----------------------------------------------------------------------------------------------------------------------------------------
Code:
else if (ForceClass == ClassesForced)
WriteProcessMemory(Hproc, (LPVOID)ForceClassAddress, &ClassesUnforced, sizeof(ClassesUnforced), NULL);
}
If ForceClass have the zero value, therefore the same of ClassesForced, it means that our hack has already been activated, and our classes are unlocked; what we are going to do now ( obviously if the user presses F5 having the hack activated ) is to write in the memory ( still using " WriteProcessMemory ) that our address will now have the ClassesUnforced value ( we are deactivating the hack. Then I close the block.
-----------------------------------------------------------------------------------------------------------------------------------------
Code:
if (GetAsyncKeyState(VK_F7))
return 0;
As we wrote before in the output, if the user wants to close our hack, sostantially stopping the endless loop defined before ( while(1) ), he just has to press F7, and everything will stop working.
-----------------------------------------------------------------------------------------------------------------------------------------
Then of course you will have to close all the parenthesis that you've opened before and put " return 0 " before the parenthesis which closes the main, because mind that we've written " int main() ", therefore we are obliged to give a value at the end.
However this is the complete code ( I have added some functions and some stuffs which make the output more nice-looking ):
Code:
#include "stdafx.h"
#include <iostream>
#include <Windows.h>
using namespace std;
/* --> LAYOUT PROCEDURES <-- */
void SetColor(short Color) {
HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hCon, Color);
}
void Clean() { system("CLS"); }
void SystemDimensions() { system("mode con lines=10"); system("mode con cols=52"); }
int main() {
SystemDimensions();
SetConsoleTitle(L"garupede-->FORCE_CLASS");
HWND Window = FindWindow(NULL, L"Call of Duty®: Modern Warfare® 3 Multiplayer");
if (!Window) {
cout << "Cannot find the window." << endl;
return 0;
}
else {
DWORD pID;
GetWindowThreadProcessId(Window, &pID);
HANDLE Hproc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pID);
if (!Hproc) {
cout << "Cannot open the process." << endl;
return 0;
}
else {
SetColor(11);
cout << "\tWelcome to the" << endl << "\t\tgarupede" << endl << "\t\t\tExtreme Switcher!" << endl;
SetColor(14);
cout << "Press F5 to activate/deactivate the FORCE CLASS." << endl;
cout << "Press F7 to exit from the FORCE CLASS program." << endl;
while(1) {
if (GetAsyncKeyState(VK_F5)) {
float ForceClass;
float ClassesForced = 0;
float ClassesUnforced = 1.401298464E-45;
UINT_PTR ForceClassAddress = 0X06BCE724;
ReadProcessMemory(Hproc, (LPVOID)(ForceClassAddress), &ForceClass, sizeof(ForceClass), NULL);
if (ForceClass == ClassesUnforced)
WriteProcessMemory(Hproc, (LPVOID)ForceClassAddress, &ClassesForced, sizeof(ClassesForced), NULL);
else if (ForceClass == ClassesForced)
WriteProcessMemory(Hproc, (LPVOID)ForceClassAddress, &ClassesUnforced, sizeof(ClassesUnforced), NULL);
}
if (GetAsyncKeyState(VK_F7))
return 0;
}
}
}
return 0;
}
This code will let you have an output like this:
http://imgur.com/IsG57xZ
And, as you can see in the pic below, our classes will be seriously unlocked and ingame we will be use them:
http://imgur.com/PJ67zvi
http://imgur.com/qbqYxq8
I hope you will appreciate this tutorial, for anything just comment below or directly contact me on skype or here in MPGH. See you 