Accessing direct memory addresses and obtaining the values in C++

前端 未结 5 1381
遇见更好的自我
遇见更好的自我 2020-12-31 04:14

I was wondering if it was possible to access a direct block of memory using C/C++ and grab the value. For example:

int i = 15;
int *p = &i;
cout <<         


        
相关标签:
5条回答
  • 2020-12-31 04:33

    In general, it's not usually possible for one program to modify the memory of another. The system goes to great lengths to ensure this. If it did not, no program would be safe. This is particularly true in all the Unix variants I've worked on, though not on all proprietary OSes I've seen.

    Note that none of these rules apply to the kernel ...

    There is also a programming paradigm called shared memory, but you have to explicitly set that up.

    Short answer: you can't usually do that. I believe you mentioned windows. I know nothing about Windows, so your mileage may vary.

    0 讨论(0)
  • 2020-12-31 04:39

    A bit late, but you still could this through a DLL injection. Here is a link to a tutorial: http://resources.infosecinstitute.com/using-createremotethread-for-dll-injection-on-windows/

    0 讨论(0)
  • 2020-12-31 04:40

    If you want to change the memory used by another process, one way would be to inject your code into the other process. From that point, you can do whatever you want to the other program's memory as if it were your owns.

    Search around for remote thread creation or hooking. There are more than a few questions about it here (and here, for starters).

    0 讨论(0)
  • 2020-12-31 04:47

    You can't do it in a platform-agnostic way in C++. While I haven't used this "cheat engine" specifically, it almost certainly is using the same special API that a debugger uses. The code will be specific to Windows, and you will require a certain privilege level on the running process.

    (For instance, if you are using Visual Studio and execute a program from it in a Debug Mode, Visual Studio can look at and modify values in that program.)

    I haven't written a debugger in a while, so I don't know where a good place to get started on the Debug API is, but you can search around the web for things like this article:

    http://www.woodmann.com/fravia/iceman1.htm

    0 讨论(0)
  • 2020-12-31 04:49

    The two processes have separate address spaces. One process cannot access another processses memory unless it is explicily shared memory.

    0 讨论(0)
提交回复
热议问题