Rizin
unix-like reverse engineering framework and cli tools
rz_parse.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2009-2018 pancake <pancake@nopcode.org>
2 // SPDX-FileCopyrightText: 2009-2018 nibble <nibble.ds@gmail.com>
3 // SPDX-License-Identifier: LGPL-3.0-only
4 
5 #ifndef RZ_PARSE_H
6 #define RZ_PARSE_H
7 
8 #include <rz_types.h>
9 #include <rz_flag.h>
10 #include <rz_analysis.h>
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
17 
18 typedef RzList *(*RzAnalysisVarList)(RzAnalysisFunction *fcn, int kind);
19 
20 typedef struct rz_parse_t {
21  void *user;
24  bool pseudo;
25  bool subreg; // replace registers with their respective alias/role name (rdi=A0, ...)
26  bool subrel; // replace rip relative expressions in instruction
27  bool subtail; // replace any immediate relative to current address with .. prefix syntax
28  bool localvar_only; // if true use only the local variable name (e.g. [local_10h] instead of [ebp + local10h])
31  int minval;
32  char *retleave_asm;
34  // RzAnalysis *analysis; // weak analysis ref XXX do not use. use analb.anal
38  const char *(*get_reg_at)(RzAnalysisFunction *fcn, st64 delta, ut64 addr);
43 
44 typedef struct rz_parse_plugin_t {
45  char *name;
46  char *desc;
47  bool (*init)(RzParse *p, void *user);
48  int (*fini)(RzParse *p, void *user);
49  bool (*parse)(RzParse *p, const char *data, RzStrBuf *sb);
50  bool (*assemble)(RzParse *p, char *data, char *str);
51  int (*filter)(RzParse *p, ut64 addr, RzFlag *f, char *data, char *str, int len, bool big_endian);
52  bool (*subvar)(RzParse *p, RzAnalysisFunction *f, RzAnalysisOp *op, char *data, char *str, int len);
53  int (*replace)(int argc, const char *argv[], char *newstr);
55 
56 #ifdef RZ_API
57 
58 /* lifecycle */
59 RZ_API struct rz_parse_t *rz_parse_new(void);
61 
62 /* plugins */
65 RZ_API bool rz_parse_use(RzParse *p, const char *name);
66 
67 /* action */
68 RZ_API char *rz_parse_pseudocode(RzParse *p, const char *data);
69 RZ_API bool rz_parse_assemble(RzParse *p, char *data, char *str); // XXX deprecate, unused and probably useless, related to write-hack
70 RZ_API bool rz_parse_filter(RzParse *p, ut64 addr, RzFlag *f, RzAnalysisHint *hint, char *data, char *str, int len, bool big_endian);
72 RZ_API char *rz_parse_immtrim(char *opstr);
73 
74 /* plugin pointers */
81 extern RzParsePlugin rz_parse_plugin_dummy;
92 #endif
93 
94 #ifdef __cplusplus
95 }
96 #endif
97 
98 #endif
size_t len
Definition: 6502dis.c:15
ut8 op
Definition: 6502dis.c:13
static int opstr(RzAsm *a, ut8 *data, const Opcode *op)
Definition: asm_x86_nz.c:4054
static RASN1String * newstr(const char *string)
Definition: astr.c:23
static SblHeader sb
Definition: bin_mbn.c:26
#define RZ_API
void * p
Definition: libc.cpp:67
static RzMain foo[]
Definition: main.c:11
static static fork const void static count static fd const char const char static newpath char char argv
Definition: sflib.h:40
RZ_API bool rz_parse_filter(RzParse *p, ut64 addr, RzFlag *f, RzAnalysisHint *hint, char *data, char *str, int len, bool big_endian)
filter the opcode in data into str by following the flags and hints information
Definition: filter.c:592
RZ_API char * rz_parse_immtrim(char *opstr)
Definition: parse.c:127
RZ_API void rz_parse_set_user_ptr(RzParse *p, void *user)
Definition: parse.c:175
RZ_API void rz_parse_free(RzParse *p)
Definition: parse.c:40
RZ_API char * rz_parse_pseudocode(RzParse *p, const char *assembly)
Converts the assembly line into pseudocode.
Definition: parse.c:107
RZ_API bool rz_parse_add(RzParse *p, RzParsePlugin *foo)
Definition: parse.c:45
RZ_API RzParse * rz_parse_new(void)
Definition: parse.c:16
RZ_API bool rz_parse_use(RzParse *p, const char *name)
Definition: parse.c:56
RZ_API bool rz_parse_subvar(RzParse *p, RZ_NULLABLE RzAnalysisFunction *f, RZ_NONNULL RzAnalysisOp *op, RZ_NONNULL RZ_IN char *data, RZ_BORROW RZ_NONNULL RZ_OUT char *str, int len)
Definition: parse.c:166
RZ_API bool rz_parse_assemble(RzParse *p, char *data, char *str)
Definition: parse.c:72
RzParsePlugin rz_parse_plugin_6502_pseudo
RzParsePlugin rz_parse_plugin_arm_pseudo
RzParsePlugin rz_parse_plugin_att2intel
RzParsePlugin rz_parse_plugin_avr_pseudo
RzParsePlugin rz_parse_plugin_chip8_pseudo
RzParsePlugin rz_parse_plugin_dalvik_pseudo
RzParsePlugin rz_parse_plugin_m68k_pseudo
RzParsePlugin rz_parse_plugin_mips_pseudo
RzParsePlugin rz_parse_plugin_ppc_pseudo
RzParsePlugin rz_parse_plugin_riscv_pseudo
RzParsePlugin rz_parse_plugin_sh_pseudo
RzParsePlugin rz_parse_plugin_tms320_pseudo
RzParsePlugin rz_parse_plugin_v850_pseudo
RzParsePlugin rz_parse_plugin_wasm_pseudo
RzParsePlugin rz_parse_plugin_x86_pseudo
RzParsePlugin rz_parse_plugin_z80_pseudo
const char *(* RzAnalysisLabelAt)(RzAnalysisFunction *fcn, ut64)
Definition: rz_analysis.h:700
RzFlagItem *(* RzFlagGetAtAddr)(RzFlag *f, ut64)
Definition: rz_flag.h:61
RzList *(* RzAnalysisVarList)(RzAnalysisFunction *fcn, int kind)
Definition: rz_parse.h:18
RZ_LIB_VERSION_HEADER(rz_parse)
struct rz_parse_plugin_t RzParsePlugin
struct rz_parse_t RzParse
#define RZ_IN
Definition: rz_types.h:50
#define RZ_NULLABLE
Definition: rz_types.h:65
#define RZ_OUT
Definition: rz_types.h:51
#define RZ_NONNULL
Definition: rz_types.h:64
#define RZ_BORROW
Definition: rz_types.h:63
#define st64
Definition: rz_types_base.h:10
static int
Definition: sfsocketcall.h:114
#define f(i)
Definition: sha256.c:46
Definition: z80asm.h:102
Definition: regcomp.c:57
bool(* assemble)(RzParse *p, char *data, char *str)
Definition: rz_parse.h:50
int(* replace)(int argc, const char *argv[], char *newstr)
Definition: rz_parse.h:53
bool(* init)(RzParse *p, void *user)
Definition: rz_parse.h:47
bool(* subvar)(RzParse *p, RzAnalysisFunction *f, RzAnalysisOp *op, char *data, char *str, int len)
Definition: rz_parse.h:52
int(* fini)(RzParse *p, void *user)
Definition: rz_parse.h:48
ut64 subrel_addr
Definition: rz_parse.h:29
RzList * parsers
Definition: rz_parse.h:35
bool subtail
Definition: rz_parse.h:27
struct rz_parse_plugin_t * cur
Definition: rz_parse.h:33
RzFlagGetAtAddr flag_get
Definition: rz_parse.h:40
bool subrel
Definition: rz_parse.h:26
RzAnalysisBind analb
Definition: rz_parse.h:39
bool subreg
Definition: rz_parse.h:25
bool pseudo
Definition: rz_parse.h:24
int maxflagnamelen
Definition: rz_parse.h:30
RzAnalysisLabelAt label_get
Definition: rz_parse.h:41
void * user
Definition: rz_parse.h:21
bool localvar_only
Definition: rz_parse.h:28
RzSpace * notin_flagspace
Definition: rz_parse.h:23
int minval
Definition: rz_parse.h:31
char * retleave_asm
Definition: rz_parse.h:32
st64(* get_ptr_at)(RzAnalysisFunction *fcn, st64 delta, ut64 addr)
Definition: rz_parse.h:37
RzAnalysisVarList varlist
Definition: rz_parse.h:36
RzSpace * flagspace
Definition: rz_parse.h:22
#define bool
Definition: sysdefs.h:146
Definition: dis.c:32
static st64 delta
Definition: vmenus.c:2425
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static int addr
Definition: z80asm.c:58