Rizin
unix-like reverse engineering framework and cli tools
rz_syscall.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2009-2021 pancake <pancake@nopcode.org>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #ifndef RZ_SYSCALL_H
5 #define RZ_SYSCALL_H
6 
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10 
11 #include <rz_types.h>
12 #include <rz_util.h>
13 #include <sdb.h>
14 
16 
17 #define RZ_SYSCALL_ARGS 7
18 
19 typedef struct rz_syscall_item_t {
20  char *name;
21  int swi;
22  int num;
23  int args;
24  char *sargs;
26 
27 typedef struct rz_sysreg_item_t {
28  char *type;
29  char *name;
30  char *comment;
32 
33 typedef struct rz_sysreg_db_t {
34  HtUP /* <ut64 , RzSysregItem> */ *port;
36 
37 typedef struct rz_syscall_t {
38  FILE *fd;
39  // memoization
40  char *arch;
41  char *os;
42  int bits;
43  char *cpu;
44  // database
46  Sdb *db;
48  int refs;
50 
51 #if 0
52 // todo: add the ability to describe particular bits
53 typedef struct rz_sysregs_item_t {
54  ut64 address;
55  ut64 size;
56  int type;
57  const char *name;
58  const char *description;
59 } RSysregsItem;
60 
61 typedef struct rz_sysregs_t {
62  FILE *fd;
63  char *arch;
64  char *cpu;
65  RSysregsItem *sysregs;
66  Sdb *db;
67 } RSysregs;
68 #endif
69 
70 /* plugin struct */
71 typedef struct rz_syscall_plugin_t {
72  char *name;
73  char *arch;
74  char *os;
75  char *desc;
76  int bits;
77  int nargs;
78  struct rz_syscall_args_t *args;
80 
81 typedef struct rz_syscall_arch_plugin_t {
82  char *name;
83  char *arch;
84  char *desc;
85  int *bits;
86  int nargs;
87  struct rz_syscall_args_t **args;
89 
90 #ifdef RZ_API
91 RZ_API RzSyscallItem *rz_syscall_item_new_from_string(const char *name, const char *s);
93 
95 RZ_API void rz_sysregs_db_free(RzSysregsDB *sysregdb);
98 RZ_API bool rz_syscall_setup(RzSyscall *s, const char *arch, int bits, const char *cpu, const char *os);
100 RZ_API int rz_syscall_get_num(RzSyscall *ctx, const char *str);
101 RZ_API const char *rz_syscall_get_i(RzSyscall *ctx, int num, int swi);
104 
105 RZ_API const char *rz_sysreg_get(RzSyscall *s, const char *type, ut64 num);
106 RZ_API bool rz_sysreg_set_arch(RzSyscall *s, RZ_NONNULL const char *arch, RZ_NONNULL const char *regs_dir);
107 RZ_API bool rz_sysreg_load_sdb(RzSysregsDB *sysregdb, const char *path);
110 RZ_API void rz_sysreg_item_free(RzSysregItem *sysregitem);
111 #endif
112 
113 #ifdef __cplusplus
114 }
115 #endif
116 
117 #endif
si
static ut32 cpu[32]
Definition: analysis_or1k.c:21
int bits(struct state *s, int need)
Definition: blast.c:72
#define RZ_API
cs_arch arch
Definition: cstool.c:13
static static fork const void static count static fd const char const char static newpath const char static path const char path
Definition: sflib.h:35
static char sc[]
Definition: egg_cb.c:6
voidpf void uLong size
Definition: ioapi.h:138
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 static sig const char static mode static oldfd struct tms static buf static getgid static geteuid const char static filename static arg static mask struct ustat static ubuf static getppid static setsid static egid sigset_t static set struct timeval struct timezone static tz fd_set fd_set fd_set struct timeval static timeout const char char static bufsiz const char static swapflags void static offset const char static length static mode static who const char struct statfs static buf unsigned unsigned num
Definition: sflib.h:126
int type
Definition: mipsasm.c:17
string FILE
Definition: benchmark.py:21
description
Definition: setup.py:259
const char * name
Definition: op.c:541
static RzSocket * s
Definition: rtr.c:28
struct rz_sysreg_db_t RzSysregsDB
struct rz_syscall_arch_plugin_t RzSyscallArchPlugin
struct rz_syscall_plugin_t RzSyscallPlugin
struct rz_syscall_t RzSyscall
struct rz_sysreg_item_t RzSysregItem
RZ_LIB_VERSION_HEADER(rz_syscall)
struct rz_syscall_item_t RzSyscallItem
#define RZ_NULLABLE
Definition: rz_types.h:65
#define RZ_OWN
Definition: rz_types.h:62
#define RZ_NONNULL
Definition: rz_types.h:64
Definition: z80asm.h:102
struct rz_syscall_args_t ** args
Definition: rz_syscall.h:87
struct rz_syscall_args_t * args
Definition: rz_syscall.h:78
char * os
Definition: rz_syscall.h:41
FILE * fd
Definition: rz_syscall.h:38
char * arch
Definition: rz_syscall.h:40
RzSyscallItem * sysptr
Definition: rz_syscall.h:45
RzSysregsDB * srdb
Definition: rz_syscall.h:47
char * cpu
Definition: rz_syscall.h:43
Definition: sdb.h:63
RZ_API RzSyscall * rz_syscall_new(void)
Creates a new RzSyscall type.
Definition: syscall.c:67
RZ_API void rz_sysreg_item_free(RzSysregItem *s)
Frees an RzSysregItem type.
Definition: syscall.c:97
RZ_API RzSysregsDB * rz_sysregs_db_new()
Creates a new RzSysregDB type.
Definition: syscall.c:40
RZ_API bool rz_sysreg_load_sdb(RzSysregsDB *sysregdb, const char *path)
Loads the RzSysregDB from the path to the hashtable.
Definition: syscall.c:198
RZ_API RzSyscall * rz_syscall_ref(RzSyscall *sc)
Definition: syscall.c:12
RZ_API void rz_syscall_free(RzSyscall *s)
Frees an RzSyscall type.
Definition: syscall.c:79
RZ_API void rz_syscall_item_free(RzSyscallItem *si)
Definition: syscall.c:325
RZ_API RZ_OWN RzSysregItem * rz_sysreg_item_new(RZ_NULLABLE const char *name)
Creates a new RzSysregItem type.
Definition: syscall.c:22
RZ_API int rz_syscall_get_swi(RzSyscall *s)
Definition: syscall.c:341
RZ_API bool rz_sysreg_set_arch(RzSyscall *s, RZ_NONNULL const char *arch, RZ_NONNULL const char *regs_dir)
Sets the architecture for sysregs during analysis and loads up the sysregs SDB database.
Definition: syscall.c:213
RZ_API int rz_syscall_get_num(RzSyscall *s, const char *str)
Definition: syscall.c:376
RZ_API RzSyscallItem * rz_syscall_item_new_from_string(const char *name, const char *s)
Definition: syscall.c:290
RZ_API RzSyscallItem * rz_syscall_get(RzSyscall *s, int num, int swi)
Definition: syscall.c:345
RZ_API const char * rz_sysreg_get(RzSyscall *s, const char *type, ut64 port)
Searches the sysregs SDB database inside librz/reg/d for the type (mmio/reg) and returns its value as...
Definition: syscall.c:433
RZ_API const char * rz_syscall_get_i(RzSyscall *s, int num, int swi)
Definition: syscall.c:388
RZ_API void rz_sysregs_db_free(RzSysregsDB *sysregdb)
Frees a RzSysregDB type.
Definition: syscall.c:56
RZ_API RzList * rz_syscall_list(RzSyscall *s)
Definition: syscall.c:415
RZ_API bool rz_syscall_setup(RzSyscall *s, const char *arch, int bits, const char *cpu, const char *os)
Definition: syscall.c:234
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static xtensa_sysreg_internal sysregs[]
static const z80_opcode fd[]
Definition: z80_tab.h:997