How to read physical memory
From: Tomas Kratochvil (tkra_at_duhasys.cz)
Date: 11/25/04
- Previous message: kugle: "ppc kernel kernel access of bad area problem"
- Next in thread: Marco Cavallini: "Re: How to read physical memory"
- Reply: Marco Cavallini: "Re: How to read physical memory"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 25 Nov 2004 07:03:57 -0800
Hello,
could you help me? I need utility or part of code which read part of
physical memory in non kernel mode.
I wrote this :
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <sys/mman.h>
int main()
{
FILE* fd = fopen("/dev/mem","r");
unsigned int i;
unsigned int base;
char c[4];
if (fd == 0)
printf("Error while opening /dev/mem\n");
base = 0x40d00010;
fseek(fd, SEEK_SET, base);
for (i = 0; i < 16*4; i+=4) {
fread(&c,4,1,fd);
printf("addr[%2X]=0x%.2X %.2X %.2X
%.2X\n",base+i,c[0],c[1],c[2],c[3]);
}
return 0;
}
But i cannot read /dev/mem on my device because /dev/mem doesn't work
(cat /dev/mem cause segmentation fault). Is there any other
possibility how do these. (ioctl)
Thank you
Tomas
- Previous message: kugle: "ppc kernel kernel access of bad area problem"
- Next in thread: Marco Cavallini: "Re: How to read physical memory"
- Reply: Marco Cavallini: "Re: How to read physical memory"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|