void disassemble_mem(void * src, size_t length) { opdis_t o; opdis_buf_t buf = opdis_buf_alloc(length, (opdis_vma_t)src); opdis_buf_fill(buf, 0, src, length); o = opdis_init(); //opdis_set_arch(o, bfd_arch_k1om, bfd_mach_k1om, NULL); //const bfd_arch_info_type *arch_info = bfd_scan_arch("i386:x86-64"); opdis_set_arch(o, bfd_arch_i386, bfd_mach_x86_64, print_insn_i386_att); opdis_disasm_linear(o, buf, (opdis_vma_t)src, length); opdis_buf_free(buf); opdis_term(o); }
opdis_buf_t LIBCALL opdis_buf_read( FILE * f, opdis_off_t size, opdis_vma_t addr ) { opdis_buf_t buf; if (! size ) { size = get_read_length( f ); if (! size ) { return NULL; } } buf = opdis_buf_alloc( size, addr ); if (! buf ) { return NULL; } if ( fread( buf->data, 1, size, f ) < size ) { fprintf( stderr, "opdis_buf_read: cannot read %d bytes\n", (int) size ); } return buf; }