How do programs that edit memory of other processes work, such as Cheat Engine and iHaxGamez? My understanding is that a process reading from (let alone writing to) another process' memory is immediate grounds for a segmentation fault.
-
1You mention 'Cheat Engine' - does that mean you're only interested in Windows? – Andrew Edgecombe Nov 02 '10 at 23:11
-
Pedantic, but I'd like to point out that "segmentation fault" doesn't actually mean "any memory error". – erjiang Nov 02 '10 at 23:15
-
I'm mostly interested in Linux, actually. – Delan Azabani Nov 02 '10 at 23:32
4 Answers
Gaining access to another processes memory under linux is fairly straightforward (assuming you have sufficient user privileges).
For example the file /dev/mem
will provide access to the entire memory space of cpu. Details of the mappings for an individual process can be found in /proc/<pid>/maps
.
Another example has been given here.

- 79,602
- 28
- 170
- 210

- 39,594
- 3
- 35
- 61
-
1/dev/mem isn't going to be very useful, even when examining /proc/pid/maps or /proc/pid/pagemap to find out where to access. What you probably want is /proc/pid/mem instead, which is the process's virtual memory rather than the physical memory. – MarkR Nov 03 '10 at 09:49
The operation system's hardware abstraction layer usually offers functions to manipulate the memory of other processes. In Windows, the corresponding functions are ReadProcessMemory and WriteProcessMemory.

- 31,821
- 4
- 39
- 33
It has no reason to segfault; OS (kernel, ...) API is used to write. Segfault occurs (get signalled) from OS when a process attempts to access it's own memory in a bad way (char[] overflow).
About the games: well, if a value is stored at an address, and gets read sometimes, then it could be modified before next reading occurs.

- 2,964
- 7
- 48
- 87
You can use WinAPI WriteProcessMemory
to write to memory space of other process.
Also read some PE/COFF documentation and use VirtualQueryEx
and ReadProcessMemory
to know what and where to write.

- 14,714
- 1
- 39
- 40