Improve aeg command and add aaef as an alias for aef@@@F ##anal

This commit is contained in:
pancake 2020-03-23 02:47:26 +01:00 committed by radare
parent 32580864ff
commit 32b39e89cb
2 changed files with 34 additions and 17 deletions

View File

@ -3374,19 +3374,18 @@ static bool check_changes(RAGraph *g, int is_interactive, RCore *core, RAnalFunc
} }
if (core) { if (core) {
ut64 off = r_anal_get_bbaddr (core->anal, core->offset); ut64 off = r_anal_get_bbaddr (core->anal, core->offset);
if (off == UT64_MAX) { if (off != UT64_MAX) {
return false; char *title = get_title (off);
} RANode *cur_anode = get_anode (g->curnode);
char *title = get_title (off); if (fcn && ((is_interactive && !cur_anode) || (cur_anode && strcmp (cur_anode->title, title)))) {
RANode *cur_anode = get_anode (g->curnode); g->update_seek_on = r_agraph_get_node (g, title);
if (fcn && ((is_interactive && !cur_anode) || (cur_anode && strcmp (cur_anode->title, title)))) { if (g->update_seek_on) {
g->update_seek_on = r_agraph_get_node (g, title); r_agraph_set_curnode (g, g->update_seek_on);
if (g->update_seek_on) { g->force_update_seek = true;
r_agraph_set_curnode (g, g->update_seek_on); }
g->force_update_seek = true;
} }
free (title);
} }
free (title);
g->can->color = r_config_get_i (core->config, "scr.color"); g->can->color = r_config_get_i (core->config, "scr.color");
g->hints = r_config_get_i (core->config, "graph.hints"); g->hints = r_config_get_i (core->config, "graph.hints");
} }
@ -4200,6 +4199,13 @@ R_API int r_core_visual_graph(RCore *core, RAGraph *g, RAnalFunction *_fcn, int
agraph_update_seek (g, get_anode (g->curnode), true); agraph_update_seek (g, get_anode (g->curnode), true);
// update scroll (with minor shift) // update scroll (with minor shift)
break; break;
// Those hardcoded keys are useful only for aegi, should add subcommand of ag to set key actions
case '1':
r_core_cmd0 (core, "so;.aeg*");
break;
case '2':
r_core_cmd0 (core, "so-1;.aeg*");
break;
case '=': case '=':
{ // TODO: edit { // TODO: edit
showcursor (core, true); showcursor (core, true);

View File

@ -5951,17 +5951,21 @@ static void cmd_anal_esil(RCore *core, const char *input) {
r_anal_esil_interrupt_free (esil, interrupt); r_anal_esil_interrupt_free (esil, interrupt);
} }
break; break;
// TODO: display help?
} }
} }
break; break;
case 'g': // "aeg" case 'g': // "aeg"
if (input[1] == 'v') { if (input[1] == 'i' || input[1] == 'v') {
r_core_cmd0 (core, ".aeg;agg"); char *oprompt = strdup (r_config_get (core->config, "cmd.gprompt"));
r_config_set (core->config, "cmd.gprompt", "pi 1");
r_core_cmd0 (core, ".aeg*;aggv");
r_config_set (core->config, "cmd.gprompt", oprompt);
free (oprompt);
} else if (!input[1]) {
r_core_cmd0 (core, ".aeg*;agg");
} else if (input[1] == ' ') { } else if (input[1] == ' ') {
r_core_anal_esil_graph (core, input + 2); r_core_anal_esil_graph (core, input + 2);
} else { // "*" } else if (input[1] == '*') {
RAnalOp *aop = r_core_anal_op (core, core->offset, R_ANAL_OP_MASK_ESIL); RAnalOp *aop = r_core_anal_op (core, core->offset, R_ANAL_OP_MASK_ESIL);
if (aop) { if (aop) {
const char *esilstr = r_strbuf_get (&aop->esil); const char *esilstr = r_strbuf_get (&aop->esil);
@ -5969,6 +5973,11 @@ static void cmd_anal_esil(RCore *core, const char *input) {
r_core_anal_esil_graph (core, esilstr); r_core_anal_esil_graph (core, esilstr);
} }
} }
} else {
r_cons_printf ("Usage: aeg[iv*]\n");
r_cons_printf (" aeg analyze current instruction as an esil graph\n");
r_cons_printf (" aeg* analyze current instruction as an esil graph\n");
r_cons_printf (" aegv and launch the visual interactive mode (.aeg*;aggv == aegv)\n");
} }
break; break;
case 'b': // "aeb" case 'b': // "aeb"
@ -9200,7 +9209,9 @@ static int cmd_anal_all(RCore *core, const char *input) {
cmd_anal_objc (core, input + 1, false); cmd_anal_objc (core, input + 1, false);
break; break;
case 'e': // "aae" case 'e': // "aae"
if (input[1]) { if (input[1] == 'f') { // "aaef
r_core_cmd0 (core, "aef@@@F");
} else if (input[1] == ' ') {
const char *len = (char *)input + 1; const char *len = (char *)input + 1;
char *addr = strchr (input + 2, ' '); char *addr = strchr (input + 2, ' ');
if (addr) { if (addr) {