#include #include #include #include #include #include #include void main (int argvc, char **argv) { int fd, mem_fd; long start, len; unsigned char *p, s[1]; /* int c;*/ /*char peek[PEEK_SIZE];*/ /* handy for using gdb to dissassemble memory */ if (argvc != 3) { fprintf(stderr, "usage: mempeek \n"); exit(-1); } start = atoi(argv[1]); len = atol(argv[2]); fprintf(stderr, "start=%ld, length=%ld\n", start, len); /* give ourselves programmed-IO access */ if ((fd = open ("/dev/console", O_RDONLY)) < 0) fd = 0; if (ioctl (fd, KDENABIO, 0) < 0) perror ("ioctl(KDENABIO)"); /* open /dev/mem */ if ((mem_fd = open ("/dev/mem", O_RDWR)) < 0) { perror ("can't open /dev/mem \n"); exit(-1); } /* lseek to where we want.. */ p = (unsigned char *) lseek (mem_fd, (off_t)start, SEEK_SET); if (p != start) { perror ("couldn't seek to location"); exit(-1); } /*c = 0;*/ while (--len) { read(mem_fd, s, 1); printf("%c", s[0]); /*peek[c++] = s[0];*/ } close(mem_fd); close(fd); }