diff --git a/libr/core/cmd.c b/libr/core/cmd.c index 5c54f27d03..731a866f87 100644 --- a/libr/core/cmd.c +++ b/libr/core/cmd.c @@ -1,4 +1,4 @@ -/* radare - LGPL - Copyright 2009-2016 - nibble, pancake */ +/* radare - LGPL - Copyright 2009-2017 - nibble, pancake */ #if 0 * Use RList * Support callback for null command (why?) diff --git a/libr/core/cmd_debug.c b/libr/core/cmd_debug.c index 3ddb92d3bf..8cb0fd7b9d 100644 --- a/libr/core/cmd_debug.c +++ b/libr/core/cmd_debug.c @@ -1214,7 +1214,7 @@ R_API void r_core_debug_rr(RCore *core, RReg *reg) { continue; } value = r_reg_get_value (core->dbg->reg, r); - rrstr = r_core_anal_hasrefs (core, value); + rrstr = r_core_anal_hasrefs (core, value, true); if (bits == 64) { if (r->flags) { tmp = r_reg_get_bvalue (reg, r); diff --git a/libr/core/cmd_help.c b/libr/core/cmd_help.c index 8eb880ce81..29552117e3 100644 --- a/libr/core/cmd_help.c +++ b/libr/core/cmd_help.c @@ -707,7 +707,7 @@ static int cmd_help(void *data, const char *input) { case 'w': { ut64 addr = r_num_math (core->num, input + 1); - const char *rstr = core->print->hasrefs (core->print->user, addr); + const char *rstr = core->print->hasrefs (core->print->user, addr, true); r_cons_println (rstr); } break; diff --git a/libr/core/cmd_print.c b/libr/core/cmd_print.c index 0852d87823..095e84e503 100644 --- a/libr/core/cmd_print.c +++ b/libr/core/cmd_print.c @@ -3839,7 +3839,7 @@ static int cmd_print(void *data, const char *input) { RFlagItem *f; ut32 v = r_read_ble32 (core->block + i, core->print->big_endian); if (p && p->colorfor) { - a = p->colorfor (p->user, v); + a = p->colorfor (p->user, v, true); if (a && *a) { b = Color_RESET; } else { @@ -3886,7 +3886,7 @@ static int cmd_print(void *data, const char *input) { // XXX: this only works in little endian withref = 0; if (core->print->hasrefs) { - const char *rstr = core->print->hasrefs (core->print->user, val); + const char *rstr = core->print->hasrefs (core->print->user, val, true); if (rstr && *rstr) { char *ns; //r_str_ansi_chop (ns, -1, 0); ns = r_str_escape (rstr); @@ -3933,7 +3933,7 @@ static int cmd_print(void *data, const char *input) { RFlagItem *f; ut64 v = (ut64)r_read_ble16 (core->block + i, p->big_endian); if (p && p->colorfor) { - a = p->colorfor (p->user, v); + a = p->colorfor (p->user, v, true); if (a && *a) { b = Color_RESET; } else { @@ -3976,7 +3976,7 @@ static int cmd_print(void *data, const char *input) { RFlagItem *f; ut64 v = r_read_ble64 (core->block + i, p->big_endian); if (p && p->colorfor) { - a = p->colorfor (p->user, v); + a = p->colorfor (p->user, v, true); if (a && *a) { b = Color_RESET; } else { diff --git a/libr/core/core.c b/libr/core/core.c index 20978a1406..12ec2d53fa 100644 --- a/libr/core/core.c +++ b/libr/core/core.c @@ -1274,8 +1274,15 @@ static int is_string (const ut8 *buf, int size, int *len) { } static char *r_core_anal_hasrefs_to_depth(RCore *core, ut64 value, int depth); -R_API char *r_core_anal_hasrefs(RCore *core, ut64 value) { - return r_core_anal_hasrefs_to_depth(core, value, r_config_get_i(core->config, "hex.depth")); +R_API char *r_core_anal_hasrefs(RCore *core, ut64 value, bool verbose) { + if (verbose) { + return r_core_anal_hasrefs_to_depth(core, value, r_config_get_i (core->config, "hex.depth")); + } + RFlagItem *fi = r_flag_get_i (core->flags, value); + if (fi) { + return strdup (fi->name); + } + return NULL; } static char *r_core_anal_hasrefs_to_depth(RCore *core, ut64 value, int depth) { @@ -1284,8 +1291,7 @@ static char *r_core_anal_hasrefs_to_depth(RCore *core, ut64 value, int depth) { RIOSection *sect; char *mapname; RAnalFunction *fcn; - RFlagItem *fi; - fi = r_flag_get_i (core->flags, value); + RFlagItem *fi = r_flag_get_i (core->flags, value); type = r_core_anal_address (core, value); fcn = r_anal_get_fcn_in (core->anal, value, 0); if (value && value != UT64_MAX) { @@ -1312,7 +1318,7 @@ static char *r_core_anal_hasrefs_to_depth(RCore *core, ut64 value, int depth) { if (fi) r_strbuf_appendf (s, " %s", fi->name); if (fcn) r_strbuf_appendf (s, " %s", fcn->name); if (type) { - const char *c = r_core_anal_optype_colorfor (core, value); + const char *c = r_core_anal_optype_colorfor (core, value, true); const char *cend = (c && *c) ? Color_RESET: ""; if (!c) c = ""; if (type & R_ANAL_ADDR_TYPE_HEAP) { @@ -1408,10 +1414,11 @@ static char *r_core_anal_hasrefs_to_depth(RCore *core, ut64 value, int depth) { return r_strbuf_drain (s); } -R_API const char *r_core_anal_optype_colorfor(RCore *core, ut64 addr) { +R_API const char *r_core_anal_optype_colorfor(RCore *core, ut64 addr, bool verbose) { ut64 type; - if (!(core->print->flags & R_PRINT_FLAGS_COLOR)) + if (!(core->print->flags & R_PRINT_FLAGS_COLOR)) { return NULL; + } type = r_core_anal_address (core, addr); if (type & R_ANAL_ADDR_TYPE_EXEC) return core->cons->pal.ai_exec; //Color_RED; diff --git a/libr/include/r_core.h b/libr/include/r_core.h index 98374fa936..916e3ebf9b 100644 --- a/libr/include/r_core.h +++ b/libr/include/r_core.h @@ -338,7 +338,7 @@ R_API int r_core_process_input_pade(RCore *core, const char *input, char** hex, R_API RAnalOp* r_core_anal_op(RCore *core, ut64 addr); R_API void r_core_anal_esil (RCore *core, const char *str, const char *addr); R_API void r_core_anal_fcn_merge (RCore *core, ut64 addr, ut64 addr2); -R_API const char *r_core_anal_optype_colorfor(RCore *core, ut64 addr); +R_API const char *r_core_anal_optype_colorfor(RCore *core, ut64 addr, bool verbose); R_API ut64 r_core_anal_address (RCore *core, ut64 addr); R_API void r_core_anal_undefine (RCore *core, ut64 off); R_API void r_core_anal_hint_print (RAnal* a, ut64 addr, int mode); @@ -556,7 +556,7 @@ typedef struct { RCoreAnalStatsItem *block; } RCoreAnalStats; -R_API char *r_core_anal_hasrefs(RCore *core, ut64 value); +R_API char *r_core_anal_hasrefs(RCore *core, ut64 value, bool verbose); R_API RCoreAnalStats* r_core_anal_get_stats (RCore *a, ut64 from, ut64 to, ut64 step); R_API void r_core_anal_stats_free (RCoreAnalStats *s); R_API void r_core_anal_list_vtables(void *core, bool printJson); diff --git a/libr/include/r_print.h b/libr/include/r_print.h index 2ef0ed813c..006fd57472 100644 --- a/libr/include/r_print.h +++ b/libr/include/r_print.h @@ -24,7 +24,7 @@ extern "C" { typedef int (*RPrintZoomCallback)(void *user, int mode, ut64 addr, ut8 *bufz, ut64 size); typedef const char *(*RPrintNameCallback)(void *user, ut64 addr); -typedef const char *(*RPrintColorFor)(void *user, ut64 addr); +typedef const char *(*RPrintColorFor)(void *user, ut64 addr, bool verbose); typedef struct r_print_zoom_t { ut8 *buf; diff --git a/libr/util/print.c b/libr/util/print.c index d0594c8492..769eaacda6 100644 --- a/libr/util/print.c +++ b/libr/util/print.c @@ -855,7 +855,7 @@ R_API void r_print_hexdump(RPrint *p, ut64 addr, const ut8 *buf, int len, int ba r_print_cursor (p, j, 1); // stub for colors if (p && p->colorfor) { - a = p->colorfor (p->user, n); + a = p->colorfor (p->user, n, true); if (a && *a) { b = Color_RESET; } else { a = b = ""; } } else { a = b = ""; @@ -910,14 +910,19 @@ R_API void r_print_hexdump(RPrint *p, ut64 addr, const ut8 *buf, int len, int ba if (col == 2) printfmt("|"); if (p && p->flags & R_PRINT_FLAGS_REFS) { ut64 *foo = (ut64*)(buf + i); - ut64 addr = *foo; + ut64 off = *foo; if (base == 32) { - addr &= UT32_MAX; + off &= UT32_MAX; } if (p->hasrefs) { - const char *rstr = p->hasrefs (p->user, addr); - if (rstr && *rstr) + const char *rstr = p->hasrefs (p->user, addr + i, false); + if (rstr && *rstr) { + printfmt (" @%s", rstr); + } + rstr = p->hasrefs (p->user, off, true); + if (rstr && *rstr) { printfmt ("%s", rstr); + } } } printfmt ("\n");