mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-24 05:40:10 +00:00
Support relative pointer resolution in pxr
##print
This commit is contained in:
parent
374b86e866
commit
80bde99c7f
@ -1932,8 +1932,10 @@ R_API void r_core_debug_ri(RCore *core, RReg *reg, int mode) {
|
||||
r_cons_printf (" %s", r);
|
||||
}
|
||||
r_cons_strcat (Color_RESET);
|
||||
ut64 o_offset = core->offset;
|
||||
char *rrstr = r_core_anal_hasrefs (core, *addr, true);
|
||||
if (rrstr && *rrstr && strchr (rrstr, 'R')) {
|
||||
core->offset = o_offset;
|
||||
if (R_STR_ISNOTEMPTY (rrstr) && strchr (rrstr, 'R')) {
|
||||
r_cons_printf (" ;%s"Color_RESET, rrstr);
|
||||
}
|
||||
r_cons_newline ();
|
||||
@ -2005,7 +2007,10 @@ R_API void r_core_debug_rr(RCore *core, RReg *reg, int mode) {
|
||||
valuestr = r_str_newf ("%"PFMT64x, value);
|
||||
}
|
||||
|
||||
r_cons_strcat (Color_RESET);
|
||||
ut64 o_offset = core->offset;
|
||||
char *rrstr = r_core_anal_hasrefs (core, value, true);
|
||||
core->offset = o_offset;
|
||||
if (!rrstr) {
|
||||
rrstr = strdup ("");
|
||||
}
|
||||
|
@ -4869,6 +4869,7 @@ static void cmd_pxr(RCore *core, int len, int mode, int wordsize, const char *ar
|
||||
return;
|
||||
}
|
||||
}
|
||||
ut64 o_offset = core->offset;
|
||||
if (mode == 'j' || mode == ',' || mode == '*' || mode == 'q') {
|
||||
size_t i;
|
||||
const int be = core->anal->big_endian;
|
||||
@ -4879,6 +4880,7 @@ static void cmd_pxr(RCore *core, int len, int mode, int wordsize, const char *ar
|
||||
|
||||
bool withref = false;
|
||||
int end = R_MIN (core->blocksize, len);
|
||||
ut64 at = core->offset;
|
||||
for (i = 0; i + wordsize < end; i += wordsize) {
|
||||
ut64 addr = core->offset + i;
|
||||
ut64 val = read_value (buf + i, wordsize, be);
|
||||
@ -4891,6 +4893,7 @@ static void cmd_pxr(RCore *core, int len, int mode, int wordsize, const char *ar
|
||||
// XXX: this only works in little endian
|
||||
withref = false;
|
||||
char *refs = NULL;
|
||||
core->offset = at + i;
|
||||
if (core->print->hasrefs) {
|
||||
char *rstr = core->print->hasrefs (core->print->user, val, true);
|
||||
if (R_STR_ISNOTEMPTY (rstr)) {
|
||||
@ -4922,6 +4925,7 @@ static void cmd_pxr(RCore *core, int len, int mode, int wordsize, const char *ar
|
||||
pj_end (pj);
|
||||
}
|
||||
}
|
||||
core->offset = at;
|
||||
if (t) {
|
||||
r_table_query (t, arg? arg + 1: NULL);
|
||||
char *s = r_table_tostring (t);
|
||||
@ -4951,6 +4955,7 @@ static void cmd_pxr(RCore *core, int len, int mode, int wordsize, const char *ar
|
||||
core->print->flags &= ~R_PRINT_FLAGS_REFS;
|
||||
core->print->cols = ocols;
|
||||
}
|
||||
core->offset = o_offset;
|
||||
}
|
||||
|
||||
static ut8 *decode_text(RCore *core, ut64 offset, size_t len, bool zeroend) {
|
||||
|
@ -2331,7 +2331,15 @@ R_API char *r_core_anal_hasrefs_to_depth(RCore *core, ut64 value, PJ *pj, int de
|
||||
}
|
||||
ut64 type = r_core_anal_address (core, value);
|
||||
RBinSection *sect = value? r_bin_get_section_at (r_bin_cur_object (core->bin), value, true): NULL;
|
||||
if(! ((type & R_ANAL_ADDR_TYPE_HEAP) || (type & R_ANAL_ADDR_TYPE_STACK)) ) {
|
||||
|
||||
if (value && (int)value < 0 && (int)value > -0xffff) {
|
||||
ut64 dst = core->offset + (st32)value;
|
||||
if (r_io_is_valid_offset (core->io, dst, false)) {
|
||||
r_strbuf_appendf (s, " rptr(%d)=0x%08"PFMT64x" ", (int)value, dst);
|
||||
value = dst;
|
||||
}
|
||||
}
|
||||
if (! ((type & R_ANAL_ADDR_TYPE_HEAP) || (type & R_ANAL_ADDR_TYPE_STACK)) ) {
|
||||
// Do not repeat "stack" or "heap" words unnecessarily.
|
||||
if (sect && sect->name[0]) {
|
||||
if (pj) {
|
||||
@ -2770,7 +2778,13 @@ static const char *colorfor_cb(void *user, ut64 addr, ut8 ch, bool verbose) {
|
||||
}
|
||||
|
||||
static char *hasrefs_cb(void *user, ut64 addr, int mode) {
|
||||
return r_core_anal_hasrefs ((RCore *)user, addr, mode);
|
||||
RCore *core = (RCore *)user;
|
||||
if (mode) {
|
||||
return r_core_anal_hasrefs ((RCore *)user, addr, mode);
|
||||
}
|
||||
core->offset = addr;
|
||||
char *res = r_core_anal_hasrefs ((RCore *)user, addr, mode);
|
||||
return res;
|
||||
}
|
||||
|
||||
static const char *get_section_name(void *user, ut64 addr) {
|
||||
|
Loading…
Reference in New Issue
Block a user