mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-26 09:06:02 +00:00
Unify fcn_find and get_fcn_at in get_fcn_in and get_fcn_at
This commit is contained in:
parent
d176cb1d01
commit
df289d8611
@ -81,7 +81,7 @@ R_API char *r_anal_cc_to_string (RAnal *anal, RAnalCC* cc) {
|
||||
}
|
||||
break;
|
||||
case R_ANAL_CC_TYPE_STDCALL: // CALL
|
||||
fcn = r_anal_fcn_find (anal, cc->jump,
|
||||
fcn = r_anal_get_fcn_in (anal, cc->jump,
|
||||
R_ANAL_FCN_TYPE_FCN|R_ANAL_FCN_TYPE_SYM|R_ANAL_FCN_TYPE_IMP);
|
||||
if (fcn && fcn->name)
|
||||
snprintf (str, sizeof (str), "%s(", fcn->name);
|
||||
|
@ -288,7 +288,7 @@ repeat:
|
||||
if (delay.adjust) {
|
||||
bb->size -= oplen;
|
||||
fcn->ninstr--;
|
||||
VERBOSE_DELAY eprintf ("Correct for branch delay @ %08"PFMT64x " bb.addr=%08"PFMT64x " corrected.bb=%d f.uncorr=%d\n",
|
||||
VERBOSE_DELAY eprintf ("Correct for branch delay @ %08"PFMT64x " bb.addr=%08"PFMT64x " corrected.bb=%d f.uncorr=%d\n",
|
||||
addr + idx - oplen, bb->addr, bb->size, fcn->size);
|
||||
FITFCNSZ();
|
||||
}
|
||||
@ -315,7 +315,7 @@ repeat:
|
||||
} else {
|
||||
varname = r_str_newf ("local_%x", -op.ptr);
|
||||
r_anal_var_add (anal, fcn->addr, 1, -op.ptr,
|
||||
'v', NULL,
|
||||
'v', NULL,
|
||||
anal->bits/8, varname);
|
||||
}
|
||||
free (varname);
|
||||
@ -473,7 +473,7 @@ R_API int r_anal_fcn(RAnal *anal, RAnalFunction *fcn, ut64 addr, ut8 *buf, ut64
|
||||
|
||||
// TODO: need to implement r_anal_fcn_remove(RAnal *anal, RAnalFunction *fcn);
|
||||
R_API int r_anal_fcn_insert(RAnal *anal, RAnalFunction *fcn) {
|
||||
RAnalFunction *f = r_anal_fcn_find (anal, fcn->addr,
|
||||
RAnalFunction *f = r_anal_get_fcn_in (anal, fcn->addr,
|
||||
R_ANAL_FCN_TYPE_ROOT);
|
||||
if (f) return R_FALSE;
|
||||
#if USE_NEW_FCN_STORE
|
||||
@ -496,7 +496,7 @@ R_API int r_anal_fcn_add(RAnal *a, ut64 addr, ut64 size, const char *name, int t
|
||||
RAnalFunction *fcn;
|
||||
if (size<1)
|
||||
return R_FALSE;
|
||||
fcn = r_anal_fcn_find (a, addr, R_ANAL_FCN_TYPE_ROOT);
|
||||
fcn = r_anal_get_fcn_in (a, addr, R_ANAL_FCN_TYPE_ROOT);
|
||||
if (fcn == NULL) {
|
||||
if (!(fcn = r_anal_fcn_new ()))
|
||||
return R_FALSE;
|
||||
@ -522,7 +522,7 @@ R_API int r_anal_fcn_add(RAnal *a, ut64 addr, ut64 size, const char *name, int t
|
||||
|
||||
R_API int r_anal_fcn_del_locs(RAnal *anal, ut64 addr) {
|
||||
RListIter *iter, *iter2;
|
||||
RAnalFunction *fcn, *f = r_anal_fcn_find (anal, addr,
|
||||
RAnalFunction *fcn, *f = r_anal_get_fcn_in (anal, addr,
|
||||
R_ANAL_FCN_TYPE_ROOT);
|
||||
#if USE_NEW_FCN_STORE
|
||||
#warning TODO: r_anal_fcn_del_locs not implemented for newstore
|
||||
@ -566,12 +566,11 @@ R_API int r_anal_fcn_del(RAnal *a, ut64 addr) {
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
R_API RAnalFunction *r_anal_fcn_find(RAnal *anal, ut64 addr, int type) {
|
||||
R_API RAnalFunction *r_anal_fcn_in(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);
|
||||
RAnalFunction *f = r_listrange_find_in_range (anal->fcnstore, addr);
|
||||
return (f->addr == addr)? f: NULL;
|
||||
return r_listrange_find_in_range (anal->fcnstore, addr);
|
||||
#else
|
||||
RAnalFunction *fcn, *ret = NULL;
|
||||
RListIter *iter;
|
||||
@ -728,7 +727,7 @@ R_API int r_anal_fcn_cc(RAnalFunction *fcn) {
|
||||
CC = E - N + 2P
|
||||
E = the number of edges of the graph.
|
||||
N = the number of nodes of the graph.
|
||||
P = the number of connected components (exit nodes).
|
||||
P = the number of connected components (exit nodes).
|
||||
*/
|
||||
int E = 0, N = 0, P = 0;
|
||||
RListIter *iter;
|
||||
@ -771,7 +770,7 @@ R_API char *r_anal_fcn_to_string(RAnal *a, RAnalFunction* fs) {
|
||||
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,
|
||||
@ -864,17 +863,28 @@ R_API int r_anal_str_to_fcn(RAnal *a, RAnalFunction *f, const char *sig) {
|
||||
//return R_FALSE;
|
||||
}
|
||||
|
||||
R_API RAnalFunction *r_anal_get_fcn_at(RAnal *anal, ut64 addr) {
|
||||
return r_anal_fcn_find (anal, addr, 0);
|
||||
#if 0
|
||||
RAnalFunction *fcni;
|
||||
R_API RAnalFunction *r_anal_get_fcn_at(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_root (anal->fcnstore, addr);
|
||||
#else
|
||||
RAnalFunction *fcn, *ret = NULL;
|
||||
RListIter *iter;
|
||||
//eprintf ("DEPRECATED: get-at\n");
|
||||
r_list_foreach (anal->fcns, iter, fcni)
|
||||
//if (fcni->addr == addr)
|
||||
if (addr >= fcni->addr && addr < (fcni->addr+fcni->size))
|
||||
return fcni;
|
||||
return NULL;
|
||||
if (type == R_ANAL_FCN_TYPE_ROOT) {
|
||||
r_list_foreach (anal->fcns, iter, fcn) {
|
||||
if (addr == fcn->addr)
|
||||
return fcn;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
r_list_foreach (anal->fcns, iter, fcn) {
|
||||
if (!type || (fcn->type & type)) {
|
||||
if (addr == fcn->addr)
|
||||
ret = fcn;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -219,12 +219,12 @@ R_API char *r_anal_op_to_string(RAnal *anal, RAnalOp *op) {
|
||||
snprintf (ret, sizeof (ret), "%s()", r0);
|
||||
break;
|
||||
case R_ANAL_OP_TYPE_CALL:
|
||||
f = r_anal_fcn_find (anal, op->jump, R_ANAL_FCN_TYPE_NULL);
|
||||
f = r_anal_get_fcn_in (anal, op->jump, R_ANAL_FCN_TYPE_NULL);
|
||||
if (f) snprintf (ret, sizeof (ret), "%s()", f->name);
|
||||
else snprintf (ret, sizeof (ret), "0x%"PFMT64x"()", op->jump);
|
||||
break;
|
||||
case R_ANAL_OP_TYPE_CCALL:
|
||||
f = r_anal_fcn_find (anal, op->jump, R_ANAL_FCN_TYPE_NULL);
|
||||
f = r_anal_get_fcn_in (anal, op->jump, R_ANAL_FCN_TYPE_NULL);
|
||||
{
|
||||
RAnalBlock *bb = r_anal_bb_from_offset (anal, op->addr);
|
||||
if (bb) {
|
||||
|
@ -85,14 +85,14 @@ R_API int r_anal_var_delete (RAnal *a, ut64 var_addr, const char kind, int scope
|
||||
R_API RAnalVar *r_anal_var_get (RAnal *a, ut64 addr, char kind, int scope, int delta) {
|
||||
RAnalVar *av;
|
||||
struct VarType vt;
|
||||
RAnalFunction *fcn = r_anal_get_fcn_at (a, addr);
|
||||
RAnalFunction *fcn = r_anal_get_fcn_at (a, addr, 0);
|
||||
if (!fcn)
|
||||
return NULL;
|
||||
if (delta<0) {
|
||||
kind = 'v';
|
||||
delta = -delta;
|
||||
}
|
||||
char *vardef = sdb_get (DB,
|
||||
char *vardef = sdb_get (DB,
|
||||
sdb_fmt (0, "var.0x%"PFMT64x".%c.%d.%d",
|
||||
fcn->addr, kind, scope, delta), 0);
|
||||
if (!vardef)
|
||||
@ -106,7 +106,7 @@ R_API RAnalVar *r_anal_var_get (RAnal *a, ut64 addr, char kind, int scope, int d
|
||||
av->name = strdup (vt.name);
|
||||
av->size = vt.size;
|
||||
av->type = strdup (vt.type);
|
||||
|
||||
|
||||
sdb_fmt_free (&vt, SDB_VARTYPE_FMT);
|
||||
// TODO:
|
||||
// get name from sdb
|
||||
|
@ -17,7 +17,7 @@ R_API char *r_core_anal_fcn_autoname(RCore *core, ut64 addr) {
|
||||
int use_getuid = 0;
|
||||
int use_isatty = 0;
|
||||
char *do_call = NULL;
|
||||
RAnalFunction *fcn = r_anal_get_fcn_at (core->anal, addr);
|
||||
RAnalFunction *fcn = r_anal_get_fcn_at (core->anal, addr, 0);
|
||||
if (fcn) {
|
||||
RAnalRef *ref;
|
||||
RListIter *iter;
|
||||
@ -545,7 +545,7 @@ R_API int r_core_anal_fcn(RCore *core, ut64 at, ut64 from, int reftype, int dept
|
||||
return R_FALSE;
|
||||
#if 1
|
||||
{
|
||||
RAnalFunction *fcn = r_anal_get_fcn_at (core->anal, at);
|
||||
RAnalFunction *fcn = r_anal_get_fcn_at (core->anal, at, 0);
|
||||
if (fcn) {
|
||||
//int len = r_list_length (fcn->xrefs);
|
||||
// XXX: use r_anal-xrefs api and sdb
|
||||
@ -638,7 +638,7 @@ R_API int r_core_anal_fcn(RCore *core, ut64 at, ut64 from, int reftype, int dept
|
||||
// real read.
|
||||
#if 0
|
||||
if (!r_core_read_at (core, at+delta, buf, ANALBS))
|
||||
goto error;
|
||||
goto error;
|
||||
#else
|
||||
// this is unnecessary if its contiguous
|
||||
r_io_read_at (core->io, at+delta, buf, ANALBS);
|
||||
@ -886,7 +886,7 @@ else
|
||||
}
|
||||
first2 = 0;
|
||||
r_list_foreach (fcni->refs, iter2, fcnr) {
|
||||
RAnalFunction *fr = r_anal_get_fcn_at (core->anal, fcnr->addr);
|
||||
RAnalFunction *fr = r_anal_get_fcn_at (core->anal, fcnr->addr, 0);
|
||||
if (!fr) {
|
||||
eprintf ("Invalid reference from 0x%08"PFMT64x
|
||||
" to 0x%08"PFMT64x"\n", fcni->addr, fcnr->addr);
|
||||
@ -1727,7 +1727,7 @@ R_API void r_core_anal_undefine (RCore *core, ut64 off) {
|
||||
RAnalFunction *f;
|
||||
r_flag_unset_i (core->flags, off, NULL);
|
||||
r_anal_fcn_del_locs (core->anal, off);
|
||||
f = r_anal_fcn_find (core->anal, off, 0);
|
||||
f = r_anal_get_fcn_in (core->anal, off, 0);
|
||||
if (f) r_meta_del (core->anal, R_META_TYPE_ANY, off, f->size, "");
|
||||
r_anal_fcn_del (core->anal, off);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ static void var_help(RCore *core, char ch) {
|
||||
}
|
||||
|
||||
static int var_cmd(RCore *core, const char *str) {
|
||||
RAnalFunction *fcn = r_anal_fcn_find (core->anal, core->offset, -1);
|
||||
RAnalFunction *fcn = r_anal_get_fcn_in (core->anal, core->offset, -1);
|
||||
char *p, *ostr;
|
||||
int delta, type = *str;
|
||||
|
||||
@ -122,7 +122,7 @@ static int var_cmd(RCore *core, const char *str) {
|
||||
if (fcn) {
|
||||
r_anal_var_add (core->anal, fcn->addr,
|
||||
scope, delta, type,
|
||||
vartype, size, name);
|
||||
vartype, size, name);
|
||||
} else eprintf ("Cannot find function\n");
|
||||
}
|
||||
break;
|
||||
@ -358,7 +358,7 @@ static int anal_fcn_add_bb (RCore *core, const char *input) {
|
||||
case 1: // get fcnaddr
|
||||
fcnaddr = r_num_math (core->num, r_str_word_get0 (ptr, 0));
|
||||
}
|
||||
if ((fcn = r_anal_get_fcn_at (core->anal, fcnaddr)) == NULL ||
|
||||
if ((fcn = r_anal_get_fcn_at (core->anal, fcnaddr, 0)) == NULL ||
|
||||
!r_anal_fcn_add_bb (fcn, addr, size, jump, fail, type, diff)) {
|
||||
//eprintf ("Error: Cannot add bb\n");
|
||||
}
|
||||
@ -432,7 +432,7 @@ static int cmd_anal_fcn(RCore *core, const char *input) {
|
||||
ut64 addr = core->offset;
|
||||
if (input[2]==' ')
|
||||
addr = r_num_math (core->num, input+2);
|
||||
RAnalFunction *fcn = r_anal_fcn_find (core->anal,
|
||||
RAnalFunction *fcn = r_anal_get_fcn_in (core->anal,
|
||||
addr, R_ANAL_FCN_TYPE_NULL);
|
||||
if (fcn) r_cons_printf ("0x%08"PFMT64x"\n", fcn->addr);
|
||||
}
|
||||
@ -457,7 +457,7 @@ static int cmd_anal_fcn(RCore *core, const char *input) {
|
||||
arg = strchr (arg, ' ');
|
||||
if (arg) arg++;
|
||||
} else addr = core->offset;
|
||||
if ((f = r_anal_fcn_find (core->anal, addr, R_ANAL_FCN_TYPE_NULL))) {
|
||||
if ((f = r_anal_get_fcn_in (core->anal, addr, R_ANAL_FCN_TYPE_NULL))) {
|
||||
if (arg && *arg) {
|
||||
r_anal_str_to_fcn (core->anal, f, arg);
|
||||
} else {
|
||||
@ -476,7 +476,7 @@ static int cmd_anal_fcn(RCore *core, const char *input) {
|
||||
case 'c':
|
||||
{
|
||||
RAnalFunction *fcn;
|
||||
if ((fcn = r_anal_get_fcn_at (core->anal, core->offset)) != NULL) {
|
||||
if ((fcn = r_anal_get_fcn_at (core->anal, core->offset, 0)) != NULL) {
|
||||
r_cons_printf ("%i\n", r_anal_fcn_cc (fcn));
|
||||
} else eprintf ("Error: Cannot find function at 0x08%"PFMT64x"\n", core->offset);
|
||||
}
|
||||
@ -485,7 +485,7 @@ static int cmd_anal_fcn(RCore *core, const char *input) {
|
||||
if (input[2] == 'b') {
|
||||
anal_fcn_add_bb (core, input+3);
|
||||
} else {
|
||||
RAnalFunction *fcn = r_anal_fcn_find (core->anal, core->offset,
|
||||
RAnalFunction *fcn = r_anal_get_fcn_in (core->anal, core->offset,
|
||||
R_ANAL_FCN_TYPE_FCN|R_ANAL_FCN_TYPE_SYM);
|
||||
if (fcn) fcn->bits = atoi (input+3);
|
||||
else eprintf ("Cannot find function to set bits\n");
|
||||
@ -508,7 +508,7 @@ static int cmd_anal_fcn(RCore *core, const char *input) {
|
||||
off = r_num_math (core->num, p);
|
||||
}
|
||||
if (*name) {
|
||||
fcn = r_anal_fcn_find (core->anal, off,
|
||||
fcn = r_anal_get_fcn_in (core->anal, off,
|
||||
R_ANAL_FCN_TYPE_FCN|R_ANAL_FCN_TYPE_SYM|R_ANAL_FCN_TYPE_LOC);
|
||||
if (fcn) {
|
||||
//r_cons_printf ("fr %s %s@ 0x%"PFMT64x"\n",
|
||||
@ -536,7 +536,7 @@ static int cmd_anal_fcn(RCore *core, const char *input) {
|
||||
*p = 0;
|
||||
off = r_num_math (core->num, p+1);
|
||||
}
|
||||
fcn = r_anal_fcn_find (core->anal, off,
|
||||
fcn = r_anal_get_fcn_in (core->anal, off,
|
||||
R_ANAL_FCN_TYPE_FCN|R_ANAL_FCN_TYPE_SYM);
|
||||
if (fcn) {
|
||||
RAnalBlock *b;
|
||||
@ -571,7 +571,7 @@ static int cmd_anal_fcn(RCore *core, const char *input) {
|
||||
// list xrefs from current address
|
||||
{
|
||||
ut64 addr = input[2]? r_num_math (core->num, input+2): core->offset;
|
||||
RAnalFunction *fcn = r_anal_fcn_find (core->anal, addr, R_ANAL_FCN_TYPE_NULL);
|
||||
RAnalFunction *fcn = r_anal_get_fcn_in (core->anal, addr, R_ANAL_FCN_TYPE_NULL);
|
||||
if (fcn) {
|
||||
RAnalRef *ref;
|
||||
RListIter *iter;
|
||||
@ -598,7 +598,7 @@ static int cmd_anal_fcn(RCore *core, const char *input) {
|
||||
*p = 0;
|
||||
a = r_num_math (core->num, mi+3);
|
||||
b = r_num_math (core->num, p+1);
|
||||
fcn = r_anal_fcn_find (core->anal, a, R_ANAL_FCN_TYPE_ROOT);
|
||||
fcn = r_anal_get_fcn_in (core->anal, a, R_ANAL_FCN_TYPE_ROOT);
|
||||
if (fcn) {
|
||||
r_anal_fcn_xref_add (core->anal, fcn, a, b, input[2]);
|
||||
} else eprintf ("Cannot add reference to non-function\n");
|
||||
@ -615,7 +615,7 @@ static int cmd_anal_fcn(RCore *core, const char *input) {
|
||||
*p = 0;
|
||||
a = r_num_math (core->num, mi);
|
||||
b = r_num_math (core->num, p+1);
|
||||
fcn = r_anal_fcn_find (core->anal, a, R_ANAL_FCN_TYPE_ROOT);
|
||||
fcn = r_anal_get_fcn_in (core->anal, a, R_ANAL_FCN_TYPE_ROOT);
|
||||
if (fcn) {
|
||||
r_anal_fcn_xref_del (core->anal, fcn, a, b, -1);
|
||||
} else eprintf ("Cannot del reference to non-function\n");
|
||||
@ -669,8 +669,8 @@ static int cmd_anal_fcn(RCore *core, const char *input) {
|
||||
//r_core_anal_undefine (core, core->offset);
|
||||
/* resize function if overlaps */
|
||||
{
|
||||
RAnalFunction *fcn = r_anal_get_fcn_at (core->anal, core->offset);
|
||||
if (fcn)
|
||||
RAnalFunction *fcn = r_anal_get_fcn_at (core->anal, core->offset, 0);
|
||||
if (fcn)
|
||||
r_anal_fcn_resize (fcn, core->offset - fcn->addr);
|
||||
}
|
||||
r_core_anal_fcn (core, core->offset, UT64_MAX,
|
||||
@ -980,7 +980,7 @@ static void esil_step(RCore *core, ut64 until_addr, const char *until_expr) {
|
||||
eprintf ("ADDR BREAK\n");
|
||||
} else goto repeat;
|
||||
}
|
||||
// check esil
|
||||
// check esil
|
||||
if (until_expr) {
|
||||
if (r_anal_esil_condition (core->anal->esil, until_expr)) {
|
||||
eprintf ("ESIL BREAK!\n");
|
||||
@ -1035,7 +1035,7 @@ static int cmd_anal(void *data, const char *input) {
|
||||
r_anal_esil_stack_free (esil);
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
case 's':
|
||||
// aes -> single step
|
||||
// aesu -> until address
|
||||
// aesue -> until esil expression
|
||||
@ -1101,7 +1101,7 @@ static int cmd_anal(void *data, const char *input) {
|
||||
{
|
||||
RListIter *iter;
|
||||
RAnalBlock *bb;
|
||||
RAnalFunction *fcn = r_anal_fcn_find (core->anal,
|
||||
RAnalFunction *fcn = r_anal_get_fcn_in (core->anal,
|
||||
core->offset, R_ANAL_FCN_TYPE_FCN | R_ANAL_FCN_TYPE_SYM);
|
||||
if (fcn) {
|
||||
// emulate every instruction in the function recursively across all the basic blocks
|
||||
|
@ -136,7 +136,7 @@ static int cmd_flag(void *data, const char *input) {
|
||||
bsze = r_num_math (core->num, s+1);
|
||||
}
|
||||
if (*str == '.') {
|
||||
RAnalFunction *fcn = r_anal_fcn_find (core->anal, off, 0);
|
||||
RAnalFunction *fcn = r_anal_get_fcn_in (core->anal, off, 0);
|
||||
if (fcn) r_anal_var_add (core->anal, fcn->addr, 0, off, 'v', "int", 4, str+1);
|
||||
else eprintf ("Cannot find function at 0x%08"PFMT64x"\n", off);
|
||||
} else r_flag_set (core->flags, str, off, bsze, (*input=='+'));
|
||||
@ -147,7 +147,7 @@ static int cmd_flag(void *data, const char *input) {
|
||||
const char *flagname = input+1;
|
||||
while (*flagname==' ') flagname++;
|
||||
if (*flagname=='.') {
|
||||
RAnalFunction *fcn = r_anal_fcn_find (core->anal, off, 0);
|
||||
RAnalFunction *fcn = r_anal_get_fcn_in (core->anal, off, 0);
|
||||
if (fcn) eprintf ("TODO: local_del_name has been deprecated\n");
|
||||
//;r_anal_fcn_local_del_name (core->anal, fcn, flagname+1);
|
||||
else eprintf ("Cannot find function at 0x%08"PFMT64x"\n", off);
|
||||
@ -164,13 +164,13 @@ static int cmd_flag(void *data, const char *input) {
|
||||
if (input[2] == '*') {
|
||||
r_anal_fcn_labels (core->anal, NULL, 1);
|
||||
} else {
|
||||
RAnalFunction *fcn = r_anal_fcn_find (core->anal, off, 0);
|
||||
RAnalFunction *fcn = r_anal_get_fcn_in (core->anal, off, 0);
|
||||
if (fcn) r_anal_fcn_labels (core->anal, fcn, 1);
|
||||
else eprintf ("Cannot find function at 0x%08"PFMT64x"\n", off);
|
||||
}
|
||||
} else {
|
||||
const char *name = input+((input[2]==' ')? 2:1);
|
||||
RAnalFunction *fcn = r_anal_fcn_find (core->anal, off, 0);
|
||||
RAnalFunction *fcn = r_anal_get_fcn_in (core->anal, off, 0);
|
||||
if (fcn) {
|
||||
if (*name=='-') {
|
||||
r_anal_fcn_label_del (core->anal, fcn, name+1, off);
|
||||
@ -180,7 +180,7 @@ static int cmd_flag(void *data, const char *input) {
|
||||
} else eprintf ("Cannot find function at 0x%08"PFMT64x"\n", off);
|
||||
}
|
||||
} else {
|
||||
RAnalFunction *fcn = r_anal_fcn_find (core->anal, off, 0);
|
||||
RAnalFunction *fcn = r_anal_get_fcn_in (core->anal, off, 0);
|
||||
if (fcn) r_anal_fcn_labels (core->anal, fcn, 0);
|
||||
else eprintf ("Cannot find function at 0x%08"PFMT64x"\n", off);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2009-2014 - pancake */
|
||||
/* radare - LGPL - Copyright 2009-2014 - pancake */
|
||||
#if 0
|
||||
static void filter_line(char *line) {
|
||||
char *a;
|
||||
@ -504,7 +504,7 @@ static int cmd_meta(void *data, const char *input) {
|
||||
}
|
||||
break;
|
||||
case 'F':
|
||||
f = r_anal_fcn_find (core->anal, core->offset,
|
||||
f = r_anal_get_fcn_in (core->anal, core->offset,
|
||||
R_ANAL_FCN_TYPE_FCN|R_ANAL_FCN_TYPE_SYM);
|
||||
if (f) r_anal_str_to_fcn (core->anal, f, input+2);
|
||||
else eprintf ("Cannot find function here\n");
|
||||
|
@ -4,7 +4,7 @@
|
||||
static void set_asm_configs(RCore *core, char *arch, ut32 bits, int segoff){
|
||||
r_config_set (core->config, "asm.arch", arch);
|
||||
r_config_set_i (core->config, "asm.bits", bits);
|
||||
// XXX - this needs to be done here, because
|
||||
// XXX - this needs to be done here, because
|
||||
// if arch == x86 and bits == 16, segoff automatically changes
|
||||
r_config_set_i (core->config, "asm.segoff", segoff);
|
||||
}
|
||||
@ -471,7 +471,7 @@ static int pdi(RCore *core, int nb_opcodes, int nb_bytes, int fmt) {
|
||||
|
||||
if (!nb_opcodes) {
|
||||
nb_opcodes = 0xffff;
|
||||
if (nb_bytes < 0) {
|
||||
if (nb_bytes < 0) {
|
||||
// Backward disasm `nb_bytes` bytes
|
||||
nb_bytes = -nb_bytes;
|
||||
core->offset -= nb_bytes;
|
||||
@ -479,7 +479,7 @@ static int pdi(RCore *core, int nb_opcodes, int nb_bytes, int fmt) {
|
||||
}
|
||||
} else if (!nb_bytes) {
|
||||
if (nb_opcodes < 0) {
|
||||
/* Backward disassembly of `ilen` opcodes
|
||||
/* Backward disassembly of `ilen` opcodes
|
||||
* - We compute the new starting offset
|
||||
* - Read at the new offset */
|
||||
nb_opcodes = -nb_opcodes;
|
||||
@ -553,20 +553,20 @@ static void cmd_print_pwn(const RCore* core) {
|
||||
ut64 num, base = r_num_get (core->num, "entry0");
|
||||
if (!base)
|
||||
base = 0x8048000;
|
||||
|
||||
|
||||
eprintf ("[+] Analyzing code starting at 0x%08"PFMT64x"...\n", base);
|
||||
r_sys_sleep (3);
|
||||
|
||||
eprintf ("[+] Looking for vulnerabilities...\n");
|
||||
r_sys_sleep (3);
|
||||
|
||||
|
||||
eprintf ("[+] Found %d bugs...\n", n);
|
||||
for (i=0; i<n; i++) {
|
||||
eprintf ("[+] Deeply analyzing bug %d at 0x%08"PFMT64x"...\n",
|
||||
i, base+r_num_rand (0xffff));
|
||||
r_sys_sleep (1);
|
||||
}
|
||||
|
||||
|
||||
eprintf ("[+] Finding ROP gadgets...\n");
|
||||
n = r_num_rand (0x20);
|
||||
num = base;
|
||||
@ -580,10 +580,10 @@ static void cmd_print_pwn(const RCore* core) {
|
||||
|
||||
eprintf ("[+] Cooking the shellcode...\n");
|
||||
r_sys_sleep (4);
|
||||
|
||||
|
||||
eprintf ("[+] Launching the exploit...\n");
|
||||
r_sys_sleep (1);
|
||||
|
||||
|
||||
r_sys_cmd ("sh");
|
||||
}
|
||||
|
||||
@ -636,7 +636,7 @@ static int cmd_print(void *data, const char *input) {
|
||||
}
|
||||
|
||||
if (input[0] && input[0]!='z' && input[1] == 'f') {
|
||||
RAnalFunction *f = r_anal_fcn_find (core->anal, core->offset,
|
||||
RAnalFunction *f = r_anal_get_fcn_in (core->anal, core->offset,
|
||||
R_ANAL_FCN_TYPE_FCN|R_ANAL_FCN_TYPE_SYM);
|
||||
if (f) {
|
||||
len = f->size;
|
||||
@ -709,7 +709,7 @@ static int cmd_print(void *data, const char *input) {
|
||||
switch (mode) {
|
||||
case 'j':
|
||||
r_cons_printf ("%s{",len?",":"");
|
||||
if ((as->block[p].flags)
|
||||
if ((as->block[p].flags)
|
||||
|| (as->block[p].functions)
|
||||
|| (as->block[p].comments)
|
||||
|| (as->block[p].imports)
|
||||
@ -734,7 +734,7 @@ static int cmd_print(void *data, const char *input) {
|
||||
total[3] += as->block[p].imports;
|
||||
total[4] += as->block[p].symbols;
|
||||
total[5] += as->block[p].strings;
|
||||
if ((as->block[p].flags)
|
||||
if ((as->block[p].flags)
|
||||
|| (as->block[p].functions)
|
||||
|| (as->block[p].comments)
|
||||
|| (as->block[p].imports)
|
||||
@ -799,7 +799,7 @@ static int cmd_print(void *data, const char *input) {
|
||||
switch (input[1]) {
|
||||
case '?':{ // bars
|
||||
const char* help_msg[] = {
|
||||
"Usage:", "p=[bep?] [num-of-blocks]", "show entropy/printable chars/chars bars",
|
||||
"Usage:", "p=[bep?] [num-of-blocks]", "show entropy/printable chars/chars bars",
|
||||
"p=", "", "print bytes of current block in bars",
|
||||
"p=", "b", "same as above",
|
||||
"p=", "e", "print entropy for each filesize/blocksize",
|
||||
@ -949,7 +949,7 @@ static int cmd_print(void *data, const char *input) {
|
||||
break;
|
||||
case 'f':
|
||||
{
|
||||
const RAnalFunction *f = r_anal_fcn_find (core->anal, core->offset,
|
||||
const RAnalFunction *f = r_anal_get_fcn_in (core->anal, core->offset,
|
||||
R_ANAL_FCN_TYPE_FCN|R_ANAL_FCN_TYPE_SYM);
|
||||
if (f) {
|
||||
r_core_print_disasm_instructions (core, f->size, l);
|
||||
@ -979,7 +979,7 @@ static int cmd_print(void *data, const char *input) {
|
||||
break;
|
||||
case 'f': //pif
|
||||
{
|
||||
RAnalFunction *f = r_anal_fcn_find (core->anal, core->offset,
|
||||
RAnalFunction *f = r_anal_get_fcn_in (core->anal, core->offset,
|
||||
R_ANAL_FCN_TYPE_FCN|R_ANAL_FCN_TYPE_SYM);
|
||||
if (f) {
|
||||
r_core_print_disasm_instructions (core, f->size, l);
|
||||
@ -1020,7 +1020,7 @@ static int cmd_print(void *data, const char *input) {
|
||||
// XXX - print help message
|
||||
//return R_FALSE;
|
||||
}
|
||||
if (!use_blocksize)
|
||||
if (!use_blocksize)
|
||||
use_blocksize = core->blocksize;
|
||||
|
||||
if (core->blocksize_max < use_blocksize && (int)use_blocksize < -core->blocksize_max) {
|
||||
@ -1081,7 +1081,7 @@ static int cmd_print(void *data, const char *input) {
|
||||
case 'r': // pdr
|
||||
processed_cmd = R_TRUE;
|
||||
{
|
||||
RAnalFunction *f = r_anal_fcn_find (core->anal, core->offset,
|
||||
RAnalFunction *f = r_anal_get_fcn_in (core->anal, core->offset,
|
||||
R_ANAL_FCN_TYPE_FCN|R_ANAL_FCN_TYPE_SYM);
|
||||
if (f) {
|
||||
RListIter *iter;
|
||||
@ -1134,7 +1134,7 @@ static int cmd_print(void *data, const char *input) {
|
||||
case 'f': //pdf
|
||||
processed_cmd = R_TRUE;
|
||||
{
|
||||
RAnalFunction *f = r_anal_fcn_find (core->anal, core->offset,
|
||||
RAnalFunction *f = r_anal_get_fcn_in (core->anal, core->offset,
|
||||
R_ANAL_FCN_TYPE_FCN|R_ANAL_FCN_TYPE_SYM);
|
||||
if (f && input[2] == 'j') {
|
||||
r_cons_printf ("{");
|
||||
@ -1167,7 +1167,7 @@ static int cmd_print(void *data, const char *input) {
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
r_core_cmdf (core, "pD %d @ 0x%08llx", f->size, f->addr);
|
||||
r_core_cmdf (core, "pD %d @ 0x%08llx", f->size, f->addr);
|
||||
pd_result = 0;
|
||||
#endif
|
||||
} else {
|
||||
@ -1278,11 +1278,11 @@ static int cmd_print(void *data, const char *input) {
|
||||
const char* help_msg[] = {
|
||||
"Usage:", "ps[zpw] [N]", "Print String",
|
||||
"ps", "", "print string",
|
||||
"psi", "", "print string inside curseek",
|
||||
"psb", "", "print strings in current block",
|
||||
"psx", "", "show string with scaped chars",
|
||||
"psz", "", "print zero terminated string",
|
||||
"psp", "", "print pascal string",
|
||||
"psi", "", "print string inside curseek",
|
||||
"psb", "", "print strings in current block",
|
||||
"psx", "", "show string with scaped chars",
|
||||
"psz", "", "print zero terminated string",
|
||||
"psp", "", "print pascal string",
|
||||
"psw", "", "print wide string",
|
||||
NULL};
|
||||
r_core_cmd_help (core, help_msg);
|
||||
@ -1719,7 +1719,7 @@ static int cmd_print(void *data, const char *input) {
|
||||
free (res);
|
||||
}
|
||||
} else {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -220,7 +220,7 @@ static int cmd_seek(void *data, const char *input) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
RAnalFunction *fcn = r_anal_fcn_find (core->anal, core->offset, 0);
|
||||
RAnalFunction *fcn = r_anal_get_fcn_in (core->anal, core->offset, 0);
|
||||
if (fcn) {
|
||||
r_core_seek (core, fcn->addr+fcn->size, 1);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ static int core_cmd_callback (void *user, const char *cmd) {
|
||||
}
|
||||
|
||||
static ut64 getref (RCore *core, int n, char t, int type) {
|
||||
RAnalFunction *fcn = r_anal_fcn_find (core->anal, core->offset, 0);
|
||||
RAnalFunction *fcn = r_anal_get_fcn_in (core->anal, core->offset, 0);
|
||||
RListIter *iter;
|
||||
RAnalRef *r;
|
||||
RList *list;
|
||||
@ -153,10 +153,10 @@ static ut64 num_callback(RNum *userptr, const char *str, int *ok) {
|
||||
case 'X': return getref (core, atoi (str+2), 'x',
|
||||
R_ANAL_REF_TYPE_CALL);
|
||||
case 'I':
|
||||
fcn = r_anal_fcn_find (core->anal, core->offset, 0);
|
||||
fcn = r_anal_get_fcn_in (core->anal, core->offset, 0);
|
||||
return fcn? fcn->ninstr: 0;
|
||||
case 'F':
|
||||
fcn = r_anal_fcn_find (core->anal, core->offset, 0);
|
||||
fcn = r_anal_get_fcn_in (core->anal, core->offset, 0);
|
||||
return fcn? fcn->size: 0;
|
||||
}
|
||||
} else
|
||||
@ -749,7 +749,7 @@ R_API RCore *r_core_free(RCore *c) {
|
||||
|
||||
R_API void r_core_prompt_loop(RCore *r) {
|
||||
int ret;
|
||||
do {
|
||||
do {
|
||||
if (r_core_prompt (r, R_FALSE)<1)
|
||||
break;
|
||||
// if (lock) r_th_lock_enter (lock);
|
||||
|
@ -415,7 +415,7 @@ static void handle_build_op_str (RCore *core, RDisasmState *ds) {
|
||||
ds->opstr = strdup (asm_str?asm_str:"");
|
||||
}
|
||||
if (ds->varsub) {
|
||||
RAnalFunction *f = r_anal_fcn_find (core->anal,
|
||||
RAnalFunction *f = r_anal_get_fcn_in (core->anal,
|
||||
ds->at, R_ANAL_FCN_TYPE_NULL);
|
||||
if (f) {
|
||||
r_parse_varsub (core->parser, f,
|
||||
@ -518,7 +518,7 @@ static char *filter_refline2(RCore *core, const char *str) {
|
||||
|
||||
static char *filter_refline(RCore *core, const char *str) {
|
||||
char *p = strdup (str);
|
||||
|
||||
|
||||
p = r_str_replace (p, "`",
|
||||
core->cons->vline[LINE_VERT], 1); // "`" -> "|"
|
||||
p = r_str_replace (p,
|
||||
@ -528,7 +528,7 @@ static char *filter_refline(RCore *core, const char *str) {
|
||||
core->cons->vline[LINE_VERT], 1); // "=" -> "|"
|
||||
p = r_str_replace (p, core->cons->vline[ARROW_RIGHT], " ", 0);
|
||||
p = r_str_replace (p, core->cons->vline[ARROW_LEFT], " ", 0);
|
||||
|
||||
|
||||
return p;
|
||||
}
|
||||
#if 0
|
||||
@ -562,7 +562,7 @@ static void beginline (RCore *core, RDisasmState *ds, RAnalFunction *f) {
|
||||
static void handle_show_xrefs (RCore *core, RDisasmState *ds) {
|
||||
// Show xrefs
|
||||
if (ds->show_xrefs) {
|
||||
RAnalFunction *f = r_anal_fcn_find (core->anal, ds->at, R_ANAL_FCN_TYPE_NULL);
|
||||
RAnalFunction *f = r_anal_get_fcn_in (core->anal, ds->at, R_ANAL_FCN_TYPE_NULL);
|
||||
RList *xrefs;
|
||||
RAnalRef *refi;
|
||||
RListIter *iter;
|
||||
@ -572,7 +572,7 @@ static void handle_show_xrefs (RCore *core, RDisasmState *ds) {
|
||||
xrefs = r_anal_xref_get (core->anal, ds->at);
|
||||
if (!xrefs)
|
||||
return;
|
||||
|
||||
|
||||
if (r_list_length (xrefs)> ds->maxrefs) {
|
||||
beginline (core, ds, f);
|
||||
r_cons_printf ("%s; XREFS: ", ds->pal_comment);
|
||||
@ -593,7 +593,7 @@ static void handle_show_xrefs (RCore *core, RDisasmState *ds) {
|
||||
}
|
||||
r_list_foreach (xrefs, iter, refi) {
|
||||
if (refi->at == ds->at) {
|
||||
RAnalFunction *fun = r_anal_fcn_find (
|
||||
RAnalFunction *fun = r_anal_get_fcn_in (
|
||||
core->anal, refi->addr,
|
||||
R_ANAL_FCN_TYPE_FCN |
|
||||
R_ANAL_FCN_TYPE_ROOT);
|
||||
@ -658,7 +658,7 @@ static void handle_print_show_cursor (RCore *core, RDisasmState *ds) {
|
||||
|
||||
static void handle_show_functions (RCore *core, RDisasmState *ds) {
|
||||
if (ds->show_functions) {
|
||||
RAnalFunction *f = r_anal_fcn_find (core->anal, ds->at, R_ANAL_FCN_TYPE_NULL);
|
||||
RAnalFunction *f = r_anal_get_fcn_in (core->anal, ds->at, R_ANAL_FCN_TYPE_NULL);
|
||||
if (f) {
|
||||
#warning TODO list from anal->sdb_fcns/fcn.0x%%x.v|a (vars/args)
|
||||
if (f->addr == ds->at) {
|
||||
@ -701,7 +701,7 @@ static void handle_show_functions (RCore *core, RDisasmState *ds) {
|
||||
r_cons_printf ("%s%s "Color_RESET,
|
||||
ds->color_fline, korner);
|
||||
} else {
|
||||
r_cons_printf (fmt, ds->pre,
|
||||
r_cons_printf (fmt, ds->pre,
|
||||
(f->type==R_ANAL_FCN_TYPE_FCN||f->type==R_ANAL_FCN_TYPE_SYM)?"fcn":
|
||||
(f->type==R_ANAL_FCN_TYPE_IMP)?"imp":"loc",
|
||||
f->name, f->size, korner);
|
||||
@ -745,7 +745,7 @@ static void handle_show_comments_right (RCore *core, RDisasmState *ds) {
|
||||
/* show comment at right? */
|
||||
ds->show_comment_right = 0;
|
||||
if (ds->show_comments) {
|
||||
RAnalFunction *f = r_anal_fcn_find (core->anal, ds->at, R_ANAL_FCN_TYPE_NULL);
|
||||
RAnalFunction *f = r_anal_get_fcn_in (core->anal, ds->at, R_ANAL_FCN_TYPE_NULL);
|
||||
RFlagItem *item = r_flag_get_i (core->flags, ds->at);
|
||||
ds->comment = r_meta_get_string (core->anal, R_META_TYPE_COMMENT, ds->at);
|
||||
if (!ds->comment && item && item->comment) {
|
||||
@ -815,7 +815,7 @@ static void handle_show_comments_right (RCore *core, RDisasmState *ds) {
|
||||
|
||||
static void handle_show_flags_option(RCore *core, RDisasmState *ds) {
|
||||
if (ds->show_flags) {
|
||||
RAnalFunction *f = r_anal_fcn_find (core->anal, ds->at, R_ANAL_FCN_TYPE_NULL);
|
||||
RAnalFunction *f = r_anal_get_fcn_in (core->anal, ds->at, R_ANAL_FCN_TYPE_NULL);
|
||||
RFlagItem *flag = r_flag_get_i (core->flags, ds->at);
|
||||
if (flag && (!f || (f && strcmp (f->name, flag->name)))) {
|
||||
if (ds->show_lines && ds->refline) {
|
||||
@ -1298,7 +1298,7 @@ static void handle_print_fcn_name (RCore * core, RDisasmState *ds) {
|
||||
case R_ANAL_OP_TYPE_JMP:
|
||||
//case R_ANAL_OP_TYPE_CJMP:
|
||||
case R_ANAL_OP_TYPE_CALL:
|
||||
f = r_anal_fcn_find (core->anal,
|
||||
f = r_anal_get_fcn_in (core->anal,
|
||||
ds->analop.jump, R_ANAL_FCN_TYPE_NULL);
|
||||
if (f && !strstr (ds->opstr, f->name)) {
|
||||
if (ds->show_color)
|
||||
@ -1342,7 +1342,7 @@ static void handle_print_cc_update (RCore *core, RDisasmState *ds) {
|
||||
static RAnalCC cc = {0};
|
||||
if (!r_anal_cc_update (core->anal, &cc, &ds->analop)) {
|
||||
if (ds->show_functions) {
|
||||
RAnalFunction *f = r_anal_fcn_find (core->anal, ds->at, R_ANAL_FCN_TYPE_NULL);
|
||||
RAnalFunction *f = r_anal_get_fcn_in (core->anal, ds->at, R_ANAL_FCN_TYPE_NULL);
|
||||
char tmp[128];
|
||||
char *ccstr = r_anal_cc_to_string (core->anal, &cc);
|
||||
tmp[0] = 0;
|
||||
@ -1459,7 +1459,7 @@ static void handle_print_ptr (RCore *core, RDisasmState *ds, int len, int idx) {
|
||||
// resolve local var if possible
|
||||
RAnalVar *v = r_anal_var_get (core->anal, ds->at, 'v', 1, (int)p);
|
||||
if (v) {
|
||||
r_cons_printf (" ; var %s", v->name);
|
||||
r_cons_printf (" ; var %s", v->name);
|
||||
r_anal_var_free (v);
|
||||
} else {
|
||||
r_cons_printf (" ; var %d", (int)-p);
|
||||
@ -1641,7 +1641,7 @@ toro:
|
||||
/* show type links */
|
||||
r_core_cmdf (core, "tf 0x%08"PFMT64x, ds->at);
|
||||
|
||||
f = r_anal_fcn_find (core->anal, ds->at, R_ANAL_FCN_TYPE_NULL);
|
||||
f = r_anal_get_fcn_in (core->anal, ds->at, R_ANAL_FCN_TYPE_NULL);
|
||||
if (!ds->hint || !ds->hint->bits) {
|
||||
if (f) {
|
||||
if (f->bits) {
|
||||
@ -1694,7 +1694,7 @@ toro:
|
||||
/* XXX: This is really cpu consuming.. need to be fixed */
|
||||
handle_show_functions (core, ds);
|
||||
{
|
||||
RAnalFunction *fcn = r_anal_get_fcn_at (core->anal, ds->addr);
|
||||
RAnalFunction *fcn = r_anal_get_fcn_at (core->anal, ds->addr, 0);
|
||||
if (handle_print_labels (core, ds, fcn)) {
|
||||
handle_show_functions (core, ds);
|
||||
}
|
||||
@ -1856,7 +1856,7 @@ R_API int r_core_print_disasm_instructions (RCore *core, int nb_bytes, int nb_op
|
||||
ds->hint = r_core_hint_begin (core, ds->hint, ds->at);
|
||||
r_asm_set_pc (core->assembler, ds->at);
|
||||
// XXX copypasta from main disassembler function
|
||||
f = r_anal_fcn_find (core->anal, ds->at, R_ANAL_FCN_TYPE_NULL);
|
||||
f = r_anal_get_fcn_in (core->anal, ds->at, R_ANAL_FCN_TYPE_NULL);
|
||||
if (!ds->hint || !ds->hint->bits) {
|
||||
if (f) {
|
||||
if (f->bits) {
|
||||
@ -2025,7 +2025,7 @@ R_API int r_core_print_disasm_json(RCore *core, ut64 addr, ut8 *buf, int nb_byte
|
||||
R_API int r_core_print_fcn_disasm(RPrint *p, RCore *core, ut64 addr, int l, int invbreak, int cbytes) {
|
||||
/* other */
|
||||
//void *old_user = core->anal->user;
|
||||
RAnalFunction *fcn = r_anal_fcn_find (core->anal, addr, R_ANAL_FCN_TYPE_NULL);
|
||||
RAnalFunction *fcn = r_anal_get_fcn_in (core->anal, addr, R_ANAL_FCN_TYPE_NULL);
|
||||
ut32 cur_buf_sz = fcn->size+1;
|
||||
ut8 *buf = malloc (cur_buf_sz);
|
||||
ut32 len = fcn->size;
|
||||
|
@ -351,7 +351,7 @@ static void r_core_graph_refresh (RCore *core) {
|
||||
r_cons_canvas_print (can);
|
||||
r_cons_flush ();
|
||||
}
|
||||
|
||||
|
||||
R_API int r_core_visual_graph(RCore *core, RAnalFunction *_fcn) {
|
||||
int key, cn, prevnode = curnode;
|
||||
int i, w, h;
|
||||
@ -360,7 +360,7 @@ R_API int r_core_visual_graph(RCore *core, RAnalFunction *_fcn) {
|
||||
edges = NULL;
|
||||
callgraph = 0;
|
||||
|
||||
fcn = _fcn? _fcn: r_anal_get_fcn_at (core->anal, core->offset);
|
||||
fcn = _fcn? _fcn: r_anal_get_fcn_at (core->anal, core->offset, 0);
|
||||
if (!fcn) {
|
||||
eprintf ("No function in current seek\n");
|
||||
return R_FALSE;
|
||||
|
@ -421,7 +421,7 @@ R_API int r_core_visual_xrefs_x (RCore *core) {
|
||||
r_cons_clear00 ();
|
||||
} else {
|
||||
r_list_foreach (xrefs, iter, refi) {
|
||||
fun = r_anal_fcn_find (core->anal, refi->addr, R_ANAL_FCN_TYPE_NULL);
|
||||
fun = r_anal_get_fcn_in (core->anal, refi->addr, R_ANAL_FCN_TYPE_NULL);
|
||||
r_cons_printf (" [%i] 0x%08"PFMT64x" %s XREF 0x%08"PFMT64x" (%s) \n", count,
|
||||
refi->at,
|
||||
refi->type==R_ANAL_REF_TYPE_CODE?"CODE (JMP)":
|
||||
@ -460,7 +460,7 @@ R_API int r_core_visual_xrefs_X (RCore *core) {
|
||||
RListIter *iter;
|
||||
RAnalFunction *fun;
|
||||
|
||||
fun = r_anal_fcn_find (core->anal, core->offset, R_ANAL_FCN_TYPE_NULL);
|
||||
fun = r_anal_get_fcn_in (core->anal, core->offset, R_ANAL_FCN_TYPE_NULL);
|
||||
if (fun) {
|
||||
r_cons_gotoxy (1, 1);
|
||||
r_cons_printf ("[GOTO REF]> \n");
|
||||
@ -870,7 +870,7 @@ R_API int r_core_visual_cmd(RCore *core, int ch) {
|
||||
case 'j':
|
||||
if (curset) {
|
||||
if (core->printidx == 1 || core->printidx == 2) { // these are dis modes
|
||||
// we read the size of the current mnemonic
|
||||
// we read the size of the current mnemonic
|
||||
cols = r_asm_disassemble (core->assembler,
|
||||
&op, core->block+cursor, 32);
|
||||
if (cols<1) cols = 1;
|
||||
@ -880,7 +880,7 @@ R_API int r_core_visual_cmd(RCore *core, int ch) {
|
||||
// we seek with the size of the first mnemo
|
||||
cols = r_asm_disassemble (core->assembler,
|
||||
&op, core->block, 32);
|
||||
r_core_seek (core, core->offset+cols, 1);
|
||||
r_core_seek (core, core->offset+cols, 1);
|
||||
cursor-=cols;
|
||||
}
|
||||
} else { // every other printmode
|
||||
|
@ -809,7 +809,7 @@ R_API void r_core_visual_mounts (RCore *core) {
|
||||
if (mode == 2) {
|
||||
if (!root) {
|
||||
mode = 0;
|
||||
} else
|
||||
} else
|
||||
if (strcmp (path, root)) {
|
||||
strcat (path, "/..");
|
||||
r_str_chop_path (path);
|
||||
@ -997,7 +997,7 @@ static ut64 r_core_visual_anal_refresh (RCore *core) {
|
||||
if (!core) return 0LL;
|
||||
old[0]='\0';
|
||||
addr = core->offset;
|
||||
fcn = r_anal_fcn_find (core->anal, addr, R_ANAL_FCN_TYPE_NULL);
|
||||
fcn = r_anal_get_fcn_in (core->anal, addr, R_ANAL_FCN_TYPE_NULL);
|
||||
|
||||
cols -= 50;
|
||||
if (cols > 60) cols = 60;
|
||||
@ -1371,9 +1371,9 @@ R_API void r_core_visual_define (RCore *core) {
|
||||
case 'e':
|
||||
// set function size
|
||||
{
|
||||
RAnalFunction *fcn = r_anal_fcn_find (core->anal, off, 0);
|
||||
RAnalFunction *fcn = r_anal_get_fcn_in (core->anal, off, 0);
|
||||
if (!fcn) {
|
||||
fcn = r_anal_fcn_find (core->anal, core->offset, 0);
|
||||
fcn = r_anal_get_fcn_in (core->anal, core->offset, 0);
|
||||
}
|
||||
if (fcn) {
|
||||
RAnalOp op;
|
||||
@ -1430,7 +1430,7 @@ R_API void r_core_visual_define (RCore *core) {
|
||||
r_core_anal_undefine (core, off);
|
||||
#if 0
|
||||
r_flag_unset_i (core->flags, off, NULL);
|
||||
f = r_anal_fcn_find (core->anal, off, 0);
|
||||
f = r_anal_get_fcn_in (core->anal, off, 0);
|
||||
r_anal_fcn_del_locs (core->anal, off);
|
||||
if (f) r_meta_del (core->anal, R_META_TYPE_ANY, off, f->size, "");
|
||||
r_anal_fcn_del (core->anal, off);
|
||||
@ -1438,8 +1438,8 @@ R_API void r_core_visual_define (RCore *core) {
|
||||
break;
|
||||
case 'f':
|
||||
{
|
||||
RAnalFunction *fcn = r_anal_get_fcn_at (core->anal, core->offset);
|
||||
if (fcn)
|
||||
RAnalFunction *fcn = r_anal_get_fcn_at (core->anal, core->offset, 0);
|
||||
if (fcn)
|
||||
r_anal_fcn_resize (fcn, core->offset - fcn->addr);
|
||||
}
|
||||
{
|
||||
@ -1456,7 +1456,7 @@ R_API void r_core_visual_define (RCore *core) {
|
||||
R_ANAL_REF_TYPE_NULL, depth);
|
||||
r_cons_break_end ();
|
||||
if (funsize) {
|
||||
RAnalFunction *f = r_anal_fcn_find (core->anal, off, -1);
|
||||
RAnalFunction *f = r_anal_get_fcn_in (core->anal, off, -1);
|
||||
if (f) f->size = funsize;
|
||||
}
|
||||
}
|
||||
|
@ -501,7 +501,7 @@ typedef struct r_anal_t {
|
||||
RList *plugins;
|
||||
Sdb *sdb_xrefs;
|
||||
Sdb *sdb_types;
|
||||
Sdb *sdb_meta; // TODO: Future r_meta api
|
||||
Sdb *sdb_meta; // TODO: Future r_meta api
|
||||
PrintfCallback printf;
|
||||
RBinBind binb; // Set only from core when an analysis plugin is called.
|
||||
//moved from RAnalFcn
|
||||
@ -829,37 +829,37 @@ typedef struct r_anal_plugin_t {
|
||||
// r_anal_ex_recursive_decent when using perform_analysis from
|
||||
// RAnalEx stuffs
|
||||
RAnalExAnalysisAlgorithm analysis_algorithm;
|
||||
// order in which these call backs are
|
||||
// order in which these call backs are
|
||||
// used with the recursive descent disassembler
|
||||
// analysis
|
||||
// 0) Before performing any analysis is start, opportunity to do any pre analysis.
|
||||
// 0) Before performing any analysis is start, opportunity to do any pre analysis.
|
||||
// in the current function
|
||||
RAnalExCallback pre_anal;
|
||||
// 1) Before any ops are bbs are created
|
||||
RAnalExCallback pre_anal_fn_cb;
|
||||
// 2) Just Before an op is created.
|
||||
// if current_op is set in state, then an op in the main alg wont be processed
|
||||
// 2) Just Before an op is created.
|
||||
// if current_op is set in state, then an op in the main alg wont be processed
|
||||
RAnalExCallback pre_anal_op_cb;
|
||||
// 3) After a op is created.
|
||||
// the current_op in state is used to fix-up the state of op before creating a bb
|
||||
// 3) After a op is created.
|
||||
// the current_op in state is used to fix-up the state of op before creating a bb
|
||||
RAnalExCallback post_anal_op_cb;
|
||||
// 4) Before a bb is created.
|
||||
// if current_op is set in state, then an op in the main alg wont be processed
|
||||
// 4) Before a bb is created.
|
||||
// if current_op is set in state, then an op in the main alg wont be processed
|
||||
RAnalExCallback pre_anal_bb_cb;
|
||||
// 5) After a bb is created.
|
||||
// the current_bb in state is used to fix-up the state of before performing analysis
|
||||
// with the current bb
|
||||
// 5) After a bb is created.
|
||||
// the current_bb in state is used to fix-up the state of before performing analysis
|
||||
// with the current bb
|
||||
RAnalExCallback post_anal_bb_cb;
|
||||
// 6) After processing is bb and cb is completed, opportunity to do any post analysis.
|
||||
// 6) After processing is bb and cb is completed, opportunity to do any post analysis.
|
||||
// in the current function
|
||||
RAnalExCallback post_anal_fn_cb;
|
||||
|
||||
// 6) After bb in a node is completed, opportunity to do any post analysis.
|
||||
// 6) After bb in a node is completed, opportunity to do any post analysis.
|
||||
// in the current function
|
||||
RAnalExCallback post_anal;
|
||||
|
||||
RAnalExCallback revisit_bb_anal;
|
||||
|
||||
|
||||
// command extension to directly call any analysis functions
|
||||
RAnalCmdExt cmd_ext;
|
||||
|
||||
@ -870,7 +870,7 @@ typedef struct r_anal_plugin_t {
|
||||
RAnalDiffFcnCallback diff_fcn;
|
||||
RAnalDiffEvalCallback diff_eval;
|
||||
struct list_head list;
|
||||
|
||||
|
||||
RAnalEsilCB esil_init;
|
||||
RAnalEsilLoopCB esil_post_loop; //cycle-counting, firing interrupts, ...
|
||||
RAnalEsilCB esil_fini;
|
||||
@ -921,7 +921,6 @@ R_API void r_anal_set_cpu(RAnal *anal, const char *cpu);
|
||||
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 RAnalFunction *r_anal_get_fcn_at(RAnal *anal, ut64 addr);
|
||||
R_API const char *r_anal_fcn_type_tostring(int type);
|
||||
|
||||
/* bb.c */
|
||||
@ -967,7 +966,8 @@ R_API void r_anal_esil_stats(RAnalEsil *esil, int enable);
|
||||
/* fcn.c */
|
||||
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 RAnalFunction *r_anal_get_fcn_at(RAnal *anal, ut64 addr, int type);
|
||||
R_API RAnalFunction *r_anal_get_fcn_in(RAnal *anal, ut64 addr, int type);
|
||||
R_API RAnalFunction *r_anal_fcn_find_name(RAnal *anal, const char *name);
|
||||
R_API RList *r_anal_fcn_list_new();
|
||||
R_API int r_anal_fcn_insert(RAnal *anal, RAnalFunction *fcn);
|
||||
@ -1115,7 +1115,7 @@ R_API RAnalRefline *r_anal_reflines_get(RAnal *anal,
|
||||
ut64 addr, const ut8 *buf, ut64 len, int nlines, int linesout, int linescall);
|
||||
R_API int r_anal_reflines_middle(RAnal *anal, RAnalRefline *list, ut64 addr, int len);
|
||||
R_API char* r_anal_reflines_str(void *core, ut64 addr, int opts);
|
||||
R_API RAnalRefline *r_anal_reflines_fcn_get( struct r_anal_t *anal, RAnalFunction *fcn,
|
||||
R_API RAnalRefline *r_anal_reflines_fcn_get( struct r_anal_t *anal, RAnalFunction *fcn,
|
||||
int nlines, int linesout, int linescall);
|
||||
/* TODO move to r_core */
|
||||
R_API void r_anal_var_list_show(RAnal *anal, RAnalFunction *fcn, ut64 addr);
|
||||
@ -1194,9 +1194,9 @@ R_API RAnalCaseOp* r_anal_switch_op_add_case(RAnalSwitchOp * swop, ut64 addr, ut
|
||||
R_API RAnalCycleFrame* r_anal_cycle_frame_new ();
|
||||
R_API void r_anal_cycle_frame_free (RAnalCycleFrame *cf);
|
||||
|
||||
/*
|
||||
/*
|
||||
* RAnalState maintains state during analysis.
|
||||
* there are standard values current_fcn, current_op, current_bb, addr,
|
||||
* there are standard values current_fcn, current_op, current_bb, addr,
|
||||
* data buffer, etc. but there is also a void * for user defined structures
|
||||
* that can be updated during the callbacks.
|
||||
*/
|
||||
|
@ -124,7 +124,7 @@ static int filter(RParse *p, RFlag *f, char *data, char *str, int len) {
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
fcn = r_anal_fcn_find (p->anal, off, 0);
|
||||
fcn = r_anal_get_fcn_in (p->anal, off, 0);
|
||||
if (fcn) {
|
||||
if (fcn->addr == off) {
|
||||
*ptr = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user