class Facter::Resolvers::System32

Private Class Methods

construct_path(bool_ptr, windows) click to toggle source
# File lib/facter/resolvers/windows/system32.rb, line 38
def construct_path(bool_ptr, windows)
  if bool_ptr.read_win32_bool
    "#{windows}\\sysnative"
  else
    "#{windows}\\system32"
  end
end
post_resolve(fact_name, _options) click to toggle source
# File lib/facter/resolvers/windows/system32.rb, line 13
def post_resolve(fact_name, _options)
  @fact_list.fetch(fact_name) { retrieve_windows_binaries_path }
end
retrieve_windows_binaries_path() click to toggle source
# File lib/facter/resolvers/windows/system32.rb, line 17
def retrieve_windows_binaries_path
  require_relative '../../../facter/resolvers/windows/ffi/system32_ffi'

  windows_path = ENV['SystemRoot']

  if !windows_path || windows_path.empty?
    @log.debug 'Unable to find correct value for SystemRoot enviroment variable'
    return nil
  end

  bool_ptr = FFI::MemoryPointer.new(:win32_bool, 1)
  if System32FFI::IsWow64Process(System32FFI::GetCurrentProcess(), bool_ptr) == FFI::WIN32FALSE
    @log.debug 'IsWow64Process failed'
    return
  end

  @fact_list[:system32] = construct_path(bool_ptr, windows_path)
rescue LoadError => e
  @log.debug("Could not retrieve: #{e}")
end