class Metasm::Gui::DasmWindow
Attributes
dasm_widget[RW]
Public Instance Methods
destroy_window()
click to toggle source
Calls superclass method
# File metasm/gui/dasm_main.rb, line 903 def destroy_window @dasm_widget.terminate if @dasm_widget super() end
display(dasm, ep=[])
click to toggle source
sets up a DisasmWidget as main widget of the window, replaces the current if it exists returns the widget
# File metasm/gui/dasm_main.rb, line 910 def display(dasm, ep=[]) @dasm_widget.terminate if @dasm_widget ep = [ep] if not ep.kind_of? Array @dasm_widget = DisasmWidget.new(dasm, ep) self.widget = @dasm_widget @dasm_widget.focus_addr(ep.first) if ep.first @dasm_widget end
initialize_window(title = 'metasm disassembler', dasm=nil, *ep)
click to toggle source
# File metasm/gui/dasm_main.rb, line 888 def initialize_window(title = 'metasm disassembler', dasm=nil, *ep) self.title = title @dasm_widget = nil if dasm ep = ep.first if ep.length == 1 and ep.first.kind_of? Array display(dasm, ep) else self.widget = NoDasmWidget.new(self) end end
loadfile(path, cpu='Ia32', exefmt=nil)
click to toggle source
# File metasm/gui/dasm_main.rb, line 924 def loadfile(path, cpu='Ia32', exefmt=nil) if exefmt exefmt = Metasm.const_get(exefmt) if exefmt.kind_of? String if exefmt.kind_of?(::Class) and exefmt.name.split('::').last == 'Shellcode' exefmt = Shellcode.withcpu(cpu) end else exefmt = AutoExe.orshellcode { cpu = Metasm.const_get(cpu) if cpu.kind_of? String ; cpu = cpu.new if cpu.kind_of?(::Class) ; cpu } end exe = exefmt.decode_file(path) { |type, str| # Disassembler save file will use this callback with unhandled sections / invalid binary file path case type when 'binarypath' ret = nil openfile("please locate #{str}", :blocking => true) { |f| ret = f } return if not ret ret end } (@dasm_widget ? DasmWindow.new : self).display(exe.disassembler) self.title = "#{File.basename(path)} - metasm disassembler" exe end
promptdebug(caption='chose target', &b)
click to toggle source
# File metasm/gui/dasm_main.rb, line 953 def promptdebug(caption='chose target', &b) l = nil i = inputbox(caption) { |name| i = nil ; l.destroy if l and not l.destroyed? if pr = OS.current.find_process(name) target = pr.debugger elsif name =~ /^(udp|tcp|.*\d+.*):/i # don't match c:\kikoo, but allow 127.0.0.1 / [1:2::3] target = GdbRemoteDebugger.new(name) elsif pr = OS.current.create_process(name) target = pr.debugger else messagebox('no such target') next end DbgWindow.new(target) destroy if not @dasm_widget b.call(self) if b } # build process list in bg (exe name resolution takes a few seconds) list = [['pid', 'name']] list_pr = OS.current.list_processes Gui.idle_add { if pr = list_pr.shift list << [pr.pid, pr.path] if pr.path true elsif i me = ::Process.pid.to_s l = listwindow('running processes', list, :noshow => true, :color_callback => lambda { |le| [:grey, :palegrey] if le[0] == me } ) { |e| i.text = e[0] } l.x += l.width l.show false end } if not list_pr.empty? end
promptopen(caption='chose target binary', &b)
click to toggle source
# File metasm/gui/dasm_main.rb, line 949 def promptopen(caption='chose target binary', &b) openfile(caption) { |exename| loadfile(exename) ; b.call(self) if b } end
promptruby()
click to toggle source
# File metasm/gui/dasm_main.rb, line 1011 def promptruby if @dasm_widget @dasm_widget.prompt_run_ruby else inputbox('code to eval') { |c| messagebox eval(c).inspect[0, 512], 'eval' } end end
promptsave()
click to toggle source
reuse last @savefile to save dasm, prompt for file if undefined
# File metasm/gui/dasm_main.rb, line 993 def promptsave return if not @dasm_widget if @savefile ||= nil @dasm_widget.dasm.save_file @savefile return end openfile('chose save file') { |file| @savefile = file @dasm_widget.dasm.save_file(file) } end
promptsaveas()
click to toggle source
same as promptsave, but always prompt
# File metasm/gui/dasm_main.rb, line 1006 def promptsaveas @savefile = nil promptsave end
widget(idx=nil)
click to toggle source
returns the specified widget from the @dasm_widget (idx in :hex, :listing, :graph etc)
# File metasm/gui/dasm_main.rb, line 920 def widget(idx=nil) idx && @dasm_widget ? @dasm_widget.view(idx) : @dasm_widget end
widget=(w)
click to toggle source
Calls superclass method
# File metasm/gui/dasm_main.rb, line 899 def widget=(w) super(w || NoDasmWidget.new(self)) end