* Add support for more opcodes in anal_x86
- lea, leave... * Update asm.decode with these changes * Add var $o for core->io->offset * Fix "function"|"loc" comments in disasm * Fix p%
This commit is contained in:
parent
80a5cb0651
commit
67e20135cc
5 changed files with 33 additions and 2 deletions
|
|
@ -88,6 +88,9 @@ R_API char *r_anal_op_to_string(RAnal *anal, RAnalOp *op) {
|
|||
case R_ANAL_OP_TYPE_JMP:
|
||||
snprintf (ret, retsz, "goto 0x%"PFMT64x, op->jump);
|
||||
break;
|
||||
case R_ANAL_OP_TYPE_UJMP:
|
||||
snprintf (ret, retsz, "goto %s", r0);
|
||||
break;
|
||||
case R_ANAL_OP_TYPE_PUSH:
|
||||
case R_ANAL_OP_TYPE_UPUSH:
|
||||
snprintf (ret, retsz, "push %s", a0);
|
||||
|
|
@ -138,6 +141,9 @@ R_API char *r_anal_op_to_string(RAnal *anal, RAnalOp *op) {
|
|||
snprintf (ret, retsz, "%s ^= %s", r0, a0);
|
||||
else snprintf (ret, retsz, "%s = %s ^ %s", r0, a0, a1);
|
||||
break;
|
||||
case R_ANAL_OP_TYPE_LEA:
|
||||
snprintf (ret, retsz, "%s -> %s", r0, a0);
|
||||
break;
|
||||
case R_ANAL_OP_TYPE_CMP:
|
||||
ret[0] = '\0';
|
||||
break;
|
||||
|
|
@ -147,6 +153,9 @@ R_API char *r_anal_op_to_string(RAnal *anal, RAnalOp *op) {
|
|||
case R_ANAL_OP_TYPE_RET:
|
||||
sprintf (ret, "ret");
|
||||
break;
|
||||
case R_ANAL_OP_TYPE_LEAVE:
|
||||
sprintf (ret, "leave");
|
||||
break;
|
||||
default:
|
||||
sprintf (ret, "// ?");
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -753,6 +753,17 @@ static void anal_xor(RAnal *anal, RAnalOp *op, x86im_instr_object io) {
|
|||
}
|
||||
}
|
||||
|
||||
static void anal_lea(RAnal *anal, RAnalOp *op, x86im_instr_object io) {
|
||||
st64 imm, disp;
|
||||
imm = r_hex_bin_truncate (io.imm, io.imm_size);
|
||||
disp = r_hex_bin_truncate (io.disp, io.disp_size);
|
||||
|
||||
op->type = R_ANAL_OP_TYPE_LEA;
|
||||
/* lea reg, [0x0ff | reg1+reg2+0x0ff] */
|
||||
op->dst = anal_fill_ai_rg (anal, io, 0);
|
||||
op->src[0] = anal_fill_ai_mm (anal, io);
|
||||
}
|
||||
|
||||
static void anal_int(RAnal *anal, RAnalOp *op, x86im_instr_object io) {
|
||||
op->type = R_ANAL_OP_TYPE_SWI;
|
||||
switch (io.id) {
|
||||
|
|
@ -860,6 +871,12 @@ static int x86_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len)
|
|||
} else
|
||||
if (io.id == X86IM_IO_ID_NOP) /* nop */
|
||||
op->type = R_ANAL_OP_TYPE_NOP;
|
||||
else
|
||||
if (io.id == X86IM_IO_ID_LEA) /* lea */
|
||||
anal_lea (anal, op, io);
|
||||
else
|
||||
if (io.id == X86IM_IO_ID_LEAVE) /* leave */
|
||||
op->type = R_ANAL_OP_TYPE_LEAVE;
|
||||
op->length = io.len;
|
||||
op->nopcode = io.opcode_count;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -278,7 +278,8 @@ if (core->inc == 0)
|
|||
if (f->addr == at) {
|
||||
char *sign = r_anal_fcn_to_string (core->anal, f);
|
||||
r_cons_printf ("/ %s: %s (%d)\n| ",
|
||||
f->type == R_ANAL_FCN_TYPE_FCN?"function":"loc", f->name, f->size);
|
||||
(f->type==R_ANAL_FCN_TYPE_FCN||f->type==R_ANAL_FCN_TYPE_SYM)?"function":"loc",
|
||||
f->name, f->size);
|
||||
if (sign) r_cons_printf ("// %s\n", sign);
|
||||
free (sign);
|
||||
pre = "| ";
|
||||
|
|
@ -1550,6 +1551,7 @@ static int cmd_help(void *data, const char *input) {
|
|||
" ??? ; show this help\n"
|
||||
"$variables:\n"
|
||||
" $$ = here (current seek)\n"
|
||||
" $o = here (current io offset)\n"
|
||||
" $s = file size\n"
|
||||
" $b = block size\n"
|
||||
" $j = jump address\n"
|
||||
|
|
@ -1877,7 +1879,7 @@ static int cmd_print(void *data, const char *input) {
|
|||
switch (input[0]) {
|
||||
case '%':
|
||||
{
|
||||
ut64 off = core->offset;
|
||||
ut64 off = core->io->off;
|
||||
ut64 s = core->file?core->file->size:0;
|
||||
ut64 piece = 0;
|
||||
int w = core->print->cols * 4;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ static ut64 num_callback(RNum *userptr, const char *str, int *ok) {
|
|||
case 's': return core->file->size;
|
||||
case '?': return core->num->value;
|
||||
case '$': return core->offset;
|
||||
case 'o': return core->io->off;
|
||||
}
|
||||
}
|
||||
if (str[0]>'A') {
|
||||
|
|
|
|||
|
|
@ -53,6 +53,8 @@ enum {
|
|||
R_ANAL_OP_TYPE_NOT = 0x8000000,
|
||||
R_ANAL_OP_TYPE_STORE = 0x10000000, /* store from register to memory */
|
||||
R_ANAL_OP_TYPE_LOAD = 0x20000000, /* load from memory to register */
|
||||
R_ANAL_OP_TYPE_LEA = 0x40000000,
|
||||
R_ANAL_OP_TYPE_LEAVE = 0x80000000,
|
||||
};
|
||||
|
||||
/* TODO: what to do with signed/unsigned conditionals? */
|
||||
|
|
|
|||
Loading…
Reference in a new issue