如何在c中读取内存地址0xfeafe000的内容? [英] how to read content of memory address 0xfeafe000 in c?
问题描述
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屋!