访问直接内存地址并获取C ++中的值 [英] Accessing direct memory addresses and obtaining the values in C++

查看:1472
本文介绍了访问直接内存地址并获取C ++中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以使用C / C ++访问直接内存块,并获取该值。例如:

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 << &i;

如果我在这里获取打印值,那么会给出变量i的地址,值15.我只是说它打印出0x0ff9c1为这个例子。如果我有一个单独的程序,它声明一个像这样的指针...

If I took the printed value here, that would give me the address of the variable i, which contains the value 15. I will just say it printed out 0x0ff9c1 for this example. If I have a separate program which declares a pointer like so...

int *p = 0x0ff9c1;
cout << *p;

是否可以打印出其他应用程序放置在内存块0x0ff9c1中的15?我知道我的指针声明与内存地址不正确,我不知道如何做到否则。我已经尝试使用 memcopy ,但我还是不能得到工作。我知道这是可能的,因为我有一个名为Cheat Engine的程序,它修改游戏内存地址值以获得不公平的优势。我已经成功地放置打印的内存位置,并获得值(15)通过作弊引擎。我的目标是使用C ++。
如果这太混乱了,基本上我想访问另一个应用程序使用其内存地址存储的变量并打印出值。我使用Windows 7 x64与MinGW编译器如果这很重要。谢谢!

Would it be possible to print out that 15 that the other application placed in the memory block 0x0ff9c1? I know my pointer declaration with the memory address is incorrect, I am unsure how to do it otherwise. I have tried using memcopy but I have not been able to get that to work either. I know this is possible somehow as I have a program called Cheat Engine which modifies game memory address values to gain unfair advantages. I have been successful in placing the printed memory location and obtaining the value (15) though Cheat Engine. My goal is to do this using C++. If this is too confusing, basically I would like to access a variable that another application stored using its memory address and print out the value. I am using Windows 7 x64 with MinGW compiler if that matters. Thanks!

PS:我会发布一个图片,告诉Cheat Engine做一个更好的主意。

PS: I'll post a picture of what Cheat Engine does to give a better idea.

推荐答案

这两个进程具有单独的地址空间。一个进程不能访问另一个进程内存,除非它是明确的共享内存。

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

这篇关于访问直接内存地址并获取C ++中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆