summaryrefslogtreecommitdiff
path: root/emulate
diff options
context:
space:
mode:
Diffstat (limited to 'emulate')
-rw-r--r--emulate/emulator.hpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/emulate/emulator.hpp b/emulate/emulator.hpp
index 69c2f46..1d26f99 100644
--- a/emulate/emulator.hpp
+++ b/emulate/emulator.hpp
@@ -293,6 +293,18 @@ public:
interrupt_handlers.at(boost::apply_visitor(return_visitor(), imm))();
}
+ void handle_I_JNZ(_DInst inst) {
+ if(!cpu.zf()) {
+ if(inst.ops[0].type == O_PC || inst.ops[0].type == O_PTR || inst.ops[0].type == O_DISP) {
+ cpu.eip() = INSTRUCTION_GET_TARGET(&inst);
+ } else if (inst.ops[0].type == O_SMEM) {
+ throw UnhandledInstruction();
+ } else {
+ throw UnrecognizedInstruction();
+ }
+ }
+ }
+
void int_0x21() {
if(cpu.ah() == 0x30) {
cpu.al() = 6;
@@ -319,6 +331,7 @@ public:
REGISTER_HANDLER(I_INT);
REGISTER_HANDLER(I_SHR);
REGISTER_HANDLER(I_CMP);
+ REGISTER_HANDLER(I_JNZ);
#undef REGISTER_HANDLER
@@ -392,12 +405,14 @@ void emulate(std::string file_path) {
_DInst decinst;
distorm_decompose(&ci, &decinst, 1, &decodedInstructionsCount);
- emulator.cpu.eip() += decinst.size;
-
_DecodedInst inst;
distorm_format64(&ci, &decinst, &inst);
- std::cout << "CurrentInstruction: " << std::hex << std::setw(8) << std::setfill('0') << inst.offset << ":\t" << inst.mnemonic.p << " " << inst.operands.p << std::endl;
+
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 << std::endl << std::endl;
+
+ emulator.cpu.eip() += decinst.size;
emulator.handle_instruction(decinst);
}