samples/disassemble-gui.rb in metasm-1.0.3 vs samples/disassemble-gui.rb in metasm-1.0.4
- old
+ new
@@ -49,10 +49,11 @@
opt.on('-v', '--verbose') { $VERBOSE = true } # default
opt.on('-q', '--no-verbose') { $VERBOSE = false }
opt.on('-d', '--debug') { $DEBUG = $VERBOSE = true }
opt.on('-S <file>', '--session <sessionfile>', 'save user actions in this session file') { |a| opts[:session] = a }
opt.on('-N', '--new-session', 'start new session, discard old one') { opts[:newsession] = true }
+ opt.on('-A', '--disassemble-all-entrypoints') { opts[:dasm_all] = true }
}.parse!(ARGV)
case exename = ARGV.shift
when /^live:(.*)/
t = $1
@@ -81,20 +82,20 @@
end
end
end
ep = ARGV.map { |arg| (?0..?9).include?(arg[0]) ? Integer(arg) : arg }
+ep += exe.get_default_entrypoints if opts[:dasm_all]
if exe
dasm = exe.disassembler
dasm.load_map opts[:map] if opts[:map]
dasm.parse_c_file opts[:cheader] if opts[:cheader]
dasm.backtrace_maxblocks_data = -1 if opts[:nodatatrace]
dasm.debug_backtrace = true if opts[:debugbacktrace]
- dasm.callback_finished = lambda { w.dasm_widget.focus_addr w.dasm_widget.curaddr, :decompile ; dasm.decompiler.finalize } if opts[:decompile]
- dasm.disassemble_fast_deep(*ep) if opts[:fast]
+ dasm.callback_finished = lambda { dasm.callback_finished = nil ; w.dasm_widget.focus_addr w.dasm_widget.curaddr, :decompile ; dasm.decompiler.finalize } if opts[:decompile]
elsif dbg
dbg.load_map opts[:map] if opts[:map]
dbg.disassembler.parse_c_file opts[:cheader] if opts[:cheader]
opts[:plugin].to_a.each { |p|
begin
@@ -102,19 +103,28 @@
rescue ::Exception
puts "Error with plugin #{p}: #{$!.class} #{$!}"
end
}
end
+
if dasm
- w.display(dasm, ep)
+ w.display(dasm)
+ w.dasm_widget.focus_addr(ep.first) if not ep.empty?
opts[:plugin].to_a.each { |p|
begin
dasm.load_plugin(p)
rescue ::Exception
puts "Error with plugin #{p}: #{$!.class} #{$!}"
end
}
+ ep.each { |eep|
+ if opts[:fast]
+ w.dasm_widget.disassemble_fast_deep(eep)
+ else
+ w.dasm_widget.disassemble(eep)
+ end
+ }
if opts[:session]
if File.exist?(opts[:session])
if opts[:newsession]
File.unlink(opts[:session])
@@ -128,5 +138,6 @@
end
opts[:hookstr].to_a.each { |f| eval f }
Metasm::Gui.main
+