Convert pC commands to rzshell (#3213)
This commit is contained in:
parent
a3885e8f99
commit
38a909738c
9 changed files with 453 additions and 196 deletions
|
|
@ -727,53 +727,6 @@ static void cmd_prc(RzCore *core, const ut8 *block, int len) {
|
|||
}
|
||||
}
|
||||
|
||||
static void cmd_pCd(RzCore *core, const char *input) {
|
||||
int h, w = rz_cons_get_size(&h);
|
||||
int colwidth = rz_config_get_i(core->config, "hex.cols") * 2.5;
|
||||
if (colwidth < 1) {
|
||||
colwidth = 16;
|
||||
}
|
||||
int i, columns = w / colwidth;
|
||||
int rows = h - 2;
|
||||
int obsz = core->blocksize;
|
||||
int user_rows = rz_num_math(core->num, input);
|
||||
bool asm_minicols = rz_config_get_i(core->config, "asm.minicols");
|
||||
char *o_ao = strdup(rz_config_get(core->config, "asm.offset"));
|
||||
char *o_ab = strdup(rz_config_get(core->config, "asm.bytes"));
|
||||
if (asm_minicols) {
|
||||
rz_config_set(core->config, "asm.offset", "false");
|
||||
// rz_config_set (core->config, "asm.bytes", "false");
|
||||
}
|
||||
rz_config_set(core->config, "asm.bytes", "false");
|
||||
if (user_rows > 0) {
|
||||
rows = user_rows + 1;
|
||||
}
|
||||
RzConsCanvas *c = rz_cons_canvas_new(w, rows);
|
||||
ut64 osek = core->offset;
|
||||
c->color = rz_config_get_i(core->config, "scr.color");
|
||||
rz_core_block_size(core, rows * 32);
|
||||
for (i = 0; i < columns; i++) {
|
||||
(void)rz_cons_canvas_gotoxy(c, i * (w / columns), 0);
|
||||
char *cmd = rz_str_newf("pdq %d @i:%d", rows, rows * i);
|
||||
char *dis = rz_core_cmd_str(core, cmd);
|
||||
rz_cons_canvas_write(c, dis);
|
||||
free(cmd);
|
||||
free(dis);
|
||||
}
|
||||
rz_core_block_size(core, obsz);
|
||||
rz_core_seek(core, osek, true);
|
||||
|
||||
rz_cons_canvas_print(c);
|
||||
rz_cons_canvas_free(c);
|
||||
if (asm_minicols) {
|
||||
rz_config_set(core->config, "asm.offset", o_ao);
|
||||
rz_config_set(core->config, "asm.bytes", o_ab);
|
||||
}
|
||||
rz_config_set(core->config, "asm.bytes", o_ab);
|
||||
free(o_ao);
|
||||
free(o_ab);
|
||||
}
|
||||
|
||||
static void findMethodBounds(RzList /*<RzBinSymbol *>*/ *methods, ut64 *min, ut64 *max) {
|
||||
RzBinSymbol *sym;
|
||||
RzListIter *iter;
|
||||
|
|
@ -812,101 +765,6 @@ static ut64 findClassBounds(RzCore *core, int *len) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void cmd_pCD(RzCore *core, const char *input) {
|
||||
int h, w = rz_cons_get_size(&h);
|
||||
int i;
|
||||
int rows = h - 2;
|
||||
int obsz = core->blocksize;
|
||||
int user_rows = rz_num_math(core->num, input);
|
||||
bool asm_minicols = rz_config_get_i(core->config, "asm.minicols");
|
||||
char *o_ao = strdup(rz_config_get(core->config, "asm.offset"));
|
||||
char *o_ab = strdup(rz_config_get(core->config, "asm.bytes"));
|
||||
if (asm_minicols) {
|
||||
rz_config_set(core->config, "asm.offset", "false");
|
||||
rz_config_set(core->config, "asm.bytes", "false");
|
||||
}
|
||||
rz_config_set(core->config, "asm.bytes", "false");
|
||||
if (user_rows > 0) {
|
||||
rows = user_rows + 1;
|
||||
}
|
||||
RzConsCanvas *c = rz_cons_canvas_new(w, rows);
|
||||
ut64 osek = core->offset;
|
||||
c->color = rz_config_get_i(core->config, "scr.color");
|
||||
rz_core_block_size(core, rows * 32);
|
||||
char *cmd = NULL;
|
||||
int columns = 2;
|
||||
for (i = 0; i < columns; i++) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
(void)rz_cons_canvas_gotoxy(c, 0, 0);
|
||||
cmd = rz_str_newf("dr;?e;?e backtrace:;dbt");
|
||||
break;
|
||||
case 1:
|
||||
(void)rz_cons_canvas_gotoxy(c, 28, 0);
|
||||
// cmd = rz_str_newf ("pxw 128@r:SP;pd@r:PC");
|
||||
cmd = rz_str_newf("%s 128@r:SP;pd@ 0x%" PFMT64x, core->stkcmd, osek);
|
||||
break;
|
||||
}
|
||||
char *dis = rz_core_cmd_str(core, cmd);
|
||||
rz_cons_canvas_write(c, dis);
|
||||
free(cmd);
|
||||
free(dis);
|
||||
}
|
||||
rz_core_block_size(core, obsz);
|
||||
rz_core_seek(core, osek, true);
|
||||
|
||||
rz_cons_canvas_print(c);
|
||||
rz_cons_canvas_free(c);
|
||||
if (asm_minicols) {
|
||||
rz_config_set(core->config, "asm.offset", o_ao);
|
||||
rz_config_set(core->config, "asm.bytes", o_ab);
|
||||
}
|
||||
rz_config_set(core->config, "asm.bytes", o_ab);
|
||||
free(o_ao);
|
||||
free(o_ab);
|
||||
}
|
||||
|
||||
static void cmd_pCx(RzCore *core, const char *input, const char *xcmd) {
|
||||
int h, w = rz_cons_get_size(&h);
|
||||
int hex_cols = rz_config_get_i(core->config, "hex.cols");
|
||||
int colwidth = hex_cols * 5;
|
||||
int i, columns = w / (colwidth * 0.9);
|
||||
int rows = h - 2;
|
||||
int user_rows = rz_num_math(core->num, input);
|
||||
rz_config_set_i(core->config, "hex.cols", colwidth / 5);
|
||||
if (user_rows > 0) {
|
||||
rows = user_rows + 1;
|
||||
}
|
||||
RzConsCanvas *c = rz_cons_canvas_new(w, rows);
|
||||
if (!c) {
|
||||
RZ_LOG_ERROR("core: Couldn't allocate a canvas with %d rows\n", rows);
|
||||
goto err;
|
||||
}
|
||||
|
||||
ut64 tsek = core->offset;
|
||||
c->color = rz_config_get_i(core->config, "scr.color");
|
||||
int bsize = hex_cols * rows;
|
||||
if (!strcmp(xcmd, "pxA")) {
|
||||
bsize *= 12;
|
||||
}
|
||||
for (i = 0; i < columns; i++) {
|
||||
(void)rz_cons_canvas_gotoxy(c, i * (w / columns), 0);
|
||||
char *cmd = rz_str_newf("%s %d @ %" PFMT64u, xcmd, bsize, tsek);
|
||||
char *dis = rz_core_cmd_str(core, cmd);
|
||||
if (dis) {
|
||||
rz_cons_canvas_write(c, dis);
|
||||
free(dis);
|
||||
}
|
||||
free(cmd);
|
||||
tsek += bsize - 32;
|
||||
}
|
||||
|
||||
rz_cons_canvas_print(c);
|
||||
rz_cons_canvas_free(c);
|
||||
err:
|
||||
rz_config_set_i(core->config, "hex.cols", hex_cols);
|
||||
}
|
||||
|
||||
static void cmd_print_eq_dict(RzCore *core, const ut8 *block, int bsz) {
|
||||
int i;
|
||||
int min = -1;
|
||||
|
|
@ -1963,7 +1821,7 @@ RZ_API void rz_core_print_examine(RzCore *core, const char *str) {
|
|||
|
||||
static bool cmd_print_pxA(RzCore *core, int len, RzOutputMode mode) {
|
||||
if (!len) {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
RzConsPrintablePalette *pal = &core->cons->context->pal;
|
||||
int show_offset = true;
|
||||
|
|
@ -3958,38 +3816,6 @@ RZ_IPI int rz_cmd_print(void *data, const char *input) {
|
|||
rz_core_magic(core, filename, true, NULL);
|
||||
}
|
||||
break;
|
||||
case 'C': // "pC"
|
||||
switch (input[1]) {
|
||||
case 0:
|
||||
cmd_pCd(core, "");
|
||||
break;
|
||||
case ' ':
|
||||
case 'd':
|
||||
cmd_pCd(core, input + 2);
|
||||
break;
|
||||
case 'D':
|
||||
cmd_pCD(core, input + 2);
|
||||
break;
|
||||
case 'a':
|
||||
cmd_pCx(core, input + 2, "pxa");
|
||||
break;
|
||||
case 'A':
|
||||
cmd_pCx(core, input + 2, "pxA");
|
||||
break;
|
||||
case 'x':
|
||||
cmd_pCx(core, input + 2, "px");
|
||||
break;
|
||||
case 'w':
|
||||
cmd_pCx(core, input + 2, "pxw");
|
||||
break;
|
||||
case 'c':
|
||||
cmd_pCx(core, input + 2, "pc");
|
||||
break;
|
||||
default:
|
||||
RZ_LOG_ERROR("core: Usage: pCd\n");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'r': // "pr"
|
||||
switch (input[1]) {
|
||||
case 'c': // "prc" // color raw dump
|
||||
|
|
@ -6477,3 +6303,178 @@ RZ_IPI RzCmdStatus rz_print_minus_table_handler(RzCore *core, int argc, const ch
|
|||
analysis_stats_range_free(srange);
|
||||
return RZ_CMD_STATUS_OK;
|
||||
}
|
||||
|
||||
RZ_IPI RzCmdStatus rz_print_columns_disassembly_handler(RzCore *core, int argc, const char **argv) {
|
||||
int h, w = rz_cons_get_size(&h);
|
||||
int colwidth = rz_config_get_i(core->config, "hex.cols") * 2.5;
|
||||
if (colwidth < 1) {
|
||||
colwidth = 16;
|
||||
}
|
||||
int i, columns = w / colwidth;
|
||||
int rows = h - 2;
|
||||
int obsz = core->blocksize;
|
||||
int user_rows = argc > 1 ? rz_num_math(core->num, argv[1]) : -1;
|
||||
if (user_rows > 0) {
|
||||
rows = user_rows;
|
||||
}
|
||||
bool asm_minicols = rz_config_get_i(core->config, "asm.minicols");
|
||||
char *o_ao = strdup(rz_config_get(core->config, "asm.offset"));
|
||||
char *o_ab = strdup(rz_config_get(core->config, "asm.bytes"));
|
||||
if (asm_minicols) {
|
||||
rz_config_set(core->config, "asm.offset", "false");
|
||||
// rz_config_set (core->config, "asm.bytes", "false");
|
||||
}
|
||||
rz_config_set(core->config, "asm.bytes", "false");
|
||||
RzConsCanvas *c = rz_cons_canvas_new(w, rows);
|
||||
ut64 osek = core->offset;
|
||||
c->color = rz_config_get_i(core->config, "scr.color");
|
||||
rz_core_block_size(core, rows * 32);
|
||||
for (i = 0; i < columns; i++) {
|
||||
(void)rz_cons_canvas_gotoxy(c, i * (w / columns), 0);
|
||||
// TODO: Use the API directly
|
||||
char *cmd = rz_str_newf("pdq %d @i:%d", rows, rows * i);
|
||||
char *dis = rz_core_cmd_str(core, cmd);
|
||||
rz_cons_canvas_write(c, dis);
|
||||
free(cmd);
|
||||
free(dis);
|
||||
}
|
||||
rz_core_block_size(core, obsz);
|
||||
rz_core_seek(core, osek, true);
|
||||
|
||||
rz_cons_canvas_print(c);
|
||||
rz_cons_canvas_free(c);
|
||||
if (asm_minicols) {
|
||||
rz_config_set(core->config, "asm.offset", o_ao);
|
||||
rz_config_set(core->config, "asm.bytes", o_ab);
|
||||
}
|
||||
rz_config_set(core->config, "asm.bytes", o_ab);
|
||||
free(o_ao);
|
||||
free(o_ab);
|
||||
rz_cons_printf("\n");
|
||||
return RZ_CMD_STATUS_OK;
|
||||
}
|
||||
|
||||
RZ_IPI RzCmdStatus rz_print_columns_debug_handler(RzCore *core, int argc, const char **argv) {
|
||||
if (!rz_config_get_b(core->config, "cfg.debug")) {
|
||||
RZ_LOG_ERROR("Command works only in debug mode\n");
|
||||
return RZ_CMD_STATUS_ERROR;
|
||||
}
|
||||
int h, w = rz_cons_get_size(&h);
|
||||
int i;
|
||||
int rows = h - 2;
|
||||
int obsz = core->blocksize;
|
||||
int user_rows = argc > 1 ? rz_num_math(core->num, argv[1]) : -1;
|
||||
if (user_rows > 0) {
|
||||
rows = user_rows;
|
||||
}
|
||||
bool asm_minicols = rz_config_get_i(core->config, "asm.minicols");
|
||||
char *o_ao = strdup(rz_config_get(core->config, "asm.offset"));
|
||||
char *o_ab = strdup(rz_config_get(core->config, "asm.bytes"));
|
||||
if (asm_minicols) {
|
||||
rz_config_set(core->config, "asm.offset", "false");
|
||||
rz_config_set(core->config, "asm.bytes", "false");
|
||||
}
|
||||
rz_config_set(core->config, "asm.bytes", "false");
|
||||
RzConsCanvas *c = rz_cons_canvas_new(w, rows);
|
||||
ut64 osek = core->offset;
|
||||
c->color = rz_config_get_i(core->config, "scr.color");
|
||||
rz_core_block_size(core, rows * 32);
|
||||
char *cmd = NULL;
|
||||
int columns = 2;
|
||||
for (i = 0; i < columns; i++) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
(void)rz_cons_canvas_gotoxy(c, 0, 0);
|
||||
// TODO: Use the API directly
|
||||
cmd = rz_str_newf("dr; ?e; ?e backtrace:; dbt");
|
||||
break;
|
||||
case 1:
|
||||
(void)rz_cons_canvas_gotoxy(c, 28, 0);
|
||||
// TODO: Use the API directly
|
||||
// cmd = rz_str_newf ("pxw 128@r:SP;pd@r:PC");
|
||||
cmd = rz_str_newf("%s 128 @r:SP; pd @ 0x%" PFMT64x, rz_core_print_stack_command(core), osek);
|
||||
break;
|
||||
}
|
||||
char *dis = rz_core_cmd_str(core, cmd);
|
||||
rz_cons_canvas_write(c, dis);
|
||||
free(cmd);
|
||||
free(dis);
|
||||
}
|
||||
rz_core_block_size(core, obsz);
|
||||
rz_core_seek(core, osek, true);
|
||||
|
||||
rz_cons_canvas_print(c);
|
||||
rz_cons_canvas_free(c);
|
||||
if (asm_minicols) {
|
||||
rz_config_set(core->config, "asm.offset", o_ao);
|
||||
rz_config_set(core->config, "asm.bytes", o_ab);
|
||||
}
|
||||
rz_config_set(core->config, "asm.bytes", o_ab);
|
||||
free(o_ao);
|
||||
free(o_ab);
|
||||
rz_cons_printf("\n");
|
||||
return RZ_CMD_STATUS_OK;
|
||||
}
|
||||
|
||||
static bool print_hexdump_columns(RzCore *core, int user_rows, const char *xcmd) {
|
||||
int h, w = rz_cons_get_size(&h);
|
||||
int hex_cols = rz_config_get_i(core->config, "hex.cols");
|
||||
int colwidth = hex_cols * 5;
|
||||
int i, columns = w / (colwidth * 0.9);
|
||||
int rows = h - 2;
|
||||
rz_config_set_i(core->config, "hex.cols", colwidth / 5);
|
||||
if (user_rows > 0) {
|
||||
// Add one more line for the hexdump header
|
||||
rows = user_rows + 1;
|
||||
}
|
||||
RzConsCanvas *c = rz_cons_canvas_new(w, rows);
|
||||
if (!c) {
|
||||
RZ_LOG_ERROR("core: Couldn't allocate a canvas with %d rows\n", rows);
|
||||
rz_config_set_i(core->config, "hex.cols", hex_cols);
|
||||
return false;
|
||||
}
|
||||
|
||||
ut64 tsek = core->offset;
|
||||
c->color = rz_config_get_i(core->config, "scr.color");
|
||||
int bsize = hex_cols * rows;
|
||||
if (!strcmp(xcmd, "pxAl")) {
|
||||
bsize *= 12;
|
||||
}
|
||||
for (i = 0; i < columns; i++) {
|
||||
(void)rz_cons_canvas_gotoxy(c, i * (w / columns), 0);
|
||||
char *cmd = rz_str_newf("%s %d @ %" PFMT64u, xcmd, bsize, tsek);
|
||||
char *dis = rz_core_cmd_str(core, cmd);
|
||||
if (dis) {
|
||||
rz_cons_canvas_write(c, dis);
|
||||
free(dis);
|
||||
}
|
||||
free(cmd);
|
||||
tsek += bsize - 32;
|
||||
}
|
||||
|
||||
rz_cons_canvas_print(c);
|
||||
rz_cons_canvas_free(c);
|
||||
rz_config_set_i(core->config, "hex.cols", hex_cols);
|
||||
rz_cons_printf("\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
RZ_IPI RzCmdStatus rz_print_columns_hex_annotated_handler(RzCore *core, int argc, const char **argv) {
|
||||
int user_rows = argc > 1 ? rz_num_math(core->num, argv[1]) : -1;
|
||||
return bool2status(print_hexdump_columns(core, user_rows, "pxa"));
|
||||
}
|
||||
|
||||
RZ_IPI RzCmdStatus rz_print_columns_hex_op_colored_handler(RzCore *core, int argc, const char **argv) {
|
||||
int user_rows = argc > 1 ? rz_num_math(core->num, argv[1]) : -1;
|
||||
return bool2status(print_hexdump_columns(core, user_rows, "pxAl"));
|
||||
}
|
||||
|
||||
RZ_IPI RzCmdStatus rz_print_columns_hex_handler(RzCore *core, int argc, const char **argv) {
|
||||
int user_rows = argc > 1 ? rz_num_math(core->num, argv[1]) : -1;
|
||||
return bool2status(print_hexdump_columns(core, user_rows, "px"));
|
||||
}
|
||||
|
||||
RZ_IPI RzCmdStatus rz_print_columns_hex_words_handler(RzCore *core, int argc, const char **argv) {
|
||||
int user_rows = argc > 1 ? rz_num_math(core->num, argv[1]) : -1;
|
||||
return bool2status(print_hexdump_columns(core, user_rows, "pxw"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -509,6 +509,12 @@ static const RzCmdDescArg esil_of_assembly_args[2];
|
|||
static const RzCmdDescArg assembly_of_hex_args[2];
|
||||
static const RzCmdDescArg esil_of_hex_args[2];
|
||||
static const RzCmdDescArg cmd_disassembly_n_bytes_args[2];
|
||||
static const RzCmdDescArg print_columns_disassembly_args[2];
|
||||
static const RzCmdDescArg print_columns_debug_args[2];
|
||||
static const RzCmdDescArg print_columns_hex_annotated_args[2];
|
||||
static const RzCmdDescArg print_columns_hex_op_colored_args[2];
|
||||
static const RzCmdDescArg print_columns_hex_args[2];
|
||||
static const RzCmdDescArg print_columns_hex_words_args[2];
|
||||
static const RzCmdDescArg cmd_disassembly_n_instructions_args[2];
|
||||
static const RzCmdDescArg cmd_disassembly_all_possible_opcodes_args[2];
|
||||
static const RzCmdDescArg cmd_disassembly_all_possible_opcodes_treeview_args[2];
|
||||
|
|
@ -11788,6 +11794,99 @@ static const RzCmdDescHelp cmd_disassembly_n_bytes_help = {
|
|||
.args = cmd_disassembly_n_bytes_args,
|
||||
};
|
||||
|
||||
static const RzCmdDescHelp pC_help = {
|
||||
.summary = "Print disassembly in columns",
|
||||
};
|
||||
static const RzCmdDescArg print_columns_disassembly_args[] = {
|
||||
{
|
||||
.name = "N",
|
||||
.type = RZ_CMD_ARG_TYPE_RZNUM,
|
||||
.flags = RZ_CMD_ARG_FLAG_LAST,
|
||||
.optional = true,
|
||||
|
||||
},
|
||||
{ 0 },
|
||||
};
|
||||
static const RzCmdDescHelp print_columns_disassembly_help = {
|
||||
.summary = "Print <N> lines of instructions disassembly in columns",
|
||||
.args = print_columns_disassembly_args,
|
||||
};
|
||||
|
||||
static const RzCmdDescArg print_columns_debug_args[] = {
|
||||
{
|
||||
.name = "N",
|
||||
.type = RZ_CMD_ARG_TYPE_RZNUM,
|
||||
.flags = RZ_CMD_ARG_FLAG_LAST,
|
||||
.optional = true,
|
||||
|
||||
},
|
||||
{ 0 },
|
||||
};
|
||||
static const RzCmdDescHelp print_columns_debug_help = {
|
||||
.summary = "Print <N> lines of the debug registers and stack in columns",
|
||||
.args = print_columns_debug_args,
|
||||
};
|
||||
|
||||
static const RzCmdDescArg print_columns_hex_annotated_args[] = {
|
||||
{
|
||||
.name = "N",
|
||||
.type = RZ_CMD_ARG_TYPE_RZNUM,
|
||||
.flags = RZ_CMD_ARG_FLAG_LAST,
|
||||
.optional = true,
|
||||
|
||||
},
|
||||
{ 0 },
|
||||
};
|
||||
static const RzCmdDescHelp print_columns_hex_annotated_help = {
|
||||
.summary = "Print <N> lines of annotated hexdump in columns",
|
||||
.args = print_columns_hex_annotated_args,
|
||||
};
|
||||
|
||||
static const RzCmdDescArg print_columns_hex_op_colored_args[] = {
|
||||
{
|
||||
.name = "N",
|
||||
.type = RZ_CMD_ARG_TYPE_RZNUM,
|
||||
.flags = RZ_CMD_ARG_FLAG_LAST,
|
||||
.optional = true,
|
||||
|
||||
},
|
||||
{ 0 },
|
||||
};
|
||||
static const RzCmdDescHelp print_columns_hex_op_colored_help = {
|
||||
.summary = "Print <N> lines of op analysis color map in columns",
|
||||
.args = print_columns_hex_op_colored_args,
|
||||
};
|
||||
|
||||
static const RzCmdDescArg print_columns_hex_args[] = {
|
||||
{
|
||||
.name = "N",
|
||||
.type = RZ_CMD_ARG_TYPE_RZNUM,
|
||||
.flags = RZ_CMD_ARG_FLAG_LAST,
|
||||
.optional = true,
|
||||
|
||||
},
|
||||
{ 0 },
|
||||
};
|
||||
static const RzCmdDescHelp print_columns_hex_help = {
|
||||
.summary = "Print <N> lines of hexdump in columns",
|
||||
.args = print_columns_hex_args,
|
||||
};
|
||||
|
||||
static const RzCmdDescArg print_columns_hex_words_args[] = {
|
||||
{
|
||||
.name = "N",
|
||||
.type = RZ_CMD_ARG_TYPE_RZNUM,
|
||||
.flags = RZ_CMD_ARG_FLAG_LAST,
|
||||
.optional = true,
|
||||
|
||||
},
|
||||
{ 0 },
|
||||
};
|
||||
static const RzCmdDescHelp print_columns_hex_words_help = {
|
||||
.summary = "Print <N> lines of 4-byte integer hexdump in columns",
|
||||
.args = print_columns_hex_words_args,
|
||||
};
|
||||
|
||||
static const RzCmdDescHelp cmd_print_disassembly_help = {
|
||||
.summary = "Print Disassembly",
|
||||
};
|
||||
|
|
@ -18830,6 +18929,26 @@ RZ_IPI void rzshell_cmddescs_init(RzCore *core) {
|
|||
RzCmdDesc *cmd_disassembly_n_bytes_cd = rz_cmd_desc_argv_state_new(core->rcmd, cmd_print_cd, "pD", RZ_OUTPUT_MODE_STANDARD | RZ_OUTPUT_MODE_QUIET | RZ_OUTPUT_MODE_TABLE | RZ_OUTPUT_MODE_JSON, rz_cmd_disassembly_n_bytes_handler, &cmd_disassembly_n_bytes_help);
|
||||
rz_warn_if_fail(cmd_disassembly_n_bytes_cd);
|
||||
|
||||
RzCmdDesc *pC_cd = rz_cmd_desc_group_new(core->rcmd, cmd_print_cd, "pC", NULL, NULL, &pC_help);
|
||||
rz_warn_if_fail(pC_cd);
|
||||
RzCmdDesc *print_columns_disassembly_cd = rz_cmd_desc_argv_new(core->rcmd, pC_cd, "pCd", rz_print_columns_disassembly_handler, &print_columns_disassembly_help);
|
||||
rz_warn_if_fail(print_columns_disassembly_cd);
|
||||
|
||||
RzCmdDesc *print_columns_debug_cd = rz_cmd_desc_argv_new(core->rcmd, pC_cd, "pCD", rz_print_columns_debug_handler, &print_columns_debug_help);
|
||||
rz_warn_if_fail(print_columns_debug_cd);
|
||||
|
||||
RzCmdDesc *print_columns_hex_annotated_cd = rz_cmd_desc_argv_new(core->rcmd, pC_cd, "pCa", rz_print_columns_hex_annotated_handler, &print_columns_hex_annotated_help);
|
||||
rz_warn_if_fail(print_columns_hex_annotated_cd);
|
||||
|
||||
RzCmdDesc *print_columns_hex_op_colored_cd = rz_cmd_desc_argv_new(core->rcmd, pC_cd, "pCA", rz_print_columns_hex_op_colored_handler, &print_columns_hex_op_colored_help);
|
||||
rz_warn_if_fail(print_columns_hex_op_colored_cd);
|
||||
|
||||
RzCmdDesc *print_columns_hex_cd = rz_cmd_desc_argv_new(core->rcmd, pC_cd, "pCx", rz_print_columns_hex_handler, &print_columns_hex_help);
|
||||
rz_warn_if_fail(print_columns_hex_cd);
|
||||
|
||||
RzCmdDesc *print_columns_hex_words_cd = rz_cmd_desc_argv_new(core->rcmd, pC_cd, "pCw", rz_print_columns_hex_words_handler, &print_columns_hex_words_help);
|
||||
rz_warn_if_fail(print_columns_hex_words_cd);
|
||||
|
||||
RzCmdDesc *cmd_print_disassembly_cd = rz_cmd_desc_group_state_new(core->rcmd, cmd_print_cd, "pd", RZ_OUTPUT_MODE_STANDARD | RZ_OUTPUT_MODE_QUIET | RZ_OUTPUT_MODE_TABLE | RZ_OUTPUT_MODE_JSON, rz_cmd_disassembly_n_instructions_handler, &cmd_disassembly_n_instructions_help, &cmd_print_disassembly_help);
|
||||
rz_warn_if_fail(cmd_print_disassembly_cd);
|
||||
RzCmdDesc *cmd_disassembly_all_opcodes_cd = rz_cmd_desc_group_state_new(core->rcmd, cmd_print_disassembly_cd, "pda", RZ_OUTPUT_MODE_STANDARD | RZ_OUTPUT_MODE_QUIET | RZ_OUTPUT_MODE_JSON, rz_cmd_disassembly_all_possible_opcodes_handler, &cmd_disassembly_all_possible_opcodes_help, &cmd_disassembly_all_opcodes_help);
|
||||
|
|
|
|||
|
|
@ -1669,6 +1669,18 @@ RZ_IPI RzCmdStatus rz_cmd_print_byte_array_yara_handler(RzCore *core, int argc,
|
|||
RZ_IPI RzCmdStatus rz_cmd_print_byte_array_rizin_handler(RzCore *core, int argc, const char **argv);
|
||||
// "pD"
|
||||
RZ_IPI RzCmdStatus rz_cmd_disassembly_n_bytes_handler(RzCore *core, int argc, const char **argv, RzCmdStateOutput *state);
|
||||
// "pCd"
|
||||
RZ_IPI RzCmdStatus rz_print_columns_disassembly_handler(RzCore *core, int argc, const char **argv);
|
||||
// "pCD"
|
||||
RZ_IPI RzCmdStatus rz_print_columns_debug_handler(RzCore *core, int argc, const char **argv);
|
||||
// "pCa"
|
||||
RZ_IPI RzCmdStatus rz_print_columns_hex_annotated_handler(RzCore *core, int argc, const char **argv);
|
||||
// "pCA"
|
||||
RZ_IPI RzCmdStatus rz_print_columns_hex_op_colored_handler(RzCore *core, int argc, const char **argv);
|
||||
// "pCx"
|
||||
RZ_IPI RzCmdStatus rz_print_columns_hex_handler(RzCore *core, int argc, const char **argv);
|
||||
// "pCw"
|
||||
RZ_IPI RzCmdStatus rz_print_columns_hex_words_handler(RzCore *core, int argc, const char **argv);
|
||||
// "pd"
|
||||
RZ_IPI RzCmdStatus rz_cmd_disassembly_n_instructions_handler(RzCore *core, int argc, const char **argv, RzCmdStateOutput *state);
|
||||
// "pda"
|
||||
|
|
|
|||
|
|
@ -165,6 +165,51 @@ commands:
|
|||
- name: n_bytes
|
||||
type: RZ_CMD_ARG_TYPE_RZNUM
|
||||
optional: true
|
||||
- name: pC
|
||||
summary: Print disassembly in columns
|
||||
subcommands:
|
||||
- name: pCd
|
||||
summary: Print <N> lines of instructions disassembly in columns
|
||||
cname: print_columns_disassembly
|
||||
args:
|
||||
- name: N
|
||||
type: RZ_CMD_ARG_TYPE_RZNUM
|
||||
optional: true
|
||||
- name: pCD
|
||||
summary: Print <N> lines of the debug registers and stack in columns
|
||||
cname: print_columns_debug
|
||||
args:
|
||||
- name: N
|
||||
type: RZ_CMD_ARG_TYPE_RZNUM
|
||||
optional: true
|
||||
- name: pCa
|
||||
summary: Print <N> lines of annotated hexdump in columns
|
||||
cname: print_columns_hex_annotated
|
||||
args:
|
||||
- name: N
|
||||
type: RZ_CMD_ARG_TYPE_RZNUM
|
||||
optional: true
|
||||
- name: pCA
|
||||
summary: Print <N> lines of op analysis color map in columns
|
||||
cname: print_columns_hex_op_colored
|
||||
args:
|
||||
- name: N
|
||||
type: RZ_CMD_ARG_TYPE_RZNUM
|
||||
optional: true
|
||||
- name: pCx
|
||||
summary: Print <N> lines of hexdump in columns
|
||||
cname: print_columns_hex
|
||||
args:
|
||||
- name: N
|
||||
type: RZ_CMD_ARG_TYPE_RZNUM
|
||||
optional: true
|
||||
- name: pCw
|
||||
summary: Print <N> lines of 4-byte integer hexdump in columns
|
||||
cname: print_columns_hex_words
|
||||
args:
|
||||
- name: N
|
||||
type: RZ_CMD_ARG_TYPE_RZNUM
|
||||
optional: true
|
||||
- name: pd
|
||||
summary: Print Disassembly
|
||||
cname: cmd_print_disassembly
|
||||
|
|
|
|||
|
|
@ -162,6 +162,7 @@ RZ_IPI bool rz_core_print_hexdump_diff(RZ_NONNULL RzCore *core, ut64 aa, ut64 ba
|
|||
RZ_IPI bool rz_core_print_dump(RZ_NONNULL RzCore *core, RzOutputMode mode, ut64 addr, ut8 n, int len, RzCorePrintFormatType format);
|
||||
RZ_IPI bool rz_core_print_hexdump_or_hexdiff(RZ_NONNULL RzCore *core, RzOutputMode mode, ut64 addr, int len, bool use_comments);
|
||||
RZ_IPI bool rz_core_print_hexdump_byline(RZ_NONNULL RzCore *core, bool hex_offset, ut64 addr, int len, ut8 size);
|
||||
RZ_IPI const char *rz_core_print_stack_command(RZ_NONNULL RzCore *core);
|
||||
|
||||
/* cmd_seek.c */
|
||||
RZ_IPI bool rz_core_seek_to_register(RzCore *core, const char *input, bool is_silent);
|
||||
|
|
|
|||
|
|
@ -870,3 +870,18 @@ restore_conf:
|
|||
rz_config_hold_free(hc);
|
||||
return rz_strbuf_drain(sb);
|
||||
}
|
||||
|
||||
RZ_IPI const char *rz_core_print_stack_command(RZ_NONNULL RzCore *core) {
|
||||
rz_return_val_if_fail(core, NULL);
|
||||
if (rz_config_get_b(core->config, "dbg.slow")) {
|
||||
return "pxr";
|
||||
}
|
||||
if (rz_config_get_b(core->config, "stack.bytes")) {
|
||||
return "px";
|
||||
}
|
||||
switch (core->rasm->bits) {
|
||||
case 64: return "pxq"; break;
|
||||
case 32: return "pxw"; break;
|
||||
}
|
||||
return "px";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -185,17 +185,7 @@ static void prevPrintCommand(RzCore *core) {
|
|||
static const char *stackPrintCommand(RzCore *core) {
|
||||
RzCoreVisual *visual = core->visual;
|
||||
if (visual->current0format == 0) {
|
||||
if (rz_config_get_b(core->config, "dbg.slow")) {
|
||||
return "pxr";
|
||||
}
|
||||
if (rz_config_get_b(core->config, "stack.bytes")) {
|
||||
return "px";
|
||||
}
|
||||
switch (core->rasm->bits) {
|
||||
case 64: return "pxq"; break;
|
||||
case 32: return "pxw"; break;
|
||||
}
|
||||
return "px";
|
||||
return rz_core_print_stack_command(core);
|
||||
}
|
||||
return printHexFormats[visual->current0format % PRINT_HEX_FORMATS];
|
||||
}
|
||||
|
|
|
|||
84
test/db/cmd/cmd_p_capital_c
Normal file
84
test/db/cmd/cmd_p_capital_c
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
NAME=pC - crash
|
||||
FILE==
|
||||
CMDS=<<EOF
|
||||
e scr.null=true
|
||||
pCd 0x200
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
EOF
|
||||
RUN
|
||||
|
||||
NAME=pCa
|
||||
FILE==
|
||||
CMDS=<<EOF
|
||||
wx 55aa55aa909055aa9090ff20000ffffffff55fffffaaffffffffff
|
||||
pCa 3
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
- offset - 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF
|
||||
0x00000000 55aa 55aa 9090 55aa 9090 ff20 000f ffff U.U...U.... ....
|
||||
0x00000010 fff5 5fff ffaa ffff ffff ff00 0000 0000 .._.............
|
||||
0x00000020 0000 0000 0000 0000 0000 0000 0000 0000 ................
|
||||
EOF
|
||||
RUN
|
||||
|
||||
NAME=pCA
|
||||
FILE==
|
||||
ARGS=-a x86 -b 64
|
||||
CMDS=<<EOF
|
||||
wx 55aa55aa909055aa9090ff20000ffffffff55fffffaaffffffffff
|
||||
pCA 4
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
0x00000000 -> -> ....-> ...._J++ -><- _J++++++++++++++++++++++++++++ 54
|
||||
0x00000036 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 64
|
||||
0x00000076 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 64
|
||||
0x000000b6 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 64
|
||||
0x000000f6 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 64
|
||||
EOF
|
||||
RUN
|
||||
|
||||
NAME=pCd
|
||||
FILE==
|
||||
ARGS=-a arm -b 32
|
||||
CMDS=<<EOF
|
||||
wx 55aa55aa909055aa9090ff20000ff34534ff55f45eaac0c0c0cdf534
|
||||
pCd 3
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
0x00000000 bge 0x156a95c 0x0000000c ldrbmi r0, [r3, 0xf00]!
|
||||
0x00000004 bge 0x156424c 0x00000010 pli [r5, -0xf34]
|
||||
0x00000008 smlalshs sb, pc, r0, r0 0x00000014 sbcgt sl, r0, lr, asr sl
|
||||
EOF
|
||||
RUN
|
||||
|
||||
NAME=pCx
|
||||
FILE==
|
||||
CMDS=<<EOF
|
||||
wx 55aa55aa909055aa9090ff20000ffffffff55fffffaaffffffffff
|
||||
pCx 5
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
- offset - 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF
|
||||
0x00000000 55aa 55aa 9090 55aa 9090 ff20 000f ffff U.U...U.... ....
|
||||
0x00000010 fff5 5fff ffaa ffff ffff ff00 0000 0000 .._.............
|
||||
0x00000020 0000 0000 0000 0000 0000 0000 0000 0000 ................
|
||||
0x00000030 0000 0000 0000 0000 0000 0000 0000 0000 ................
|
||||
0x00000040 0000 0000 0000 0000 0000 0000 0000 0000 ................
|
||||
EOF
|
||||
RUN
|
||||
|
||||
NAME=pCw
|
||||
FILE==
|
||||
CMDS=<<EOF
|
||||
wx 55aa55aa909055aa9090ff20000ffffffff55fffffaaffffffffff
|
||||
pCw 4
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
0x00000000 0xaa55aa55 0xaa559090 0x20ff9090 0xffff0f00 U.U...U.... ....
|
||||
0x00000010 0xff5ff5ff 0xffffaaff 0x00ffffff 0x00000000 .._.............
|
||||
0x00000020 0x00000000 0x00000000 0x00000000 0x00000000 ................
|
||||
0x00000030 0x00000000 0x00000000 0x00000000 0x00000000 ................
|
||||
0x00000040 0x00000000 0x00000000 0x00000000 0x00000000 ................
|
||||
EOF
|
||||
RUN
|
||||
|
|
@ -1552,16 +1552,6 @@ EXPECT=<<EOF
|
|||
EOF
|
||||
RUN
|
||||
|
||||
NAME=pC - crash
|
||||
FILE==
|
||||
CMDS=<<EOF
|
||||
e scr.null=true
|
||||
pC 0x200
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
EOF
|
||||
RUN
|
||||
|
||||
NAME=pd bin.str.purge
|
||||
FILE=bins/elf/analysis/ls2
|
||||
CMDS=<<EOF
|
||||
|
|
|
|||
Loading…
Reference in a new issue