class Metasm::WinAPI

Constants

SE_DEBUG_NAME

Public Class Methods

api_not_found(lib, func) click to toggle source
# File metasm/os/windows.rb, line 12
def self.api_not_found(lib, func)
        puts "could not find symbol #{func.name.inspect} in #{lib.inspect}" if $VERBOSE and not func.attributes.to_a.include?('optional')
end
convert_ret_c2rb(fproto, ret) click to toggle source

convert a native function return value if the native does not have the zero_not_fail attribute, convert 0

to nil, and print a message on stdout
Calls superclass method Metasm::DynLdr.convert_ret_c2rb
# File metasm/os/windows.rb, line 1184
def self.convert_ret_c2rb(fproto, ret)
        @last_err_msg = nil
        if ret == 0 and not fproto.has_attribute 'zero_not_fail'
                # save error msg so that last_error_msg returns the same thing if called again
                puts "WinAPI: error in #{fproto.name}: #{@last_err_msg = last_error_msg}" if $VERBOSE
                puts caller if $DEBUG
                nil
        else super(fproto, ret)
        end
end
last_error_msg(errno = nil) click to toggle source

retrieve the textual error message relative to GetLastError

# File metasm/os/windows.rb, line 1196
def self.last_error_msg(errno = nil)
        return @last_err_msg if @last_err_msg
        errno ||= getlasterror
        message = ' '*512
        if formatmessagea(FORMAT_MESSAGE_FROM_SYSTEM, nil, errno, 0, message, message.length, nil) == 0
                message = 'unknown error %x' % errno
        else
                message = message[0, message.index(\0)] if message.index(\0)
                message.chomp!
        end
        message
end