about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorserpilliere <serpilliere@users.noreply.github.com>2017-02-02 16:41:41 +0100
committerGitHub <noreply@github.com>2017-02-02 16:41:41 +0100
commitbb96e18db435760fca4ff80f012f69e656e0c699 (patch)
treeb6445fdf7497563ec4ffb78f1268d3a2d62731a2
parent54f81c62f9b02ff9af843f2d40753efc19297228 (diff)
parentcfe41ee07e36302666d327908567d125e833f7e0 (diff)
downloadmiasm-bb96e18db435760fca4ff80f012f69e656e0c699.tar.gz
miasm-bb96e18db435760fca4ff80f012f69e656e0c699.zip
Merge pull request #485 from commial/feature/pytthon-cpuid
Add support for 'cpuid' in Emulatedsymbexec
Diffstat (limited to '')
-rw-r--r--miasm2/jitter/emulatedsymbexec.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/miasm2/jitter/emulatedsymbexec.py b/miasm2/jitter/emulatedsymbexec.py
index 6a0882ba..ff9e5eaa 100644
--- a/miasm2/jitter/emulatedsymbexec.py
+++ b/miasm2/jitter/emulatedsymbexec.py
@@ -5,6 +5,21 @@ from miasm2.ir.symbexec import symbexec
 class EmulatedSymbExec(symbexec):
     """Symbolic exec instance linked with a jitter"""
 
+    cpuid = {
+        0: {
+            0: 0xa,
+            1: 0x756E6547,
+            2: 0x6C65746E,
+            3: 0x49656E69,
+        },
+        1: {
+            0: 0x00020652,
+            1: 0x00000800,
+            2: 0x00000209,
+            3: 0x078bf9ff
+        },
+    }
+
     def __init__(self, cpu, vm, *args, **kwargs):
         """Instanciate an EmulatedSymbExec, associated to CPU @cpu and bind
         memory accesses.
@@ -96,10 +111,20 @@ class EmulatedSymbExec(symbexec):
                                   m2_expr.ExprInt(segmaddr, expr.size),
                                   expr.args[1]))
 
+    def _simp_handle_cpuid(self, e_s, expr):
+        """From miasm2/jitter/vm_mngr.h: cpuid"""
+        if expr.op != "cpuid":
+            return expr
+
+        a, reg_num = (int(x) for x in expr.args)
+
+        # Not found error is keeped on purpose
+        return m2_expr.ExprInt(self.cpuid[a][reg_num], expr.size)
+
     def enable_emulated_simplifications(self):
         """Enable simplifications needing a CPU instance on associated
         ExpressionSimplifier
         """
         self.expr_simp.enable_passes({
-            m2_expr.ExprOp: [self._simp_handle_segm]
+            m2_expr.ExprOp: [self._simp_handle_segm, self._simp_handle_cpuid],
         })