diff --git a/libr/anal/anal.c b/libr/anal/anal.c index c83b32c51087f..e7659c549580d 100644 --- a/libr/anal/anal.c +++ b/libr/anal/anal.c @@ -7,9 +7,10 @@ #include #include "../config.h" -static RAnalPlugin *anal_static_plugins[] = +static RAnalPlugin *anal_static_plugins[] = { R_ANAL_STATIC_PLUGINS }; +/* static RAnalVarType anal_default_vartypes[] = {{ "char", "c", 1 }, { "byte", "b", 1 }, @@ -19,6 +20,7 @@ static RAnalVarType anal_default_vartypes[] = { "dword", "x", 4 }, { "float", "f", 4 }, { NULL, NULL, 0 }}; +*/ R_API RAnal *r_anal_new() { int i; @@ -40,7 +42,7 @@ R_API RAnal *r_anal_new() { anal->fcns = r_anal_fcn_list_new (); anal->fcnstore = r_listrange_new (); anal->refs = r_anal_ref_list_new (); - anal->vartypes = r_anal_var_type_list_new (); + anal->types = r_anal_type_list_new (); r_anal_set_bits (anal, 32); r_anal_set_big_endian (anal, R_FALSE); INIT_LIST_HEAD (&anal->anals); // TODO: use RList here @@ -49,9 +51,11 @@ R_API RAnal *r_anal_new() { memcpy (static_plugin, anal_static_plugins[i], sizeof (RAnalPlugin)); r_anal_add (anal, static_plugin); } +/* for (i=0; anal_default_vartypes[i].name; i++) r_anal_var_type_add (anal, anal_default_vartypes[i].name, anal_default_vartypes[i].size, anal_default_vartypes[i].fmt); +*/ return anal; } @@ -62,7 +66,7 @@ R_API void r_anal_free(RAnal *anal) { r_list_free (anal->fcns); // r_listrange_free (anal->fcnstore); // might provoke double frees since this is used in r_anal_fcn_insert() r_list_free (anal->refs); - r_list_free (anal->vartypes); + r_list_free (anal->types); r_list_free (anal->meta->data); r_reg_free(anal->reg); r_syscall_free(anal->syscall); @@ -166,7 +170,7 @@ R_API char *r_anal_strmask (RAnal *anal, const char *data) { R_API void r_anal_trace_bb(RAnal *anal, ut64 addr) { RAnalBlock *bbi; - RAnalFcn *fcni; + RAnalFunction *fcni; RListIter *iter, *iter2; VERBOSE_ANAL eprintf ("bbtraced\n"); // XXX Debug msg r_list_foreach (anal->fcns, iter, fcni) { diff --git a/libr/anal/bb.c b/libr/anal/bb.c index 33fa21c213c7a..dd5e58f306b2c 100644 --- a/libr/anal/bb.c +++ b/libr/anal/bb.c @@ -114,7 +114,7 @@ R_API inline int r_anal_bb_is_in_offset (RAnalBlock *bb, ut64 off) { R_API RAnalBlock *r_anal_bb_from_offset(RAnal *anal, ut64 off) { RListIter *iter, *iter2; - RAnalFcn *fcn; + RAnalFunction *fcn; RAnalBlock *bb; r_list_foreach (anal->fcns, iter, fcn) r_list_foreach (fcn->bbs, iter2, bb) diff --git a/libr/anal/cc.c b/libr/anal/cc.c index af27fb03628cb..a4fd909c9a278 100644 --- a/libr/anal/cc.c +++ b/libr/anal/cc.c @@ -39,7 +39,7 @@ R_API void r_anal_cc_reset (RAnalCC *cc) { //XXX: may overflow. this is vulnerable. needs fix R_API char *r_anal_cc_to_string (RAnal *anal, RAnalCC* cc) { RSyscallItem *si; - RAnalFcn *fcn; + RAnalFunction *fcn; char str[1024], buf[64]; int i, eax = 0; // eax = arg0 diff --git a/libr/anal/cparse/cdata.h b/libr/anal/cparse/cdata.h index 275c324be7130..dfc6257c0e0fc 100644 --- a/libr/anal/cparse/cdata.h +++ b/libr/anal/cparse/cdata.h @@ -22,22 +22,13 @@ typedef struct Token Token; #define R_ANAL_UINT64_T 4 #define NONE_SIGN 11 -#define NONE_MODIFIER 12 +#define NONE_QUALIFIER 12 #define R_ANAL_VAR_STATIC 0 #define R_ANAL_VAR_CONST 1 #define R_ANAL_VAR_REGISTER 2 #define R_ANAL_VAR_VOLATILE 3 -#define R_ANAL_FMODIFIER_NONE 0 -#define R_ANAL_FMODIFIER_STATIC 1 -#define R_ANAL_FMODIFIER_VOLATILE 2 -#define R_ANAL_FMODIFIER_INLINE 3 - -#define R_ANAL_CALLCONV_NONE 0 -#define R_ANAL_CALLCONV_STDCALL 1 -#define R_ANAL_CALLCONV_CCALL 2 - RAnalType* new_variable_node(char* name, short type, short sign, short modifier); RAnalType* new_pointer_node(char* name, short type, short sign, short modifier); RAnalType* new_array_node(char* name, short type, short sign, short modifier, long size); diff --git a/libr/anal/cparse/cparse.h b/libr/anal/cparse/cparse.h index 3844b9e6769d9..40d14853ab5eb 100644 --- a/libr/anal/cparse/cparse.h +++ b/libr/anal/cparse/cparse.h @@ -5,31 +5,37 @@ #define INLINE 5 #define VOLATILE 6 #define STATIC 7 -#define STDCALL 8 -#define CCALL 9 -#define ATTRIBUTE 10 -#define COMMA 11 -#define STRUCT 12 -#define OBRACE 13 -#define EBRACE 14 -#define UNION 15 -#define ASTERISK 16 -#define LBRACKET 17 -#define RBRACKET 18 -#define NUMBER 19 -#define CHAR 20 -#define SHORT 21 -#define INTEGER 22 -#define LONG 23 -#define FLOAT 24 -#define DOUBLE 25 -#define VOID 26 -#define UINT8 27 -#define UINT16 28 -#define UINT32 29 -#define UINT64 30 -#define SIGNED 31 -#define UNSIGNED 32 -#define CONST 33 -#define REGISTER 34 -#define IDENTIFIER 35 +#define NAKED 8 +#define VIRTUAL 9 +#define STDCALL 10 +#define CDECL 11 +#define FASTCALL 12 +#define PASCALCALL 13 +#define WINAPI 14 +#define THISCALL 15 +#define ATTRIBUTE 16 +#define COMMA 17 +#define STRUCT 18 +#define OBRACE 19 +#define EBRACE 20 +#define UNION 21 +#define ASTERISK 22 +#define LBRACKET 23 +#define RBRACKET 24 +#define NUMBER 25 +#define CHAR 26 +#define SHORT 27 +#define INTEGER 28 +#define LONG 29 +#define FLOAT 30 +#define DOUBLE 31 +#define VOID 32 +#define UINT8 33 +#define UINT16 34 +#define UINT32 35 +#define UINT64 36 +#define SIGNED 37 +#define UNSIGNED 38 +#define CONST 39 +#define REGISTER 40 +#define IDENTIFIER 41 diff --git a/libr/anal/cparse/cparse.l b/libr/anal/cparse/cparse.l index 59426432d1b2d..dff4f1918234a 100644 --- a/libr/anal/cparse/cparse.l +++ b/libr/anal/cparse/cparse.l @@ -26,6 +26,8 @@ "static" { return(STATIC); } "volatile" { return(VOLATILE); } "inline" { return(INLINE); } +"naked" { return(NAKED); } +"virtual" { return(VIRTUAL); } "struct" { return(STRUCT); } "union" { return(UNION); } "function" { return(FUNCTION); } @@ -41,7 +43,12 @@ "__attribute__" { return(ATTRIBUTE); } "__stdcall" { return(STDCALL); } -"__ccall" { return(CCALL); } +"__cdecl" { return(CDECL); } +"__fastcall" { return(FASTCALL); } +"__pascal" { return(PASCALCALL); } +"WINAPI" { return(WINAPI); } +"thiscall" { return(THISCALL); } + "{" { return(OBRACE); } "}" { return(EBRACE); } diff --git a/libr/anal/cparse/cparse.y b/libr/anal/cparse/cparse.y index 5be2c89575734..b1b8ed1873b39 100644 --- a/libr/anal/cparse/cparse.y +++ b/libr/anal/cparse/cparse.y @@ -38,30 +38,36 @@ def(A) ::= pointer(B). { A = B; } def(A) ::= array(B). { A = B; } function(A) ::= FUNCTION type(B) name(C) LPARENT arglist(D) RPARENT. { - A = new_function_node(C.sval, B.dval, D, R_ANAL_FMODIFIER_NONE, R_ANAL_CALLCONV_NONE, NULL); + A = new_function_node(C.sval, B.dval, D, R_ANAL_FQUALIFIER_NONE, R_ANAL_CC_TYPE_NONE, NULL); } -function(A) ::= FUNCTION fmodifier(B) type(C) name(D) LPARENT arglist(E) RPARENT. { - A = new_function_node(D.sval, C.dval, E, B.dval, R_ANAL_CALLCONV_NONE, NULL); +function(A) ::= FUNCTION fqualifier(B) type(C) name(D) LPARENT arglist(E) RPARENT. { + A = new_function_node(D.sval, C.dval, E, B.dval, R_ANAL_CC_TYPE_NONE, NULL); } function(A) ::= FUNCTION callconvention(B) type(C) name(D) LPARENT arglist(E) RPARENT. { - A = new_function_node(D.sval, C.dval, E, R_ANAL_FMODIFIER_NONE, B.dval, NULL); + A = new_function_node(D.sval, C.dval, E, R_ANAL_FQUALIFIER_NONE, B.dval, NULL); } -function(A) ::= FUNCTION callconvention(B) fmodifier(C) type(D) name(E) LPARENT arglist(F) RPARENT. { +function(A) ::= FUNCTION callconvention(B) fqualifier(C) type(D) name(E) LPARENT arglist(F) RPARENT. { A = new_function_node(E.sval, D.dval, F, C.dval, B.dval, NULL); } -function(A) ::= FUNCTION attribute(B) fmodifier(C) type(D) name(E) LPARENT arglist(F) RPARENT. { - A = new_function_node(E.sval, D.dval, F, C.dval, R_ANAL_CALLCONV_NONE, B.sval); +function(A) ::= FUNCTION attribute(B) fqualifier(C) type(D) name(E) LPARENT arglist(F) RPARENT. { + A = new_function_node(E.sval, D.dval, F, C.dval, R_ANAL_CC_TYPE_NONE, B.sval); } -function(A) ::= FUNCTION attribute(B) callconvention(C) fmodifier(D) type(E) name(F) LPARENT arglist(G) RPARENT. { +function(A) ::= FUNCTION attribute(B) callconvention(C) fqualifier(D) type(E) name(F) LPARENT arglist(G) RPARENT. { A = new_function_node(F.sval, E.dval, G, D.dval, C.dval, B.sval); } -fmodifier(A) ::= INLINE. { A.sval = "inline"; A.dval = R_ANAL_FMODIFIER_INLINE; } -fmodifier(A) ::= VOLATILE. { A.sval = "volatile"; A.dval = R_ANAL_FMODIFIER_VOLATILE; } -fmodifier(A) ::= STATIC. { A.sval = "static"; A.dval = R_ANAL_FMODIFIER_STATIC; } +fqualifier(A) ::= INLINE. { A.sval = "inline"; A.dval = R_ANAL_FQUALIFIER_INLINE; } +fqualifier(A) ::= VOLATILE. { A.sval = "volatile"; A.dval = R_ANAL_FQUALIFIER_VOLATILE; } +fqualifier(A) ::= STATIC. { A.sval = "static"; A.dval = R_ANAL_FQUALIFIER_STATIC; } +fqualifier(A) ::= NAKED. { A.sval = "naked"; A.dval = R_ANAL_FQUALIFIER_NAKED; } +fqualifier(A) ::= VIRTUAL. { A.sval = "virtual"; A.dval = R_ANAL_FQUALIFIER_VIRTUAL; } -callconvention(A) ::= STDCALL. { A.sval = "__stdcall"; A.dval = R_ANAL_CALLCONV_STDCALL; } -callconvention(A) ::= CCALL. { A.sval = "__ccall"; A.dval = R_ANAL_CALLCONV_CCALL; } +callconvention(A) ::= STDCALL. { A.sval = "__stdcall"; A.dval = R_ANAL_CC_TYPE_STDCALL; } +callconvention(A) ::= CDECL. { A.sval = "__cdecl"; A.dval = R_ANAL_CC_TYPE_CDECL; } +callconvention(A) ::= FASTCALL. { A.sval = "__fastcall"; A.dval = R_ANAL_CC_TYPE_FASTCALL; } +callconvention(A) ::= PASCALCALL. { A.sval = "__pascal"; A.dval = R_ANAL_CC_TYPE_PASCAL; } +callconvention(A) ::= WINAPI. { A.sval = "WINAPI"; A.dval = R_ANAL_CC_TYPE_WINAPI; } +callconvention(A) ::= THISCALL. { A.sval = "__thiscall"; A.dval = R_ANAL_CC_TYPE_THISCALL; } attribute(A) ::= ATTRIBUTE LPARENT LPARENT name(B) RPARENT RPARENT. { A.sval = B.sval; A.dval = 0; @@ -79,10 +85,10 @@ struct(A) ::= STRUCT name(B) OBRACE deflist(C) EBRACE. { union(A) ::= UNION name(B) OBRACE deflist(C) EBRACE. { A = new_union_node(B.sval, C); } -variable(A) ::= modifier(E) signedness(D) type(C) name(B). { +variable(A) ::= qualifier(E) signedness(D) type(C) name(B). { A = new_variable_node(B.sval, C.dval, D.dval, E.dval); } -variable(A) ::= modifier(E) shorttype(C) name(B). { +variable(A) ::= qualifier(E) shorttype(C) name(B). { switch (C.dval) { case R_ANAL_UINT8_T: A = new_variable_node(B.sval, R_ANAL_TYPE_SHORT, R_ANAL_TYPE_UNSIGNED, E.dval); @@ -100,10 +106,10 @@ variable(A) ::= modifier(E) shorttype(C) name(B). { break; } } -pointer(A) ::= modifier(E) signedness(D) type(C) ASTERISK name(B). { +pointer(A) ::= qualifier(E) signedness(D) type(C) ASTERISK name(B). { A = new_pointer_node(B.sval, C.dval, D.dval, E.dval); } -pointer(A) ::= modifier(E) shorttype(C) ASTERISK name(B). { +pointer(A) ::= qualifier(E) shorttype(C) ASTERISK name(B). { switch (C.dval) { case R_ANAL_UINT8_T: A = new_pointer_node(B.sval, R_ANAL_TYPE_SHORT, R_ANAL_TYPE_UNSIGNED, E.dval); @@ -121,10 +127,10 @@ pointer(A) ::= modifier(E) shorttype(C) ASTERISK name(B). { break; } } -array(A) ::= modifier(F) signedness(E) type(D) name(B) LBRACKET size(C) RBRACKET. { +array(A) ::= qualifier(F) signedness(E) type(D) name(B) LBRACKET size(C) RBRACKET. { A = new_array_node(B.sval, D.dval, E.dval, F.dval, C.dval); } -array(A) ::= modifier(F) shorttype(D) name(B) LBRACKET size(C) RBRACKET. { +array(A) ::= qualifier(F) shorttype(D) name(B) LBRACKET size(C) RBRACKET. { switch (D.dval) { case R_ANAL_UINT8_T: A = new_array_node(B.sval, R_ANAL_TYPE_SHORT, R_ANAL_TYPE_UNSIGNED, F.dval, C.dval); @@ -159,10 +165,10 @@ shorttype(A) ::= UINT64. { A.dval = R_ANAL_UINT64_T; } signedness(A) ::= . { A.sval = ""; A.dval = NONE_SIGN; } signedness(A) ::= SIGNED. { A.sval = "signed"; A.dval = R_ANAL_TYPE_SIGNED; } signedness(A) ::= UNSIGNED. { A.sval = "unsigned"; A.dval = R_ANAL_TYPE_UNSIGNED; } -modifier(A) ::= . { A.sval = ""; A.dval = NONE_MODIFIER; } -modifier(A) ::= STATIC. { A.sval = "static"; A.dval = R_ANAL_VAR_STATIC; } -modifier(A) ::= CONST. {A.sval = "const"; A.dval = R_ANAL_VAR_CONST; } -modifier(A) ::= REGISTER. { A.sval = "register"; A.dval = R_ANAL_VAR_REGISTER; } -modifier(A) ::= VOLATILE. { A.sval = "volatile"; A.dval = R_ANAL_VAR_VOLATILE; } +qualifier(A) ::= . { A.sval = ""; A.dval = NONE_QUALIFIER; } +qualifier(A) ::= STATIC. { A.sval = "static"; A.dval = R_ANAL_VAR_STATIC; } +qualifier(A) ::= CONST. {A.sval = "const"; A.dval = R_ANAL_VAR_CONST; } +qualifier(A) ::= REGISTER. { A.sval = "register"; A.dval = R_ANAL_VAR_REGISTER; } +qualifier(A) ::= VOLATILE. { A.sval = "volatile"; A.dval = R_ANAL_VAR_VOLATILE; } name(A) ::= IDENTIFIER(B). { A.sval = B.sval; } diff --git a/libr/anal/cparse/tree.c b/libr/anal/cparse/tree.c index ae172e96964d1..0b8cde925c27a 100644 --- a/libr/anal/cparse/tree.c +++ b/libr/anal/cparse/tree.c @@ -7,6 +7,7 @@ static int new_tree() { return 0; } +#if 0 static int print_tree(RAnalType *t) { RAnalType *p = t; if (!p) { @@ -22,7 +23,7 @@ static int print_tree(RAnalType *t) { eprintf("ptr %s\n", p->custom.p->name); break; case R_ANAL_TYPE_ARRAY: - eprintf("arr %s[%ld]\n", p->custom.a->name, p->custom.a->count); + eprintf("arr %s[%lld]\n", p->custom.a->name, p->custom.a->count); break; case R_ANAL_TYPE_STRUCT: eprintf("Entering struct %s...\n", p->custom.s->name); @@ -44,6 +45,7 @@ static int print_tree(RAnalType *t) { } return R_TRUE; } +#endif RAnalType* new_variable_node(char* name, short type, short sign, short modifier) { RAnalTypeVar *ivar = R_NEW (RAnalTypeVar); @@ -113,7 +115,7 @@ RAnalType* new_union_node(char* name, RAnalType *defs) { /* Function can return another function or have multiple returns */ //item_list* new_function_node(char* name, item_list *rets, item_list *args) RAnalType* new_function_node(char* name, short ret_type, RAnalType *args, short fmodifier, short callconvention, char* attributes) { - RAnalTypeFunction *ifnc = R_NEW (RAnalTypeFunction); + RAnalFunction *ifnc = R_NEW (RAnalFunction); RAnalType *tmp = R_NEW (RAnalType); ifnc->name = name; ifnc->rets = ret_type; diff --git a/libr/anal/diff.c b/libr/anal/diff.c index d1b6e4218dd7b..82a95dedd060b 100644 --- a/libr/anal/diff.c +++ b/libr/anal/diff.c @@ -75,7 +75,7 @@ R_API int r_anal_diff_fingerprint_bb(RAnal *anal, RAnalBlock *bb) { return bb->size; } -R_API int r_anal_diff_fingerprint_fcn(RAnal *anal, RAnalFcn *fcn) { +R_API int r_anal_diff_fingerprint_fcn(RAnal *anal, RAnalFunction *fcn) { RAnalBlock *bb; RListIter *iter; int len = 0; @@ -94,7 +94,7 @@ R_API int r_anal_diff_fingerprint_fcn(RAnal *anal, RAnalFcn *fcn) { return len; } -R_API int r_anal_diff_bb(RAnal *anal, RAnalFcn *fcn, RAnalFcn *fcn2) { +R_API int r_anal_diff_bb(RAnal *anal, RAnalFunction *fcn, RAnalFunction *fcn2) { RAnalBlock *bb, *bb2, *mbb, *mbb2; RListIter *iter, *iter2; double t, ot; @@ -141,7 +141,7 @@ R_API int r_anal_diff_bb(RAnal *anal, RAnalFcn *fcn, RAnalFcn *fcn2) { } R_API int r_anal_diff_fcn(RAnal *anal, RList *fcns, RList *fcns2) { - RAnalFcn *fcn, *fcn2, *mfcn, *mfcn2; + RAnalFunction *fcn, *fcn2, *mfcn, *mfcn2; RListIter *iter, *iter2; ut64 maxsize, minsize; double t, ot; diff --git a/libr/anal/fcn.c b/libr/anal/fcn.c index cbc609216e259..fed7fb6e44cb2 100644 --- a/libr/anal/fcn.c +++ b/libr/anal/fcn.c @@ -9,19 +9,28 @@ #define USE_NEW_FCN_STORE 0 /* faster retrival, slower storage */ -R_API RAnalFcn *r_anal_fcn_new() { - RAnalFcn *fcn = R_NEW (RAnalFcn); +R_API RAnalFunction *r_anal_fcn_new() { + RAnalFunction *fcn = R_NEW (RAnalFunction); if (!fcn) return NULL; - memset (fcn, 0, sizeof (RAnalFcn)); + memset (fcn, 0, sizeof (RAnalFunction)); + fcn->name = NULL; + fcn->dsc = NULL; + /* Function return type */ + fcn->rets = 0; + /* Function qualifier: static/volatile/inline/naked/virtual */ + fcn->fmod = R_ANAL_FQUALIFIER_NONE; + /* Function calling convention: cdecl/stdcall/fastcall/etc */ + fcn->call = R_ANAL_CC_TYPE_NONE; + /* Function attributes: weak/noreturn/format/etc */ + fcn->attr = NULL; fcn->addr = -1; - fcn->stack = 0; - fcn->size = 0; fcn->vars = r_anal_var_list_new (); fcn->refs = r_anal_ref_list_new (); fcn->xrefs = r_anal_ref_list_new (); fcn->bbs = r_anal_bb_list_new (); fcn->fingerprint = NULL; fcn->diff = r_anal_diff_new (); + fcn->args = NULL; return fcn; } @@ -33,19 +42,21 @@ R_API RList *r_anal_fcn_list_new() { } R_API void r_anal_fcn_free(void *_fcn) { - RAnalFcn *fcn = _fcn; + RAnalFunction *fcn = _fcn; if (!_fcn) return; free (fcn->name); + free (fcn->attr); r_list_free (fcn->refs); r_list_free (fcn->xrefs); r_list_free (fcn->vars); r_list_free (fcn->bbs); free (fcn->fingerprint); r_anal_diff_free (fcn->diff); + free (fcn->args); free (fcn); } -R_API int r_anal_fcn_xref_add (RAnal *anal, RAnalFcn *fcn, ut64 at, ut64 addr, int type) { +R_API int r_anal_fcn_xref_add (RAnal *anal, RAnalFunction *fcn, ut64 at, ut64 addr, int type) { RAnalRef *ref; if (!fcn || !anal) return R_FALSE; @@ -59,7 +70,7 @@ R_API int r_anal_fcn_xref_add (RAnal *anal, RAnalFcn *fcn, ut64 at, ut64 addr, i return R_TRUE; } -R_API int r_anal_fcn_xref_del (RAnal *anal, RAnalFcn *fcn, ut64 at, ut64 addr, int type) { +R_API int r_anal_fcn_xref_del (RAnal *anal, RAnalFunction *fcn, ut64 at, ut64 addr, int type) { RAnalRef *ref; RListIter *iter; /* No _safe loop necessary because we return immediately after the delete. */ @@ -74,7 +85,7 @@ R_API int r_anal_fcn_xref_del (RAnal *anal, RAnalFcn *fcn, ut64 at, ut64 addr, i return R_FALSE; } -R_API int r_anal_fcn(RAnal *anal, RAnalFcn *fcn, ut64 addr, ut8 *buf, ut64 len, int reftype) { +R_API int r_anal_fcn(RAnal *anal, RAnalFunction *fcn, ut64 addr, ut8 *buf, ut64 len, int reftype) { RAnalOp op = {0}; char *varname; int oplen, idx = 0; @@ -110,11 +121,11 @@ R_API int r_anal_fcn(RAnal *anal, RAnalFcn *fcn, ut64 addr, ut8 *buf, ut64 len, if (op.ref > 0) { varname = r_str_dup_printf ("arg_%x", op.ref); r_anal_var_add (anal, fcn, op.addr, op.ref, - R_ANAL_VAR_TYPE_ARG|R_ANAL_VAR_DIR_IN, NULL, varname, 1); + R_ANAL_VAR_SCOPE_ARG|R_ANAL_VAR_DIR_IN, NULL, varname, 1); } else { varname = r_str_dup_printf ("local_%x", -op.ref); r_anal_var_add (anal, fcn, op.addr, -op.ref, - R_ANAL_VAR_TYPE_LOCAL|R_ANAL_VAR_DIR_NONE, NULL, varname, 1); + R_ANAL_VAR_SCOPE_LOCAL|R_ANAL_VAR_DIR_NONE, NULL, varname, 1); } free (varname); break; @@ -122,11 +133,11 @@ R_API int r_anal_fcn(RAnal *anal, RAnalFcn *fcn, ut64 addr, ut8 *buf, ut64 len, if (op.ref > 0) { varname = r_str_dup_printf ("arg_%x", op.ref); r_anal_var_add (anal, fcn, op.addr, op.ref, - R_ANAL_VAR_TYPE_ARG|R_ANAL_VAR_DIR_IN, NULL, varname, 0); + R_ANAL_VAR_SCOPE_ARG|R_ANAL_VAR_DIR_IN, NULL, varname, 0); } else { varname = r_str_dup_printf ("local_%x", -op.ref); r_anal_var_add (anal, fcn, op.addr, -op.ref, - R_ANAL_VAR_TYPE_LOCAL|R_ANAL_VAR_DIR_NONE, NULL, varname, 0); + R_ANAL_VAR_SCOPE_LOCAL|R_ANAL_VAR_DIR_NONE, NULL, varname, 0); } free (varname); break; @@ -153,8 +164,8 @@ R_API int r_anal_fcn(RAnal *anal, RAnalFcn *fcn, ut64 addr, ut8 *buf, ut64 len, return fcn->size; } -// TODO: need to implement r_anal_fcn_remove(RAnal *anal, RAnalFcn *fcn); -R_API int r_anal_fcn_insert(RAnal *anal, RAnalFcn *fcn) { +// TODO: need to implement r_anal_fcn_remove(RAnal *anal, RAnalFunction *fcn); +R_API int r_anal_fcn_insert(RAnal *anal, RAnalFunction *fcn) { #if USE_NEW_FCN_STORE r_listrange_add (anal->fcnstore, fcn); // HUH? store it here .. for backweird compatibility @@ -167,7 +178,7 @@ R_API int r_anal_fcn_insert(RAnal *anal, RAnalFcn *fcn) { R_API int r_anal_fcn_add(RAnal *anal, ut64 addr, ut64 size, const char *name, int type, RAnalDiff *diff) { int append = 0; - RAnalFcn *fcn = r_anal_fcn_find (anal, addr, R_ANAL_FCN_TYPE_ROOT); + RAnalFunction *fcn = r_anal_fcn_find (anal, addr, R_ANAL_FCN_TYPE_ROOT); if (fcn == NULL) { if (!(fcn = r_anal_fcn_new ())) return R_FALSE; @@ -201,10 +212,10 @@ R_API int r_anal_fcn_del(RAnal *anal, ut64 addr) { } else { #if USE_NEW_FCN_STORE // XXX: must only get the function if starting at 0? - RAnalFcn *f = r_listrange_find_in_range (anal->fcnstore, addr); + RAnalFunction *f = r_listrange_find_in_range (anal->fcnstore, addr); if (f) r_listrange_del (anal->fcnstore, f); #else - RAnalFcn *fcni; + RAnalFunction *fcni; RListIter *iter, *iter_tmp; r_list_foreach_safe (anal->fcns, iter, iter_tmp, fcni) { if (addr >= fcni->addr && addr < fcni->addr+fcni->size) { @@ -216,13 +227,13 @@ R_API int r_anal_fcn_del(RAnal *anal, ut64 addr) { return R_TRUE; } -R_API RAnalFcn *r_anal_fcn_find(RAnal *anal, ut64 addr, int type) { +R_API RAnalFunction *r_anal_fcn_find(RAnal *anal, ut64 addr, int type) { #if USE_NEW_FCN_STORE // TODO: type is ignored here? wtf.. we need more work on fcnstore if (root) return r_listrange_find_root (anal->fcnstore, addr); return r_listrange_find_in_range (anal->fcnstore, addr); #else - RAnalFcn *fcn, *ret = NULL; + RAnalFunction *fcn, *ret = NULL; RListIter *iter; if (type == R_ANAL_FCN_TYPE_ROOT) { r_list_foreach (anal->fcns, iter, fcn) { @@ -241,8 +252,8 @@ R_API RAnalFcn *r_anal_fcn_find(RAnal *anal, ut64 addr, int type) { #endif } -/* rename RAnalFcnBB.add() */ -R_API int r_anal_fcn_add_bb(RAnalFcn *fcn, ut64 addr, ut64 size, ut64 jump, ut64 fail, int type, RAnalDiff *diff) { +/* rename RAnalFunctionBB.add() */ +R_API int r_anal_fcn_add_bb(RAnalFunction *fcn, ut64 addr, ut64 size, ut64 jump, ut64 fail, int type, RAnalDiff *diff) { RAnalBlock *bb = NULL, *bbi; RListIter *iter; int append = 0, mid = 0; @@ -280,7 +291,7 @@ R_API int r_anal_fcn_add_bb(RAnalFcn *fcn, ut64 addr, ut64 size, ut64 jump, ut64 } // TODO: rename fcn_bb_split() -R_API int r_anal_fcn_split_bb(RAnalFcn *fcn, RAnalBlock *bb, ut64 addr) { +R_API int r_anal_fcn_split_bb(RAnalFunction *fcn, RAnalBlock *bb, ut64 addr) { RAnalBlock *bbi; #if R_ANAL_BB_HAS_OPS RAnalOp *opi; @@ -328,7 +339,7 @@ R_API int r_anal_fcn_split_bb(RAnalFcn *fcn, RAnalBlock *bb, ut64 addr) { } // TODO: rename fcn_bb_overlap() -R_API int r_anal_fcn_overlap_bb(RAnalFcn *fcn, RAnalBlock *bb) { +R_API int r_anal_fcn_overlap_bb(RAnalFunction *fcn, RAnalBlock *bb) { RAnalBlock *bbi; RListIter *iter; #if R_ANAL_BB_HAS_OPS @@ -362,7 +373,7 @@ R_API int r_anal_fcn_overlap_bb(RAnalFcn *fcn, RAnalBlock *bb) { return R_ANAL_RET_NEW; } -R_API int r_anal_fcn_cc(RAnalFcn *fcn) { +R_API int r_anal_fcn_cc(RAnalFunction *fcn) { struct r_anal_bb_t *bbi; RListIter *iter; int ret = 0, retbb; @@ -374,54 +385,76 @@ R_API int r_anal_fcn_cc(RAnalFcn *fcn) { return ret; } -R_API RAnalVar *r_anal_fcn_get_var(RAnalFcn *fs, int num, int type) { +R_API RAnalVar *r_anal_fcn_get_var(RAnalFunction *fs, int num, int type) { RAnalVar *var; RListIter *iter; int count = 0; // vars are sorted by delta in r_anal_var_add() r_list_foreach (fs->vars, iter, var) { - if (type & var->type) + //if (type & var->type) /* What we need to use here? */ if (count++ == num) return var; } return NULL; } -R_API char *r_anal_fcn_to_string(RAnal *a, RAnalFcn* fs) { +R_API char *r_anal_fcn_to_string(RAnal *a, RAnalFunction* fs) { int i; char *sign; RAnalVar *arg, *ret; if (fs->type != R_ANAL_FCN_TYPE_FCN || fs->type != R_ANAL_FCN_TYPE_SYM) return NULL; - ret = r_anal_fcn_get_var (fs, 0, R_ANAL_VAR_TYPE_RET); + ret = r_anal_fcn_get_var (fs, 0, R_ANAL_VAR_SCOPE_RET); sign = ret? r_str_newf ("%s %s (", ret->name, fs->name): r_str_newf ("void %s (", fs->name); + /* FIXME: Use RAnalType instead */ for (i=0; ; i++) { if (!(arg = r_anal_fcn_get_var (fs, i, - R_ANAL_VAR_TYPE_ARG|R_ANAL_VAR_TYPE_ARGREG))) + R_ANAL_VAR_SCOPE_ARG|R_ANAL_VAR_SCOPE_ARGREG))) break; - if (arg->array>1) + if (arg->type->type == R_ANAL_TYPE_ARRAY) sign = r_str_concatf (sign, i?", %s %s:%02x[%d]":"%s %s:%02x[%d]", - arg->vartype, arg->name, arg->delta, arg->array); + arg->type, arg->name, arg->delta, arg->type->custom.a->count); else sign = r_str_concatf (sign, i?", %s %s:%02x":"%s %s:%02x", - arg->vartype, arg->name, arg->delta); + arg->type, arg->name, arg->delta); } return (sign = r_str_concatf (sign, ");")); } // TODO: This function is not fully implemented /* set function signature from string */ -R_API int r_anal_fcn_from_string(RAnal *a, RAnalFcn *f, const char *sig) { +R_API int r_anal_str_to_fcn(RAnal *a, RAnalFunction *f, const char *sig) { char *p, *q, *r, *str; RAnalVar *var; + RAnalType *t; int i, arg; if (!a || !f || !sig) { - eprintf ("r_anal_fcn_from_string: No function received\n"); + eprintf ("r_anal_str_to_fcn: No function received\n"); return R_FALSE; } + + /* Add 'function' keyword */ + str = malloc(strlen(sig) + 10); + strcpy(str, "function "); + strcat(str, sig); + + /* Send whole definition to cparse */ + int yv, yylval; + void *pParser = cdataParseAlloc(malloc); + yy_scan_string(str); + while ((yv = yylex()) != 0) { + cdataParse(pParser, yv, yylval); + } + cdataParse(pParser, 0, yylval); + cdataParseFree(pParser, free); + + /* TODO: Improve arguments parsing */ + +/* str = strdup (sig); - /* TODO : implement parser */ + + // TODO : implement parser //r_list_destroy (fs->vars); //set: fs->vars = r_list_new (); //set: fs->name @@ -434,15 +467,15 @@ R_API int r_anal_fcn_from_string(RAnal *a, RAnalFcn *f, const char *sig) { *q = 0; printf ("RET=(%s)\n", str); printf ("NAME=(%s)\n", q+1); - /* set function name */ + // set function name free (f->name); f->name = strdup (q+1); - /* set return value */ + // set return value // TODO: simplify this complex api usage r_anal_var_add (a, f, 0LL, 0, - R_ANAL_VAR_TYPE_RET|R_ANAL_VAR_DIR_OUT, str, "ret", 1); + R_ANAL_VAR_SCOPE_RET|R_ANAL_VAR_DIR_OUT, t, "ret", 1); - /* parse arguments */ + // parse arguments for (i=arg=0,p++;;p=q+1,i++) { q = strchr (p, ','); if (!q) { @@ -457,24 +490,26 @@ R_API int r_anal_fcn_from_string(RAnal *a, RAnalFcn *f, const char *sig) { r = r_str_chop (r+1); printf ("VAR %d=(%s)(%s)\n", arg, p, r); // TODO : increment arg by var size - if ((var = r_anal_fcn_get_var (f, i, R_ANAL_VAR_TYPE_ARG|R_ANAL_VAR_TYPE_ARGREG))) { - free (var->name); var->name = strdup (r); - free (var->vartype); var->vartype = strdup (p); - } else r_anal_var_add (a, f, 0LL, arg, R_ANAL_VAR_TYPE_ARG|R_ANAL_VAR_DIR_IN, p, r, 0); + if ((var = r_anal_fcn_get_var (f, i, R_ANAL_VAR_SCOPE_ARG|R_ANAL_VAR_SCOPE_ARGREG))) { + free (var->name); var->name = strdup(r); + // FIXME: add cparse function + free (var->type); var->type = r_anal_str_to_type(p); + } else r_anal_var_add (a, f, 0LL, arg, R_ANAL_VAR_SCOPE_ARG|R_ANAL_VAR_DIR_IN, p, r, 0); arg++; } // r_anal_fcn_set_var (fs, 0, R_ANAL_VAR_DIR_OUT, ); free (str); +*/ return R_TRUE; - parsefail: - free (str); - eprintf ("Function string parse fail\n"); - return R_FALSE; + //parsefail: + //free (str); + //eprintf ("Function string parse fail\n"); + //return R_FALSE; } -R_API RAnalFcn *r_anal_get_fcn_at(RAnal *anal, ut64 addr) { - RAnalFcn *fcni; +R_API RAnalFunction *r_anal_get_fcn_at(RAnal *anal, ut64 addr) { + RAnalFunction *fcni; RListIter *iter; //eprintf ("DEPRECATED: get-at\n"); r_list_foreach (anal->fcns, iter, fcni) @@ -485,11 +520,11 @@ R_API RAnalFcn *r_anal_get_fcn_at(RAnal *anal, ut64 addr) { } /* getters */ -R_API RList* r_anal_fcn_get_refs (RAnalFcn *anal) { return anal->refs; } -R_API RList* r_anal_fcn_get_xrefs (RAnalFcn *anal) { return anal->xrefs; } -R_API RList* r_anal_fcn_get_vars (RAnalFcn *anal) { return anal->vars; } -R_API RList* r_anal_fcn_get_bbs (RAnalFcn *anal) { return anal->bbs; } +R_API RList* r_anal_fcn_get_refs (RAnalFunction *anal) { return anal->refs; } +R_API RList* r_anal_fcn_get_xrefs (RAnalFunction *anal) { return anal->xrefs; } +R_API RList* r_anal_fcn_get_vars (RAnalFunction *anal) { return anal->vars; } +R_API RList* r_anal_fcn_get_bbs (RAnalFunction *anal) { return anal->bbs; } -R_API int r_anal_fcn_is_in_offset (RAnalFcn *fcn, ut64 addr) { +R_API int r_anal_fcn_is_in_offset (RAnalFunction *fcn, ut64 addr) { return (addr >= fcn->addr && addr < (fcn->addr+fcn->size)); } diff --git a/libr/anal/fcnstore.c b/libr/anal/fcnstore.c index 3c3d615564ed5..f6a7c7a7ce963 100644 --- a/libr/anal/fcnstore.c +++ b/libr/anal/fcnstore.c @@ -13,8 +13,8 @@ #include static int cmpfun(void *a, void *b) { - RAnalFcn *fa = (RAnalFcn*)a; - RAnalFcn *fb = (RAnalFcn*)b; + RAnalFunction *fa = (RAnalFunction*)a; + RAnalFunction *fb = (RAnalFunction*)b; // TODO: swap sort order here or wtf? return (fb->addr - fa->addr); } @@ -46,7 +46,7 @@ R_API void r_listrange_free(RListRange *s) { free (s); } -R_API void r_listrange_add(RListRange *s, RAnalFcn *f) { +R_API void r_listrange_add(RListRange *s, RAnalFunction *f) { ut64 addr; RList *list; ut64 from = f->addr; @@ -68,7 +68,7 @@ R_API void r_listrange_add(RListRange *s, RAnalFcn *f) { r_list_add_sorted (s->l, f, cmpfun); } -R_API void r_listrange_del(RListRange *s, RAnalFcn *f) { +R_API void r_listrange_del(RListRange *s, RAnalFunction *f) { RList *list; ut64 addr, from, to; if (!f) return; @@ -81,14 +81,14 @@ R_API void r_listrange_del(RListRange *s, RAnalFcn *f) { r_list_delete_data (s->l, f); } -R_API void r_listrange_resize(RListRange *s, RAnalFcn *f, int newsize) { +R_API void r_listrange_resize(RListRange *s, RAnalFunction *f, int newsize) { r_listrange_del (s, f); f->size = newsize; r_listrange_add (s, f); } -R_API RAnalFcn *r_listrange_find_in_range(RListRange* s, ut64 addr) { - RAnalFcn *f; +R_API RAnalFunction *r_listrange_find_in_range(RListRange* s, ut64 addr) { + RAnalFunction *f; RListIter *iter; RList *list = r_hashtable64_lookup (s->h, r_listrange_key (addr)); if (list) @@ -99,8 +99,8 @@ R_API RAnalFcn *r_listrange_find_in_range(RListRange* s, ut64 addr) { return NULL; } -R_API RAnalFcn *r_listrange_find_root(RListRange* s, ut64 addr) { - RAnalFcn *f; +R_API RAnalFunction *r_listrange_find_root(RListRange* s, ut64 addr) { + RAnalFunction *f; RListIter *iter; RList *list = r_hashtable64_lookup (s->h, r_listrange_key (addr)); if (list) diff --git a/libr/anal/op.c b/libr/anal/op.c index f96b7105a562f..eea1c082d8d2f 100644 --- a/libr/anal/op.c +++ b/libr/anal/op.c @@ -129,7 +129,7 @@ R_API int r_anal_op_execute (RAnal *anal, RAnalOp *op) { } R_API char *r_anal_op_to_string(RAnal *anal, RAnalOp *op) { - RAnalFcn *f; + RAnalFunction *f; char ret[128]; char *cstr; char *r0 = r_anal_value_to_string (op->dst); diff --git a/libr/anal/ref.c b/libr/anal/ref.c index 45f507a5d72c4..2053514660fac 100644 --- a/libr/anal/ref.c +++ b/libr/anal/ref.c @@ -65,7 +65,7 @@ R_API int r_anal_ref_del(RAnal *anal, ut64 at) { } R_API RList *r_anal_xref_get(RAnal *anal, ut64 addr) { - RAnalFcn *fcni; + RAnalFunction *fcni; RAnalRef *refi, *ref; RListIter *iter, *iter2; RList *ret; diff --git a/libr/anal/type.c b/libr/anal/type.c index a0e1eca89a4d3..ba635cc3fb8d5 100644 --- a/libr/anal/type.c +++ b/libr/anal/type.c @@ -29,34 +29,55 @@ R_API RMetaType *r_meta_type_new() { R_API RAnalType *r_anal_type_new() { RAnalType *t = R_NEW(RAnalType); - return NULL; + return t; +} + +R_API RList *r_anal_type_list_new() { + RList *t = R_NEW(RList); + return t; } -R_API void r_anal_type_del() { +// TODO: Insert type in types list +R_API void r_anal_type_add(RList *l, RAnalType *t) { } -R_API void r_anal_type_cleanup() { +// TODO: Remove type from types list +R_API void r_anal_type_del(RList *l, const char* name) { } -R_API void r_anal_type_free(RAnalType *t) { +R_API RAnalType *r_anal_type_free(RAnalType *t) { free(t); + return t; } -R_API void r_anal_type_list() { +R_API void r_anal_type_list(RList *t, short category, short enabled) { + // List all types by category: var/struct/unions/pointers } R_API RAnalType *r_anal_type_find(char *name) { - + return NULL; } -R_API char* r_anal_type_to_string(char* name) { +R_API char* r_anal_type_to_str(RAnal *a, RAnalType *t) { + return ""; +} +R_API RAnalType *r_anal_str_to_type(RAnal *a, const char* type) { + int yv; + void *pParser = cdataParseAlloc(malloc); + yy_scan_string(type); + while ((yv = yylex()) != 0) { + cdataParse(pParser, yv, yylval); + } + cdataParse(pParser, 0, yylval); + cdataParseFree(pParser, free); + return NULL; } -R_API RAnalType *r_anal_type_loadfile(char *path) { +R_API RAnalType *r_anal_type_loadfile(RAnal *a, const char *path) { FILE *cfile; int n; - int yv; + int yv, yylval; char buf[4096]; void *pParser = cdataParseAlloc(malloc); @@ -71,8 +92,5 @@ R_API RAnalType *r_anal_type_loadfile(char *path) { fclose(cfile); cdataParse(pParser, 0, yylval); cdataParseFree(pParser, free); -} - -R_API RAnalType *r_anal_type_loadstring(char *buf) { return NULL; } diff --git a/libr/anal/var.c b/libr/anal/var.c index 84cfa65831ca5..d9c4b85ad8986 100644 --- a/libr/anal/var.c +++ b/libr/anal/var.c @@ -15,13 +15,6 @@ R_API RAnalVar *r_anal_var_new() { return var; } -R_API RAnalVarType *r_anal_var_type_new() { - RAnalVarType *vartype = R_NEW (RAnalVarType); - if (vartype) - memset (vartype, 0, sizeof (RAnalVarType)); - return vartype; -} - R_API RAnalVarAccess *r_anal_var_access_new() { RAnalVarAccess *access = R_NEW (RAnalVarAccess); if (access) @@ -35,12 +28,6 @@ R_API RList *r_anal_var_list_new() { return list; } -R_API RList *r_anal_var_type_list_new() { - RList *list = r_list_new (); - list->free = &r_anal_var_type_free; - return list; -} - R_API RList *r_anal_var_access_list_new() { RList *list = r_list_new (); list->free = &r_anal_var_access_free; @@ -51,67 +38,24 @@ R_API void r_anal_var_free(void *var) { if (var) { if (((RAnalVar*)var)->name) free (((RAnalVar*)var)->name); - if (((RAnalVar*)var)->vartype) - free (((RAnalVar*)var)->vartype); + if (((RAnalVar*)var)->type) + free (((RAnalVar*)var)->type); if (((RAnalVar*)var)->accesses) r_list_free (((RAnalVar*)var)->accesses); free (var); } } -R_API void r_anal_var_type_free(void *vartype) { - if (vartype) { - if (((RAnalVarType*)vartype)->name) - free (((RAnalVarType*)vartype)->name); - if (((RAnalVarType*)vartype)->fmt) - free (((RAnalVarType*)vartype)->fmt); - } - free (vartype); -} - R_API void r_anal_var_access_free(void *access) { free (access); } -R_API int r_anal_var_type_add(RAnal *anal, const char *name, int size, const char *fmt) { - RAnalVarType *t; - if (!(t = r_anal_var_type_new ())) - return R_FALSE; - if (name) - t->name = strdup (name); - if (fmt) - t->fmt = strdup (fmt); - t->size = size; - r_list_append (anal->vartypes, t); - return R_TRUE; -} - -R_API int r_anal_var_type_del(RAnal *anal, const char *name) { - RAnalVarType *vti; - RListIter *iter; - /* No _safe loop necessary because we return immediately after the delete. */ - r_list_foreach(anal->vartypes, iter, vti) - if (!strcmp (name, vti->name)) { - r_list_unlink (anal->vartypes, vti); - return R_TRUE; - } - return R_FALSE; -} - -R_API RAnalVarType *r_anal_var_type_get(RAnal *anal, const char *name) { - RAnalVarType *vti; - RListIter *iter; - r_list_foreach (anal->vartypes, iter, vti) - if (!strcmp (name, vti->name)) - return vti; - return NULL; -} - static int cmpdelta(RAnalVar *a, RAnalVar *b) { return (a->delta - b->delta); } -R_API int r_anal_var_add(RAnal *anal, RAnalFcn *fcn, ut64 from, int delta, int type, const char *vartype, const char *name, int set) { +/* Add local variable for selected function */ +R_API int r_anal_var_add(RAnal *anal, RAnalFunction *fcn, ut64 from, int delta, int scope, const RAnalType *type, const char *name, int set) { RAnalVar *var, *vari; RListIter *iter; if (from != 0LL) @@ -122,10 +66,10 @@ R_API int r_anal_var_add(RAnal *anal, RAnalFcn *fcn, ut64 from, int delta, int t return R_FALSE; if (name) var->name = strdup (name); - if (vartype) - var->vartype = strdup (vartype); + if (type) + var->type = type; var->type = type; - if ((type & R_ANAL_VAR_TYPE_ARG) || (type & R_ANAL_VAR_TYPE_ARGREG)) + if ((scope & R_ANAL_VAR_SCOPE_ARG) || (scope & R_ANAL_VAR_SCOPE_ARGREG)) fcn->nargs++; var->delta = delta; if (from != 0LL) @@ -134,40 +78,40 @@ R_API int r_anal_var_add(RAnal *anal, RAnalFcn *fcn, ut64 from, int delta, int t return R_TRUE; } -R_API int r_anal_var_del(RAnal *anal, RAnalFcn *fcn, int delta, int type) { +/* Remove local variable from selected function */ +R_API int r_anal_var_del(RAnal *anal, RAnalFunction *fcn, int delta, int scope) { RAnalVar *vari; RListIter *iter; /* No _safe loop necessary because we return immediately after the delete. */ r_list_foreach(fcn->vars, iter, vari) - if (vari->type == type && vari->delta == delta) { + if (vari->scope == scope && vari->delta == delta) { r_list_unlink (fcn->vars, vari); return R_TRUE; } return R_FALSE; } -R_API RAnalVar *r_anal_var_get(RAnal *anal, RAnalFcn *fcn, int delta, int type) { +R_API RAnalVar *r_anal_var_get(RAnal *anal, RAnalFunction *fcn, int delta, int scope) { RAnalVar *vari; RListIter *iter; r_list_foreach (fcn->vars, iter, vari) - if ((type==-1||vari->type == type) && vari->delta == delta) + if ((scope==-1||vari->scope == scope) && vari->delta == delta) return vari; return NULL; } -// XXX: rename function type? i think this is 'scope' -R_API const char *r_anal_var_type_to_str (RAnal *anal, int type) { - if (type & R_ANAL_VAR_TYPE_GLOBAL) +R_API const char *r_anal_var_scope_to_str (RAnal *anal, int scope) { + if (scope & R_ANAL_VAR_SCOPE_GLOBAL) return "global"; - else if (type & R_ANAL_VAR_TYPE_LOCAL) + else if (scope & R_ANAL_VAR_SCOPE_LOCAL) return "local"; - else if (type & R_ANAL_VAR_TYPE_ARG) + else if (scope & R_ANAL_VAR_SCOPE_ARG) return "arg"; - else if (type & R_ANAL_VAR_TYPE_ARGREG) + else if (scope & R_ANAL_VAR_SCOPE_ARGREG) return "fastarg"; - else if (type & R_ANAL_VAR_TYPE_RET) + else if (scope & R_ANAL_VAR_SCOPE_RET) return "ret"; return "(?)"; } @@ -211,19 +155,21 @@ R_API RAnalVarAccess *r_anal_var_access_get(RAnal *anal, RAnalVar *var, ut64 fro } // XXX: move into core_anal? -R_API void r_anal_var_list_show(RAnal *anal, RAnalFcn *fcn, ut64 addr) { +R_API void r_anal_var_list_show(RAnal *anal, RAnalFunction *fcn, ut64 addr) { RAnalVar *v; RListIter *iter; if (fcn && fcn->vars) r_list_foreach (fcn->vars, iter, v) { if (addr == 0 || (addr >= v->addr && addr <= v->eaddr)) { //ut32 value = r_var_dbg_read(v->delta); - if (v->array>1) + if (v->type->type == R_ANAL_TYPE_ARRAY) eprintf ("%s %s %s[%d] = ", - r_anal_var_type_to_str(anal, v->type), v->vartype, - v->name, v->array); - else eprintf ("%s %s %s = ", r_anal_var_type_to_str (anal, v->type), - v->vartype, v->name); + r_anal_var_scope_to_str(anal, v->scope), + r_anal_type_to_str(anal, v->type), + v->name, v->type->custom.a->count); + else + eprintf ("%s %s %s = ", r_anal_var_scope_to_str (anal, v->scope), + r_anal_type_to_str(anal, v->type), v->name); // TODO: implement r_var_dbg_read using r_vm or r_num maybe?? sounds dupped // XXX: not fully implemented eprintf ("0x%"PFMT64x, 0LL); @@ -238,16 +184,22 @@ R_API void r_anal_var_list_show(RAnal *anal, RAnalFcn *fcn, ut64 addr) { } /* 0,0 to list all */ -R_API void r_anal_var_list(RAnal *anal, RAnalFcn *fcn, ut64 addr, int delta) { +R_API void r_anal_var_list(RAnal *anal, RAnalFunction *fcn, ut64 addr, int delta) { RAnalVarAccess *x; RAnalVar *v; RListIter *iter, *iter2; if (fcn && fcn->vars) r_list_foreach (fcn->vars, iter, v) { if (addr == 0 || (addr >= v->addr && addr <= v->eaddr)) { - eprintf ("0x%08"PFMT64x" - 0x%08"PFMT64x" type=%s type=%s name=%s delta=%d array=%d\n", - v->addr, v->eaddr, r_anal_var_type_to_str(anal, v->type), - v->vartype, v->name, v->delta, v->array); + if (v->type->type == R_ANAL_TYPE_ARRAY) + eprintf ("0x%08"PFMT64x" - 0x%08"PFMT64x" type=%s type=%s name=%s delta=%d array=%d\n", + v->addr, v->eaddr, r_anal_var_scope_to_str(anal, v->scope), + r_anal_type_to_str(anal, v->type), v->name, v->delta, v->type->custom.a->count); + else + eprintf ("0x%08"PFMT64x" - 0x%08"PFMT64x" type=%s type=%s name=%s delta=%d\n", + v->addr, v->eaddr, r_anal_var_scope_to_str(anal, v->scope), + r_anal_type_to_str(anal, v->type), v->name, v->delta); + r_list_foreach (v->accesses, iter2, x) { eprintf (" 0x%08"PFMT64x" %s\n", x->addr, x->set?"set":"get"); } diff --git a/libr/core/anal.c b/libr/core/anal.c index 98f009dbcb255..9f4c0bee34db1 100644 --- a/libr/core/anal.c +++ b/libr/core/anal.c @@ -69,7 +69,7 @@ static char *r_core_anal_graph_label(RCore *core, RAnalBlock *bb, int opts) { return str; } -static void r_core_anal_graph_nodes(RCore *core, RAnalFcn *fcn, int opts) { +static void r_core_anal_graph_nodes(RCore *core, RAnalFunction *fcn, int opts) { struct r_anal_bb_t *bbi; RListIter *iter; char *str; @@ -107,7 +107,7 @@ static void r_core_anal_graph_nodes(RCore *core, RAnalFcn *fcn, int opts) { } } -R_API int r_core_anal_bb(RCore *core, RAnalFcn *fcn, ut64 at, int head) { +R_API int r_core_anal_bb(RCore *core, RAnalFunction *fcn, ut64 at, int head) { struct r_anal_bb_t *bb = NULL, *bbi; RListIter *iter; ut64 jump, fail; @@ -164,7 +164,7 @@ R_API int r_core_anal_bb(RCore *core, RAnalFcn *fcn, ut64 at, int head) { R_API int r_core_anal_bb_seek(RCore *core, ut64 addr) { RAnalBlock *bbi; - RAnalFcn *fcni; + RAnalFunction *fcni; RListIter *iter, *iter2; r_list_foreach (core->anal->fcns, iter, fcni) r_list_foreach (fcni->bbs, iter2, bbi) @@ -182,7 +182,7 @@ static int cmpaddr (void *_a, void *_b) { R_API int r_core_anal_fcn(RCore *core, ut64 at, ut64 from, int reftype, int depth) { RListIter *iter, *iter2; int buflen, fcnlen = 0; - RAnalFcn *fcn = NULL, *fcni; + RAnalFunction *fcn = NULL, *fcni; RAnalRef *ref = NULL, *refi; ut8 *buf; @@ -223,7 +223,7 @@ R_API int r_core_anal_fcn(RCore *core, ut64 at, ut64 from, int reftype, int dept goto error; if (r_cons_singleton ()->breaked) break; - fcnlen = r_anal_fcn (core->anal, fcn, at+fcnlen, buf, buflen, reftype); + fcnlen = r_anal_fcn (core->anal, fcn, at+fcnlen, buf, buflen, reftype); if (fcnlen == R_ANAL_RET_ERROR || (fcnlen == R_ANAL_RET_END && fcn->size < 1)) { /* Error analyzing function */ goto error; @@ -285,7 +285,7 @@ R_API int r_core_anal_fcn(RCore *core, ut64 at, ut64 from, int reftype, int dept } R_API int r_core_anal_fcn_clean(RCore *core, ut64 addr) { - RAnalFcn *fcni; + RAnalFunction *fcni; RListIter *iter, *iter_tmp; if (addr == 0) { @@ -306,7 +306,7 @@ R_API void r_core_anal_refs(RCore *core, ut64 addr, int gv) { const char *font = r_config_get (core->config, "graph.font"); RListIter *iter, *iter2; RAnalRef *fcnr; - RAnalFcn *fcni; + RAnalFunction *fcni; int showhdr = 0; r_list_foreach (core->anal->fcns, iter, fcni) { @@ -342,7 +342,7 @@ R_API void r_core_anal_refs(RCore *core, ut64 addr, int gv) { r_cons_printf ("}\n"); } -static void fcn_list_bbs(RAnalFcn *fcn) { +static void fcn_list_bbs(RAnalFunction *fcn) { RAnalBlock *bbi; RListIter *iter; @@ -371,7 +371,7 @@ static void fcn_list_bbs(RAnalFcn *fcn) { } R_API int r_core_anal_fcn_list(RCore *core, const char *input, int rad) { - RAnalFcn *fcni; + RAnalFunction *fcni; struct r_anal_ref_t *refi; struct r_anal_var_t *vari; RListIter *iter, *iter2; @@ -420,7 +420,7 @@ R_API int r_core_anal_fcn_list(RCore *core, const char *input, int rad) { r_cons_printf ("\n vars:"); r_list_foreach (fcni->vars, iter2, vari) r_cons_printf ("\n %-10s delta=0x%02x type=%s", vari->name, - vari->delta, r_anal_var_type_to_str (core->anal, vari->type)); + vari->delta, r_anal_type_to_str (core->anal, vari->type)); r_cons_printf ("\n diff: type=%s", fcni->diff->type==R_ANAL_DIFF_TYPE_MATCH?"match": fcni->diff->type==R_ANAL_DIFF_TYPE_UNMATCH?"unmatch":"new"); @@ -478,7 +478,7 @@ R_API RList* r_core_anal_graph_to(RCore *core, ut64 addr, int n) { RAnalBlock *bb, *root, *dest; RListIter *iter, *iter2; RList *list2, *list = NULL; - RAnalFcn *fcn; + RAnalFunction *fcn; r_list_foreach (core->anal->fcns, iter, fcn) { if (!r_anal_fcn_is_in_offset (fcn, core->offset)) @@ -512,7 +512,7 @@ R_API RList* r_core_anal_graph_to(RCore *core, ut64 addr, int n) { } R_API int r_core_anal_graph(RCore *core, ut64 addr, int opts) { - RAnalFcn *fcni; + RAnalFunction *fcni; RListIter *iter; int reflines, bytes, dwarf; const char *font = r_config_get (core->config, "graph.font"); @@ -618,24 +618,24 @@ R_API int r_core_anal_search(RCore *core, ut64 from, ut64 to, ut64 ref) { } R_API int r_core_anal_ref_list(RCore *core, int rad) { - RAnalFcn *fcni; + RAnalFunction *fcni; struct r_anal_ref_t *refi; RListIter *iter, *iter2; r_list_foreach (core->anal->fcns, iter, fcni) r_list_foreach (fcni->refs, iter2, refi) { if (rad) - r_cons_printf ("ar%s 0x%08"PFMT64x" 0x%08"PFMT64x"\n", + r_cons_printf ("ar%s 0x%08"PFMT64x" 0x%08"PFMT64x"\n", refi->type==R_ANAL_REF_TYPE_DATA?"d":"", refi->at, refi->addr); - else r_cons_printf ("0x%08"PFMT64x" -> 0x%08"PFMT64x" (%c)\n", + else r_cons_printf ("0x%08"PFMT64x" -> 0x%08"PFMT64x" (%c)\n", refi->at, refi->addr, refi->type); } r_list_foreach (core->anal->refs, iter2, refi) { - if (rad) r_cons_printf ("ar%s 0x%08"PFMT64x" 0x%08"PFMT64x"\n", + if (rad) r_cons_printf ("ar%s 0x%08"PFMT64x" 0x%08"PFMT64x"\n", refi->type==R_ANAL_REF_TYPE_DATA?"d":"", refi->at, refi->addr); - else r_cons_printf ("0x%08"PFMT64x" -> 0x%08"PFMT64x" (%c)\n", + else r_cons_printf ("0x%08"PFMT64x" -> 0x%08"PFMT64x" (%c)\n", refi->at, refi->addr, refi->type); } r_cons_flush (); @@ -645,13 +645,13 @@ R_API int r_core_anal_ref_list(RCore *core, int rad) { R_API int r_core_anal_all(RCore *core) { RList *list; RListIter *iter; - RAnalFcn *fcni; + RAnalFunction *fcni; RBinAddr *binmain; RBinAddr *entry; RBinSymbol *symbol; ut64 baddr; ut64 offset; - int depth =r_config_get_i (core->config, "anal.depth"); + int depth =r_config_get_i (core->config, "anal.depth"); int va = core->io->va || core->io->debug; baddr = r_bin_get_baddr (core->bin); diff --git a/libr/core/cmd.c b/libr/core/cmd.c index 4b6aeae5bd0bf..d2de57cd287a0 100644 --- a/libr/core/cmd.c +++ b/libr/core/cmd.c @@ -1,6 +1,7 @@ /* radare - LGPL - Copyright 2009-2012 // nibble<.ds@gmail.com>, pancake */ -#include "r_core.h" +#include +#include #include #include diff --git a/libr/core/cmd_anal.c b/libr/core/cmd_anal.c index e47e2e8aeca26..ca9c3bd2726df 100644 --- a/libr/core/cmd_anal.c +++ b/libr/core/cmd_anal.c @@ -14,10 +14,10 @@ static void var_help() { } static int var_cmd(RCore *core, const char *str) { - RAnalFcn *fcn = r_anal_fcn_find (core->anal, core->offset, + RAnalFunction *fcn = r_anal_fcn_find (core->anal, core->offset, R_ANAL_FCN_TYPE_FCN|R_ANAL_FCN_TYPE_SYM); char *p, *p2, *p3, *ostr; - int type, delta; + int scope, delta; ostr = p = strdup (str); str = (const char *)ostr; @@ -34,9 +34,9 @@ static int var_cmd(RCore *core, const char *str) { case 'A': // fastcall arg // XXX nested dup switch (*str) { - case 'v': type = R_ANAL_VAR_TYPE_LOCAL|R_ANAL_VAR_DIR_NONE; break; - case 'a': type = R_ANAL_VAR_TYPE_ARG|R_ANAL_VAR_DIR_IN; break; - case 'A': type = R_ANAL_VAR_TYPE_ARGREG|R_ANAL_VAR_DIR_IN; break; + case 'v': scope = R_ANAL_VAR_SCOPE_LOCAL|R_ANAL_VAR_DIR_NONE; break; + case 'a': scope = R_ANAL_VAR_SCOPE_ARG|R_ANAL_VAR_DIR_IN; break; + case 'A': scope = R_ANAL_VAR_SCOPE_ARGREG|R_ANAL_VAR_DIR_IN; break; default: eprintf ("Unknown type\n"); return 0; @@ -51,7 +51,7 @@ static int var_cmd(RCore *core, const char *str) { case 'g': if (str[2]!='\0') { if (fcn != NULL) { - RAnalVar *var = r_anal_var_get (core->anal, fcn, atoi (str+2), R_ANAL_VAR_TYPE_LOCAL); + RAnalVar *var = r_anal_var_get (core->anal, fcn, atoi (str+2), R_ANAL_VAR_SCOPE_LOCAL); if (var != NULL) return r_anal_var_access_add (core->anal, var, atoi (str+2), (str[1]=='g')?0:1); eprintf ("Can not find variable in: '%s'\n", str); @@ -68,6 +68,7 @@ static int var_cmd(RCore *core, const char *str) { var_help(); break; } + // TODO: Improve parsing error handling p[0]='\0'; p++; p2 = strchr (p, ' '); if (p2) { @@ -77,7 +78,9 @@ static int var_cmd(RCore *core, const char *str) { p3[0]='\0'; p3=p3+1; } - r_anal_var_add (core->anal, fcn, core->offset, delta, type, p, p2, p3?atoi(p3):0); + // p2 - name of variable + r_anal_var_add (core->anal, fcn, core->offset, delta, scope, + r_anal_str_to_type(core->anal, p), p2, p3?atoi(p3):0); } else var_help (); break; default: @@ -202,7 +205,7 @@ static int cmd_anal(void *data, const char *input) { // list xrefs from current address { ut64 addr = input[1]? r_num_math (core->num, input+1): core->offset; - RAnalFcn *fcn = r_anal_fcn_find (core->anal, addr, R_ANAL_FCN_TYPE_NULL); + RAnalFunction *fcn = r_anal_fcn_find (core->anal, addr, R_ANAL_FCN_TYPE_NULL); if (fcn) { RAnalRef *ref; RListIter *iter; @@ -218,7 +221,7 @@ static int cmd_anal(void *data, const char *input) { case 'C': { char *p; ut64 a, b; - RAnalFcn *fcn; + RAnalFunction *fcn; char *mi = strdup (input); if (mi && mi[2]==' ' && (p=strchr (mi+3, ' '))) { *p = 0; @@ -235,7 +238,7 @@ static int cmd_anal(void *data, const char *input) { case '-': { char *p; ut64 a, b; - RAnalFcn *fcn; + RAnalFunction *fcn; char *mi = strdup (input); if (mi && mi[2]==' ' && (p=strchr (mi+3, ' '))) { *p = 0; @@ -331,7 +334,7 @@ static int cmd_anal(void *data, const char *input) { break; case 'l': { - RAnalFcn *fcn; + RAnalFunction *fcn; RListIter *iter; r_list_foreach (core->anal->fcns, iter, fcn) { @@ -346,7 +349,7 @@ static int cmd_anal(void *data, const char *input) { break; case 's': { ut64 addr; - RAnalFcn *f; + RAnalFunction *f; const char *arg = input+3; if (input[2] && (addr = r_num_math (core->num, arg))) { arg = strchr (arg, ' '); @@ -354,7 +357,7 @@ static int cmd_anal(void *data, const char *input) { } else addr = core->offset; if ((f = r_anal_fcn_find (core->anal, addr, R_ANAL_FCN_TYPE_NULL))) { if (arg && *arg) { - r_anal_fcn_from_string (core->anal, f, arg); + r_anal_str_to_fcn (core->anal, f, arg); } else { char *str = r_anal_fcn_to_string (core->anal, f); r_cons_printf ("%s\n", str); @@ -370,7 +373,7 @@ static int cmd_anal(void *data, const char *input) { break; case 'c': { - RAnalFcn *fcn; + RAnalFunction *fcn; int cc; if ((fcn = r_anal_get_fcn_at (core->anal, core->offset)) != NULL) { cc = r_anal_fcn_cc (fcn); @@ -388,7 +391,7 @@ static int cmd_anal(void *data, const char *input) { ut64 jump = -1LL; ut64 fail = -1LL; int type = R_ANAL_BB_TYPE_NULL; - RAnalFcn *fcn = NULL; + RAnalFunction *fcn = NULL; RAnalDiff *diff = NULL; switch(r_str_word_set0 (ptr)) { @@ -433,7 +436,7 @@ static int cmd_anal(void *data, const char *input) { break; case 'r': { - RAnalFcn *fcn; + RAnalFunction *fcn; ut64 off = core->offset; char *p, *name = strdup (input+3); if ((p=strchr (name, ' '))) { @@ -452,7 +455,7 @@ static int cmd_anal(void *data, const char *input) { break; case 'e': { - RAnalFcn *fcn; + RAnalFunction *fcn; ut64 off = core->offset; char *p, *name = strdup (input+3); if ((p=strchr (name, ' '))) { diff --git a/libr/core/cmd_meta.c b/libr/core/cmd_meta.c index 984af0c9aa563..d4cc38e449218 100644 --- a/libr/core/cmd_meta.c +++ b/libr/core/cmd_meta.c @@ -2,7 +2,6 @@ // XXX this command is broken. output of _list is not compatible with input static int cmd_meta(void *data, const char *input) { - RAnalVarType *var; RListIter *iter; RCore *core = (RCore*)data; int i, ret, line = 0; @@ -13,40 +12,6 @@ static int cmd_meta(void *data, const char *input) { case '*': r_meta_list (core->anal->meta, R_META_TYPE_ANY, 1); break; - case 't': - switch (input[1]) { - case '-': - r_anal_var_type_del (core->anal, input+2); - break; - case ' ': - { - int size; - const char *fmt = NULL; - const char *ptr, *name = input+2; - ptr = strchr (name, ' '); - if (ptr) { - size = atoi (ptr+1); - ptr = strchr (ptr+2, ' '); - if (ptr) - fmt = ptr+1; - } - if (fmt==NULL) - eprintf ("Usage: Ct name size format\n"); - else r_anal_var_type_add (core->anal, name, size, fmt); - } - break; - case '\0': - r_list_foreach (core->anal->vartypes, iter, var) { - r_cons_printf ("Ct %s %d %s\n", var->name, var->size, var->fmt); - } - break; - default: - eprintf ("Usage: Ct[..]\n" - " Ct-int : remove 'int' type\n" - " Ct int 4 d : define int type\n"); - break; - } - break; case 'l': // XXX: this should be moved to CL? if (input[2]=='a') { @@ -190,7 +155,7 @@ static int cmd_meta(void *data, const char *input) { switch (input[1]) { case '-': { - RAnalFcn *f; + RAnalFunction *f; RListIter *iter; ut64 offset; if (input[2]==' ') { @@ -205,7 +170,7 @@ static int cmd_meta(void *data, const char *input) { break; case '*': { - RAnalFcn *f; + RAnalFunction *f; RListIter *iter; r_list_foreach (core->anal->fcns, iter, f) { for (i = 0; i < R_ANAL_VARSUBS; i++) { @@ -218,7 +183,7 @@ static int cmd_meta(void *data, const char *input) { break; default: { - RAnalFcn *f; + RAnalFunction *f; char *ptr = strdup (input+2); const char *varsub = NULL; const char *pattern = NULL; @@ -267,9 +232,9 @@ static int cmd_meta(void *data, const char *input) { break; case 'F': { - RAnalFcn *f = r_anal_fcn_find (core->anal, core->offset, + RAnalFunction *f = r_anal_fcn_find (core->anal, core->offset, R_ANAL_FCN_TYPE_FCN|R_ANAL_FCN_TYPE_SYM); - if (f) r_anal_fcn_from_string (core->anal, f, input+2); + if (f) r_anal_str_to_fcn (core->anal, f, input+2); else eprintf ("Cannot find function here\n"); } break; diff --git a/libr/core/cmd_print.c b/libr/core/cmd_print.c index ab8997c3d1d40..cab5a883e5470 100644 --- a/libr/core/cmd_print.c +++ b/libr/core/cmd_print.c @@ -74,7 +74,7 @@ static int cmd_print(void *data, const char *input) { } if (input[0] && input[1] == 'f') { - RAnalFcn *f = r_anal_fcn_find (core->anal, core->offset, + RAnalFunction *f = r_anal_fcn_find (core->anal, core->offset, R_ANAL_FCN_TYPE_FCN|R_ANAL_FCN_TYPE_SYM); if (f) len = f->size; else eprintf ("Cannot find function at 0x%08"PFMT64x"\n", core->offset); @@ -180,7 +180,7 @@ free (ptr); int bs = core->blocksize; if (input[1]=='f') { - RAnalFcn *f = r_anal_fcn_find (core->anal, core->offset, + RAnalFunction *f = r_anal_fcn_find (core->anal, core->offset, R_ANAL_FCN_TYPE_FCN|R_ANAL_FCN_TYPE_SYM); if (f) { len = bs = f->size; @@ -251,7 +251,7 @@ free (ptr); } break; break; case 'f': { - RAnalFcn *f = r_anal_fcn_find (core->anal, core->offset, + RAnalFunction *f = r_anal_fcn_find (core->anal, core->offset, R_ANAL_FCN_TYPE_FCN|R_ANAL_FCN_TYPE_SYM); if (f) { ut8 *block = malloc (f->size+1); diff --git a/libr/core/cmd_type.c b/libr/core/cmd_type.c index a59614ea207cc..e7a565fc55982 100644 --- a/libr/core/cmd_type.c +++ b/libr/core/cmd_type.c @@ -2,17 +2,15 @@ static int cmd_type(void *data, const char *input) { RCore *core = (RCore*)data; -#if USED - RAnalVarType *var; RListIter *iter; + RAnalType *t; int i, ret, line = 0; ut64 addr_end = 0LL; ut64 addr = core->offset; char file[1024]; -#endif switch (*input) { case '*': -// TODO r_anal_type_list (core->anal->type, R_ANAL_TYPE_ANY, 1); + r_anal_type_list (core->anal->types, R_ANAL_TYPE_ANY, 1); break; case 'f': switch (input[1]) { @@ -22,7 +20,9 @@ static int cmd_type(void *data, const char *input) { { char *out, *ctype = ""; out = r_core_editor (core, ctype); - r_anal_type_loadstring (core->anal->type, out); + t = r_anal_str_to_type (core->anal, out); + if (t != NULL) + r_anal_type_add (core->anal->types, t); free (out); free (ctype); } @@ -32,7 +32,7 @@ static int cmd_type(void *data, const char *input) { const char *ptr, *filename = input + 2; ptr = strchr (filename, ' '); if (ptr && !ptr[1]) { - r_anal_type_loadfile(core->anal->type, filename); + r_anal_type_loadfile(core->anal, filename); eprintf ("Usage: tf name\n"); } else eprintf ("Usage: tf[!] [name]\n"); } @@ -60,15 +60,25 @@ static int cmd_type(void *data, const char *input) { if (input[1]!='*') { ut64 n = r_num_math (core->num, input + ((input[1] == ' ') ? 2 : 1)); eprintf ("val 0x%"PFMT64x"\n", n); - //TODO r_anal_type_del (core->anal->type, R_ANAL_TYPE_ANY, core->offset, i, ""); - } else r_anal_type_cleanup (core->anal->type, 0LL, UT64_MAX); + //TODO r_anal_type_del (core->anal->types, R_ANAL_TYPE_ANY, core->offset, i, ""); + } else { + const char *ntr, *name = input + 2; + ntr = strchr(name, ' '); + if (ntr && !ntr[1]) { + r_anal_type_del (core->anal->types, name); + } else + eprintf ("Usage: t- name\n" + "t- name : delete type by its name\n"); + } break; case '\0': case '!': { char *out, *ctype = ""; out = r_core_editor (core, ctype); - r_anal_type_loadstring (core->anal->type, out); + t = r_anal_str_to_type(core->anal, out); + if (t != NULL) + r_anal_type_add (core->anal->types, t); free (out); free (ctype); } diff --git a/libr/core/cmd_zign.c b/libr/core/cmd_zign.c index 4a0f0f238f3fd..f4119daad122b 100644 --- a/libr/core/cmd_zign.c +++ b/libr/core/cmd_zign.c @@ -2,7 +2,7 @@ static int cmd_zign(void *data, const char *input) { RCore *core = (RCore *)data; - RAnalFcn *fcni; + RAnalFunction *fcni; RListIter *iter; RSignItem *item; int i, fd = -1, len; diff --git a/libr/core/disasm.c b/libr/core/disasm.c index 5a1cb90cac863..4528d63a4ac91 100644 --- a/libr/core/disasm.c +++ b/libr/core/disasm.c @@ -34,7 +34,7 @@ static void printoffset(ut64 off, int show_color, int invert, int opt) { // int l is for lines R_API int r_core_print_disasm(RPrint *p, RCore *core, ut64 addr, ut8 *buf, int len, int l, int invbreak) { RAnalCC cc = {0}; - RAnalFcn *f = NULL; + RAnalFunction *f = NULL; int ret, idx, i, j, k, lines, ostackptr = 0, stackptr = 0; int counter = 0; int middle = 0; @@ -84,7 +84,7 @@ R_API int r_core_print_disasm(RPrint *p, RCore *core, ut64 addr, ut8 *buf, int l int show_comment_right = 0; int ocols = 0; int lcols = 0; - + if (show_lines) ocols += 10; if (show_offset) ocols += 14; lcols = ocols+2; @@ -112,7 +112,7 @@ R_API int r_core_print_disasm(RPrint *p, RCore *core, ut64 addr, ut8 *buf, int l #if 0 /* find last function else stackptr=0 */ { - RAnalFcn *fcni; + RAnalFunction *fcni; RListIter *iter; r_list_foreach (core->anal.fcns, iter, fcni) { @@ -290,7 +290,7 @@ R_API int r_core_print_disasm(RPrint *p, RCore *core, ut64 addr, ut8 *buf, int l RListIter *iter; if ((xrefs = r_anal_xref_get (core->anal, at))) { r_list_foreach (xrefs, iter, refi) { - RAnalFcn *fun = r_anal_fcn_find (core->anal, refi->addr, R_ANAL_FCN_TYPE_NULL); + RAnalFunction *fun = r_anal_fcn_find (core->anal, refi->addr, R_ANAL_FCN_TYPE_NULL); r_cons_printf ("%s%s", pre, refline); if (show_color) r_cons_printf (Color_TURQOISE"; %s XREF 0x%08"PFMT64x" (%s)"Color_RESET"\n", @@ -360,7 +360,7 @@ R_API int r_core_print_disasm(RPrint *p, RCore *core, ut64 addr, ut8 *buf, int l ostackptr = stackptr; stackptr += analop.stackptr; /* XXX if we reset the stackptr 'ret 0x4' has not effect. - * Use RAnalFcn->RAnalOp->stackptr? */ + * Use RAnalFunction->RAnalOp->stackptr? */ if (analop.type == R_ANAL_OP_TYPE_RET) stackptr = 0; } @@ -510,7 +510,7 @@ R_API int r_core_print_disasm(RPrint *p, RCore *core, ut64 addr, ut8 *buf, int l opstr = str; } else opstr = asmop.buf_asm; if (varsub) { - RAnalFcn *f = r_anal_fcn_find (core->anal, at, R_ANAL_FCN_TYPE_NULL); + RAnalFunction *f = r_anal_fcn_find (core->anal, at, R_ANAL_FCN_TYPE_NULL); if (f) { r_parse_varsub (core->parser, f, opstr, strsub, sizeof (strsub)); if (decode) free (opstr); diff --git a/libr/core/gdiff.c b/libr/core/gdiff.c index 19f8bbc030443..23cd851695798 100644 --- a/libr/core/gdiff.c +++ b/libr/core/gdiff.c @@ -9,7 +9,7 @@ R_API int r_core_gdiff(RCore *c, RCore *c2) { RCore *cores[2] = {c, c2}; - RAnalFcn *fcn; + RAnalFunction *fcn; RAnalBlock *bb; RListIter *iter, *iter2; int i; @@ -45,7 +45,7 @@ static void diffrow(ut64 addr, const char *name, ut64 addr2, const char *name2, R_API void r_core_diff_show(RCore *c, RCore *c2) { const char *match; RListIter *iter; - RAnalFcn *f; + RAnalFunction *f; RList *fcns = r_anal_get_fcns (c->anal); r_list_foreach (fcns, iter, f) { switch (f->type) { diff --git a/libr/core/visual.c b/libr/core/visual.c index 4b6393a94c57b..a3d96e4a32832 100644 --- a/libr/core/visual.c +++ b/libr/core/visual.c @@ -92,7 +92,7 @@ static int visual_fkey(RCore *core, int ch) { switch (ch) { case R_CONS_KEY_F1: cmd = r_config_get (core->config, "key.f1"); - if (cmd && *cmd) return r_core_cmd0 (core, cmd); + if (cmd && *cmd) return r_core_cmd0 (core, cmd); ch = '?'; break; case R_CONS_KEY_F2: @@ -145,7 +145,7 @@ static int visual_fkey(RCore *core, int ch) { void setcursor (RCore *core, int cur) { curset = cur; - if (curset) flags|=R_PRINT_FLAGS_CURSOR; + if (curset) flags|=R_PRINT_FLAGS_CURSOR; else flags &= ~(flags&R_PRINT_FLAGS_CURSOR); r_print_set_flags (core->print, flags); core->print->col = curset? 1: 0; @@ -171,7 +171,6 @@ R_API int r_core_visual_cmd(RCore *core, int ch) { case 'c': // XXX dupped flag imho setcursor (core, curset ^ 1); - break; case 'd': r_core_visual_define (core); @@ -253,7 +252,7 @@ R_API int r_core_visual_cmd(RCore *core, int ch) { RList *xrefs = NULL; RAnalRef *refi; RListIter *iter; - RAnalFcn *fun; + RAnalFunction *fun; if ((xrefs = r_anal_xref_get (core->anal, core->offset))) { r_cons_printf ("XREFS:\n"); @@ -793,7 +792,7 @@ R_API int r_core_visual(RCore *core, const char *input) { flags = R_PRINT_FLAGS_ADDRMOD | R_PRINT_FLAGS_HEADER; if (color) flags |= R_PRINT_FLAGS_COLOR; do { - scrseek = r_num_math (core->num, + scrseek = r_num_math (core->num, r_config_get (core->config, "scr.seek")); if (scrseek != 0LL) r_core_seek (core, scrseek, 1); diff --git a/libr/core/vmenus.c b/libr/core/vmenus.c index 26d7765e1e7ce..4acc4b22fe59c 100644 --- a/libr/core/vmenus.c +++ b/libr/core/vmenus.c @@ -27,7 +27,7 @@ R_API int r_core_visual_trackflags(RCore *core) { i = j = 0; r_list_foreach (core->flags->flags, iter, flag) { /* filter per flag spaces */ - if ((core->flags->space_idx != -1) && + if ((core->flags->space_idx != -1) && (flag->space != core->flags->space_idx)) continue; if (option==i) { @@ -67,7 +67,7 @@ R_API int r_core_visual_trackflags(RCore *core) { if ((i >=option-delta) && ((i':' ', j, + (option==i)?'>':' ', j, (i==core->flags->space_idx)?'*':' ', core->flags->spaces[i]); j++; @@ -80,7 +80,7 @@ R_API int r_core_visual_trackflags(RCore *core) { hit = 1; } r_cons_printf (" %c %02d %c %s\n", - (option==j)?'>':' ', j, + (option==j)?'>':' ', j, (i==core->flags->space_idx)?'*':' ', "*"); } @@ -267,7 +267,7 @@ R_API int r_core_visual_comments (RCore *core) { int found = 0; ut64 from = 0, size = 0; RListIter *iter; - RAnalFcn *fcn; + RAnalFunction *fcn; RMetaItem *d; for (;;) { @@ -860,7 +860,7 @@ R_API void r_core_visual_mounts (RCore *core) { } #if 1 -static void var_index_show(RAnal *anal, RAnalFcn *fcn, ut64 addr, int idx) { +static void var_index_show(RAnal *anal, RAnalFunction *fcn, ut64 addr, int idx) { int i = 0; RAnalVar *v; RAnalVarAccess *x; @@ -878,9 +878,14 @@ static void var_index_show(RAnal *anal, RAnalFcn *fcn, ut64 addr, int idx) { } if (idx == i) r_cons_printf (" * "); else r_cons_printf (" "); - r_cons_printf ("0x%08llx - 0x%08llx type=%s type=%s name=%s delta=%d array=%d\n", - v->addr, v->eaddr, r_anal_var_type_to_str (anal, v->type), - v->vartype, v->name, v->delta, v->array); + if (v->type->type == R_ANAL_TYPE_ARRAY) + r_cons_printf ("0x%08llx - 0x%08llx scope=%s type=%s name=%s delta=%d array=%d\n", + v->addr, v->eaddr, r_anal_var_scope_to_str (anal, v->scope), + r_anal_type_to_str(anal, v->type), v->name, v->delta, v->type->custom.a->count); + else + r_cons_printf ("0x%08llx - 0x%08llx scope=%s type=%s name=%s delta=%d\n", + v->addr, v->eaddr, r_anal_var_scope_to_str (anal, v->scope), + r_anal_type_to_str(anal, v->type), v->name, v->delta); r_list_foreach (v->accesses, iter2, x) { r_cons_printf (" 0x%08llx %s\n", x->addr, x->set?"set":"get"); } @@ -893,7 +898,7 @@ static void var_index_show(RAnal *anal, RAnalFcn *fcn, ut64 addr, int idx) { // helper static void function_rename(RCore *core, ut64 addr, const char *name) { RListIter *iter; - RAnalFcn *fcn; + RAnalFunction *fcn; r_list_foreach (core->anal->fcns, iter, fcn) { if (fcn->addr == addr) { @@ -913,7 +918,7 @@ static ut64 var_functions_show(RCore *core, int idx, int show) { int window = 15; int wdelta = (idx>5)?idx-5:0; RListIter *iter; - RAnalFcn *fcn; + RAnalFunction *fcn; r_list_foreach (core->anal->fcns, iter, fcn) { if (i>=wdelta) { @@ -925,7 +930,7 @@ static ut64 var_functions_show(RCore *core, int idx, int show) { if (idx == i) addr = fcn->addr; if (show) - r_cons_printf ("%c%c 0x%08llx (%s)\n", + r_cons_printf ("%c%c 0x%08llx (%s)\n", (seek == fcn->addr)?'>':' ', (idx==i)?'*':' ', fcn->addr, fcn->name); @@ -944,7 +949,7 @@ static void r_core_visual_anal_refresh (RCore *core) { char old[1024]; old[0]='\0'; int cols = r_cons_get_size (NULL); - RAnalFcn *fcn = r_anal_fcn_find (core->anal, core->offset, R_ANAL_FCN_TYPE_NULL); // once + RAnalFunction *fcn = r_anal_fcn_find (core->anal, core->offset, R_ANAL_FCN_TYPE_NULL); // once char *oprofile; cols -= 50; @@ -1056,7 +1061,7 @@ eprintf ("TODO: Add new function manually\n"); if (!r_cons_fgets (old, sizeof (old), 0, NULL)) break; //old[strlen (old)-1] = 0; function_rename (core, addr, old); - + r_cons_set_raw (R_TRUE); r_cons_show_cursor (R_FALSE); break; @@ -1108,7 +1113,7 @@ eprintf ("TODO: Add new function manually\n"); beach: core->cons->event_resize = olde; level = 0; - + } #endif @@ -1122,7 +1127,7 @@ R_API void r_core_seek_next(RCore *core, const char *type) { else eprintf ("Invalid opcode\n"); } else if (strstr (type, "fun")) { - RAnalFcn *fcni; + RAnalFunction *fcni; r_list_foreach (core->anal->fcns, iter, fcni) { if (fcni->addr < next && fcni->addr > core->offset) next = fcni->addr; @@ -1154,7 +1159,7 @@ R_API void r_core_seek_previous (RCore *core, const char *type) { eprintf ("TODO: r_core_seek_previous (opc)\n"); } else if (strstr (type, "fun")) { - RAnalFcn *fcni; + RAnalFunction *fcni; r_list_foreach (core->anal->fcns, iter, fcni) { if (fcni->addr > next && fcni->addr < core->offset) next = fcni->addr; @@ -1234,7 +1239,7 @@ R_API void r_core_visual_define (RCore *core) { case 'd': // TODO: check r_meta_add (core->anal->meta, R_META_TYPE_DATA, off, off+core->blocksize, ""); break; - case 'c': // TODO: check + case 'c': // TODO: check r_meta_add (core->anal->meta, R_META_TYPE_CODE, off, off+core->blocksize, ""); break; case 'u': diff --git a/libr/include/r_anal.h b/libr/include/r_anal.h index 67773b2b90d46..95094ed910ecf 100644 --- a/libr/include/r_anal.h +++ b/libr/include/r_anal.h @@ -46,10 +46,11 @@ enum { R_ANAL_TYPE_STRUCT = 4, R_ANAL_TYPE_UNION = 5, R_ANAL_TYPE_FUNCTION = 6, + R_ANAL_TYPE_ANY = 7, }; -// [0:2] bits - place to store variable size -#define R_ANAL_VAR_TYPE_SIZE_MASK 0x4 +// [0:3] bits - place to store variable size +#define R_ANAL_VAR_TYPE_SIZE_MASK 0xF enum { R_ANAL_VAR_TYPE_BYTE = 1, @@ -60,18 +61,18 @@ enum { R_ANAL_VAR_TYPE_DOUBLE = 6, }; -// [3:4] bits - place to store sign of variable -#define R_ANAL_VAR_TYPE_SIGN_MASK 0x18 -#define R_ANAL_VAR_TYPE_SIGN_SHIFT 3 +// [4:7] bits - place to store sign of variable +#define R_ANAL_VAR_TYPE_SIGN_MASK 0xF0 +#define R_ANAL_VAR_TYPE_SIGN_SHIFT 4 enum { R_ANAL_VAR_TYPE_SIGNED = 1, R_ANAL_VAR_TYPE_UNSIGNED = 2, }; -// [5:7] bits - place to store variable modifiers/parameters -#define R_ANAL_VAR_TYPE_MODIFIER_MASK 0xe0 -#define R_ANAL_VAR_TYPE_MODIFIER_SHIFT 5 +// [8:11] bits - place to store variable modifiers/parameters +#define R_ANAL_VAR_TYPE_MODIFIER_MASK 0xF00 +#define R_ANAL_VAR_TYPE_MODIFIER_SHIFT 8 enum { R_ANAL_VAR_TYPE_REGISTER = 1, @@ -86,7 +87,7 @@ enum { */ typedef struct r_anal_type_var_t { char *name; - ut8 type; // contain (type || signedness || modifier) + ut16 type; // contain (type || signedness || modifier) ut8 size; union { ut8 v8; @@ -98,7 +99,7 @@ typedef struct r_anal_type_var_t { typedef struct r_anal_type_ptr_t { char *name; - ut8 type; // contain (type || signedness || modifier) + ut16 type; // contain (type || signedness || modifier) ut8 size; union { ut8 v8; @@ -110,7 +111,7 @@ typedef struct r_anal_type_ptr_t { typedef struct r_anal_type_array_t { char *name; - ut8 type; // contain (type || signedness || modifier) + ut16 type; // contain (type || signedness || modifier) ut8 size; ut64 count; union { @@ -140,20 +141,148 @@ typedef struct r_anal_type_union_t { RAnalType *items; } RAnalTypeUnion; +enum { + R_ANAL_FQUALIFIER_NONE = 0, + R_ANAL_FQUALIFIER_STATIC = 1, + R_ANAL_FQUALIFIER_VOLATILE = 2, + R_ANAL_FQUALIFIER_INLINE = 3, + R_ANAL_FQUALIFIER_NAKED = 4, + R_ANAL_FQUALIFIER_VIRTUAL = 5, +}; + +enum { + R_ANAL_CC_TYPE_NONE, + R_ANAL_CC_TYPE_CDECL, + R_ANAL_CC_TYPE_STDCALL, + R_ANAL_CC_TYPE_FASTCALL, + R_ANAL_CC_TYPE_PASCAL, + R_ANAL_CC_TYPE_WINAPI, // Microsoft's pascal call clone + R_ANAL_CC_TYPE_MSFASTCALL, // microsoft fastcall + R_ANAL_CC_TYPE_BOFASTCALL, // borland fastcall + R_ANAL_CC_TYPE_WAFASTCALL, // wacom fastcall + R_ANAL_CC_TYPE_CLARION, // TopSpeed/Clarion/JPI + /* Clation: + * first four integer parameters are passed in registers: + * eax, ebx, ecx, edx. Floating point parameters are passed + * on the floating point stack - registers + * st0, st1, st2, st3, st4, st5, st6. Structure parameters + * are always passed on the stack. Additional parameters + * are passed on the stack after registers are exhausted. + * Integer values are returned in eax, pointers in edx + * and floating point types in st0. + */ + R_ANAL_CC_TYPE_SAFECALL, // Delphi and Free Pascal on Windows + R_ANAL_CC_TYPE_SYSV, + R_ANAL_CC_TYPE_THISCALL, +}; + +#define R_ANAL_CC_ARGS 16 + +typedef struct r_anal_cc_t { + int type; + int bits; + int rel; // relative or absolute? + ut64 off; // offset of the call instruction (caller) + ut64 jump; // offset of the call instruction (caller) + int nargs; + ut64 args[R_ANAL_CC_ARGS]; + // TODO: Store arguments someway +} RAnalCC; + +typedef struct r_anal_cc_type_t { + int rtl; // right-to-left? if false use left-to-right + int alignstack; + // + //const char **reglist; // +} RAnalCCType; + + +enum { + R_ANAL_FCN_TYPE_NULL = 0, + R_ANAL_FCN_TYPE_FCN = 1, + R_ANAL_FCN_TYPE_LOC = 2, + R_ANAL_FCN_TYPE_SYM = 4, + R_ANAL_FCN_TYPE_IMP = 8, + R_ANAL_FCN_TYPE_ROOT = 16 /* matching flag */ +}; + +#define R_ANAL_VARSUBS 32 + +typedef struct r_anal_varsub_t { + char pat[1024]; + char sub[1024]; +} RAnalVarSub; + +/* +typedef struct r_anal_fcn_t { + char *name; + ut64 addr; + ut64 size; + int type; + int calltype; // See R_ANAL_CC_TYPE_ + int stack; + int ninstr; + int nargs; + int depth; + RAnalVarSub varsubs[R_ANAL_VARSUBS]; + ut8 *fingerprint; + RAnalDiff *diff; + RList *bbs; + RList *vars; + RList *refs; + RList *xrefs; +} RAnalFcn; +*/ + +enum { + R_ANAL_DIFF_TYPE_NULL = 0, + R_ANAL_DIFF_TYPE_MATCH = 'm', + R_ANAL_DIFF_TYPE_UNMATCH = 'u' +}; + +typedef struct r_anal_diff_t { + int type; + ut64 addr; + double dist; + char *name; +} RAnalDiff; + +typedef struct r_anal_fcn_store_t { + RHashTable64 *h; + RList *l; +} RAnalFcnStore; + +/* Store various function information, + * variables, arguments, refs and even + * description */ typedef struct r_anal_type_function_t { char* name; - long size; // Size of function header? - int param_count; // Function arguments counter + char* dsc; // For producing nice listings + ut64 size; // Size of function + short type; /*item_list *rets; // Type of return value */ short rets; short fmod; // static, inline or volatile? + /* TODO: Change to RAnalCC ??? */ short call; // calling convention char* attr; // __attribute__(()) list + ut64 addr; + int stack; + int ninstr; + int nargs; // Function arguments counter + int depth; RAnalType *args; // list of arguments -} RAnalTypeFunction; + RAnalVarSub varsubs[R_ANAL_VARSUBS]; + ut8 *fingerprint; // TODO: make is fuzzy and smarter + RAnalDiff *diff; + RList *bbs; + RList *vars; + RList *refs; + RList *xrefs; +} RAnalFunction; struct r_anal_type_t { - char name[32]; + char *name; ut32 size; int type; union { @@ -162,7 +291,7 @@ struct r_anal_type_t { RAnalTypeArray *a; RAnalTypeStruct *s; RAnalTypeUnion *u; - RAnalTypeFunction *f; + RAnalFunction *f; } custom; RAnalType *next; RAnalType *prev; @@ -242,13 +371,13 @@ enum { }; enum { - R_ANAL_VAR_TYPE_NULL = 0, - R_ANAL_VAR_TYPE_GLOBAL = 0x01, - R_ANAL_VAR_TYPE_LOCAL = 0x02, - R_ANAL_VAR_TYPE_ARG = 0x04, - R_ANAL_VAR_TYPE_ARGREG = 0x08, - R_ANAL_VAR_TYPE_RET = 0x10, -}; + R_ANAL_VAR_SCOPE_NULL = 0, + R_ANAL_VAR_SCOPE_GLOBAL = 0x01, + R_ANAL_VAR_SCOPE_LOCAL = 0x02, + R_ANAL_VAR_SCOPE_ARG = 0x04, + R_ANAL_VAR_SCOPE_ARGREG = 0x08, + R_ANAL_VAR_SCOPE_RET = 0x10, +} _RAnalVarScope; typedef enum { R_ANAL_VAR_DIR_NONE = 0, @@ -313,7 +442,7 @@ typedef struct r_anal_t { double diff_thbb; double diff_thfcn; RIOBind iob; - RList *type; + RList *types; //struct r_anal_ctx_t *ctx; struct r_anal_plugin_t *cur; struct list_head anals; // TODO: Reimplement with RList @@ -363,19 +492,6 @@ typedef struct r_anal_cond_t { RAnalValue *arg[2]; // filled by CMP opcode } RAnalCond; -enum { - R_ANAL_DIFF_TYPE_NULL = 0, - R_ANAL_DIFF_TYPE_MATCH = 'm', - R_ANAL_DIFF_TYPE_UNMATCH = 'u' -}; - -typedef struct r_anal_diff_t { - int type; - ut64 addr; - double dist; - char *name; -} RAnalDiff; - typedef struct r_anal_bb_t { ut64 addr; ut64 size; @@ -394,99 +510,30 @@ typedef struct r_anal_bb_t { RAnalCond *cond; } RAnalBlock; -enum { - R_ANAL_CC_TYPE_CDECL, - R_ANAL_CC_TYPE_STDCALL, - R_ANAL_CC_TYPE_FASTCALL, - R_ANAL_CC_TYPE_PASCAL, - R_ANAL_CC_TYPE_MSFASTCALL, // microsoft fastcall - R_ANAL_CC_TYPE_BOFASTCALL, // borland fastcall - R_ANAL_CC_TYPE_WAFASTCALL, // wacom fastcall - R_ANAL_CC_TYPE_CLARION, - R_ANAL_CC_TYPE_SYSV, -}; - -#define R_ANAL_CC_ARGS 16 -typedef struct r_anal_cc_t { - int type; - int bits; - int rel; // relative or absolute? - ut64 off; // offset of the call instruction (caller) - ut64 jump; // offset of the call instruction (caller) - int nargs; - ut64 args[R_ANAL_CC_ARGS]; - // TODO: Store arguments someway -} RAnalCC; - -typedef struct r_anal_cc_type_t { - int rtl; // right-to-left? if false use left-to-right - int alignstack; - // - //const char **reglist; // -} RAnalCCType; - -enum { - R_ANAL_FCN_TYPE_NULL = 0, - R_ANAL_FCN_TYPE_FCN = 1, - R_ANAL_FCN_TYPE_LOC = 2, - R_ANAL_FCN_TYPE_SYM = 4, - R_ANAL_FCN_TYPE_IMP = 8, - R_ANAL_FCN_TYPE_ROOT = 16 /* matching flag */ -}; - -#define R_ANAL_VARSUBS 32 -typedef struct r_anal_varsub_t { - char pat[1024]; - char sub[1024]; -} RAnalVarSub; - -typedef struct r_anal_fcn_t { - char *name; - ut64 addr; - ut64 size; - int type; - int calltype; /* See R_ANAL_CC_TYPE_ */ - int stack; - int ninstr; - int nargs; - int depth; - RAnalVarSub varsubs[R_ANAL_VARSUBS]; - ut8 *fingerprint; - RAnalDiff *diff; - RList *bbs; - RList *vars; - RList *refs; - RList *xrefs; -} RAnalFcn; - -typedef struct r_anal_fcn_store_t { - RHashTable64 *h; - RList *l; -} RAnalFcnStore; - typedef struct r_anal_var_access_t { ut64 addr; int set; } RAnalVarAccess; typedef struct r_anal_var_t { - char *name; /* name of the variable */ - ut64 addr; // not used correctly? - ut64 eaddr; // not used correctly? - int delta; /* delta offset inside stack frame */ - int type; /* global, local... | in, out... */ - int array; /* array size */ - char *vartype; /* float, int... */ + char *name; /* name of the variable */ + ut64 addr; // not used correctly? + ut64 eaddr; // not used correctly? + int delta; /* delta offset inside stack frame */ + int scope; /* global, local... | in, out... */ + RAnalType *type; /* probably dupped or so */ RList/*RAnalVarAccess*/ *accesses; /* list of accesses for this var */ RList/*RAnalValue*/ *stores; /* where this */ } RAnalVar; +/* typedef struct r_anal_var_type_t { char *name; char *fmt; ut32 size; } RAnalVarType; +*/ typedef enum { R_ANAL_REF_TYPE_NULL = 0, @@ -511,8 +558,8 @@ typedef struct r_anal_refline_t { typedef int (*RAnalOpCallback)(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *data, int len); typedef int (*RAnalRegProfCallback)(RAnal *a); typedef int (*RAnalFPBBCallback)(RAnal *a, RAnalBlock *bb); -typedef int (*RAnalFPFcnCallback)(RAnal *a, RAnalFcn *fcn); -typedef int (*RAnalDiffBBCallback)(RAnal *anal, RAnalFcn *fcn, RAnalFcn *fcn2); +typedef int (*RAnalFPFcnCallback)(RAnal *a, RAnalFunction *fcn); +typedef int (*RAnalDiffBBCallback)(RAnal *anal, RAnalFunction *fcn, RAnalFunction *fcn2); typedef int (*RAnalDiffFcnCallback)(RAnal *anal, RList *fcns, RList *fcns2); typedef int (*RAnalDiffEvalCallback)(RAnal *anal); @@ -538,12 +585,23 @@ typedef struct r_anal_plugin_t { /* --------- */ /* REFACTOR */ /* ---------- */ R_API RListRange* r_listrange_new (); R_API void r_listrange_free(RListRange *s); -R_API void r_listrange_add(RListRange *s, RAnalFcn *f); -R_API void r_listrange_del(RListRange *s, RAnalFcn *f); -R_API void r_listrange_resize(RListRange *s, RAnalFcn *f, int newsize); -R_API RAnalFcn *r_listrange_find_in_range(RListRange* s, ut64 addr); -R_API RAnalFcn *r_listrange_find_root(RListRange* s, ut64 addr); +R_API void r_listrange_add(RListRange *s, RAnalFunction *f); +R_API void r_listrange_del(RListRange *s, RAnalFunction *f); +R_API void r_listrange_resize(RListRange *s, RAnalFunction *f, int newsize); +R_API RAnalFunction *r_listrange_find_in_range(RListRange* s, ut64 addr); +R_API RAnalFunction *r_listrange_find_root(RListRange* s, ut64 addr); /* --------- */ /* REFACTOR */ /* ---------- */ +/* type.c */ +R_API RAnalType *r_anal_type_new(); +R_API void r_anal_type_add(RList *l, RAnalType *t); +R_API void r_anal_type_del(RList *l, const char *name); +R_API RList *r_anal_type_list_new(); +R_API void r_anal_type_list(RList *l, short category, short enabled); +R_API RAnalType *r_anal_str_to_type(RAnal *a, const char* s); +R_API char *r_anal_type_to_str(RAnal *a, RAnalType *t); +R_API RAnalType *r_anal_type_free(RAnalType *t); +R_API RAnalType *r_anal_type_loadfile(RAnal *a, const char *path); + /* anal.c */ R_API RAnal *r_anal_new(); R_API void r_anal_free(RAnal *r); @@ -556,7 +614,7 @@ R_API int r_anal_set_bits(RAnal *anal, int bits); R_API int r_anal_set_big_endian(RAnal *anal, int boolean); R_API char *r_anal_strmask (RAnal *anal, const char *data); R_API void r_anal_trace_bb(RAnal *anal, ut64 addr); -R_API RAnalFcn *r_anal_get_fcn_at(RAnal *anal, ut64 addr); +R_API RAnalFunction *r_anal_get_fcn_at(RAnal *anal, ut64 addr); /* bb.c */ R_API RAnalBlock *r_anal_bb_new(); @@ -577,25 +635,25 @@ R_API int r_anal_op(RAnal *anal, RAnalOp *op, ut64 addr, R_API char *r_anal_op_to_string(RAnal *anal, RAnalOp *op); /* fcn.c */ -R_API RAnalFcn *r_anal_fcn_new(); -R_API int r_anal_fcn_is_in_offset (RAnalFcn *fcn, ut64 addr); -R_API RAnalFcn *r_anal_fcn_find(RAnal *anal, ut64 addr, int type); +R_API RAnalFunction *r_anal_fcn_new(); +R_API int r_anal_fcn_is_in_offset (RAnalFunction *fcn, ut64 addr); +R_API RAnalFunction *r_anal_fcn_find(RAnal *anal, ut64 addr, int type); R_API RList *r_anal_fcn_list_new(); -R_API int r_anal_fcn_insert(RAnal *anal, RAnalFcn *fcn); +R_API int r_anal_fcn_insert(RAnal *anal, RAnalFunction *fcn); R_API void r_anal_fcn_free(void *fcn); -R_API int r_anal_fcn(RAnal *anal, RAnalFcn *fcn, ut64 addr, +R_API int r_anal_fcn(RAnal *anal, RAnalFunction *fcn, ut64 addr, ut8 *buf, ut64 len, int reftype); R_API int r_anal_fcn_add(RAnal *anal, ut64 addr, ut64 size, const char *name, int type, RAnalDiff *diff); R_API int r_anal_fcn_del(RAnal *anal, ut64 addr); -R_API int r_anal_fcn_add_bb(RAnalFcn *fcn, ut64 addr, ut64 size, +R_API int r_anal_fcn_add_bb(RAnalFunction *fcn, ut64 addr, ut64 size, ut64 jump, ut64 fail, int type, RAnalDiff *diff); -R_API int r_anal_fcn_cc(RAnalFcn *fcn); -R_API int r_anal_fcn_split_bb(RAnalFcn *fcn, RAnalBlock *bb, ut64 addr); -R_API int r_anal_fcn_overlap_bb(RAnalFcn *fcn, RAnalBlock *bb); -R_API RAnalVar *r_anal_fcn_get_var(RAnalFcn *fs, int num, int dir); -R_API char *r_anal_fcn_to_string(RAnal *a, RAnalFcn* fs); -R_API int r_anal_fcn_from_string(RAnal *a, RAnalFcn *f, const char *_str); +R_API int r_anal_fcn_cc(RAnalFunction *fcn); +R_API int r_anal_fcn_split_bb(RAnalFunction *fcn, RAnalBlock *bb, ut64 addr); +R_API int r_anal_fcn_overlap_bb(RAnalFunction *fcn, RAnalBlock *bb); +R_API RAnalVar *r_anal_fcn_get_var(RAnalFunction *fs, int num, int dir); +R_API char *r_anal_fcn_to_string(RAnal *a, RAnalFunction* fs); +R_API int r_anal_str_to_fcn(RAnal *a, RAnalFunction *f, const char *_str); #if 0 #define r_anal_fcn_get_refs(x) x->refs @@ -603,10 +661,10 @@ R_API int r_anal_fcn_from_string(RAnal *a, RAnalFcn *f, const char *_str); #define r_anal_fcn_get_vars(x) x->vars #define r_anal_fcn_get_bbs(x) x->bbs #else -R_API RList* r_anal_fcn_get_refs (RAnalFcn *anal); -R_API RList* r_anal_fcn_get_xrefs (RAnalFcn *anal); -R_API RList* r_anal_fcn_get_vars (RAnalFcn *anal); -R_API RList* r_anal_fcn_get_bbs (RAnalFcn *anal); +R_API RList* r_anal_fcn_get_refs (RAnalFunction *anal); +R_API RList* r_anal_fcn_get_xrefs (RAnalFunction *anal); +R_API RList* r_anal_fcn_get_vars (RAnalFunction *anal); +R_API RList* r_anal_fcn_get_bbs (RAnalFunction *anal); R_API RList* r_anal_get_fcns (RAnal *anal); #endif @@ -620,22 +678,16 @@ R_API RList *r_anal_xref_get(RAnal *anal, ut64 addr); /* var.c */ R_API RAnalVar *r_anal_var_new(); -R_API RAnalVarType *r_anal_var_type_new(); R_API RAnalVarAccess *r_anal_var_access_new(); R_API RList *r_anal_var_list_new(); -R_API RList *r_anal_var_type_list_new(); R_API RList *r_anal_var_access_list_new(); R_API void r_anal_var_free(void *var); -R_API void r_anal_var_type_free(void *vartype); R_API void r_anal_var_access_free(void *access); -R_API int r_anal_var_type_add(RAnal *anal, const char *name, int size, const char *fmt); -R_API int r_anal_var_type_del(RAnal *anal, const char *name); -R_API RAnalVarType *r_anal_var_type_get(RAnal *anal, const char *name); -R_API int r_anal_var_add(RAnal *anal, RAnalFcn *fcn, ut64 from, int delta, int type, - const char *vartype, const char *name, int set); -R_API int r_anal_var_del(RAnal *anal, RAnalFcn *fcn, int delta, int type); -R_API RAnalVar *r_anal_var_get(RAnal *anal, RAnalFcn *fcn, int delta, int type); -R_API const char *r_anal_var_type_to_str (RAnal *anal, int type); +R_API int r_anal_var_add(RAnal *anal, RAnalFunction *fcn, ut64 from, int delta, int scope, + const RAnalType *type, const char *name, int set); +R_API int r_anal_var_del(RAnal *anal, RAnalFunction *fcn, int delta, int scope); +R_API RAnalVar *r_anal_var_get(RAnal *anal, RAnalFunction *fcn, int delta, int type); +R_API const char *r_anal_var_scope_to_str(RAnal *anal, int scope); R_API int r_anal_var_access_add(RAnal *anal, RAnalVar *var, ut64 from, int set); R_API int r_anal_var_access_del(RAnal *anal, RAnalVar *var, ut64 from); R_API RAnalVarAccess *r_anal_var_access_get(RAnal *anal, RAnalVar *var, ut64 from); @@ -649,8 +701,8 @@ R_API void r_anal_diff_setup(RAnal *anal, int doops, double thbb, double thfcn); R_API void r_anal_diff_setup_i(RAnal *anal, int doops, int thbb, int thfcn); R_API void* r_anal_diff_free(RAnalDiff *diff); R_API int r_anal_diff_fingerprint_bb(RAnal *anal, RAnalBlock *bb); -R_API int r_anal_diff_fingerprint_fcn(RAnal *anal, RAnalFcn *fcn); -R_API int r_anal_diff_bb(RAnal *anal, RAnalFcn *fcn, RAnalFcn *fcn2); +R_API int r_anal_diff_fingerprint_fcn(RAnal *anal, RAnalFunction *fcn); +R_API int r_anal_diff_bb(RAnal *anal, RAnalFunction *fcn, RAnalFunction *fcn2); R_API int r_anal_diff_fcn(RAnal *anal, RList *fcns, RList *fcns2); R_API int r_anal_diff_eval(RAnal *anal); @@ -680,8 +732,8 @@ R_API char* r_anal_reflines_str(struct r_anal_t *anal, struct r_anal_refline_t * R_API int r_anal_reflines_middle(RAnal *anal, RAnalRefline *list, ut64 addr, int len); /* TODO move to r_core */ -R_API void r_anal_var_list_show(RAnal *anal, RAnalFcn *fcn, ut64 addr); -R_API void r_anal_var_list(RAnal *anal, RAnalFcn *fcn, ut64 addr, int delta); +R_API void r_anal_var_list_show(RAnal *anal, RAnalFunction *fcn, ut64 addr); +R_API void r_anal_var_list(RAnal *anal, RAnalFunction *fcn, ut64 addr, int delta); // calling conventions API R_API RAnalCC* r_anal_cc_new (); @@ -701,15 +753,15 @@ R_API char *r_meta_get_string(RMeta *m, int type, ut64 addr); R_API int r_meta_set_string(RMeta *m, int type, ut64 addr, const char *s); R_API int r_meta_del(RMeta *m, int type, ut64 from, ut64 size, const char *str); R_API int r_meta_add(RMeta *m, int type, ut64 from, ut64 size, const char *str); -R_API struct r_meta_item_t *r_meta_find(RMeta *m, ut64 off, int type, int where); +R_API RMetaItem *r_meta_find(RMeta *m, ut64 off, int type, int where); R_API int r_meta_cleanup(RMeta *m, ut64 from, ut64 to); R_API const char *r_meta_type_to_string(int type); R_API int r_meta_list(RMeta *m, int type, int rad); R_API void r_meta_item_free(void *_item); R_API RMetaItem *r_meta_item_new(int type); -R_API int r_anal_fcn_xref_add (RAnal *anal, RAnalFcn *fcn, ut64 at, ut64 addr, int type); -R_API int r_anal_fcn_xref_del (RAnal *anal, RAnalFcn *fcn, ut64 at, ut64 addr, int type); +R_API int r_anal_fcn_xref_add (RAnal *anal, RAnalFunction *fcn, ut64 at, ut64 addr, int type); +R_API int r_anal_fcn_xref_del (RAnal *anal, RAnalFunction *fcn, ut64 at, ut64 addr, int type); /* plugin pointers */ extern RAnalPlugin r_anal_plugin_csr; diff --git a/libr/include/r_asm.h b/libr/include/r_asm.h index 8c501cb7e44bd..c91c27e2e60b6 100644 --- a/libr/include/r_asm.h +++ b/libr/include/r_asm.h @@ -4,7 +4,7 @@ #define _INCLUDE_R_ASM_H_ #include -#include // only for binding, no hard dep required +#include // only for binding, no hard dep required #include #include #include @@ -98,8 +98,8 @@ typedef struct r_asm_plugin_t { int *bits; int (*init)(void *user); int (*fini)(void *user); - int (*disassemble)(RAsm *a, struct r_asm_op_t *op, const ut8 *buf, ut64 len); - int (*assemble)(RAsm *a, struct r_asm_op_t *op, const char *buf); + int (*disassemble)(RAsm *a, RAsmOp *op, const ut8 *buf, ut64 len); + int (*assemble)(RAsm *a, RAsmOp *op, const char *buf); RAsmModifyCallback modify; int (*set_subarch)(RAsm *a, const char *buf); } RAsmPlugin; @@ -118,19 +118,19 @@ R_API int r_asm_set_bits(RAsm *a, int bits); R_API int r_asm_set_big_endian(RAsm *a, int boolean); R_API int r_asm_set_syntax(RAsm *a, int syntax); R_API int r_asm_set_pc(RAsm *a, ut64 pc); -R_API int r_asm_disassemble(RAsm *a, struct r_asm_op_t *op, const ut8 *buf, ut64 len); -R_API int r_asm_assemble(RAsm *a, struct r_asm_op_t *op, const char *buf); -R_API struct r_asm_code_t* r_asm_mdisassemble(RAsm *a, ut8 *buf, ut64 len); +R_API int r_asm_disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, ut64 len); +R_API int r_asm_assemble(RAsm *a, RAsmOp *op, const char *buf); +R_API RAsmCode* r_asm_mdisassemble(RAsm *a, ut8 *buf, ut64 len); R_API RAsmCode* r_asm_mdisassemble_hexstr(RAsm *a, const char *hexstr); -R_API struct r_asm_code_t* r_asm_massemble(RAsm *a, const char *buf); -R_API struct r_asm_code_t* r_asm_assemble_file(RAsm *a, const char *file); +R_API RAsmCode* r_asm_massemble(RAsm *a, const char *buf); +R_API RAsmCode* r_asm_assemble_file(RAsm *a, const char *file); R_API int r_asm_filter_input(RAsm *a, const char *f); R_API int r_asm_filter_output(RAsm *a, const char *f); R_API char *r_asm_describe(RAsm *a, const char* str); /* code.c */ R_API RAsmCode *r_asm_code_new(); -R_API void* r_asm_code_free(struct r_asm_code_t *acode); +R_API void* r_asm_code_free(RAsmCode *acode); R_API int r_asm_code_set_equ (RAsmCode *code, const char *key, const char *value); R_API char *r_asm_code_equ_replace (RAsmCode *code, char *str); diff --git a/libr/include/r_bin.h b/libr/include/r_bin.h index 65547d13e62b9..eb3d0e455d194 100644 --- a/libr/include/r_bin.h +++ b/libr/include/r_bin.h @@ -44,14 +44,36 @@ enum { R_BIN_CLASS_PROTECTED, }; +typedef struct r_bin_addr_t { + ut64 rva; + ut64 offset; +} RBinAddr; + +typedef struct r_bin_info_t { + char file[R_BIN_SIZEOF_STRINGS]; + char type[R_BIN_SIZEOF_STRINGS]; + char bclass[R_BIN_SIZEOF_STRINGS]; + char rclass[R_BIN_SIZEOF_STRINGS]; + char arch[R_BIN_SIZEOF_STRINGS]; + char machine[R_BIN_SIZEOF_STRINGS]; + char os[R_BIN_SIZEOF_STRINGS]; + char subsystem[R_BIN_SIZEOF_STRINGS]; + char rpath[R_BIN_SIZEOF_STRINGS]; + int bits; + int has_va; + int big_endian; + ut64 dbg_info; +} RBinInfo; + + // XXX: isnt this a copy of Obj ? typedef struct r_bin_arch_t { char *file; int size; ut64 baddr; ut64 offset; - struct r_bin_addr_t *binsym[R_BIN_SYM_LAST]; - struct r_bin_info_t *info; + RBinAddr *binsym[R_BIN_SYM_LAST]; + RBinInfo *info; RList* entries; RList* sections; RList* symbols; @@ -97,13 +119,13 @@ typedef struct r_bin_plugin_t { int (*destroy)(RBinArch *arch); int (*check)(RBinArch *arch); ut64 (*baddr)(RBinArch *arch); - struct r_bin_addr_t* (*binsym)(RBinArch *arch, int num); + RBinAddr* (*binsym)(RBinArch *arch, int num); RList* (*entries)(RBinArch *arch); RList* (*sections)(RBinArch *arch); RList* (*symbols)(RBinArch *arch); RList* (*imports)(RBinArch *arch); RList* (*strings)(RBinArch *arch); - struct r_bin_info_t* (*info)(RBinArch *arch); + RBinInfo* (*info)(RBinArch *arch); RList* (*fields)(RBinArch *arch); RList* (*libs)(RBinArch *arch); RList* (*relocs)(RBinArch *arch); @@ -115,11 +137,6 @@ typedef struct r_bin_plugin_t { RBuffer* (*create)(RBin *bin, const ut8 *code, int codelen, const ut8 *data, int datalen); } RBinPlugin; -typedef struct r_bin_addr_t { - ut64 rva; - ut64 offset; -} RBinAddr; - typedef struct r_bin_section_t { char name[R_BIN_SIZEOF_STRINGS]; ut64 size; @@ -182,22 +199,6 @@ typedef struct r_bin_string_t { ut64 size; } RBinString; -typedef struct r_bin_info_t { - char file[R_BIN_SIZEOF_STRINGS]; - char type[R_BIN_SIZEOF_STRINGS]; - char bclass[R_BIN_SIZEOF_STRINGS]; - char rclass[R_BIN_SIZEOF_STRINGS]; - char arch[R_BIN_SIZEOF_STRINGS]; - char machine[R_BIN_SIZEOF_STRINGS]; - char os[R_BIN_SIZEOF_STRINGS]; - char subsystem[R_BIN_SIZEOF_STRINGS]; - char rpath[R_BIN_SIZEOF_STRINGS]; - int bits; - int has_va; - int big_endian; - ut64 dbg_info; -} RBinInfo; - typedef struct r_bin_field_t { char name[R_BIN_SIZEOF_STRINGS]; ut64 rva; @@ -241,7 +242,7 @@ typedef struct r_bin_bind_t { #ifdef R_API -R_API void r_bin_bind(RBin *b, struct r_bin_bind_t *bnd); +R_API void r_bin_bind(RBin *b, RBinBind *bnd); /* bin.c */ R_API int r_bin_add(RBin *bin, RBinPlugin *foo); R_API int r_bin_xtr_add(RBin *bin, RBinXtrPlugin *foo); diff --git a/libr/include/r_bp.h b/libr/include/r_bp.h index aff8955a84bf7..57848eed4811e 100644 --- a/libr/include/r_bp.h +++ b/libr/include/r_bp.h @@ -28,7 +28,7 @@ typedef struct r_bp_plugin_t { char *arch; int type; // R_BP_TYPE_SW int nbps; - struct r_bp_arch_t *bps; + RBreakpointArch *bps; } RBreakpointPlugin; // XXX: type is add() or del() @@ -88,7 +88,7 @@ R_API RBreakpoint *r_bp_free(RBreakpoint *bp); R_API int r_bp_del(RBreakpoint *bp, ut64 addr); -R_API int r_bp_plugin_add(RBreakpoint *bp, struct r_bp_plugin_t *foo); +R_API int r_bp_plugin_add(RBreakpoint *bp, RBreakpointPlugin *foo); R_API int r_bp_use(RBreakpoint *bp, const char *name); R_API int r_bp_plugin_del(RBreakpoint *bp, const char *name); R_API void r_bp_plugin_list(RBreakpoint *bp); @@ -125,15 +125,15 @@ R_API RList *r_bp_traptrace_new(); R_API void r_bp_traptrace_enable(RBreakpoint *bp, int enable); /* plugin pointers */ -extern struct r_bp_plugin_t r_bp_plugin_x86; -extern struct r_bp_plugin_t r_bp_plugin_arm; -extern struct r_bp_plugin_t r_bp_plugin_mips; -extern struct r_bp_plugin_t r_bp_plugin_ppc; -extern struct r_bp_plugin_t r_bp_plugin_sh; -extern struct r_bp_plugin_t r_bp_plugin_bf; +extern RBreakpointPlugin r_bp_plugin_x86; +extern RBreakpointPlugin r_bp_plugin_arm; +extern RBreakpointPlugin r_bp_plugin_mips; +extern RBreakpointPlugin r_bp_plugin_ppc; +extern RBreakpointPlugin r_bp_plugin_sh; +extern RBreakpointPlugin r_bp_plugin_bf; #endif #if 0 -extern struct r_bp_plugin_t r_bp_plugin_sparc; +extern RBreakpointPlugin r_bp_plugin_sparc; #endif #endif diff --git a/libr/include/r_cmd.h b/libr/include/r_cmd.h index 7f5c71976c398..3f0edce470ca9 100644 --- a/libr/include/r_cmd.h +++ b/libr/include/r_cmd.h @@ -74,27 +74,27 @@ typedef struct r_cmd_plugin_t { #ifdef R_API R_API RCmd *r_cmd_new(); R_API RCmd *r_cmd_free(RCmd *cmd); -R_API int r_cmd_set_data(struct r_cmd_t *cmd, void *data); -R_API int r_cmd_add(struct r_cmd_t *cmd, const char *command, const char *desc, r_cmd_callback(callback)); -R_API int r_cmd_add_long(struct r_cmd_t *cmd, const char *longcmd, const char *shortcmd, const char *desc); -R_API int r_cmd_del(struct r_cmd_t *cmd, const char *command); -R_API int r_cmd_call(struct r_cmd_t *cmd, const char *command); -R_API int r_cmd_call_long(struct r_cmd_t *cmd, const char *input); -R_API char **r_cmd_args(struct r_cmd_t *cmd, int *argc); +R_API int r_cmd_set_data(RCmd *cmd, void *data); +R_API int r_cmd_add(RCmd *cmd, const char *command, const char *desc, r_cmd_callback(callback)); +R_API int r_cmd_add_long(RCmd *cmd, const char *longcmd, const char *shortcmd, const char *desc); +R_API int r_cmd_del(RCmd *cmd, const char *command); +R_API int r_cmd_call(RCmd *cmd, const char *command); +R_API int r_cmd_call_long(RCmd *cmd, const char *input); +R_API char **r_cmd_args(RCmd *cmd, int *argc); -R_API int r_cmd_plugin_init(struct r_cmd_t *cmd); -R_API int r_cmd_plugin_add(struct r_cmd_t *cmd, struct r_cmd_plugin_t *plugin); -R_API int r_cmd_plugin_check(struct r_cmd_t *cmd, const char *a0); +R_API int r_cmd_plugin_init(RCmd *cmd); +R_API int r_cmd_plugin_add(RCmd *cmd, RCmdPlugin *plugin); +R_API int r_cmd_plugin_check(RCmd *cmd, const char *a0); /* plugins */ extern struct r_cmd_plugin_t r_cmd_plugin_dummy; /* r_cmd_macro */ -R_API void r_cmd_macro_init(struct r_cmd_macro_t *mac); -R_API int r_cmd_macro_add(struct r_cmd_macro_t *mac, const char *name); -R_API int r_cmd_macro_rm(struct r_cmd_macro_t *mac, const char *_name); -R_API void r_cmd_macro_list(struct r_cmd_macro_t *mac); -R_API int r_cmd_macro_call(struct r_cmd_macro_t *mac, const char *name); -R_API int r_cmd_macro_break(struct r_cmd_macro_t *mac, const char *value); +R_API void r_cmd_macro_init(RCmdMacro *mac); +R_API int r_cmd_macro_add(RCmdMacro *mac, const char *name); +R_API int r_cmd_macro_rm(RCmdMacro *mac, const char *_name); +R_API void r_cmd_macro_list(RCmdMacro *mac); +R_API int r_cmd_macro_call(RCmdMacro *mac, const char *name); +R_API int r_cmd_macro_break(RCmdMacro *mac, const char *value); #endif #endif diff --git a/libr/include/r_config.h b/libr/include/r_config.h index 26317dea5737d..de54a97e877b7 100644 --- a/libr/include/r_config.h +++ b/libr/include/r_config.h @@ -42,10 +42,10 @@ R_API RConfig *r_config_new(void *user); R_API int r_config_free(RConfig *cfg); R_API void r_config_lock(RConfig *cfg, int l); R_API int r_config_eval(RConfig *cfg, const char *str); -R_API struct r_config_node_t *r_config_set_i(RConfig *cfg, const char *name, const ut64 i); -R_API struct r_config_node_t *r_config_set_cb(RConfig *cfg, const char *name, const char *value, int (*callback)(void *user, void *data)); -R_API struct r_config_node_t *r_config_set_i_cb(RConfig *cfg, const char *name, int ivalue, int (*callback)(void *user, void *data)); -R_API struct r_config_node_t *r_config_set(RConfig *cfg, const char *name, const char *value); +R_API RConfigNode *r_config_set_i(RConfig *cfg, const char *name, const ut64 i); +R_API RConfigNode *r_config_set_cb(RConfig *cfg, const char *name, const char *value, int (*callback)(void *user, void *data)); +R_API RConfigNode *r_config_set_i_cb(RConfig *cfg, const char *name, int ivalue, int (*callback)(void *user, void *data)); +R_API RConfigNode *r_config_set(RConfig *cfg, const char *name, const char *value); R_API int r_config_rm(RConfig *cfg, const char *name); R_API ut64 r_config_get_i(RConfig *cfg, const char *name); R_API const char *r_config_get(RConfig *cfg, const char *name); diff --git a/libr/include/r_core.h b/libr/include/r_core.h index ac4685b2e7122..77cb72976d12a 100644 --- a/libr/include/r_core.h +++ b/libr/include/r_core.h @@ -130,58 +130,59 @@ typedef int (*RCoreSearchCallback)(RCore *core, ut64 from, ut8 *buf, int len); R_API RCons *r_core_get_cons (RCore *core); R_API RConfig *r_core_get_config (RCore *core); R_API RAsmOp *r_core_disassemble (RCore *core, ut64 addr); -R_API int r_core_init(struct r_core_t *core); -R_API struct r_core_t *r_core_new(); -R_API struct r_core_t *r_core_free(struct r_core_t *c); -R_API int r_core_config_init(struct r_core_t *core); -R_API int r_core_prompt(RCore *r, int sync); -R_API int r_core_prompt_exec(RCore *r); -R_API void r_core_prompt_loop(RCore *r); -R_API int r_core_cmd(struct r_core_t *r, const char *cmd, int log); +R_API int r_core_init(RCore *core); +R_API RCore *r_core_new(); +R_API RCore *r_core_free(RCore *core); +R_API int r_core_config_init(RCore *core); +R_API int r_core_prompt(RCore *core, int sync); +R_API int r_core_prompt_exec(RCore *core); +R_API void r_core_prompt_loop(RCore *core); +R_API int r_core_cmd(RCore *core, const char *cmd, int log); R_API void r_core_cmd_repeat(RCore *core, int next); R_API char *r_core_editor (RCore *core, const char *str); -// XXX void*?? must be RCore ! +// FIXME: change (void *user) to (RCore *core) R_API int r_core_cmdf(void *user, const char *fmt, ...); R_API int r_core_flush(void *user, const char *cmd); R_API int r_core_cmd0(void *user, const char *cmd); -R_API void r_core_cmd_init(struct r_core_t *core); -R_API char *r_core_cmd_str(struct r_core_t *core, const char *cmd); -R_API int r_core_cmd_file(struct r_core_t *core, const char *file); -R_API int r_core_cmd_command(struct r_core_t *core, const char *command); -R_API boolt r_core_seek(struct r_core_t *core, ut64 addr, boolt rb); +R_API void r_core_cmd_init(RCore *core); +R_API char *r_core_cmd_str(RCore *core, const char *cmd); +R_API int r_core_cmd_file(RCore *core, const char *file); +R_API int r_core_cmd_command(RCore *core, const char *command); +R_API boolt r_core_seek(RCore *core, ut64 addr, boolt rb); R_API void r_core_seek_previous (RCore *core, const char *type); R_API void r_core_seek_next (RCore *core, const char *type); -R_API int r_core_seek_align(struct r_core_t *core, ut64 align, int count); -R_API int r_core_block_read(struct r_core_t *core, int next); -R_API int r_core_block_size(struct r_core_t *core, int bsize); -R_API int r_core_read_at(struct r_core_t *core, ut64 addr, ut8 *buf, int size); -R_API int r_core_visual(struct r_core_t *core, const char *input); -R_API int r_core_visual_cmd(struct r_core_t *core, int ch); +R_API int r_core_seek_align(RCore *core, ut64 align, int count); +R_API int r_core_block_read(RCore *core, int next); +R_API int r_core_block_size(RCore *core, int bsize); +R_API int r_core_read_at(RCore *core, ut64 addr, ut8 *buf, int size); +R_API int r_core_visual(RCore *core, const char *input); +R_API int r_core_visual_cmd(RCore *core, int ch); R_API int r_core_search_cb(RCore *core, ut64 from, ut64 to, RCoreSearchCallback cb); R_API int r_core_serve(RCore *core, RIODesc *fd); R_API int r_core_file_reopen(RCore *core, const char *args); R_API void r_core_file_free(RCoreFile *cf); -R_API struct r_core_file_t *r_core_file_open(struct r_core_t *r, const char *file, int mode, ut64 loadaddr); -R_API struct r_core_file_t *r_core_file_get_fd(struct r_core_t *core, int fd); -R_API int r_core_file_close(struct r_core_t *r, RCoreFile *fh); -R_API int r_core_file_close_fd(struct r_core_t *core, int fd); -R_API int r_core_file_list(struct r_core_t *core); -R_API int r_core_seek_delta(struct r_core_t *core, st64 addr); -R_API int r_core_write_at(struct r_core_t *core, ut64 addr, const ut8 *buf, int size); -R_API int r_core_write_op(struct r_core_t *core, const char *arg, char op); - -R_API int r_core_yank(struct r_core_t *core, ut64 addr, int len); -R_API int r_core_yank_paste(struct r_core_t *core, ut64 addr, int len); +R_API struct r_core_file_t *r_core_file_open(RCore *core, const char *file, int mode, ut64 loadaddr); +R_API struct r_core_file_t *r_core_file_get_fd(RCore *core, int fd); +R_API int r_core_file_close(RCore *core, RCoreFile *fh); +R_API int r_core_file_close_fd(RCore *core, int fd); +R_API int r_core_file_list(RCore *core); +R_API int r_core_seek_delta(RCore *core, st64 addr); +R_API int r_core_write_at(RCore *core, ut64 addr, const ut8 *buf, int size); +R_API int r_core_write_op(RCore *core, const char *arg, char op); + +R_API int r_core_yank(RCore *core, ut64 addr, int len); +R_API int r_core_yank_paste(RCore *core, ut64 addr, int len); R_API void r_core_yank_set (RCore *core, const char *str); R_API int r_core_yank_to(RCore *core, char *arg); -R_API int r_core_loadlibs(struct r_core_t *core); +R_API int r_core_loadlibs(RCore *core); +// FIXME: change (void *user) -> (RCore *core) R_API int r_core_cmd_buffer(void *user, const char *buf); R_API int r_core_cmdf(void *user, const char *fmt, ...); R_API int r_core_cmd0(void *user, const char *cmd); -R_API char *r_core_cmd_str(struct r_core_t *core, const char *cmd); -R_API int r_core_cmd_foreach(struct r_core_t *core, const char *cmd, char *each); +R_API char *r_core_cmd_str(RCore *core, const char *cmd); +R_API int r_core_cmd_foreach(RCore *core, const char *cmd, char *each); R_API char *r_core_op_str(RCore *core, ut64 addr); R_API RAnalOp *r_core_op_anal(RCore *core, ut64 addr); R_API char *r_core_disassemble_instr(RCore *core, ut64 addr, int l); @@ -190,14 +191,14 @@ R_API char *r_core_disassemble_bytes(RCore *core, ut64 addr, int b); /* anal.c */ R_API int r_core_anal_search(RCore *core, ut64 from, ut64 to, ut64 ref); R_API void r_core_anal_refs(RCore *core, ut64 addr, int gv); -R_API int r_core_anal_bb(RCore *core, RAnalFcn *fcn, ut64 at, int head); -R_API int r_core_anal_bb_seek(struct r_core_t *core, ut64 addr); -R_API int r_core_anal_fcn(struct r_core_t *core, ut64 at, ut64 from, int reftype, int depth); +R_API int r_core_anal_bb(RCore *core, RAnalFunction *fcn, ut64 at, int head); +R_API int r_core_anal_bb_seek(RCore *core, ut64 addr); +R_API int r_core_anal_fcn(RCore *core, ut64 at, ut64 from, int reftype, int depth); R_API int r_core_anal_fcn_list(RCore *core, const char *input, int rad); -R_API int r_core_anal_graph(struct r_core_t *core, ut64 addr, int opts); -R_API int r_core_anal_graph_fcn(struct r_core_t *core, char *input, int opts); +R_API int r_core_anal_graph(RCore *core, ut64 addr, int opts); +R_API int r_core_anal_graph_fcn(RCore *core, char *input, int opts); R_API RList* r_core_anal_graph_to(RCore *core, ut64 addr, int n); -R_API int r_core_anal_ref_list(struct r_core_t *core, int rad); +R_API int r_core_anal_ref_list(RCore *core, int rad); R_API int r_core_anal_all(RCore *core); /* asm.c */ @@ -215,11 +216,11 @@ R_API RList *r_core_asm_strsearch(RCore *core, const char *input, ut64 from, ut6 R_API RList *r_core_asm_bwdisassemble (RCore *core, ut64 addr, int n, int len); R_API int r_core_print_disasm(RPrint *p, RCore *core, ut64 addr, ut8 *buf, int len, int lines, int invbreak); -R_API int r_core_bin_load(RCore *r, const char *file); -R_API int r_core_hash_load(RCore *r, const char *file); +R_API int r_core_bin_load(RCore *core, const char *file); +R_API int r_core_hash_load(RCore *core, const char *file); /* gdiff.c */ -R_API int r_core_gdiff(RCore *c, RCore *c2); +R_API int r_core_gdiff(RCore *core1, RCore *core2); R_API int r_core_project_open(RCore *core, const char *file); R_API int r_core_project_save(RCore *core, const char *file); @@ -280,7 +281,7 @@ R_API int r_core_patch (RCore *core, const char *patch); R_API void r_core_hack_help(RCore *core); R_API int r_core_hack(RCore *core, const char *op); R_API int r_core_dump(RCore *core, const char *file, ut64 addr, ut64 size); -R_API void r_core_diff_show(RCore *c, RCore *c2); +R_API void r_core_diff_show(RCore *core, RCore *core2); #endif diff --git a/libr/include/r_crypto.h b/libr/include/r_crypto.h index bee49384200c1..4e193452dd245 100644 --- a/libr/include/r_crypto.h +++ b/libr/include/r_crypto.h @@ -30,33 +30,33 @@ typedef struct r_crypto_t { typedef struct r_crypto_plugin_t { const char *name; - int (*get_key_size)(struct r_crypto_t* cry); - int (*set_iv)(struct r_crypto_t* cry, const ut8 *iv); - int (*set_key)(struct r_crypto_t* cry, const ut8 *key, int mode, int direction); - int (*update)(struct r_crypto_t* cry, const ut8 *buf, int len); - int (*final)(struct r_crypto_t* cry, const ut8 *buf, int len); + int (*get_key_size)(RCrypto *cry); + int (*set_iv)(RCrypto *cry, const ut8 *iv); + int (*set_key)(RCrypto *cry, const ut8 *key, int mode, int direction); + int (*update)(RCrypto *cry, const ut8 *buf, int len); + int (*final)(RCrypto *cry, const ut8 *buf, int len); int (*use)(const char *algo); - int (*fini)(struct r_crypto_t *cry); + int (*fini)(RCrypto *cry); struct list_head list; } RCryptoPlugin; #ifdef R_API -R_API struct r_crypto_t *r_crypto_init(struct r_crypto_t *cry, int hard); -R_API struct r_crypto_t *r_crypto_as_new(struct r_crypto_t *cry); -R_API int r_crypto_add(struct r_crypto_t *cry, struct r_crypto_plugin_t *h); -R_API struct r_crypto_t *r_crypto_new(); -R_API struct r_crypto_t *r_crypto_free(struct r_crypto_t *cry); -R_API int r_crypto_use(struct r_crypto_t *cry, const char *algo); -R_API int r_crypto_set_key(struct r_crypto_t *cry, const ut8* key, int mode, int direction); -R_API int r_crypto_get_key_size(struct r_crypto_t *cry); -R_API int r_crypto_set_iv(struct r_crypto_t *cry, const ut8 *iv); -R_API int r_crypto_update(struct r_crypto_t *cry, ut8 *buf, int len); -R_API int r_crypto_final(struct r_crypto_t *cry, ut8 *buf, int len); -R_API int r_crypto_append(struct r_crypto_t *cry, const ut8 *buf, int len); -R_API ut8 *r_crypto_get_output(struct r_crypto_t *cry); +R_API RCrypto *r_crypto_init(RCrypto *cry, int hard); +R_API RCrypto *r_crypto_as_new(RCrypto *cry); +R_API int r_crypto_add(RCrypto *cry, RCryptoPlugin *h); +R_API RCrypto *r_crypto_new(); +R_API RCrypto *r_crypto_free(RCrypto *cry); +R_API int r_crypto_use(RCrypto *cry, const char *algo); +R_API int r_crypto_set_key(RCrypto *cry, const ut8* key, int mode, int direction); +R_API int r_crypto_get_key_size(RCrypto *cry); +R_API int r_crypto_set_iv(RCrypto *cry, const ut8 *iv); +R_API int r_crypto_update(RCrypto *cry, ut8 *buf, int len); +R_API int r_crypto_final(RCrypto *cry, ut8 *buf, int len); +R_API int r_crypto_append(RCrypto *cry, const ut8 *buf, int len); +R_API ut8 *r_crypto_get_output(RCrypto *cry); #endif /* plugin pointers */ -extern struct r_crypto_plugin_t r_crypto_plugin_aes; +extern RCryptoPlugin r_crypto_plugin_aes; #endif diff --git a/libr/include/r_db.h b/libr/include/r_db.h index 8016f56dde26c..7055994186489 100644 --- a/libr/include/r_db.h +++ b/libr/include/r_db.h @@ -26,14 +26,14 @@ typedef struct r_db_block_t { typedef struct r_db_t { int id_min; int id_max; - struct r_db_block_t *blocks[R_DB_KEYS]; + RDatabaseBlock *blocks[R_DB_KEYS]; int blocks_sz[R_DB_KEYS]; void *cb_user; int (*cb_free)(void *db, const void *item, void *user); } RDatabase; typedef struct r_db_iter_t { - struct r_db_t *db; + RDatabase *db; int key; /* key to be used */ int size; /* key size */ int path[256]; /* for each depth level */ @@ -64,40 +64,40 @@ typedef struct r_pair_item_t { #ifdef R_API -R_API RPairItem *r_pair_item_new (); -R_API void r_pair_item_free (RPairItem*); +R_API RPairItem *r_pair_item_new(); +R_API void r_pair_item_free(RPairItem*); R_API int r_pair_load(RPair *p, const char *f); R_API int r_pair_save(RPair *p, const char *f); -R_API RPair *r_pair_new (); -R_API RPair *r_pair_new_from_file (const char *file); -R_API void r_pair_free (RPair *p); -R_API void r_pair_delete (RPair *p, const char *name); -R_API char *r_pair_get (RPair *p, const char *name); -R_API void r_pair_set (RPair *p, const char *name, const char *value); -R_API RList *r_pair_list (RPair *p, const char *domain); -R_API void r_pair_set_sync_dir (RPair *p, const char *dir); -R_API int r_pair_sync (RPair *p); -R_API void r_pair_reset (RPair *p); +R_API RPair *r_pair_new(); +R_API RPair *r_pair_new_from_file(const char *file); +R_API void r_pair_free(RPair *p); +R_API void r_pair_delete(RPair *p, const char *name); +R_API char *r_pair_get(RPair *p, const char *name); +R_API void r_pair_set(RPair *p, const char *name, const char *value); +R_API RList *r_pair_list(RPair *p, const char *domain); +R_API void r_pair_set_sync_dir(RPair *p, const char *dir); +R_API int r_pair_sync(RPair *p); +R_API void r_pair_reset(RPair *p); /* */ -R_API struct r_db_t *r_db_new(); -R_API struct r_db_block_t *r_db_block_new(); -R_API int r_db_add_id(struct r_db_t *db, int off, int size); -R_API int r_db_add(struct r_db_t *db, void *b); -R_API int r_db_add_unique(struct r_db_t *db, void *b); -R_API void **r_db_get(struct r_db_t *db, int key, const ut8 *b); +R_API RDatabase *r_db_new(); +R_API RDatabaseBlock *r_db_block_new(); +R_API int r_db_add_id(RDatabase *db, int off, int size); +R_API int r_db_add(RDatabase *db, void *b); +R_API int r_db_add_unique(RDatabase *db, void *b); +R_API void **r_db_get(RDatabase *db, int key, const ut8 *b); R_API void *r_db_get_cur(void **ptr); -R_API int r_db_delete(struct r_db_t *db, const void *b); +R_API int r_db_delete(RDatabase *db, const void *b); R_API void **r_db_get_next(void **ptr); -R_API struct r_db_iter_t *r_db_iter(struct r_db_t *db, int key, const ut8 *b); -R_API void *r_db_iter_cur(struct r_db_iter_t *iter); -R_API int r_db_iter_next(struct r_db_iter_t *iter); -R_API void *r_db_iter_prev(struct r_db_iter_t *iter); -R_API struct r_db_iter_t *r_db_iter_new(struct r_db_t *db, int key); -R_API struct r_db_iter_t *r_db_iter_free(struct r_db_iter_t *iter); -R_API int r_db_free(struct r_db_t *db); -//R_API int r_db_push(struct r_db_t *db, const ut8 *b); -//R_API ut8 *r_db_pop(struct r_db_t *db); +R_API RDatabaseIter *r_db_iter(RDatabase *db, int key, const ut8 *b); +R_API void *r_db_iter_cur(RDatabaseIter *iter); +R_API int r_db_iter_next(RDatabaseIter *iter); +R_API void *r_db_iter_prev(RDatabaseIter *iter); +R_API RDatabaseIter *r_db_iter_new(RDatabase *db, int key); +R_API RDatabaseIter *r_db_iter_free(RDatabaseIter *iter); +R_API int r_db_free(RDatabase *db); +//R_API int r_db_push(RDatabase *db, const ut8 *b); +//R_API ut8 *r_db_pop(RDatabase *db); #endif #endif diff --git a/libr/include/r_debug.h b/libr/include/r_debug.h index d006a5ed91cda..ab0475d378a87 100644 --- a/libr/include/r_debug.h +++ b/libr/include/r_debug.h @@ -206,49 +206,46 @@ typedef struct r_debug_pid_t { } RDebugPid; #ifdef R_API -R_API int r_debug_attach(struct r_debug_t *dbg, int pid); -R_API int r_debug_detach(struct r_debug_t *dbg, int pid); -R_API int r_debug_startv(struct r_debug_t *dbg, int argc, char **argv); -R_API int r_debug_start(struct r_debug_t *dbg, const char *cmd); -R_API int r_debug_stop_reason(struct r_debug_t *dbg); -R_API int r_debug_wait(struct r_debug_t *dbg); -R_API int r_debug_step_over(struct r_debug_t *dbg, int steps); -R_API int r_debug_continue_until(struct r_debug_t *dbg, ut64 addr); +R_API int r_debug_attach(RDebug *dbg, int pid); +R_API int r_debug_detach(RDebug *dbg, int pid); +R_API int r_debug_startv(RDebug *dbg, int argc, char **argv); +R_API int r_debug_start(RDebug *dbg, const char *cmd); +R_API int r_debug_stop_reason(RDebug *dbg); +R_API int r_debug_wait(RDebug *dbg); +R_API int r_debug_step_over(RDebug *dbg, int steps); +R_API int r_debug_continue_until(RDebug *dbg, ut64 addr); R_API int r_debug_continue_until_optype(RDebug *dbg, int type, int over); R_API int r_debug_continue_until_nontraced(RDebug *dbg); -R_API int r_debug_continue_syscall(struct r_debug_t *dbg, int sc); -//R_API int r_debug_pid_add(struct r_debug_t *dbg); -//R_API int r_debug_pid_add_thread(struct r_debug_t *dbg); -//R_API int r_debug_pid_del(struct r_debug_t *dbg); -//R_API int r_debug_pid_del_thread(struct r_debug_t *dbg); +R_API int r_debug_continue_syscall(RDebug *dbg, int sc); +//R_API int r_debug_pid_add(RDebug *dbg); +//R_API int r_debug_pid_add_thread(RDebug *dbg); +//R_API int r_debug_pid_del(RDebug *dbg); +//R_API int r_debug_pid_del_thread(RDebug *dbg); R_API int r_debug_pid_list(RDebug *dbg, int pid); R_API RDebugPid *r_debug_pid_new(const char *path, int pid, char status, ut64 pc); R_API RDebugPid *r_debug_pid_free(RDebugPid *pid); R_API RList *r_debug_pids(RDebug *dbg, int pid); R_API int r_debug_set_arch(RDebug *dbg, int arch, int bits); -R_API int r_debug_use(struct r_debug_t *dbg, const char *str); -R_API int r_debug_plugin_add(struct r_debug_t *dbg, struct r_debug_plugin_t *foo); -R_API int r_debug_plugin_init(struct r_debug_t *dbg); -R_API int r_debug_plugin_list(struct r_debug_t *dbg); +R_API int r_debug_use(RDebug *dbg, const char *str); -R_API struct r_debug_t *r_debug_new(int hard); -R_API struct r_debug_t *r_debug_free(struct r_debug_t *dbg); +R_API RDebug *r_debug_new(int hard); +R_API RDebug *r_debug_free(RDebug *dbg); /* send signals */ -R_API int r_debug_kill(struct r_debug_t *dbg, boolt thread, int sig); +R_API int r_debug_kill(RDebug *dbg, boolt thread, int sig); // XXX: must be uint64 action -R_API int r_debug_kill_setup(struct r_debug_t *dbg, int sig, int action); -R_API int r_debug_step(struct r_debug_t *dbg, int steps); -R_API int r_debug_continue(struct r_debug_t *dbg); -R_API int r_debug_continue_kill(struct r_debug_t *dbg, int signal); -R_API int r_debug_select(struct r_debug_t *dbg, int pid, int tid); +R_API int r_debug_kill_setup(RDebug *dbg, int sig, int action); +R_API int r_debug_step(RDebug *dbg, int steps); +R_API int r_debug_continue(RDebug *dbg); +R_API int r_debug_continue_kill(RDebug *dbg, int signal); +R_API int r_debug_select(RDebug *dbg, int pid, int tid); /* handle.c */ -R_API int r_debug_plugin_init(struct r_debug_t *dbg); -R_API int r_debug_plugin_set(struct r_debug_t *dbg, const char *str); -R_API int r_debug_plugin_list(struct r_debug_t *dbg); -R_API int r_debug_plugin_add(struct r_debug_t *dbg, struct r_debug_plugin_t *foo); +R_API int r_debug_plugin_init(RDebug *dbg); +R_API int r_debug_plugin_set(RDebug *dbg, const char *str); +R_API int r_debug_plugin_list(RDebug *dbg); +R_API int r_debug_plugin_add(RDebug *dbg, RDebugPlugin *foo); /* memory */ R_API int r_debug_map_alloc(RDebug *dbg, RDebugMap *map); @@ -278,7 +275,7 @@ R_API int r_debug_reg_set(RDebug *dbg, const char *name, ut64 num); R_API ut64 r_debug_reg_get(RDebug *dbg, const char *name); R_API void r_debug_io_bind(RDebug *dbg, RIO *io); -R_API ut64 r_debug_execute(struct r_debug_t *dbg, ut8 *buf, int len); +R_API ut64 r_debug_execute(RDebug *dbg, ut8 *buf, int len); R_API int r_debug_map_sync(RDebug *dbg); R_API int r_debug_stop(RDebug *dbg); @@ -293,8 +290,8 @@ R_API ut64 r_debug_arg_get (RDebug *dbg, int fast, int num); R_API int r_debug_arg_set (RDebug *dbg, int fast, int num, ut64 value); /* pid */ -R_API int r_debug_pid_list(struct r_debug_t *dbg, int pid); -R_API int r_debug_thread_list(struct r_debug_t *dbg, int pid); +R_API int r_debug_pid_list(RDebug *dbg, int pid); +R_API int r_debug_thread_list(RDebug *dbg, int pid); R_API void r_debug_trace_reset (RDebug *dbg); R_API int r_debug_trace_pc (RDebug *dbg); diff --git a/libr/include/r_flags.h b/libr/include/r_flags.h index f2db3fd403fc8..c7a43597947a9 100644 --- a/libr/include/r_flags.h +++ b/libr/include/r_flags.h @@ -44,14 +44,14 @@ typedef struct r_flag_t { } RFlag; #ifdef R_API -R_API struct r_flag_t * r_flag_new(); +R_API RFlag * r_flag_new(); R_API RFlag * r_flag_free(RFlag *f); -R_API void r_flag_list(struct r_flag_t *f, int rad); +R_API void r_flag_list(RFlag *f, int rad); R_API RFlagItem *r_flag_get(RFlag *f, const char *name); R_API RFlagItem *r_flag_get_i(RFlag *f, ut64 off); -R_API int r_flag_unset(struct r_flag_t *f, const char *name, RFlagItem *p); -R_API int r_flag_unset_i(struct r_flag_t *f, ut64 addr, RFlagItem *p); -R_API int r_flag_set(struct r_flag_t *fo, const char *name, ut64 addr, ut32 size, int dup); +R_API int r_flag_unset(RFlag *f, const char *name, RFlagItem *p); +R_API int r_flag_unset_i(RFlag *f, ut64 addr, RFlagItem *p); +R_API int r_flag_set(RFlag *fo, const char *name, ut64 addr, ut32 size, int dup); R_API int r_flag_sort(RFlag *f, int namesort); R_API void r_flag_item_set_name(RFlagItem *item, const char *name); R_API int r_flag_unset_glob(RFlag *f, const char *name); diff --git a/libr/include/r_fs.h b/libr/include/r_fs.h index 308f1cc37ab06..7a4ed88e1fae2 100644 --- a/libr/include/r_fs.h +++ b/libr/include/r_fs.h @@ -81,36 +81,36 @@ enum { }; #ifdef R_API -R_API RFS *r_fs_new (); -R_API void r_fs_view (RFS* fs, int view); -R_API void r_fs_free (RFS* fs); -R_API void r_fs_add (RFS *fs, RFSPlugin *p); -R_API void r_fs_del (RFS *fs, RFSPlugin *p); -R_API RFSRoot *r_fs_mount (RFS* fs, const char *fstype, const char *path, ut64 delta); -R_API boolt r_fs_umount (RFS* fs, const char *path); -R_API RList *r_fs_root (RFS *fs, const char *path); -R_API RFSFile *r_fs_open (RFS* fs, const char *path); -R_API void r_fs_close (RFS* fs, RFSFile *file); -R_API int r_fs_read (RFS* fs, RFSFile *file, ut64 addr, int len); +R_API RFS *r_fs_new(); +R_API void r_fs_view(RFS* fs, int view); +R_API void r_fs_free(RFS* fs); +R_API void r_fs_add(RFS *fs, RFSPlugin *p); +R_API void r_fs_del(RFS *fs, RFSPlugin *p); +R_API RFSRoot *r_fs_mount(RFS* fs, const char *fstype, const char *path, ut64 delta); +R_API boolt r_fs_umount(RFS* fs, const char *path); +R_API RList *r_fs_root(RFS *fs, const char *path); +R_API RFSFile *r_fs_open(RFS* fs, const char *path); +R_API void r_fs_close(RFS* fs, RFSFile *file); +R_API int r_fs_read(RFS* fs, RFSFile *file, ut64 addr, int len); R_API RFSFile *r_fs_slurp(RFS* fs, const char *path); R_API RList *r_fs_dir(RFS* fs, const char *path); -R_API int r_fs_dir_dump (RFS* fs, const char *path, const char *name); -R_API RList *r_fs_find_name (RFS* fs, const char *name, const char *glob); -R_API RList *r_fs_find_off (RFS* fs, const char *name, ut64 off); +R_API int r_fs_dir_dump(RFS* fs, const char *path, const char *name); +R_API RList *r_fs_find_name(RFS* fs, const char *name, const char *glob); +R_API RList *r_fs_find_off(RFS* fs, const char *name, ut64 off); R_API RList *r_fs_partitions(RFS* fs, const char *ptype, ut64 delta); -R_API char *r_fs_name (RFS *fs, ut64 offset); -R_API int r_fs_prompt (RFS *fs, const char *root); +R_API char *r_fs_name(RFS *fs, ut64 offset); +R_API int r_fs_prompt(RFS *fs, const char *root); /* file.c */ -R_API RFSFile *r_fs_file_new (RFSRoot *root, const char *path); -R_API void r_fs_file_free (RFSFile *file); -R_API RFSRoot *r_fs_root_new (const char *path, ut64 delta); -R_API void r_fs_root_free (RFSRoot *root); +R_API RFSFile *r_fs_file_new(RFSRoot *root, const char *path); +R_API void r_fs_file_free(RFSFile *file); +R_API RFSRoot *r_fs_root_new(const char *path, ut64 delta); +R_API void r_fs_root_free(RFSRoot *root); R_API RFSPartition *r_fs_partition_new(int num, ut64 start, ut64 length); -R_API void r_fs_partition_free (RFSPartition *p); -R_API const char *r_fs_partition_type (const char *part, int type); -R_API const char *r_fs_partition_type_get (int n); -R_API int r_fs_partition_get_size (); // WTF. wrong function name +R_API void r_fs_partition_free(RFSPartition *p); +R_API const char *r_fs_partition_type(const char *part, int type); +R_API const char *r_fs_partition_type_get(int n); +R_API int r_fs_partition_get_size(); // WTF. wrong function name /* plugins */ extern RFSPlugin r_fs_plugin_ext2; diff --git a/libr/include/r_io.h b/libr/include/r_io.h index e343bb1856f37..f7c9bb72a09dc 100644 --- a/libr/include/r_io.h +++ b/libr/include/r_io.h @@ -100,7 +100,7 @@ typedef struct r_io_t { ut8 *write_mask_buf; int write_mask_len; struct r_io_plugin_t *plugin; - struct r_io_undo_t undo; + RIOUndo undo; //RList *iolist; struct list_head io_list; RList *sections; @@ -123,9 +123,9 @@ typedef struct r_io_plugin_t { char *name; char *desc; void *widget; - int (*listener)(RIODesc *io); + int (*listener)(RIODesc *io); int (*init)(); - struct r_io_undo_t undo; + RIOUndo undo; struct debug_t *debug; // ??? int (*system)(RIO *io, RIODesc *fd, const char *); RIODesc* (*open)(RIO *io, const char *, int rw, int mode); @@ -141,7 +141,7 @@ typedef struct r_io_plugin_t { } RIOPlugin; typedef struct r_io_list_t { - struct r_io_plugin_t *plugin; + RIOPlugin *plugin; struct list_head list; } RIOList; @@ -205,15 +205,15 @@ R_API RIO *r_io_new(); R_API RIO *r_io_free(RIO *io); R_API int r_io_plugin_init(RIO *io); R_API void r_io_raise (RIO *io, int fd); -R_API int r_io_plugin_open(RIO *io, int fd, struct r_io_plugin_t *plugin); -R_API int r_io_plugin_close(RIO *io, int fd, struct r_io_plugin_t *plugin); +R_API int r_io_plugin_open(RIO *io, int fd, RIOPlugin *plugin); +R_API int r_io_plugin_close(RIO *io, int fd, RIOPlugin *plugin); R_API int r_io_plugin_generate(RIO *io); -R_API int r_io_plugin_add(RIO *io, struct r_io_plugin_t *plugin); +R_API int r_io_plugin_add(RIO *io, RIOPlugin *plugin); R_API int r_io_plugin_list(RIO *io); R_API int r_io_is_listener(RIO *io); // TODO: _del ?? -R_API struct r_io_plugin_t *r_io_plugin_resolve(RIO *io, const char *filename); -R_API struct r_io_plugin_t *r_io_plugin_resolve_fd(RIO *io, int fd); +R_API RIOPlugin *r_io_plugin_resolve(RIO *io, const char *filename); +R_API RIOPlugin *r_io_plugin_resolve_fd(RIO *io, int fd); /* io/io.c */ R_API int r_io_set_write_mask(RIO *io, const ut8 *buf, int len); @@ -242,18 +242,18 @@ R_API int r_io_cache_invalidate(RIO *io, ut64 from, ut64 to); R_API void r_io_cache_commit(RIO *io); R_API void r_io_cache_enable(RIO *io, int read, int write); R_API void r_io_cache_init(RIO *io); -R_API int r_io_cache_list(struct r_io_t *io, int rad); -R_API void r_io_cache_reset(struct r_io_t *io, int set); +R_API int r_io_cache_list(RIO *io, int rad); +R_API void r_io_cache_reset(RIO *io, int set); R_API int r_io_cache_write(RIO *io, ut64 addr, const ut8 *buf, int len); R_API int r_io_cache_read(RIO *io, ut64 addr, ut8 *buf, int len); /* io/bind.c */ -R_API int r_io_bind(RIO *io, struct r_io_bind_t *bnd); +R_API int r_io_bind(RIO *io, RIOBind *bnd); /* io/map.c */ R_API void r_io_map_init(RIO *io); R_API RIOMap *r_io_map_add(RIO *io, int fd, int flags, ut64 delta, ut64 offset, ut64 size); -R_API int r_io_map_del_at(struct r_io_t *io, ut64 addr); +R_API int r_io_map_del_at(RIO *io, ut64 addr); R_API int r_io_map_del(RIO *io, int fd); R_API int r_io_map(RIO *io, const char *file, ut64 offset); R_API int r_io_map_select(RIO *io, ut64 off); @@ -272,7 +272,7 @@ R_API struct r_io_section_t *r_io_section_get(RIO *io, ut64 offset); R_API ut64 r_io_section_get_offset(RIO *io, ut64 offset); R_API ut64 r_io_section_get_vaddr(RIO *io, ut64 offset); R_API int r_io_section_get_rwx(RIO *io, ut64 offset); -R_API int r_io_section_overlaps(RIO *io, struct r_io_section_t *s); +R_API int r_io_section_overlaps(RIO *io, RIOSection *s); R_API ut64 r_io_section_vaddr_to_offset(RIO *io, ut64 vaddr); R_API ut64 r_io_section_offset_to_vaddr(RIO *io, ut64 offset); R_API ut64 r_io_section_next(RIO *io, ut64 o); @@ -293,7 +293,7 @@ R_API void r_io_wundo_new(RIO *io, ut64 off, const ut8 *data, int len); R_API void r_io_wundo_clear(RIO *io); R_API int r_io_wundo_size(RIO *io); R_API void r_io_wundo_list(RIO *io); -R_API int r_io_wundo_set_t(RIO *io, struct r_io_undo_w_t *u, int set) ; +R_API int r_io_wundo_set_t(RIO *io, RIOUndoWrite *u, int set) ; R_API void r_io_wundo_set_all(RIO *io, int set); R_API int r_io_wundo_set(RIO *io, int n, int set); @@ -303,28 +303,28 @@ R_API void r_io_desc_fini(RIO *io); R_API RIODesc *r_io_desc_new(RIOPlugin *plugin, int fd, const char *name, int flags, int mode, void *data); R_API void r_io_desc_free(RIODesc *desc); //R_API void r_io_desc_add(RIO *io, RIODesc *desc); -R_API int r_io_desc_del(struct r_io_t *io, int fd); +R_API int r_io_desc_del(RIO *io, int fd); R_API RIODesc *r_io_desc_get(RIO *io, int fd); R_API void r_io_desc_add(RIO *io, RIODesc *desc); //int fd, const char *file, int flags, struct r_io_plugin_t *plugin); R_API int r_io_desc_del(RIO *io, int fd); -R_API struct r_io_desc_t *r_io_desc_get(RIO *io, int fd); +R_API RIODesc *r_io_desc_get(RIO *io, int fd); //R_API int r_io_desc_generate(RIO *io); /* plugins */ -extern struct r_io_plugin_t r_io_plugin_procpid; -extern struct r_io_plugin_t r_io_plugin_malloc; -extern struct r_io_plugin_t r_io_plugin_ptrace; -extern struct r_io_plugin_t r_io_plugin_w32dbg; -extern struct r_io_plugin_t r_io_plugin_mach; -extern struct r_io_plugin_t r_io_plugin_debug; -extern struct r_io_plugin_t r_io_plugin_shm; -extern struct r_io_plugin_t r_io_plugin_gdb; -extern struct r_io_plugin_t r_io_plugin_rap; -extern struct r_io_plugin_t r_io_plugin_http; -extern struct r_io_plugin_t r_io_plugin_haret; -extern struct r_io_plugin_t r_io_plugin_bfdbg; -extern struct r_io_plugin_t r_io_plugin_w32; -extern struct r_io_plugin_t r_io_plugin_ewf; +extern RIOPlugin r_io_plugin_procpid; +extern RIOPlugin r_io_plugin_malloc; +extern RIOPlugin r_io_plugin_ptrace; +extern RIOPlugin r_io_plugin_w32dbg; +extern RIOPlugin r_io_plugin_mach; +extern RIOPlugin r_io_plugin_debug; +extern RIOPlugin r_io_plugin_shm; +extern RIOPlugin r_io_plugin_gdb; +extern RIOPlugin r_io_plugin_rap; +extern RIOPlugin r_io_plugin_http; +extern RIOPlugin r_io_plugin_haret; +extern RIOPlugin r_io_plugin_bfdbg; +extern RIOPlugin r_io_plugin_w32; +extern RIOPlugin r_io_plugin_ewf; #endif #if 0 diff --git a/libr/include/r_lang.h b/libr/include/r_lang.h index 2cb4202e9a066..4003f9f4a1d46 100644 --- a/libr/include/r_lang.h +++ b/libr/include/r_lang.h @@ -15,13 +15,13 @@ typedef struct r_lang_plugin_t { const char *name; const char *desc; const char **help; - int (*init)(struct r_lang_t* user); - int (*setup)(struct r_lang_t* user); - int (*fini)(struct r_lang_t *user); - int (*prompt)(struct r_lang_t *user); - int (*run)(struct r_lang_t *user, const char *code, int len); - int (*run_file)(struct r_lang_t *user, const char *file); - int (*set_argv)(struct r_lang_t *user, int argc, char **argv); + int (*init)(RLang *user); + int (*setup)(RLang *user); + int (*fini)(RLang *user); + int (*prompt)(RLang *user); + int (*run)(RLang *user, const char *code, int len); + int (*run_file)(RLang *user, const char *file); + int (*set_argv)(RLang *user, int argc, char **argv); } RLangPlugin; typedef struct r_lang_def_t { @@ -31,10 +31,10 @@ typedef struct r_lang_def_t { } RLangDef; #ifdef R_API -R_API struct r_lang_t *r_lang_new(); +R_API RLang *r_lang_new(); R_API void *r_lang_free(RLang *lang); R_API int r_lang_setup(RLang *lang); -R_API int r_lang_add(RLang *lang, struct r_lang_plugin_t *foo); +R_API int r_lang_add(RLang *lang, RLangPlugin *foo); R_API int r_lang_list(RLang *lang); R_API int r_lang_use(RLang *lang, const char *name); R_API int r_lang_run(RLang *lang, const char *code, int len); @@ -45,12 +45,12 @@ R_API int r_lang_set_argv(RLang *lang, int argc, char **argv); R_API int r_lang_run(RLang *lang, const char *code, int len); R_API int r_lang_run_file(RLang *lang, const char *file); R_API int r_lang_prompt(RLang *lang); -R_API void r_lang_plugin_free (RLangPlugin *p); // XXX -R_API RLangPlugin *r_lang_get (RLang *lang, const char *name); +R_API void r_lang_plugin_free(RLangPlugin *p); // XXX +R_API RLangPlugin *r_lang_get(RLang *lang, const char *name); // TODO: rename r_Lang_add for r_lang_plugin_add R_API int r_lang_define(RLang *lang, const char *type, const char *name, void *value); R_API void r_lang_undef(RLang *lang, const char *name); -R_API void r_lang_def_free (RLangDef *def); +R_API void r_lang_def_free(RLangDef *def); #endif #endif diff --git a/libr/include/r_lib.h b/libr/include/r_lib.h index da9d8ff492a11..831877c5f513b 100644 --- a/libr/include/r_lib.h +++ b/libr/include/r_lib.h @@ -35,11 +35,11 @@ typedef struct r_lib_handler_t { int type; char desc[128]; void *user; /* user pointer */ - int (*constructor)(struct r_lib_plugin_t *, void *user, void *data); - int (*destructor)(struct r_lib_plugin_t *, void *user, void *data); + int (*constructor)(RLibPlugin *, void *user, void *data); + int (*destructor)(RLibPlugin *, void *user, void *data); } RLibHandler; -/* this structure should be pointed by the 'radare_plugin' symbol +/* this structure should be pointed by the 'radare_plugin' symbol found in the loaded .so */ typedef struct r_lib_struct_t { int type; @@ -83,13 +83,16 @@ R_API int r_lib_dl_check_filename(const char *file); /* high level api */ R_API RLib *r_lib_new(const char *symname); R_API RLib *r_lib_free(RLib *lib); -R_API int r_lib_run_handler(RLib *lib, struct r_lib_plugin_t *plugin, struct r_lib_struct_t *symbol); +R_API int r_lib_run_handler(RLib *lib, RLibPlugin *plugin, RLibStruct *symbol); R_API RLibHandler *r_lib_get_handler(RLib *lib, int type); R_API int r_lib_open(RLib *lib, const char *file); R_API int r_lib_opendir(RLib *lib, const char *path); R_API char *r_lib_path(const char *libname); R_API void r_lib_list(RLib *lib); -R_API int r_lib_add_handler(RLib *lib, int type, const char *desc, int (*cb)(struct r_lib_plugin_t *,void *, void *), int (*dt)(struct r_lib_plugin_t *, void *, void *), void *user ); +R_API int r_lib_add_handler(RLib *lib, int type, const char *desc, + int (*cb)(RLibPlugin *, void *, void *), + int (*dt)(RLibPlugin *, void *, void *), + void *user ); R_API int r_lib_del_handler(RLib *lib, int type); R_API int r_lib_close(RLib *lib, const char *file); #endif diff --git a/libr/include/r_line.h b/libr/include/r_line.h index 6fa62b8327eb4..6eb90d37a53fc 100644 --- a/libr/include/r_line.h +++ b/libr/include/r_line.h @@ -22,8 +22,9 @@ typedef struct r_line_buffer_t { int length; } RLineBuffer; -struct r_line_t; // ugly forward declaration -typedef int (*RLineCallback)(struct r_line_t *line); +typedef struct r_line_t RLine; // forward declaration + +typedef int (*RLineCallback)(RLine *line); typedef struct r_line_comp_t { int argc; @@ -31,7 +32,7 @@ typedef struct r_line_comp_t { RLineCallback run; } RLineCompletion; -typedef struct r_line_t { +struct r_line_t { RLineCompletion completion; RLineHistory history; RLineBuffer buffer; @@ -41,16 +42,15 @@ typedef struct r_line_t { char *clipboard; int disable; void *user; -} RLine; +}; /* RLine */ #ifdef R_API -// XXX : Kill extern variables -//extern RLine r_line_instance; -R_API RLine *r_line_new (); -R_API RLine *r_line_singleton (); -R_API void r_line_free (); + +R_API RLine *r_line_new(); +R_API RLine *r_line_singleton(); +R_API void r_line_free(); R_API char *r_line_get_prompt (); -R_API void r_line_set_prompt (const char *prompt); +R_API void r_line_set_prompt(const char *prompt); R_API int r_line_hist_load(const char *file); R_API char *r_line_readline(); @@ -59,6 +59,6 @@ R_API int r_line_hist_add(const char *line); R_API int r_line_hist_save(const char *file); R_API int r_line_hist_label(const char *label, void (*cb)(const char*)); R_API void r_line_label_show(); -#endif #endif +#endif diff --git a/libr/include/r_magic.h b/libr/include/r_magic.h index 516d0d6d4fd4b..e12e304448984 100644 --- a/libr/include/r_magic.h +++ b/libr/include/r_magic.h @@ -18,17 +18,17 @@ #ifdef R_API #define RMagic struct magic_set -#define r_magic_new(x) magic_open(x) -#define r_magic_free(x) x?magic_close(x):x -#define r_magic_file(x,y) magic_file(x,y) -#define r_magic_buffer(x,y,z) magic_buffer(x,y,z) -#define r_magic_descriptor(x,y) magic_descriptor(x,y) -#define r_magic_error(x) magic_error(x) -#define r_magic_setflags(x,y) magic_setflags(x,y) -#define r_magic_load(x,y) magic_load(x,y) -#define r_magic_compile(x,y) magic_compile(x,y) -#define r_magic_check(x,y) magic_check(x,y) -#define r_magic_errno(x) magic_errno(x) +#define r_magic_new(x) magic_open(x) +#define r_magic_free(x) x ? magic_close(x) : x +#define r_magic_file(x,y) magic_file(x,y) +#define r_magic_buffer(x,y,z) magic_buffer(x,y,z) +#define r_magic_descriptor(x,y) magic_descriptor(x,y) +#define r_magic_error(x) magic_error(x) +#define r_magic_setflags(x,y) magic_setflags(x,y) +#define r_magic_load(x,y) magic_load(x,y) +#define r_magic_compile(x,y) magic_compile(x,y) +#define r_magic_check(x,y) magic_check(x,y) +#define r_magic_errno(x) magic_errno(x) #endif #else @@ -42,11 +42,11 @@ /* limits */ #ifndef HOWMANY -# define HOWMANY (256 * 1024) /* how much of the file to look at */ +# define HOWMANY (256 * 1024) /* how much of the file to look at */ #endif -#define MAXDESC 64 -#define MAXMAGIS 8192 /* max entries in any one magic file or directory */ -#define MAXstring 32 /* max leng of "string" types */ +#define MAXDESC 64 +#define MAXMAGIS 8192 /* max entries in any one magic file or directory */ +#define MAXstring 32 /* max leng of "string" types */ /* define this outside to fix build for g++ */ union VALUETYPE { @@ -63,26 +63,27 @@ union VALUETYPE { }; /* either number or string */ /* constants */ -#define MAGICNO 0xF11E041C -#define VERSIONNO 5 -#define FILE_MAGICSIZE (32 * 6) +#define MAGICNO 0xF11E041C +#define VERSIONNO 5 +#define FILE_MAGICSIZE (32 * 6) -#define FILE_LOAD 0 -#define FILE_CHECK 1 -#define FILE_COMPILE 2 +#define FILE_LOAD 0 +#define FILE_CHECK 1 +#define FILE_COMPILE 2 struct r_magic { /* Word 1 */ ut16 cont_level; /* level of ">" */ ut8 flag; -#define INDIR 0x01 /* if '(...)' appears */ -#define OFFADD 0x02 /* if '>&' or '>...(&' appears */ -#define INDIROFFADD 0x04 /* if '>&(' appears */ -#define UNSIGNED 0x08 /* comparison is unsigned */ -#define NOSPACE 0x10 /* suppress space character before output */ -#define BINTEST 0x20 /* test is for a binary type (set only - for top-level tests) */ -#define TEXTTEST 0 /* for passing to file_softmagic */ + +#define INDIR 0x01 /* if '(...)' appears */ +#define OFFADD 0x02 /* if '>&' or '>...(&' appears */ +#define INDIROFFADD 0x04 /* if '>&(' appears */ +#define UNSIGNED 0x08 /* comparison is unsigned */ +#define NOSPACE 0x10 /* suppress space character before output */ +#define BINTEST 0x20 /* test is for a binary type (set only + for top-level tests) */ +#define TEXTTEST 0 /* for passing to file_softmagic */ ut8 dummy1; @@ -91,46 +92,46 @@ struct r_magic { ut8 vallen; /* length of string value, if any */ ut8 type; /* comparison type (FILE_*) */ ut8 in_type; /* type of indirection */ -#define FILE_INVALID 0 -#define FILE_BYTE 1 -#define FILE_SHORT 2 -#define FILE_DEFAULT 3 -#define FILE_LONG 4 -#define FILE_STRING 5 -#define FILE_DATE 6 -#define FILE_BESHORT 7 -#define FILE_BELONG 8 -#define FILE_BEDATE 9 -#define FILE_LESHORT 10 -#define FILE_LELONG 11 -#define FILE_LEDATE 12 -#define FILE_PSTRING 13 -#define FILE_LDATE 14 -#define FILE_BELDATE 15 -#define FILE_LELDATE 16 -#define FILE_REGEX 17 -#define FILE_BESTRING16 18 -#define FILE_LESTRING16 19 -#define FILE_SEARCH 20 -#define FILE_MEDATE 21 -#define FILE_MELDATE 22 -#define FILE_MELONG 23 -#define FILE_QUAD 24 -#define FILE_LEQUAD 25 -#define FILE_BEQUAD 26 -#define FILE_QDATE 27 -#define FILE_LEQDATE 28 -#define FILE_BEQDATE 29 -#define FILE_QLDATE 30 -#define FILE_LEQLDATE 31 -#define FILE_BEQLDATE 32 -#define FILE_FLOAT 33 -#define FILE_BEFLOAT 34 -#define FILE_LEFLOAT 35 -#define FILE_DOUBLE 36 -#define FILE_BEDOUBLE 37 -#define FILE_LEDOUBLE 38 -#define FILE_NAMES_SIZE 39/* size of array to contain all names */ +#define FILE_INVALID 0 +#define FILE_BYTE 1 +#define FILE_SHORT 2 +#define FILE_DEFAULT 3 +#define FILE_LONG 4 +#define FILE_STRING 5 +#define FILE_DATE 6 +#define FILE_BESHORT 7 +#define FILE_BELONG 8 +#define FILE_BEDATE 9 +#define FILE_LESHORT 10 +#define FILE_LELONG 11 +#define FILE_LEDATE 12 +#define FILE_PSTRING 13 +#define FILE_LDATE 14 +#define FILE_BELDATE 15 +#define FILE_LELDATE 16 +#define FILE_REGEX 17 +#define FILE_BESTRING16 18 +#define FILE_LESTRING16 19 +#define FILE_SEARCH 20 +#define FILE_MEDATE 21 +#define FILE_MELDATE 22 +#define FILE_MELONG 23 +#define FILE_QUAD 24 +#define FILE_LEQUAD 25 +#define FILE_BEQUAD 26 +#define FILE_QDATE 27 +#define FILE_LEQDATE 28 +#define FILE_BEQDATE 29 +#define FILE_QLDATE 30 +#define FILE_LEQLDATE 31 +#define FILE_BEQLDATE 32 +#define FILE_FLOAT 33 +#define FILE_BEFLOAT 34 +#define FILE_LEFLOAT 35 +#define FILE_DOUBLE 36 +#define FILE_BEDOUBLE 37 +#define FILE_LEDOUBLE 38 +#define FILE_NAMES_SIZE 39 /* size of array to contain all names */ #define MAGIC_IS_STRING(t) \ ((t) == FILE_STRING || \ @@ -141,39 +142,39 @@ struct r_magic { (t) == FILE_SEARCH || \ (t) == FILE_DEFAULT) -#define FILE_FMT_NONE 0 -#define FILE_FMT_NUM 1 /* "cduxXi" */ -#define FILE_FMT_STR 2 /* "s" */ -#define FILE_FMT_QUAD 3 /* "ll" */ -#define FILE_FMT_FLOAT 4 /* "eEfFgG" */ -#define FILE_FMT_DOUBLE 5 /* "eEfFgG" */ +#define FILE_FMT_NONE 0 +#define FILE_FMT_NUM 1 /* "cduxXi" */ +#define FILE_FMT_STR 2 /* "s" */ +#define FILE_FMT_QUAD 3 /* "ll" */ +#define FILE_FMT_FLOAT 4 /* "eEfFgG" */ +#define FILE_FMT_DOUBLE 5 /* "eEfFgG" */ /* Word 3 */ ut8 in_op; /* operator for indirection */ ut8 mask_op; /* operator for mask */ ut8 cond; /* conditional type */ - ut8 dummy2; - -#define FILE_OPS "&|^+-*/%" -#define FILE_OPAND 0 -#define FILE_OPOR 1 -#define FILE_OPXOR 2 -#define FILE_OPADD 3 -#define FILE_OPMINUS 4 -#define FILE_OPMULTIPLY 5 -#define FILE_OPDIVIDE 6 -#define FILE_OPMODULO 7 -#define FILE_OPS_MASK 0x07 /* mask for above ops */ -#define FILE_UNUSED_1 0x08 -#define FILE_UNUSED_2 0x10 -#define FILE_UNUSED_3 0x20 -#define FILE_OPINVERSE 0x40 -#define FILE_OPINDIRECT 0x80 - -#define COND_NONE 0 -#define COND_IF 1 -#define COND_ELIF 2 -#define COND_ELSE 3 + ut8 dummy2; + +#define FILE_OPS "&|^+-*/%" +#define FILE_OPAND 0 +#define FILE_OPOR 1 +#define FILE_OPXOR 2 +#define FILE_OPADD 3 +#define FILE_OPMINUS 4 +#define FILE_OPMULTIPLY 5 +#define FILE_OPDIVIDE 6 +#define FILE_OPMODULO 7 +#define FILE_OPS_MASK 0x07 /* mask for above ops */ +#define FILE_UNUSED_1 0x08 +#define FILE_UNUSED_2 0x10 +#define FILE_UNUSED_3 0x20 +#define FILE_OPINVERSE 0x40 +#define FILE_OPINDIRECT 0x80 + +#define COND_NONE 0 +#define COND_IF 1 +#define COND_ELIF 2 +#define COND_ELSE 3 /* Word 4 */ ut32 offset; /* offset to magic number */ @@ -189,6 +190,7 @@ struct r_magic { ut32 _flags; /* modifier flags */ } _s; /* for use with string types */ } _u; + #define num_mask _u._mask #define str_range _u._s._count #define str_flags _u._s._flags @@ -201,19 +203,19 @@ struct r_magic { char mimetype[MAXDESC]; /* MIME type */ }; -#define BIT(A) (1 << (A)) -#define STRING_COMPACT_BLANK BIT(0) -#define STRING_COMPACT_OPTIONAL_BLANK BIT(1) -#define STRING_IGNORE_LOWERCASE BIT(2) -#define STRING_IGNORE_UPPERCASE BIT(3) -#define REGEX_OFFSET_START BIT(4) -#define CHAR_COMPACT_BLANK 'B' -#define CHAR_COMPACT_OPTIONAL_BLANK 'b' -#define CHAR_IGNORE_LOWERCASE 'c' -#define CHAR_IGNORE_UPPERCASE 'C' -#define CHAR_REGEX_OFFSET_START 's' -#define STRING_IGNORE_CASE (STRING_IGNORE_LOWERCASE|STRING_IGNORE_UPPERCASE) -#define STRING_DEFAULT_RANGE 100 +#define BIT(A) (1 << (A)) +#define STRING_COMPACT_BLANK BIT(0) +#define STRING_COMPACT_OPTIONAL_BLANK BIT(1) +#define STRING_IGNORE_LOWERCASE BIT(2) +#define STRING_IGNORE_UPPERCASE BIT(3) +#define REGEX_OFFSET_START BIT(4) +#define CHAR_COMPACT_BLANK 'B' +#define CHAR_COMPACT_OPTIONAL_BLANK 'b' +#define CHAR_IGNORE_LOWERCASE 'c' +#define CHAR_IGNORE_UPPERCASE 'C' +#define CHAR_REGEX_OFFSET_START 's' +#define STRING_IGNORE_CASE (STRING_IGNORE_LOWERCASE|STRING_IGNORE_UPPERCASE) +#define STRING_DEFAULT_RANGE 100 /* list of magic entries */ struct mlist { @@ -225,30 +227,31 @@ struct mlist { struct mlist *next, *prev; }; -#define R_MAGIC_NONE 0x000000 /* No flags */ -#define R_MAGIC_DEBUG 0x000001 /* Turn on debugging */ -#define R_MAGIC_SYMLINK 0x000002 /* Follow symlinks */ -#define R_MAGIC_COMPRESS 0x000004 /* Check inside compressed files */ -#define R_MAGIC_DEVICES 0x000008 /* Look at the contents of devices */ -#define R_MAGIC_MIME_TYPE 0x000010 /* Return only the MIME type */ -#define R_MAGIC_CONTINUE 0x000020 /* Return all matches */ -#define R_MAGIC_CHECK 0x000040 /* Print warnings to stderr */ -#define R_MAGIC_PRESERVE_ATIME 0x000080 /* Restore access time on exit */ -#define R_MAGIC_RAW 0x000100 /* Don't translate unprint chars */ -#define R_MAGIC_ERROR 0x000200 /* Handle ENOENT etc as real errors */ -#define R_MAGIC_MIME_ENCODING 0x000400 /* Return only the MIME encoding */ -#define R_MAGIC_MIME (R_MAGIC_MIME_TYPE|R_MAGIC_MIME_ENCODING) -#define R_MAGIC_NO_CHECK_COMPRESS 0x001000 /* Don't check for compressed files */ -#define R_MAGIC_NO_CHECK_TAR 0x002000 /* Don't check for tar files */ -#define R_MAGIC_NO_CHECK_SOFT 0x004000 /* Don't check magic entries */ -#define R_MAGIC_NO_CHECK_APPTYPE 0x008000 /* Don't check application type */ -#define R_MAGIC_NO_CHECK_ELF 0x010000 /* Don't check for elf details */ -#define R_MAGIC_NO_CHECK_ASCII 0x020000 /* Don't check for ascii files */ -#define R_MAGIC_NO_CHECK_TOKENS 0x100000 /* Don't check ascii/tokens */ +#define R_MAGIC_NONE 0x000000 /* No flags */ +#define R_MAGIC_DEBUG 0x000001 /* Turn on debugging */ +#define R_MAGIC_SYMLINK 0x000002 /* Follow symlinks */ +#define R_MAGIC_COMPRESS 0x000004 /* Check inside compressed files */ +#define R_MAGIC_DEVICES 0x000008 /* Look at the contents of devices */ +#define R_MAGIC_MIME_TYPE 0x000010 /* Return only the MIME type */ +#define R_MAGIC_CONTINUE 0x000020 /* Return all matches */ +#define R_MAGIC_CHECK 0x000040 /* Print warnings to stderr */ +#define R_MAGIC_PRESERVE_ATIME 0x000080 /* Restore access time on exit */ +#define R_MAGIC_RAW 0x000100 /* Don't translate unprint chars */ +#define R_MAGIC_ERROR 0x000200 /* Handle ENOENT etc as real errors */ +#define R_MAGIC_MIME_ENCODING 0x000400 /* Return only the MIME encoding */ +#define R_MAGIC_MIME (R_MAGIC_MIME_TYPE|R_MAGIC_MIME_ENCODING) +#define R_MAGIC_NO_CHECK_COMPRESS 0x001000 /* Don't check for compressed files */ +#define R_MAGIC_NO_CHECK_TAR 0x002000 /* Don't check for tar files */ +#define R_MAGIC_NO_CHECK_SOFT 0x004000 /* Don't check magic entries */ +#define R_MAGIC_NO_CHECK_APPTYPE 0x008000 /* Don't check application type */ +#define R_MAGIC_NO_CHECK_ELF 0x010000 /* Don't check for elf details */ +#define R_MAGIC_NO_CHECK_ASCII 0x020000 /* Don't check for ascii files */ +#define R_MAGIC_NO_CHECK_TOKENS 0x100000 /* Don't check ascii/tokens */ /* Defined for backwards compatibility; do nothing */ -#define MAGIC_NO_CHECK_FORTRAN 0x000000 /* Don't check ascii/fortran */ -#define MAGIC_NO_CHECK_TROFF 0x000000 /* Don't check ascii/troff */ +#define MAGIC_NO_CHECK_FORTRAN 0x000000 /* Don't check ascii/fortran */ +#define MAGIC_NO_CHECK_TROFF 0x000000 /* Don't check ascii/troff */ + struct r_magic_set { struct mlist *mlist; struct cont { diff --git a/libr/include/r_parse.h b/libr/include/r_parse.h index 6840153b9af39..01bc2ec92b380 100644 --- a/libr/include/r_parse.h +++ b/libr/include/r_parse.h @@ -24,8 +24,8 @@ typedef struct r_parse_plugin_t { int (*fini)(void *user); int (*parse)(RParse *p, const char *data, char *str); int (*assemble)(RParse *p, char *data, char *str); - int (*filter)(RParse *p, struct r_flag_t *f, char *data, char *str, int len); - int (*varsub)(RParse *p, struct r_anal_fcn_t *f, char *data, char *str, int len); + int (*filter)(RParse *p, RFlag *f, char *data, char *str, int len); + int (*varsub)(RParse *p, RAnalFunction *f, char *data, char *str, int len); struct list_head list; } RParsePlugin; @@ -39,7 +39,7 @@ R_API int r_parse_use(RParse *p, const char *name); R_API int r_parse_parse(RParse *p, const char *data, char *str); R_API int r_parse_assemble(RParse *p, char *data, char *str); R_API int r_parse_filter(RParse *p, RFlag *f, char *data, char *str, int len); -R_API int r_parse_varsub(RParse *p, RAnalFcn *f, char *data, char *str, int len); +R_API int r_parse_varsub(RParse *p, RAnalFunction *f, char *data, char *str, int len); /* plugin pointers */ extern struct r_parse_plugin_t r_parse_plugin_dummy; diff --git a/libr/include/r_print.h b/libr/include/r_print.h index 1002cf9617f23..760b07d53c0bd 100644 --- a/libr/include/r_print.h +++ b/libr/include/r_print.h @@ -63,15 +63,15 @@ R_API void r_print_code(RPrint *p, ut64 addr, ut8 *buf, int len); R_API void r_print_format(RPrint *p, ut64 seek, const ut8* buf, int len, const char *fmt); // XXX . change wide, zeroend, urlencode for option flags R_API int r_print_string(RPrint *p, ut64 seek, const ut8 *str, int len, int wide, int zeroend, int urlencode); -R_API int r_print_date_dos(struct r_print_t *p, ut8 *buf, int len); -R_API int r_print_date_w32(struct r_print_t *p, const ut8 *buf, int len); -R_API int r_print_date_unix(struct r_print_t *p, const ut8 *buf, int len); +R_API int r_print_date_dos(RPrint *p, ut8 *buf, int len); +R_API int r_print_date_w32(RPrint *p, const ut8 *buf, int len); +R_API int r_print_date_unix(RPrint *p, const ut8 *buf, int len); R_API void r_print_zoom(RPrint *p, void *user, RPrintZoomCallback cb, ut64 from, ut64 to, int len, int maxlen); R_API void r_print_progressbar(RPrint *pr, int pc, int _cols); // WIP -R_API int r_print_unpack7bit (const char *src, char *dest); -R_API int r_print_pack7bit (const char *src, char *dest); +R_API int r_print_unpack7bit(const char *src, char *dest); +R_API int r_print_pack7bit(const char *src, char *dest); #endif #endif diff --git a/libr/include/r_reg.h b/libr/include/r_reg.h index 26b0d3b67cbd2..267189a2a783c 100644 --- a/libr/include/r_reg.h +++ b/libr/include/r_reg.h @@ -69,7 +69,7 @@ R_API int r_reg_set_profile(RReg *reg, const char *profile); R_API const char *r_reg_get_name(RReg *reg, int kind); R_API int r_reg_set_name(RReg *reg, int role, const char *name); -R_API struct r_reg_item_t *r_reg_get(RReg *reg, const char *name, int type); +R_API RRegItem *r_reg_get(RReg *reg, const char *name, int type); R_API RList *r_reg_get_list(RReg *reg, int type); /* XXX: dupped ?? */ @@ -77,13 +77,13 @@ R_API int r_reg_type_by_name(const char *str); R_API int r_reg_get_name_idx(const char *type); /* value */ -R_API ut64 r_reg_get_value(RReg *reg, struct r_reg_item_t *item); -R_API int r_reg_set_value(RReg *reg, struct r_reg_item_t *item, ut64 value); -R_API float r_reg_get_fvalue(RReg *reg, struct r_reg_item_t *item); -R_API int r_reg_set_fvalue(RReg *reg, struct r_reg_item_t *item, float value); -R_API ut64 r_reg_get_pvalue(RReg *reg, struct r_reg_item_t *item, int packidx); +R_API ut64 r_reg_get_value(RReg *reg, RRegItem *item); +R_API int r_reg_set_value(RReg *reg, RRegItem *item, ut64 value); +R_API float r_reg_get_fvalue(RReg *reg, RRegItem *item); +R_API int r_reg_set_fvalue(RReg *reg, RRegItem *item, float value); +R_API ut64 r_reg_get_pvalue(RReg *reg, RRegItem *item, int packidx); R_API char *r_reg_get_bvalue(RReg *reg, RRegItem *item); -R_API int r_reg_set_pvalue(RReg *reg, struct r_reg_item_t *item, ut64 value, int packidx); +R_API int r_reg_set_pvalue(RReg *reg, RRegItem *item, ut64 value, int packidx); /* byte arena */ R_API ut8* r_reg_get_bytes(RReg *reg, int type, int *size); diff --git a/libr/include/r_regex.h b/libr/include/r_regex.h index bd5aa37dadbd7..5743023afeea1 100644 --- a/libr/include/r_regex.h +++ b/libr/include/r_regex.h @@ -19,44 +19,44 @@ typedef struct r_regmatch_t { typedef int regoff_t; /* regcomp() flags */ -#define R_REGEX_BASIC 0000 +#define R_REGEX_BASIC 0000 #define R_REGEX_EXTENDED 0001 -#define R_REGEX_ICASE 0002 -#define R_REGEX_NOSUB 0004 -#define R_REGEX_NEWLINE 0010 -#define R_REGEX_NOSPEC 0020 -#define R_REGEX_PEND 0040 -#define R_REGEX_DUMP 0200 +#define R_REGEX_ICASE 0002 +#define R_REGEX_NOSUB 0004 +#define R_REGEX_NEWLINE 0010 +#define R_REGEX_NOSPEC 0020 +#define R_REGEX_PEND 0040 +#define R_REGEX_DUMP 0200 /* regerror() flags */ -#define R_REGEX_ENOSYS (-1) /* Reserved */ -#define R_REGEX_NOMATCH 1 -#define R_REGEX_BADPAT 2 -#define R_REGEX_ECOLLATE 3 -#define R_REGEX_ECTYPE 4 -#define R_REGEX_EESCAPE 5 -#define R_REGEX_ESUBREG 6 -#define R_REGEX_EBRACK 7 -#define R_REGEX_EPAREN 8 -#define R_REGEX_EBRACE 9 -#define R_REGEX_BADBR 10 -#define R_REGEX_ERANGE 11 -#define R_REGEX_ESPACE 12 -#define R_REGEX_BADRPT 13 -#define R_REGEX_EMPTY 14 -#define R_REGEX_ASSERT 15 -#define R_REGEX_INVARG 16 -#define R_REGEX_ILLSEQ 17 -#define R_REGEX_ATOI 255 /* convert name to number (!) */ -#define R_REGEX_ITOA 0400 /* convert number to name (!) */ +#define R_REGEX_ENOSYS (-1) /* Reserved */ +#define R_REGEX_NOMATCH 1 +#define R_REGEX_BADPAT 2 +#define R_REGEX_ECOLLATE 3 +#define R_REGEX_ECTYPE 4 +#define R_REGEX_EESCAPE 5 +#define R_REGEX_ESUBREG 6 +#define R_REGEX_EBRACK 7 +#define R_REGEX_EPAREN 8 +#define R_REGEX_EBRACE 9 +#define R_REGEX_BADBR 10 +#define R_REGEX_ERANGE 11 +#define R_REGEX_ESPACE 12 +#define R_REGEX_BADRPT 13 +#define R_REGEX_EMPTY 14 +#define R_REGEX_ASSERT 15 +#define R_REGEX_INVARG 16 +#define R_REGEX_ILLSEQ 17 +#define R_REGEX_ATOI 255 /* convert name to number (!) */ +#define R_REGEX_ITOA 0400 /* convert number to name (!) */ /* regexec() flags */ -#define R_REGEX_NOTBOL 00001 -#define R_REGEX_NOTEOL 00002 +#define R_REGEX_NOTBOL 00001 +#define R_REGEX_NOTEOL 00002 #define R_REGEX_STARTEND 00004 -#define R_REGEX_TRACE 00400 /* tracing of execution */ -#define R_REGEX_LARGE 01000 /* force large representation */ -#define R_REGEX_BACKR 02000 /* force use of backref code */ +#define R_REGEX_TRACE 00400 /* tracing of execution */ +#define R_REGEX_LARGE 01000 /* force large representation */ +#define R_REGEX_BACKR 02000 /* force use of backref code */ R_API RRegex *r_regex_new (const char *pattern, const char *cflags); R_API int r_regex_run (const char *pattern, const char *flags, const char *text); diff --git a/libr/include/r_util.h b/libr/include/r_util.h index e78614a097857..de9feb7f91ea4 100644 --- a/libr/include/r_util.h +++ b/libr/include/r_util.h @@ -259,9 +259,9 @@ R_API void r_buf_free(RBuffer *b); R_API ut64 r_mem_get_num(ut8 *b, int size, int endian); /* MEMORY POOL */ -R_API RMemoryPool* r_mem_pool_deinit(struct r_mem_pool_t *pool); +R_API RMemoryPool* r_mem_pool_deinit(RMemoryPool *pool); R_API RMemoryPool *r_mem_pool_new(int nodesize, int poolsize, int poolcount); -R_API RMemoryPool *r_mem_pool_free(struct r_mem_pool_t *pool); +R_API RMemoryPool *r_mem_pool_free(RMemoryPool *pool); R_API void* r_mem_pool_alloc(RMemoryPool *pool); /* FACTORY POOL */ @@ -274,14 +274,14 @@ R_API void r_poolfactory_free(RPoolFactory *pf); R_API int r_mem_count(const ut8 **addr); R_API RCache* r_cache_new(); -R_API void r_cache_free(struct r_cache_t *c); -R_API char *r_cache_get(struct r_cache_t *c, ut64 addr); -R_API int r_cache_set(struct r_cache_t *c, ut64 addr, char *str); -R_API int r_cache_validate(struct r_cache_t *c, ut64 from, ut64 to); -R_API int r_cache_invalidate(struct r_cache_t *c, ut64 from, ut64 to); - -R_API void r_prof_start(struct r_prof_t *p); -R_API double r_prof_end(struct r_prof_t *p); +R_API void r_cache_free(RCache *c); +R_API char *r_cache_get(RCache *c, ut64 addr); +R_API int r_cache_set(RCache *c, ut64 addr, char *str); +R_API int r_cache_validate(RCache *c, ut64 from, ut64 to); +R_API int r_cache_invalidate(RCache *c, ut64 from, ut64 to); + +R_API void r_prof_start(RProfile *p); +R_API double r_prof_end(RProfile *p); R_API int r_mem_protect(void *ptr, int size, const char *prot); R_API int r_mem_set_num (ut8 *dest, int dest_size, ut64 num, int endian); diff --git a/libr/parse/p/parse_att2intel.c b/libr/parse/p/parse_att2intel.c index d5f5a46863921..2838d8e7f5b24 100644 --- a/libr/parse/p/parse_att2intel.c +++ b/libr/parse/p/parse_att2intel.c @@ -196,7 +196,7 @@ static int filter(RParse *p, RFlag *f, char *data, char *str, int len) { return R_FALSE; } -static int varsub(RParse *p, struct r_anal_fcn_t *f, char *data, char *str, int len) { +static int varsub(RParse *p, RAnalFunction *f, char *data, char *str, int len) { char *ptr, *ptr2; int i; diff --git a/libr/parse/p/parse_x86_pseudo.c b/libr/parse/p/parse_x86_pseudo.c index edaf387011c34..cc156e6e043b0 100644 --- a/libr/parse/p/parse_x86_pseudo.c +++ b/libr/parse/p/parse_x86_pseudo.c @@ -124,7 +124,7 @@ static int parse(RParse *p, const char *data, char *str) { return R_TRUE; } -static int assemble(struct r_parse_t *p, char *data, char *str) { +static int assemble(RParse *p, char *data, char *str) { char *ptr; printf ("assembling '%s' to generate real asm code\n", str); ptr = strchr (str, '='); @@ -135,7 +135,7 @@ static int assemble(struct r_parse_t *p, char *data, char *str) { return R_TRUE; } -static int filter(struct r_parse_t *p, struct r_flag_t *f, char *data, char *str, int len) { +static int filter(RParse *p, RFlag *f, char *data, char *str, int len) { RListIter *iter; RFlagItem *flag; char *ptr, *ptr2; @@ -161,7 +161,7 @@ static int filter(struct r_parse_t *p, struct r_flag_t *f, char *data, char *str return R_FALSE; } -static int varsub(struct r_parse_t *p, struct r_anal_fcn_t *f, char *data, char *str, int len) { +static int varsub(RParse *p, RAnalFunction *f, char *data, char *str, int len) { char *ptr, *ptr2; int i; diff --git a/libr/parse/parse.c b/libr/parse/parse.c index 8b4a63a7eaae3..1c7d3056a9e8b 100644 --- a/libr/parse/parse.c +++ b/libr/parse/parse.c @@ -7,7 +7,7 @@ #include #include "../config.h" -static RParsePlugin *parse_static_plugins[] = +static RParsePlugin *parse_static_plugins[] = { R_PARSE_STATIC_PLUGINS }; R_API RParse *r_parse_new() { @@ -94,13 +94,13 @@ R_API int r_parse_parse(RParse *p, const char *data, char *str) { return R_FALSE; } -R_API int r_parse_filter(RParse *p, struct r_flag_t *f, char *data, char *str, int len) { +R_API int r_parse_filter(RParse *p, RFlag *f, char *data, char *str, int len) { if (p->cur && p->cur->filter) return p->cur->filter (p, f, data, str, len); return R_FALSE; } -R_API int r_parse_varsub(RParse *p, struct r_anal_fcn_t *f, char *data, char *str, int len) { +R_API int r_parse_varsub(RParse *p, RAnalFunction *f, char *data, char *str, int len) { if (p->cur && p->cur->varsub) return p->cur->varsub (p, f, data, str, len); return R_FALSE;