Results 1 to 8 of 8
  1. #1
    headsup's Avatar
    Join Date
    Apr 2009
    Gender
    male
    Location
    Pa
    Posts
    1,232
    Reputation
    8
    Thanks
    208
    My Mood
    Cynical

    Post """Basic C++ Game Hacking"""

    (THIS TUT REQUIRES A BASIC KNOWLEDGE OF C++ SUCH AS FUNCTIONS AND VARIABLES)

    THIS IS MY TUT I TAKE FULL CREDIT'S!


    First of all, this tutorial assumes a basic understanding of C++ and game hacking. You don't need to be great, but you'll need to know what you're doing or you'll have no idea what I'm talking about. This guide will also not address a single hack, but more a general approach to making a hack using C++. This leaves the responsibility of developing the program itself to you, the reader. This hack will address only writing to memory, and not hotkeying and dialogs. With that out of the way, we can get to the meat of this document. You don't need anything special other than a compiler, I recommend MS Visual C++..


    To start, I'll list out the functions that we'll be using, and explain each briefly. The function that we'll use to actually write to memory is Write Process Memory. Its parameters in order are a handle to the process to write to, the address to write to, the data to be written, the length of the data to be written to in bytes and finally, a pointer to a variable to store the actual number of bytes successfully written. Write Process memory returns 0 if it fails, and a nonzero value if it succeeds.


    The next function we'll be using is OpenProcess. This is used to get the process handle we pass to WriteProcessMemory. The parameters taken by OpenProcess are the access level to the process (You need at least write access to use WriteProcessMemory), the inheritance flag and the process id of the process to open. This function returns the handle to the process.

    Since we don't have a process handle, we'll need another function to grab it. This function is GetWindowThreadProcessId. Despite it's apparently complex name, it only takes two parameters, a handle to the window for which you want the process id and a pointer to the variable that will store the process id. This function returns the thread id of the thread that created the window.

    Once again, we don't have a necessary parameter, the window handle. To get this, we use FindWindow. This also only take two parameters, the classname of the window to be found and the window name. The classname can be ignored, but it's best to go ahead and include it if at all possible. This function returns a handle to the window found.


    Phew, that took a while, three functions just to be able to use WriteProcessMemory. Don't worry, it's all pretty simple from here. All that's left to do is actually construct our hack. I'll assume a basic understanding of how a simple C++ application works from this point forward. If you don't know how to make a simple C++ program, just stop reading now.Before we can use WriteProcessMemory, we must grab the process handle, so we call the functions in the reverse order I listed them:

    1.FindWindow
    2.GetWindowThreadProcessId
    3.OpenProcess
    4.WriteProcessMemory



    It's best to make sure that each function succeeds, otherwise your hack may not work when you expect it to. This can be accomplished with an if or a while. If you use a while loop, you can start up the hack before the game is loaded, and it will continue trying to open the process until it succeeds. Here is an example of a while loop that will wait until the game starts.



    Code:
    #include < w i n d o w s . h >
    #include < i o s t r e a m >
    
    using namespace std;
    int main()
    {
    // declare the variables
    
    DWORD pid;
    HANDLE ProcessHandle;
    HWND hWnd;
    LPVOID address = (void*) 0xoffset;
    
    hWnd = FindWindow(NULL, "GAMENAME"); //Grab a handle to the window
    
    while(!hWnd) //If the handle is null...
    {
    Sleep(50); //Wait 50 miliseconds..
    hWnd = FindWindow(Null,"GAMENAME");//and try again
    }
    
    GetWindowThreadProcessId(hWnd,&pid);//Get a process id
    ProcessHandle = OpenProcess(PROCESS_ALL_ACCESS,0,pid);//And grab the process handle
    
    WriteProcessMemory(ProcessHandle,(void*)address,&DataToWrite,DataLength,&BytesWritten);
    
    system("PAUSE");
    return0;
    }

    Moving right along, we are now at the actual memory writing. The way in which you use WriteProcessMemory is pretty simple.


    Code:
    WriteProcessMemory (ProcessHand,(void*)AddressToWriteTo, & DataToWrite,DataLength,&BytesWritten);

    You can probably figure everything out but the (void*) part. That just tells the compiler that the following variable is a pointer that points to void, or nothing in other words. This makes sense because the address you will be writing to will not point to anything in your hack, but to something in the game. When declaring the address you are writing to, you must preceed the address with (void*) or else the compiler will think you're trying to pass a const int to a void pointer.

    This is all that will be covered in this tutorial, and I'm sure that you all still have quite a few questions such as hotkeys and dialogs. Those are subjects best left to more specialized tutorials, and there are plenty of documents out on the internet that do a wonderful job of explaining the subjects, far better than anything I could produce at any rate.


    I don't understand how to declare the & Data To Write,Data Length,& Bytes Written
    variables for the parameters in the WriteProcessMemory function so i cant help you with that. Maybe a coder could post how?




    If i helped you, Or you thought this was a good tutorial,

    Thank me!

  2. The Following 6 Users Say Thank You to headsup For This Useful Post:

    andrewgeltz (06-08-2009),chrissy (06-08-2009),Mat17 (06-08-2009),MetalGr (06-08-2009),Moneyman4265 (06-08-2009),riceking (06-08-2009)

  3. #2
    homil07's Avatar
    Join Date
    Dec 2008
    Gender
    male
    Location
    Canada
    Posts
    46
    Reputation
    10
    Thanks
    8
    nice one i am trying to learn this program lol.

  4. #3
    riceking's Avatar
    Join Date
    Oct 2008
    Gender
    male
    Location
    b
    Posts
    478
    Reputation
    12
    Thanks
    301
    My Mood
    Amazed
    Quote Originally Posted by homil07 View Post
    nice one i am trying to learn this program lol.
    >.> how do you do that without knowing any addys,

    so this tutorial is basically CheatEngine but undetected, this program would only work on simple hacks... I like it =) very nice tutorial, are you going to continue the tutorial? I wanna learn D3D game hacking


    [img]https://i37.photobucke*****m/albums/e52zies/Rainbow.png?[/img]


  5. #4

  6. #5
    headsup's Avatar
    Join Date
    Apr 2009
    Gender
    male
    Location
    Pa
    Posts
    1,232
    Reputation
    8
    Thanks
    208
    My Mood
    Cynical
    Cheat engine sorta i guess but a little more advanced. You could code simple hacks yes and more advanced ones...

  7. #6
    Obama's Avatar
    Join Date
    Dec 2008
    Gender
    male
    Location
    The Black house
    Posts
    22,195
    Reputation
    870
    Thanks
    6,076
    My Mood
    Cool
    You didn't make this. Copy n paste. Make sure to give credits next time. Ive seen this tutorial on many occasions on a different site.

  8. #7
    slayrofevil's Avatar
    Join Date
    Sep 2008
    Gender
    male
    Location
    im lost =(
    Posts
    154
    Reputation
    10
    Thanks
    43
    this is cool. now all i need to do is read it...

  9. #8
    Toymaker's Avatar
    Join Date
    Feb 2008
    Gender
    male
    Location
    Hannah, Montana
    Posts
    659
    Reputation
    14
    Thanks
    193
    My Mood
    Amused
    You didn't make this. Copy n paste
    Indeed, I know the source even, where he found it.

    Quote Originally Posted by riceking
    >.> how do you do that without knowing any addys,
    so this tutorial is basically CheatEngine but undetected, this program would only work on simple hacks...
    Quote Originally Posted by headsup
    Cheat engine sorta i guess but a little more advanced. You could code simple hacks yes and more advanced ones...
    Holy...You two have no clue what you're talking about. Cheat Engine is a tool used for memory searching. It's extra features for 'hack making' are piss poor. The cplusplus code he ripped here, has the potential to be a real hack, more useful and powerful. You two have it all backwards, you see. Now...headsup, remove the aws link in your signature before I use it as an excuse to ban you. Look at my example where I use similar code: https://www.mpgh.net/forum/17-tutoria...ing_101_a.html I'd like to say if you are trying to code on MPGH, you need to have some integrity and more knowledge before sharing or: you might just be misleading people.
    Last edited by Toymaker; 06-08-2009 at 12:49 PM.

Similar Threads

  1. [Tutorial] Basic C++ Game Hacking (Memory Editing)
    By Tukjedude in forum C++/C Programming
    Replies: 17
    Last Post: 06-05-2010, 08:23 AM
  2. [Vid tut] Basic Game Hacking
    By Matrix_NEO006 in forum Programming Tutorials
    Replies: 5
    Last Post: 01-02-2010, 10:43 AM
  3. Is Visual Basic good for game hacking?
    By Huuye in forum General Hacking
    Replies: 0
    Last Post: 08-18-2009, 05:49 PM
  4. """Basic C++ Game Hacking"""
    By headsup in forum Combat Arms Hacks & Cheats
    Replies: 5
    Last Post: 06-08-2009, 08:57 AM
  5. Game Hacking IMPOSSIBLE IN VISTA?
    By Dave84311 in forum General Game Hacking
    Replies: 13
    Last Post: 01-09-2006, 08:58 PM

Tags for this Thread