#include "dumpobject.hpp" #include "leparseutil.hpp" #include #include void dump_object(std::string file_name, binparse::Value32 object_id) { std::ifstream ifs(file_name, std::ios::binary); ifs.unsetf(std::ios::skipws); auto file = parse_file(ifs); std::vector<_DecodedInst> instructions; instructions.resize(100000); unsigned int read_inst; std::vector code = read_object(ifs, file, object_id); auto result = distorm_decode64( file.object_table.entries[object_id].reloc_base_address, code.data(), code.size(), Decode32Bits, instructions.data(), instructions.size(), &read_inst ); instructions.resize(read_inst); instructions.shrink_to_fit(); for(auto&& inst : instructions) { std::cout << std::hex << std::setw(8) << std::setfill('0') << inst.offset << ":\t" << inst.mnemonic.p << " " << inst.operands.p << std::endl; } }