Allow af and df to resize+ redefine new function (anal testing)

This commit is contained in:
pancake 2014-09-22 15:00:41 +02:00
parent 8863e9917e
commit b0b16a7318
6 changed files with 40 additions and 7 deletions

View File

@ -6,7 +6,7 @@
#define FCN_DEPTH 32
#define JMP_IS_EOB 0
#define JMP_IS_EOB 1
#define JMP_IS_EOB_RANGE 512
#define CALL_IS_EOB 0
@ -459,8 +459,8 @@ R_API int r_anal_fcn(RAnal *anal, RAnalFunction *fcn, ut64 addr, ut8 *buf, ut64
fcn->type = (reftype==R_ANAL_REF_TYPE_CODE)?
R_ANAL_FCN_TYPE_LOC: R_ANAL_FCN_TYPE_FCN;
if (fcn->addr == UT64_MAX) fcn->addr = addr;
if (anal->cur && anal->cur->fcn){
int result = anal->cur->fcn(anal, fcn, addr, buf, len, reftype);
if (anal->cur && anal->cur->fcn) {
int result = anal->cur->fcn (anal, fcn, addr, buf, len, reftype);
if (anal->cur->custom_fn_anal) return result;
}
return fcn_recurse (anal, fcn, addr, buf, len, FCN_DEPTH);

View File

@ -1733,3 +1733,12 @@ R_API RList* r_core_anal_cycles (RCore *core, int ccl)
}
return hooks;
};
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);
if (f) r_meta_del (core->anal, R_META_TYPE_ANY, off, f->size, "");
r_anal_fcn_del (core->anal, off);
}

View File

@ -666,9 +666,19 @@ static int cmd_anal_fcn(RCore *core, const char *input) {
}
break;
default:
r_core_anal_fcn (core, core->offset, UT64_MAX,
{
// first undefine
//r_core_anal_undefine (core, core->offset);
/* resize function if overlaps */
{
RAnalFunction *fcn = r_anal_get_fcn_at (core->anal, core->offset);
if (fcn)
r_anal_fcn_resize (fcn, core->offset - fcn->addr);
}
r_core_anal_fcn (core, core->offset, UT64_MAX,
R_ANAL_REF_TYPE_NULL,
r_config_get_i (core->config, "anal.depth"));
r_config_get_i (core->config, "anal.depth"));
}
}
return R_TRUE;
}
@ -1227,8 +1237,9 @@ if (ret) {
r_core_anal_fcn (core, core->offset, UT64_MAX, R_ANAL_REF_TYPE_NULL, 1);
break;
case 'f':
if (!cmd_anal_fcn (core, input))
if (!cmd_anal_fcn (core, input)) {
return R_FALSE;
}
break;
case 'g':
switch (input[1]) {

View File

@ -924,7 +924,11 @@ R_API int r_core_config_init(RCore *core) {
#endif
r_config_desc (cfg, "scr.fgets", "Use fgets instead of dietline for prompt input");
SETPREF("scr.colorops", "true", "Colorize in numbers/registers in opcodes");
SETPREF("scr.responsive", "true", "Auto-adjust asm. and hex. depending on screen size");
#if __ANDROID__
SETPREF("scr.responsive", "true", "Auto-adjust Visual depending on screen (disable asm.bytes and other)");
#else
SETPREF("scr.responsive", "false", "Auto-adjust Visual depending on screen (disable asm.bytes and other)");
#endif
SETPREF("scr.wheel", "true", "Enable the use of mouse wheel in visual mode");
SETI("scr.colpos", 80, "Column position of cmd.cprompt in visual");
SETICB("scr.columns", 0, &cb_scrcolumns, "Set the columns number");

View File

@ -1428,13 +1428,21 @@ R_API void r_core_visual_define (RCore *core) {
r_meta_add (core->anal, R_META_TYPE_CODE, off, off+plen, "");
break;
case 'u':
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);
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);
#endif
break;
case 'f':
{
RAnalFunction *fcn = r_anal_get_fcn_at (core->anal, core->offset);
if (fcn)
r_anal_fcn_resize (fcn, core->offset - fcn->addr);
}
{
int funsize = 0;
int depth = r_config_get_i (core->config, "anal.depth");

View File

@ -281,6 +281,7 @@ R_API char *r_core_disassemble_bytes(RCore *core, ut64 addr, int b);
/* anal.c */
R_API RAnalOp* r_core_anal_op(RCore *core, ut64 addr);
R_API void r_core_anal_undefine (RCore *core, ut64 off);
R_API void r_core_anal_hint_list (RAnal *a, int mode);
R_API int r_core_anal_search(RCore *core, ut64 from, ut64 to, ut64 ref);
R_API int r_core_anal_data (RCore *core, ut64 addr, int count, int depth);