12 #include <sys/ptrace.h>
14 #include <asm/unistd.h>
18 #include <skas_ptrace.h>
20 #define ARBITRARY_ADDR -1
21 #define FAILURE_PID -1
23 #define STAT_PATH_LEN sizeof("/proc/#######/stat\0")
24 #define COMM_SCANF "%*[^)])"
32 sprintf(proc_stat,
"/proc/%d/stat", pid);
36 "errno = %d\n", proc_stat,
errno);
42 "err = %d\n", proc_stat,
errno);
48 "%*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d "
49 "%*d %*d %*d %*d %*d %lu", &pc) != 1)
67 snprintf(stat,
sizeof(stat),
"/proc/%d/stat", pid);
158 if (loc == MAP_FAILED)
168 if (mprotect(addr, len, prot) < 0)
178 err = munmap(addr, len);
185 #define MADV_REMOVE KERNEL_MADV_REMOVE
213 if (addr == MAP_FAILED) {
215 "err = %d\n", -
errno);
219 if (madvise(addr, UM_KERN_PAGE_SIZE,
MADV_REMOVE) != 0) {
228 munmap(addr, UM_KERN_PAGE_SIZE);