Class: Metasm::WinAPI
Constant Summary collapse
- SE_DEBUG_NAME =
'SeDebugPrivilege'
Constants inherited from DynLdr
DynLdr::DYNLDR_ASM_IA32, DynLdr::DYNLDR_ASM_X86_64, DynLdr::DYNLDR_C, DynLdr::DYNLDR_C_PE_HACK, DynLdr::RUBY_H
Class Method Summary collapse
- .api_not_found(lib, func) ⇒ Object
-
.convert_ret_c2rb(fproto, ret) ⇒ Object
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.
-
.last_error_msg(errno = nil) ⇒ Object
retrieve the textual error message relative to GetLastError.
Methods inherited from DynLdr
alloc_c_ary, alloc_c_ptr, alloc_c_struct, c_const_name_to_rb, c_func_name_to_rb, callback_alloc_c, callback_alloc_cobj, callback_find_id, callback_free, callback_run, compile_binary_module, compile_binary_module_hack, compile_c, const_missing, convert_c2rb, convert_cbargs_c2rb, convert_rb2c, cp, cp=, decode_c_ary, decode_c_struct, decode_c_value, encode_c_value, find_bin_path, find_write_dir, host_arch, host_cpu, host_exe, lib_from_sym, memory_read_strz, memory_read_wstrz, new_api_c, new_caller_for, new_func_asm, new_func_c, parse_c, start, trace_invoke
Class Method Details
.api_not_found(lib, func) ⇒ Object
11 12 13 |
# File 'lib/metasm/os/windows.rb', line 11 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) ⇒ Object
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
1173 1174 1175 1176 1177 1178 1179 1180 1181 |
# File 'lib/metasm/os/windows.rb', line 1173 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 nil else super(fproto, ret) end end |
.last_error_msg(errno = nil) ⇒ Object
retrieve the textual error message relative to GetLastError
1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 |
# File 'lib/metasm/os/windows.rb', line 1184 def self.last_error_msg(errno = nil) return @last_err_msg if @last_err_msg errno ||= getlasterror = ' '*512 if (FORMAT_MESSAGE_FROM_SYSTEM, nil, errno, 0, , .length, nil) == 0 = 'unknown error %x' % errno else = [0, .index(?\0)] if .index(?\0) .chomp! end end |