memzap

replay memory writes
git clone git://git.2f30.org/memzap
Log | Files | Refs | README | LICENSE

commit fdcc971d1dc2e851e4a50eae1f3424d68f00b351
parent a260739367a4e344eae9de5d1d997ee3c50ce667
Author: sin <sin@2f30.org>
Date:   Fri,  1 Mar 2013 12:11:23 +0000

memzap: Add a `verbose' flag to control verbosity levels

Diffstat:
Mmemzap.c | 15++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/memzap.c b/memzap.c @@ -2,6 +2,8 @@ #include "data.h" +static int verbose = 0; + void readmem(pid_t pid, void *buf, off_t offset, size_t size) { @@ -52,8 +54,9 @@ main(int argc, char *argv[]) addr = (char *)strtoul(argv[2], NULL, 16); len = strtoul(argv[3], NULL, 10); - printf("[+] Base address: %p, length: %zu\n", - addr, len); + if (verbose > 0) + printf("[+] Base address: %p, length: %zu\n", + addr, len); pid = fork(); if (pid < 0) @@ -70,7 +73,8 @@ main(int argc, char *argv[]) break; } - printf("[+] Mapping buffers into memory\n"); + if (verbose > 0) + printf("[+] Mapping buffers into memory\n"); buf = mmap(0, len, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); @@ -84,8 +88,9 @@ main(int argc, char *argv[]) err(1, "mmap"); } - printf("[+] Single stepping child with pid %jd\n", - (intmax_t)pid); + if (verbose > 0) + printf("[+] Single stepping child with pid %jd\n", + (intmax_t)pid); ret = ptrace(PTRACE_SINGLESTEP, pid, NULL, NULL); if (ret < 0)