Module: SecureRandom::Kernel32

Extended by:
Fiddle::Importer
Defined in:
lib/securerandom.rb

Overview

:nodoc:

Class Method Summary collapse

Class Method Details

.last_error_messageObject

Following code is based on David Garamond’s GUID library for Ruby.



82
83
84
85
86
87
88
89
90
# File 'lib/securerandom.rb', line 82

def self.last_error_message
  format_message_ignore_inserts = 0x00000200
  format_message_from_system    = 0x00001000

  code = GetLastError()
  msg = "\0" * 1024
  len = FormatMessageA(format_message_ignore_inserts + format_message_from_system, 0, code, 0, msg, 1024, nil)
  msg[0, len].force_encoding("filesystem").tr("\r", '').chomp
end