diff options
| author | Dennis Brentjes <d.brentjes@gmail.com> | 2016-09-08 21:49:49 +0200 |
|---|---|---|
| committer | Dennis Brentjes <d.brentjes@gmail.com> | 2016-09-08 21:49:49 +0200 |
| commit | cec56db9d4c84de13796ce7cd7dcd2631c443cec (patch) | |
| tree | d21847b479ee5bf4f263abd124a8dc7a3293e1cd /disasm/dumpobject.cpp | |
| parent | 35be012af254617b72ecbe4bca718f3ce96c1fd2 (diff) | |
| download | openwar-cec56db9d4c84de13796ce7cd7dcd2631c443cec.tar.gz openwar-cec56db9d4c84de13796ce7cd7dcd2631c443cec.tar.bz2 openwar-cec56db9d4c84de13796ce7cd7dcd2631c443cec.zip | |
Refactored argument parsing, and added stub for extractfunction.
Diffstat (limited to 'disasm/dumpobject.cpp')
| -rw-r--r-- | disasm/dumpobject.cpp | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/disasm/dumpobject.cpp b/disasm/dumpobject.cpp index 85fbf43..4f1a5cc 100644 --- a/disasm/dumpobject.cpp +++ b/disasm/dumpobject.cpp @@ -1,4 +1,5 @@ #include "dumpobject.hpp" +#include "parsefileandrewind.hpp" #include "le_file.hpp" @@ -6,28 +7,25 @@ #include <iomanip> -void dump_object(std::ifstream& ifs, uint32_t object_id) -{ - auto x = le::parse_file(ifs); - - ifs.clear(); - ifs.seekg(0, std::ios::beg); - +void dump_object(std::ifstream& ifs, binparse::Value32 object_id) +{ + auto file = parse_file_and_rewind(ifs); + std::vector<uint8_t> code(std::istreambuf_iterator<char>(ifs), {}); std::vector<_DecodedInst> instructions; instructions.resize(100000); unsigned int read_inst; - auto object = x.object_table.entries[object_id]; + auto object = file.object_table.entries[object_id]; auto index = object.page_table_index; - binparse::Offset32 offset = x.le_header.data_page_offset; + binparse::Offset32 offset = file.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, + code.data() + offset + (index - 1) * file.le_header.page_size, + file.object_table.entries[1].nr_page_table_entries * file.le_header.page_size, Decode32Bits, instructions.data(), instructions.size(), @@ -37,10 +35,6 @@ void dump_object(std::ifstream& ifs, uint32_t object_id) 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; } |
