class FFI::Pointer

Public Instance Methods

read_wide_string_with_length(char_length) click to toggle source
# File lib/facter/resolvers/windows/ffi/ffi.rb, line 29
def read_wide_string_with_length(char_length)
  # char_length is number of wide chars (typically excluding NULLs), *not* bytes
  str = get_bytes(0, char_length * 2).force_encoding('UTF-16LE')
  str.encode('UTF-8', str.encoding)
end
read_wide_string_without_length() click to toggle source
# File lib/facter/resolvers/windows/ffi/ffi.rb, line 35
def read_wide_string_without_length
  wide_character = get_bytes(0, 2)
  i = 2
  str = []

  while wide_character.encode('UTF-16LE') != END_OF_WCHAR_STRING
    str << wide_character
    wide_character = get_bytes(i, 2)
    i += 2
  end
  str.join.force_encoding('UTF-16LE').encode('UTF-8')
end
read_win32_bool() click to toggle source
# File lib/facter/resolvers/windows/ffi/ffi.rb, line 48
def read_win32_bool
  # BOOL is always a 32-bit integer in Win32
  # some Win32 APIs return 1 for true, while others are non-0
  read_int32 != WIN32FALSE
end