about summary refs log tree commit diff stats
path: root/miasm2/jitter/emulatedsymbexec.py
diff options
context:
space:
mode:
authorFabrice Desclaux <fabrice.desclaux@cea.fr>2019-02-25 11:09:54 +0100
committerFabrice Desclaux <fabrice.desclaux@cea.fr>2019-03-05 16:52:49 +0100
commit02bbb30efea4980c9d133947cbbf69fb599071ad (patch)
tree3fea6826fcc5354840a27cb1dc99ff31eef81896 /miasm2/jitter/emulatedsymbexec.py
parenteab809932871f91d6f4aa770fc321af9e156e0f5 (diff)
downloadmiasm-02bbb30efea4980c9d133947cbbf69fb599071ad.tar.gz
miasm-02bbb30efea4980c9d133947cbbf69fb599071ad.zip
Support python2/python3
Diffstat (limited to 'miasm2/jitter/emulatedsymbexec.py')
-rw-r--r--miasm2/jitter/emulatedsymbexec.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/miasm2/jitter/emulatedsymbexec.py b/miasm2/jitter/emulatedsymbexec.py
index 78c02fb1..3ccce522 100644
--- a/miasm2/jitter/emulatedsymbexec.py
+++ b/miasm2/jitter/emulatedsymbexec.py
@@ -1,3 +1,4 @@
+from miasm2.core.utils import decode_hex, encode_hex
 import miasm2.expression.expression as m2_expr
 from miasm2.ir.symbexec import SymbolicExecutionEngine
 
@@ -43,14 +44,16 @@ class EmulatedSymbExec(SymbolicExecutionEngine):
         if not addr.is_int():
             return super(EmulatedSymbExec, self).mem_read(expr_mem)
         addr = int(addr)
-        size = expr_mem.size / 8
+        size = expr_mem.size // 8
         value = self.cpu.get_mem(addr, size)
         if self.vm.is_little_endian():
             value = value[::-1]
         self.vm.add_mem_read(addr, size)
 
-        return m2_expr.ExprInt(int(value.encode("hex"), 16),
-                               expr_mem.size)
+        return m2_expr.ExprInt(
+            int(encode_hex(value), 16),
+            expr_mem.size
+        )
 
     def mem_write(self, dest, data):
         """Memory read wrapper for symbolic execution
@@ -65,10 +68,10 @@ class EmulatedSymbExec(SymbolicExecutionEngine):
 
         # Format information
         addr = dest.ptr.arg.arg
-        size = data.size / 8
+        size = data.size // 8
         content = hex(to_write).replace("0x", "").replace("L", "")
         content = "0" * (size * 2 - len(content)) + content
-        content = content.decode("hex")
+        content = decode_hex(content)
 
         if self.vm.is_little_endian():
             content = content[::-1]