mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-11 23:16:05 +00:00
Fix #4362
This commit is contained in:
parent
6919b58716
commit
9c998618aa
@ -2281,6 +2281,48 @@ static void cmd_anal_esil(RCore *core, const char *input) {
|
||||
cmd_aea (core, 0, core->offset, r_num_math (core->num, input+2));
|
||||
}
|
||||
break;
|
||||
case 'x':{ // "aex"
|
||||
ut32 new_bits = -1;
|
||||
int segoff, old_bits, pos = 0;
|
||||
ut8 settings_changed = false;
|
||||
char *new_arch = NULL, *old_arch = NULL, *hex = NULL;
|
||||
old_arch = strdup (r_config_get (core->config, "asm.arch"));
|
||||
old_bits = r_config_get_i (core->config, "asm.bits");
|
||||
segoff = r_config_get_i (core->config, "asm.segoff");
|
||||
|
||||
if (input[0])
|
||||
for (pos = 1; pos < R_BIN_SIZEOF_STRINGS && input[pos]; pos++)
|
||||
if (input[pos] == ' ') break;
|
||||
|
||||
if (!r_core_process_input_pade (core, input+pos, &hex, &new_arch, &new_bits)) {
|
||||
// XXX - print help message
|
||||
//return false;
|
||||
}
|
||||
|
||||
if (new_arch == NULL) new_arch = strdup (old_arch);
|
||||
if (new_bits == -1) new_bits = old_bits;
|
||||
|
||||
if (strcmp (new_arch, old_arch) != 0 || new_bits != old_bits){
|
||||
r_core_set_asm_configs (core, new_arch, new_bits, segoff);
|
||||
settings_changed = true;
|
||||
}
|
||||
int ret, bufsz;
|
||||
RAnalOp aop = {0};
|
||||
const char *str;
|
||||
char *str2 = NULL;
|
||||
bufsz = r_hex_str2bin (hex, (ut8*)hex);
|
||||
ret = r_anal_op (core->anal, &aop, core->offset,
|
||||
(const ut8*)hex, bufsz);
|
||||
if (ret>0) {
|
||||
str = R_STRBUF_SAFEGET (&aop.esil);
|
||||
str2 = calloc(sizeof(char), strlen(str)+1);
|
||||
strcat(str2," ");
|
||||
strcat(str2, str);
|
||||
cmd_anal_esil (core, str2);
|
||||
}
|
||||
r_anal_op_fini (&aop);
|
||||
}
|
||||
break;
|
||||
case '?':
|
||||
if (input[1] == '?') {
|
||||
const char *help_msg[] = {
|
||||
@ -2326,6 +2368,7 @@ static void cmd_anal_esil(RCore *core, const char *input) {
|
||||
"aeim", "", "initialize ESIL VM stack (aeim- remove)",
|
||||
"aeip", "", "initialize ESIL program counter to curseek",
|
||||
"ae", " [expr]", "evaluate ESIL expression",
|
||||
"aex", " [hex]", "evaluate opcode expression",
|
||||
"ae[aA]", "[f] [count]", "analyse esil accesses (regs, mem..)",
|
||||
"aep", " [addr]", "change esil PC to this address",
|
||||
"aef", " [addr]", "emulate function",
|
||||
|
@ -77,7 +77,7 @@ static void cmd_print_eq_dict(RCore *core, int bsz) {
|
||||
r_cons_printf ("block: %d 0x%x\n", bsz, bsz);
|
||||
}
|
||||
|
||||
static void set_asm_configs(RCore *core, char *arch, ut32 bits, int segoff){
|
||||
R_API void r_core_set_asm_configs(RCore *core, char *arch, ut32 bits, int segoff){
|
||||
r_config_set (core->config, "asm.arch", arch);
|
||||
r_config_set_i (core->config, "asm.bits", bits);
|
||||
// XXX - this needs to be done here, because
|
||||
@ -200,7 +200,7 @@ static int process_input(RCore *core, const char *input, ut64* blocksize, char *
|
||||
}
|
||||
|
||||
/* This function is not necessary anymore, but it's kept for discussion */
|
||||
static int process_input_pade(RCore *core, const char *input, char** hex, char **asm_arch, ut32 *bits) {
|
||||
R_API int r_core_process_input_pade(RCore *core, const char *input, char** hex, char **asm_arch, ut32 *bits) {
|
||||
// input: start of the input string e.g. after the command symbols have been consumed
|
||||
// size: hex if present, otherwise -1
|
||||
// asm_arch: asm_arch to interpret as if present and valid, otherwise NULL;
|
||||
@ -2022,7 +2022,7 @@ static int cmd_print(void *data, const char *input) {
|
||||
for (pos = 1; pos < R_BIN_SIZEOF_STRINGS && input[pos]; pos++)
|
||||
if (input[pos] == ' ') break;
|
||||
|
||||
if (!process_input_pade (core, input+pos, &hex, &new_arch, &new_bits)) {
|
||||
if (!r_core_process_input_pade (core, input+pos, &hex, &new_arch, &new_bits)) {
|
||||
// XXX - print help message
|
||||
//return false;
|
||||
}
|
||||
@ -2031,7 +2031,7 @@ static int cmd_print(void *data, const char *input) {
|
||||
if (new_bits == -1) new_bits = old_bits;
|
||||
|
||||
if (strcmp (new_arch, old_arch) != 0 || new_bits != old_bits){
|
||||
set_asm_configs (core, new_arch, new_bits, segoff);
|
||||
r_core_set_asm_configs (core, new_arch, new_bits, segoff);
|
||||
settings_changed = true;
|
||||
}
|
||||
}
|
||||
@ -2083,7 +2083,7 @@ static int cmd_print(void *data, const char *input) {
|
||||
}
|
||||
}
|
||||
if (settings_changed)
|
||||
set_asm_configs (core, old_arch, old_bits, segoff);
|
||||
r_core_set_asm_configs (core, old_arch, old_bits, segoff);
|
||||
free (old_arch);
|
||||
free (new_arch);
|
||||
}
|
||||
@ -2301,7 +2301,7 @@ static int cmd_print(void *data, const char *input) {
|
||||
if (new_bits == -1) new_bits = old_bits;
|
||||
|
||||
if (strcmp (new_arch, old_arch) != 0 || new_bits != old_bits){
|
||||
set_asm_configs (core, new_arch, new_bits, segoff);
|
||||
r_core_set_asm_configs (core, new_arch, new_bits, segoff);
|
||||
settings_changed = true;
|
||||
}
|
||||
|
||||
@ -2581,7 +2581,7 @@ static int cmd_print(void *data, const char *input) {
|
||||
core->offset = current_offset;
|
||||
// change back asm setting is they were changed
|
||||
if (settings_changed)
|
||||
set_asm_configs (core, old_arch, old_bits, segoff);
|
||||
r_core_set_asm_configs (core, old_arch, old_bits, segoff);
|
||||
|
||||
free (old_arch);
|
||||
free (new_arch);
|
||||
|
@ -321,6 +321,8 @@ R_API RAnalOp *r_core_op_anal(RCore *core, ut64 addr);
|
||||
R_API char *r_core_disassemble_instr(RCore *core, ut64 addr, int l);
|
||||
R_API char *r_core_disassemble_bytes(RCore *core, ut64 addr, int b);
|
||||
|
||||
R_API int r_core_process_input_pade(RCore *core, const char *input, char** hex, char **asm_arch, ut32 *bits);
|
||||
|
||||
/* anal.c */
|
||||
R_API RAnalOp* r_core_anal_op(RCore *core, ut64 addr);
|
||||
R_API void r_core_anal_esil (RCore *core, const char *str);
|
||||
@ -363,6 +365,7 @@ R_API RBuffer *r_core_syscallf (RCore *core, const char *name, const char *fmt,
|
||||
R_API RCoreAsmHit *r_core_asm_hit_new(void);
|
||||
R_API RList *r_core_asm_hit_list_new(void);
|
||||
R_API void r_core_asm_hit_free(void *_hit);
|
||||
R_API void r_core_set_asm_configs(RCore *core, char *arch, ut32 bits, int segoff);
|
||||
R_API char* r_core_asm_search(RCore *core, const char *input, ut64 from, ut64 to);
|
||||
R_API RList *r_core_asm_strsearch(RCore *core, const char *input, ut64 from, ut64 to, int maxhits, int regexp);
|
||||
R_API RList *r_core_asm_bwdisassemble (RCore *core, ut64 addr, int n, int len);
|
||||
|
Loading…
Reference in New Issue
Block a user