1 /* radare - LGPL - Copyright 2009-2021 - pancake */ 2 3 #ifndef R2_SYSCALL_H 4 #define R2_SYSCALL_H 5 6 #ifdef __cplusplus 7 extern "C" { 8 #endif 9 10 #include <r_types.h> 11 #include <r_util.h> 12 #include <sdb.h> 13 14 R_LIB_VERSION_HEADER (r_syscall); 15 16 #define R_SYSCALL_ARGS 7 17 18 typedef struct r_syscall_item_t { 19 char *name; 20 int swi; 21 int num; 22 int args; 23 char *sargs; 24 } RSyscallItem; 25 26 typedef struct r_syscall_port_t { 27 int port; 28 const char *name; 29 } RSyscallPort; 30 31 typedef struct r_syscall_t { 32 FILE *fd; 33 // memoization 34 char *arch; 35 char *os; 36 int bits; 37 char *cpu; 38 // database 39 RSyscallItem *sysptr; 40 RSyscallPort *sysport; 41 Sdb *db; 42 Sdb *srdb; 43 int refs; 44 } RSyscall; 45 46 #if 0 47 // todo: add the ability to describe particular bits 48 typedef struct r_sysregs_item_t { 49 ut64 address; 50 ut64 size; 51 int type; 52 const char *name; 53 const char *description; 54 } RSysregsItem; 55 56 typedef struct r_sysregs_t { 57 FILE *fd; 58 char *arch; 59 char *cpu; 60 RSysregsItem *sysregs; 61 Sdb *db; 62 } RSysregs; 63 #endif 64 65 /* plugin struct */ 66 typedef struct r_syscall_plugin_t { 67 char *name; 68 char *arch; 69 char *os; 70 char *desc; 71 int bits; 72 int nargs; 73 struct r_syscall_args_t *args; 74 } RSyscallPlugin; 75 76 typedef struct r_syscall_arch_plugin_t { 77 char *name; 78 char *arch; 79 char *desc; 80 int *bits; 81 int nargs; 82 struct r_syscall_args_t **args; 83 } RSyscallArchPlugin; 84 85 #ifdef R_API 86 R_API RSyscallItem *r_syscall_item_new_from_string(const char *name, const char *s); 87 R_API void r_syscall_item_free(RSyscallItem *si); 88 89 R_API RSyscall *r_syscall_new(void); 90 R_API void r_syscall_free(RSyscall *ctx); 91 R_API RSyscall* r_syscall_ref(RSyscall *sc); 92 R_API bool r_syscall_setup(RSyscall *s, const char *arch, int bits, const char *cpu, const char *os); 93 R_API RSyscallItem *r_syscall_get(RSyscall *ctx, int num, int swi); 94 R_API int r_syscall_get_num(RSyscall *ctx, const char *str); 95 R_API const char *r_syscall_get_i(RSyscall *ctx, int num, int swi); 96 R_API const char* r_syscall_sysreg(RSyscall *s, const char *type, ut64 num); 97 R_API RList *r_syscall_list(RSyscall *ctx); 98 R_API int r_syscall_get_swi(RSyscall *s); 99 100 /* io */ 101 R_API const char *r_syscall_get_io(RSyscall *s, int ioport); 102 #endif 103 104 #ifdef __cplusplus 105 } 106 #endif 107 108 #endif 109