this module regroups OS-related functions (eg. ::find_process, inject_shellcode) a 'class' just to be able to inherit from it…
create a new debuggee process stopped at start
# File metasm/os/main.rb, line 46 def self.create_process(path) dbg = create_debugger(path) pr = open_process(dbg.pid) pr.debugger = dbg pr.memory = dbg.memory pr end
return the platform-specific version
# File metasm/os/main.rb, line 63 def self.current case shortname when 'winos'; WinOS when 'linos'; LinOS end end
returns the Process whose pid is name (if name is an Integer) or first module path includes name (string)
# File metasm/os/main.rb, line 34 def self.find_process(name) case name when nil when Integer list_processes.find { |pr| pr.pid == name } else list_processes.find { |pr| pr.path.to_s.include? name.to_s } or (find_process(Integer(name)) if name =~ /^(0x[0-9a-f]+|[0-9]+)$/) end end
return 'winos' or 'linos' depending on the underlying OS
# File metasm/os/main.rb, line 55 def self.shortname case RUBY_PLATFORM when /mswin|mingw|cygwin/; 'winos' when /linux/; 'linos' end end