From 01e7e033e6254f141e44c4e3fc5fe8fc9d0b0c59 Mon Sep 17 00:00:00 2001 From: Dennis Brentjes Date: Sat, 16 Jun 2018 19:26:39 +0200 Subject: Adds some more output to a emulation run. --- emulate/emulator.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'emulate/emulator.cpp') diff --git a/emulate/emulator.cpp b/emulate/emulator.cpp index 2e30fd8..669684f 100644 --- a/emulate/emulator.cpp +++ b/emulate/emulator.cpp @@ -1,6 +1,8 @@ #include "emulator.hpp" +#include + template <> struct SignedCounterpart { typedef int32_t type; @@ -417,8 +419,13 @@ void emulate(std::string file_path) { emulator.set_data_segment(file.object_table.entries.at(2).reloc_base_address); unsigned int decodedInstructionsCount; + unsigned int emulated_instructions = 0; bool run = true; + + boost::timer::cpu_timer timer; + timer.start(); + while(run) { ci.code = binary.data() + emulator.cpu.eip(); ci.nextOffset = emulator.cpu.eip(); @@ -428,17 +435,21 @@ void emulate(std::string file_path) { ci.features = DF_NONE; _DInst decinst; - distorm_decompose(&ci, &decinst, 1, &decodedInstructionsCount); + distorm_decompose(&ci, &decinst, 1, &decodedInstructionsCount); _DecodedInst inst; distorm_format64(&ci, &decinst, &inst); std::cout << emulator.cpu << std::endl; - std::cout << "CurrentInstruction: " << std::hex << std::setw(8) << std::setfill('0') << inst.offset << ":\t" << inst.mnemonic.p << " " << inst.operands.p << std::endl; + std::cout << "CurrentInstruction: " << std::hex << std::setw(8) << std::setfill('0') << inst.offset << ":\t" << inst.mnemonic.p << " " << inst.operands.p << std::dec << std::endl; std::cout << std::endl << std::endl; emulator.cpu.eip() += decinst.size; run = emulator.handle_instruction(decinst); + emulated_instructions++; } + + timer.stop(); + std::cout << "Serviced: " << emulated_instructions << " Instructions in: " << timer.elapsed().user << "ns" << std::endl; } -- cgit v1.2.3-70-g09d2