2018-03-23 10:35:30 +01:00
|
|
|
/* Copyright radare2 2014-2018 - Author: pancake, vane11ope */
|
2015-03-05 02:07:53 +01:00
|
|
|
|
2015-03-05 12:18:37 +01:00
|
|
|
// pls move the typedefs into roons and rename it -> RConsPanel
|
|
|
|
|
2015-03-05 02:07:53 +01:00
|
|
|
#include <r_core.h>
|
|
|
|
|
2018-02-20 10:15:17 +09:00
|
|
|
#define LIMIT 256
|
2018-03-11 18:23:44 +09:00
|
|
|
|
2018-02-21 20:31:01 +09:00
|
|
|
#define PANEL_TITLE_SYMBOLS "Symbols"
|
|
|
|
#define PANEL_TITLE_STACK "Stack"
|
|
|
|
#define PANEL_TITLE_REGISTERS "Registers"
|
|
|
|
#define PANEL_TITLE_REGISTERREFS "RegisterRefs"
|
|
|
|
#define PANEL_TITLE_DISASSEMBLY "Disassembly"
|
|
|
|
#define PANEL_TITLE_NEWFILES "New files"
|
|
|
|
#define PANEL_TITLE_INFO "Info"
|
|
|
|
#define PANEL_TITLE_DATABASE "Database"
|
|
|
|
#define PANEL_TITLE_HEXDUMP "Hexdump"
|
|
|
|
#define PANEL_TITLE_FUNCTIONS "Functions"
|
|
|
|
#define PANEL_TITLE_COMMENTS "Comments"
|
|
|
|
#define PANEL_TITLE_ENTROPY "Entropy"
|
|
|
|
#define PANEL_TITLE_DRX "DRX"
|
|
|
|
#define PANEL_TITLE_SECTIONS "Sections"
|
|
|
|
#define PANEL_TITLE_STRINGS "Strings"
|
|
|
|
#define PANEL_TITLE_MAPS "Maps"
|
|
|
|
#define PANEL_TITLE_MODULES "Modules"
|
|
|
|
#define PANEL_TITLE_BACKTRACE "Backtrace"
|
|
|
|
#define PANEL_TITLE_BREAKPOINTS "Breakpoints"
|
|
|
|
#define PANEL_TITLE_IMPORTS "Imports"
|
|
|
|
#define PANEL_TITLE_CLIPBOARD "Clipboard"
|
|
|
|
#define PANEL_TITLE_FCNINFO "FcnInfo"
|
|
|
|
|
2018-03-11 18:23:44 +09:00
|
|
|
#define PANEL_CMD_SYMBOLS "isq"
|
|
|
|
#define PANEL_CMD_STACK "px 256@r:SP"
|
|
|
|
#define PANEL_CMD_REGISTERS "dr="
|
|
|
|
#define PANEL_CMD_REGISTERREFS "drr"
|
|
|
|
#define PANEL_CMD_DISASSEMBLY "pd $r @e:scr.utf8=0"
|
|
|
|
|
2018-02-21 20:31:01 +09:00
|
|
|
static RConsCanvas *can;
|
2018-02-20 10:15:17 +09:00
|
|
|
|
2015-03-05 02:07:53 +01:00
|
|
|
typedef struct {
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int w;
|
|
|
|
int h;
|
|
|
|
int depth;
|
|
|
|
int type;
|
2015-09-29 04:26:00 +02:00
|
|
|
int sx; // scroll-x
|
|
|
|
int sy; // scroll-y
|
2015-03-05 02:07:53 +01:00
|
|
|
char *cmd;
|
|
|
|
char *text;
|
2018-03-21 19:29:46 +09:00
|
|
|
bool refresh;
|
2015-03-05 02:07:53 +01:00
|
|
|
} Panel;
|
|
|
|
|
2018-03-28 17:00:54 +09:00
|
|
|
enum {
|
|
|
|
PANEL_TYPE_FRAME,
|
|
|
|
PANEL_TYPE_MENU
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
LAYOUT_DEFAULT,
|
|
|
|
LAYOUT_BALANCE
|
|
|
|
};
|
|
|
|
|
2018-02-21 20:31:01 +09:00
|
|
|
static Panel *panels = NULL;
|
|
|
|
static int n_panels = 0;
|
2018-03-28 17:00:54 +09:00
|
|
|
static int columnWidth = 80;
|
2016-11-22 01:58:52 +01:00
|
|
|
static const int layoutCount = 2;
|
|
|
|
static int layout = 0;
|
2015-03-05 02:07:53 +01:00
|
|
|
static RCore *_core;
|
|
|
|
static int menu_pos = 0;
|
|
|
|
static int menu_x = 0;
|
|
|
|
static int menu_y = 0;
|
2018-02-21 20:31:01 +09:00
|
|
|
static int callgraph = 0;
|
2018-03-22 15:43:59 +09:00
|
|
|
static bool isResizing = false;
|
2015-03-05 02:07:53 +01:00
|
|
|
|
|
|
|
static const char *menus[] = {
|
2015-08-31 11:53:03 +02:00
|
|
|
"File", "Edit", "View", "Tools", "Search", "Debug", "Analyze", "Help",
|
2015-03-05 02:07:53 +01:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *menus_File[] = {
|
2016-11-22 01:58:52 +01:00
|
|
|
"New", "Open", "Close", ".", "Sections", "Strings", "Symbols", "Imports", "Info", "Database", ".", "Quit",
|
2015-03-05 02:07:53 +01:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *menus_Edit[] = {
|
2015-08-31 05:06:01 +02:00
|
|
|
"Copy", "Paste", "Clipboard", "Write String", "Write Hex", "Write Value", "Assemble", "Fill", "io.cache",
|
2015-03-05 02:07:53 +01:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *menus_View[] = {
|
2015-08-31 05:43:38 +02:00
|
|
|
"Hexdump", "Disassembly", "Graph", "FcnInfo", "Functions", "Comments", "Entropy", "Colors",
|
2015-03-05 02:07:53 +01:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *menus_Tools[] = {
|
2015-09-29 04:26:00 +02:00
|
|
|
"Assembler", "Calculator", "R2 Shell", "System Shell",
|
2015-03-05 02:07:53 +01:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2015-08-31 11:53:03 +02:00
|
|
|
static const char *menus_Search[] = {
|
|
|
|
"String", "ROP", "Code", "Hexpairs",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2015-03-05 02:07:53 +01:00
|
|
|
static const char *menus_Debug[] = {
|
2015-10-07 11:32:08 +02:00
|
|
|
"Registers", "RegisterRefs", "DRX", "Breakpoints",
|
2016-11-22 01:58:52 +01:00
|
|
|
"Watchpoints", "Maps", "Modules",
|
2015-08-31 05:06:01 +02:00
|
|
|
"Backtrace",
|
2016-11-22 01:58:52 +01:00
|
|
|
".",
|
|
|
|
"Continue", "Cont until.",
|
|
|
|
"Step", "Step Over",
|
2015-03-05 02:07:53 +01:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *menus_Analyze[] = {
|
2015-08-31 05:06:01 +02:00
|
|
|
"Function", "Program", "Calls", "References",
|
2015-03-05 02:07:53 +01:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *menus_Help[] = {
|
2016-11-22 01:58:52 +01:00
|
|
|
"Fortune", "Commands", "2048", "License", ".", "About",
|
2015-03-05 02:07:53 +01:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char **menus_sub[] = {
|
|
|
|
menus_File,
|
|
|
|
menus_Edit,
|
|
|
|
menus_View,
|
|
|
|
menus_Tools,
|
2015-08-31 11:53:03 +02:00
|
|
|
menus_Search,
|
2015-03-05 02:07:53 +01:00
|
|
|
menus_Debug,
|
|
|
|
menus_Analyze,
|
|
|
|
menus_Help,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
// TODO: handle mouse wheel
|
|
|
|
static int curnode = 0;
|
|
|
|
|
|
|
|
static void Panel_print(RConsCanvas *can, Panel *n, int cur) {
|
2018-03-23 12:52:56 +01:00
|
|
|
if (!n || !can || !n->refresh) {
|
2018-03-21 19:29:46 +09:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
n->refresh = false;
|
2018-03-23 01:30:41 +09:00
|
|
|
char *text;
|
2015-03-05 02:07:53 +01:00
|
|
|
char title[128];
|
2015-11-22 11:39:54 +01:00
|
|
|
int delta_x, delta_y;
|
2015-11-22 11:27:45 +01:00
|
|
|
delta_x = n->sx;
|
|
|
|
delta_y = n->sy;
|
2018-03-21 19:29:46 +09:00
|
|
|
// clear the canvas first
|
2018-02-20 10:15:17 +09:00
|
|
|
r_cons_canvas_fill (can, n->x, n->y, n->w, n->h, ' ', 0);
|
2018-03-23 01:30:41 +09:00
|
|
|
// for menu
|
2018-03-28 17:00:54 +09:00
|
|
|
RCons *cons = r_cons_singleton ();
|
2018-03-23 01:30:41 +09:00
|
|
|
if (n->type == PANEL_TYPE_MENU) {
|
|
|
|
(void) r_cons_canvas_gotoxy (can, n->x + 2, n->y + 2);
|
|
|
|
text = r_str_ansi_crop (n->text,
|
|
|
|
delta_x, delta_y, n->w + 5, n->h - delta_y);
|
|
|
|
if (text) {
|
|
|
|
r_cons_canvas_write (can, text);
|
|
|
|
free (text);
|
|
|
|
} else {
|
|
|
|
r_cons_canvas_write (can, n->text);
|
|
|
|
}
|
|
|
|
} else {
|
2015-03-05 02:07:53 +01:00
|
|
|
if (cur) {
|
2018-03-05 23:32:27 +01:00
|
|
|
const char *k = cons->pal.graph_box;
|
2017-02-22 23:45:51 +01:00
|
|
|
snprintf (title, sizeof (title) - 1,
|
2018-03-05 23:32:27 +01:00
|
|
|
"%s[x] %s"Color_RESET, k, n->text);
|
2015-03-05 02:07:53 +01:00
|
|
|
} else {
|
2017-02-22 23:45:51 +01:00
|
|
|
snprintf (title, sizeof (title) - 1,
|
2015-08-31 05:06:01 +02:00
|
|
|
" %s ", n->text);
|
2015-03-05 02:07:53 +01:00
|
|
|
}
|
2018-02-20 10:15:17 +09:00
|
|
|
if (r_cons_canvas_gotoxy (can, n->x + 1, n->y + 1)) {
|
|
|
|
r_cons_canvas_write (can, title); // delta_x
|
2017-02-22 23:45:51 +01:00
|
|
|
}
|
2018-03-23 01:30:41 +09:00
|
|
|
(void) r_cons_canvas_gotoxy (can, n->x + 2, n->y + 2);
|
|
|
|
char *foo = r_core_cmd_str (_core, n->cmd);
|
|
|
|
if (delta_y < 0) {
|
|
|
|
delta_y = 0;
|
|
|
|
}
|
|
|
|
if (delta_x < 0) {
|
|
|
|
char *white = (char*)r_str_pad (' ', 128);;
|
|
|
|
int idx = -delta_x;
|
|
|
|
if (idx >= sizeof (white)) {
|
|
|
|
idx = sizeof (white) - 1;
|
|
|
|
}
|
|
|
|
white[idx] = 0;
|
|
|
|
text = r_str_ansi_crop (foo,
|
|
|
|
0, delta_y, n->w + delta_x - 2, n->h - 2 + delta_y);
|
|
|
|
char *newText = r_str_prefix_all (text, white);
|
|
|
|
if (newText) {
|
|
|
|
free (text);
|
|
|
|
text = newText;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
text = r_str_ansi_crop (foo,
|
|
|
|
delta_x, delta_y, n->w + delta_x - 2, n->h - 2 + delta_y);
|
2018-03-21 19:29:46 +09:00
|
|
|
}
|
2018-03-23 01:30:41 +09:00
|
|
|
if (text) {
|
|
|
|
r_cons_canvas_write (can, text);
|
2015-03-05 02:07:53 +01:00
|
|
|
free (text);
|
2018-03-23 01:30:41 +09:00
|
|
|
} else {
|
|
|
|
r_cons_canvas_write (can, n->text);
|
2015-03-05 02:07:53 +01:00
|
|
|
}
|
2018-03-23 01:30:41 +09:00
|
|
|
free (foo);
|
2015-03-05 02:07:53 +01:00
|
|
|
}
|
|
|
|
if (cur) {
|
2018-03-05 23:32:27 +01:00
|
|
|
r_cons_canvas_box (can, n->x, n->y, n->w, n->h, cons->pal.graph_box2);
|
2015-03-05 02:07:53 +01:00
|
|
|
} else {
|
2018-03-05 23:32:27 +01:00
|
|
|
r_cons_canvas_box (can, n->x, n->y, n->w, n->h, cons->pal.graph_box);
|
2015-03-05 02:07:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void Layout_run(Panel *panels) {
|
|
|
|
int h, w = r_cons_get_size (&h);
|
|
|
|
int i, j;
|
2018-03-28 17:00:54 +09:00
|
|
|
int colpos = w - columnWidth;
|
2016-05-09 11:13:37 +02:00
|
|
|
if (colpos < 0) {
|
2018-03-28 17:00:54 +09:00
|
|
|
columnWidth = w;
|
2015-10-08 13:24:47 +02:00
|
|
|
colpos = 0;
|
|
|
|
}
|
2015-03-05 02:07:53 +01:00
|
|
|
can->sx = 0;
|
|
|
|
can->sy = 0;
|
2018-03-28 17:00:54 +09:00
|
|
|
for (i = j = 0; i < n_panels; i++) {
|
2015-03-05 02:07:53 +01:00
|
|
|
switch (panels[i].type) {
|
2018-03-11 18:23:44 +09:00
|
|
|
case PANEL_TYPE_MENU:
|
2015-03-05 23:07:39 +01:00
|
|
|
panels[i].w = r_str_bounds (
|
|
|
|
panels[i].text,
|
2015-03-05 02:07:53 +01:00
|
|
|
&panels[i].h);
|
|
|
|
panels[i].h += 4;
|
|
|
|
break;
|
|
|
|
case PANEL_TYPE_FRAME:
|
2016-11-22 01:58:52 +01:00
|
|
|
switch (layout) {
|
2018-03-28 17:00:54 +09:00
|
|
|
case LAYOUT_DEFAULT:
|
2016-11-22 01:58:52 +01:00
|
|
|
if (j == 0) {
|
|
|
|
panels[i].x = 0;
|
|
|
|
panels[i].y = 1;
|
2017-02-22 23:45:51 +01:00
|
|
|
if (panels[j + 1].text) {
|
|
|
|
panels[i].w = colpos + 1;
|
2016-11-22 01:58:52 +01:00
|
|
|
} else {
|
|
|
|
panels[i].w = w;
|
|
|
|
}
|
2017-02-22 23:45:51 +01:00
|
|
|
panels[i].h = h - 1;
|
2015-03-05 02:07:53 +01:00
|
|
|
} else {
|
2016-11-22 01:58:52 +01:00
|
|
|
int ph = ((h - 1) / (n_panels - 2));
|
|
|
|
panels[i].x = colpos;
|
|
|
|
panels[i].y = 1 + (ph * (j - 1));
|
2017-02-22 23:45:51 +01:00
|
|
|
panels[i].w = w - colpos;
|
2016-11-22 01:58:52 +01:00
|
|
|
if (panels[i].w < 0) {
|
|
|
|
panels[i].w = 0;
|
|
|
|
}
|
|
|
|
panels[i].h = ph;
|
|
|
|
if (!panels[i + 1].text) {
|
|
|
|
panels[i].h = h - panels[i].y;
|
|
|
|
}
|
|
|
|
if (j != 1) {
|
|
|
|
panels[i].y--;
|
|
|
|
panels[i].h++;
|
|
|
|
}
|
2015-03-05 23:07:39 +01:00
|
|
|
}
|
2016-11-22 01:58:52 +01:00
|
|
|
break;
|
2018-03-28 17:00:54 +09:00
|
|
|
case LAYOUT_BALANCE:
|
2016-11-22 01:58:52 +01:00
|
|
|
if (j == 0) {
|
|
|
|
panels[i].x = 0;
|
|
|
|
panels[i].y = 1;
|
2017-02-22 23:45:51 +01:00
|
|
|
if (panels[j + 1].text) {
|
2016-11-22 01:58:52 +01:00
|
|
|
panels[i].w = colpos + 1;
|
|
|
|
} else {
|
|
|
|
panels[i].w = w;
|
|
|
|
}
|
|
|
|
panels[i].h = (h / 2) + 1;
|
|
|
|
} else if (j == 1) {
|
|
|
|
panels[i].x = 0;
|
|
|
|
panels[i].y = (h / 2) + 1;
|
2017-02-22 23:45:51 +01:00
|
|
|
if (panels[j + 1].text) {
|
2016-11-22 01:58:52 +01:00
|
|
|
panels[i].w = colpos + 1;
|
|
|
|
} else {
|
|
|
|
panels[i].w = w;
|
|
|
|
}
|
2017-02-22 23:45:51 +01:00
|
|
|
panels[i].h = (h - 1) / 2;
|
2016-11-22 01:58:52 +01:00
|
|
|
} else {
|
|
|
|
int ph = ((h - 1) / (n_panels - 3));
|
|
|
|
panels[i].x = colpos;
|
|
|
|
panels[i].y = 1 + (ph * (j - 2));
|
|
|
|
panels[i].w = w - colpos;
|
|
|
|
if (panels[i].w < 0) {
|
|
|
|
panels[i].w = 0;
|
|
|
|
}
|
|
|
|
panels[i].h = ph;
|
|
|
|
if (!panels[i + 1].text) {
|
|
|
|
panels[i].h = h - panels[i].y;
|
|
|
|
}
|
|
|
|
if (j != 2) {
|
|
|
|
panels[i].y--;
|
|
|
|
panels[i].h++;
|
|
|
|
}
|
2015-09-29 04:26:00 +02:00
|
|
|
}
|
2016-11-22 01:58:52 +01:00
|
|
|
break;
|
2015-03-05 02:07:53 +01:00
|
|
|
}
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-31 05:06:01 +02:00
|
|
|
static void delcurpanel() {
|
2016-05-09 11:13:37 +02:00
|
|
|
int i;
|
2016-10-26 23:16:31 +02:00
|
|
|
if (curnode > 0 && n_panels > 3) {
|
2016-05-09 11:13:37 +02:00
|
|
|
for (i = curnode; i < (n_panels - 1); i++) {
|
|
|
|
panels[i] = panels[i + 1];
|
2015-08-31 05:06:01 +02:00
|
|
|
}
|
|
|
|
panels[i].text = 0;
|
|
|
|
n_panels--;
|
2016-05-09 11:13:37 +02:00
|
|
|
if (curnode >= n_panels) {
|
|
|
|
curnode = n_panels - 1;
|
2015-08-31 05:06:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-03-05 02:07:53 +01:00
|
|
|
|
2015-08-31 05:06:01 +02:00
|
|
|
static void zoom() {
|
2016-05-09 11:13:37 +02:00
|
|
|
if (n_panels > 2) {
|
|
|
|
if (curnode < 2) {
|
2015-08-31 05:43:38 +02:00
|
|
|
curnode = 2;
|
|
|
|
}
|
|
|
|
Panel ocurnode = panels[curnode];
|
|
|
|
panels[curnode] = panels[1];
|
|
|
|
panels[1] = ocurnode;
|
2016-11-22 01:58:52 +01:00
|
|
|
curnode = 1;
|
2015-08-31 05:06:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-23 01:30:41 +09:00
|
|
|
static void refreshAll() {
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < n_panels; i++) {
|
|
|
|
panels[i].refresh = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-11 18:23:44 +09:00
|
|
|
static void addPanelFrame(const char *title, const char *cmd) {
|
2018-03-23 11:17:42 +01:00
|
|
|
if (title) {
|
|
|
|
panels[n_panels].text = strdup (title);
|
|
|
|
panels[n_panels].cmd = r_str_newf (cmd);
|
|
|
|
} else {
|
|
|
|
panels[n_panels].text = r_core_cmd_str (_core, cmd);
|
|
|
|
panels[n_panels].cmd = NULL;
|
|
|
|
}
|
2018-02-21 20:31:01 +09:00
|
|
|
panels[n_panels].type = PANEL_TYPE_FRAME;
|
2018-03-21 19:29:46 +09:00
|
|
|
panels[n_panels].refresh = true;
|
2018-02-21 20:31:01 +09:00
|
|
|
panels[n_panels + 1].text = NULL;
|
2015-08-31 05:06:01 +02:00
|
|
|
n_panels++;
|
2016-11-22 01:58:52 +01:00
|
|
|
curnode = n_panels - 1;
|
2017-02-22 23:45:51 +01:00
|
|
|
zoom ();
|
2016-11-22 01:58:52 +01:00
|
|
|
menu_y = 0;
|
2018-03-23 11:17:42 +01:00
|
|
|
refreshAll ();
|
2015-08-31 05:06:01 +02:00
|
|
|
}
|
|
|
|
|
2018-03-11 18:23:44 +09:00
|
|
|
static bool initPanel() {
|
|
|
|
panels = NULL;
|
|
|
|
panels = calloc (sizeof (Panel), LIMIT);
|
|
|
|
if (!panels) return false;
|
|
|
|
n_panels = 0;
|
|
|
|
menu_pos = 0;
|
|
|
|
panels[n_panels].text = strdup ("");
|
|
|
|
panels[n_panels].type = PANEL_TYPE_MENU;
|
2018-03-21 19:29:46 +09:00
|
|
|
panels[n_panels].refresh = true;
|
2018-03-11 18:23:44 +09:00
|
|
|
n_panels++;
|
|
|
|
|
|
|
|
addPanelFrame (PANEL_TITLE_SYMBOLS, PANEL_CMD_SYMBOLS);
|
|
|
|
addPanelFrame (PANEL_TITLE_STACK, PANEL_CMD_STACK);
|
|
|
|
addPanelFrame (PANEL_TITLE_REGISTERS, PANEL_CMD_REGISTERS);
|
|
|
|
addPanelFrame (PANEL_TITLE_REGISTERREFS, PANEL_CMD_REGISTERREFS);
|
|
|
|
addPanelFrame (PANEL_TITLE_DISASSEMBLY, PANEL_CMD_DISASSEMBLY);
|
2016-11-22 01:58:52 +01:00
|
|
|
curnode = 1;
|
2018-03-11 18:23:44 +09:00
|
|
|
return true;
|
2015-03-05 02:07:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// damn singletons.. there should be only one screen and therefor
|
|
|
|
// only one visual instance of the graph view. refactoring this
|
|
|
|
// into a struct makes the code to reference pointers unnecesarily
|
|
|
|
// we can look for a non-global solution here in the future if
|
|
|
|
// necessary
|
2015-08-31 11:53:03 +02:00
|
|
|
static void r_core_panels_refresh(RCore *core) {
|
|
|
|
char title[1024];
|
2018-03-05 23:32:27 +01:00
|
|
|
const char *color = curnode? core->cons->pal.graph_box : core->cons->pal.graph_box2;
|
2015-08-31 11:53:03 +02:00
|
|
|
char str[1024];
|
2015-03-05 02:07:53 +01:00
|
|
|
int i, j, h, w = r_cons_get_size (&h);
|
2018-03-21 19:29:46 +09:00
|
|
|
r_cons_gotoxy (0, 0);
|
2015-03-05 02:07:53 +01:00
|
|
|
if (!can) {
|
|
|
|
return;
|
|
|
|
}
|
2018-03-22 15:43:59 +09:00
|
|
|
if (isResizing) {
|
|
|
|
isResizing = false;
|
|
|
|
r_cons_canvas_resize (can, w, h);
|
2018-03-23 01:30:41 +09:00
|
|
|
refreshAll ();
|
2018-03-22 15:43:59 +09:00
|
|
|
}
|
2016-11-22 01:58:52 +01:00
|
|
|
#if 0
|
|
|
|
/* avoid flickering */
|
2015-03-05 02:07:53 +01:00
|
|
|
r_cons_canvas_clear (can);
|
2015-09-29 04:26:00 +02:00
|
|
|
r_cons_flush ();
|
2016-11-22 01:58:52 +01:00
|
|
|
#endif
|
2015-03-05 02:07:53 +01:00
|
|
|
if (panels) {
|
2018-03-05 23:32:27 +01:00
|
|
|
panels[menu_pos].x = (menu_y > 0) ? menu_x * 6 : w;
|
2015-03-05 02:07:53 +01:00
|
|
|
panels[menu_pos].y = 1;
|
|
|
|
free (panels[menu_pos].text);
|
2017-03-24 10:46:13 +01:00
|
|
|
panels[menu_pos].text = calloc (1, 1024); // r_str_newf ("%d", menu_y);
|
2015-03-05 02:07:53 +01:00
|
|
|
int maxsub = 0;
|
2017-02-22 23:45:51 +01:00
|
|
|
for (i = 0; menus_sub[i]; i++) {
|
|
|
|
maxsub = i;
|
|
|
|
}
|
2018-03-28 17:00:54 +09:00
|
|
|
if (menu_x < 0) {
|
|
|
|
menu_x = 0;
|
|
|
|
}
|
|
|
|
if (menu_x > maxsub) {
|
|
|
|
menu_x = maxsub;
|
|
|
|
}
|
2015-08-31 05:06:01 +02:00
|
|
|
if (menu_x >= 0 && menu_x <= maxsub && menus_sub[menu_x]) {
|
2015-03-05 02:07:53 +01:00
|
|
|
for (j = 0; menus_sub[menu_x][j]; j++) {
|
2017-02-22 23:45:51 +01:00
|
|
|
if (menu_y - 1 == j) {
|
2015-03-05 02:07:53 +01:00
|
|
|
strcat (panels[menu_pos].text, "> ");
|
|
|
|
} else {
|
|
|
|
strcat (panels[menu_pos].text, " ");
|
|
|
|
}
|
2018-03-23 10:35:30 +01:00
|
|
|
strcat (panels[menu_pos].text, menus_sub[menu_x][j]);
|
2015-08-31 05:06:01 +02:00
|
|
|
strcat (panels[menu_pos].text, " \n");
|
2015-03-05 02:07:53 +01:00
|
|
|
}
|
|
|
|
}
|
2018-03-28 17:00:54 +09:00
|
|
|
for (i = 0; i < n_panels; i++) {
|
2015-08-31 11:53:03 +02:00
|
|
|
if (i != curnode) {
|
2018-02-20 10:15:17 +09:00
|
|
|
Panel_print (can, &panels[i], 0);
|
2015-08-31 11:53:03 +02:00
|
|
|
}
|
2015-03-05 02:07:53 +01:00
|
|
|
}
|
|
|
|
}
|
2018-03-26 13:42:39 +02:00
|
|
|
if (panels && n_panels > 1) {
|
|
|
|
// always refresh first panel or can be trashed
|
|
|
|
panels[1].refresh = true;
|
|
|
|
}
|
2015-03-05 02:07:53 +01:00
|
|
|
if (menu_y) {
|
2015-03-12 15:16:38 -04:00
|
|
|
curnode = menu_pos;
|
2015-03-05 02:07:53 +01:00
|
|
|
}
|
2017-07-26 18:46:22 +02:00
|
|
|
if (panels) {
|
2018-03-23 01:30:41 +09:00
|
|
|
if (panels[curnode].type == PANEL_TYPE_MENU) {
|
2018-03-28 17:00:54 +09:00
|
|
|
panels[curnode].refresh = true;
|
|
|
|
Panel_print (can, &panels[curnode], menu_y);
|
2018-03-23 01:30:41 +09:00
|
|
|
} else {
|
|
|
|
Panel_print (can, &panels[curnode], 1);
|
2017-07-26 18:46:22 +02:00
|
|
|
}
|
2015-03-05 02:07:53 +01:00
|
|
|
}
|
|
|
|
|
2018-02-20 10:15:17 +09:00
|
|
|
(void) r_cons_canvas_gotoxy (can, -can->sx, -can->sy);
|
2015-03-05 02:07:53 +01:00
|
|
|
title[0] = 0;
|
2016-10-26 23:16:31 +02:00
|
|
|
if (curnode == 0) {
|
2015-08-31 05:06:01 +02:00
|
|
|
strcpy (title, "> ");
|
2016-10-26 23:16:31 +02:00
|
|
|
}
|
|
|
|
for (i = 0; menus[i]; i++) {
|
2015-03-05 02:07:53 +01:00
|
|
|
if (menu_x == i) {
|
2017-02-22 23:45:51 +01:00
|
|
|
snprintf (str, sizeof (title) - 1, "%s[%s]"Color_RESET, color, menus[i]);
|
2015-03-05 02:07:53 +01:00
|
|
|
} else {
|
2017-02-22 23:45:51 +01:00
|
|
|
snprintf (str, sizeof (title) - 1, "%s %s "Color_RESET, color, menus[i]);
|
2015-03-05 02:07:53 +01:00
|
|
|
}
|
|
|
|
strcat (title, str);
|
|
|
|
}
|
2016-10-26 23:16:31 +02:00
|
|
|
if (curnode == 0) {
|
2018-02-20 10:15:17 +09:00
|
|
|
r_cons_canvas_write (can, Color_BLUE);
|
|
|
|
r_cons_canvas_write (can, title);
|
|
|
|
r_cons_canvas_write (can, Color_RESET);
|
2015-08-31 05:06:01 +02:00
|
|
|
} else {
|
2018-02-20 10:15:17 +09:00
|
|
|
r_cons_canvas_write (can, Color_RESET);
|
|
|
|
r_cons_canvas_write (can, title);
|
2015-08-31 05:06:01 +02:00
|
|
|
}
|
2015-03-05 02:07:53 +01:00
|
|
|
|
2017-02-22 23:45:51 +01:00
|
|
|
snprintf (title, sizeof (title) - 1,
|
|
|
|
"[0x%08"PFMT64x "]", core->offset);
|
2018-02-20 10:15:17 +09:00
|
|
|
(void) r_cons_canvas_gotoxy (can, -can->sx + w - strlen (title), -can->sy);
|
|
|
|
r_cons_canvas_write (can, title);
|
2015-03-05 02:07:53 +01:00
|
|
|
|
|
|
|
r_cons_canvas_print (can);
|
2015-07-13 23:04:34 +02:00
|
|
|
r_cons_flush ();
|
2015-03-05 02:07:53 +01:00
|
|
|
}
|
|
|
|
|
2018-03-28 17:00:54 +09:00
|
|
|
static void doRefresh(RCore *core) {
|
2018-03-23 10:35:30 +01:00
|
|
|
isResizing = true;
|
|
|
|
Layout_run (panels);
|
|
|
|
r_core_panels_refresh (core);
|
|
|
|
}
|
|
|
|
|
2015-08-31 11:53:03 +02:00
|
|
|
static int havePanel(const char *s) {
|
|
|
|
int i;
|
2016-10-26 23:16:31 +02:00
|
|
|
if (!panels || !panels[0].text) {
|
2015-08-31 11:53:03 +02:00
|
|
|
return 0;
|
2016-10-26 23:16:31 +02:00
|
|
|
}
|
2015-08-31 11:53:03 +02:00
|
|
|
// add new panel for testing
|
2016-10-26 23:16:31 +02:00
|
|
|
for (i = 1; panels[i].text; i++) {
|
2017-02-22 23:45:51 +01:00
|
|
|
if (!strcmp (panels[i].text, s)) {
|
2015-08-31 11:53:03 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-02-22 23:45:51 +01:00
|
|
|
static void panel_single_step_in(RCore *core) {
|
|
|
|
if (r_config_get_i (core->config, "cfg.debug")) {
|
|
|
|
if (core->print->cur_enabled) {
|
|
|
|
// dcu 0xaddr
|
|
|
|
r_core_cmdf (core, "dcu 0x%08"PFMT64x, core->offset + core->print->cur);
|
|
|
|
core->print->cur_enabled = 0;
|
|
|
|
} else {
|
|
|
|
r_core_cmd (core, "ds", 0);
|
|
|
|
r_core_cmd (core, ".dr*", 0);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
r_core_cmd (core, "aes", 0);
|
|
|
|
r_core_cmd (core, ".ar*", 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void panel_single_step_over(RCore *core) {
|
|
|
|
if (r_config_get_i (core->config, "cfg.debug")) {
|
|
|
|
if (core->print->cur_enabled) {
|
|
|
|
r_core_cmd (core, "dcr", 0);
|
|
|
|
core->print->cur_enabled = 0;
|
|
|
|
} else {
|
|
|
|
r_core_cmd (core, "dso", 0);
|
|
|
|
r_core_cmd (core, ".dr*", 0);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
r_core_cmd (core, "aeso", 0);
|
|
|
|
r_core_cmd (core, ".ar*", 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void panel_breakpoint(RCore *core) {
|
|
|
|
r_core_cmd (core, "dbs $$", 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void panel_continue(RCore *core) {
|
|
|
|
r_core_cmd (core, "dc", 0);
|
|
|
|
}
|
|
|
|
|
2018-02-21 19:49:54 +08:00
|
|
|
static bool init (RCore *core, int w, int h) {
|
2018-02-21 20:31:01 +09:00
|
|
|
layout = 0;
|
2015-03-05 02:07:53 +01:00
|
|
|
_core = core;
|
2018-02-21 20:31:01 +09:00
|
|
|
menu_pos = 0;
|
|
|
|
menu_x = 0;
|
|
|
|
callgraph = 0;
|
2018-03-22 15:43:59 +09:00
|
|
|
isResizing = false;
|
2015-06-04 18:51:39 +02:00
|
|
|
can = r_cons_canvas_new (w, h);
|
2017-02-22 23:45:51 +01:00
|
|
|
if (!can) {
|
2018-02-21 20:31:01 +09:00
|
|
|
eprintf ("Cannot create RCons.canvas context\n");
|
2017-02-22 23:45:51 +01:00
|
|
|
return false;
|
|
|
|
}
|
2017-01-14 01:14:50 +01:00
|
|
|
can->linemode = r_config_get_i (core->config, "graph.linemode");
|
2015-03-05 02:07:53 +01:00
|
|
|
can->color = r_config_get_i (core->config, "scr.color");
|
2016-05-09 11:13:37 +02:00
|
|
|
if (w < 140) {
|
2018-03-28 17:00:54 +09:00
|
|
|
columnWidth = w / 3;
|
2015-08-31 05:06:01 +02:00
|
|
|
}
|
2018-03-11 18:23:44 +09:00
|
|
|
if (!initPanel ()) {
|
|
|
|
return false;
|
|
|
|
}
|
2018-02-21 19:49:54 +08:00
|
|
|
return true;
|
2018-02-21 20:31:01 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
R_API int r_core_visual_panels(RCore *core) {
|
|
|
|
int okey, key, wheel;
|
|
|
|
int w, h;
|
|
|
|
int asm_comments = 0;
|
|
|
|
int asm_bytes = 0;
|
|
|
|
int have_utf8 = 0;
|
|
|
|
|
|
|
|
w = r_cons_get_size (&h);
|
2018-02-21 19:49:54 +08:00
|
|
|
if (!init (core, w, h)) {
|
|
|
|
return false;
|
|
|
|
}
|
2015-03-05 02:07:53 +01:00
|
|
|
|
|
|
|
asm_comments = r_config_get_i (core->config, "asm.comments");
|
2018-02-21 20:31:01 +09:00
|
|
|
asm_bytes = r_config_get_i (core->config, "asm.bytes");
|
2015-10-11 11:57:00 -04:00
|
|
|
have_utf8 = r_config_get_i (core->config, "scr.utf8");
|
2015-03-05 02:07:53 +01:00
|
|
|
r_config_set_i (core->config, "asm.comments", 0);
|
|
|
|
r_config_set_i (core->config, "asm.bytes", 0);
|
2018-03-05 23:32:27 +01:00
|
|
|
r_config_set_i (core->config, "scr.utf8", 1);
|
2015-03-05 02:07:53 +01:00
|
|
|
|
|
|
|
repeat:
|
|
|
|
core->cons->event_data = core;
|
2018-03-23 10:35:30 +01:00
|
|
|
// core->cons->event_resize = (RConsEvent) r_core_panels_refresh;
|
2018-03-28 17:00:54 +09:00
|
|
|
core->cons->event_resize = (RConsEvent) doRefresh;
|
2015-03-05 02:07:53 +01:00
|
|
|
Layout_run (panels);
|
|
|
|
r_core_panels_refresh (core);
|
|
|
|
wheel = r_config_get_i (core->config, "scr.wheel");
|
2016-11-22 01:58:52 +01:00
|
|
|
if (wheel) {
|
2015-09-14 12:35:38 +02:00
|
|
|
r_cons_enable_mouse (true);
|
2016-11-22 01:58:52 +01:00
|
|
|
}
|
2015-03-05 02:07:53 +01:00
|
|
|
// r_core_graph_inputhandle()
|
|
|
|
okey = r_cons_readchar ();
|
|
|
|
key = r_cons_arrow_to_hjkl (okey);
|
2017-02-18 13:26:54 +01:00
|
|
|
const char *cmd;
|
2015-03-05 02:07:53 +01:00
|
|
|
switch (key) {
|
2015-08-31 05:06:01 +02:00
|
|
|
case 'u':
|
|
|
|
r_core_cmd0 (core, "s-");
|
|
|
|
break;
|
|
|
|
case 'U':
|
|
|
|
r_core_cmd0 (core, "s+");
|
|
|
|
break;
|
|
|
|
case 'n':
|
2018-03-23 11:17:42 +01:00
|
|
|
{
|
|
|
|
r_cons_enable_mouse (false);
|
|
|
|
char *res = r_cons_input ("New panel with command: ");
|
|
|
|
if (res) {
|
|
|
|
if (*res) {
|
|
|
|
addPanelFrame (res, res);
|
|
|
|
// do not refresh stuff
|
|
|
|
}
|
|
|
|
free (res);
|
|
|
|
}
|
|
|
|
r_cons_enable_mouse (true);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'N':
|
|
|
|
{
|
|
|
|
r_cons_enable_mouse (false);
|
|
|
|
char *res = r_cons_input ("New panel with command: ");
|
|
|
|
if (res) {
|
|
|
|
if (*res) {
|
|
|
|
addPanelFrame (NULL, res);
|
|
|
|
}
|
|
|
|
free (res);
|
|
|
|
}
|
|
|
|
r_cons_enable_mouse (true);
|
|
|
|
}
|
2015-08-31 05:06:01 +02:00
|
|
|
break;
|
|
|
|
case 'p':
|
|
|
|
r_core_cmd0 (core, "sp");
|
|
|
|
break;
|
2018-03-23 11:17:42 +01:00
|
|
|
case 'P':
|
|
|
|
r_core_cmd0 (core, "sn");
|
|
|
|
break;
|
2015-08-31 05:06:01 +02:00
|
|
|
case '.':
|
|
|
|
if (r_config_get_i (core->config, "cfg.debug")) {
|
2015-10-31 01:57:52 +01:00
|
|
|
r_core_cmd0 (core, "sr PC");
|
2017-03-24 10:46:13 +01:00
|
|
|
// r_core_seek (core, r_num_math (core->num, "entry0"), 1);
|
2015-08-31 05:06:01 +02:00
|
|
|
} else {
|
|
|
|
r_core_cmd0 (core, "s entry0; px");
|
|
|
|
}
|
2018-03-28 17:00:54 +09:00
|
|
|
doRefresh (core);
|
2015-08-31 05:06:01 +02:00
|
|
|
break;
|
2015-03-05 02:07:53 +01:00
|
|
|
case ' ':
|
2015-08-31 05:06:01 +02:00
|
|
|
case '\r':
|
2015-03-05 02:07:53 +01:00
|
|
|
case '\n':
|
2015-08-31 05:06:01 +02:00
|
|
|
if (curnode == 0 && menu_y) {
|
2017-02-22 23:45:51 +01:00
|
|
|
const char *action = menus_sub[menu_x][menu_y - 1];
|
2015-03-05 02:07:53 +01:00
|
|
|
if (strstr (action, "New")) {
|
2018-03-11 18:23:44 +09:00
|
|
|
addPanelFrame (PANEL_TITLE_NEWFILES, "o");
|
2015-08-31 05:06:01 +02:00
|
|
|
} else if (strstr (action, "Open")) {
|
2017-02-23 19:46:01 +01:00
|
|
|
/* XXX doesnt autocompletes filenames */
|
|
|
|
r_cons_enable_mouse (false);
|
2015-08-31 05:06:01 +02:00
|
|
|
char *res = r_cons_input ("open file: ");
|
2015-08-31 11:53:03 +02:00
|
|
|
if (res) {
|
2017-02-22 23:45:51 +01:00
|
|
|
if (*res) {
|
2015-08-31 11:53:03 +02:00
|
|
|
r_core_cmdf (core, "o %s", res);
|
2017-02-22 23:45:51 +01:00
|
|
|
}
|
2015-08-31 11:53:03 +02:00
|
|
|
free (res);
|
2015-08-31 05:06:01 +02:00
|
|
|
}
|
2017-02-23 19:46:01 +01:00
|
|
|
r_cons_enable_mouse (true);
|
2018-03-23 10:35:30 +01:00
|
|
|
} else if (strstr (action, "RegisterRefs")) {
|
|
|
|
addPanelFrame ("drr", "drr");
|
|
|
|
} else if (strstr (action, "Registers")) {
|
|
|
|
addPanelFrame ("dr=", "dr=");
|
2015-08-31 05:06:01 +02:00
|
|
|
} else if (strstr (action, "Info")) {
|
2018-03-11 18:23:44 +09:00
|
|
|
addPanelFrame (PANEL_TITLE_INFO, "i");
|
2015-08-31 05:06:01 +02:00
|
|
|
} else if (strstr (action, "Database")) {
|
2018-03-11 18:23:44 +09:00
|
|
|
addPanelFrame (PANEL_TITLE_DATABASE, "k ***");
|
2015-08-31 05:06:01 +02:00
|
|
|
} else if (strstr (action, "Registers")) {
|
2015-08-31 11:53:03 +02:00
|
|
|
if (!havePanel ("Registers")) {
|
2018-03-11 18:23:44 +09:00
|
|
|
addPanelFrame (PANEL_TITLE_REGISTERS, "dr=");
|
2015-08-31 05:06:01 +02:00
|
|
|
}
|
2015-08-31 11:53:03 +02:00
|
|
|
} else if (strstr (action, "About")) {
|
2015-08-31 05:06:01 +02:00
|
|
|
char *s = r_core_cmd_str (core, "?V");
|
|
|
|
r_cons_message (s);
|
|
|
|
free (s);
|
|
|
|
} else if (strstr (action, "Hexdump")) {
|
2018-03-11 18:23:44 +09:00
|
|
|
addPanelFrame (PANEL_TITLE_HEXDUMP, "px 512");
|
2015-08-31 05:06:01 +02:00
|
|
|
} else if (strstr (action, "Disassembly")) {
|
2018-03-11 18:23:44 +09:00
|
|
|
addPanelFrame (PANEL_TITLE_DISASSEMBLY, "pd 128");
|
2015-08-31 05:06:01 +02:00
|
|
|
} else if (strstr (action, "Functions")) {
|
2018-03-11 18:23:44 +09:00
|
|
|
addPanelFrame (PANEL_TITLE_FUNCTIONS, "afl");
|
2015-08-31 05:43:38 +02:00
|
|
|
} else if (strstr (action, "Comments")) {
|
2018-03-11 18:23:44 +09:00
|
|
|
addPanelFrame (PANEL_TITLE_COMMENTS, "CC");
|
2015-08-31 05:43:38 +02:00
|
|
|
} else if (strstr (action, "Entropy")) {
|
2018-03-11 18:23:44 +09:00
|
|
|
addPanelFrame (PANEL_TITLE_ENTROPY, "p=e");
|
2015-08-31 05:06:01 +02:00
|
|
|
} else if (strstr (action, "Function")) {
|
|
|
|
r_core_cmdf (core, "af");
|
2015-08-31 11:53:03 +02:00
|
|
|
} else if (strstr (action, "DRX")) {
|
2018-03-11 18:23:44 +09:00
|
|
|
addPanelFrame (PANEL_TITLE_DRX, "drx");
|
2015-08-31 05:06:01 +02:00
|
|
|
} else if (strstr (action, "Program")) {
|
|
|
|
r_core_cmdf (core, "aaa");
|
|
|
|
} else if (strstr (action, "Calls")) {
|
|
|
|
r_core_cmdf (core, "aac");
|
2015-08-31 11:53:03 +02:00
|
|
|
} else if (strstr (action, "ROP")) {
|
2017-02-23 19:46:01 +01:00
|
|
|
r_cons_enable_mouse (false);
|
2015-08-31 11:53:03 +02:00
|
|
|
char *res = r_cons_input ("rop grep: ");
|
|
|
|
if (res) {
|
2016-05-09 11:13:37 +02:00
|
|
|
r_core_cmdf (core, "\"/R %s\"", res);
|
2015-08-31 11:53:03 +02:00
|
|
|
free (res);
|
|
|
|
}
|
2017-02-23 19:46:01 +01:00
|
|
|
r_cons_enable_mouse (true);
|
2015-08-31 11:53:03 +02:00
|
|
|
} else if (strstr (action, "String")) {
|
2017-02-23 19:46:01 +01:00
|
|
|
r_cons_enable_mouse (false);
|
2015-08-31 11:53:03 +02:00
|
|
|
char *res = r_cons_input ("search string: ");
|
|
|
|
if (res) {
|
2016-05-09 11:13:37 +02:00
|
|
|
r_core_cmdf (core, "\"/ %s\"", res);
|
2015-08-31 11:53:03 +02:00
|
|
|
free (res);
|
|
|
|
}
|
2017-02-23 19:46:01 +01:00
|
|
|
r_cons_enable_mouse (true);
|
2015-08-31 11:53:03 +02:00
|
|
|
} else if (strstr (action, "Hexpairs")) {
|
2017-02-23 19:46:01 +01:00
|
|
|
r_cons_enable_mouse (false);
|
2015-08-31 11:53:03 +02:00
|
|
|
char *res = r_cons_input ("search hexpairs: ");
|
|
|
|
if (res) {
|
2016-05-09 11:13:37 +02:00
|
|
|
r_core_cmdf (core, "\"/x %s\"", res);
|
2015-08-31 11:53:03 +02:00
|
|
|
free (res);
|
|
|
|
}
|
2017-02-23 19:46:01 +01:00
|
|
|
r_cons_enable_mouse (true);
|
2015-08-31 11:53:03 +02:00
|
|
|
} else if (strstr (action, "Code")) {
|
2017-02-23 19:46:01 +01:00
|
|
|
r_cons_enable_mouse (false);
|
2015-08-31 11:53:03 +02:00
|
|
|
char *res = r_cons_input ("search code: ");
|
|
|
|
if (res) {
|
2016-05-09 11:13:37 +02:00
|
|
|
r_core_cmdf (core, "\"/c %s\"", res);
|
2015-08-31 11:53:03 +02:00
|
|
|
free (res);
|
|
|
|
}
|
2017-02-23 19:46:01 +01:00
|
|
|
r_cons_enable_mouse (true);
|
2015-08-31 05:06:01 +02:00
|
|
|
} else if (strstr (action, "Copy")) {
|
2017-02-23 19:46:01 +01:00
|
|
|
r_cons_enable_mouse (false);
|
2015-08-31 05:06:01 +02:00
|
|
|
char *res = r_cons_input ("How many bytes? ");
|
|
|
|
if (res) {
|
2016-05-09 11:13:37 +02:00
|
|
|
r_core_cmdf (core, "\"y %s\"", res);
|
2015-08-31 05:06:01 +02:00
|
|
|
free (res);
|
|
|
|
}
|
2017-02-23 19:46:01 +01:00
|
|
|
r_cons_enable_mouse (true);
|
2015-08-31 05:06:01 +02:00
|
|
|
} else if (strstr (action, "Write String")) {
|
2017-02-23 19:46:01 +01:00
|
|
|
r_cons_enable_mouse (false);
|
2015-08-31 05:06:01 +02:00
|
|
|
char *res = r_cons_input ("insert string: ");
|
|
|
|
if (res) {
|
2016-05-09 11:13:37 +02:00
|
|
|
r_core_cmdf (core, "\"w %s\"", res);
|
2015-08-31 05:06:01 +02:00
|
|
|
free (res);
|
|
|
|
}
|
2017-02-23 19:46:01 +01:00
|
|
|
r_cons_enable_mouse (true);
|
2015-08-31 05:06:01 +02:00
|
|
|
} else if (strstr (action, "Write Value")) {
|
2017-02-23 19:46:01 +01:00
|
|
|
r_cons_enable_mouse (false);
|
2015-08-31 05:06:01 +02:00
|
|
|
char *res = r_cons_input ("insert number: ");
|
|
|
|
if (res) {
|
2016-05-09 11:13:37 +02:00
|
|
|
r_core_cmdf (core, "\"wv %s\"", res);
|
2015-08-31 05:06:01 +02:00
|
|
|
free (res);
|
|
|
|
}
|
2017-02-23 19:46:01 +01:00
|
|
|
r_cons_enable_mouse (true);
|
2015-08-31 05:06:01 +02:00
|
|
|
} else if (strstr (action, "Write Hex")) {
|
2017-02-23 19:46:01 +01:00
|
|
|
r_cons_enable_mouse (false);
|
2015-08-31 05:06:01 +02:00
|
|
|
char *res = r_cons_input ("insert hexpairs: ");
|
|
|
|
if (res) {
|
2016-05-09 11:13:37 +02:00
|
|
|
r_core_cmdf (core, "\"wx %s\"", res);
|
2015-08-31 05:06:01 +02:00
|
|
|
free (res);
|
|
|
|
}
|
2017-02-23 19:46:01 +01:00
|
|
|
r_cons_enable_mouse (true);
|
2015-08-31 05:06:01 +02:00
|
|
|
} else if (strstr (action, "Calculator")) {
|
2017-02-23 19:46:01 +01:00
|
|
|
r_cons_enable_mouse (false);
|
2015-08-31 05:06:01 +02:00
|
|
|
for (;;) {
|
|
|
|
char *s = r_cons_input ("> ");
|
2015-08-31 00:42:21 -04:00
|
|
|
if (!s || !*s) {
|
|
|
|
free (s);
|
2015-08-31 05:06:01 +02:00
|
|
|
break;
|
2015-08-31 00:42:21 -04:00
|
|
|
}
|
2015-08-31 05:06:01 +02:00
|
|
|
r_core_cmdf (core, "? %s", s);
|
|
|
|
r_cons_flush ();
|
|
|
|
free (s);
|
|
|
|
}
|
2017-02-23 19:46:01 +01:00
|
|
|
r_cons_enable_mouse (true);
|
2015-08-31 05:06:01 +02:00
|
|
|
} else if (strstr (action, "Assemble")) {
|
|
|
|
r_core_visual_asm (core, core->offset);
|
|
|
|
} else if (strstr (action, "Sections")) {
|
2018-03-11 18:23:44 +09:00
|
|
|
addPanelFrame (PANEL_TITLE_SECTIONS, "iSq");
|
2015-08-31 05:06:01 +02:00
|
|
|
} else if (strstr (action, "Close")) {
|
|
|
|
r_core_cmd0 (core, "o-*");
|
|
|
|
} else if (strstr (action, "Strings")) {
|
2018-03-11 18:23:44 +09:00
|
|
|
addPanelFrame (PANEL_TITLE_STRINGS, "izq");
|
2015-08-31 05:06:01 +02:00
|
|
|
} else if (strstr (action, "Maps")) {
|
2018-03-11 18:23:44 +09:00
|
|
|
addPanelFrame (PANEL_TITLE_MAPS, "dm");
|
2016-11-22 01:58:52 +01:00
|
|
|
} else if (strstr (action, "Modules")) {
|
2018-03-11 18:23:44 +09:00
|
|
|
addPanelFrame (PANEL_TITLE_MODULES, "dmm");
|
2015-08-31 05:06:01 +02:00
|
|
|
} else if (strstr (action, "Backtrace")) {
|
2018-03-11 18:23:44 +09:00
|
|
|
addPanelFrame (PANEL_TITLE_BACKTRACE, "dbt");
|
2016-11-22 01:58:52 +01:00
|
|
|
} else if (strstr (action, "Step")) {
|
|
|
|
r_core_cmd (core, "ds", 0);
|
|
|
|
r_cons_flush ();
|
|
|
|
} else if (strstr (action, "Step Over")) {
|
|
|
|
r_core_cmd (core, "dso", 0);
|
|
|
|
r_cons_flush ();
|
2017-11-20 09:16:02 +01:00
|
|
|
} else if (strstr (action, "Continue")) {
|
|
|
|
r_core_cmd (core, "dc", 0);
|
|
|
|
r_cons_flush ();
|
2015-08-31 05:06:01 +02:00
|
|
|
} else if (strstr (action, "Breakpoints")) {
|
2018-03-11 18:23:44 +09:00
|
|
|
addPanelFrame (PANEL_TITLE_BREAKPOINTS, "db");
|
2015-08-31 05:06:01 +02:00
|
|
|
} else if (strstr (action, "Symbols")) {
|
2018-03-11 18:23:44 +09:00
|
|
|
addPanelFrame (PANEL_TITLE_SYMBOLS, "isq");
|
2015-08-31 05:06:01 +02:00
|
|
|
} else if (strstr (action, "Imports")) {
|
2018-03-11 18:23:44 +09:00
|
|
|
addPanelFrame (PANEL_TITLE_IMPORTS, "iiq");
|
2015-08-31 05:06:01 +02:00
|
|
|
} else if (strstr (action, "Paste")) {
|
|
|
|
r_core_cmd0 (core, "yy");
|
|
|
|
} else if (strstr (action, "Clipboard")) {
|
2018-03-11 18:23:44 +09:00
|
|
|
addPanelFrame (PANEL_TITLE_CLIPBOARD, "yx");
|
2015-08-31 05:06:01 +02:00
|
|
|
} else if (strstr (action, "io.cache")) {
|
|
|
|
r_core_cmd0 (core, "e!io.cache");
|
|
|
|
} else if (strstr (action, "Fill")) {
|
2017-03-24 10:46:13 +01:00
|
|
|
r_cons_enable_mouse (false);
|
2015-08-31 05:06:01 +02:00
|
|
|
char *s = r_cons_input ("Fill with: ");
|
|
|
|
r_core_cmdf (core, "wow %s", s);
|
|
|
|
free (s);
|
2017-03-24 10:46:13 +01:00
|
|
|
r_cons_enable_mouse (true);
|
2015-08-31 05:06:01 +02:00
|
|
|
} else if (strstr (action, "References")) {
|
|
|
|
r_core_cmdf (core, "aar");
|
2015-08-31 05:43:38 +02:00
|
|
|
} else if (strstr (action, "FcnInfo")) {
|
2018-03-11 18:23:44 +09:00
|
|
|
addPanelFrame (PANEL_TITLE_FCNINFO, "afi");
|
2015-08-31 05:06:01 +02:00
|
|
|
} else if (strstr (action, "Graph")) {
|
2016-01-04 23:00:01 +01:00
|
|
|
r_core_visual_graph (core, NULL, NULL, true);
|
2018-03-11 18:23:44 +09:00
|
|
|
// addPanelFrame ("Graph", "agf");
|
2015-08-31 05:43:38 +02:00
|
|
|
} else if (strstr (action, "System Shell")) {
|
|
|
|
r_cons_set_raw (0);
|
2015-09-29 04:26:00 +02:00
|
|
|
r_cons_flush ();
|
2015-08-31 05:43:38 +02:00
|
|
|
r_sys_cmd ("$SHELL");
|
2015-09-29 04:26:00 +02:00
|
|
|
} else if (strstr (action, "R2 Shell")) {
|
2015-09-14 12:35:38 +02:00
|
|
|
core->vmode = false;
|
2015-08-31 05:06:01 +02:00
|
|
|
r_core_visual_prompt_input (core);
|
2015-09-14 12:35:38 +02:00
|
|
|
core->vmode = true;
|
2015-09-29 04:26:00 +02:00
|
|
|
} else if (!strcmp (action, "2048")) {
|
2016-05-26 17:58:02 +03:00
|
|
|
r_cons_2048 (can->color);
|
2015-08-31 05:06:01 +02:00
|
|
|
} else if (strstr (action, "License")) {
|
2016-12-21 00:36:38 +01:00
|
|
|
r_cons_message ("Copyright 2006-2016 - pancake - LGPL");
|
2015-08-31 05:06:01 +02:00
|
|
|
} else if (strstr (action, "Fortune")) {
|
|
|
|
char *s = r_core_cmd_str (core, "fo");
|
|
|
|
r_cons_message (s);
|
|
|
|
free (s);
|
|
|
|
} else if (strstr (action, "Commands")) {
|
|
|
|
r_core_cmd0 (core, "?;?@?;?$?;???");
|
2017-02-22 23:45:51 +01:00
|
|
|
r_cons_any_key (NULL);
|
2015-08-31 05:06:01 +02:00
|
|
|
} else if (strstr (action, "Colors")) {
|
|
|
|
r_core_cmd0 (core, "e!scr.color");
|
|
|
|
} else if (strstr (action, "Quit")) {
|
2015-03-05 02:07:53 +01:00
|
|
|
goto beach;
|
|
|
|
}
|
2015-08-31 05:06:01 +02:00
|
|
|
} else {
|
2016-11-22 01:58:52 +01:00
|
|
|
if (curnode > 0) {
|
2015-09-29 04:26:00 +02:00
|
|
|
zoom ();
|
2015-08-31 05:06:01 +02:00
|
|
|
} else {
|
|
|
|
menu_y = 1;
|
|
|
|
}
|
2015-03-05 02:07:53 +01:00
|
|
|
}
|
2018-03-28 17:00:54 +09:00
|
|
|
doRefresh (core);
|
2015-03-05 02:07:53 +01:00
|
|
|
break;
|
|
|
|
case '?':
|
|
|
|
r_cons_clear00 ();
|
2015-03-05 23:33:28 +01:00
|
|
|
r_cons_printf ("Visual Ascii Art Panels:\n"
|
2017-02-22 23:45:51 +01:00
|
|
|
" ! - run r2048 game\n"
|
|
|
|
" . - seek to PC or entrypoint\n"
|
2018-03-23 11:17:42 +01:00
|
|
|
" : - run r2 command in prompt\n"
|
2017-02-22 23:45:51 +01:00
|
|
|
" _ - start the hud input mode\n"
|
2018-03-23 11:17:42 +01:00
|
|
|
" ? - show this help\n"
|
2017-02-22 23:45:51 +01:00
|
|
|
" x - close current panel\n"
|
|
|
|
" m - open menubar\n"
|
|
|
|
" V - view graph\n"
|
|
|
|
" C - toggle color\n"
|
|
|
|
" M - open new custom frame\n"
|
|
|
|
" hl - toggle scr.color\n"
|
|
|
|
" HL - move vertical column split\n"
|
|
|
|
" jk - scroll/select menu\n"
|
|
|
|
" JK - select prev/next panels (same as TAB)\n"
|
|
|
|
" sS - step in / step over\n"
|
|
|
|
" uU - undo / redo seek\n"
|
2018-03-23 11:17:42 +01:00
|
|
|
" pP - seek to next or previous scr.nkey\n"
|
|
|
|
" nN - create new panel with given command\n"
|
2017-02-22 23:45:51 +01:00
|
|
|
" q - quit, back to visual mode\n"
|
|
|
|
);
|
2015-03-05 02:07:53 +01:00
|
|
|
r_cons_flush ();
|
2015-03-05 23:33:28 +01:00
|
|
|
r_cons_any_key (NULL);
|
2015-03-05 02:07:53 +01:00
|
|
|
break;
|
2015-08-31 05:06:01 +02:00
|
|
|
case 's':
|
|
|
|
if (r_config_get_i (core->config, "cfg.debug")) {
|
2017-03-24 10:46:13 +01:00
|
|
|
r_core_cmd0 (core, "ds;.dr*"); // ;sr PC");
|
2015-08-31 05:06:01 +02:00
|
|
|
} else {
|
2017-02-22 23:45:51 +01:00
|
|
|
panel_single_step_in (core);
|
2015-08-31 05:06:01 +02:00
|
|
|
}
|
2018-03-23 15:29:36 +09:00
|
|
|
refreshAll ();
|
2015-08-31 05:06:01 +02:00
|
|
|
break;
|
|
|
|
case 'S':
|
|
|
|
if (r_config_get_i (core->config, "cfg.debug")) {
|
2017-03-24 10:46:13 +01:00
|
|
|
r_core_cmd0 (core, "dso;.dr*"); // ;sr PC");
|
2015-08-31 05:06:01 +02:00
|
|
|
} else {
|
2017-02-22 23:45:51 +01:00
|
|
|
panel_single_step_over (core);
|
2015-08-31 05:06:01 +02:00
|
|
|
}
|
2018-03-23 15:29:36 +09:00
|
|
|
refreshAll ();
|
2015-08-31 05:06:01 +02:00
|
|
|
break;
|
2015-03-05 02:07:53 +01:00
|
|
|
case ':':
|
2015-09-14 12:35:38 +02:00
|
|
|
core->vmode = false;
|
2015-03-05 02:07:53 +01:00
|
|
|
r_core_visual_prompt_input (core);
|
2015-09-14 12:35:38 +02:00
|
|
|
core->vmode = true;
|
2017-12-16 09:48:26 -06:00
|
|
|
|
|
|
|
// FIX: Issue with visual mode instruction highlighter
|
|
|
|
// not updating after 'ds' or 'dcu' commands.
|
|
|
|
r_core_cmd0 (core, ".dr*");
|
2018-03-28 17:00:54 +09:00
|
|
|
doRefresh (core);
|
2015-03-05 02:07:53 +01:00
|
|
|
break;
|
|
|
|
case 'C':
|
2018-02-20 10:15:17 +09:00
|
|
|
can->color = !can->color;
|
2017-03-24 10:46:13 +01:00
|
|
|
// r_config_toggle (core->config, "scr.color");
|
2015-03-05 02:07:53 +01:00
|
|
|
// refresh graph
|
2018-03-28 17:00:54 +09:00
|
|
|
doRefresh (core);
|
2015-03-05 02:07:53 +01:00
|
|
|
break;
|
2015-09-29 04:26:00 +02:00
|
|
|
case 'R':
|
2016-11-22 01:58:52 +01:00
|
|
|
if (r_config_get_i (core->config, "scr.randpal")) {
|
|
|
|
r_core_cmd0 (core, "ecr");
|
|
|
|
} else {
|
|
|
|
r_core_cmd0 (core, "ecn");
|
|
|
|
}
|
2018-03-28 17:00:54 +09:00
|
|
|
doRefresh (core);
|
2015-03-05 23:33:28 +01:00
|
|
|
break;
|
2015-03-05 02:07:53 +01:00
|
|
|
case 'j':
|
2018-03-21 19:29:46 +09:00
|
|
|
panels[curnode].refresh = true;
|
2016-11-22 01:58:52 +01:00
|
|
|
if (curnode == 0) {
|
2018-03-11 18:23:44 +09:00
|
|
|
if (panels[curnode].type == PANEL_TYPE_MENU) {
|
2017-02-22 23:45:51 +01:00
|
|
|
if (menus_sub[menu_x][menu_y]) {
|
|
|
|
menu_y++;
|
|
|
|
}
|
2015-08-31 05:06:01 +02:00
|
|
|
}
|
|
|
|
} else {
|
2015-09-29 04:26:00 +02:00
|
|
|
if (curnode == 1) {
|
2018-03-01 06:16:11 +09:00
|
|
|
int cols = core->print->cols;
|
|
|
|
RAnalFunction *f = NULL;
|
|
|
|
RAsmOp op;
|
|
|
|
f = r_anal_get_fcn_in (core->anal, core->offset, 0);
|
|
|
|
op.size = 1;
|
|
|
|
if (f && f->folded) {
|
|
|
|
cols = core->offset - f->addr + r_anal_fcn_size (f);
|
|
|
|
} 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 > 1 ? op.size : 1;
|
|
|
|
}
|
|
|
|
r_core_seek (core, core->offset + cols, 1);
|
2018-03-01 14:58:20 +09:00
|
|
|
r_core_block_read (core);
|
2015-09-29 04:26:00 +02:00
|
|
|
} else {
|
2017-02-22 23:45:51 +01:00
|
|
|
panels[curnode].sy++;
|
2015-09-29 04:26:00 +02:00
|
|
|
}
|
2015-03-05 23:07:39 +01:00
|
|
|
}
|
2015-03-05 02:07:53 +01:00
|
|
|
break;
|
|
|
|
case 'k':
|
2018-03-21 19:29:46 +09:00
|
|
|
panels[curnode].refresh = true;
|
2017-02-22 23:45:51 +01:00
|
|
|
if (curnode == 0) {
|
2018-03-11 18:23:44 +09:00
|
|
|
if (panels[curnode].type == PANEL_TYPE_MENU) {
|
2017-02-22 23:45:51 +01:00
|
|
|
menu_y--;
|
|
|
|
if (menu_y < 0) {
|
2015-08-31 05:06:01 +02:00
|
|
|
menu_y = 0;
|
2017-02-22 23:45:51 +01:00
|
|
|
}
|
2015-08-31 05:06:01 +02:00
|
|
|
}
|
|
|
|
} else {
|
2015-09-29 04:26:00 +02:00
|
|
|
if (curnode == 1) {
|
|
|
|
r_core_cmd0 (core, "s-8");
|
|
|
|
} else {
|
2018-02-14 16:05:56 +09:00
|
|
|
if (panels[curnode].sy > 0) {
|
|
|
|
panels[curnode].sy--;
|
|
|
|
}
|
2015-09-29 04:26:00 +02:00
|
|
|
}
|
2015-03-06 00:56:10 +01:00
|
|
|
}
|
2015-03-05 02:07:53 +01:00
|
|
|
break;
|
2015-08-31 13:57:39 +02:00
|
|
|
case '_':
|
|
|
|
r_core_visual_hud (core);
|
|
|
|
break;
|
2015-08-31 05:06:01 +02:00
|
|
|
case 'x':
|
2016-10-26 23:16:31 +02:00
|
|
|
delcurpanel ();
|
2018-03-23 11:20:25 +01:00
|
|
|
refreshAll ();
|
2015-08-31 05:06:01 +02:00
|
|
|
break;
|
|
|
|
case 9: // TAB
|
2015-03-05 23:07:39 +01:00
|
|
|
case 'J':
|
2015-08-31 05:06:01 +02:00
|
|
|
menu_y = 0;
|
|
|
|
menu_x = -1;
|
2018-03-23 15:29:36 +09:00
|
|
|
panels[curnode].refresh = true;
|
|
|
|
curnode++;
|
2018-03-21 19:29:46 +09:00
|
|
|
panels[curnode].refresh = true;
|
2015-03-05 23:07:39 +01:00
|
|
|
if (!panels[curnode].text) {
|
2015-08-31 05:06:01 +02:00
|
|
|
curnode = 0;
|
|
|
|
menu_x = 0;
|
2015-03-05 23:07:39 +01:00
|
|
|
}
|
|
|
|
break;
|
2017-08-27 19:31:17 +02:00
|
|
|
case 'Z': // SHIFT-TAB
|
2015-03-05 23:07:39 +01:00
|
|
|
case 'K':
|
2015-08-31 05:06:01 +02:00
|
|
|
menu_y = 0;
|
|
|
|
menu_x = -1;
|
2018-03-23 15:29:36 +09:00
|
|
|
panels[curnode].refresh = true;
|
2015-03-05 23:07:39 +01:00
|
|
|
curnode--;
|
2018-03-23 15:29:36 +09:00
|
|
|
panels[curnode].refresh = true;
|
2016-10-26 23:16:31 +02:00
|
|
|
if (curnode < 0) {
|
2015-08-31 05:06:01 +02:00
|
|
|
curnode = n_panels - 1;
|
|
|
|
}
|
|
|
|
if (!curnode) {
|
|
|
|
menu_x = 0;
|
|
|
|
}
|
|
|
|
break;
|
2015-08-31 23:36:35 +02:00
|
|
|
case 'M':
|
2017-02-22 23:45:51 +01:00
|
|
|
{
|
2017-02-23 19:46:01 +01:00
|
|
|
r_cons_enable_mouse (false);
|
2017-02-22 23:45:51 +01:00
|
|
|
char *name = r_cons_input ("Name: ");
|
|
|
|
char *cmd = r_cons_input ("Command: ");
|
|
|
|
if (name && *name && cmd && *cmd) {
|
2018-03-11 18:23:44 +09:00
|
|
|
addPanelFrame (name, cmd);
|
2015-08-31 23:36:35 +02:00
|
|
|
}
|
2017-02-22 23:45:51 +01:00
|
|
|
free (name);
|
|
|
|
free (cmd);
|
2017-02-23 19:46:01 +01:00
|
|
|
r_cons_enable_mouse (true);
|
2017-02-22 23:45:51 +01:00
|
|
|
}
|
|
|
|
break;
|
2015-08-31 05:06:01 +02:00
|
|
|
case 'm':
|
|
|
|
curnode = 0;
|
2016-10-26 23:16:31 +02:00
|
|
|
if (menu_x < 0) {
|
2015-08-31 05:06:01 +02:00
|
|
|
menu_x = 0;
|
|
|
|
r_core_panels_refresh (core);
|
|
|
|
}
|
|
|
|
menu_y = 1;
|
2015-03-05 23:07:39 +01:00
|
|
|
break;
|
|
|
|
case 'H':
|
2018-03-28 17:00:54 +09:00
|
|
|
columnWidth += 4;
|
2018-03-22 15:43:59 +09:00
|
|
|
isResizing = true;
|
2015-03-05 23:07:39 +01:00
|
|
|
break;
|
|
|
|
case 'L':
|
2018-03-28 17:00:54 +09:00
|
|
|
columnWidth -= 4;
|
2018-03-22 15:43:59 +09:00
|
|
|
isResizing = true;
|
2018-03-28 17:00:54 +09:00
|
|
|
if (columnWidth < 0) {
|
|
|
|
columnWidth = 0;
|
2017-02-22 23:45:51 +01:00
|
|
|
}
|
2015-03-05 23:07:39 +01:00
|
|
|
break;
|
2015-03-05 02:07:53 +01:00
|
|
|
case 'h':
|
2018-03-21 19:29:46 +09:00
|
|
|
panels[curnode].refresh = true;
|
2015-08-31 05:06:01 +02:00
|
|
|
if (curnode == 0) {
|
|
|
|
if (menu_x) {
|
2017-02-22 23:45:51 +01:00
|
|
|
menu_x--;
|
|
|
|
menu_y = menu_y? 1: 0;
|
2015-08-31 05:06:01 +02:00
|
|
|
r_core_panels_refresh (core);
|
|
|
|
}
|
2015-09-29 04:26:00 +02:00
|
|
|
} else {
|
2017-02-22 23:45:51 +01:00
|
|
|
panels[curnode].sx--;
|
2015-03-05 12:18:37 +01:00
|
|
|
}
|
2015-03-05 02:07:53 +01:00
|
|
|
break;
|
|
|
|
case 'l':
|
2018-03-21 19:29:46 +09:00
|
|
|
panels[curnode].refresh = true;
|
2015-08-31 05:06:01 +02:00
|
|
|
if (curnode == 0) {
|
|
|
|
if (menus[menu_x + 1]) {
|
2017-02-22 23:45:51 +01:00
|
|
|
menu_x++;
|
|
|
|
menu_y = menu_y? 1: 0;
|
2015-08-31 05:06:01 +02:00
|
|
|
r_core_panels_refresh (core);
|
|
|
|
}
|
2015-09-29 04:26:00 +02:00
|
|
|
} else {
|
2017-02-22 23:45:51 +01:00
|
|
|
panels[curnode].sx++;
|
2015-03-05 12:18:37 +01:00
|
|
|
}
|
2015-03-05 02:07:53 +01:00
|
|
|
break;
|
2015-09-29 04:26:00 +02:00
|
|
|
case 'V':
|
2016-09-02 17:14:52 +02:00
|
|
|
/* copypasta from visual.c */
|
|
|
|
if (r_config_get_i (core->config, "graph.web")) {
|
|
|
|
r_core_cmd0 (core, "agv $$");
|
|
|
|
} else {
|
2015-09-29 04:26:00 +02:00
|
|
|
RAnalFunction *fun = r_anal_get_fcn_in (core->anal, core->offset, R_ANAL_FCN_TYPE_NULL);
|
|
|
|
int ocolor;
|
|
|
|
|
|
|
|
if (!fun) {
|
2017-02-22 23:45:51 +01:00
|
|
|
r_cons_message ("Not in a function. Type 'df' to define it here");
|
2015-09-29 04:26:00 +02:00
|
|
|
break;
|
|
|
|
} else if (r_list_empty (fun->bbs)) {
|
2017-02-22 23:45:51 +01:00
|
|
|
r_cons_message ("No basic blocks in this function. You may want to use 'afb+'.");
|
2015-09-29 04:26:00 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
ocolor = r_config_get_i (core->config, "scr.color");
|
2016-01-04 23:00:01 +01:00
|
|
|
r_core_visual_graph (core, NULL, NULL, true);
|
2015-09-29 04:26:00 +02:00
|
|
|
r_config_set_i (core->config, "scr.color", ocolor);
|
|
|
|
}
|
|
|
|
break;
|
2016-11-22 01:58:52 +01:00
|
|
|
case ']':
|
|
|
|
r_config_set_i (core->config, "hex.cols", r_config_get_i (core->config, "hex.cols") + 1);
|
|
|
|
break;
|
|
|
|
case '[':
|
|
|
|
r_config_set_i (core->config, "hex.cols", r_config_get_i (core->config, "hex.cols") - 1);
|
|
|
|
break;
|
|
|
|
case 'w':
|
|
|
|
layout++;
|
2018-03-28 17:00:54 +09:00
|
|
|
if (layout >= layoutCount) {
|
|
|
|
layout = 0;
|
|
|
|
}
|
|
|
|
refreshAll ();
|
2016-11-22 01:58:52 +01:00
|
|
|
break;
|
2017-02-22 23:45:51 +01:00
|
|
|
case R_CONS_KEY_F1:
|
|
|
|
cmd = r_config_get (core->config, "key.f1");
|
|
|
|
if (cmd && *cmd) {
|
|
|
|
key = r_core_cmd0 (core, cmd);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case R_CONS_KEY_F2:
|
|
|
|
cmd = r_config_get (core->config, "key.f2");
|
|
|
|
if (cmd && *cmd) {
|
|
|
|
key = r_core_cmd0 (core, cmd);
|
|
|
|
} else {
|
|
|
|
panel_breakpoint (core);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case R_CONS_KEY_F3:
|
|
|
|
cmd = r_config_get (core->config, "key.f3");
|
|
|
|
if (cmd && *cmd) {
|
|
|
|
key = r_core_cmd0 (core, cmd);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case R_CONS_KEY_F4:
|
|
|
|
cmd = r_config_get (core->config, "key.f4");
|
|
|
|
if (cmd && *cmd) {
|
|
|
|
key = r_core_cmd0 (core, cmd);
|
|
|
|
}
|
|
|
|
break;
|
2017-02-18 13:26:54 +01:00
|
|
|
case R_CONS_KEY_F5:
|
|
|
|
cmd = r_config_get (core->config, "key.f5");
|
2017-02-22 23:45:51 +01:00
|
|
|
if (cmd && *cmd) {
|
|
|
|
key = r_core_cmd0 (core, cmd);
|
|
|
|
}
|
2017-02-18 13:26:54 +01:00
|
|
|
break;
|
|
|
|
case R_CONS_KEY_F6:
|
|
|
|
cmd = r_config_get (core->config, "key.f6");
|
2017-02-22 23:45:51 +01:00
|
|
|
if (cmd && *cmd) {
|
|
|
|
key = r_core_cmd0 (core, cmd);
|
|
|
|
}
|
2017-02-18 13:26:54 +01:00
|
|
|
break;
|
|
|
|
case R_CONS_KEY_F7:
|
|
|
|
cmd = r_config_get (core->config, "key.f7");
|
2017-02-22 23:45:51 +01:00
|
|
|
if (cmd && *cmd) {
|
|
|
|
key = r_core_cmd0 (core, cmd);
|
|
|
|
} else {
|
|
|
|
panel_single_step_in (core);
|
|
|
|
}
|
2017-02-18 13:26:54 +01:00
|
|
|
break;
|
|
|
|
case R_CONS_KEY_F8:
|
|
|
|
cmd = r_config_get (core->config, "key.f8");
|
2017-02-22 23:45:51 +01:00
|
|
|
if (cmd && *cmd) {
|
|
|
|
key = r_core_cmd0 (core, cmd);
|
|
|
|
} else {
|
|
|
|
panel_single_step_over (core);
|
|
|
|
}
|
2017-02-18 13:26:54 +01:00
|
|
|
break;
|
|
|
|
case R_CONS_KEY_F9:
|
|
|
|
cmd = r_config_get (core->config, "key.f9");
|
2017-02-22 23:45:51 +01:00
|
|
|
if (cmd && *cmd) {
|
|
|
|
key = r_core_cmd0 (core, cmd);
|
|
|
|
} else {
|
|
|
|
panel_continue (core);
|
|
|
|
}
|
2017-02-18 13:26:54 +01:00
|
|
|
break;
|
|
|
|
case R_CONS_KEY_F10:
|
|
|
|
cmd = r_config_get (core->config, "key.f10");
|
2017-02-22 23:45:51 +01:00
|
|
|
if (cmd && *cmd) {
|
|
|
|
key = r_core_cmd0 (core, cmd);
|
|
|
|
}
|
2017-02-18 13:26:54 +01:00
|
|
|
break;
|
|
|
|
case R_CONS_KEY_F11:
|
|
|
|
cmd = r_config_get (core->config, "key.f11");
|
2017-02-22 23:45:51 +01:00
|
|
|
if (cmd && *cmd) {
|
|
|
|
key = r_core_cmd0 (core, cmd);
|
|
|
|
}
|
2017-02-18 13:26:54 +01:00
|
|
|
break;
|
|
|
|
case R_CONS_KEY_F12:
|
|
|
|
cmd = r_config_get (core->config, "key.f12");
|
2017-02-22 23:45:51 +01:00
|
|
|
if (cmd && *cmd) {
|
|
|
|
key = r_core_cmd0 (core, cmd);
|
|
|
|
}
|
2017-02-18 13:26:54 +01:00
|
|
|
break;
|
2015-09-29 04:26:00 +02:00
|
|
|
case '!':
|
2015-03-05 02:07:53 +01:00
|
|
|
case 'q':
|
2015-03-23 14:45:31 +01:00
|
|
|
case -1: // EOF
|
2018-03-23 11:17:42 +01:00
|
|
|
if (menu_y < 1) {
|
2015-08-31 05:06:01 +02:00
|
|
|
goto beach;
|
|
|
|
}
|
2018-03-23 11:17:42 +01:00
|
|
|
menu_y = 0;
|
2015-08-31 05:06:01 +02:00
|
|
|
break;
|
2015-08-31 05:43:38 +02:00
|
|
|
#if 0
|
2015-03-05 02:07:53 +01:00
|
|
|
case 27: // ESC
|
|
|
|
if (r_cons_readchar () == 91) {
|
2017-02-22 23:45:51 +01:00
|
|
|
if (r_cons_readchar () == 90) {}
|
2015-03-05 02:07:53 +01:00
|
|
|
}
|
|
|
|
break;
|
2015-08-31 05:43:38 +02:00
|
|
|
#endif
|
2015-03-05 02:07:53 +01:00
|
|
|
default:
|
2017-03-24 10:46:13 +01:00
|
|
|
// eprintf ("Key %d\n", key);
|
|
|
|
// sleep (1);
|
2015-03-05 02:07:53 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
goto repeat;
|
|
|
|
beach:
|
|
|
|
free (panels);
|
2015-05-31 17:33:07 +03:00
|
|
|
r_config_set_i (core->config, "scr.color", can->color);
|
2015-03-05 02:07:53 +01:00
|
|
|
free (can);
|
|
|
|
r_config_set_i (core->config, "asm.comments", asm_comments);
|
|
|
|
r_config_set_i (core->config, "asm.bytes", asm_bytes);
|
2015-10-11 11:57:00 -04:00
|
|
|
r_config_set_i (core->config, "scr.utf8", have_utf8);
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2015-03-05 02:07:53 +01:00
|
|
|
}
|