|
|
1.1 root 1: /* Attempt to find a reference to an address in /dev/mem. */
2: #include <stdio.h>
3: #define ONE_CLICK 0x400 /* Number of longs in a click. */
4: #define MEM_SIZE 0x460000L /* Size of memory on qiqineb. */
5: #define PRESENT 0x00000001L /* Present bit for Page Table Entries. */
6: #define ADDR_PART 0xfffff000L /* Address part of a PTE. */
7: #define TRUE (1==1)
8: #define FALSE (1==2)
9:
10: /* Address to look for. */
11: unsigned long ref = 0x03ff000;
12:
13: main()
14: {
15: static unsigned long page_buffer[ONE_CLICK]; /* Load pages here. */
16:
17: int fd; /* Handle for /dev/mem. */
18:
19: unsigned long *base; /* Loop through all possible clicks. */
20: unsigned long *walker; /* Loop through each long in a click. */
21:
22:
23: if (-1 == (fd = open("/dev/mem", 0))) {
24: perror("Can't open /dev/mem");
25: exit (1);
26: }
27:
28: for (base = 0; base < (unsigned long *) MEM_SIZE; base += ONE_CLICK) {
29:
30: if (-1 == read(fd, page_buffer, ONE_CLICK*sizeof(long)) ) {
31: perror("Read error");
32: exit (1);
33: }
34: printf(".");
35: fflush(stdout);
36:
37: for (walker = page_buffer;
38: walker < page_buffer + ONE_CLICK;
39: ++walker) {
40:
41: /* There must be at least one nonzero entry. */
42:
43: /* All PTE's must point at existant memory. */
44: if (ref == (ADDR_PART & *walker)) {
45: printf("Ref to %x: %x\n", ref,
46: base + (walker - page_buffer));
47: }
48: } /* for (walker...) */
49: } /* for (base...) */
50: } /* main() */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.