about summary refs log tree commit diff stats
path: root/example/disasm/callback.py
diff options
context:
space:
mode:
authorFabrice Desclaux <fabrice.desclaux@cea.fr>2018-12-07 22:44:44 +0100
committerFabrice Desclaux <fabrice.desclaux@cea.fr>2018-12-10 11:10:45 +0100
commit5e620f04a458a7ff3fb72673f887c9423a40c1aa (patch)
tree2dd12a15c7f3a038471e566d4a971b5934084a17 /example/disasm/callback.py
parentcc722f808ec76a3edeb6503d3a8ada975ef0a3d5 (diff)
downloadmiasm-5e620f04a458a7ff3fb72673f887c9423a40c1aa.tar.gz
miasm-5e620f04a458a7ff3fb72673f887c9423a40c1aa.zip
Updt example api
Diffstat (limited to 'example/disasm/callback.py')
-rw-r--r--example/disasm/callback.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/example/disasm/callback.py b/example/disasm/callback.py
index b9a09c09..02416b38 100644
--- a/example/disasm/callback.py
+++ b/example/disasm/callback.py
@@ -1,6 +1,6 @@
-from miasm2.core.bin_stream import bin_stream_str
+from miasm2.analysis.binary import Container
+from miasm2.analysis.machine import Machine
 from miasm2.core.asmblock import AsmConstraint
-from miasm2.arch.x86.disasm import dis_x86_32, cb_x86_funcs
 
 
 def cb_x86_callpop(cur_bloc, loc_db, *args, **kwargs):
@@ -45,17 +45,18 @@ shellcode = ''.join(["\xe8\x00\x00\x00\x00", # CALL $
                      "X",                    # POP EAX
                      "\xc3",                 # RET
                      ])
-bin_stream = bin_stream_str(shellcode)
-mdis = dis_x86_32(bin_stream)
+
+# 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"
 asmcfg = mdis.dis_multiblock(0)
 print "\n".join(str(block) for block in asmcfg.blocks)
 
 # Enable callback
-cb_x86_funcs.append(cb_x86_callpop)
-## Other method:
-## mdis.dis_block_callback = cb_x86_callpop
+mdis.dis_block_callback = cb_x86_callpop
 
 print "=" * 40
 print "With callback:\n"