Programmer's Wiki
Advertisement

There are many C++ questions and one of them is... how do you use it to hack video games? Well, there is a very simple way. This isn't going to work if you restart the target application though... it's not a pointer although I may make a tutorial on pointer hacking later on.

Definitions of needed variables:[]

There are two main variables needed in this code. HWND and DWORD are very essential for memory allocation of another window. HWND stands for Handle Window and you can also kind of see what it means in the text here: HWND = H WND = Handle WiNDow.

DWORD variables are variables that go through a range of 0 to 42949677295 and can also be a decimal (I got the DWORD definition from Google lol.). They are 32-bit unsigned integers or in other words, they help generate process id's yayyyyyy!!!!!!!!

There are also basic variable types needed to. For example, the int (integer) variable type. The int variable type is a common variable type and is in a percentage of bytes. An integer with a 1 digit value is 1 Byte. Another example of an int/integer variable is a 4 digit integer, also known as 4 Bytes. Basically, the number of digits in an integer variable is the number of Bytes there are. When 100 is translated from integer to Byte, it is equal to 3 Bytes because it is a 3 digit number.

Next are floats. Floats are decimals. For example, 1.5 is a float or 10.05 is a float. Something that you have to know about decimals is that they are always greater than the main digit. For example, 1.5 is also equal to 1.50 and then 1.500 and so on. Even though they may seem different, they are all the same number. Therefore, 1.5 is actually greater than 1.40 since 1.5 = 1.50 and 1.40 < 1.50.

The next variable type on the list is a double variable. Doubles are basically longer versions of floats. A float can be 1.5 or 1.50 or even 1.500 but doubles can be much bigger decimals. For example, a float can't reach the value of 1.382572398572893792837489237589237589734895793825 but a double can. Doubles can also have decimals inside of decimals. For example, 1.5.5.7.4.2.6.8.5 is aloud in a double, but not in a float.

And last but not least, there are strings. Strings can be text inputs. For example, "Hello, World" is a string since it includes text. Strings can be imported to C++ by using the string library. And the best part, you don't have to download any external applications for it! Simply type "#include <string>" at the top of your C++ code and then you can use strings!

Needed functions:[]

The most needed functions are: int main(), WriteProcessMemory(), GetWindowThreadProcessId(), and OpenProcess().

The int main() function creates the main program.

The WriteProcessMemory() function writes to the processes memory address of your choice.

The GetWindowThreadProcessId() function helps find the process id of the target application.

And last but not least, the OpenProcess() function opens the process found by the GetWindowThreadProcessId() function.

Code[]

Here is the part that you've all been waiting for, the code of the program. This is just an example and won't actually work unless modified.

#include <iostream> //Includes iostream (For outputs and etc).
#include <Windows.h> //Includes the Windows header file (For accessing active windows and variable types like the HWND variable and the NULL value).

using namespace std; //Uses the std namespace so that we don't have to type std:: in front of everything lol.

int main() //The main function.
{ //Starts the main function.
    HWND target = FindWindowA(NULL, "Application goes here"); //Connects to the target application in a variable.
    if (HWND == NULL) //Checks if the target application window is currently open.
    {
        cout << "ERROR! The window that is meant to be hacked isn't currently open. Please restart the application and check if the target window is currently open next time." << endl; //Outputs the error.
    }
    else //If the target application is currently open.
    {
        DWORD ProcessId; //Creates Process Id variable.
        GetWindowThreadProcessId(hwnd, &ProcessId); //Gets the process id of the target application and inserts it into the process id variable.
        HANDLE handleApplication = OpenProcess(PROCESS_ALL_ACCESS, FALSE, ProcessId); //Opens the process so that we can write to its memory.
        if (ProcessId == NULL) //Checks if the process isn't valid.
        {
            cout << "ERROR! The window that is meant to be hacked isn't currently open. Please restart the application and check if the target window is currently open next time." << endl; //Outputs the error.
        }
        else //If process is valid.
        {
            int value = 100; //New value for memory address.
            WriteProcessMemory(handleApplication, (LPVOID)0x00, &value, sizeof(value), 0); //WriteProcessMemory(handleApplication, (LPVOID)0x00 Memory Address goes here, &value, sizeof(value), 0); writes to the processes memory to hack it.
        }
    }
    
    return 0; //Returns the value to the compiler.
} //Ends the main function.

As you can clearly see in the WriteProcessMemory() function, there is nothing after the 0x00 text in the LPVOID parameter accessing area. That is where your memory address goes. To allocate memory addresses, you can use a tool called Cheat Engine, or possibly make your own tool using pointers. Cheat Engine can also be used to hack memory addresses and not only allocate them, so if you are to lazy to program all of this, just use Cheat Engine (Virus free download for Cheat Engine here: http://www.mediafire.com/file/3312a8tqk8au1xq/CE_6.4.zip/fi.).


Advertisement