Add align info in payloads #7376 (#7574)

This commit is contained in:
Marc 2017-05-23 03:01:45 +02:00 committed by radare
parent c506c8ebd7
commit ae1aef88b9
4 changed files with 12 additions and 5 deletions

View File

@ -143,6 +143,7 @@ R_API RAsm *r_asm_new() {
if (!a) {
return NULL;
}
a->dataalign = 1;
a->bits = R_SYS_BITS;
a->syntax = R_ASM_SYNTAX_INTEL;
a->plugins = r_list_newf ((RListFree)plugin_free);

View File

@ -15,6 +15,7 @@ static int dalvik_disassemble (RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
char str[1024], *strasm;
ut64 offset;
const char *flag_str;
a->dataalign = 2;
op->buf_asm[0] = 0;
if (buf[0] == 0x00) { /* nop */
@ -54,7 +55,7 @@ static int dalvik_disassemble (RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
snprintf (op->buf_asm, sizeof (op->buf_asm),
"fill-array-data-payload %d, %d",
elem_width, array_size);
payload = 2 * ((array_size * elem_width+1)/2);
payload = array_size * elem_width;
}
size = 8;
len = 0;

View File

@ -2592,9 +2592,13 @@ static void ds_print_asmop_payload(RDisasmState *ds, const ut8 *buf) {
if (ds->asmop.payload != 0) {
r_cons_printf ("\n; .. payload of %d bytes", ds->asmop.payload);
if (ds->showpayloads) {
int mod = ds->asmop.payload % ds->core->assembler->dataalign;
int x;
for (x = 0; x < ds->asmop.payload; ++x) {
r_cons_printf ("\n 0x%x", buf[ds->oplen + x]);
r_cons_printf ("\n 0x%02x", buf[ds->oplen + x]);
}
for (x = 0; x < mod; ++x) {
r_cons_printf ("\n 0x%02x ; alignment", buf[ds->oplen + ds->asmop.payload + x]);
}
}
}
@ -3786,7 +3790,7 @@ toro:
if (inc < 1) {
inc = 1;
}
inc += ds->asmop.payload;
inc += ds->asmop.payload + (ds->asmop.payload % ds->core->assembler->dataalign);
}
R_FREE (nbuf);
r_cons_break_pop ();
@ -4258,8 +4262,8 @@ R_API int r_core_print_disasm_json(RCore *core, ut64 addr, ut8 *buf, int nb_byte
}
r_cons_printf ("}");
i += oplen + asmop.payload; // bytes
k += oplen + asmop.payload; // delta from addr
i += oplen + asmop.payload + (ds->asmop.payload % ds->core->assembler->dataalign); // bytes
k += oplen + asmop.payload + (ds->asmop.payload % ds->core->assembler->dataalign); // delta from addr
j++; // instructions
line++;

View File

@ -111,6 +111,7 @@ typedef struct r_asm_t {
char *features;
int invhex; // invalid instructions displayed in hex
int pcalign;
int dataalign;
} RAsm;
typedef int (*RAsmModifyCallback)(RAsm *a, ut8 *buf, int field, ut64 val);