mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-30 01:34:23 +00:00
19fa55ba33
* Properly installation of vapi files - Lot of fixtures to build a external hello world in gtk+vala+r_asm - default staticplugins for r_asm are: mips, java and x86_olly by default - Add r_util.vapi and make .pc file point to -lr_util - Use .deps to generate dependencies between vapi files - Fix r_asm.vapi (Added Asm.Aop struct) - add set(string) method - asm/disasm -> assemble/disassemble * Fix warning + build in sign.c - Included in default build * Fix segfault in r_lib with NULL in opendir() * More fixtures for r_asm_plugin_* - use #ifndef CORELIB - drop 'static' * Update README
53 lines
1.2 KiB
C
53 lines
1.2 KiB
C
/* radare - LGPL - Copyright 2009 nibble<.ds@gmail.com> */
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#include <r_types.h>
|
|
#include <r_lib.h>
|
|
#include <r_asm.h>
|
|
|
|
#include "x86/udis86/types.h"
|
|
#include "x86/udis86/extern.h"
|
|
|
|
|
|
static int disassemble(struct r_asm_t *a, struct r_asm_aop_t *aop, u8 *buf, u64 len)
|
|
{
|
|
static ud_t disasm_obj;
|
|
|
|
ud_init(&disasm_obj);
|
|
if (a->syntax == R_ASM_SYN_ATT)
|
|
ud_set_syntax(&disasm_obj, UD_SYN_ATT);
|
|
else
|
|
ud_set_syntax(&disasm_obj, UD_SYN_INTEL);
|
|
ud_set_mode(&disasm_obj, a->bits);
|
|
ud_set_pc(&disasm_obj, a->pc);
|
|
ud_set_input_buffer(&disasm_obj, buf, len);
|
|
ud_disassemble(&disasm_obj);
|
|
aop->disasm_obj = &disasm_obj;
|
|
aop->inst_len = ud_insn_len(&disasm_obj);
|
|
snprintf(aop->buf_asm, 256, "%s", ud_insn_asm(&disasm_obj));
|
|
snprintf(aop->buf_hex, 256, "%s", ud_insn_hex(&disasm_obj));
|
|
|
|
if (aop->inst_len > 0)
|
|
memcpy(aop->buf, buf, aop->inst_len);
|
|
|
|
return aop->inst_len;
|
|
}
|
|
|
|
struct r_asm_handle_t r_asm_plugin_x86 = {
|
|
.name = "asm_x86",
|
|
.desc = "X86 disassembly plugin",
|
|
.init = NULL,
|
|
.fini = NULL,
|
|
.disassemble = &disassemble,
|
|
.assemble = NULL
|
|
};
|
|
|
|
#ifndef CORELIB
|
|
struct r_lib_struct_t radare_plugin = {
|
|
.type = R_LIB_TYPE_ASM,
|
|
.data = &r_asm_plugin_x86
|
|
};
|
|
#endif
|