Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
151 views
in Technique[技术] by (71.8m points)

how to read content of memory address 0xfeafe000 in c?

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("
 %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??

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...