Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making a program see another program's memory

Tags:

c++

memory

There are tools such as TSearch, Cheat Engine, etc. These are hacking programs for viewing and modifying parts of memory of another program.

If I am to create a C++ program that can see and modify other program's memory, how can I do that? What are some of the things I should be looking for?

like image 470
Karl Avatar asked Dec 19 '10 12:12

Karl


People also ask

Can a program access another program's memory?

Unless the program is specifically built to be able to inject itself in another processes memory space (i.e. using specific Windows programming calls that need administrative access), a program cannot see another programs memory.

Can one process access another process memory?

Processes cannot access other processes' memory in principle. In practice the underlying operating system usually offers this mechanism to privileged processes.

How can the OS prevent a process from accessing memory of another process?

Short answer: On x86 processors they do it by activating Protected Mode(32-bit) or Long Mode(64-bit). ARM or other processors implement similar concepts. The Protected Mode protects the memory space of different Processes from each other - giving each process its own memory space.


1 Answers

This is not a feature of C++, it's under the control of the OS itself.

For example, Windows provides the ReadProcessMemory() API call so that you can get your grubby little hands on the memory of another process. And of course, the equivalent for writing as well so you can cause even more damage :-)

All this depends on having the correct privileges as well.

I'm not sure how Linux provides this but earlier UNIXes had "memory mapping" files like /dev/mem so you could get at the memory. There may be a per-process variant in the procfs file system which can give you access to the virtual memory of a specific process. That'd be the first place I'd start looking although others here will undoubtedly know more about that than I.

like image 200
paxdiablo Avatar answered Sep 28 '22 17:09

paxdiablo