Sha256: 0389878cf0f5de2e42b9aa4409aeea26f12f8a5619ad2eeb8ffca1d99bee664d

Contents?: true

Size: 1.23 KB

Versions: 8

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

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

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

        def read_os_version_information(fact_name)
          require 'facter/resolvers/windows/ffi/kernel_ffi'

          ver_ptr = FFI::MemoryPointer.new(OsVersionInfoEx.size)
          ver = OsVersionInfoEx.new(ver_ptr)
          ver[:dwOSVersionInfoSize] = OsVersionInfoEx.size

          if KernelFFI::RtlGetVersion(ver_ptr) != KernelFFI::STATUS_SUCCESS
            @log.debug 'Calling Windows RtlGetVersion failed'
            return
          end

          result = { major: ver[:dwMajorVersion], minor: ver[:dwMinorVersion], build: ver[:dwBuildNumber] }
          build_facts_list(result)

          @fact_list[fact_name]
        end

        def build_facts_list(result)
          @fact_list[:kernelversion] = "#{result[:major]}.#{result[:minor]}.#{result[:build]}"
          @fact_list[:kernelmajorversion] = "#{result[:major]}.#{result[:minor]}"
          @fact_list[:kernel] = 'windows'
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
facter-4.0.44 lib/facter/resolvers/windows/kernel_resolver.rb
facter-4.0.43 lib/facter/resolvers/windows/kernel_resolver.rb
facter-4.0.42 lib/facter/resolvers/windows/kernel_resolver.rb
facter-4.0.41 lib/facter/resolvers/windows/kernel_resolver.rb
facter-4.0.40 lib/facter/resolvers/windows/kernel_resolver.rb
facter-4.0.39 lib/facter/resolvers/windows/kernel_resolver.rb
facter-4.0.38 lib/facter/resolvers/windows/kernel_resolver.rb
facter-4.0.37 lib/facter/resolvers/windows/kernel_resolver.rb