diff options
| author | Ajax <commial@gmail.com> | 2015-03-19 10:39:01 +0100 |
|---|---|---|
| committer | Ajax <commial@gmail.com> | 2015-03-19 10:39:01 +0100 |
| commit | b9dcf09ba85c8b49819e07dbbc273e41155a01c9 (patch) | |
| tree | 82b254f78f9074a6ad375f1006fd4584d6e015da /example/disasm/full.py | |
| parent | 1edede413369205dd86a3be0b19ad4863b4e1ffd (diff) | |
| download | miasm-b9dcf09ba85c8b49819e07dbbc273e41155a01c9.tar.gz miasm-b9dcf09ba85c8b49819e07dbbc273e41155a01c9.zip | |
DisasmFull: The architecture is now an optionnal argument, otherwise cont.arch is used
Diffstat (limited to 'example/disasm/full.py')
| -rw-r--r-- | example/disasm/full.py | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/example/disasm/full.py b/example/disasm/full.py index f15efe6e..9e953122 100644 --- a/example/disasm/full.py +++ b/example/disasm/full.py @@ -21,11 +21,11 @@ if filename and os.path.isfile(filename): parser = ArgumentParser("Disassemble a binary") -parser.add_argument('architecture', help="architecture: " + \ - ",".join(Machine.available_machine())) parser.add_argument('filename', help="File to disassemble") parser.add_argument('address', help="Starting address for disassembly engine", nargs="*") +parser.add_argument('-m', '--architecture', help="architecture: " + \ + ",".join(Machine.available_machine())) parser.add_argument('-f', "--followcall", action="store_true", help="Follow call instructions") parser.add_argument('-b', "--blockwatchdog", default=None, type=int, @@ -55,12 +55,6 @@ args = parser.parse_args() if args.verbose: log_asmbloc.setLevel(logging.DEBUG) -log.info("import machine...") -machine = Machine(args.architecture) -mn, dis_engine = machine.mn, machine.dis_engine -ira, ir = machine.ira, machine.ir -log.info('ok') - log.info('Load binary') with open(args.filename) as fdesc: cont = Container.from_stream(fdesc, addr=args.shiftoffset) @@ -68,8 +62,21 @@ with open(args.filename) as fdesc: default_addr = cont.entry_point bs = cont.bin_stream e = cont.executable +log.info('ok') +log.info("import machine...") +# Use the guessed architecture or the specified one +arch = args.architecture if args.architecture else cont.arch +if not arch: + print "Architecture recognition fail. Please specify it in arguments" + exit(-1) + +# Instance the arch-dependent machine +machine = Machine(arch) +mn, dis_engine = machine.mn, machine.dis_engine +ira, ir = machine.ira, machine.ir log.info('ok') + mdis = dis_engine(bs) # configure disasm engine mdis.dontdis_retcall = args.dontdis_retcall |