

InterviewSolution
1. |
Solve : Game Cheat Memory Hack Question? |
Answer» I have been using game cheats for years, most of which were easter egged in there intentionally by the programmer such as (showmethemoney - 'starcraft' ) or cheats implemented by saving game state to an alternate location and always writing good changes to a single save file to boost gear etc ( Diablo 1 & 2 for example 'single-player') I also had the Game Genie for NES way back. Data stored in RAM (Random Access Memory) is not stored at randomly chosen locations. A program (or rather, the programmer) knows exactly where all its data is stored, including all the variables. If you happen to know which location you want to change, you can just target that one value. Question I have with this is if you have two instances of the same program running the address in the Ram will be different to where the variable is stored in both instances. And on a multitasking system depending on what loads first from second as well as the amount of Ram that one user has say 1GB over another user with 4GB will likely have the variable tied with the game located in different locations in the memory .... so there must be a fingerprint sort of speak to search for before altering the value ... right? If so how do they find this fingerprint to know where the data is located in a multitasking environment? If there are two instances of a program each will have its own private data memory. When a program is run the operating system allocates it with a unique program ID and also reserves memory for it. The program neither knows nor CARES what the actual memory addresses are. The OS will allocate the program blocks of memory and the program code will know the start address of each block and keep track of the contents. Cheat engines for a particular game work because the engine author knows the game program inside out and knows how to query the OS to find out the block locations and once that is know can calculate where the various data values are located. All Processes have their memory SEPARATED. As far as each process is concerned, they are the only thing even in memory. They allocate memory and are given pointers to their own Virtual Address Space, which maps to either RAM itself or the pagefile. Most games either store their information in the same places in Virtual Memory or have some other sort of distinctive way of finding where things are in memory externally, and cheat programs simply open the process and read and write to the game program's address space. I guess one way to show what me and Salmon are describing is with a small example. Let's pretend we have a small little text adventure. The text adventure stores your inventory. Let's try to keep things as simple as possible here, though that might be tricky. Usually, an inventory item would have quite a bit of information. Let's stick to a simple example- each item has a item ID, and a "damage" value, which might work with armor or something. these might be 32-bit integers, so each item is 8 BYTES of memory. Usually such an inventory listing will probably be used in several places- as a list in each "room" to show the contents of the room, as a list for each player to show their inventory, and as a list on each enemy as well, to determine what they will drop. If the program is written in C, C++, or another compiled language, usually the order that things are initialized will determine where in Virtual Memory the variables are actually stored. If we go with the simple case that the Player structure is initialized first, that means that the Player structure will always start at a given Virtual Memory address in the game process. a Game cheat program can easily take advantage of this- if it knows the structure, it can wander through the memory itself and see things; for example, the Player Structure would likely contain a pointer to an array of INVITEM's for the inventory. the cheat program can use the Process Memory FUNCTIONS to read from the Player structure location (which will be fixed for each compile, most likely); then it can find the pointer to the array, which will be a pointer within the Virtual Memory address space; it can then continue and read that data and parse and interpret it as needed; if desired even changing, say, item IDs within the process memory on the spot to change items. Thank you both for explaining with detailed information. Quote Cheat engines for a particular game work because the engine author knows the game program inside out and knows how to query the OS to find out the block locations and once that is know can calculate where the various data values are located. lit the light above my head, and BC's content BRIGHTENED it Now I know how its done. MANY THANKS!!! |
|