#include "dumpobject.hpp" #include "le_file.hpp" #include #include void dump_object(std::ifstream& ifs, uint32_t object_id) { auto x = le::parse_file(ifs); ifs.clear(); ifs.seekg(0, std::ios::beg); std::vector code(std::istreambuf_iterator(ifs), {}); std::vector<_DecodedInst> instructions; instructions.resize(100000); unsigned int read_inst; auto object = x.object_table.entries[object_id]; auto index = object.page_table_index; binparse::Offset32 offset = x.le_header.data_page_offset; auto result = distorm_decode64( object.reloc_base_address, code.data() + offset + (index - 1) * x.le_header.page_size, x.object_table.entries[1].nr_page_table_entries * x.le_header.page_size, Decode32Bits, instructions.data(), instructions.size(), &read_inst ); instructions.resize(read_inst); instructions.shrink_to_fit(); if(result) { } 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; } }