def disasm(ctx): ctx.gph, pe_nb_new_syms = ctx.dis.get_graph(ctx.entry_addr) if ctx.gph == None: error("capstone can't disassemble here") return None ctx.gph.simplify() if ctx.db.loaded and pe_nb_new_syms: ctx.db.modified = True try: ctx.gph.loop_detection(ctx, ctx.entry_addr) ast, correctly_ended = generate_ast(ctx) if not correctly_ended: debug__("Second try...") ctx.gph.loop_detection(ctx, ctx.entry_addr, True) ast, _ = generate_ast(ctx) except ExcIfelse as e: error("can't have a ifelse here %x" % e.addr) if ctx.interactive_mode: return None die() if ctx.graph: ctx.gph.dot_graph(ctx.dis.jmptables) if ctx.vim: base = os.path.basename(ctx.filename) + "_" + ctx.entry # re-assign if no colors ctx.libarch.process_ast.assign_colors(ctx, ast) ctx.color = False generate_vim_syntax(ctx, base + ".vim") sys.stdout = open(base + ".rev", "w+") o = ctx.libarch.output.Output(ctx) o._ast(ctx.entry_addr, ast) if ctx.vim: print("Run : vim {0}.rev -S {0}.vim".format(base), file=sys.stderr) return o
sys.exit(0) ctx = gctx.get_addr_context(gctx.entry) if ctx is None: sys.exit(0) if gctx.do_dump: ctx.dump_asm(gctx.nb_lines).print() sys.exit(0) o = ctx.decompile() if gctx.graph: ctx.gph.dot_graph(gctx.dis.jmptables) if o is not None: if gctx.vim: base = os.path.basename(gctx.filename) + "_" + gctx.entry # re-assign if no colors gctx.libarch.process_ast.assign_colors(ctx, ctx.ast) gctx.color = False generate_vim_syntax(ctx, base + ".vim") sys.stdout = open(base + ".rev", "w+") o.print() if gctx.vim: print("run : vim {0}.rev -S {0}.vim".format(base), file=sys.stderr)
gctx.dis.print_symbols(gctx.sectionsname) sys.exit(0) ctx = gctx.get_addr_context(gctx.entry) if ctx is None: sys.exit(0) if gctx.do_dump: ctx.dump_asm(gctx.nb_lines).print() sys.exit(0) o = ctx.decompile() if gctx.graph: ctx.gph.dot_graph(gctx.dis.jmptables) if o is not None: if gctx.vim: base = os.path.basename(gctx.filename) + "_" + gctx.entry # re-assign if no colors gctx.libarch.process_ast.assign_colors(ctx, ctx.ast) gctx.color = False generate_vim_syntax(ctx, base + ".vim") sys.stdout = open(base + ".rev", "w+") o.print() if gctx.vim: print("run : vim {0}.rev -S {0}.vim".format(base), file=sys.stderr)