diff options
| author | serpilliere <devnull@localhost> | 2014-06-03 10:27:56 +0200 |
|---|---|---|
| committer | serpilliere <devnull@localhost> | 2014-06-03 10:27:56 +0200 |
| commit | ed5c3668cc9f545b52674ad699fc2b0ed1ccb575 (patch) | |
| tree | 07faf97d7e4d083173a1f7e1bfd249baed2d74f9 /miasm2/arch/x86/disasm.py | |
| parent | a183e1ebd525453710306695daa8c410fd0cb2af (diff) | |
| download | miasm-ed5c3668cc9f545b52674ad699fc2b0ed1ccb575.tar.gz miasm-ed5c3668cc9f545b52674ad699fc2b0ed1ccb575.zip | |
Miasm v2
* API has changed, so old scripts need updates * See example for API usage * Use tcc or llvm for jit emulation * Go to test and run test_all.py to check install Enjoy !
Diffstat (limited to 'miasm2/arch/x86/disasm.py')
| -rw-r--r-- | miasm2/arch/x86/disasm.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/miasm2/arch/x86/disasm.py b/miasm2/arch/x86/disasm.py new file mode 100644 index 00000000..7185a973 --- /dev/null +++ b/miasm2/arch/x86/disasm.py @@ -0,0 +1,51 @@ +from miasm2.core.asmbloc import asm_constraint, asm_label, disasmEngine +from miasm2.expression.expression import ExprId +from arch import mn_x86 + + +def cb_x86_callpop(mn, attrib, pool_bin, cur_bloc, offsets_to_dis, symbol_pool): + """ + 1000: call 1005 + 1005: pop + """ + if len(cur_bloc.lines) < 1: + return + l = cur_bloc.lines[-1] + if l.name != 'CALL': + return + dst = l.args[0] + if not (isinstance(dst, ExprId) and isinstance(dst.name, asm_label)): + return + if dst.name.offset != l.offset + l.l: + return + l.name = 'PUSH' + # cur_bloc.bto.pop() + cur_bloc.bto[0].c_bto = asm_constraint.c_next + + +cb_x86_funcs = [cb_x86_callpop] + + +def cb_x86_disasm(mn, attrib, pool_bin, cur_bloc, offsets_to_dis, symbol_pool): + for func in cb_x86_funcs: + func(mn, attrib, pool_bin, cur_bloc, offsets_to_dis, symbol_pool) + + +class dis_x86(disasmEngine): + attrib = None + + def __init__(self, bs=None, **kwargs): + super(dis_x86, self).__init__(mn_x86, self.attrib, bs, **kwargs) + self.dis_bloc_callback = cb_x86_disasm + + +class dis_x86_16(dis_x86): + attrib = 16 + + +class dis_x86_32(dis_x86): + attrib = 32 + + +class dis_x86_64(dis_x86): + attrib = 64 |