memzap

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

openbsd_ops.c (628B)


      1 /* See LICENSE file for copyright and license details. */
      2 
      3 #include "proto.h"
      4 
      5 int
      6 traceme(void)
      7 {
      8 	int ret;
      9 
     10 	ret = ptrace(PT_TRACE_ME, 0, 0, 0);
     11 	if (ret < 0)
     12 		err(1, "ptrace");
     13 	return ret;
     14 }
     15 
     16 int
     17 single_step(pid_t pid)
     18 {
     19 	int ret;
     20 
     21 	ret = ptrace(PT_STEP, pid, 0, 0);
     22 	if (ret < 0)
     23 		err(1, "ptrace");
     24 	return ret;
     25 }
     26 
     27 void
     28 readmem(pid_t pid, void *buf, void *offset, size_t size)
     29 {
     30 	struct ptrace_io_desc pi_desc;
     31 	int ret;
     32 
     33 	pi_desc.piod_op = PIOD_READ_D;
     34 	pi_desc.piod_offs = offset;
     35 	pi_desc.piod_addr = buf;
     36 	pi_desc.piod_len = size;
     37 
     38 	ret = ptrace(PT_IO, pid, (caddr_t)&pi_desc, 0);
     39 	if (ret < 0)
     40 		err(1, "ptrace");
     41 }