Minor improvements here and there

This commit is contained in:
pancake 2018-04-12 11:28:25 +02:00
parent 76eb47797b
commit 59d8f4e280
6 changed files with 77 additions and 62 deletions

View File

@ -935,6 +935,7 @@ repeat:
}
switch (op.type & R_ANAL_OP_TYPE_MASK) {
case R_ANAL_OP_TYPE_CMOV:
case R_ANAL_OP_TYPE_MOV:
// skip mov reg,reg
if (anal->opt.hpskip && regs_exist (op.src[0], op.dst)

View File

@ -1038,7 +1038,6 @@ R_API const char *r_line_readline_cb(RLineReadCallback cb, void *user) {
r_cons_break_push (NULL, NULL);
for (;;) {
if (r_cons_is_breaked ()) {
eprintf ("CATCH\n");
break;
}
I.buffer.data[I.buffer.length] = '\0';

View File

@ -1257,16 +1257,16 @@ static int taskbgrun(RThread *th) {
static int cmd_thread(void *data, const char *input) {
RCore *core = (RCore*) data;
if (r_sandbox_enable (0)) {
eprintf ("This command is disabled in sandbox mode\n");
return 0;
}
switch (input[0]) {
case '\0':
case 'j':
r_core_task_list (core, *input);
break;
case '&':
if (r_sandbox_enable (0)) {
eprintf ("This command is disabled in sandbox mode\n");
return 0;
}
if (input[1] == '&') {
// wait until ^C
} else {
@ -1292,15 +1292,25 @@ static int cmd_thread(void *data, const char *input) {
task->id, task->state, task->msg->text);
if (task->msg->res)
r_cons_println (task->msg->res);
} else eprintf ("Cannot find task\n");
} else {
eprintf ("Cannot find task\n");
}
} else {
r_core_task_list (core, 1);
}}
break;
case '+':
if (r_sandbox_enable (0)) {
eprintf ("This command is disabled in sandbox mode\n");
return 0;
}
r_core_task_add (core, r_core_task_new (core, input + 1, (RCoreTaskCallback)task_finished, core));
break;
case '-':
if (r_sandbox_enable (0)) {
eprintf ("This command is disabled in sandbox mode\n");
return 0;
}
if (input[1] == '*') {
r_core_task_del (core, -1);
} else {
@ -1311,6 +1321,10 @@ static int cmd_thread(void *data, const char *input) {
helpCmdTasks (core);
break;
case ' ':
if (r_sandbox_enable (0)) {
eprintf ("This command is disabled in sandbox mode\n");
return 0;
}
{
int tid = r_num_math (core->num, input + 1);
if (tid) {

View File

@ -839,10 +839,7 @@ static char *colorize_asm_string(RCore *core, RDisasmState *ds, bool print_color
if (print_color) {
r_cons_strcat (r_print_color_op_type (core->print, ds->analop.type));
}
// workaround dummy colorizer in case of paired commands (tms320 & friends)
spacer = strstr (source, "||");
if (spacer) {
char *scol1, *s1 = r_str_ndup (source, spacer - source);
@ -2550,7 +2547,7 @@ static void ds_instruction_mov_lea(RDisasmState *ds, int idx) {
case R_ANAL_OP_TYPE_CMOV:
case R_ANAL_OP_TYPE_MOV:
src = ds->analop.src[0];
if (src && src->memref>0 && src->reg && core->anal->reg) {
if (src && src->memref > 0 && src->reg && core->anal->reg) {
const char *pc = core->anal->reg->name[R_REG_NAME_PC];
RAnalValue *dst = ds->analop.dst;
if (dst && dst->reg && dst->reg->name) {
@ -2976,63 +2973,61 @@ static void ds_print_core_vmode(RDisasmState *ds, int pos) {
if (!core->vmode) {
return;
}
{
switch (ds->analop.type) {
case R_ANAL_OP_TYPE_MOV:
case R_ANAL_OP_TYPE_LEA:
case R_ANAL_OP_TYPE_LOAD:
if (ds->show_leahints) {
if (ds->analop.ptr != UT64_MAX && ds->analop.ptr > 256) {
ds_print_shortcut (ds, ds->analop.ptr, pos);
gotShortcut = true;
}
switch (ds->analop.type) {
case R_ANAL_OP_TYPE_MOV:
case R_ANAL_OP_TYPE_LEA:
case R_ANAL_OP_TYPE_LOAD:
if (ds->show_leahints) {
if (ds->analop.ptr != UT64_MAX && ds->analop.ptr > 256) {
ds_print_shortcut (ds, ds->analop.ptr, pos);
gotShortcut = true;
}
break;
case R_ANAL_OP_TYPE_UCALL:
case R_ANAL_OP_TYPE_UCALL | R_ANAL_OP_TYPE_REG | R_ANAL_OP_TYPE_IND:
case R_ANAL_OP_TYPE_UCALL | R_ANAL_OP_TYPE_IND:
}
break;
case R_ANAL_OP_TYPE_UCALL:
case R_ANAL_OP_TYPE_UCALL | R_ANAL_OP_TYPE_REG | R_ANAL_OP_TYPE_IND:
case R_ANAL_OP_TYPE_UCALL | R_ANAL_OP_TYPE_IND:
#if 0
if (ds->analop.jump == 0 && ds->analop.ptr) {
ut8 buf[sizeof(ut64)] = {0};
r_io_read_at (core->io, ds->analop.ptr, buf, sizeof (buf));
ut32 n32 = r_read_ble32 (buf, 0);
// is valid address
// ut32 n64 = r_read_ble32 (buf, 0);
ds_print_shortcut (ds, n32, pos);
if (ds->analop.jump == 0 && ds->analop.ptr) {
ut8 buf[sizeof(ut64)] = {0};
r_io_read_at (core->io, ds->analop.ptr, buf, sizeof (buf));
ut32 n32 = r_read_ble32 (buf, 0);
// is valid address
// ut32 n64 = r_read_ble32 (buf, 0);
ds_print_shortcut (ds, n32, pos);
} else {
// ds_print_shortcut (ds, ds->analop.jump, pos);
ds_print_shortcut (ds, ds->analop.ptr, pos);
}
#endif
if (ds->show_jmphints) {
if (ds->analop.jump != UT64_MAX) {
ds_print_shortcut (ds, ds->analop.jump, pos);
} else {
// ds_print_shortcut (ds, ds->analop.jump, pos);
ds_print_shortcut (ds, ds->analop.ptr, pos);
}
#endif
if (ds->show_jmphints) {
if (ds->analop.jump != UT64_MAX) {
ds_print_shortcut (ds, ds->analop.jump, pos);
} else {
ds_print_shortcut (ds, ds->analop.ptr, pos);
}
gotShortcut = true;
}
break;
case R_ANAL_OP_TYPE_RCALL:
break;
case R_ANAL_OP_TYPE_JMP:
case R_ANAL_OP_TYPE_CJMP:
case R_ANAL_OP_TYPE_CALL:
case R_ANAL_OP_TYPE_COND | R_ANAL_OP_TYPE_CALL:
if (ds->show_jmphints) {
ds_print_shortcut (ds, ds->analop.jump, pos);
gotShortcut = true;
}
break;
default:
if (ds_print_core_vmode_jump_hit (ds, pos)) {
gotShortcut = true;
}
break;
gotShortcut = true;
}
if (!gotShortcut) {
r_cons_strcat (" ");
break;
case R_ANAL_OP_TYPE_RCALL:
break;
case R_ANAL_OP_TYPE_JMP:
case R_ANAL_OP_TYPE_CJMP:
case R_ANAL_OP_TYPE_CALL:
case R_ANAL_OP_TYPE_COND | R_ANAL_OP_TYPE_CALL:
if (ds->show_jmphints) {
ds_print_shortcut (ds, ds->analop.jump, pos);
gotShortcut = true;
}
break;
default:
if (ds_print_core_vmode_jump_hit (ds, pos)) {
gotShortcut = true;
}
break;
}
if (!gotShortcut) {
r_cons_strcat (" ");
}
}
@ -3988,7 +3983,7 @@ static void ds_print_esil_anal(RDisasmState *ds) {
bool warning = false;
bool on_stack = false;
r_list_foreach (list, iter, arg) {
if (arg->cc_source && !strncmp (arg->cc_source, "stack", 5)) {
if (r_str_startswith (arg->cc_source, "stack")) {
on_stack = true;
}
if (!arg->size) {

View File

@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2014-2016 - pancake */
/* radare - LGPL - Copyright 2014-2018 - pancake */
#include <r_core.h>

View File

@ -2598,6 +2598,12 @@ R_API char *r_str_between(const char *cmt, const char *prefix, const char *suffi
}
R_API bool r_str_startswith(const char *str, const char *needle) {
if (!str || !needle) {
return false;
}
if (str == needle) {
return true;
}
return !strncmp (str, needle, strlen (needle));
}