コード例 #1
0
ファイル: rasm.c プロジェクト: BDLuzhuo/tainttrap
/* reference (accurate but expensive) disassembly */
const char* emu_disasm_ref(unsigned int pc, uint8_t bits) {
    if (!rasm) {
        /* rasm2 configuration defaults */
        static const char arch[]    = {"arm"};   /* ARM ISA */
        static const int big_endian = 0;         /* ARMv7 is little endian */

        rasm = r_asm_new();
        /* R_API int r_asm_setup(RAsm *a, const char *arch, int bits, int big_endian); */
        r_asm_setup(rasm, arch, bits, big_endian);
    }
    assert(rasm != NULL);

    r_asm_set_bits(rasm, bits);
    r_asm_set_big_endian(rasm, bits == 16); /* 16: big endian, 32: little endian */

    /* printf("emu: %0lx: %0x\n", cpu(pc), *(unsigned int *)cpu(pc)); // if all else fails */
    static RAsmOp rop;

    const int len = bits / 8;         /* disassemble 4 bytes (A32) or 2 bytes (T16) */
    uint32_t ins = *(const uint32_t *)pc;
    if (bits == 16) ins &= 0xffff;

    r_asm_set_pc(rasm, pc);
    // printf("r_asm_disassemble() pc: %x bits: %d len: %d\n", pc, bits, len);
    r_asm_disassemble(rasm, &rop, (const unsigned char *)pc, len);
    printf("disas: %x %x %s\n", pc, ins, rop.buf_asm);

    return rop.buf_asm;
}
コード例 #2
0
ファイル: emu.c プロジェクト: condret/ramulate
emu *emu_new()
{
	struct emu_t *e = R_NEW0(emu);
	e->reg = r_reg_new();
	e->io = r_io_new();
	e->bin = r_bin_new();
	e->lib = r_lib_new("ramulate_plugin");
	e->plugins = r_list_new();
	e->a = r_asm_new();
	e->op = R_NEW0(RAsmOp);
	e->anal = r_anal_new();
	e->anop = r_anal_op_new();
	e->next_vs_id = 0;
	e->screen = NULL;
	r_lib_add_handler(e->lib, RAMULATE_EMU_PLUGIN, "emulation plugin handler", &emu_plugin_cb, &emu_plugin_cb_end, e);
	return e;
}