Rizin
unix-like reverse engineering framework and cli tools
ptrace_wrap.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2018-2021 thestr4ng3r <info@florianmaerkl.de>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #ifndef PTRACE_WRAP_H
5 #define PTRACE_WRAP_H
6 
7 #include <pthread.h>
8 #include <semaphore.h>
9 #include <sys/ptrace.h>
10 
11 #ifdef __GLIBC__
13 #else
15 #endif
16 
17 typedef enum {
23 
24 typedef void *(*ptrace_wrap_func_func)(void *);
25 
26 typedef struct ptrace_wrap_request_t {
28  union {
29  struct {
32  void *addr;
33  void *data;
34  int *_errno;
35  } ptrace;
36  struct {
37  void (*child_callback)(void *);
39  int *_errno;
40  } fork;
41  struct {
43  void *user;
44  } func;
45  };
47 
48 typedef struct ptrace_wrap_instance_t {
49  pthread_t th;
50  sem_t request_sem;
52  sem_t result_sem;
53  union {
56  void *func_result;
57  };
59 
63 pid_t ptrace_wrap_fork(ptrace_wrap_instance *inst, void (*child_callback)(void *), void *child_callback_user);
64 void *ptrace_wrap_func(ptrace_wrap_instance *inst, ptrace_wrap_func_func func, void *user);
65 
66 #endif // PTRACE_WRAP_H
static static sync static getppid static getegid const char static filename request
Definition: sflib.h:62
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc pid
Definition: sflib.h:64
struct ptrace_wrap_instance_t ptrace_wrap_instance
void * ptrace_wrap_func(ptrace_wrap_instance *inst, ptrace_wrap_func_func func, void *user)
Definition: ptrace_wrap.c:130
void ptrace_wrap_instance_stop(ptrace_wrap_instance *inst)
Definition: ptrace_wrap.c:36
pid_t ptrace_wrap_fork(ptrace_wrap_instance *inst, void(*child_callback)(void *), void *child_callback_user)
Definition: ptrace_wrap.c:108
long ptrace_wrap(ptrace_wrap_instance *inst, ptrace_wrap_ptrace_request request, pid_t pid, void *addr, void *data)
Definition: ptrace_wrap.c:90
int ptrace_wrap_ptrace_request
Definition: ptrace_wrap.h:14
int ptrace_wrap_instance_start(ptrace_wrap_instance *inst)
Definition: ptrace_wrap.c:14
ptrace_wrap_request_type
Definition: ptrace_wrap.h:17
@ PTRACE_WRAP_REQUEST_TYPE_STOP
Definition: ptrace_wrap.h:18
@ PTRACE_WRAP_REQUEST_TYPE_PTRACE
Definition: ptrace_wrap.h:19
@ PTRACE_WRAP_REQUEST_TYPE_FORK
Definition: ptrace_wrap.h:20
@ PTRACE_WRAP_REQUEST_TYPE_FUNC
Definition: ptrace_wrap.h:21
struct ptrace_wrap_request_t ptrace_wrap_request
void *(* ptrace_wrap_func_func)(void *)
Definition: ptrace_wrap.h:24
int pid_t
Definition: sftypes.h:38
__ptrace_request
Definition: sftypes.h:552
ptrace_wrap_request request
Definition: ptrace_wrap.h:51
ptrace_wrap_ptrace_request request
Definition: ptrace_wrap.h:30
struct ptrace_wrap_request_t::@423::@425 ptrace
void(* child_callback)(void *)
Definition: ptrace_wrap.h:37
ptrace_wrap_func_func func
Definition: ptrace_wrap.h:42
ptrace_wrap_request_type type
Definition: ptrace_wrap.h:27
struct ptrace_wrap_request_t::@423::@426 fork
static int addr
Definition: z80asm.c:58