diff options
| author | Dennis Brentjes <d.brentjes@gmail.com> | 2016-07-05 17:51:21 +0200 |
|---|---|---|
| committer | Dennis Brentjes <d.brentjes@gmail.com> | 2016-07-05 17:51:21 +0200 |
| commit | 06336eaddcc6a8f9cc578d8f059117c3aa535c9f (patch) | |
| tree | 4884cc68161df06112a49a04007fa6d03775d507 /disasm | |
| parent | b80a82fcc9edc73057796005cede4eea8380e193 (diff) | |
| download | openwar-06336eaddcc6a8f9cc578d8f059117c3aa535c9f.tar.gz openwar-06336eaddcc6a8f9cc578d8f059117c3aa535c9f.tar.bz2 openwar-06336eaddcc6a8f9cc578d8f059117c3aa535c9f.zip | |
Made the interface somewhat more consistant.
Diffstat (limited to 'disasm')
| -rw-r--r-- | disasm/disasm.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
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 <iostream> #include <istream> +#include <iomanip> 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<char> code_file(file_path.string()); std::vector<uint8_t> code(std::istreambuf_iterator<char>(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; } |
