From b0141ba809bf80073d50e7154e14666b56831d59 Mon Sep 17 00:00:00 2001 From: radare Date: Sun, 31 Mar 2019 21:43:19 +0200 Subject: [PATCH] Improve pf visualization via Cf in pd ##disasm --- libr/core/disasm.c | 39 +++++++++++++++++++++++++-------------- libr/core/visual.c | 3 +++ 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/libr/core/disasm.c b/libr/core/disasm.c index 52b7ce75b9..12a2abe80e 100644 --- a/libr/core/disasm.c +++ b/libr/core/disasm.c @@ -311,7 +311,6 @@ static void ds_print_offset(RDisasmState *ds); static void ds_print_op_size(RDisasmState *ds); static void ds_print_trace(RDisasmState *ds); static void ds_adistrick_comments(RDisasmState *ds); -static int ds_print_meta_infos(RDisasmState *ds, ut8* buf, int len, int idx ); static void ds_print_opstr(RDisasmState *ds); static void ds_print_color_reset(RDisasmState *ds); static int ds_print_middle(RDisasmState *ds, int ret); @@ -2622,6 +2621,7 @@ static int ds_print_meta_infos(RDisasmState *ds, ut8* buf, int len, int idx) { int hexlen; int delta; if (mi) { + ret = mi->type; switch (mi->type) { case R_META_TYPE_STRING: { @@ -2683,17 +2683,17 @@ static int ds_print_meta_infos(RDisasmState *ds, ut8* buf, int len, int idx) { } core->inc = 16; // ds->oplen; // core->print->flags |= R_PRINT_FLAGS_HEADER; - ds->asmop.size = ret = (int)mi->size; //-delta; + ds->asmop.size = (int)mi->size; R_FREE (ds->line); R_FREE (ds->refline); R_FREE (ds->refline2); ds->mi_found = true; break; case R_META_TYPE_FORMAT: - r_cons_printf ("format %s {\n", mi->str); - r_print_format (core->print, ds->at, buf+idx, len-idx, mi->str, R_PRINT_MUSTSEE, NULL, NULL); - r_cons_printf ("} %d", mi->size); - ds->oplen = ds->asmop.size = ret = (int)mi->size; + r_cons_printf ("pf %s # size=%d\n", mi->str, mi->size); + r_print_format (core->print, ds->at, buf + idx, + len - idx, mi->str, R_PRINT_MUSTSEE, NULL, NULL); + ds->oplen = ds->asmop.size = (int)mi->size; R_FREE (ds->line); R_FREE (ds->refline); R_FREE (ds->refline2); @@ -5011,7 +5011,7 @@ toro: ds_print_cycles (ds); ds_print_family (ds); ds_print_stackptr (ds); - ret = ds_print_meta_infos (ds, buf, len, idx); + int miType = ds_print_meta_infos (ds, buf, len, idx); if (ds->mi_found) { ds_print_dwarf (ds); ret = ds_print_middle (ds, ret); @@ -5025,13 +5025,22 @@ toro: len - addrbytes * idx + 5); r_asm_set_syntax (core->assembler, os); } - if (ds->asm_hint_pos > 0) { - ds_print_core_vmode (ds, ds->asm_hint_pos); + if (miType == R_META_TYPE_FORMAT) { + if ((ds->show_comments || ds->show_usercomments) && ds->show_comment_right) { + // haveMeta = false; + } } - ds_end_line_highlight (ds); - if ((ds->show_comments || ds->show_usercomments) && ds->show_comment_right) { - ds_print_color_reset (ds); - ds_print_comments_right (ds); + if (miType != R_META_TYPE_FORMAT) { + if (ds->asm_hint_pos > 0) { + ds_print_core_vmode (ds, ds->asm_hint_pos); + } + } + { + ds_end_line_highlight (ds); + if ((ds->show_comments || ds->show_usercomments) && ds->show_comment_right) { + ds_print_color_reset (ds); + ds_print_comments_right (ds); + } } } else { ds->mi_found = false; @@ -5072,7 +5081,9 @@ toro: } } core->print->resetbg = true; - ds_newline (ds); + if (miType != R_META_TYPE_FORMAT) { + ds_newline (ds); + } if (ds->show_bbline && !ds->bblined && !ds->fcn) { switch (ds->analop.type) { case R_ANAL_OP_TYPE_MJMP: diff --git a/libr/core/visual.c b/libr/core/visual.c index ddc5c37299..9bb88d7779 100644 --- a/libr/core/visual.c +++ b/libr/core/visual.c @@ -588,6 +588,9 @@ repeat: " df -> define function\n" " du -> undefine function\n" " dc -> define as code\n" + " dw -> define as dword (32bit)\n" + " dw -> define as qword (64bit)\n" + " dd -> define current block or selected bytes as data\n" " V -> view graph (same as press the 'space' key)\n" ); ret = r_cons_less_str (r_strbuf_get (p), "?");