Sha256: 91028ea1022e96bf0b5689f625e318baa9e75ec4199fd911ae958cc407959c44

Contents?: true

Size: 1.21 KB

Versions: 21

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

module Facter
  module Resolvers
    class System32 < BaseResolver
      @log = Facter::Log.new(self)
      @semaphore = Mutex.new
      @fact_list ||= {}
      class << self
        private

        def post_resolve(fact_name)
          @fact_list.fetch(fact_name) { retrieve_windows_binaries_path }
        end

        def retrieve_windows_binaries_path
          require "#{ROOT_DIR}/lib/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)
        end

        def construct_path(bool_ptr, windows)
          if bool_ptr.read_win32_bool
            "#{windows}\\sysnative"
          else
            "#{windows}\\system32"
          end
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
facter-4.0.29 lib/resolvers/windows/system32_resolver.rb
facter-4.0.28 lib/resolvers/windows/system32_resolver.rb
facter-4.0.26 lib/resolvers/windows/system32_resolver.rb
facter-4.0.25 lib/resolvers/windows/system32_resolver.rb
facter-4.0.24 lib/resolvers/windows/system32_resolver.rb
facter-4.0.23 lib/resolvers/windows/system32_resolver.rb
facter-4.0.22 lib/resolvers/windows/system32_resolver.rb
facter-4.0.21 lib/resolvers/windows/system32_resolver.rb
facter-4.0.20 lib/resolvers/windows/system32_resolver.rb
facter-4.0.19 lib/resolvers/windows/system32_resolver.rb
facter-4.0.18 lib/resolvers/windows/system32_resolver.rb
facter-4.0.17 lib/resolvers/windows/system32_resolver.rb
facter-4.0.16 lib/resolvers/windows/system32_resolver.rb
facter-4.0.15 lib/resolvers/windows/system32_resolver.rb
facter-4.0.14 lib/resolvers/windows/system32_resolver.rb
facter-4.0.13 lib/resolvers/windows/system32_resolver.rb
facter-4.0.12 lib/resolvers/windows/system32_resolver.rb
facter-4.0.11 lib/resolvers/windows/system32_resolver.rb
facter-4.0.10.pre lib/resolvers/windows/system32_resolver.rb
facter-4.0.9.pre lib/resolvers/windows/system32_resolver.rb