diff options
| author | serpilliere <serpilliere@users.noreply.github.com> | 2015-01-26 10:04:24 +0100 |
|---|---|---|
| committer | serpilliere <serpilliere@users.noreply.github.com> | 2015-01-26 10:04:24 +0100 |
| commit | b87f775c1a6a5c78c62beee925eaba6dc337577e (patch) | |
| tree | cf2650f575971bf8a23655a28c944e9e8a9da561 /example/symbol_exec/single_instr.py | |
| parent | c59591a779ac644d1b50a720aea93cd8b36a2ddf (diff) | |
| parent | 7b9bbe4754db4d1f5229cc5cc5769ad6cf2e0a84 (diff) | |
| download | miasm-b87f775c1a6a5c78c62beee925eaba6dc337577e.tar.gz miasm-b87f775c1a6a5c78c62beee925eaba6dc337577e.zip | |
Merge pull request #45 from commial/refactor-examples
Refactor examples
Diffstat (limited to 'example/symbol_exec/single_instr.py')
| -rw-r--r-- | example/symbol_exec/single_instr.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/example/symbol_exec/single_instr.py b/example/symbol_exec/single_instr.py new file mode 100644 index 00000000..416909f2 --- /dev/null +++ b/example/symbol_exec/single_instr.py @@ -0,0 +1,31 @@ +# Minimalist Symbol Exec example +from miasm2.core.bin_stream import bin_stream_str +from miasm2.arch.x86.arch import mn_x86 +from miasm2.arch.x86.ira import ir_a_x86_32 +from miasm2.arch.x86.regs import all_regs_ids, all_regs_ids_init +from miasm2.ir.symbexec import symbexec +from miasm2.arch.x86.disasm import dis_x86_32 as dis_engine +import miasm2.expression.expression as m2_expr + +l = mn_x86.fromstring("MOV EAX, EBX", 32) +asm = mn_x86.asm(l)[0] + +bin_stream = bin_stream_str(asm) + +mdis = dis_engine(bin_stream) +disasm = mdis.dis_multibloc(0) + +ir = ir_a_x86_32(mdis.symbol_pool) +for bbl in disasm: ir.add_bloc(bbl) + +symbols_init = {} +for i, r in enumerate(all_regs_ids): + symbols_init[r] = all_regs_ids_init[i] +symb = symbexec(ir, symbols_init) + +block = ir.get_bloc(0) + +cur_addr = symb.emulbloc(block) +assert(symb.symbols[m2_expr.ExprId("EAX")] == symbols_init[m2_expr.ExprId("EBX")]) +print 'modified registers:' +symb.dump_id() |