如何在c中读取内存地址0xfeafe000的内容? [英] how to read content of memory address 0xfeafe000 in c?

查看:130
本文介绍了如何在c中读取内存地址0xfeafe000的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已尝试读取内存地址0xfeafe000和0xfe9b000的内容.我已经使用了一些技术,但无法这样做. 我尝试了以下代码,它们是-

1.

unsigned int *abar = (unsigned int *) 0x0feaf000;
printf("\n %x",*abar);// got segmentation fault

2.

char txt[512];
  memcpy(txt,(char *)0xfeafe000,sizeof(txt));
  printf("%s",txt);// got segmentation fault

还有另一种方法可以解决此问题或我尝试中的任何缺陷吗?

解决方案

操作系统将程序中的逻辑地址映射到对您的进程有效的地址,因此在大多数系统中您都无法访问绝对地址.

如果您拥有一个可以直接访问真实地址空间的系统,那么您的第一个示例应该可以工作,但在这种情况下,我建议使用abar const.

i have tried to read content of a memory address 0xfeafe000 and 0xfe9b000. i have used a few techinue but unable to do so. i have tried following codes, they are-

1.

unsigned int *abar = (unsigned int *) 0x0feaf000;
printf("\n %x",*abar);// got segmentation fault

2.

char txt[512];
  memcpy(txt,(char *)0xfeafe000,sizeof(txt));
  printf("%s",txt);// got segmentation fault

is there anather way to resolve this or any flaws in my attempts??

解决方案

The logical address in your program is mapped by the OS into an address that's valid for your process, so you have no access to an absolute address in most systems.

If you got a system with direct access to the real address space, then your first example should works, but I would suggest to make abar const in that case.

这篇关于如何在c中读取内存地址0xfeafe000的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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