From fcc6b8d01332694f06bd734976c8d0580b9309cd Mon Sep 17 00:00:00 2001 From: Nibble Date: Sun, 30 May 2010 13:00:21 +0200 Subject: [PATCH] * Add flag -M to rabin2 at radare2 startup and cg * Add r_asm_mdisassemble_hexstr * Update r_asm.vapi --- binr/radare2/radare2.c | 2 +- libr/asm/asm.c | 13 +++++++++++++ libr/core/gdiff.c | 3 ++- libr/include/r_asm.h | 1 + swig/vapi/r_asm.vapi | 1 + 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/binr/radare2/radare2.c b/binr/radare2/radare2.c index eb2e1c5120..261fc1290f 100644 --- a/binr/radare2/radare2.c +++ b/binr/radare2/radare2.c @@ -170,7 +170,7 @@ int main(int argc, char **argv) { // Load the binary information from rabin2 { - char *cmd = r_str_dup_printf (".!rabin2 -rSIeis%s %s", + char *cmd = r_str_dup_printf (".!rabin2 -rSIeMis%s %s", (debug||r.io->va)?"v":"", r.file->filename); r_core_cmd (&r, cmd, 0); r_str_free (cmd); diff --git a/libr/asm/asm.c b/libr/asm/asm.c index c422914d47..0d877bc8f6 100644 --- a/libr/asm/asm.c +++ b/libr/asm/asm.c @@ -237,6 +237,19 @@ R_API RAsmCode* r_asm_mdisassemble(RAsm *a, ut8 *buf, ut64 len) { return acode; } +R_API RAsmCode* r_asm_mdisassemble_hexstr(RAsm *a, const char *hexstr) { + RAsmCode *ret; + ut8 *buf; + int len; + + if (!(buf = malloc (strlen (hexstr)))) + return NULL; + len = r_hex_str2bin (hexstr, buf); + ret = r_asm_mdisassemble (a, buf, len); + free (buf); + return ret; +} + R_API RAsmCode* r_asm_massemble(RAsm *a, const char *buf) { char *lbuf = NULL, *ptr2, *ptr = NULL, *ptr_start = NULL, *tokens[R_ASM_BUFSIZE], buf_token[R_ASM_BUFSIZE]; diff --git a/libr/core/gdiff.c b/libr/core/gdiff.c index a978241203..4aad2efa18 100644 --- a/libr/core/gdiff.c +++ b/libr/core/gdiff.c @@ -209,12 +209,13 @@ R_API int r_core_gdiff(RCore *core, char *file1, char *file2, int va) { return R_FALSE; } r_config_set_i (core2->config, "io.va", va); - sprintf (cmd, ".!rabin2 -rSIeis%s %s", va?"v":"", files[i]); + sprintf (cmd, ".!rabin2 -rSIeMis%s %s", va?"v":"", files[i]); r_core_cmd0 (core2, cmd); /* XXX Select correct analysis plugin */ r_core_cmd0 (core2, "ah x86_x86im"); r_core_cmd0 (core2, "fs *"); r_core_cmd0 (core2, "af @ entry0"); + r_core_cmd0 (core2, "af @ main"); r_core_cmd0 (core2, "af @@ fcn."); r_core_cmd0 (core2, "ab @@ fcn."); /* Copy bb's and fcn's */ diff --git a/libr/include/r_asm.h b/libr/include/r_asm.h index 8f7899e040..d10c63ac58 100644 --- a/libr/include/r_asm.h +++ b/libr/include/r_asm.h @@ -112,6 +112,7 @@ R_API int r_asm_set_pc(RAsm *a, ut64 pc); R_API int r_asm_disassemble(RAsm *a, struct r_asm_aop_t *aop, ut8 *buf, ut64 len); R_API int r_asm_assemble(RAsm *a, struct r_asm_aop_t *aop, const char *buf); R_API struct r_asm_code_t* r_asm_mdisassemble(RAsm *a, ut8 *buf, ut64 len); +R_API RAsmCode* r_asm_mdisassemble_hexstr(RAsm *a, const char *hexstr); R_API struct r_asm_code_t* r_asm_massemble(RAsm *a, const char *buf); /* code.c */ diff --git a/swig/vapi/r_asm.vapi b/swig/vapi/r_asm.vapi index ba39d434f1..40519475e1 100644 --- a/swig/vapi/r_asm.vapi +++ b/swig/vapi/r_asm.vapi @@ -77,6 +77,7 @@ public class RAsm { public int disassemble(out Aop aop, uint8 *buf, uint64 length); public int assemble(out Aop aop, string buf); public Code? mdisassemble(uint8 *buf, uint64 length); + public Code? mdisassemble_hexstr(string hexstr); public Code? massemble(string buf); public unowned string fastcall(int idx, int num);