about summary refs log tree commit diff stats
path: root/example/disasm/callback.py
diff options
context:
space:
mode:
authorCamille Mougey <commial@gmail.com>2019-03-07 14:37:07 +0100
committerGitHub <noreply@github.com>2019-03-07 14:37:07 +0100
commit4c2320b46250a8d6f8774e1218544b72a154cd8e (patch)
treeb67e7b072439f84109bd39dad8ed7f3f135224f8 /example/disasm/callback.py
parenteab809932871f91d6f4aa770fc321af9e156e0f5 (diff)
parent26c1075723a02984da6d3bc7423c5c0c43082dc3 (diff)
downloadmiasm-4c2320b46250a8d6f8774e1218544b72a154cd8e.tar.gz
miasm-4c2320b46250a8d6f8774e1218544b72a154cd8e.zip
Merge pull request #990 from serpilliere/support_python2_python3
Support python2 python3
Diffstat (limited to 'example/disasm/callback.py')
-rw-r--r--example/disasm/callback.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/example/disasm/callback.py b/example/disasm/callback.py
index 02416b38..7219462f 100644
--- a/example/disasm/callback.py
+++ b/example/disasm/callback.py
@@ -1,6 +1,7 @@
-from miasm2.analysis.binary import Container
-from miasm2.analysis.machine import Machine
-from miasm2.core.asmblock import AsmConstraint
+from __future__ import print_function
+from miasm.analysis.binary import Container
+from miasm.analysis.machine import Machine
+from miasm.core.asmblock import AsmConstraint
 
 
 def cb_x86_callpop(cur_bloc, loc_db, *args, **kwargs):
@@ -41,27 +42,28 @@ def cb_x86_callpop(cur_bloc, loc_db, *args, **kwargs):
 
 
 # Prepare a tiny shellcode
-shellcode = ''.join(["\xe8\x00\x00\x00\x00", # CALL $
-                     "X",                    # POP EAX
-                     "\xc3",                 # RET
-                     ])
+shellcode = (
+    b"\xe8\x00\x00\x00\x00" # CALL $
+    b"X"                    # POP EAX
+    b"\xc3"                 # RET
+)
 
 # Instantiate a x86 32 bit architecture
 machine = Machine("x86_32")
 cont = Container.from_string(shellcode)
 mdis = machine.dis_engine(cont.bin_stream, loc_db=cont.loc_db)
 
-print "Without callback:\n"
+print("Without callback:\n")
 asmcfg = mdis.dis_multiblock(0)
-print "\n".join(str(block) for block in asmcfg.blocks)
+print("\n".join(str(block) for block in asmcfg.blocks))
 
 # Enable callback
 mdis.dis_block_callback = cb_x86_callpop
 
-print "=" * 40
-print "With callback:\n"
+print("=" * 40)
+print("With callback:\n")
 asmcfg_after = mdis.dis_multiblock(0)
-print "\n".join(str(block) for block in asmcfg_after.blocks)
+print("\n".join(str(block) for block in asmcfg_after.blocks))
 
 # Ensure the callback has been called
 assert asmcfg.loc_key_to_block(asmcfg.heads()[0]).lines[0].name == "CALL"