From 0248e53fb66e71c3f5188404f6389b0719113fd4 Mon Sep 17 00:00:00 2001 From: pancake Date: Sun, 28 Sep 2014 03:27:22 +0200 Subject: [PATCH] Add scr.visual, Fix BinBios section loading (rva issue) --- libr/bin/p/bin_bios.c | 3 ++- libr/core/bin.c | 3 +++ libr/core/cmd_anal.c | 5 ++++- libr/core/config.c | 1 + libr/core/visual.c | 16 ++++++++++++++++ libr/core/vmenus.c | 2 +- 6 files changed, 27 insertions(+), 3 deletions(-) diff --git a/libr/bin/p/bin_bios.c b/libr/bin/p/bin_bios.c index 5e1453524a..74d35ff925 100644 --- a/libr/bin/p/bin_bios.c +++ b/libr/bin/p/bin_bios.c @@ -105,7 +105,8 @@ static RList* entries(RBinFile *arch) { ret->free = free; if (!(ptr = R_NEW0 (RBinAddr))) return ret; - ptr->paddr = ptr->vaddr = 0xffff0; + ptr->paddr = 0x70000; + ptr->vaddr = 0xffff0; r_list_append (ret, ptr); return ret; } diff --git a/libr/core/bin.c b/libr/core/bin.c index fdcf90a51a..90e3ed5504 100644 --- a/libr/core/bin.c +++ b/libr/core/bin.c @@ -25,6 +25,8 @@ static ut64 rva (RBin *bin, int va, ut64 paddr, ut64 vaddr, ut64 baddr, ut64 lad case 1: // va $ rabin2 return r_bin_get_vaddr (bin, baddr, paddr, vaddr); case 2: // la $ rabin2 -B + if (!baddr && !laddr) + return vaddr; return paddr + laddr; } return vaddr; @@ -1013,6 +1015,7 @@ static int bin_sections (RCore *r, int mode, ut64 baddr, ut64 laddr, int va, ut6 r_list_foreach (sections, iter, section) { ut64 addr = rva (r->bin, va, section->paddr, section->vaddr, baddr, laddr); + addr = section->vaddr; // this line fixes rbin_bios if (name && strcmp (section->name, name)) continue; r_name_filter (section->name, sizeof (section->name)); diff --git a/libr/core/cmd_anal.c b/libr/core/cmd_anal.c index 4cfa61c235..c7c6962f86 100644 --- a/libr/core/cmd_anal.c +++ b/libr/core/cmd_anal.c @@ -972,8 +972,11 @@ static void esil_step(RCore *core, ut64 until_addr, const char *until_expr) { r_anal_esil_stack_free (esil); } ut64 newaddr = r_reg_getv (core->anal->reg, name); - if (addr == newaddr) + if (addr == newaddr) { + if (op.size<1) + op.size = 1; // avoid inverted stepping r_reg_setv (core->anal->reg, name, addr + op.size); + } // check addr if (until_addr != UT64_MAX) { if (addr == until_addr) { diff --git a/libr/core/config.c b/libr/core/config.c index 2762ca26e1..c2921ce8d2 100644 --- a/libr/core/config.c +++ b/libr/core/config.c @@ -969,6 +969,7 @@ R_API int r_core_config_init(RCore *core) { SETICB("scr.fix_columns", 0, &cb_fixcolumns, "Workaround for Prompt iOS ssh client"); SETCB("scr.highlight", "", &cb_scrhighlight, "Highligh that word at RCons level"); SETCB("scr.interactive", "true", &cb_scrint, "Start in interractive mode"); + SETI("scr.feedback", 1, "Set visual feedback level (1=arrow on jump, 2=every key (useful for videos))"); SETCB("scr.html", "false", &cb_scrhtml, "If enabled disassembly uses HTML syntax"); SETCB("scr.nkey", "hit", &cb_scrnkey, "Select the seek mode in visual"); SETCB("scr.pager", "", &cb_pager, "Select pager program (used if output doesn't fit on window)"); diff --git a/libr/core/visual.c b/libr/core/visual.c index 49a4df5a69..f023cfdaf9 100644 --- a/libr/core/visual.c +++ b/libr/core/visual.c @@ -319,7 +319,22 @@ static void visual_search (RCore *core) { } } +R_API void r_core_visual_show_char (RCore *core, char ch) { + if (r_config_get_i (core->config, "scr.feedback")<2) + return; + if (!IS_PRINTABLE(ch)) + return; + r_cons_gotoxy (1, 2); + r_cons_printf (".---.\n"); + r_cons_printf ("| %c |\n", ch); + r_cons_printf ("'---'\n"); + r_cons_flush (); + r_sys_usleep (90000); +} + R_API void r_core_visual_seek_animation (RCore *core, ut64 addr) { + if (r_config_get_i (core->config, "scr.feedback")<1) + return; #if 0 int i, ns = 90000; const char *scmd = (addr > core->offset)? "so": "s-4"; @@ -1469,6 +1484,7 @@ R_API int r_core_visual(RCore *core, const char *input) { r_core_cmd (core, cmdprompt, 0); r_core_visual_refresh (core); ch = r_cons_readchar (); + r_core_visual_show_char (core, ch); if (ch==-1 || ch==4) break; // error or eof } while (r_core_visual_cmd (core, ch)); diff --git a/libr/core/vmenus.c b/libr/core/vmenus.c index 7b9bd145ff..ac08073782 100644 --- a/libr/core/vmenus.c +++ b/libr/core/vmenus.c @@ -1251,7 +1251,7 @@ R_API void r_core_visual_define (RCore *core) { { int h; (void)r_cons_get_size (&h); - h-=18; + h-=19; if (h<0) { r_cons_clear00 (); } else {