• Amused
  • Angry
  • Annoyed
  • Awesome
  • Bemused
  • Cocky
  • Cool
  • Crazy
  • Crying
  • Down
  • Drunk
  • Embarrased
  • Enraged
  • Friendly
  • Geeky
  • Godly
  • Happy
  • Hateful
  • Hungry
  • Innocent
  • Meh
  • Piratey
  • Poorly
  • Sad
  • Secret
  • Shy
  • Sneaky
  • Tired
  • Wtf
  • At Work
  • CodenzHub
  • Coding
  • Deejaying
  • Donating
  • Drinking
  • Eating
  • Editing
  • Hacking
  • Hate Mailing
  • Jamin'
  • Lagging
  • Live Streaming
  • Lurking
  • No Status
  • Pawning
  • PC Gaming
  • PS Gaming
  • Raging
  • Reversing
  • Sleeping
  • Steam Gaming
  • Trolling
  • TwitchStreamer
  • Vodka!
  • Watching TV/Movie
  • Xbox Gaming
  • Youtuber
  • Zombies
  • Page 1 of 2 12 LastLast
    Results 1 to 10 of 13
    1. #1
      Administrator
      Hacked By Jesus
       
      Reversing
       
      [GH]Rake's Avatar
      Join Date
      Jan 2014
      Location
      USA
      Posts
      2,954
      Thanks (-->)
      637
      Thanks (<--)
      885

      Post Reverse Engineer C++ Games Game Hacking Tutorial

      John Kittz
      I am writing this tutorial to address the majority of issues people have understanding game hacking. We all started this journey because we wanted to cheat in a video game we were playing. Well guess what buddy, if you don't know how to program a video game, you aren't going to understand how to reverse engineer one. Think of it like this:

      You've been driving a car for the past 3 years. Now here's a wrench, I want you to install a new idle air control valve, 3 port electronic boost control solenoid and a limited slip differential with active yaw and stability control. You can poke at it all day, check the dipstick and kick the tires all day but you aren't gonna do xxxx. Wouldn't it make sense to learn how a car is built first?

      So let's learn how a game written with object oriented programming works and how your operating system and CPU execute it. Remember folks a pointer isn't a unicorn, an offset is just a number & DMA is not witchcraft. All these things can be very simply explained, learn 'em now or suffer the consequences :P


      //Example Game
      class playerClass
      {

      int health;
      float xposition;
      float yposition;
      float zposition;

      }

      playerClass(int specialHealth)
      {
      health = specialHealth;
      xposition = 5.0f;
      xposition = 10.0f;
      xposition = 0.0f;

      return newPlayerObject;
      }

      void decreaseHealth(playerClass* player)
      {
      player->health = player->health - 10;

      }

      playerClass NPC_Bob;

      playerClass * localPlayer = new playerClass(100);
      playerClass * playerArray[3];

      int main()
      {

      //Game begins

      //Bob comes alive and is placed in the world
      NPC_Bob.health = 100;
      NPC_Bob.xposition = 20;
      NPC_Bob.yposition = 55;
      NPC_Bob.zposition = 200;


      //3 players join
      playerArray[0] = new Player(500);
      playerArray[1] = new Player(400);
      playerArray[2] = new Player(300);

      //Player[0] shoots localPlayer
      decreaseHealth(localPlayer);


      return 0;
      }

      Let's start off with a little knowledge:
      int, float etc... are data types intrinsic to C++. A pointer is a compound datatype, generally it is a 4 byte variable that stores an address.
      By using a data type specifier such as "int", the compiler/CPU knows how to read the values of the variables. A integer and a float are both 4 bytes but are read in a different way by the CPU to discern their value.

      So lets look at each piece of this program:


      class playerClass
      {

      int health;
      float xpos;
      float ypos;
      float zpos;

      }

      A class is a fundamental concept of programming. An object is created from a class and is a fundamental concept of Object Oriented Programming. The variables contained in the class are called member variables.

      By declaring this class the compiler knows these things:
      There are 4 member variables
      Each member variable is 4 bytes in size
      The total class size is 16 bytes

      Each playerClass object created is 16 bytes in size.

      The compiler takes this class object and takes the information that it knows about it's class to map it to memory and define how it's member variables will be accessed.
      When you create an object from this class it is referred to as instantiating a class object. When you instantiate a class object it is alotted a space in memory with the size of the class, in this case 16 bytes. Classes and objects are only important to programmers and compilers, the classes and identifiers are all stripped away and everything is assigned an address or an offset relative to an address. The compiler takes the class objects and maps the member variables into a contiguous space of memory. The machine code is created by the compiler to access the member variables using relative offsets based on data type size and sequence in memory.
      Remember your CPU runs in binary, our brains can't comprehend these detailed values, so we use hexadecimal as a representation that our brains can more easily differentiate.


      playerClass NPC_Bob;

      A playerClass object is instantiated with the identifier NPC_Bob.
      This player object is instantiated in the global namespace, meaning it is mapped to memory before any game code is ran, meaning we have virgin memory space, this object can be staticly placed in memory. It will be located in the same memory position every single time the game is ran. Ding ding ding that's right, a static memory address.

      Because the object size is 16 bytes he is alloted 16 bytes of memory at let's say 0x100.
      The address of the player object is 0x100. Ding Ding Ding it's a "PlayerBase" or whatever preschool babble you want to call it

      There are normally no buffers preceding the class variables, or in between the member variables that wouldn't be efficient. But padding is possible, so don't rule it out. Also if a class has virtual functions, the first variable at offset 0x0 will be a pointer to the vTable aka Virtual Function/Method Table.

      The first member variable "int health" is located at 0x100. You may ask, but how can the object and the first member variable have the same address? Remember what was said earlier, the CPU doesn't care about classes or objects. It eats and sh1ts numbers. It doesn't care that NPC_Bob is a playerClass object, it only cares what addresses the member variables are stored in and what size they are and what x86 instructions to use on them. So the address of the player object is the address of it's first member variable.

      Therefore:

      Addresses:
      Object = 0x100
      -int health = 0x100
      -float xpos = 0x104
      -float ypos = 0x108
      -float zpos = 0x10c

      Offsets:
      -int health = 0x0
      -float xpos = 0x4
      -float ypos = 0x8
      -float zpos = 0xc


      Any time the game code needs to access these variables, it adds the offset of the variable to the address of the object


      NPC_Bob.health = 100;

      When accessing a member variable of a player class you use the "dot operator" to access it. The dot operator is used by the compiler to properly access the class variables in memory.
      The compiler turns this assignment into x86 instructions to be fed to the CPU. The CPU doesn't know it's variable is named "Health", all it knows is that it's the first 4 byte variable at the address 0x100.

      The compiler might assemble this assignment into these x86 instructions:

      mov eax, 0x100;
      add eax, 0x0;
      mov [eax], 0x64;

      Move the address of the player object into register EAX
      Add offset 0x0 to EAX and store the result in EAX. This sets EAX to the memory address where health is stored.
      Move the hex value 0x64(this is 100 in decimal) into the address that EAX holds, as opposed to moving it into the EAX register.

      but more than likely it will just be:
      mov eax, 0x100;
      mov [eax], 0x64;

      playerClass * localPlayer = new playerClass(100);

      localPlayer is the identifier for a variable that is of type Pointer. A pointer is a 4 byte datatype, in memory it will simply be a 4 byte section of memory that contains an address. The pointer points to an object of type playerClass, but the only purpose that serves the compiler is to know how to access member variables of that object and how functions will operate on it. The only way to know what data type a pointer points to is by reversing instructions/functions that access it.
      This particular line of code creates a playerClass pointer named localPlayer that points to a newly created playerClass object that was allocated on the heap because of the new keyword. This is a classic example of a dynamic memory address. The address pointed to by localPlayer will be a different address everytime this line of code is executed. You need to find the address of the pointer and read the address that it holds to find the dynamic address. This line of code is in the global namespace of the games executable so the pointer itself will be a static address, that points to the allocated playerObject on the heap.

      to be continued....

    2. #2
      Newbie
      learn me C++
       
      Feeling Normal
       
      programming's Avatar
      Join Date
      Feb 2016
      Posts
      8
      Thanks (-->)
      0
      Thanks (<--)
      0
      hello , thanks for this useful thread i have 1 question bro why you used class in playerclass ?
      can we use struct ?
      thank you

    3. #3
      Administrator
      Hacked By Jesus
       
      Reversing
       
      [GH]Rake's Avatar
      Join Date
      Jan 2014
      Location
      USA
      Posts
      2,954
      Thanks (-->)
      637
      Thanks (<--)
      885
      Quote Originally Posted by programming View Post
      can we use struct ?
      Yes, the only difference between a struct and a class is that a class defaults the member variables to private, meaning only member functions can access them

    4. #4
      Newbie
      learn me C++
       
      Feeling Normal
       
      programming's Avatar
      Join Date
      Feb 2016
      Posts
      8
      Thanks (-->)
      0
      Thanks (<--)
      0
      Thank you for explaining
      there still 1 question i really want from you to answer it for me really important
      i start my first semester in my university my major is computer science
      the problem is i heard a lot of people saying that CS is useless in university and it wont let you learn only the basics that mean after the university i can't program that good game or hack is that really true bro ? i really don't want to waste 3 years in university then i can't even program a hack or game..
      thank you

    5. #5
      Sober linux neb
      High in dem codez
       
      Hacking
       
      Alex's Avatar
      Join Date
      Nov 2015
      Posts
      152
      Thanks (-->)
      10
      Thanks (<--)
      18
      Quote Originally Posted by programming View Post
      Thank you for explaining
      there still 1 question i really want from you to answer it for me really important
      i start my first semester in my university my major is computer science
      the problem is i heard a lot of people saying that CS is useless in university and it wont let you learn only the basics that mean after the university i can't program that good game or hack is that really true bro ? i really don't want to waste 3 years in university then i can't even program a hack or game..
      thank you
      Games and Hacks can be made with several languages, including C# and C++. but C/C++ can be used for more complex stuff, and is actually easier to write than C# in some bigger projects.

      I recommend C/C++, in any case.

      EDIT: Most companies use C or/and C++.
      #KBackForAWhile

    6. #6
      Newbie
      learn me C++
       
      Feeling Normal
       
      programming's Avatar
      Join Date
      Feb 2016
      Posts
      8
      Thanks (-->)
      0
      Thanks (<--)
      0
      great , that what i really want but does the universities teach me enough to make my hack or aimbot or anything i want or when i finish my university i need learn how to make hack ?

    7. #7
      Sober linux neb
      High in dem codez
       
      Hacking
       
      Alex's Avatar
      Join Date
      Nov 2015
      Posts
      152
      Thanks (-->)
      10
      Thanks (<--)
      18
      Quote Originally Posted by programming View Post
      great , that what i really want but does the universities teach me enough to make my hack or aimbot or anything i want or when i finish my university i need learn how to make hack ?
      Basically yes, but usually you need to apply some self-taught shit into your codenz. But if you like hacking overall, it won't be hard to succeed at learning it.

      Idk if uni goes over memory editing, but that's the thing you want to focus on if you're planning to do hacks.
      #KBackForAWhile

    8. #8
      Newbie
      learn me C++
       
      Feeling Normal
       
      programming's Avatar
      Join Date
      Feb 2016
      Posts
      8
      Thanks (-->)
      0
      Thanks (<--)
      0
      Quote Originally Posted by Alex View Post
      Basically yes, but usually you need to apply some self-taught shit into your codenz. But if you like hacking overall, it won't be hard to succeed at learning it.

      Idk if uni goes over memory editing, but that's the thing you want to focus on if you're planning to do hacks.

      Thank You Bro i will do me best

    9. #9
      Jr.Coder
      Still noob
       
      Raging
       
      MasterG's Avatar
      Join Date
      Mar 2015
      Location
      Idk.
      Posts
      97
      Thanks (-->)
      13
      Thanks (<--)
      14
      Well, when will you continue that ?

    10. #10
      Newbie
      Learning to hack games!
       
      Feeling Normal
       
      samoray's Avatar
      Join Date
      Apr 2016
      Posts
      1
      Thanks (-->)
      1
      Thanks (<--)
      0
      CheatTheGame
      Thank you for the wonderful tutorial, I really enjoyed reading it.
      when will you intend to continue your serie... I can hardly wait for the next one

    Page 1 of 2 12 LastLast

    Similar Game Hacker Threads

    1. [VideoTutorial] How to Reverse Engineer with IDA Pro Disassembler
      By [GH]Rake in forum GH Hack Video Tutorials
      Replies: 14
      Last Post: 01-11-2017, 11:52 PM
    2. [VideoTutorial] C++ Detour / Hooking Function Tutorial for Game Hacking
      By [GH]Rake in forum GH Hack Video Tutorials
      Replies: 26
      Last Post: 12-29-2016, 06:48 PM
    3. [VideoTutorial] How To Hack Android Games with Game Guardian Tutorial
      By binomi in forum Binomi's Android Hacking
      Replies: 1
      Last Post: 08-05-2016, 09:42 AM
    4. [VideoTutorial] How To Hack Android Games Game Hacker Tutorial - Zombi Waves
      By binomi in forum Binomi's Android Hacking
      Replies: 0
      Last Post: 04-17-2016, 10:12 AM
    5. [VideoTutorial] Game Hacking with Reclass Tutorial
      By [GH]Rake in forum GH Hack Video Tutorials
      Replies: 9
      Last Post: 04-04-2016, 03:18 PM