From f516afe1e2ca95bc6ca3bf13d065ceefd477d6c7 Mon Sep 17 00:00:00 2001 From: Jann Horn Date: Sun, 9 Feb 2014 22:33:54 +0100 Subject: [PATCH] clean up a bit --- tools/spawnhunter.c | 2 ++ tools/viewmem.c | 48 --------------------------------------------- 2 files changed, 2 insertions(+), 48 deletions(-) delete mode 100644 tools/viewmem.c diff --git a/tools/spawnhunter.c b/tools/spawnhunter.c index 6a1d059..ad5e250 100644 --- a/tools/spawnhunter.c +++ b/tools/spawnhunter.c @@ -1,4 +1,6 @@ // Try to print the cmdlines of all process spawns by polling /proc. +// Doesn't do exactly what you probably need because it might catch +// a process between fork and exec, then ignore it. #include #include diff --git a/tools/viewmem.c b/tools/viewmem.c deleted file mode 100644 index ab00ef3..0000000 --- a/tools/viewmem.c +++ /dev/null @@ -1,48 +0,0 @@ -#define _GNU_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -int main(int argc, char *argv[]) { - if (argc != 3) { - fputs("invocation: ./viewmem /proc//mem \n", stderr); - return 1; - } - char *end; - errno = 0; - unsigned long long addr = strtoull(argv[2], &end, 0); - if (errno != 0 || *end != 0) { - fputs("invalid addr\n", stderr); - return 1; - } - int fd = open(argv[1], O_RDWR); - if (fd == -1) { - fprintf(stderr, "error: can't open %s - %s\n", argv[1], strerror(errno)); - return 1; - } - fprintf(stderr, "please press the any key...\n"); - fd = openat(fd, "", 0, O_RDWR); - while (getchar() != '\n'); - fprintf(stderr, "trying to dump..."); - errno = 0; - lseek(fd, addr, SEEK_SET); - if (errno != 0) { - fprintf(stderr, "lseek() failed: %s\n", strerror(errno)); - return 1; - } - char buf[4096]; // nothing interesting has a different pagesize anyway - int i=0; - while (read(fd, buf, 4096) == 4096) { - write(1, buf, 4096); - i++; - } - fprintf(stderr, "read %i pages\n", i); - return 0; -} -- 2.20.1