about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAjax <commial@gmail.com>2016-06-29 08:24:29 +0200
committerAjax <commial@gmail.com>2016-09-01 17:34:50 +0200
commit48e3279683c16cb00d7c006b4716781a44d39798 (patch)
treeb846b261d63a428b5a48a0bf1d427b8c4abc6649
parent64e7bdcc046f4b5584443e01accd2206a73bf176 (diff)
downloadmiasm-48e3279683c16cb00d7c006b4716781a44d39798.tar.gz
miasm-48e3279683c16cb00d7c006b4716781a44d39798.zip
Handle CPU exception in Jitcore Python
This patch may affect performance, but this jitter is already
slow (compared to others) and without it, the emulation is not correct
-rw-r--r--miasm2/jitter/csts.py1
-rw-r--r--miasm2/jitter/jitcore_python.py13
2 files changed, 8 insertions, 6 deletions
diff --git a/miasm2/jitter/csts.py b/miasm2/jitter/csts.py
index 7af2435f..95cd34a8 100644
--- a/miasm2/jitter/csts.py
+++ b/miasm2/jitter/csts.py
@@ -4,6 +4,7 @@
 
 # VM Mngr Exceptions
 EXCEPT_DO_NOT_UPDATE_PC = 1 << 25
+EXCEPT_NUM_UPDT_EIP = (1<<11)
 
 EXCEPT_CODE_AUTOMOD = (1 << 0)
 EXCEPT_SOFT_BP = (1 << 1)
diff --git a/miasm2/jitter/jitcore_python.py b/miasm2/jitter/jitcore_python.py
index 70131157..87259f71 100644
--- a/miasm2/jitter/jitcore_python.py
+++ b/miasm2/jitter/jitcore_python.py
@@ -91,17 +91,18 @@ class JitCore_Python(jitcore.JitCore):
                         if self.log_mn:
                             print "%08x %s" % (line.offset, line)
 
-                        # Check for memory exception
-                        if (vmmngr.get_exception() != 0):
+                        # Check for exception
+                        if (vmmngr.get_exception() != 0 or
+                            cpu.get_exception() != 0):
                             exec_engine.update_cpu_from_engine()
                             return line.offset
 
                     # Eval current instruction (in IR)
                     exec_engine.eval_ir(ir)
-
-                    # Check for memory exception which do not update PC
-                    if (vmmngr.get_exception() & csts.EXCEPT_DO_NOT_UPDATE_PC != 0):
-                        exec_engine.update_cpu_from_engine()
+                    # Check for exceptions which do not update PC
+                    exec_engine.update_cpu_from_engine()
+                    if (vmmngr.get_exception() & csts.EXCEPT_DO_NOT_UPDATE_PC != 0 or
+                        cpu.get_exception() > csts.EXCEPT_NUM_UPDT_EIP):
                         return line.offset
 
                 vmmngr.check_invalid_code_blocs()