From f8dec83968ac5ea14cb1d432f9d6c06976961265 Mon Sep 17 00:00:00 2001 From: Khairul Azhar Kasmiran Date: Mon, 1 Apr 2019 00:22:07 +0800 Subject: [PATCH] Fix Visual jk - prc interaction (#13578) --- libr/core/cmd_print.c | 15 ++++++++++----- libr/core/visual.c | 5 +++++ libr/include/r_core.h | 1 + 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/libr/core/cmd_print.c b/libr/core/cmd_print.c index 6f5fd33e4c..bbe6698c14 100644 --- a/libr/core/cmd_print.c +++ b/libr/core/cmd_print.c @@ -545,21 +545,26 @@ static void cmd_print_init(RCore *core) { DEFINE_CMD_DESCRIPTOR (core, pz); } +R_API int r_core_get_prc_cols(RCore *core) { + int cols = r_config_get_i (core->config, "hex.pcols") + core->print->cols; // * 3.5; + cols /= 2; + if (cols < 1) { + cols = 1; + } + return cols; +} + // colordump static void cmd_prc(RCore *core, const ut8* block, int len) { const char *chars = " .,:;!O@#"; bool square = true; //false; int i, j; char ch, ch2, *color; - int cols = r_config_get_i (core->config, "hex.pcols") + core->print->cols; // * 3.5; + int cols = r_core_get_prc_cols (core); bool show_color = r_config_get_i (core->config, "scr.color"); bool show_flags = r_config_get_i (core->config, "asm.flags"); bool show_cursor = core->print->cur_enabled; bool show_unalloc = core->print->flags & R_PRINT_FLAGS_UNALLOC; - if (cols < 1) { - cols = 1; - } - cols /= 2; for (i = 0; i < len; i += cols) { r_print_addr (core->print, core->offset + i); for (j = i; j < i + cols; j ++) { diff --git a/libr/core/visual.c b/libr/core/visual.c index 9331a89bbb..ddc5c37299 100644 --- a/libr/core/visual.c +++ b/libr/core/visual.c @@ -2784,6 +2784,9 @@ R_API int r_core_visual_cmd(RCore *core, const char *arg) { while (times--) { if (isDisasmPrint (core->printidx)) { r_core_visual_disasm_down (core, &op, &cols); + } else if (!strcmp (__core_visual_print_command (core), + "prc")) { + cols = r_core_get_prc_cols (core); } r_core_seek (core, core->offset + cols, 1); } @@ -2851,6 +2854,8 @@ R_API int r_core_visual_cmd(RCore *core, const char *arg) { while (times--) { if (isDisasmPrint (core->printidx)) { r_core_visual_disasm_up (core, &cols); + } else if (!strcmp (__core_visual_print_command (core), "prc")) { + cols = r_core_get_prc_cols (core); } r_core_seek_delta (core, -cols); } diff --git a/libr/include/r_core.h b/libr/include/r_core.h index 5d33442287..67ec21fd3d 100644 --- a/libr/include/r_core.h +++ b/libr/include/r_core.h @@ -598,6 +598,7 @@ R_API int r_core_print_disasm_instructions (RCore *core, int len, int l); R_API int r_core_print_disasm_all (RCore *core, ut64 addr, int l, int len, int mode); R_API int r_core_disasm_pdi(RCore *core, int nb_opcodes, int nb_bytes, int fmt); R_API int r_core_print_fcn_disasm(RPrint *p, RCore *core, ut64 addr, int l, int invbreak, int cbytes); +R_API int r_core_get_prc_cols(RCore *core); R_API int r_core_flag_in_middle(RCore *core, ut64 at, int oplen, int *midflags); R_API int r_core_bb_starts_in_middle(RCore *core, ut64 at, int oplen); R_API int r_core_file_bin_raise (RCore *core, ut32 binfile_idx);