|
|
1.1 ! root 1: /* ! 2: * Call a kernel function with the NLCALL ioctl on /dev/kmem. ! 3: */ ! 4: #include <stdio.h> ! 5: #include <fcntl.h> ! 6: #include <sys/null.h> ! 7: ! 8: /* ! 9: * Set FUNC to the address of the routine you want called. ! 10: */ ! 11: #define FUNC 0xFFC02610 /* vptop() */ ! 12: /* #define FUNC 0xFFC02590 /* vtop() */ ! 13: /* #define FUNC 0xFFC0267C /* vtovp() */ ! 14: ! 15: main() ! 16: { ! 17: int fd; ! 18: unsigned vec[7]; ! 19: ! 20: if ((fd = open("/dev/kmem", O_RDONLY)) == -1) { ! 21: printf("Can't open /dev/kmem.\n"); ! 22: } ! 23: ! 24: /* ! 25: * The first element of this vector gives the length for the ! 26: * whole vector. The kernel will copy in this many unsigneds. ! 27: * Because extra arguments are ignored by any function, I ! 28: * usually just leave this at the maximum value of 7. ! 29: * Setting this element to something larger than 7 results in ! 30: * a return value of -1 with errno set to EINVAL. ! 31: * ! 32: * The ioctl() will put the return value of the function in element ! 33: * 0. ! 34: * ! 35: * The second element is the address of the function to be ! 36: * called. ! 37: * ! 38: * Successive elements are arguments to be passed to the ! 39: * function. Only the first 5 will be passed. ! 40: */ ! 41: vec[0] = 7; ! 42: vec[1] = FUNC; ! 43: vec[2] = 0xF3B0E8; /* virtual-physical */ ! 44: vec[3] = 0; ! 45: vec[4] = 0; ! 46: vec[5] = 0; ! 47: vec[6] = 0; ! 48: ! 49: ioctl(fd, NLCALL, vec); ! 50: ! 51: printf("retval: 0x%x\n", vec[0]); ! 52: ! 53: close(fd); ! 54: } /* main() */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.