From 06336eaddcc6a8f9cc578d8f059117c3aa535c9f Mon Sep 17 00:00:00 2001 From: Dennis Brentjes Date: Tue, 5 Jul 2016 17:51:21 +0200 Subject: Made the interface somewhat more consistant. --- disasm/disasm.cpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'disasm/disasm.cpp') diff --git a/disasm/disasm.cpp b/disasm/disasm.cpp index 609794e..862813c 100644 --- a/disasm/disasm.cpp +++ b/disasm/disasm.cpp @@ -8,6 +8,7 @@ #include #include +#include int main(int argc, char* argv[]) { boost::program_options::options_description description; @@ -58,11 +59,28 @@ int main(int argc, char* argv[]) { std::basic_ifstream code_file(file_path.string()); std::vector code(std::istreambuf_iterator(code_file), {}); - _DecodedInst inst; + std::vector<_DecodedInst> instructions; + instructions.resize(100000); unsigned int read_inst; + + auto eip_object = x.object_table.entries[x.le_header.EIP_object]; + auto index = eip_object.page_table_index; + auto page = x.object_page_table.entries[index]; - auto result = distorm_decode64(x.mz_header.ip, code.data(), 1, Decode16Bits, &inst, 1, &read_inst); + binparse::Offset32 offset = x.le_offset + x.le_header.data_page_offset; - std::cout << inst.mnemonic.p << " " << inst.operands.p << std::endl; - + auto result = distorm_decode64(0x00010000, code.data() + offset, 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; + } + + return 0; } -- cgit v1.2.3-70-g09d2