mirror of
https://github.com/radareorg/radare2.git
synced 2024-10-08 11:23:27 +00:00
changed VX that it does not need a function to work
This commit is contained in:
parent
5e70e0f8b6
commit
b1ef3edd18
@ -3274,8 +3274,8 @@ R_API int r_core_visual_graph(RCore *core, RAGraph *g, RAnalFunction *_fcn, int
|
|||||||
ut64 old_off = core->offset;
|
ut64 old_off = core->offset;
|
||||||
ut64 off = r_core_anal_get_bbaddr (core, core->offset);
|
ut64 off = r_core_anal_get_bbaddr (core, core->offset);
|
||||||
r_core_seek (core, off, 0);
|
r_core_seek (core, off, 0);
|
||||||
if ((key == 'x' && !r_core_visual_xrefs_x (core)) ||
|
if ((key == 'x' && !r_core_visual_refs (core, true)) ||
|
||||||
(key == 'X' && !r_core_visual_xrefs_X (core))) {
|
(key == 'X' && !r_core_visual_refs (core, false))) {
|
||||||
r_core_seek (core, old_off, 0);
|
r_core_seek (core, old_off, 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -769,7 +769,7 @@ static int prevopsz(RCore *core, ut64 addr) {
|
|||||||
return addr - prev_addr;
|
return addr - prev_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
R_API int r_core_visual_xrefs_x(RCore *core) {
|
R_API int r_core_visual_refs(RCore *core, bool xref) {
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
#if FCN_OLD
|
#if FCN_OLD
|
||||||
char ch;
|
char ch;
|
||||||
@ -787,14 +787,20 @@ R_API int r_core_visual_xrefs_x(RCore *core) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
repeat:
|
repeat:
|
||||||
if ((xrefs = r_anal_xref_get (core->anal, addr))) {
|
if (xref) {
|
||||||
|
xrefs = r_anal_xrefs_get (core->anal, addr);
|
||||||
|
} else {
|
||||||
|
xrefs = r_anal_refs_get (core->anal, addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xrefs) {
|
||||||
bool asm_bytes = r_config_get_i (core->config, "asm.bytes");
|
bool asm_bytes = r_config_get_i (core->config, "asm.bytes");
|
||||||
r_config_set_i (core->config, "asm.bytes", false);
|
r_config_set_i (core->config, "asm.bytes", false);
|
||||||
r_cons_clear00 ();
|
r_cons_clear00 ();
|
||||||
r_cons_gotoxy (1, 1);
|
r_cons_gotoxy (1, 1);
|
||||||
r_cons_printf ("[GOTO XREF]> 0x%08"PFMT64x "\n", addr);
|
r_cons_printf ("[GOTO %cREF]> 0x%08"PFMT64x "\n", xref ? 'X':' ', addr);
|
||||||
if (r_list_empty (xrefs)) {
|
if (r_list_empty (xrefs)) {
|
||||||
r_cons_printf ("No XREF found at 0x%"PFMT64x "\n", addr);
|
r_cons_printf ("No %cREF found at 0x%"PFMT64x "\n", xref ? 'X':' ', addr);
|
||||||
r_cons_any_key (NULL);
|
r_cons_any_key (NULL);
|
||||||
r_cons_clear00 ();
|
r_cons_clear00 ();
|
||||||
} else {
|
} else {
|
||||||
@ -832,10 +838,11 @@ repeat:
|
|||||||
name = strdup ("unk");
|
name = strdup ("unk");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
r_cons_printf (" %d [%s] 0x%08"PFMT64x " %s XREF (%s)\n",
|
r_cons_printf (" %d [%s] 0x%08"PFMT64x " %s %cREF (%s)\n",
|
||||||
idx, cstr, refi->addr,
|
idx, cstr, refi->addr,
|
||||||
refi->type == R_ANAL_REF_TYPE_CODE? "CODE (JMP)" :
|
refi->type == R_ANAL_REF_TYPE_CODE? "CODE (JMP)" :
|
||||||
refi->type == R_ANAL_REF_TYPE_CALL? "CODE (CALL)": "DATA",
|
refi->type == R_ANAL_REF_TYPE_CALL? "CODE (CALL)": "DATA",
|
||||||
|
xref ? 'X':' ',
|
||||||
name);
|
name);
|
||||||
free (name);
|
free (name);
|
||||||
if (idx == skip) {
|
if (idx == skip) {
|
||||||
@ -920,149 +927,6 @@ repeat:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
R_API int r_core_visual_xrefs_X(RCore *core) {
|
|
||||||
int ret = 0;
|
|
||||||
#if FCN_OLD
|
|
||||||
char ch;
|
|
||||||
int count = 0;
|
|
||||||
RAnalRef *refi;
|
|
||||||
RListIter *iter;
|
|
||||||
RAnalFunction *fun;
|
|
||||||
int skip = 0;
|
|
||||||
int idx = 0;
|
|
||||||
char cstr[32];
|
|
||||||
#define maxcount 9
|
|
||||||
ut64 references[maxcount];
|
|
||||||
ut64 addr = core->offset;
|
|
||||||
if (core->print->cur_enabled) {
|
|
||||||
addr += core->print->cur;
|
|
||||||
}
|
|
||||||
|
|
||||||
repeat:
|
|
||||||
fun = r_anal_get_fcn_in (core->anal, addr, R_ANAL_FCN_TYPE_NULL);
|
|
||||||
if (fun) {
|
|
||||||
bool asm_bytes = r_config_get_i (core->config, "asm.bytes");
|
|
||||||
(void) r_config_set_i (core->config, "asm.bytes", false);
|
|
||||||
r_cons_clear00 ();
|
|
||||||
r_cons_gotoxy (1, 1);
|
|
||||||
r_cons_printf ("[GOTO REF]> 0x%08"PFMT64x "\n", addr);
|
|
||||||
if (r_list_empty (fun->refs)) {
|
|
||||||
r_cons_printf ("No REF found at 0x%"PFMT64x "\n", addr);
|
|
||||||
r_cons_any_key (NULL);
|
|
||||||
r_cons_clear00 ();
|
|
||||||
} else {
|
|
||||||
int rows, cols = r_cons_get_size (&rows);
|
|
||||||
idx = 0;
|
|
||||||
count = 0;
|
|
||||||
char *dis = NULL;
|
|
||||||
rows -= 3;
|
|
||||||
idx = 0;
|
|
||||||
ut64 curat = UT64_MAX;
|
|
||||||
r_list_foreach (fun->refs, iter, refi) {
|
|
||||||
if (refi->at != addr) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (idx - skip > maxcount) {
|
|
||||||
r_cons_printf ("...");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!iter->n && idx < skip) {
|
|
||||||
skip = idx;
|
|
||||||
}
|
|
||||||
if (idx >= skip) {
|
|
||||||
if (count > maxcount) {
|
|
||||||
strcpy (cstr, "?");
|
|
||||||
} else {
|
|
||||||
snprintf (cstr, sizeof (cstr), "%d", count);
|
|
||||||
}
|
|
||||||
references[count] = refi->addr;
|
|
||||||
RFlagItem *f = r_flag_get_at (core->flags, refi->addr, true);
|
|
||||||
char* name;
|
|
||||||
if (f) {
|
|
||||||
name = r_str_newf ("%s + %d", f->name, refi->addr - f->offset);
|
|
||||||
} else {
|
|
||||||
name = strdup ("unk");
|
|
||||||
}
|
|
||||||
r_cons_printf (" %d [%s] 0x%08"PFMT64x " %s REF (%s)\n",
|
|
||||||
idx, cstr, refi->addr,
|
|
||||||
refi->type == R_ANAL_REF_TYPE_CODE? "CODE (JMP)" :
|
|
||||||
refi->type == R_ANAL_REF_TYPE_CALL? "CODE (CALL)": "DATA",
|
|
||||||
name);
|
|
||||||
free (name);
|
|
||||||
if (idx == skip) {
|
|
||||||
free (dis);
|
|
||||||
curat = refi->addr;
|
|
||||||
dis = r_core_cmd_strf (core, "pd $r-4 @ 0x%08"PFMT64x, refi->addr);
|
|
||||||
}
|
|
||||||
if (++count >= rows) {
|
|
||||||
r_cons_printf ("...");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
idx++;
|
|
||||||
}
|
|
||||||
if (dis) {
|
|
||||||
if (count < rows) {
|
|
||||||
r_cons_newline ();
|
|
||||||
}
|
|
||||||
int i = count;
|
|
||||||
for (; i < 10; i++) {
|
|
||||||
r_cons_newline ();
|
|
||||||
}
|
|
||||||
/* prepare highlight */
|
|
||||||
char *cmd = strdup (r_config_get (core->config, "scr.highlight"));
|
|
||||||
char *ats = r_str_newf ("%"PFMT64x, curat);
|
|
||||||
r_config_set (core->config, "scr.highlight", ats);
|
|
||||||
/* print disasm */
|
|
||||||
char *d = r_str_ansi_crop (dis, 0, 0, cols, rows - 9);
|
|
||||||
r_cons_printf ("%s", d);
|
|
||||||
free (d);
|
|
||||||
/* flush and restore highlight */
|
|
||||||
r_cons_flush ();
|
|
||||||
r_config_set (core->config, "scr.highlight", cmd);
|
|
||||||
free (ats);
|
|
||||||
free (cmd);
|
|
||||||
free (dis);
|
|
||||||
dis = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
(void) r_config_set_i (core->config, "asm.bytes", asm_bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!count) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
r_cons_flush ();
|
|
||||||
ch = r_cons_readchar ();
|
|
||||||
if (ch == ':') {
|
|
||||||
r_core_visual_prompt_input (core);
|
|
||||||
} else if (r_cons_arrow_to_hjkl (ch) == 'j') {
|
|
||||||
skip++;
|
|
||||||
if (skip >= count) {
|
|
||||||
skip = count - 1;
|
|
||||||
}
|
|
||||||
goto repeat;
|
|
||||||
} else if (r_cons_arrow_to_hjkl (ch) == 'k') {
|
|
||||||
skip--;
|
|
||||||
if (skip < 0) {
|
|
||||||
skip = 0;
|
|
||||||
}
|
|
||||||
goto repeat;
|
|
||||||
} else if (ch == ' ' || ch == '\n' || ch == '\r') {
|
|
||||||
ch = '0';
|
|
||||||
}
|
|
||||||
if (IS_DIGIT (ch) && (ch - 0x30) < count && (ch > 0x30)) {
|
|
||||||
r_io_sundo_push (core->io, core->offset, r_print_get_cursor (core->print));
|
|
||||||
r_core_seek (core, references[ch - 0x30], false);
|
|
||||||
ret = 1;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
eprintf ("TODO: sdbize xrefs here\n");
|
|
||||||
#endif
|
|
||||||
return ret;
|
|
||||||
#undef maxcount
|
|
||||||
}
|
|
||||||
|
|
||||||
#if __WINDOWS__ && !__CYGWIN__
|
#if __WINDOWS__ && !__CYGWIN__
|
||||||
void SetWindow(int Width, int Height) {
|
void SetWindow(int Width, int Height) {
|
||||||
COORD coord;
|
COORD coord;
|
||||||
@ -1909,10 +1773,10 @@ R_API int r_core_visual_cmd(RCore *core, const char *arg) {
|
|||||||
r_core_visual_trackflags (core);
|
r_core_visual_trackflags (core);
|
||||||
break;
|
break;
|
||||||
case 'x':
|
case 'x':
|
||||||
r_core_visual_xrefs_x (core);
|
r_core_visual_refs (core, true);
|
||||||
break;
|
break;
|
||||||
case 'X':
|
case 'X':
|
||||||
r_core_visual_xrefs_X (core);
|
r_core_visual_refs (core, false);
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
if (core->print->ocur != -1) {
|
if (core->print->ocur != -1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user