daily pastebin goal
93%
SHARE
TWEET

ecc_check.c

a guest May 13th, 2012 4,580 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <sys/types.h>
  4. #include <sys/stat.h>
  5. #include <unistd.h>
  6. #include <fcntl.h>
  7. #include <sys/mman.h>
  8.  
  9.  
  10. #define MEM_START       0xFED10000
  11. #define FILESIZE        32*1024
  12.  
  13. int main(int argc, char *argv[])
  14. {
  15.     int i;
  16.     int fd = -1;
  17.         unsigned long pagesize;
  18.     unsigned char *map;
  19.         unsigned char *mem;
  20.  
  21.     fd = open("/dev/mem", O_RDONLY|O_SYNC);
  22.     if (fd == -1) {
  23.                 perror("Error opening /dev/mem for reading");
  24.                 exit(EXIT_FAILURE);
  25.     }
  26.  
  27.     map = mmap(0, FILESIZE, PROT_READ, MAP_SHARED, fd, MEM_START);
  28.     if (map == MAP_FAILED) {
  29.                 close(fd);
  30.                 perror("Error mmapping the file");
  31.                 exit(EXIT_FAILURE);
  32.     }
  33.    
  34.         // Get RAM info
  35.         printf("5004-5007h: ");
  36.         for (i = 0x5004; i < 0x5004+4; i++) {
  37.                 printf("%lx ", map[i]);
  38.         }
  39.         printf("\n");
  40.  
  41.         printf("5008-500Bh: ");
  42.         for (i = 0x5008; i < 0x5008+4; i++) {
  43.                 printf("%lx ", map[i]);
  44.         }
  45.         printf("\n");
  46.  
  47.         // Unmap the file
  48.     if (munmap(map, FILESIZE) == -1) {
  49.                 perror("Error un-mmapping the file");
  50.     }
  51.  
  52.     close(fd);
  53.     return 0;
  54. }
RAW Paste Data
Top