user1124295
user1124295

Reputation: 53

Read process memory in C

I try to read from process memory that I wrote, my code is:

 #include <stdio.h>
 void main()
 {
    int x,y;
    scanf("%d",&x);
    scanf("%d",&y);
    x = y;
    scanf("%d",&y);
    printf("%d",x);
    scanf("%d",&y);
 }

ok, i finded the adress in Cheat engine, and success editing and so on, i search in google for like 5 hours at least, find alot of codes, cant understand them, i mean. the code that does work, run even when the process is off -_-' can someone help me to build a typical code that read value from adresss in memory?

Upvotes: 0

Views: 708

Answers (2)

hmjd
hmjd

Reputation: 121961

As the platform is Windows, see the WINAPI function ReadProcessMemory().

The posted code is reading from standard input and writing to standard output, it is not attempting to read memory.

Upvotes: 3

unwind
unwind

Reputation: 399753

Your code is not doing anything that even resembles what you speak about in the question text, making this very confusing.

In most modern operating systems that implement virtual memory and memory protection, you cannot easily read other processes' memory.

Even if you have one process print out the address of one of its variables, that address is virtual, so if your process tries to access memory at the same virtual address it will not access the same physical memory.

Upvotes: 1

Related Questions