From 192120822e63f7aef18bd8bd4542b315e29565b4 Mon Sep 17 00:00:00 2001 From: ajax Date: Mon, 16 Jun 2014 19:08:20 +0200 Subject: Jitter Python: check all memory exceptions only on new instruction (in assembly) --- miasm2/jitter/jitcore_python.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'miasm2/jitter/jitcore_python.py') diff --git a/miasm2/jitter/jitcore_python.py b/miasm2/jitter/jitcore_python.py index 7dc0b710..90c8bace 100644 --- a/miasm2/jitter/jitcore_python.py +++ b/miasm2/jitter/jitcore_python.py @@ -114,6 +114,9 @@ class JitCore_Python(jitcore.JitCore): cur_label = label loop = True + # Required to detect new instructions + offsets_jitted = set() + # Get exec engine exec_engine = self.symbexec @@ -135,12 +138,17 @@ class JitCore_Python(jitcore.JitCore): # Execute current ir bloc for ir, line in zip(irb.irs, irb.lines): - # Check for memory exception - if (vmmngr.vm_get_exception() != 0): - update_cpu_from_engine(cpu, exec_engine) - return line.offset - # Eval current instruction + # For each new instruction (in assembly) + if line.offset not in offsets_jitted: + offsets_jitted.add(line.offset) + + # Check for memory exception + if (vmmngr.vm_get_exception() != 0): + update_cpu_from_engine(cpu, exec_engine) + return line.offset + + # Eval current instruction (in IR) exec_engine.eval_ir(ir) # Check for memory exception which do not update PC -- cgit 1.4.1