#include #include #include #include #define __KERNEL__ #include int main ( void ) { int i; int fd; FILE *fp; char *map; char buf[256]; char buf2[256]; struct page *pg; unsigned long tmp; fp = fopen("/proc/ksyms", "r"); if (!fp) { perror("fopen"); return 1; } while (fgets(buf, 255, fp)) { sscanf(buf, "%lx %s", &tmp, buf2); if (0 == strcmp(buf2, "mem_map")) break; tmp = 0; } if (!tmp) { fprintf(stderr, "Couldn't get address of symbol mem_map\n"); return 1; } fd = open("/dev/mem", O_RDONLY); if (fd < 0) { perror("open"); return 1; } map = mmap(0, 1024*16704, PROT_READ, MAP_FILE | MAP_SHARED, fd, 0); if ((void *)map == (void *)-1) { perror("mmap"); return 1; } tmp = (unsigned long)*(char **)(map + tmp); printf("\033[H\033[J"); for (;;) { printf("\033[H"); /* ESC[J */ #if 0 pg = *(struct page **)(map + 0x001b2cc0 - 4096); #endif pg = (struct page *)(map + tmp); for (i=0; i<(16704/4); i++) { if (pg->reserved) putchar('r'); else if (pg->count > 1) putchar('S'); else if (pg->count) putchar('o'); else putchar('.'); pg++; } putchar('\n'); sleep(2); } }