Implement hex.offset config variable to hide address column from hex-dump (#16373) ##print

This commit is contained in:
kuqadk3 2020-03-31 19:44:23 +07:00 committed by GitHub
parent e3dd6674d6
commit ad88c78944
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 5 deletions

BIN
binr/r2r/r2r Executable file

Binary file not shown.

View File

@ -3044,7 +3044,8 @@ R_API int r_core_config_init(RCore *core) {
SETCB ("asm.tailsub", "false", &cb_asmtailsub, "Replace addresses with prefix .. syntax");
SETBPREF ("asm.middle", "false", "Allow disassembling jumps in the middle of an instruction");
SETBPREF ("asm.noisy", "true", "Show comments considered noisy but possibly useful");
SETBPREF ("asm.offset", "true", "Show offsets at disassembly");
SETBPREF ("asm.offset", "true", "Show offsets in disassembly");
SETBPREF ("hex.offset", "true", "Show offsets in hex-dump");
SETBPREF ("scr.square", "true", "Use square pixels or not");
SETCB ("scr.prompt.vi", "false", &cb_scr_vi, "Use vi mode for input prompt");
SETCB ("scr.prompt.mode", "false", &cb_scr_prompt_mode, "Set prompt color based on vi mode");

View File

@ -6079,7 +6079,7 @@ l = use_blocksize;
break;
case 'x': // "px"
{
int show_offset = r_config_get_i (core->config, "asm.offset");
bool show_offset = r_config_get_i (core->config, "hex.offset");
if (show_offset) {
core->print->flags |= R_PRINT_FLAGS_OFFSET;
} else {
@ -6207,6 +6207,7 @@ l = use_blocksize;
break;
case 'i': // "pxi"
if (l != 0) {
core->print->show_offset = r_config_get_i (core->config, "hex.offset");
r_print_hexii (core->print, core->offset, core->block,
core->blocksize, r_config_get_i (core->config, "hex.cols"));
}
@ -6278,7 +6279,7 @@ l = use_blocksize;
break;
case 'W': // "pxW"
if (l) {
bool printOffset = (input[2] != 'q' && r_config_get_i (core->config, "asm.offset"));
bool printOffset = (input[2] != 'q' && r_config_get_i (core->config, "hex.offset"));
len = len - (len % 4);
for (i = 0; i < len; i += 4) {
const char *a, *b;
@ -6442,7 +6443,7 @@ l = use_blocksize;
case 'Q': // "pxQ"
// TODO. show if flag name, or inside function
if (l) {
bool printOffset = (input[2] != 'q' && r_config_get_i (core->config, "asm.offset"));
bool printOffset = (input[2] != 'q' && r_config_get_i (core->config, "hex.offset"));
len = len - (len % 8);
for (i = 0; i < len; i += 8) {
const char *a, *b;

View File

@ -112,6 +112,7 @@ typedef struct r_print_t {
const char *strconv_mode;
RList *vars;
char io_unalloc_ch;
bool show_offset;
// when true it uses row_offsets
bool calc_row_offsets;

View File

@ -741,6 +741,7 @@ R_API void r_print_hexii(RPrint *rp, ut64 addr, const ut8 *buf, int len, int ste
const char *color_other = c? (Pal (rp, other): Color_WHITE): "";
const char *color_reset = c? Color_RESET: "";
int i, j;
bool show_offset = rp->show_offset;
if (rp->flags & R_PRINT_FLAGS_HEADER) {
p (" ");
@ -755,7 +756,9 @@ R_API void r_print_hexii(RPrint *rp, ut64 addr, const ut8 *buf, int len, int ste
if (isAllZeros (buf + i, inc)) {
continue;
}
p ("%8X:", addr + i);
if (show_offset) {
p ("%8X:", addr + i);
}
for (j = 0; j < inc; j++) {
ut8 ch = buf[i + j];
if (ch == 0x00) {