How do programs that edit memory of other processes work, such as Cheat Engine and iHaxGamez? My understanding is that a process readi开发者_如何转开发ng from (let alone writing to) another process' memory is immediate grounds for a segmentation fault.
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.
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.
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.
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.
精彩评论