memzap

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

commit 2b913b2400645b5aab68f127cd84f4ea1e16774b
parent 9448d34eeb67827d84dd1b46a0c972513add361f
Author: sin <sin@2f30.org>
Date:   Fri,  1 Mar 2013 14:46:33 +0000

ops: Add openbsd port

This has *not* been tested.

Diffstat:
AMakefile.openbsd | 34++++++++++++++++++++++++++++++++++
Aopenbsd_ops.c | 41+++++++++++++++++++++++++++++++++++++++++
2 files changed, 75 insertions(+), 0 deletions(-)

diff --git a/Makefile.openbsd b/Makefile.openbsd @@ -0,0 +1,34 @@ +BIN = memzap +VER = 0.1 +SRC = memzap.c mem.c utils.c md5.c openbsd_ops.c +OBJ = ${SRC:.c=.o} + +PREFIX = /usr + +CC = gcc + +INCS = -I/usr/local/include +LIBS = -L/usr/local/lib + +CFLAGS += -g -O3 -Wall -Wextra -Wunused -DVERSION=\"${VER}\" ${INCS} +LDFLAGS += + +${BIN}: ${OBJ} + ${CC} ${CFLAGS} ${LDFLAGS} -o $@ ${OBJ} + +%.o: %.c + ${CC} ${CFLAGS} -c -o $@ $< + +clean: + rm -rf ${BIN} ${OBJ} + +all: memzap + +install: + cp -f ${BIN} ${PREFIX}/bin + chmod 755 ${PREFIX}/bin/${BIN} + +uninstall: + rm -f ${PREFIX}/bin/${BIN} + +.PHONY: all clean install uninstall diff --git a/openbsd_ops.c b/openbsd_ops.c @@ -0,0 +1,41 @@ +/* See LICENSE file for copyright and license details. */ + +#include "data.h" + +int +traceme(void) +{ + int ret; + + ret = ptrace(PT_TRACE_ME, 0, 0, 0); + if (ret < 0) + err(1, "ptrace"); + return ret; +} + +int +single_step(pid_t pid) +{ + int ret; + + ret = ptrace(PT_STEP, pid, 0, 0); + if (ret < 0) + err(1, "ptrace"); + return ret; +} + +void +readmem(pid_t pid, void *buf, void *offset, size_t size) +{ + struct ptrace_io_desc pi_desc; + int ret; + + pi_desc.piod_op = PIOD_READ_D; + pi_desc.piod_offs = offset; + pi_desc.piod_addr = buf; + pi_desc.piod_len = size; + + ret = ptrace(PT_IO, pid, (caddr_t)&pi_desc, 0); + if (ret < 0) + err(1, "ptrace"); +}