2016-02-10 17:45:25 +00:00
|
|
|
/* radare - LGPL - Copyright 2009-2016 - pancake */
|
2009-02-05 21:08:46 +00:00
|
|
|
|
2015-07-25 15:22:43 +00:00
|
|
|
#include <r_core.h>
|
2009-02-05 21:08:46 +00:00
|
|
|
|
2015-10-14 21:50:16 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2015-03-21 02:06:31 +00:00
|
|
|
#define NPF 7
|
2015-09-28 00:04:08 +00:00
|
|
|
static int obs = 0;
|
2011-05-21 12:27:46 +00:00
|
|
|
static int blocksize = 0;
|
2015-09-28 00:04:08 +00:00
|
|
|
static int autoblocksize = 1;
|
2013-10-19 22:25:37 +00:00
|
|
|
static void r_core_visual_refresh (RCore *core);
|
2016-02-25 10:35:59 +00:00
|
|
|
#define PIDX (R_ABS(core->printidx%NPF))
|
2015-09-28 00:04:08 +00:00
|
|
|
|
2016-02-25 09:28:54 +00:00
|
|
|
#define debugfmt_default "?0;f tmp;sr SP;pxw 64;?1;dr=;?1;s-;s tmp;f-tmp;pd $r"
|
2012-06-30 18:51:18 +00:00
|
|
|
static const char *printfmt[] = {
|
2015-04-10 23:05:51 +00:00
|
|
|
"x", "pd $r",
|
2015-09-28 00:04:08 +00:00
|
|
|
debugfmt_default,
|
2015-03-21 02:06:31 +00:00
|
|
|
"pxw", "pc", "pxA", "pxa"
|
2012-06-30 18:51:18 +00:00
|
|
|
};
|
2009-02-09 11:42:54 +00:00
|
|
|
|
2015-05-18 22:11:04 +00:00
|
|
|
#undef USE_THREADS
|
|
|
|
#define USE_THREADS 1
|
|
|
|
|
|
|
|
#if USE_THREADS
|
2015-05-18 22:18:14 +00:00
|
|
|
static int visual_repeat_thread(RThread *th) {
|
2015-05-18 22:11:04 +00:00
|
|
|
RCore *core = th->user;
|
|
|
|
int i = 0;
|
|
|
|
for (;;) {
|
|
|
|
if (core->cons->breaked)
|
|
|
|
break;
|
|
|
|
r_core_visual_refresh (core);
|
|
|
|
r_cons_flush ();
|
|
|
|
r_cons_gotoxy (0, 0);
|
|
|
|
r_cons_printf ("[@%d] ", i++);
|
|
|
|
r_cons_flush ();
|
2015-05-18 22:18:14 +00:00
|
|
|
r_sys_sleep (1);
|
2015-05-18 22:11:04 +00:00
|
|
|
}
|
2015-05-18 22:18:14 +00:00
|
|
|
r_th_kill (th, 1);
|
|
|
|
return 0;
|
2015-05-18 22:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void visual_repeat(RCore *core) {
|
2015-05-18 22:18:14 +00:00
|
|
|
int atport = r_config_get_i (core->config, "scr.atport");
|
|
|
|
if (atport) {
|
|
|
|
#if __UNIX__ && !__APPLE__
|
|
|
|
int port = r_config_get_i (core->config, "http.port");
|
|
|
|
if (!r_core_rtr_http (core, '&', NULL)) {
|
|
|
|
const char *xterm = r_config_get (core->config, "cmd.xterm");
|
|
|
|
// TODO: this must be configurable
|
|
|
|
r_sys_cmdf ("%s 'r2 -C http://localhost:%d/cmd/V;sleep 1' &", xterm, port);
|
|
|
|
//xterm -bg black -fg gray -e 'r2 -C http://localhost:%d/cmd/;sleep 1' &", port);
|
|
|
|
} else {
|
|
|
|
r_cons_any_key (NULL);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
eprintf ("Unsupported on this platform\n");
|
|
|
|
r_cons_any_key (NULL);
|
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
RThread *th = r_th_new (visual_repeat_thread, core, 0);
|
|
|
|
r_th_start (th, 1);
|
|
|
|
r_cons_break (NULL, NULL);
|
|
|
|
r_cons_any_key (NULL);
|
|
|
|
eprintf ("^C \n");
|
2015-09-14 10:35:38 +00:00
|
|
|
core->cons->breaked = true;
|
2015-05-18 22:18:14 +00:00
|
|
|
r_th_wait (th);
|
|
|
|
r_cons_break_end ();
|
|
|
|
}
|
2015-05-18 22:11:04 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-10-10 23:24:30 +00:00
|
|
|
static void showcursor(RCore *core, int x) {
|
2014-03-01 23:31:35 +00:00
|
|
|
if (core && core->vmode) {
|
2013-10-10 23:24:30 +00:00
|
|
|
r_cons_show_cursor (x);
|
2014-09-03 21:13:41 +00:00
|
|
|
if (x) {
|
|
|
|
// TODO: cache this
|
|
|
|
int wheel = r_config_get_i (core->config, "scr.wheel");
|
2015-09-27 23:00:06 +00:00
|
|
|
if (wheel) r_cons_enable_mouse (true);
|
|
|
|
else r_cons_enable_mouse (false);
|
2014-09-03 21:13:41 +00:00
|
|
|
} else {
|
2015-09-14 10:35:38 +00:00
|
|
|
r_cons_enable_mouse (false);
|
2014-09-03 21:13:41 +00:00
|
|
|
}
|
2015-09-14 10:35:38 +00:00
|
|
|
} else r_cons_enable_mouse (false);
|
2014-03-01 23:31:35 +00:00
|
|
|
r_cons_flush ();
|
2013-10-10 23:24:30 +00:00
|
|
|
}
|
|
|
|
|
2009-02-09 11:42:54 +00:00
|
|
|
static int color = 1;
|
2009-04-17 11:42:45 +00:00
|
|
|
static int debug = 1;
|
2011-02-16 23:58:54 +00:00
|
|
|
static int zoom = 0;
|
2009-02-18 00:43:57 +00:00
|
|
|
|
2015-08-31 11:57:39 +00:00
|
|
|
R_API int r_core_visual_hud(RCore *core) {
|
2014-08-29 22:16:46 +00:00
|
|
|
const char *c = r_config_get (core->config, "hud.path");
|
2013-02-07 08:41:05 +00:00
|
|
|
const char *f = R2_LIBDIR"/radare2/"R2_VERSION"/hud/main";
|
2013-10-08 22:29:49 +00:00
|
|
|
char *homehud = r_str_home (R2_HOMEDIR"/hud");
|
2012-02-12 22:45:04 +00:00
|
|
|
char *res = NULL;
|
2012-01-31 02:34:23 +00:00
|
|
|
char *p = 0;
|
2013-02-07 08:41:05 +00:00
|
|
|
|
2015-09-14 10:35:38 +00:00
|
|
|
showcursor (core, true);
|
2014-08-29 22:16:46 +00:00
|
|
|
if (c && *c && r_file_exists (c))
|
|
|
|
res = r_cons_hud_file (c);
|
|
|
|
if (!res && homehud)
|
2012-01-31 01:45:17 +00:00
|
|
|
res = r_cons_hud_file (homehud);
|
2014-08-29 22:16:46 +00:00
|
|
|
if (!res && r_file_exists (f))
|
|
|
|
res = r_cons_hud_file (f);
|
|
|
|
if (!res)
|
|
|
|
r_cons_message ("Cannot find hud file");
|
|
|
|
|
2012-01-31 01:45:17 +00:00
|
|
|
r_cons_clear ();
|
|
|
|
if (res) {
|
2012-01-31 02:34:23 +00:00
|
|
|
p = strchr (res, '\t');
|
2012-01-31 01:45:17 +00:00
|
|
|
r_cons_printf ("%s\n", res);
|
|
|
|
r_cons_flush ();
|
2012-01-31 02:34:23 +00:00
|
|
|
if (p) r_core_cmd0 (core, p+1);
|
2012-01-31 01:45:17 +00:00
|
|
|
free (res);
|
|
|
|
}
|
2015-09-14 10:35:38 +00:00
|
|
|
showcursor (core, false);
|
2012-01-31 01:45:17 +00:00
|
|
|
r_cons_flush ();
|
2014-05-03 00:21:02 +00:00
|
|
|
free (homehud);
|
2012-01-31 02:34:23 +00:00
|
|
|
return (int)(size_t)p;
|
2012-01-31 01:45:17 +00:00
|
|
|
}
|
|
|
|
|
2015-10-29 11:54:19 +00:00
|
|
|
static int visual_help() {
|
2013-11-07 01:07:10 +00:00
|
|
|
r_cons_clear00 ();
|
2015-10-29 11:54:19 +00:00
|
|
|
return r_cons_less_str (
|
2014-04-07 01:13:06 +00:00
|
|
|
"Visual mode help:\n"
|
2015-10-29 11:54:19 +00:00
|
|
|
" ? show this help or enter the userfriendly hud\n"
|
2014-06-25 01:07:54 +00:00
|
|
|
" & rotate asm.bits between supported 8, 16, 32, 64\n"
|
2015-02-13 10:06:27 +00:00
|
|
|
" % in cursor mode finds matching pair, otherwise toggle autoblocksz\n"
|
2014-09-27 01:48:54 +00:00
|
|
|
" @ set cmd.vprompt to run commands before the visual prompt\n"
|
2015-03-05 22:33:28 +00:00
|
|
|
" ! enter into the visual panels mode\n"
|
2015-10-29 11:54:19 +00:00
|
|
|
" _ enter the flag/comment/functions/.. hud (same as VF_)\n"
|
2014-10-06 00:36:22 +00:00
|
|
|
" = set cmd.vprompt (top row)\n"
|
|
|
|
" | set cmd.cprompt (right column)\n"
|
2013-11-07 01:07:10 +00:00
|
|
|
" . seek to program counter\n"
|
|
|
|
" / in cursor mode search in current block\n"
|
|
|
|
" :cmd run radare command\n"
|
|
|
|
" ;[-]cmt add/remove comment\n"
|
|
|
|
" /*+-[] change block size, [] = resize hex.cols\n"
|
|
|
|
" >||< seek aligned to block size\n"
|
2014-08-29 23:11:46 +00:00
|
|
|
" a/A (a)ssemble code, visual (A)ssembler\n"
|
2015-02-13 10:06:27 +00:00
|
|
|
" b toggle breakpoint\n"
|
2013-11-07 01:07:10 +00:00
|
|
|
" c/C toggle (c)ursor and (C)olors\n"
|
|
|
|
" d[f?] define function, data, code, ..\n"
|
|
|
|
" D enter visual diff mode (set diff.from/to)\n"
|
|
|
|
" e edit eval configuration variables\n"
|
2015-02-17 00:02:00 +00:00
|
|
|
" f/F set/unset or browse flags. f- to unset, F to browse, ..\n"
|
2013-11-07 01:07:10 +00:00
|
|
|
" gG go seek to begin and end of file (0-$s)\n"
|
|
|
|
" hjkl move around (or HJKL) (left-down-up-right)\n"
|
2014-08-29 23:11:46 +00:00
|
|
|
" i insert hex or string (in hexdump) use tab to toggle\n"
|
2013-11-07 01:07:10 +00:00
|
|
|
" mK/'K mark/go to Key (any key)\n"
|
|
|
|
" M walk the mounted filesystems\n"
|
|
|
|
" n/N seek next/prev function/flag/hit (scr.nkey)\n"
|
2014-02-10 02:31:12 +00:00
|
|
|
" o go/seek to given offset\n"
|
2014-08-29 23:11:46 +00:00
|
|
|
" O toggle asm.esil\n"
|
2013-11-07 01:07:10 +00:00
|
|
|
" p/P rotate print modes (hex, disasm, debug, words, buf)\n"
|
|
|
|
" q back to radare shell\n"
|
2014-08-28 01:11:13 +00:00
|
|
|
" r browse anal info and comments\n"
|
2013-11-07 01:07:10 +00:00
|
|
|
" R randomize color palette (ecr)\n"
|
|
|
|
" sS step / step over\n"
|
2014-08-28 01:11:13 +00:00
|
|
|
" T enter textlog chat console (TT)\n"
|
2014-08-29 23:11:46 +00:00
|
|
|
" uU undo/redo seek\n"
|
2013-11-07 01:07:10 +00:00
|
|
|
" v visual code analysis menu\n"
|
2015-02-13 10:06:27 +00:00
|
|
|
" V (V)iew graph using cmd.graph (agv?)\n"
|
|
|
|
" wW seek cursor to next/prev word\n"
|
2014-08-05 17:49:33 +00:00
|
|
|
" xX show xrefs/refs of current function from/to data/code\n"
|
2013-11-07 01:07:10 +00:00
|
|
|
" yY copy and paste selection\n"
|
2015-06-01 23:04:10 +00:00
|
|
|
" z fold/unfold comments in disassembly\n"
|
|
|
|
" Z toggle zoom mode\n"
|
2014-02-07 13:54:31 +00:00
|
|
|
" Enter follow address of jump/call\n"
|
2014-04-07 01:13:06 +00:00
|
|
|
"Function Keys: (See 'e key.'), defaults to:\n"
|
|
|
|
" F2 toggle breakpoint\n"
|
2015-12-16 19:42:21 +00:00
|
|
|
" F4 run to cursor\n"
|
2014-04-07 01:13:06 +00:00
|
|
|
" F7 single step\n"
|
|
|
|
" F8 step over\n"
|
2015-10-29 11:54:19 +00:00
|
|
|
" F9 continue\n",
|
|
|
|
"?");
|
2013-11-07 01:07:10 +00:00
|
|
|
r_cons_flush ();
|
|
|
|
r_cons_clear00 ();
|
|
|
|
}
|
|
|
|
|
2012-08-13 02:33:01 +00:00
|
|
|
static void prompt_read (const char *p, char *buf, int buflen) {
|
2016-02-27 11:38:02 +00:00
|
|
|
if (!buf || buflen < 1)
|
|
|
|
return;
|
|
|
|
*buf = 0;
|
2012-08-13 02:33:01 +00:00
|
|
|
r_line_set_prompt (p);
|
2015-09-14 10:35:38 +00:00
|
|
|
showcursor (NULL, true);
|
2012-08-13 02:33:01 +00:00
|
|
|
r_cons_fgets (buf, buflen, 0, NULL);
|
2015-09-14 10:35:38 +00:00
|
|
|
showcursor (NULL, false);
|
2012-08-13 02:33:01 +00:00
|
|
|
}
|
|
|
|
|
2014-08-05 17:49:33 +00:00
|
|
|
R_API void r_core_visual_prompt_input (RCore *core) {
|
|
|
|
int ret;
|
2014-10-01 16:57:01 +00:00
|
|
|
ut64 addr = core->offset;
|
|
|
|
ut64 bsze = core->blocksize;
|
2015-10-20 22:57:15 +00:00
|
|
|
int h;
|
|
|
|
(void)r_cons_get_size (&h);
|
|
|
|
r_cons_gotoxy (0, h-2);
|
2015-11-19 11:23:10 +00:00
|
|
|
r_cons_reset_colors ();
|
|
|
|
r_cons_printf ("\nPress <enter> to return to Visual mode.\n");
|
2015-09-14 10:35:38 +00:00
|
|
|
r_cons_show_cursor (true);
|
|
|
|
core->vmode = false;
|
2014-10-01 16:57:01 +00:00
|
|
|
ut64 newaddr = addr;
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->cur_enabled) {
|
|
|
|
if (core->print->ocur != -1) {
|
|
|
|
int newsz = core->print->cur - core->print->ocur;
|
|
|
|
newaddr = core->offset + core->print->ocur;
|
|
|
|
r_core_block_size (core, newsz);
|
|
|
|
} else newaddr = core->offset + core->print->cur;
|
2014-10-01 16:57:01 +00:00
|
|
|
r_core_seek (core, newaddr, 1);
|
|
|
|
}
|
2014-08-05 17:49:33 +00:00
|
|
|
do {
|
|
|
|
ret = r_core_visual_prompt (core);
|
2014-10-01 16:57:01 +00:00
|
|
|
if (core->offset != newaddr) {
|
|
|
|
// do not restore seek anymore
|
|
|
|
newaddr = addr;
|
|
|
|
}
|
|
|
|
} while (ret);
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->cur_enabled) {
|
2014-10-01 16:57:01 +00:00
|
|
|
if (addr != newaddr) {
|
2014-08-05 17:49:33 +00:00
|
|
|
r_core_seek (core, addr, 1);
|
|
|
|
r_core_block_size (core, bsze);
|
|
|
|
}
|
2014-10-01 16:57:01 +00:00
|
|
|
}
|
2015-09-14 10:35:38 +00:00
|
|
|
r_cons_show_cursor (false);
|
|
|
|
core->vmode = true;
|
2014-08-05 17:49:33 +00:00
|
|
|
}
|
|
|
|
|
2013-12-31 12:09:50 +00:00
|
|
|
R_API int r_core_visual_prompt (RCore *core) {
|
2011-05-21 12:27:46 +00:00
|
|
|
char buf[1024];
|
2013-12-31 12:09:50 +00:00
|
|
|
int ret;
|
2011-12-04 20:02:09 +00:00
|
|
|
#if __UNIX__
|
|
|
|
r_line_set_prompt (Color_RESET":> ");
|
|
|
|
#else
|
2011-05-21 12:27:46 +00:00
|
|
|
r_line_set_prompt (":> ");
|
2011-12-04 20:02:09 +00:00
|
|
|
#endif
|
2015-09-14 10:35:38 +00:00
|
|
|
showcursor (core, true);
|
2011-05-21 12:27:46 +00:00
|
|
|
r_cons_fgets (buf, sizeof (buf), 0, NULL);
|
2014-10-01 16:57:01 +00:00
|
|
|
if (!strcmp (buf, "q")) {
|
2015-09-14 10:35:38 +00:00
|
|
|
ret = false;
|
2014-10-01 16:57:01 +00:00
|
|
|
} else if (*buf) {
|
2013-12-31 12:09:50 +00:00
|
|
|
r_line_hist_add (buf);
|
|
|
|
r_core_cmd (core, buf, 0);
|
|
|
|
r_cons_flush ();
|
2015-09-14 10:35:38 +00:00
|
|
|
ret = true;
|
2013-12-31 12:09:50 +00:00
|
|
|
} else {
|
2015-09-14 10:35:38 +00:00
|
|
|
ret = false;
|
2015-03-05 22:33:28 +00:00
|
|
|
//r_cons_any_key (NULL);
|
2013-12-31 12:09:50 +00:00
|
|
|
r_cons_clear00 ();
|
2015-09-14 10:35:38 +00:00
|
|
|
showcursor (core, false);
|
2013-12-31 12:09:50 +00:00
|
|
|
}
|
|
|
|
return ret;
|
2011-05-21 12:27:46 +00:00
|
|
|
}
|
|
|
|
|
2012-09-28 00:20:52 +00:00
|
|
|
static int visual_nkey(RCore *core, int ch) {
|
2011-06-05 22:16:11 +00:00
|
|
|
const char *cmd;
|
2013-10-06 13:15:23 +00:00
|
|
|
ut64 oseek = UT64_MAX;
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->ocur == -1) {
|
2013-10-06 13:15:23 +00:00
|
|
|
oseek = core->offset;
|
2016-02-07 16:06:39 +00:00
|
|
|
r_core_seek (core, core->offset + core->print->cur, 0);
|
2013-10-06 13:15:23 +00:00
|
|
|
}
|
|
|
|
|
2011-06-05 22:16:11 +00:00
|
|
|
switch (ch) {
|
|
|
|
case R_CONS_KEY_F1:
|
|
|
|
cmd = r_config_get (core->config, "key.f1");
|
2013-10-06 13:15:23 +00:00
|
|
|
if (cmd && *cmd) ch = r_core_cmd0 (core, cmd);
|
|
|
|
else ch = '?';
|
2011-06-05 22:16:11 +00:00
|
|
|
break;
|
|
|
|
case R_CONS_KEY_F2:
|
|
|
|
cmd = r_config_get (core->config, "key.f2");
|
2013-10-06 13:15:23 +00:00
|
|
|
if (cmd && *cmd) ch = r_core_cmd0 (core, cmd);
|
2011-06-05 22:16:11 +00:00
|
|
|
break;
|
|
|
|
case R_CONS_KEY_F3:
|
|
|
|
cmd = r_config_get (core->config, "key.f3");
|
2013-10-06 13:15:23 +00:00
|
|
|
if (cmd && *cmd) ch = r_core_cmd0 (core, cmd);
|
2011-06-05 22:16:11 +00:00
|
|
|
break;
|
|
|
|
case R_CONS_KEY_F4:
|
|
|
|
cmd = r_config_get (core->config, "key.f4");
|
2013-10-06 13:15:23 +00:00
|
|
|
if (cmd && *cmd) ch = r_core_cmd0 (core, cmd);
|
2015-12-16 19:35:45 +00:00
|
|
|
else {
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->cur_enabled) {
|
2015-12-16 19:35:45 +00:00
|
|
|
// dcu 0xaddr
|
2016-02-07 16:06:39 +00:00
|
|
|
r_core_cmdf (core, "dcu 0x%08"PFMT64x, core->offset + core->print->cur);
|
|
|
|
core->print->cur_enabled = 0;
|
2015-12-16 19:35:45 +00:00
|
|
|
}
|
|
|
|
}
|
2014-08-01 12:59:31 +00:00
|
|
|
break;
|
2011-06-05 22:16:11 +00:00
|
|
|
case R_CONS_KEY_F5:
|
|
|
|
cmd = r_config_get (core->config, "key.f5");
|
2013-10-06 13:15:23 +00:00
|
|
|
if (cmd && *cmd) ch = r_core_cmd0 (core, cmd);
|
2014-08-01 12:59:31 +00:00
|
|
|
break;
|
2011-06-05 22:16:11 +00:00
|
|
|
case R_CONS_KEY_F6:
|
|
|
|
cmd = r_config_get (core->config, "key.f6");
|
2013-10-06 13:15:23 +00:00
|
|
|
if (cmd && *cmd) ch = r_core_cmd0 (core, cmd);
|
2011-06-05 22:16:11 +00:00
|
|
|
break;
|
|
|
|
case R_CONS_KEY_F7:
|
|
|
|
cmd = r_config_get (core->config, "key.f7");
|
2013-10-06 13:15:23 +00:00
|
|
|
if (cmd && *cmd) ch = r_core_cmd0 (core, cmd);
|
|
|
|
else ch = 's';
|
2011-06-05 22:16:11 +00:00
|
|
|
break;
|
|
|
|
case R_CONS_KEY_F8:
|
|
|
|
cmd = r_config_get (core->config, "key.f8");
|
2013-10-06 13:15:23 +00:00
|
|
|
if (cmd && *cmd) ch = r_core_cmd0 (core, cmd);
|
2011-06-05 22:16:11 +00:00
|
|
|
break;
|
|
|
|
case R_CONS_KEY_F9:
|
|
|
|
cmd = r_config_get (core->config, "key.f9");
|
2013-10-06 13:15:23 +00:00
|
|
|
if (cmd && *cmd) ch = r_core_cmd0 (core, cmd);
|
|
|
|
else r_core_cmd0 (core, "dc");
|
2011-06-05 22:16:11 +00:00
|
|
|
break;
|
|
|
|
case R_CONS_KEY_F10:
|
|
|
|
cmd = r_config_get (core->config, "key.f10");
|
2013-10-06 13:15:23 +00:00
|
|
|
if (cmd && *cmd) ch = r_core_cmd0 (core, cmd);
|
2011-06-05 22:16:11 +00:00
|
|
|
break;
|
|
|
|
case R_CONS_KEY_F11:
|
|
|
|
cmd = r_config_get (core->config, "key.f11");
|
2013-10-06 13:15:23 +00:00
|
|
|
if (cmd && *cmd) ch = r_core_cmd0 (core, cmd);
|
2011-06-05 22:16:11 +00:00
|
|
|
break;
|
|
|
|
case R_CONS_KEY_F12:
|
|
|
|
cmd = r_config_get (core->config, "key.f12");
|
2013-10-06 13:15:23 +00:00
|
|
|
if (cmd && *cmd) ch = r_core_cmd0 (core, cmd);
|
2011-06-05 22:16:11 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-10-06 13:15:23 +00:00
|
|
|
if (oseek != UT64_MAX)
|
|
|
|
r_core_seek (core, oseek, 0);
|
2011-06-05 22:16:11 +00:00
|
|
|
return ch;
|
|
|
|
}
|
|
|
|
|
2016-02-07 16:06:39 +00:00
|
|
|
static void setcursor (RCore *core, bool cur) {
|
2013-08-26 23:12:58 +00:00
|
|
|
int flags = core->print->flags; // wtf
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->cur_enabled) flags |= R_PRINT_FLAGS_CURSOR;
|
2013-08-26 23:12:58 +00:00
|
|
|
else flags &= ~(R_PRINT_FLAGS_CURSOR);
|
2013-10-10 23:24:30 +00:00
|
|
|
core->print->cur_enabled = cur;
|
2012-06-14 08:01:16 +00:00
|
|
|
r_print_set_flags (core->print, flags);
|
2016-02-07 16:06:39 +00:00
|
|
|
core->print->col = core->print->cur_enabled ? 1 : 0;
|
2012-06-14 08:01:16 +00:00
|
|
|
}
|
|
|
|
|
2012-08-13 02:33:01 +00:00
|
|
|
static void setdiff (RCore *core) {
|
|
|
|
char from[64], to[64];
|
|
|
|
prompt_read ("diff from: ", from, sizeof (from));
|
|
|
|
r_config_set (core->config, "diff.from", from);
|
|
|
|
prompt_read ("diff to: ", to, sizeof (to));
|
|
|
|
r_config_set (core->config, "diff.to", to);
|
|
|
|
}
|
|
|
|
|
2015-02-12 23:36:05 +00:00
|
|
|
static void findPair (RCore *core) {
|
|
|
|
ut8 buf[256];
|
2016-02-07 16:06:39 +00:00
|
|
|
int i, len, d = core->print->cur + 1;
|
2015-02-12 23:36:05 +00:00
|
|
|
int delta = 0;
|
2015-02-13 10:06:27 +00:00
|
|
|
const ut8 *p, *q = NULL;
|
2015-02-12 23:36:05 +00:00
|
|
|
const char *keys = "{}[]()<>";
|
2016-02-07 16:06:39 +00:00
|
|
|
ut8 ch = core->block[core->print->cur];
|
2015-02-12 23:36:05 +00:00
|
|
|
|
|
|
|
p = (const ut8*)strchr (keys, ch);
|
|
|
|
if (p) {
|
|
|
|
delta = (size_t)(p-(const ut8*)keys);
|
2015-11-23 00:40:35 +00:00
|
|
|
ch = (delta%2 && p != (const ut8*)keys)? p[-1]: p[1];
|
2015-02-12 23:36:05 +00:00
|
|
|
}
|
|
|
|
len = 1;
|
|
|
|
buf[0] = ch;
|
|
|
|
|
2015-02-13 10:06:27 +00:00
|
|
|
if (p && (delta%2)) {
|
|
|
|
for (i = d-1; i>=0; i--) {
|
|
|
|
if (core->block[i] == ch) {
|
|
|
|
q = core->block + i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
q = r_mem_mem (core->block+d, core->blocksize-d,
|
|
|
|
(const ut8*)buf, len);
|
|
|
|
if (!q) {
|
|
|
|
q = r_mem_mem (core->block, R_MIN (core->blocksize, d),
|
|
|
|
(const ut8*)buf, len);
|
|
|
|
}
|
2015-02-12 23:36:05 +00:00
|
|
|
}
|
|
|
|
if (q) {
|
2016-02-07 16:06:39 +00:00
|
|
|
core->print->cur = (int)(size_t)(q-core->block);
|
|
|
|
core->print->ocur = -1;
|
2015-09-14 10:35:38 +00:00
|
|
|
showcursor (core, true);
|
2015-02-12 23:36:05 +00:00
|
|
|
}
|
|
|
|
}
|
2015-02-13 10:06:27 +00:00
|
|
|
|
|
|
|
static void findNextWord (RCore *core) {
|
2016-02-07 16:06:39 +00:00
|
|
|
int i, d = core->print->cur_enabled ? core->print->cur : 0;
|
2015-02-13 10:06:27 +00:00
|
|
|
for (i = d+1; i<core->blocksize; i++) {
|
|
|
|
switch (core->block[i]) {
|
|
|
|
case ' ':
|
|
|
|
case '.':
|
|
|
|
case '\t':
|
|
|
|
case '\n':
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->cur_enabled) {
|
|
|
|
core->print->cur = i + 1;
|
|
|
|
core->print->ocur = -1;
|
2015-09-14 10:35:38 +00:00
|
|
|
showcursor (core, true);
|
2015-02-13 10:06:27 +00:00
|
|
|
} else {
|
|
|
|
r_core_seek (core, core->offset + i + 1, 1);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int isSpace (char ch) {
|
|
|
|
switch (ch) {
|
|
|
|
case ' ':
|
|
|
|
case '.':
|
|
|
|
case ',':
|
|
|
|
case '\t':
|
|
|
|
case '\n':
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void findPrevWord (RCore *core) {
|
2016-02-07 16:06:39 +00:00
|
|
|
int i = core->print->cur_enabled ? core->print->cur : 0;
|
2015-02-13 10:06:27 +00:00
|
|
|
while (i>1) {
|
|
|
|
if (isSpace (core->block[i]))
|
|
|
|
i--;
|
|
|
|
else if (isSpace (core->block[i-1]))
|
|
|
|
i-=2;
|
|
|
|
else break;
|
|
|
|
}
|
|
|
|
for (; i>=0; i--) {
|
|
|
|
if (isSpace (core->block[i])) {
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->cur_enabled) {
|
|
|
|
core->print->cur = i + 1;
|
|
|
|
core->print->ocur = -1;
|
2015-09-14 10:35:38 +00:00
|
|
|
showcursor (core, true);
|
2015-02-13 10:06:27 +00:00
|
|
|
} else {
|
|
|
|
// r_core_seek (core, core->offset + i + 1, 1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-01 23:50:39 +00:00
|
|
|
// TODO: integrate in '/' command with search.inblock ?
|
|
|
|
static void visual_search (RCore *core) {
|
2012-08-04 21:48:06 +00:00
|
|
|
const ut8 *p;
|
2016-02-07 16:06:39 +00:00
|
|
|
int len, d = core->print->cur;
|
2012-08-01 23:50:39 +00:00
|
|
|
char str[128], buf[258];
|
|
|
|
|
|
|
|
r_line_set_prompt ("search byte/string in block: ");
|
|
|
|
r_cons_fgets (str, sizeof (str), 0, NULL);
|
2012-08-04 21:48:06 +00:00
|
|
|
len = r_hex_str2bin (str, (ut8*)buf);
|
2012-08-01 23:50:39 +00:00
|
|
|
if (*str=='"') {
|
|
|
|
char *e = strncpy (buf, str+1, sizeof (buf)-1);
|
|
|
|
if (e) { --e; if (*e=='"') *e=0; }
|
|
|
|
len = strlen (buf);
|
|
|
|
} else
|
|
|
|
if (len<1) {
|
|
|
|
strncpy (buf, str, sizeof (buf)-1);
|
|
|
|
len = strlen (str);
|
|
|
|
}
|
2012-08-04 21:48:06 +00:00
|
|
|
p = r_mem_mem (core->block+d, core->blocksize-d,
|
|
|
|
(const ut8*)buf, len);
|
2012-08-01 23:50:39 +00:00
|
|
|
if (p) {
|
2016-02-07 16:06:39 +00:00
|
|
|
core->print->cur = (int)(size_t)(p-core->block);
|
2012-08-01 23:50:39 +00:00
|
|
|
if (len>1) {
|
2016-02-07 16:06:39 +00:00
|
|
|
core->print->ocur = core->print->cur+len-1;
|
|
|
|
} else core->print->ocur = -1;
|
2015-09-14 10:35:38 +00:00
|
|
|
showcursor (core, true);
|
2016-02-07 16:06:39 +00:00
|
|
|
eprintf ("FOUND IN %d\n", core->print->cur);
|
2015-03-05 22:33:28 +00:00
|
|
|
r_cons_any_key (NULL);
|
2012-08-01 23:50:39 +00:00
|
|
|
} else {
|
|
|
|
eprintf ("Cannot find bytes\n");
|
2015-03-05 22:33:28 +00:00
|
|
|
r_cons_any_key (NULL);
|
2012-08-01 23:50:39 +00:00
|
|
|
r_cons_clear00 ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-28 01:27:22 +00:00
|
|
|
R_API void r_core_visual_show_char (RCore *core, char ch) {
|
|
|
|
if (r_config_get_i (core->config, "scr.feedback")<2)
|
|
|
|
return;
|
2015-04-09 14:43:20 +00:00
|
|
|
if (!IS_PRINTABLE (ch))
|
2014-09-28 01:27:22 +00:00
|
|
|
return;
|
|
|
|
r_cons_gotoxy (1, 2);
|
|
|
|
r_cons_printf (".---.\n");
|
|
|
|
r_cons_printf ("| %c |\n", ch);
|
|
|
|
r_cons_printf ("'---'\n");
|
|
|
|
r_cons_flush ();
|
2014-10-20 23:20:06 +00:00
|
|
|
r_sys_sleep (1);
|
2014-09-28 01:27:22 +00:00
|
|
|
}
|
|
|
|
|
2013-10-19 22:25:37 +00:00
|
|
|
R_API void r_core_visual_seek_animation (RCore *core, ut64 addr) {
|
2015-11-19 11:23:10 +00:00
|
|
|
r_core_seek (core, addr, 1);
|
2014-09-28 01:27:22 +00:00
|
|
|
if (r_config_get_i (core->config, "scr.feedback")<1)
|
|
|
|
return;
|
2013-10-19 22:25:37 +00:00
|
|
|
if (core->offset == addr)
|
|
|
|
return;
|
|
|
|
r_cons_gotoxy (1, 2);
|
|
|
|
if (addr>core->offset) {
|
|
|
|
r_cons_printf (".----.\n");
|
|
|
|
r_cons_printf ("| \\/ |\n");
|
|
|
|
r_cons_printf ("'----'\n");
|
|
|
|
} else {
|
|
|
|
r_cons_printf (".----.\n");
|
|
|
|
r_cons_printf ("| /\\ |\n");
|
|
|
|
r_cons_printf ("'----'\n");
|
|
|
|
}
|
|
|
|
r_cons_flush();
|
2014-10-20 23:20:06 +00:00
|
|
|
r_sys_usleep (90000);
|
2013-10-19 22:25:37 +00:00
|
|
|
}
|
|
|
|
|
2013-12-02 02:53:29 +00:00
|
|
|
static void setprintmode (RCore *core, int n) {
|
2013-12-31 12:09:50 +00:00
|
|
|
RAsmOp op;
|
2013-12-02 02:53:29 +00:00
|
|
|
if (n>0) {
|
|
|
|
core->printidx = R_ABS ((core->printidx+1)%NPF);
|
|
|
|
} else {
|
|
|
|
if (core->printidx)
|
|
|
|
core->printidx--;
|
|
|
|
else core->printidx = NPF-1;
|
|
|
|
}
|
|
|
|
switch (core->printidx) {
|
|
|
|
case 0:
|
|
|
|
core->inc = 16;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
core->inc = r_asm_disassemble (core->assembler,
|
|
|
|
&op, core->block, 32);
|
|
|
|
break;
|
2015-03-21 02:06:31 +00:00
|
|
|
case 5: // "pxA"
|
|
|
|
core->inc = 256;
|
|
|
|
break;
|
2013-12-02 02:53:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-01 22:33:07 +00:00
|
|
|
#define OPDELTA 32
|
2016-02-10 23:18:09 +00:00
|
|
|
static ut64 prevop_addr (RCore *core, ut64 addr) {
|
|
|
|
ut8 buf[OPDELTA * 2];
|
|
|
|
ut64 target, base;
|
|
|
|
RAnalBlock *bb;
|
2013-11-07 01:07:10 +00:00
|
|
|
RAnalOp op;
|
2016-02-10 23:18:09 +00:00
|
|
|
int len, ret, i;
|
|
|
|
|
|
|
|
// let's see if we can use anal info to get the previous instruction
|
|
|
|
// TODO: look in the current basicblock, then in the current function
|
|
|
|
// and search in all functions only as a last chance, to try to speed
|
|
|
|
// up the process.
|
|
|
|
bb = r_anal_bb_from_offset (core->anal, addr - 1);
|
|
|
|
if (bb) {
|
|
|
|
ut64 res = r_anal_bb_opaddr_at (bb, addr - 1);
|
|
|
|
if (res != UT64_MAX) {
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
2013-11-07 01:07:10 +00:00
|
|
|
|
2016-02-10 23:18:09 +00:00
|
|
|
// if we anal info didn't help then fallback to the dumb solution.
|
|
|
|
target = addr;
|
|
|
|
base = target - OPDELTA;
|
2013-11-07 01:07:10 +00:00
|
|
|
r_core_read_at (core, base, buf, sizeof (buf));
|
2016-02-10 23:18:09 +00:00
|
|
|
for (i = 0; i < sizeof (buf); i++) {
|
|
|
|
ret = r_anal_op (core->anal, &op, base + i,
|
|
|
|
buf + i, sizeof (buf) - i);
|
2013-11-07 01:07:10 +00:00
|
|
|
if (!ret) continue;
|
2013-12-06 04:18:57 +00:00
|
|
|
len = op.size;
|
2013-12-01 22:33:07 +00:00
|
|
|
r_anal_op_fini (&op); // XXX
|
2016-02-10 23:18:09 +00:00
|
|
|
if (len < 1) continue;
|
|
|
|
if (target == base + i + len) {
|
|
|
|
return base + i;
|
|
|
|
}
|
|
|
|
i += len - 1;
|
2013-11-07 01:07:10 +00:00
|
|
|
}
|
2016-02-10 23:18:09 +00:00
|
|
|
return target - 4;
|
2013-11-07 01:07:10 +00:00
|
|
|
}
|
2014-02-10 02:31:12 +00:00
|
|
|
static void visual_offset (RCore *core) {
|
|
|
|
char buf[256];
|
|
|
|
r_line_set_prompt ("[offset]> ");
|
|
|
|
strcpy (buf, "s ");
|
|
|
|
if (r_cons_fgets (buf+2, sizeof (buf)-3, 0, NULL) >0) {
|
|
|
|
if (buf[2]=='.')buf[1]='.';
|
|
|
|
r_core_cmd0 (core, buf);
|
|
|
|
}
|
|
|
|
}
|
2013-11-07 01:07:10 +00:00
|
|
|
|
2016-02-10 23:18:09 +00:00
|
|
|
static int prevopsz(RCore *core, ut64 addr) {
|
|
|
|
ut64 prev_addr = prevop_addr (core, addr);
|
|
|
|
return addr - prev_addr;
|
|
|
|
}
|
|
|
|
|
2014-08-05 03:37:48 +00:00
|
|
|
R_API int r_core_visual_xrefs_x (RCore *core) {
|
2014-09-22 22:40:35 +00:00
|
|
|
int ret = 0;
|
|
|
|
#if FCN_OLD
|
|
|
|
char ch;
|
2014-08-05 03:37:48 +00:00
|
|
|
int count = 0;
|
|
|
|
RList *xrefs = NULL;
|
|
|
|
RAnalRef *refi;
|
|
|
|
RListIter *iter;
|
|
|
|
RAnalFunction *fun;
|
2016-02-16 00:20:25 +00:00
|
|
|
int skip = 0;
|
|
|
|
int idx = 0;
|
|
|
|
char cstr[32];
|
2014-08-05 03:37:48 +00:00
|
|
|
|
2016-02-16 00:20:25 +00:00
|
|
|
repeat:
|
2014-08-05 03:37:48 +00:00
|
|
|
if ((xrefs = r_anal_xref_get (core->anal, core->offset))) {
|
2016-02-16 00:20:25 +00:00
|
|
|
r_cons_clear00 ();
|
2014-08-05 03:37:48 +00:00
|
|
|
r_cons_gotoxy (1, 1);
|
2016-02-16 00:20:25 +00:00
|
|
|
r_cons_printf ("[GOTO XREF]> 0x%08"PFMT64x"\n", core->offset);
|
2014-08-05 03:37:48 +00:00
|
|
|
if (r_list_empty (xrefs)) {
|
|
|
|
r_cons_printf ("\tNo XREF found at 0x%"PFMT64x"\n", core->offset);
|
2015-03-05 22:33:28 +00:00
|
|
|
r_cons_any_key (NULL);
|
2014-08-05 03:37:48 +00:00
|
|
|
r_cons_clear00 ();
|
|
|
|
} else {
|
2016-02-16 00:20:25 +00:00
|
|
|
int lines;
|
|
|
|
(void)r_cons_get_size (&lines);
|
|
|
|
idx = 0;
|
|
|
|
count = 0;
|
|
|
|
lines -= 3;
|
2014-08-05 03:37:48 +00:00
|
|
|
r_list_foreach (xrefs, iter, refi) {
|
2016-02-16 00:20:25 +00:00
|
|
|
if (idx >= skip) {
|
|
|
|
if (count>9) {
|
|
|
|
strcpy (cstr, "?");
|
|
|
|
} else {
|
|
|
|
snprintf (cstr, sizeof (cstr), "%d", count);
|
|
|
|
}
|
|
|
|
fun = r_anal_get_fcn_in (core->anal, refi->addr, R_ANAL_FCN_TYPE_NULL);
|
|
|
|
#if 0
|
|
|
|
r_cons_printf (" %d [%s] 0x%08"PFMT64x" %s XREF 0x%08"PFMT64x" (%s) \n",
|
|
|
|
idx, cstr, refi->at,
|
|
|
|
refi->type==R_ANAL_REF_TYPE_CODE?"CODE (JMP)":
|
|
|
|
refi->type==R_ANAL_REF_TYPE_CALL?"CODE (CALL)":"DATA", refi->addr,
|
|
|
|
fun?fun->name:"unk");
|
|
|
|
#endif
|
|
|
|
r_cons_printf (" %d [%s] 0x%08"PFMT64x" %s XREF (%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",
|
|
|
|
fun?fun->name:"unk");
|
|
|
|
if (++count >= lines) {
|
|
|
|
r_cons_printf ("...\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
idx++;
|
2014-08-05 03:37:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else xrefs = NULL;
|
2014-08-17 18:30:28 +00:00
|
|
|
if (!xrefs || !r_list_length (xrefs)) {
|
|
|
|
r_list_free (xrefs);
|
2014-08-05 03:37:48 +00:00
|
|
|
return 0;
|
2014-08-17 18:30:28 +00:00
|
|
|
}
|
2014-08-05 03:37:48 +00:00
|
|
|
r_cons_flush ();
|
|
|
|
ch = r_cons_readchar ();
|
2016-02-16 00:20:25 +00:00
|
|
|
if (ch == 'j') {
|
|
|
|
skip++;
|
|
|
|
goto repeat;
|
|
|
|
} else if (ch == 'k') {
|
|
|
|
skip--;
|
|
|
|
goto repeat;
|
|
|
|
} else if (ch == ' ' || ch == '\n' || ch == '\r') {
|
|
|
|
refi = r_list_get_n (xrefs, skip);
|
|
|
|
if (refi) {
|
|
|
|
r_core_cmdf (core, "s 0x%"PFMT64x, refi->addr);
|
|
|
|
ret = 1;
|
|
|
|
}
|
|
|
|
} else if (ch >= '0' && ch <= '9') {
|
|
|
|
refi = r_list_get_n (xrefs, ch - 0x30);
|
2014-08-05 03:37:48 +00:00
|
|
|
if (refi) {
|
|
|
|
r_core_cmdf (core, "s 0x%"PFMT64x, refi->addr);
|
|
|
|
ret = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
r_list_free (xrefs);
|
2014-09-22 22:40:35 +00:00
|
|
|
#else
|
|
|
|
eprintf ("TODO: sdbize xrefs here\n");
|
|
|
|
#endif
|
2014-08-05 03:37:48 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
R_API int r_core_visual_xrefs_X (RCore *core) {
|
2014-09-22 22:40:35 +00:00
|
|
|
int ret = 0;
|
|
|
|
#if FCN_OLD
|
|
|
|
char ch;
|
2014-08-05 03:37:48 +00:00
|
|
|
int count = 0;
|
|
|
|
RAnalRef *refi;
|
|
|
|
RListIter *iter;
|
|
|
|
RAnalFunction *fun;
|
|
|
|
|
2014-09-26 13:40:17 +00:00
|
|
|
fun = r_anal_get_fcn_in (core->anal, core->offset, R_ANAL_FCN_TYPE_NULL);
|
2014-08-05 03:37:48 +00:00
|
|
|
if (fun) {
|
2016-02-23 01:31:53 +00:00
|
|
|
r_cons_clear00 ();
|
2014-08-05 03:37:48 +00:00
|
|
|
r_cons_gotoxy (1, 1);
|
|
|
|
r_cons_printf ("[GOTO REF]> \n");
|
|
|
|
if (r_list_empty (fun->refs)) {
|
|
|
|
r_cons_printf ("\tNo REF found at 0x%"PFMT64x"\n", core->offset);
|
2015-03-05 22:33:28 +00:00
|
|
|
r_cons_any_key (NULL);
|
2014-08-05 03:37:48 +00:00
|
|
|
r_cons_clear00 ();
|
|
|
|
} else {
|
|
|
|
r_list_foreach (fun->refs, iter, refi) {
|
2016-02-23 01:31:53 +00:00
|
|
|
RFlagItem *f = r_flag_get_at (core->flags, refi->addr);
|
|
|
|
if (f) {
|
|
|
|
eprintf ("%s\n", f->name);
|
|
|
|
}
|
|
|
|
r_cons_printf (" [%i] 0x%08"PFMT64x" %s XREF 0x%08"PFMT64x" (%s)(%s) \n", count,
|
2014-08-05 03:37:48 +00:00
|
|
|
refi->at,
|
|
|
|
refi->type==R_ANAL_REF_TYPE_CODE?"CODE (JMP)":
|
2016-02-23 01:31:53 +00:00
|
|
|
refi->type==R_ANAL_REF_TYPE_CALL?"CODE (CALL)":"DATA", refi->addr, fun->name, f?f->name:"");
|
2014-08-05 03:37:48 +00:00
|
|
|
if (++count > 9) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
r_cons_flush ();
|
|
|
|
if (!count)
|
|
|
|
return 0;
|
|
|
|
ch = r_cons_readchar ();
|
|
|
|
if (fun && fun->refs) {
|
|
|
|
if (ch >= '0' && ch <= '9') {
|
|
|
|
refi = r_list_get_n (fun->refs, ch-0x30);
|
|
|
|
if (refi) {
|
|
|
|
r_core_cmdf (core, "s 0x%"PFMT64x, refi->addr);
|
|
|
|
ret = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-09-22 22:40:35 +00:00
|
|
|
#else
|
|
|
|
eprintf ("TODO: sdbize this\n");
|
|
|
|
#endif
|
2014-08-05 03:37:48 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-04-07 14:25:14 +00:00
|
|
|
#if __WINDOWS__ && !__CYGWIN__
|
2015-04-07 13:23:03 +00:00
|
|
|
void SetWindow(int Width, int Height) {
|
2015-11-18 12:03:35 +00:00
|
|
|
COORD coord;
|
|
|
|
coord.X = Width;
|
|
|
|
coord.Y = Height;
|
2015-04-07 13:23:03 +00:00
|
|
|
|
2015-11-18 12:03:35 +00:00
|
|
|
SMALL_RECT Rect;
|
|
|
|
Rect.Top = 0;
|
|
|
|
Rect.Left = 0;
|
|
|
|
Rect.Bottom = Height - 1;
|
|
|
|
Rect.Right = Width - 1;
|
2015-04-07 13:23:03 +00:00
|
|
|
|
2015-11-18 12:03:35 +00:00
|
|
|
HANDLE Handle = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
|
|
SetConsoleScreenBufferSize(Handle, coord);
|
|
|
|
SetConsoleWindowInfo(Handle, TRUE, &Rect);
|
2015-04-07 13:23:03 +00:00
|
|
|
}
|
2015-04-07 14:25:14 +00:00
|
|
|
#endif
|
2015-04-07 13:23:03 +00:00
|
|
|
|
2015-11-18 16:02:42 +00:00
|
|
|
// unnecesarily public
|
|
|
|
char *getcommapath(RCore *core) {
|
|
|
|
char *cwd;
|
2015-11-18 12:03:35 +00:00
|
|
|
const char *dir = r_config_get (core->config, "dir.projects");
|
|
|
|
const char *prj = r_config_get (core->config, "file.project");
|
|
|
|
if (dir && *dir && prj && *prj) {
|
2015-11-25 11:49:02 +00:00
|
|
|
char *abspath = r_file_abspath (dir);
|
2015-11-18 12:03:35 +00:00
|
|
|
/* use prjdir as base directory for comma-ent files */
|
2015-11-24 17:26:10 +00:00
|
|
|
cwd = r_str_newf ("%s"R_SYS_DIR"%s.d", abspath, prj);
|
|
|
|
free (abspath);
|
2015-11-18 12:03:35 +00:00
|
|
|
} else {
|
|
|
|
/* use cwd as base directory for comma-ent files */
|
2015-11-18 16:02:42 +00:00
|
|
|
cwd = r_sys_getdir ();
|
2015-11-18 12:03:35 +00:00
|
|
|
}
|
2015-11-18 16:02:42 +00:00
|
|
|
return cwd;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void visual_comma(RCore *core) {
|
2016-02-07 16:06:39 +00:00
|
|
|
ut64 addr = core->offset + (core->print->cur_enabled ? core->print->cur : 0);
|
2015-11-18 16:02:42 +00:00
|
|
|
char *comment, *cwd, *cmtfile;
|
|
|
|
comment = r_meta_get_string (core->anal, R_META_TYPE_COMMENT, addr);
|
|
|
|
cmtfile = r_str_between (comment, ",(", ")");
|
|
|
|
cwd = getcommapath (core);
|
2015-11-18 12:03:35 +00:00
|
|
|
if (!cmtfile) {
|
|
|
|
char *fn;
|
|
|
|
showcursor (core, true);
|
2015-11-18 22:32:18 +00:00
|
|
|
fn = r_cons_input ("<comment-file> ");
|
2015-11-18 12:03:35 +00:00
|
|
|
showcursor (core, false);
|
|
|
|
if (fn && *fn) {
|
|
|
|
cmtfile = strdup (fn);
|
|
|
|
if (!comment || !*comment) {
|
2015-11-18 16:02:42 +00:00
|
|
|
comment = r_str_newf (",(%s)", fn);
|
2015-11-18 12:03:35 +00:00
|
|
|
r_meta_set_string (core->anal, R_META_TYPE_COMMENT, addr, comment);
|
|
|
|
} else {
|
|
|
|
// append filename in current comment
|
2015-11-18 16:02:42 +00:00
|
|
|
char *nc = r_str_newf ("%s ,(%s)", comment, fn);
|
2015-11-18 12:03:35 +00:00
|
|
|
r_meta_set_string (core->anal, R_META_TYPE_COMMENT, addr, nc);
|
|
|
|
free (nc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free (fn);
|
|
|
|
}
|
|
|
|
if (cmtfile) {
|
|
|
|
char *cwf = r_str_newf ("%s"R_SYS_DIR"%s", cwd, cmtfile);
|
|
|
|
char *odata = r_file_slurp (cwf, NULL);
|
|
|
|
char *data = r_core_editor (core, NULL, odata);
|
|
|
|
r_file_dump (cwf, (const ut8*)data, -1, 0);
|
|
|
|
free (data);
|
|
|
|
free (odata);
|
|
|
|
free (cwf);
|
|
|
|
} else {
|
2015-11-18 16:02:42 +00:00
|
|
|
eprintf ("No commafile found.\n");
|
2015-11-18 12:03:35 +00:00
|
|
|
}
|
|
|
|
free (comment);
|
|
|
|
}
|
|
|
|
|
2015-12-14 23:37:33 +00:00
|
|
|
static bool isDisasmPrint(int mode) {
|
|
|
|
return (mode == 1 || mode == 2);
|
|
|
|
}
|
|
|
|
|
2016-02-10 23:10:48 +00:00
|
|
|
static void cursor_ocur(RCore *core, bool use_ocur) {
|
|
|
|
RPrint *p = core->print;
|
|
|
|
|
|
|
|
if (use_ocur && p->ocur == -1) {
|
|
|
|
p->ocur = p->cur;
|
|
|
|
} else if (!use_ocur) {
|
|
|
|
p->ocur = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cursor_nextrow(RCore *core, bool use_ocur) {
|
|
|
|
RPrint *p = core->print;
|
|
|
|
ut32 roff, next_roff;
|
|
|
|
int row, sz, delta;
|
|
|
|
RAsmOp op;
|
|
|
|
|
|
|
|
cursor_ocur (core, use_ocur);
|
2016-02-25 10:35:59 +00:00
|
|
|
if (PIDX == 2) {
|
|
|
|
if (core->seltab == 1) {
|
|
|
|
const int cols = core->dbg->regcols;
|
|
|
|
p->cur += cols>0? cols: 3;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2016-02-10 23:10:48 +00:00
|
|
|
|
|
|
|
if (p->row_offsets != NULL) {
|
|
|
|
// FIXME: cache the current row
|
|
|
|
row = r_print_row_at_off (p, p->cur);
|
|
|
|
roff = r_print_rowoff (p, row);
|
|
|
|
if (roff == -1) {
|
|
|
|
p->cur++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
next_roff = r_print_rowoff (p, row + 1);
|
|
|
|
if (next_roff == -1) {
|
|
|
|
p->cur++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
sz = r_asm_disassemble (core->assembler, &op,
|
|
|
|
core->block + next_roff, 32);
|
|
|
|
if (sz < 1) sz = 1;
|
|
|
|
delta = p->cur - roff;
|
|
|
|
p->cur = next_roff + R_MIN (delta, sz - 1);
|
|
|
|
} else {
|
|
|
|
p->cur += R_MAX (1, p->cols);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cursor_prevrow(RCore *core, bool use_ocur) {
|
|
|
|
RPrint *p = core->print;
|
|
|
|
int row;
|
|
|
|
ut32 roff, prev_roff;
|
|
|
|
|
2016-02-25 10:35:59 +00:00
|
|
|
if (PIDX == 2) {
|
|
|
|
if (core->seltab == 1) {
|
|
|
|
const int cols = core->dbg->regcols;
|
|
|
|
p->cur -= cols>0? cols: 4;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2016-02-10 23:10:48 +00:00
|
|
|
cursor_ocur (core, use_ocur);
|
|
|
|
|
|
|
|
if (p->row_offsets != NULL) {
|
|
|
|
int delta, prev_sz;
|
|
|
|
|
|
|
|
// FIXME: cache the current row
|
|
|
|
row = r_print_row_at_off (p, p->cur);
|
|
|
|
roff = r_print_rowoff (p, row);
|
|
|
|
if (roff == UT32_MAX) {
|
|
|
|
p->cur--;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
prev_roff = row > 0 ? r_print_rowoff (p, row - 1) : UT32_MAX;
|
|
|
|
delta = p->cur - roff;
|
|
|
|
if (prev_roff == UT32_MAX) {
|
2016-02-10 23:18:09 +00:00
|
|
|
ut64 prev_addr = prevop_addr (core, core->offset + roff);
|
|
|
|
RAsmOp op;
|
|
|
|
|
2016-02-10 23:10:48 +00:00
|
|
|
prev_roff = 0;
|
2016-02-10 23:18:09 +00:00
|
|
|
r_core_seek (core, prev_addr, 1);
|
|
|
|
prev_sz = r_asm_disassemble (core->assembler, &op,
|
|
|
|
core->block, 32);
|
2016-02-10 23:10:48 +00:00
|
|
|
} else {
|
|
|
|
prev_sz = roff - prev_roff;
|
|
|
|
}
|
|
|
|
p->cur = prev_roff + R_MIN (delta, prev_sz - 1);
|
|
|
|
} else {
|
|
|
|
p->cur -= p->cols;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cursor_left(RCore *core, bool use_ocur) {
|
2016-02-25 10:35:59 +00:00
|
|
|
if (PIDX == 2) {
|
|
|
|
if (core->seltab == 1) {
|
|
|
|
|
|
|
|
core->print->cur--;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2016-02-10 23:10:48 +00:00
|
|
|
cursor_ocur (core, use_ocur);
|
|
|
|
core->print->cur--;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cursor_right(RCore *core, bool use_ocur) {
|
2016-02-25 10:35:59 +00:00
|
|
|
if (PIDX == 2) {
|
|
|
|
if (core->seltab == 1) {
|
|
|
|
core->print->cur++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2016-02-10 23:10:48 +00:00
|
|
|
cursor_ocur (core, use_ocur);
|
|
|
|
core->print->cur++;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool fix_cursor(RCore *core) {
|
|
|
|
RPrint *p = core->print;
|
|
|
|
int offscreen = (core->cons->rows - 3) * p->cols;
|
|
|
|
bool res = false;
|
|
|
|
|
|
|
|
if (core->screen_bounds > 1) {
|
|
|
|
bool off_is_visible = core->offset < core->screen_bounds;
|
|
|
|
bool cur_is_visible = core->offset + p->cur < core->screen_bounds;
|
|
|
|
bool is_close = core->offset + p->cur < core->screen_bounds + 32;
|
|
|
|
|
|
|
|
if (!cur_is_visible && !is_close) {
|
|
|
|
// when the cursor is not visible and it's far from the
|
|
|
|
// last visible byte, just seek there.
|
|
|
|
r_core_seek (core, core->offset + p->cur, 1);
|
|
|
|
p->cur = 0;
|
|
|
|
p->ocur = -1;
|
|
|
|
} else if ((!cur_is_visible && is_close) || !off_is_visible) {
|
|
|
|
RAsmOp op;
|
|
|
|
int sz = r_asm_disassemble (core->assembler,
|
|
|
|
&op, core->block, 32);
|
|
|
|
if (sz < 1) sz = 1;
|
|
|
|
r_core_seek (core, core->offset + sz, 1);
|
|
|
|
p->cur = R_MAX (p->cur - sz, 0);
|
|
|
|
if (p->ocur != -1) p->ocur = R_MAX (p->ocur - sz, 0);
|
|
|
|
res |= off_is_visible;
|
|
|
|
}
|
|
|
|
} else if (core->print->cur >= offscreen) {
|
|
|
|
r_core_seek (core, core->offset + p->cols, 1);
|
|
|
|
p->cur -= p->cols;
|
|
|
|
if (p->ocur != -1) p->ocur -= p->cols;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p->cur < 0) {
|
|
|
|
int sz = p->cols;
|
|
|
|
|
|
|
|
if (isDisasmPrint (core->printidx)) {
|
|
|
|
sz = prevopsz (core, core->offset + p->cur);
|
|
|
|
if (sz < 1) sz = 1;
|
|
|
|
}
|
|
|
|
r_core_seek_delta (core, -sz);
|
|
|
|
p->cur += sz;
|
|
|
|
if (p->ocur != -1) p->ocur += sz;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2010-03-08 11:45:22 +00:00
|
|
|
R_API int r_core_visual_cmd(RCore *core, int ch) {
|
2011-02-24 15:50:29 +00:00
|
|
|
RAsmOp op;
|
2014-01-29 23:55:34 +00:00
|
|
|
ut64 offset = core->offset;
|
2011-03-01 23:02:50 +00:00
|
|
|
char buf[4096];
|
2015-06-12 00:19:58 +00:00
|
|
|
const char *key_s;
|
2016-02-10 23:10:48 +00:00
|
|
|
int i, ret, cols = core->print->cols, delta = 0;
|
2015-02-10 23:13:04 +00:00
|
|
|
int wheelspeed;
|
2010-06-17 15:55:39 +00:00
|
|
|
ch = r_cons_arrow_to_hjkl (ch);
|
2012-09-28 00:20:52 +00:00
|
|
|
ch = visual_nkey (core, ch);
|
2011-06-05 22:16:11 +00:00
|
|
|
if (ch<2) return 1;
|
2015-04-07 14:25:14 +00:00
|
|
|
|
2015-02-10 23:13:04 +00:00
|
|
|
if (r_cons_singleton()->mouse_event) {
|
|
|
|
wheelspeed = r_config_get_i (core->config, "scr.wheelspeed");
|
|
|
|
} else {
|
|
|
|
wheelspeed = 1;
|
|
|
|
}
|
2009-02-09 00:54:09 +00:00
|
|
|
|
2010-06-17 15:55:39 +00:00
|
|
|
// do we need hotkeys for data references? not only calls?
|
2015-10-08 18:00:31 +00:00
|
|
|
if (ch >= '0'&& ch <= '9') {
|
|
|
|
char chbuf[2];
|
|
|
|
ut64 off;
|
|
|
|
|
|
|
|
chbuf[0] = ch;
|
|
|
|
chbuf[1] = '\0';
|
|
|
|
off = r_core_get_asmqjmps (core, chbuf);
|
2013-10-13 23:12:09 +00:00
|
|
|
if (off != UT64_MAX) {
|
2014-01-29 23:55:34 +00:00
|
|
|
int delta = R_ABS ((st64)off-(st64)offset);
|
|
|
|
r_io_sundo_push (core->io, offset);
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->cur_enabled && delta<100) {
|
|
|
|
core->print->cur = delta;
|
2013-10-13 23:12:09 +00:00
|
|
|
} else {
|
2013-10-19 22:25:37 +00:00
|
|
|
r_core_visual_seek_animation (core, off);
|
2016-02-07 16:06:39 +00:00
|
|
|
core->print->cur = 0;
|
2013-10-13 23:12:09 +00:00
|
|
|
}
|
|
|
|
r_core_block_read (core, 1);
|
2013-10-08 22:29:49 +00:00
|
|
|
}
|
2010-05-19 22:59:42 +00:00
|
|
|
} else
|
|
|
|
switch (ch) {
|
2015-04-07 14:25:14 +00:00
|
|
|
#if __WINDOWS__ && !__CYGWIN__
|
2015-04-07 13:23:03 +00:00
|
|
|
case 0xf5:
|
|
|
|
SetWindow(81,25);
|
|
|
|
break;
|
|
|
|
case 0xcf5:
|
|
|
|
SetWindow(81,40);
|
|
|
|
break;
|
2015-04-07 14:25:14 +00:00
|
|
|
#endif
|
2015-11-19 11:23:10 +00:00
|
|
|
case 0x0d: // "enter" "\\n" "newline"
|
2014-02-07 13:54:31 +00:00
|
|
|
{
|
2015-02-10 23:13:04 +00:00
|
|
|
RAnalOp *op;
|
2014-09-03 21:55:09 +00:00
|
|
|
int wheel = r_config_get_i (core->config, "scr.wheel");
|
|
|
|
if (wheel)
|
2015-09-14 10:35:38 +00:00
|
|
|
r_cons_enable_mouse (true);
|
2015-02-10 23:13:04 +00:00
|
|
|
do {
|
2016-02-07 16:06:39 +00:00
|
|
|
op = r_core_anal_op (core, core->offset + core->print->cur);
|
2015-02-10 23:13:04 +00:00
|
|
|
if (op) {
|
|
|
|
if (op->type == R_ANAL_OP_TYPE_JMP ||
|
|
|
|
op->type == R_ANAL_OP_TYPE_CJMP ||
|
|
|
|
op->type == R_ANAL_OP_TYPE_CALL ||
|
|
|
|
op->type == R_ANAL_OP_TYPE_CCALL) {
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->cur_enabled) {
|
2014-09-23 11:32:51 +00:00
|
|
|
int delta = R_ABS ((st64)op->jump-(st64)offset);
|
2016-02-09 23:26:24 +00:00
|
|
|
if ( op->jump < core->offset || op->jump >= core->screen_bounds) {
|
2014-09-23 11:32:51 +00:00
|
|
|
r_io_sundo_push (core->io, offset);
|
|
|
|
r_core_visual_seek_animation (core, op->jump);
|
2016-02-07 16:06:39 +00:00
|
|
|
core->print->cur = 0;
|
2014-09-23 11:32:51 +00:00
|
|
|
} else {
|
2016-02-07 16:06:39 +00:00
|
|
|
core->print->cur = delta;
|
2014-09-23 11:32:51 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
r_io_sundo_push (core->io, offset);
|
2015-02-10 23:13:04 +00:00
|
|
|
r_core_visual_seek_animation (core, op->jump);
|
2014-09-23 11:32:51 +00:00
|
|
|
}
|
2014-02-07 13:54:31 +00:00
|
|
|
}
|
2015-02-10 23:13:04 +00:00
|
|
|
}
|
|
|
|
r_anal_op_free (op);
|
|
|
|
} while (--wheelspeed>0);
|
2014-02-07 13:54:31 +00:00
|
|
|
}
|
|
|
|
break;
|
2012-08-13 02:33:01 +00:00
|
|
|
case 9: // tab
|
2016-02-25 09:28:54 +00:00
|
|
|
core->curtab = 0;
|
|
|
|
if (core->printidx == 2) {
|
|
|
|
core->print->cur = 0;
|
|
|
|
core->seltab ++;
|
|
|
|
if (core->seltab>2) {
|
|
|
|
core->seltab = 0;
|
|
|
|
}
|
2012-08-13 02:33:01 +00:00
|
|
|
} else {
|
2016-02-25 09:28:54 +00:00
|
|
|
core->seltab = 0;
|
|
|
|
ut64 f = r_config_get_i (core->config, "diff.from");
|
|
|
|
ut64 t = r_config_get_i (core->config, "diff.to");
|
|
|
|
if (f == t && f == 0) {
|
|
|
|
core->print->col = core->print->col==1? 2: 1;
|
|
|
|
} else {
|
|
|
|
ut64 delta = offset - f;
|
|
|
|
r_core_seek (core, t+delta, 1);
|
|
|
|
r_config_set_i (core->config, "diff.from", t);
|
|
|
|
r_config_set_i (core->config, "diff.to", f);
|
|
|
|
}
|
2012-08-13 02:33:01 +00:00
|
|
|
}
|
2012-06-07 01:41:21 +00:00
|
|
|
break;
|
2013-08-21 22:08:08 +00:00
|
|
|
case 'a':
|
2014-10-08 11:27:33 +00:00
|
|
|
if (core->file && core->file->desc && !(core->file->desc->flags & 2)) {
|
2013-08-21 22:08:08 +00:00
|
|
|
r_cons_printf ("\nFile has been opened in read-only mode. Use -w flag\n");
|
2015-03-05 22:33:28 +00:00
|
|
|
r_cons_any_key (NULL);
|
2015-09-14 10:35:38 +00:00
|
|
|
return true;
|
2013-08-21 22:08:08 +00:00
|
|
|
}
|
|
|
|
r_cons_printf ("Enter assembler opcodes separated with ';':\n");
|
2015-09-14 10:35:38 +00:00
|
|
|
showcursor (core, true);
|
2013-08-21 22:08:08 +00:00
|
|
|
r_cons_flush ();
|
2015-09-14 10:35:38 +00:00
|
|
|
r_cons_set_raw (false);
|
2013-08-21 22:08:08 +00:00
|
|
|
strcpy (buf, "wa ");
|
|
|
|
r_line_set_prompt (":> ");
|
|
|
|
if (r_cons_fgets (buf+3, 1000, 0, NULL) <0) buf[0]='\0';
|
|
|
|
if (*buf) {
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->cur_enabled) {
|
|
|
|
int t = core->offset + core->print->cur;
|
|
|
|
r_core_seek (core, t, 0);
|
|
|
|
}
|
2015-09-14 10:35:38 +00:00
|
|
|
r_core_cmd (core, buf, true);
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->cur_enabled) {
|
|
|
|
int t = core->offset - core->print->cur;
|
|
|
|
r_core_seek (core, t, 1);
|
|
|
|
}
|
2013-08-21 22:08:08 +00:00
|
|
|
}
|
2015-09-14 10:35:38 +00:00
|
|
|
showcursor (core, false);
|
|
|
|
r_cons_set_raw (true);
|
2013-08-21 22:08:08 +00:00
|
|
|
break;
|
2014-10-06 00:36:22 +00:00
|
|
|
case '=':
|
|
|
|
{ // TODO: edit
|
2015-01-30 23:50:05 +00:00
|
|
|
const char *buf = NULL;
|
2014-10-06 00:36:22 +00:00
|
|
|
#define I core->cons
|
|
|
|
const char *cmd = r_config_get (core->config, "cmd.vprompt");
|
|
|
|
r_line_set_prompt ("cmd.vprompt> ");
|
|
|
|
I->line->contents = strdup (cmd);
|
|
|
|
buf = r_line_readline ();
|
|
|
|
// if (r_cons_fgets (buf, sizeof (buf)-4, 0, NULL) <0) buf[0]='\0';
|
|
|
|
I->line->contents = NULL;
|
|
|
|
r_config_set (core->config, "cmd.vprompt", buf);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '|':
|
|
|
|
{ // TODO: edit
|
2015-01-30 23:50:05 +00:00
|
|
|
const char *buf = NULL;
|
2014-10-06 00:36:22 +00:00
|
|
|
#define I core->cons
|
|
|
|
const char *cmd = r_config_get (core->config, "cmd.cprompt");
|
|
|
|
r_line_set_prompt ("cmd.cprompt> ");
|
|
|
|
I->line->contents = strdup (cmd);
|
|
|
|
buf = r_line_readline ();
|
|
|
|
// if (r_cons_fgets (buf, sizeof (buf)-4, 0, NULL) <0) buf[0]='\0';
|
|
|
|
I->line->contents = NULL;
|
|
|
|
r_config_set (core->config, "cmd.cprompt", buf);
|
|
|
|
}
|
|
|
|
break;
|
2014-03-31 01:05:48 +00:00
|
|
|
case '!':
|
2015-03-05 22:33:28 +00:00
|
|
|
r_core_visual_panels (core);
|
2014-03-31 01:05:48 +00:00
|
|
|
break;
|
2014-02-10 02:31:12 +00:00
|
|
|
case 'o':
|
|
|
|
visual_offset (core);
|
|
|
|
break;
|
2013-08-21 22:08:08 +00:00
|
|
|
case 'A':
|
2016-02-07 16:06:39 +00:00
|
|
|
{
|
|
|
|
int oc = core->print->cur_enabled;
|
|
|
|
ut64 off = oc ? core->offset + core->print->cur : core->offset;
|
|
|
|
core->print->cur_enabled = 0;
|
2013-08-21 22:08:08 +00:00
|
|
|
r_core_visual_asm (core, off);
|
2016-02-07 16:06:39 +00:00
|
|
|
core->print->cur_enabled = oc;
|
2013-08-21 22:08:08 +00:00
|
|
|
}
|
|
|
|
break;
|
2009-02-09 00:54:09 +00:00
|
|
|
case 'c':
|
2016-02-07 16:06:39 +00:00
|
|
|
setcursor (core, !core->print->cur_enabled);
|
2010-05-19 22:59:42 +00:00
|
|
|
break;
|
2014-09-27 01:48:54 +00:00
|
|
|
case '@':
|
2015-05-18 22:11:04 +00:00
|
|
|
visual_repeat (core);
|
2014-09-27 01:48:54 +00:00
|
|
|
break;
|
2013-08-21 22:08:08 +00:00
|
|
|
case 'C':
|
|
|
|
color = color? 0: 1;
|
|
|
|
r_config_set_i (core->config, "scr.color", color);
|
|
|
|
break;
|
2010-05-19 22:59:42 +00:00
|
|
|
case 'd':
|
2014-10-20 23:20:06 +00:00
|
|
|
{
|
|
|
|
int wheel = r_config_get_i (core->config, "scr.wheel");
|
2015-09-14 10:35:38 +00:00
|
|
|
if (wheel) r_cons_enable_mouse (false);
|
2014-10-20 23:20:06 +00:00
|
|
|
r_core_visual_define (core);
|
2015-09-14 10:35:38 +00:00
|
|
|
if (wheel) r_cons_enable_mouse (true);
|
2014-10-20 23:20:06 +00:00
|
|
|
}
|
2009-02-09 00:54:09 +00:00
|
|
|
break;
|
2012-08-13 02:33:01 +00:00
|
|
|
case 'D':
|
|
|
|
setdiff (core);
|
|
|
|
break;
|
2011-03-01 23:02:50 +00:00
|
|
|
case 'f':
|
2012-09-28 00:20:52 +00:00
|
|
|
{
|
2013-10-15 01:56:01 +00:00
|
|
|
int range, min, max;
|
2012-09-28 00:20:52 +00:00
|
|
|
char name[256], *n;
|
|
|
|
r_line_set_prompt ("flag name: ");
|
2015-09-14 10:35:38 +00:00
|
|
|
showcursor (core, true);
|
2012-09-28 00:20:52 +00:00
|
|
|
if (r_cons_fgets (name, sizeof (name), 0, NULL) >=0 && *name) {
|
|
|
|
n = r_str_chop (name);
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->ocur != -1) {
|
|
|
|
min = R_MIN (core->print->cur, core->print->ocur);
|
|
|
|
max = R_MAX (core->print->cur, core->print->ocur);
|
2013-03-03 23:33:14 +00:00
|
|
|
} else {
|
2016-02-07 16:06:39 +00:00
|
|
|
min = max = core->print->cur;
|
2014-09-23 07:35:37 +00:00
|
|
|
}
|
|
|
|
range = max-min+1;
|
2015-02-17 00:02:00 +00:00
|
|
|
if (!strcmp (n, "-")) {
|
2016-02-20 14:25:27 +00:00
|
|
|
r_flag_unset_off (core->flags, core->offset + core->print->cur);
|
2015-02-17 00:02:00 +00:00
|
|
|
} else if (*n=='.') {
|
2014-09-23 07:35:37 +00:00
|
|
|
if (n[1]=='-') {
|
|
|
|
//unset
|
|
|
|
r_core_cmdf (core, "f.-%s@0x%"PFMT64x, n+1, core->offset+min);
|
2013-10-15 01:56:01 +00:00
|
|
|
} else {
|
2014-09-23 07:35:37 +00:00
|
|
|
r_core_cmdf (core, "f.%s@0x%"PFMT64x, n+1, core->offset+min);
|
2013-10-15 01:56:01 +00:00
|
|
|
}
|
2015-02-17 00:02:00 +00:00
|
|
|
} else if (*n=='-') {
|
2016-02-20 14:25:27 +00:00
|
|
|
if (*n) r_flag_unset_name (core->flags, n+1);
|
2014-09-23 07:35:37 +00:00
|
|
|
} else {
|
2013-03-03 23:33:14 +00:00
|
|
|
if (range<1) range = 1;
|
|
|
|
if (*n) r_flag_set (core->flags, n,
|
2016-02-20 14:38:46 +00:00
|
|
|
core->offset + min, range);
|
2013-03-03 23:33:14 +00:00
|
|
|
}
|
|
|
|
} }
|
2015-09-14 10:35:38 +00:00
|
|
|
showcursor (core, false);
|
2011-03-01 23:02:50 +00:00
|
|
|
break;
|
2015-11-18 12:03:35 +00:00
|
|
|
case ',':
|
|
|
|
visual_comma (core);
|
|
|
|
break;
|
2014-08-28 01:11:13 +00:00
|
|
|
case 'T':
|
2014-08-28 01:41:23 +00:00
|
|
|
if (r_sandbox_enable (0)) {
|
|
|
|
eprintf ("sandbox not enabled\n");
|
|
|
|
} else {
|
|
|
|
if (r_config_get_i (core->config, "scr.interactive"))
|
|
|
|
r_core_cmd0 (core, "TT");
|
|
|
|
}
|
2014-08-28 01:11:13 +00:00
|
|
|
break;
|
2012-09-28 00:20:52 +00:00
|
|
|
case 'n':
|
|
|
|
r_core_seek_next (core, r_config_get (core->config, "scr.nkey"));
|
|
|
|
break;
|
|
|
|
case 'N':
|
|
|
|
r_core_seek_previous (core, r_config_get (core->config, "scr.nkey"));
|
2011-03-01 23:02:50 +00:00
|
|
|
break;
|
2012-06-07 01:41:21 +00:00
|
|
|
case 'i':
|
2013-02-25 08:36:07 +00:00
|
|
|
case 'I':
|
2016-02-25 10:35:59 +00:00
|
|
|
if (PIDX == 2 && core->seltab == 1) {
|
|
|
|
char buf[128];
|
|
|
|
prompt_read ("new-reg-value> ", buf, sizeof (buf));
|
|
|
|
if (*buf) {
|
|
|
|
const char *creg = core->dbg->creg;
|
|
|
|
if (creg) {
|
|
|
|
r_core_cmdf (core, "dr %s = %s\n", creg, buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2014-10-08 11:27:33 +00:00
|
|
|
if (core->file && core->file->desc &&!(core->file->desc->flags & 2)) {
|
2012-07-06 00:17:44 +00:00
|
|
|
r_cons_printf ("\nFile has been opened in read-only mode. Use -w flag\n");
|
2015-03-05 22:33:28 +00:00
|
|
|
r_cons_any_key (NULL);
|
2015-09-14 10:35:38 +00:00
|
|
|
return true;
|
2012-07-06 00:17:44 +00:00
|
|
|
}
|
2015-09-14 10:35:38 +00:00
|
|
|
showcursor (core, true);
|
2010-02-02 10:09:52 +00:00
|
|
|
r_cons_flush ();
|
|
|
|
r_cons_set_raw (0);
|
2013-02-25 08:36:07 +00:00
|
|
|
if (ch=='I') {
|
2012-11-07 03:25:42 +00:00
|
|
|
strcpy (buf, "wow ");
|
2013-02-25 08:36:07 +00:00
|
|
|
r_line_set_prompt ("insert hexpair block: ");
|
2014-04-26 00:12:09 +00:00
|
|
|
if (r_cons_fgets (buf+4, sizeof (buf)-5, 0, NULL) <0)
|
2012-11-07 03:25:42 +00:00
|
|
|
buf[0]='\0';
|
2013-02-25 08:36:07 +00:00
|
|
|
char *p = strdup (buf);
|
|
|
|
int cur = core->print->cur;
|
|
|
|
if (cur>=core->blocksize)
|
|
|
|
cur = core->print->cur-1;
|
|
|
|
snprintf (buf, sizeof (buf), "%s @ $$0!%i", p,
|
2016-02-07 16:06:39 +00:00
|
|
|
core->blocksize-core->print->cur);
|
2013-02-25 08:36:07 +00:00
|
|
|
r_core_cmd (core, buf, 0);
|
|
|
|
free (p);
|
|
|
|
break;
|
|
|
|
}
|
2016-02-07 16:06:39 +00:00
|
|
|
delta = (core->print->ocur!=-1)? R_MIN (core->print->cur, core->print->ocur): core->print->cur;
|
2012-06-07 01:41:21 +00:00
|
|
|
if (core->print->col==2) {
|
2013-11-13 01:31:35 +00:00
|
|
|
strcpy (buf, "\"w ");
|
2012-06-07 01:41:21 +00:00
|
|
|
r_line_set_prompt ("insert string: ");
|
2013-11-13 01:31:35 +00:00
|
|
|
if (r_cons_fgets (buf+3, sizeof (buf)-4, 0, NULL) <0)
|
2012-06-07 01:41:21 +00:00
|
|
|
buf[0]='\0';
|
2013-11-13 01:31:35 +00:00
|
|
|
strcat (buf, "\"");
|
2012-06-07 01:41:21 +00:00
|
|
|
} else {
|
|
|
|
r_line_set_prompt ("insert hex: ");
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->ocur != -1) {
|
|
|
|
int bs = R_ABS (core->print->cur-core->print->ocur)+1;
|
2014-01-29 23:55:34 +00:00
|
|
|
core->blocksize = bs;
|
|
|
|
strcpy (buf, "wow ");
|
|
|
|
} else {
|
|
|
|
strcpy (buf, "wx ");
|
|
|
|
}
|
|
|
|
if (r_cons_fgets (buf+strlen (buf), sizeof (buf)-strlen (buf), 0, NULL) <0)
|
2012-06-07 01:41:21 +00:00
|
|
|
buf[0]='\0';
|
|
|
|
}
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->cur_enabled) r_core_seek (core, core->offset + delta, 0);
|
2013-02-25 08:36:07 +00:00
|
|
|
r_core_cmd (core, buf, 1);
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->cur_enabled) r_core_seek (core, offset, 1);
|
2011-06-04 01:14:04 +00:00
|
|
|
r_cons_set_raw (1);
|
2015-09-14 10:35:38 +00:00
|
|
|
showcursor (core, false);
|
2009-04-07 00:26:41 +00:00
|
|
|
break;
|
2013-09-30 02:23:58 +00:00
|
|
|
case 'R':
|
|
|
|
r_core_cmd0 (core, "ecr");
|
|
|
|
break;
|
2009-04-02 01:23:45 +00:00
|
|
|
case 'e':
|
2010-05-19 22:59:42 +00:00
|
|
|
r_core_visual_config (core);
|
2009-04-02 01:23:45 +00:00
|
|
|
break;
|
2013-07-17 01:51:53 +00:00
|
|
|
case 'E':
|
|
|
|
r_core_visual_colors (core);
|
|
|
|
break;
|
2011-07-11 20:52:05 +00:00
|
|
|
case 'M':
|
|
|
|
r_core_visual_mounts (core);
|
|
|
|
break;
|
2014-06-25 01:07:54 +00:00
|
|
|
case '&':
|
|
|
|
switch (core->assembler->bits) {
|
|
|
|
case 8:
|
|
|
|
r_config_set_i (core->config, "asm.bits", 16);
|
|
|
|
if (core->assembler->bits!=16) {
|
|
|
|
r_config_set_i (core->config, "asm.bits", 32);
|
|
|
|
if (core->assembler->bits!=32) {
|
|
|
|
r_config_set_i (core->config, "asm.bits", 64);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
r_config_set_i (core->config, "asm.bits", 32);
|
|
|
|
if (core->assembler->bits!=32) {
|
|
|
|
r_config_set_i (core->config, "asm.bits", 64);
|
|
|
|
if (core->assembler->bits!=64) {
|
|
|
|
r_config_set_i (core->config, "asm.bits", 8);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
r_config_set_i (core->config, "asm.bits", 64);
|
|
|
|
if (core->assembler->bits!=64) {
|
|
|
|
r_config_set_i (core->config, "asm.bits", 8);
|
|
|
|
if (core->assembler->bits!=8) {
|
|
|
|
r_config_set_i (core->config, "asm.bits", 16);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 64:
|
|
|
|
r_config_set_i (core->config, "asm.bits", 8);
|
|
|
|
if (core->assembler->bits!=8) {
|
|
|
|
r_config_set_i (core->config, "asm.bits", 16);
|
|
|
|
if (core->assembler->bits!=16) {
|
|
|
|
r_config_set_i (core->config, "asm.bits", 32);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2015-03-17 00:29:28 +00:00
|
|
|
case 't':
|
|
|
|
r_core_visual_types (core);
|
|
|
|
break;
|
2015-10-12 14:11:19 +00:00
|
|
|
case 'B':
|
|
|
|
r_core_visual_classes (core);
|
|
|
|
break;
|
2015-02-17 00:02:00 +00:00
|
|
|
case 'F':
|
2010-05-19 22:59:42 +00:00
|
|
|
r_core_visual_trackflags (core);
|
2009-04-02 00:44:24 +00:00
|
|
|
break;
|
2011-11-24 22:50:15 +00:00
|
|
|
case 'x':
|
2014-08-05 03:37:48 +00:00
|
|
|
r_core_visual_xrefs_x (core);
|
2014-05-25 01:28:54 +00:00
|
|
|
break;
|
|
|
|
case 'X':
|
2014-08-05 03:37:48 +00:00
|
|
|
r_core_visual_xrefs_X (core);
|
2011-11-24 22:50:15 +00:00
|
|
|
break;
|
2014-08-28 01:11:13 +00:00
|
|
|
case 'r':
|
2011-11-23 01:29:09 +00:00
|
|
|
r_core_visual_comments (core);
|
|
|
|
break;
|
2015-08-30 22:55:41 +00:00
|
|
|
case ' ':
|
2012-08-14 01:21:31 +00:00
|
|
|
case 'V':
|
2014-04-29 01:53:48 +00:00
|
|
|
if (r_config_get_i (core->config, "graph.web")) {
|
|
|
|
r_core_cmd0 (core, "agv $$");
|
2014-11-07 08:56:39 +00:00
|
|
|
} else {
|
2015-08-30 22:55:41 +00:00
|
|
|
RAnalFunction *fun = r_anal_get_fcn_in (core->anal, core->offset, R_ANAL_FCN_TYPE_NULL);
|
2015-09-28 08:18:26 +00:00
|
|
|
int ocolor;
|
|
|
|
|
|
|
|
if (!fun) {
|
2015-08-30 22:55:41 +00:00
|
|
|
r_cons_message("Not in a function. Type 'df' to define it here");
|
2015-09-28 08:18:26 +00:00
|
|
|
break;
|
|
|
|
} else if (r_list_empty (fun->bbs)) {
|
|
|
|
r_cons_message("No basic blocks in this function. You may want to use 'afb+'.");
|
|
|
|
break;
|
2015-08-30 22:55:41 +00:00
|
|
|
}
|
2015-09-28 08:18:26 +00:00
|
|
|
ocolor = r_config_get_i (core->config, "scr.color");
|
2016-01-04 22:00:01 +00:00
|
|
|
r_core_visual_graph (core, NULL, NULL, true);
|
2015-09-28 08:18:26 +00:00
|
|
|
r_config_set_i (core->config, "scr.color", ocolor);
|
2014-11-07 08:56:39 +00:00
|
|
|
}
|
2012-08-14 01:21:31 +00:00
|
|
|
break;
|
2010-08-22 17:07:03 +00:00
|
|
|
case 'v':
|
|
|
|
r_core_visual_anal (core);
|
|
|
|
break;
|
2009-03-20 21:05:12 +00:00
|
|
|
case 'g':
|
2011-06-26 21:41:34 +00:00
|
|
|
if (core->io->va) {
|
|
|
|
ut64 offset = r_io_section_get_vaddr (core->io, 0);
|
2011-07-04 16:54:41 +00:00
|
|
|
if (offset == -1)
|
|
|
|
offset = 0;
|
2011-06-26 21:41:34 +00:00
|
|
|
r_core_seek (core, offset, 1);
|
2012-06-30 18:51:18 +00:00
|
|
|
} else r_core_seek (core, 0, 1);
|
2011-12-04 20:09:16 +00:00
|
|
|
r_io_sundo_push (core->io, core->offset);
|
2009-03-20 21:05:12 +00:00
|
|
|
break;
|
2015-08-28 18:58:21 +00:00
|
|
|
case 'G':
|
|
|
|
ret = 0;
|
2015-06-09 12:27:12 +00:00
|
|
|
int scols = r_config_get_i (core->config, "hex.cols");
|
2015-06-12 19:47:08 +00:00
|
|
|
if (core->file) {
|
|
|
|
if (core->io->va) {
|
|
|
|
ut64 offset = r_io_section_get_vaddr (core->io, 0);
|
|
|
|
if (offset == UT64_MAX) {
|
|
|
|
offset = r_io_desc_size (core->io,
|
|
|
|
core->file->desc)
|
|
|
|
- core->blocksize + 2*scols;
|
|
|
|
ret = r_core_seek (core, offset, 1);
|
|
|
|
} else {
|
|
|
|
offset += r_io_desc_size (core->io,
|
|
|
|
core->file->desc)
|
2015-11-23 15:24:36 +00:00
|
|
|
- core->blocksize + 2 * scols;
|
2015-06-12 19:47:08 +00:00
|
|
|
ret = r_core_seek (core, offset, 1);
|
|
|
|
}
|
2011-09-04 00:34:54 +00:00
|
|
|
} else {
|
2015-06-12 19:47:08 +00:00
|
|
|
ret = r_core_seek (core,
|
|
|
|
r_io_desc_size (core->io, core->file->desc)
|
2015-11-23 15:24:36 +00:00
|
|
|
- core->blocksize + 2 * scols, 1);
|
2011-09-04 00:34:54 +00:00
|
|
|
}
|
2012-06-30 18:51:18 +00:00
|
|
|
} else {
|
2015-06-12 19:47:08 +00:00
|
|
|
ret = -1;
|
2012-06-30 18:51:18 +00:00
|
|
|
}
|
2011-10-25 18:30:05 +00:00
|
|
|
if (ret != -1)
|
2011-12-04 20:09:16 +00:00
|
|
|
r_io_sundo_push (core->io, core->offset);
|
2009-03-20 21:05:12 +00:00
|
|
|
break;
|
2009-02-09 00:54:09 +00:00
|
|
|
case 'h':
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->cur_enabled) {
|
2016-02-10 23:10:48 +00:00
|
|
|
cursor_left (core, false);
|
2012-06-14 00:18:15 +00:00
|
|
|
} else r_core_seek_delta (core, -1);
|
2009-02-09 00:54:09 +00:00
|
|
|
break;
|
2011-02-04 23:20:28 +00:00
|
|
|
case 'H':
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->cur_enabled) {
|
2016-02-10 23:10:48 +00:00
|
|
|
cursor_left(core, true);
|
2012-06-14 00:18:15 +00:00
|
|
|
} else r_core_seek_delta (core, -2);
|
2011-02-04 23:20:28 +00:00
|
|
|
break;
|
2009-02-09 00:54:09 +00:00
|
|
|
case 'l':
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->cur_enabled) {
|
2016-02-10 23:10:48 +00:00
|
|
|
cursor_right (core, false);
|
2012-06-14 00:18:15 +00:00
|
|
|
} else r_core_seek_delta (core, 1);
|
2009-02-09 00:54:09 +00:00
|
|
|
break;
|
2011-02-04 23:20:28 +00:00
|
|
|
case 'L':
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->cur_enabled) {
|
2016-02-10 23:10:48 +00:00
|
|
|
cursor_right (core, true);
|
2012-06-14 00:18:15 +00:00
|
|
|
} else r_core_seek_delta (core, 2);
|
2010-05-19 00:39:01 +00:00
|
|
|
break;
|
2009-02-09 00:54:09 +00:00
|
|
|
case 'j':
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->cur_enabled) {
|
2016-02-10 23:10:48 +00:00
|
|
|
cursor_nextrow (core, false);
|
2011-01-27 00:12:02 +00:00
|
|
|
} else {
|
2016-02-21 00:56:50 +00:00
|
|
|
if (r_config_get_i (core->config, "scr.wheelnkey")) {
|
|
|
|
r_core_cmd0 (core, "sn");
|
|
|
|
} else {
|
|
|
|
int times = wheelspeed;
|
|
|
|
if (times<1) times = 1;
|
|
|
|
while (times--) {
|
|
|
|
if (isDisasmPrint(core->printidx)) {
|
|
|
|
RAnalFunction *f = NULL;
|
|
|
|
if (true) {
|
|
|
|
f = r_anal_get_fcn_in (core->anal, core->offset, 0);
|
|
|
|
}
|
|
|
|
if (f && f->folded) {
|
|
|
|
cols = core->offset - f->addr + f->size;
|
|
|
|
} else {
|
|
|
|
r_asm_set_pc (core->assembler, core->offset);
|
|
|
|
cols = r_asm_disassemble (core->assembler,
|
|
|
|
&op, core->block, 32);
|
|
|
|
}
|
|
|
|
if (cols<1) cols = op.size;
|
|
|
|
if (cols<1) cols = 1;
|
2015-12-14 09:19:07 +00:00
|
|
|
}
|
2016-02-21 00:56:50 +00:00
|
|
|
r_core_seek (core, core->offset + cols, 1);
|
2015-02-10 23:13:04 +00:00
|
|
|
}
|
2011-02-15 15:19:18 +00:00
|
|
|
}
|
2011-01-27 00:12:02 +00:00
|
|
|
}
|
2009-02-09 00:54:09 +00:00
|
|
|
break;
|
2011-02-04 23:20:28 +00:00
|
|
|
case 'J':
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->cur_enabled) {
|
2016-02-10 23:10:48 +00:00
|
|
|
cursor_nextrow (core, true);
|
2014-09-22 11:45:36 +00:00
|
|
|
} else {
|
2016-02-18 23:31:37 +00:00
|
|
|
if (core->screen_bounds > 1 && core->screen_bounds >= core->offset) {
|
2016-02-09 23:26:24 +00:00
|
|
|
r_core_seek (core, core->screen_bounds, 1);
|
2014-09-22 11:45:36 +00:00
|
|
|
} else {
|
2016-02-18 23:31:37 +00:00
|
|
|
r_core_seek (core, core->offset + obs, 1);
|
2014-09-22 11:45:36 +00:00
|
|
|
}
|
|
|
|
}
|
2011-02-04 23:20:28 +00:00
|
|
|
break;
|
2009-02-09 00:54:09 +00:00
|
|
|
case 'k':
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->cur_enabled) {
|
2016-02-10 23:10:48 +00:00
|
|
|
cursor_prevrow (core, false);
|
2011-01-27 00:12:02 +00:00
|
|
|
} else {
|
2016-02-21 00:56:50 +00:00
|
|
|
if (r_config_get_i (core->config, "scr.wheelnkey")) {
|
|
|
|
r_core_cmd0(core, "sp");
|
|
|
|
} else {
|
|
|
|
int times = wheelspeed;
|
|
|
|
if (times<1) times = 1;
|
|
|
|
while (times--) {
|
|
|
|
if (isDisasmPrint (core->printidx)) {
|
|
|
|
RAnalFunction *f = r_anal_get_fcn_in (core->anal, core->offset, R_ANAL_FCN_TYPE_NULL);
|
|
|
|
if (f && f->folded) {
|
|
|
|
cols = core->offset - f->addr; // + f->size;
|
|
|
|
if (cols<1) {
|
|
|
|
cols = 4;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
cols = prevopsz (core, core->offset);
|
2015-12-14 09:19:07 +00:00
|
|
|
}
|
|
|
|
}
|
2016-02-29 14:55:25 +00:00
|
|
|
r_core_seek_delta (core, -cols);
|
2015-12-18 18:53:54 +00:00
|
|
|
}
|
2011-02-15 11:31:32 +00:00
|
|
|
}
|
2011-01-27 00:12:02 +00:00
|
|
|
}
|
2009-02-09 00:54:09 +00:00
|
|
|
break;
|
2011-02-04 23:20:28 +00:00
|
|
|
case 'K':
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->cur_enabled) {
|
2016-02-10 23:10:48 +00:00
|
|
|
cursor_prevrow (core, true);
|
2011-03-02 13:11:34 +00:00
|
|
|
} else {
|
2016-02-09 23:26:24 +00:00
|
|
|
if (core->screen_bounds >= core->offset) {
|
|
|
|
int delta = (core->screen_bounds - core->offset);
|
|
|
|
if (core->offset >= delta)
|
|
|
|
r_core_seek (core, core->offset - delta, 1);
|
2015-04-15 22:25:32 +00:00
|
|
|
else
|
|
|
|
r_core_seek (core, 0, 1);
|
2014-09-22 11:45:36 +00:00
|
|
|
} else {
|
|
|
|
ut64 at = (core->offset>obs)?core->offset-obs:0;
|
2015-04-15 22:25:32 +00:00
|
|
|
if (core->offset >obs)
|
|
|
|
r_core_seek (core, at, 1);
|
|
|
|
else
|
|
|
|
r_core_seek (core, 0, 1);
|
2014-09-22 11:45:36 +00:00
|
|
|
}
|
2011-03-02 13:11:34 +00:00
|
|
|
}
|
2011-02-04 23:20:28 +00:00
|
|
|
break;
|
|
|
|
case '[':
|
|
|
|
{
|
2013-04-16 17:48:59 +00:00
|
|
|
int scrcols = r_config_get_i (core->config, "hex.cols");
|
2011-02-04 23:20:28 +00:00
|
|
|
if (scrcols>2)
|
2013-04-16 17:48:59 +00:00
|
|
|
r_config_set_i (core->config, "hex.cols", scrcols-2);
|
2011-02-04 23:20:28 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ']':
|
|
|
|
{
|
2013-04-16 17:48:59 +00:00
|
|
|
int scrcols = r_config_get_i (core->config, "hex.cols");
|
|
|
|
r_config_set_i (core->config, "hex.cols", scrcols+2);
|
2011-02-04 23:20:28 +00:00
|
|
|
}
|
|
|
|
break;
|
2013-02-25 08:36:07 +00:00
|
|
|
#if 0
|
2011-11-25 03:32:32 +00:00
|
|
|
case 'I':
|
|
|
|
r_core_cmd (core, "dsp", 0);
|
|
|
|
r_core_cmd (core, ".dr*", 0);
|
|
|
|
break;
|
2013-02-25 08:36:07 +00:00
|
|
|
#endif
|
2009-02-18 00:43:57 +00:00
|
|
|
case 's':
|
2015-06-12 00:19:58 +00:00
|
|
|
key_s = r_config_get (core->config, "key.s");
|
|
|
|
if (key_s && *key_s) {
|
|
|
|
r_core_cmd0 (core, key_s);
|
|
|
|
} else {
|
|
|
|
if (r_config_get_i (core->config, "cfg.debug")) {
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->cur_enabled) {
|
2015-06-12 00:19:58 +00:00
|
|
|
// dcu 0xaddr
|
2016-02-07 16:06:39 +00:00
|
|
|
r_core_cmdf (core, "dcu 0x%08"PFMT64x, core->offset + core->print->cur);
|
|
|
|
core->print->cur_enabled = 0;
|
2015-06-12 00:19:58 +00:00
|
|
|
} else {
|
|
|
|
r_core_cmd (core, "ds", 0);
|
|
|
|
r_core_cmd (core, ".dr*", 0);
|
|
|
|
}
|
2014-02-10 02:31:12 +00:00
|
|
|
} else {
|
2015-06-12 00:19:58 +00:00
|
|
|
r_core_cmd (core, "aes", 0);
|
|
|
|
r_core_cmd (core, ".ar*", 0);
|
2014-02-10 02:31:12 +00:00
|
|
|
}
|
2014-06-16 03:58:00 +00:00
|
|
|
}
|
2009-02-18 00:43:57 +00:00
|
|
|
break;
|
2010-05-24 15:51:51 +00:00
|
|
|
case 'S':
|
2015-06-12 00:19:58 +00:00
|
|
|
key_s = r_config_get (core->config, "key.S");
|
|
|
|
if (key_s && *key_s) {
|
|
|
|
r_core_cmd0 (core, key_s);
|
2012-05-30 09:14:41 +00:00
|
|
|
} else {
|
2015-06-12 00:19:58 +00:00
|
|
|
if (r_config_get_i (core->config, "cfg.debug")) {
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->cur_enabled) {
|
2015-06-12 00:19:58 +00:00
|
|
|
r_core_cmd (core, "dcr", 0);
|
2016-02-07 16:06:39 +00:00
|
|
|
core->print->cur_enabled = 0;
|
2015-06-12 00:19:58 +00:00
|
|
|
} else {
|
|
|
|
r_core_cmd (core, "dso", 0);
|
|
|
|
r_core_cmd (core, ".dr*", 0);
|
|
|
|
}
|
|
|
|
} else {
|
2015-11-23 15:24:36 +00:00
|
|
|
r_core_cmd (core, "aeso", 0);
|
2015-06-12 00:19:58 +00:00
|
|
|
r_core_cmd (core, ".ar*", 0);
|
|
|
|
}
|
2012-05-30 09:14:41 +00:00
|
|
|
}
|
2010-05-24 15:51:51 +00:00
|
|
|
break;
|
2009-02-09 00:54:09 +00:00
|
|
|
case 'p':
|
2013-12-02 02:53:29 +00:00
|
|
|
setprintmode (core, 1);
|
2009-02-09 00:54:09 +00:00
|
|
|
break;
|
|
|
|
case 'P':
|
2013-12-02 02:53:29 +00:00
|
|
|
setprintmode (core, -1);
|
2009-02-09 00:54:09 +00:00
|
|
|
break;
|
2015-02-12 23:36:05 +00:00
|
|
|
case '%':
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->cur_enabled) {
|
2015-02-12 23:36:05 +00:00
|
|
|
findPair (core);
|
|
|
|
} else {
|
|
|
|
/* do nothing? */
|
2015-02-13 10:06:27 +00:00
|
|
|
autoblocksize = !autoblocksize;
|
|
|
|
if (autoblocksize)
|
|
|
|
obs = core->blocksize;
|
|
|
|
else r_core_block_size (core, obs);
|
|
|
|
r_cons_clear ();
|
2015-02-12 23:36:05 +00:00
|
|
|
}
|
|
|
|
break;
|
2015-02-13 10:06:27 +00:00
|
|
|
case 'w':
|
|
|
|
findNextWord (core);
|
|
|
|
break;
|
|
|
|
case 'W':
|
|
|
|
findPrevWord (core);
|
|
|
|
//r_core_cmd0 (core, "=H");
|
|
|
|
break;
|
2009-02-18 00:43:57 +00:00
|
|
|
case 'm':
|
2011-09-04 00:34:54 +00:00
|
|
|
r_core_visual_mark (core, r_cons_readchar ());
|
2009-02-18 00:43:57 +00:00
|
|
|
break;
|
|
|
|
case '\'':
|
2011-09-04 00:34:54 +00:00
|
|
|
r_core_visual_mark_seek (core, r_cons_readchar ());
|
2009-02-18 00:43:57 +00:00
|
|
|
break;
|
2010-08-12 13:52:07 +00:00
|
|
|
case 'y':
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->ocur==-1) r_core_yank (core, core->offset+core->print->cur, 1);
|
|
|
|
else r_core_yank (core, core->offset+((core->print->ocur<core->print->cur)?
|
|
|
|
core->print->ocur:core->print->cur), R_ABS (core->print->cur-core->print->ocur)+1);
|
2010-08-12 13:52:07 +00:00
|
|
|
break;
|
|
|
|
case 'Y':
|
2012-09-19 12:08:44 +00:00
|
|
|
if (!core->yank_buf) {
|
2016-01-04 01:19:02 +00:00
|
|
|
r_cons_strcat ("Cannot paste, clipboard is empty.\n");
|
2010-08-12 13:52:07 +00:00
|
|
|
r_cons_flush ();
|
2015-03-05 22:33:28 +00:00
|
|
|
r_cons_any_key (NULL);
|
2011-12-02 01:13:49 +00:00
|
|
|
r_cons_clear00 ();
|
2016-02-07 16:06:39 +00:00
|
|
|
} else r_core_yank_paste (core, core->offset+core->print->cur, 0);
|
2010-08-12 13:52:07 +00:00
|
|
|
break;
|
2010-06-17 15:55:39 +00:00
|
|
|
case '-':
|
|
|
|
if (core->print->cur_enabled) {
|
|
|
|
int cur = core->print->cur;
|
|
|
|
if (cur>=core->blocksize)
|
|
|
|
cur = core->print->cur-1;
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->ocur==-1) sprintf (buf, "wos 01 @ $$+%i!1",core->print->cur);
|
|
|
|
else sprintf (buf, "wos 01 @ $$+%i!%i", core->print->cur<core->print->ocur?
|
|
|
|
core->print->cur:core->print->ocur, R_ABS (core->print->ocur-core->print->cur)+1);
|
2010-08-12 13:52:07 +00:00
|
|
|
r_core_cmd (core, buf, 0);
|
2011-11-29 02:46:46 +00:00
|
|
|
} else {
|
2011-12-05 14:21:13 +00:00
|
|
|
if (!autoblocksize)
|
|
|
|
r_core_block_size (core, core->blocksize-1);
|
2011-11-29 02:46:46 +00:00
|
|
|
}
|
2010-06-17 15:55:39 +00:00
|
|
|
break;
|
2009-02-09 00:54:09 +00:00
|
|
|
case '+':
|
2010-06-17 15:55:39 +00:00
|
|
|
if (core->print->cur_enabled) {
|
|
|
|
int cur = core->print->cur;
|
|
|
|
if (cur>=core->blocksize)
|
|
|
|
cur = core->print->cur-1;
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->ocur==-1) sprintf (buf, "woa 01 @ $$+%i!1", core->print->cur);
|
2012-12-07 02:12:25 +00:00
|
|
|
else sprintf (buf, "woa 01 @ $$+%i!%i",
|
2016-02-07 16:06:39 +00:00
|
|
|
core->print->cur<core->print->ocur? core->print->cur: core->print->ocur, R_ABS (core->print->ocur-core->print->cur)+1);
|
2010-08-12 13:52:07 +00:00
|
|
|
r_core_cmd (core, buf, 0);
|
2011-11-29 02:46:46 +00:00
|
|
|
} else {
|
2011-12-05 14:21:13 +00:00
|
|
|
if (!autoblocksize)
|
|
|
|
r_core_block_size (core, core->blocksize+1);
|
2011-11-29 02:46:46 +00:00
|
|
|
}
|
2009-02-09 00:54:09 +00:00
|
|
|
break;
|
|
|
|
case '/':
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->cur_enabled) {
|
2012-08-01 23:50:39 +00:00
|
|
|
visual_search (core);
|
|
|
|
} else {
|
2014-09-28 02:01:31 +00:00
|
|
|
if (autoblocksize) {
|
|
|
|
r_core_cmd0 (core, "?i highlight;e scr.highlight=`?y`");
|
|
|
|
} else {
|
2012-08-01 23:50:39 +00:00
|
|
|
r_core_block_size (core, core->blocksize-cols);
|
2014-09-28 02:01:31 +00:00
|
|
|
}
|
2012-08-01 23:50:39 +00:00
|
|
|
}
|
2009-02-09 00:54:09 +00:00
|
|
|
break;
|
|
|
|
case '*':
|
2011-12-05 14:21:13 +00:00
|
|
|
if (!autoblocksize)
|
|
|
|
r_core_block_size (core, core->blocksize+cols);
|
2009-03-12 12:30:32 +00:00
|
|
|
break;
|
|
|
|
case '>':
|
2010-02-02 10:09:52 +00:00
|
|
|
r_core_seek_align (core, core->blocksize, 1);
|
2011-12-04 20:09:16 +00:00
|
|
|
r_io_sundo_push (core->io, core->offset);
|
2009-03-12 12:30:32 +00:00
|
|
|
break;
|
|
|
|
case '<':
|
2011-03-02 13:11:34 +00:00
|
|
|
r_core_seek_align (core, core->blocksize, -1);
|
2010-02-02 10:09:52 +00:00
|
|
|
r_core_seek_align (core, core->blocksize, -1);
|
2011-12-04 20:09:16 +00:00
|
|
|
r_io_sundo_push (core->io, core->offset);
|
2009-02-09 00:54:09 +00:00
|
|
|
break;
|
2009-04-18 21:49:17 +00:00
|
|
|
case '.':
|
2015-12-16 18:58:54 +00:00
|
|
|
r_io_sundo_push (core->io, core->offset);
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->cur_enabled) {
|
|
|
|
r_core_seek (core, core->offset+core->print->cur, 1);
|
|
|
|
core->print->cur = 0;
|
2013-10-19 22:25:37 +00:00
|
|
|
} else {
|
2015-10-31 01:20:25 +00:00
|
|
|
ut64 addr = r_debug_reg_get (core->dbg, "PC");
|
2014-10-22 22:07:30 +00:00
|
|
|
if (addr) {
|
|
|
|
r_core_seek (core, addr, 1);
|
2015-10-31 01:20:25 +00:00
|
|
|
r_core_cmdf (core, "ar `arn PC`=0x%"PFMT64x, addr);
|
2014-02-20 01:11:04 +00:00
|
|
|
} else {
|
|
|
|
r_core_seek (core, r_num_get (core->num, "entry0"), 1);
|
|
|
|
//r_core_cmd (core, "s entry0", 0);
|
|
|
|
}
|
2013-10-19 22:25:37 +00:00
|
|
|
}
|
2009-04-18 21:49:17 +00:00
|
|
|
break;
|
2012-09-28 00:20:52 +00:00
|
|
|
#if 0
|
|
|
|
case 'n': r_core_seek_delta (core, core->blocksize); break;
|
|
|
|
case 'N': r_core_seek_delta (core, 0-(int)core->blocksize); break;
|
|
|
|
#endif
|
2011-05-21 12:27:46 +00:00
|
|
|
case ':':
|
2014-08-05 17:49:33 +00:00
|
|
|
r_core_visual_prompt_input (core);
|
2009-02-09 00:54:09 +00:00
|
|
|
break;
|
2012-01-31 01:45:17 +00:00
|
|
|
case '_':
|
2015-10-29 11:54:19 +00:00
|
|
|
r_core_visual_hudstuff (core);
|
2012-01-31 01:45:17 +00:00
|
|
|
break;
|
2009-04-06 22:53:25 +00:00
|
|
|
case ';':
|
2011-05-21 12:27:46 +00:00
|
|
|
r_cons_printf ("Enter a comment: ('-' to remove, '!' to use $EDITOR)\n");
|
2015-09-14 10:35:38 +00:00
|
|
|
showcursor (core, true);
|
2010-02-02 10:09:52 +00:00
|
|
|
r_cons_flush ();
|
2015-09-14 10:35:38 +00:00
|
|
|
r_cons_set_raw (false);
|
2011-03-05 18:09:38 +00:00
|
|
|
r_line_set_prompt ("comment: ");
|
2015-12-22 22:09:23 +00:00
|
|
|
strcpy (buf, "\"CC ");
|
2011-05-21 12:27:46 +00:00
|
|
|
i = strlen (buf);
|
2015-12-31 15:28:16 +00:00
|
|
|
if (r_cons_fgets (buf + i, sizeof (buf) - i - 1, 0, NULL) > 0) {
|
2015-12-22 22:09:23 +00:00
|
|
|
ut64 addr, orig;
|
|
|
|
addr = orig = core->offset;
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->cur_enabled) {
|
|
|
|
addr += core->print->cur;
|
2011-05-21 12:27:46 +00:00
|
|
|
r_core_seek (core, addr, 0);
|
2014-05-28 15:49:32 +00:00
|
|
|
r_core_cmdf (core, "s 0x%"PFMT64x, addr);
|
2011-05-21 12:27:46 +00:00
|
|
|
}
|
2015-12-31 15:28:16 +00:00
|
|
|
if (!strcmp (buf + i, "-")) {
|
2015-12-22 22:09:23 +00:00
|
|
|
strcpy (buf, "CC-");
|
|
|
|
} else {
|
|
|
|
switch (buf[i]) {
|
|
|
|
case '-':
|
2015-12-31 15:28:16 +00:00
|
|
|
memcpy (buf, "\"CC-", 4);
|
2015-12-22 22:09:23 +00:00
|
|
|
break;
|
|
|
|
case '!':
|
2015-12-31 15:28:16 +00:00
|
|
|
memcpy (buf, "\"CC!", 4);
|
2015-12-22 22:09:23 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
memcpy (buf, "\"CC ", 4);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
strcat (buf, "\"");
|
2011-05-21 12:27:46 +00:00
|
|
|
}
|
2010-02-02 10:09:52 +00:00
|
|
|
r_core_cmd (core, buf, 1);
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->cur_enabled) r_core_seek (core, orig, 1);
|
2009-04-07 11:28:22 +00:00
|
|
|
}
|
2015-09-14 10:35:38 +00:00
|
|
|
r_cons_set_raw (true);
|
|
|
|
showcursor (core, false);
|
2009-04-06 22:53:25 +00:00
|
|
|
break;
|
2012-09-28 00:20:52 +00:00
|
|
|
case 'b':
|
|
|
|
{
|
2016-02-07 16:06:39 +00:00
|
|
|
ut64 addr = core->print->cur_enabled? core->offset + core->print->cur : core->offset;
|
2014-10-28 01:28:58 +00:00
|
|
|
RBreakpointItem *bp = r_bp_get_at (core->dbg->bp, addr);
|
2012-09-28 00:20:52 +00:00
|
|
|
if (bp) {
|
|
|
|
r_bp_del (core->dbg->bp, addr);
|
|
|
|
} else {
|
|
|
|
r_bp_add_sw (core->dbg->bp, addr, 1, R_BP_PROT_EXEC);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2014-08-29 23:11:46 +00:00
|
|
|
case 'O':
|
|
|
|
r_core_cmd0 (core, "e!asm.esil");
|
|
|
|
break;
|
2011-02-04 23:20:28 +00:00
|
|
|
case 'u':
|
2011-12-04 20:09:16 +00:00
|
|
|
{
|
2011-12-05 07:27:16 +00:00
|
|
|
ut64 off = r_io_sundo (core->io, core->offset);
|
2015-11-13 16:47:15 +00:00
|
|
|
if (off != UT64_MAX) {
|
2013-10-19 22:25:37 +00:00
|
|
|
r_core_visual_seek_animation (core, off);
|
2015-11-13 16:47:15 +00:00
|
|
|
} else {
|
|
|
|
eprintf ("Cannot undo\n");
|
|
|
|
}
|
2011-12-04 20:09:16 +00:00
|
|
|
}
|
2011-02-04 23:20:28 +00:00
|
|
|
break;
|
|
|
|
case 'U':
|
2011-12-05 07:27:16 +00:00
|
|
|
{
|
|
|
|
ut64 off = r_io_sundo_redo (core->io);
|
2015-11-13 16:47:15 +00:00
|
|
|
if (off != UT64_MAX) {
|
2013-10-19 22:25:37 +00:00
|
|
|
r_core_visual_seek_animation (core, off);
|
2011-12-05 07:27:16 +00:00
|
|
|
}
|
2015-11-13 16:47:15 +00:00
|
|
|
}
|
2011-02-04 23:20:28 +00:00
|
|
|
break;
|
2011-02-16 23:58:54 +00:00
|
|
|
case 'z':
|
2015-12-14 09:19:07 +00:00
|
|
|
{
|
|
|
|
RAnalFunction *fcn;
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->cur_enabled) {
|
2015-12-14 09:19:07 +00:00
|
|
|
fcn = r_anal_get_fcn_in (core->anal,
|
2016-02-07 16:06:39 +00:00
|
|
|
core->offset+core->print->cur, R_ANAL_FCN_TYPE_NULL);
|
2015-12-14 09:19:07 +00:00
|
|
|
} else {
|
|
|
|
fcn = r_anal_get_fcn_in (core->anal,
|
|
|
|
core->offset, R_ANAL_FCN_TYPE_NULL);
|
|
|
|
}
|
|
|
|
if (fcn) {
|
|
|
|
fcn->folded = !fcn->folded;
|
|
|
|
} else {
|
|
|
|
r_config_toggle (core->config, "asm.cmtfold");
|
|
|
|
}
|
|
|
|
}
|
2015-06-01 23:04:10 +00:00
|
|
|
break;
|
|
|
|
case 'Z':
|
2016-02-07 16:06:39 +00:00
|
|
|
if (zoom && core->print->cur) {
|
2011-02-23 02:01:26 +00:00
|
|
|
ut64 from = r_config_get_i (core->config, "zoom.from");
|
|
|
|
ut64 to = r_config_get_i (core->config, "zoom.to");
|
2016-02-07 16:06:39 +00:00
|
|
|
r_core_seek (core, from + ((to-from)/core->blocksize)*core->print->cur, 1);
|
2011-02-23 02:01:26 +00:00
|
|
|
}
|
2011-02-16 23:58:54 +00:00
|
|
|
zoom = !zoom;
|
|
|
|
break;
|
2009-02-09 00:54:09 +00:00
|
|
|
case '?':
|
2015-10-29 11:54:19 +00:00
|
|
|
if (visual_help ()=='?')
|
|
|
|
r_core_visual_hud (core);
|
2009-02-09 00:54:09 +00:00
|
|
|
break;
|
2012-02-01 01:22:43 +00:00
|
|
|
case 0x1b:
|
2009-02-09 00:54:09 +00:00
|
|
|
case 'q':
|
2009-02-09 11:42:54 +00:00
|
|
|
case 'Q':
|
2016-02-07 16:06:39 +00:00
|
|
|
setcursor (core, false);
|
2015-09-14 10:35:38 +00:00
|
|
|
return false;
|
2009-02-09 00:54:09 +00:00
|
|
|
}
|
2013-03-17 23:38:04 +00:00
|
|
|
r_core_block_read (core, 0);
|
2015-09-14 10:35:38 +00:00
|
|
|
return true;
|
2009-02-09 00:54:09 +00:00
|
|
|
}
|
|
|
|
|
2011-06-04 01:23:12 +00:00
|
|
|
R_API void r_core_visual_title (RCore *core, int color) {
|
2014-10-22 22:07:30 +00:00
|
|
|
static ut64 oldpc = 0;
|
2013-05-22 02:22:49 +00:00
|
|
|
const char *BEGIN = core->cons->pal.prompt;
|
2011-02-09 23:21:05 +00:00
|
|
|
const char *filename;
|
2015-02-06 18:24:26 +00:00
|
|
|
char pos[512], foo[512], bar[512], pcs[32];
|
2014-10-22 22:07:30 +00:00
|
|
|
if (!oldpc) oldpc = core->offset;
|
2011-01-23 16:48:31 +00:00
|
|
|
/* automatic block size */
|
2015-03-22 15:49:29 +00:00
|
|
|
int pc, hexcols = r_config_get_i (core->config, "hex.cols");
|
2011-02-02 23:57:29 +00:00
|
|
|
if (autoblocksize)
|
2011-06-04 01:14:04 +00:00
|
|
|
switch (core->printidx) {
|
2015-03-21 02:06:31 +00:00
|
|
|
case 0: // x"
|
|
|
|
case 6: // pxa
|
2015-03-22 15:16:51 +00:00
|
|
|
r_core_block_size (core, core->cons->rows * hexcols);
|
2011-01-23 16:48:31 +00:00
|
|
|
break;
|
2012-02-09 00:38:16 +00:00
|
|
|
case 3: // XXX pw
|
2015-03-22 15:16:51 +00:00
|
|
|
r_core_block_size (core, core->cons->rows * hexcols);
|
2012-02-09 00:38:16 +00:00
|
|
|
break;
|
|
|
|
case 4: // XXX pc
|
|
|
|
r_core_block_size (core, core->cons->rows * 5);
|
|
|
|
break;
|
2011-01-23 16:48:31 +00:00
|
|
|
case 1: // pd
|
|
|
|
case 2: // pd+dbg
|
2016-02-12 23:46:33 +00:00
|
|
|
{
|
|
|
|
int bsize = core->cons->rows * 5;
|
|
|
|
|
|
|
|
if (core->screen_bounds > 1) {
|
|
|
|
// estimate new blocksize with the size of the last
|
|
|
|
// printed instructions
|
|
|
|
int new_sz = core->screen_bounds - core->offset + 32;
|
|
|
|
if (new_sz > bsize) bsize = new_sz;
|
|
|
|
}
|
|
|
|
r_core_block_size (core, bsize);
|
2011-01-23 16:48:31 +00:00
|
|
|
break;
|
2016-02-12 23:46:33 +00:00
|
|
|
}
|
2015-03-21 02:06:31 +00:00
|
|
|
case 5: // pxA
|
2015-03-22 15:16:51 +00:00
|
|
|
r_core_block_size (core, hexcols * core->cons->rows * 8);
|
2015-03-21 02:06:31 +00:00
|
|
|
break;
|
2011-01-23 16:48:31 +00:00
|
|
|
}
|
|
|
|
|
2014-10-22 22:07:30 +00:00
|
|
|
if (r_config_get_i (core->config, "cfg.debug")) {
|
2015-10-31 01:20:25 +00:00
|
|
|
ut64 curpc = r_debug_reg_get (core->dbg, "PC");
|
2015-10-15 15:28:34 +00:00
|
|
|
if (curpc && curpc != UT64_MAX && curpc != oldpc) {
|
2014-10-22 22:07:30 +00:00
|
|
|
// check dbg.follow here
|
2014-10-22 22:16:32 +00:00
|
|
|
int follow = (int)(st64)r_config_get_i (core->config, "dbg.follow");
|
2014-10-22 22:07:30 +00:00
|
|
|
if (follow>0) {
|
|
|
|
if ((curpc<core->offset) || (curpc> (core->offset+follow)))
|
|
|
|
r_core_seek (core, curpc, 1);
|
2014-10-22 22:16:32 +00:00
|
|
|
} else if (follow<0) {
|
|
|
|
r_core_seek (core, curpc+follow, 1);
|
2014-10-22 22:07:30 +00:00
|
|
|
}
|
|
|
|
oldpc = curpc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-09 15:01:04 +00:00
|
|
|
filename = (core->file && core->file->desc && core->file->desc->name)? core->file->desc->name: "";
|
2011-11-22 00:42:16 +00:00
|
|
|
{ /* get flag with delta */
|
2016-02-07 16:06:39 +00:00
|
|
|
ut64 addr = core->offset + (core->print->cur_enabled? core->print->cur: 0);
|
2013-03-17 23:38:04 +00:00
|
|
|
RFlagItem *f = r_flag_get_at (core->flags, addr);
|
2011-11-22 00:42:16 +00:00
|
|
|
if (f) {
|
2013-03-17 23:38:04 +00:00
|
|
|
if (f->offset == addr || !f->offset)
|
2012-11-14 02:25:32 +00:00
|
|
|
snprintf (pos, sizeof (pos), "@ %s", f->name);
|
2013-04-16 01:24:47 +00:00
|
|
|
else snprintf (pos, sizeof (pos), "@ %s+%d # 0x%"PFMT64x,
|
|
|
|
f->name, (int)(addr-f->offset), addr);
|
2011-11-22 00:42:16 +00:00
|
|
|
} else pos[0] = 0;
|
|
|
|
}
|
2011-02-09 23:21:05 +00:00
|
|
|
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->cur<0) core->print->cur = 0;
|
2013-02-27 00:40:26 +00:00
|
|
|
|
2013-05-22 02:22:49 +00:00
|
|
|
if (color) r_cons_strcat (BEGIN);
|
2012-07-16 09:39:43 +00:00
|
|
|
strncpy (bar, printfmt[PIDX], sizeof (bar)-1);
|
2013-02-27 00:40:26 +00:00
|
|
|
|
2012-02-01 10:49:46 +00:00
|
|
|
bar[sizeof (bar)-1] = 0; // '\0'-terminate bar
|
2011-12-02 13:32:04 +00:00
|
|
|
bar[10] = '.'; // chop cmdfmt
|
|
|
|
bar[11] = '.'; // chop cmdfmt
|
|
|
|
bar[12] = 0; // chop cmdfmt
|
2015-02-06 18:24:26 +00:00
|
|
|
{
|
|
|
|
ut64 sz = r_io_size (core->io);
|
2015-09-09 20:01:29 +00:00
|
|
|
ut64 pa = r_io_section_vaddr_to_maddr_try (core->io, core->offset);
|
2015-02-06 18:24:26 +00:00
|
|
|
if (sz == UT64_MAX) {
|
|
|
|
pcs[0] = 0;
|
|
|
|
} else {
|
2015-02-07 23:30:25 +00:00
|
|
|
if (!sz || pa>sz) {
|
2015-02-06 18:24:26 +00:00
|
|
|
pc = 0;
|
|
|
|
} else {
|
|
|
|
pc = ( pa * 100 ) / sz;
|
|
|
|
}
|
|
|
|
sprintf (pcs, "%d%% ", pc);
|
|
|
|
}
|
|
|
|
}
|
2016-02-07 16:06:39 +00:00
|
|
|
if (core->print->cur_enabled)
|
2015-02-06 18:24:26 +00:00
|
|
|
snprintf (foo, sizeof (foo), "[0x%08"PFMT64x" %s%d (0x%x:%d=%d)]> %s %s\n",
|
|
|
|
core->offset, pcs, core->blocksize,
|
2016-02-07 16:06:39 +00:00
|
|
|
core->print->cur, core->print->ocur, core->print->ocur==-1?1:R_ABS (core->print->cur-core->print->ocur)+1,
|
2013-03-17 23:38:04 +00:00
|
|
|
bar, pos);
|
2011-12-02 13:32:04 +00:00
|
|
|
else
|
2015-02-06 18:24:26 +00:00
|
|
|
snprintf (foo, sizeof (foo), "[0x%08"PFMT64x" %s%d %s]> %s %s\n",
|
|
|
|
core->offset, pcs, core->blocksize, filename, bar, pos);
|
2015-02-12 15:41:02 +00:00
|
|
|
r_cons_printf ("%s", foo);
|
2010-07-16 09:28:16 +00:00
|
|
|
if (color) r_cons_strcat (Color_RESET);
|
2009-02-09 11:42:54 +00:00
|
|
|
}
|
|
|
|
|
2015-11-23 16:09:46 +00:00
|
|
|
static int r_core_visual_responsive (RCore *core) {
|
|
|
|
int h, w = r_cons_get_size (&h);
|
2014-09-11 02:18:23 +00:00
|
|
|
if (r_config_get_i (core->config, "scr.responsive")) {
|
2015-06-04 22:19:41 +00:00
|
|
|
if (w<110) {
|
2014-11-06 10:11:51 +00:00
|
|
|
r_config_set_i (core->config, "asm.cmtright", 0);
|
|
|
|
} else {
|
|
|
|
r_config_set_i (core->config, "asm.cmtright", 1);
|
|
|
|
}
|
2014-09-11 02:18:23 +00:00
|
|
|
if (w<68) {
|
|
|
|
r_config_set_i (core->config, "hex.cols", w/5.2);
|
|
|
|
} else {
|
|
|
|
r_config_set_i (core->config, "hex.cols", 16);
|
|
|
|
}
|
|
|
|
if (w<25) {
|
|
|
|
r_config_set_i (core->config, "asm.offset", 0);
|
|
|
|
} else {
|
|
|
|
r_config_set_i (core->config, "asm.offset", 1);
|
|
|
|
}
|
|
|
|
if (w>80) {
|
|
|
|
r_config_set_i (core->config, "asm.lineswidth", 14);
|
2015-02-10 23:13:04 +00:00
|
|
|
r_config_set_i (core->config, "asm.lineswidth", w-(w/1.2));
|
|
|
|
r_config_set_i (core->config, "asm.cmtcol", w-(w/2.5));
|
2014-09-11 02:18:23 +00:00
|
|
|
} else {
|
|
|
|
r_config_set_i (core->config, "asm.lineswidth", 7);
|
|
|
|
}
|
2015-06-04 22:19:41 +00:00
|
|
|
if (w<70) {
|
2014-09-11 02:18:23 +00:00
|
|
|
r_config_set_i (core->config, "asm.lineswidth", 1);
|
|
|
|
r_config_set_i (core->config, "asm.bytes", 0);
|
|
|
|
} else {
|
|
|
|
r_config_set_i (core->config, "asm.bytes", 1);
|
|
|
|
}
|
|
|
|
}
|
2015-11-23 16:09:46 +00:00
|
|
|
return w;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void r_core_visual_refresh (RCore *core) {
|
|
|
|
int w;
|
|
|
|
const char *vi, *vcmd;
|
|
|
|
if (!core) return;
|
2016-02-07 16:06:39 +00:00
|
|
|
r_print_set_cursor (core->print, core->print->cur_enabled, core->print->ocur, core->print->cur);
|
2015-11-23 16:09:46 +00:00
|
|
|
core->cons->blankline = true;
|
|
|
|
|
|
|
|
w = r_core_visual_responsive (core);
|
2014-09-11 02:18:23 +00:00
|
|
|
|
2012-06-30 18:51:18 +00:00
|
|
|
if (autoblocksize) {
|
|
|
|
r_cons_gotoxy (0, 0);
|
2014-09-17 08:36:38 +00:00
|
|
|
} else {
|
|
|
|
r_cons_clear ();
|
|
|
|
}
|
2015-11-23 16:09:46 +00:00
|
|
|
r_cons_flush ();
|
2012-11-14 02:25:32 +00:00
|
|
|
r_cons_print_clear ();
|
2016-02-25 09:28:54 +00:00
|
|
|
//core->curtab = 0;
|
2011-06-05 18:36:22 +00:00
|
|
|
|
2011-05-21 13:45:43 +00:00
|
|
|
vi = r_config_get (core->config, "cmd.cprompt");
|
|
|
|
if (vi && *vi) {
|
2012-12-07 14:44:36 +00:00
|
|
|
// XXX: slow
|
2015-09-14 10:35:38 +00:00
|
|
|
core->cons->blankline = false;
|
2014-10-06 00:36:22 +00:00
|
|
|
r_cons_clear00 ();
|
2012-11-30 15:12:54 +00:00
|
|
|
r_cons_flush ();
|
2014-10-06 00:36:22 +00:00
|
|
|
{
|
|
|
|
int hc = r_config_get_i (core->config, "hex.cols");
|
|
|
|
int nw = 12 + 4 + hc + (hc*3);
|
|
|
|
if (nw>w) {
|
|
|
|
// do not show column contents
|
|
|
|
} else {
|
|
|
|
r_cons_printf ("[cmd.cprompt=%s]\n", vi);
|
|
|
|
r_core_cmd0 (core, vi);
|
|
|
|
r_cons_column (nw);
|
|
|
|
r_cons_flush ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
r_cons_gotoxy (0, 0);
|
|
|
|
r_core_visual_title (core, color);
|
2012-12-07 14:44:36 +00:00
|
|
|
vi = r_config_get (core->config, "cmd.vprompt");
|
|
|
|
if (vi) r_core_cmd (core, vi, 0);
|
2012-11-30 15:12:54 +00:00
|
|
|
} else {
|
2012-12-07 14:44:36 +00:00
|
|
|
vi = r_config_get (core->config, "cmd.vprompt");
|
|
|
|
if (vi) r_core_cmd (core, vi, 0);
|
2012-11-30 15:12:54 +00:00
|
|
|
r_core_visual_title (core, color);
|
2011-05-21 13:45:43 +00:00
|
|
|
}
|
2012-11-14 02:25:32 +00:00
|
|
|
|
2013-02-27 00:40:26 +00:00
|
|
|
vcmd = r_config_get (core->config, "cmd.visual");
|
|
|
|
if (vcmd && *vcmd) {
|
2016-02-09 23:26:24 +00:00
|
|
|
// disable screen bounds when it's a user-defined command
|
|
|
|
// because it can cause some issues
|
|
|
|
core->screen_bounds = 0;
|
2013-02-27 00:40:26 +00:00
|
|
|
r_core_cmd (core, vcmd, 0);
|
|
|
|
} else {
|
2016-02-09 23:26:24 +00:00
|
|
|
core->screen_bounds = 1LL;
|
2016-02-25 09:28:54 +00:00
|
|
|
r_core_cmd0 (core, zoom? "pz": printfmt[PIDX]);
|
2013-02-27 00:40:26 +00:00
|
|
|
}
|
2014-09-22 11:45:36 +00:00
|
|
|
if (core->screen_bounds != 1LL) {
|
|
|
|
r_cons_printf ("[0x%08"PFMT64x"..0x%08"PFMT64x"]\n",
|
|
|
|
core->offset, core->screen_bounds);
|
|
|
|
}
|
2011-05-21 12:27:46 +00:00
|
|
|
blocksize = core->num->value? core->num->value : core->blocksize;
|
2012-11-14 02:25:32 +00:00
|
|
|
|
2012-11-30 15:12:54 +00:00
|
|
|
/* this is why there's flickering */
|
2016-02-10 23:10:48 +00:00
|
|
|
if (core->print->vflush) {
|
|
|
|
r_cons_visual_flush ();
|
|
|
|
} else {
|
|
|
|
r_cons_reset ();
|
|
|
|
}
|
2015-09-14 10:35:38 +00:00
|
|
|
core->cons->blankline = true;
|
2016-02-25 09:28:54 +00:00
|
|
|
core->curtab = 0; // which command are we focusing
|
|
|
|
//core->seltab = 0; // user selected tab
|
2011-01-23 12:12:16 +00:00
|
|
|
}
|
|
|
|
|
2010-03-08 11:45:22 +00:00
|
|
|
R_API int r_core_visual(RCore *core, const char *input) {
|
2011-02-27 23:03:26 +00:00
|
|
|
const char *cmdprompt, *teefile;
|
2009-07-08 11:49:55 +00:00
|
|
|
ut64 scrseek;
|
2014-09-04 09:06:11 +00:00
|
|
|
int wheel, flags, ch;
|
2016-02-10 23:10:48 +00:00
|
|
|
bool skip;
|
2009-02-09 00:54:09 +00:00
|
|
|
|
2015-04-09 14:43:20 +00:00
|
|
|
if (r_cons_get_size (&ch)<1 || ch<1) {
|
2014-09-24 01:17:43 +00:00
|
|
|
eprintf ("Cannot create Visual context. Use scr.fix_{columns|rows}\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-08-26 23:12:58 +00:00
|
|
|
obs = core->blocksize;
|
2015-09-14 10:35:38 +00:00
|
|
|
//r_cons_set_cup (true);
|
2011-01-23 12:12:16 +00:00
|
|
|
|
2015-09-14 10:35:38 +00:00
|
|
|
core->vmode = false;
|
2011-03-01 23:02:50 +00:00
|
|
|
while (*input) {
|
2012-07-16 09:39:43 +00:00
|
|
|
if (!r_core_visual_cmd (core, input[0]))
|
2009-02-09 00:54:09 +00:00
|
|
|
return 0;
|
2011-01-23 12:12:16 +00:00
|
|
|
input++;
|
2009-02-09 00:54:09 +00:00
|
|
|
}
|
2015-09-14 10:35:38 +00:00
|
|
|
core->vmode = true;
|
2009-02-09 00:54:09 +00:00
|
|
|
|
2011-02-27 23:03:26 +00:00
|
|
|
// disable tee in cons
|
|
|
|
teefile = r_cons_singleton ()->teefile;
|
|
|
|
r_cons_singleton ()->teefile = "";
|
|
|
|
|
2014-09-24 01:17:43 +00:00
|
|
|
core->print->flags |= R_PRINT_FLAGS_ADDRMOD;
|
2009-02-09 00:54:09 +00:00
|
|
|
do {
|
2016-02-10 23:10:48 +00:00
|
|
|
skip = false;
|
|
|
|
if (core->print->cur_enabled) {
|
|
|
|
// update the cursor when it's not visible anymore
|
|
|
|
skip |= fix_cursor (core);
|
|
|
|
}
|
|
|
|
|
2014-09-27 01:48:54 +00:00
|
|
|
if (core->printidx == 2) {
|
|
|
|
static char debugstr[512];
|
|
|
|
const char *cmdvhex = r_config_get (core->config, "cmd.stack");
|
2016-01-02 08:07:46 +00:00
|
|
|
const int ref = r_config_get_i (core->config, "dbg.slow");
|
2014-09-27 01:48:54 +00:00
|
|
|
const int pxa = r_config_get_i (core->config, "stack.anotated"); // stack.anotated
|
2014-10-03 18:05:33 +00:00
|
|
|
const int size = r_config_get_i (core->config, "stack.size");
|
|
|
|
const int delta = r_config_get_i (core->config, "stack.delta");
|
|
|
|
const int bytes = r_config_get_i (core->config, "stack.bytes");
|
2014-09-27 01:48:54 +00:00
|
|
|
if (cmdvhex && *cmdvhex) {
|
2016-02-25 09:28:54 +00:00
|
|
|
snprintf (debugstr, sizeof (debugstr),
|
|
|
|
"?0;f tmp;sr SP;%s;?1;%s;?1;s-;"
|
2016-01-02 08:07:46 +00:00
|
|
|
"s tmp;f-tmp;pd $r", cmdvhex,
|
|
|
|
ref? "drr": "dr=");
|
2016-02-25 09:28:54 +00:00
|
|
|
debugstr[sizeof (debugstr)-1]=0;
|
2014-09-27 01:48:54 +00:00
|
|
|
} else {
|
2014-10-03 18:05:33 +00:00
|
|
|
const char *pxw;
|
2016-01-02 08:07:46 +00:00
|
|
|
if (ref) {
|
|
|
|
pxw = "pxr";
|
|
|
|
} else if (bytes) {
|
2014-10-03 18:05:33 +00:00
|
|
|
pxw = "px";
|
|
|
|
} else {
|
|
|
|
switch (core->assembler->bits) {
|
|
|
|
case 64: pxw = "pxq"; break;
|
|
|
|
case 32: pxw = "pxw"; break;
|
|
|
|
default: pxw = "px"; break;
|
|
|
|
}
|
|
|
|
}
|
2015-11-23 15:31:31 +00:00
|
|
|
snprintf (debugstr, sizeof (debugstr),
|
2016-02-25 09:28:54 +00:00
|
|
|
"?0;f tmp;sr SP;%s %d@$$-%d;"
|
|
|
|
"?1;%s;s-;"
|
|
|
|
"?1;s tmp;f-tmp;pd $r",
|
2016-01-02 08:07:46 +00:00
|
|
|
pxa? "pxa": pxw, size, delta,
|
|
|
|
ref? "drr": "dr=");
|
2014-09-27 01:48:54 +00:00
|
|
|
}
|
|
|
|
printfmt[2] = debugstr;
|
|
|
|
}
|
2014-09-04 09:06:11 +00:00
|
|
|
wheel = r_config_get_i (core->config, "scr.wheel");
|
2015-09-14 10:35:38 +00:00
|
|
|
r_cons_show_cursor (false);
|
2015-11-23 15:31:31 +00:00
|
|
|
if (wheel) r_cons_enable_mouse (true);
|
2014-08-03 23:29:53 +00:00
|
|
|
core->cons->event_data = core;
|
|
|
|
core->cons->event_resize = (RConsEvent)r_core_visual_refresh;
|
2013-08-26 23:12:58 +00:00
|
|
|
flags = core->print->flags;
|
2013-08-21 22:08:08 +00:00
|
|
|
color = r_config_get_i (core->config, "scr.color");
|
|
|
|
if (color) flags |= R_PRINT_FLAGS_COLOR;
|
|
|
|
debug = r_config_get_i (core->config, "cfg.debug");
|
2015-08-28 16:29:31 +00:00
|
|
|
flags |= R_PRINT_FLAGS_ADDRMOD | R_PRINT_FLAGS_HEADER;
|
2015-04-11 02:45:09 +00:00
|
|
|
r_print_set_flags (core->print, core->print->flags);
|
2012-07-22 08:00:35 +00:00
|
|
|
scrseek = r_num_math (core->num,
|
2010-05-19 22:59:42 +00:00
|
|
|
r_config_get (core->config, "scr.seek"));
|
2016-02-10 23:10:48 +00:00
|
|
|
if (scrseek != 0LL) {
|
2009-04-07 11:28:22 +00:00
|
|
|
r_core_seek (core, scrseek, 1);
|
2016-02-10 23:10:48 +00:00
|
|
|
}
|
|
|
|
if (debug) {
|
2010-05-19 22:59:42 +00:00
|
|
|
r_core_cmd (core, ".dr*", 0);
|
2016-02-10 23:10:48 +00:00
|
|
|
}
|
2010-05-19 22:59:42 +00:00
|
|
|
cmdprompt = r_config_get (core->config, "cmd.vprompt");
|
2016-02-10 23:10:48 +00:00
|
|
|
if (cmdprompt && *cmdprompt) {
|
2010-02-28 22:57:55 +00:00
|
|
|
r_core_cmd (core, cmdprompt, 0);
|
2016-02-10 23:10:48 +00:00
|
|
|
}
|
|
|
|
core->print->vflush = !skip;
|
2011-01-23 12:12:16 +00:00
|
|
|
r_core_visual_refresh (core);
|
2016-02-10 23:10:48 +00:00
|
|
|
if (!skip) {
|
|
|
|
ch = r_cons_readchar ();
|
|
|
|
r_core_visual_show_char (core, ch);
|
|
|
|
if (ch == -1 || ch == 4) break; // error or eof
|
|
|
|
}
|
|
|
|
} while (skip || r_core_visual_cmd (core, ch));
|
2010-02-28 22:57:55 +00:00
|
|
|
|
2015-09-14 10:35:38 +00:00
|
|
|
r_cons_enable_mouse (false);
|
2010-02-28 22:57:55 +00:00
|
|
|
if (color)
|
|
|
|
r_cons_printf (Color_RESET);
|
2013-08-26 01:17:29 +00:00
|
|
|
r_config_set_i (core->config, "scr.color", color);
|
2015-09-14 10:35:38 +00:00
|
|
|
core->print->cur_enabled = false;
|
2011-02-02 23:57:29 +00:00
|
|
|
if (autoblocksize)
|
|
|
|
r_core_block_size (core, obs);
|
2011-02-27 23:03:26 +00:00
|
|
|
r_cons_singleton ()->teefile = teefile;
|
2015-09-14 10:35:38 +00:00
|
|
|
r_cons_set_cup (false);
|
2014-09-17 08:36:38 +00:00
|
|
|
r_cons_clear00 ();
|
2015-09-14 10:35:38 +00:00
|
|
|
core->vmode = false;
|
2013-04-04 23:53:21 +00:00
|
|
|
core->cons->event_resize = NULL;
|
|
|
|
core->cons->event_data = NULL;
|
2015-09-14 10:35:38 +00:00
|
|
|
r_cons_show_cursor (true);
|
2009-02-05 21:08:46 +00:00
|
|
|
return 0;
|
|
|
|
}
|