4 #include <sys/ptrace.h>
7 unsigned char buf[1024];
9 int main(int argc, unsigned char **argv)
12 unsigned long addr1, addr2;
17 fprintf(stderr, "Not enough args\n");
20 pid = strtol(argv[1], NULL, 0);
21 addr1 = (unsigned long)strtoll(argv[2], NULL, 0);
22 addr2 = (unsigned long)strtoll(argv[3], NULL, 0);
23 if(ptrace(PTRACE_ATTACH, pid, NULL, NULL))
25 perror("PTRACE_ATTACH");
28 for(; addr1 < addr2; addr1 += sizeof(int))
31 if(((buf = ptrace(PTRACE_PEEKDATA, pid, (void *)addr1, NULL)) == -1) && errno)
33 perror("PTRACE_PEEKDATA");
34 if(ptrace(PTRACE_DETACH, pid, NULL, NULL))
35 perror("PTRACE_DETACH");
38 if(write(1, &buf, sizeof(buf)) != 4)
41 if(ptrace(PTRACE_DETACH, pid, NULL, NULL))
42 perror("PTRACE_DETACH");
46 if(ptrace(PTRACE_DETACH, pid, NULL, NULL))
48 perror("PTRACE_DETACH");