class Metasm::OS

this module regroups OS-related functions (eg. find_process, inject_shellcode) a 'class' just to be able to inherit from it…

Public Class Methods

create_process(path) click to toggle source

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
current() click to toggle source

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
find_process(name) click to toggle source

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]+)$/i)
        end
end
shortname() click to toggle source

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/i; 'winos'
        when /linux/i; 'linos'
        end
end