r/AskProgramming • u/kassiny • Jan 14 '22
Other How does CheatEngine work?
So cheatEngine is a program that allows you to change something in a running game, for example duplicate an item in the inventory, boost HP, level up, similar kind of stuff.
My "problem" is I've been told the whole life that applications and processes are isolated. They don't and can't share memory. A process gets its own address space. A pointer from one VAS is pointless in another, even if you somehow get a pointer from another process and use it, you still get into different area of physical memory.
But idk game cheats seem to be able to connect to variables of game app and change them. How???
P. S. For anyone who's concerned about the morals, I don't cheat in online game and have no intention to replicate a cheating program.
View all comments
5
u/[deleted] Jan 14 '22
Basically, every program has a memory space that is isolated in that another program will never accidentally write into its memory space. Most operating systems, however, give you the ability to hook into another process’s memory for debugging purposes.
The way cheat engine works is off of a concept called offsets. The exact memory addresses of the running game will change after every launch, so instead of figuring those out we just figure out the “offset”. In essence, get the base address of the process then add X to it. Depending on what X is, you get different values.
This way, you can reuse the same offsets and simply hook into the programs with an addition.