Sha256: 270bf511d1dcab80b9cdda64cd8a31051642700e32115e093fc3eb870ac5a77b

Contents?: true

Size: 1.24 KB

Versions: 22

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

module Facter
  module Resolvers
    class Kernel < BaseResolver
      @log = Facter::Log.new(self)

      init_resolver

      class << self
        private

        def post_resolve(fact_name, _options)
          @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

22 entries across 22 versions & 1 rubygems

Version Path
facter-4.3.1 lib/facter/resolvers/windows/kernel.rb
facter-4.3.0 lib/facter/resolvers/windows/kernel.rb
facter-4.2.14 lib/facter/resolvers/windows/kernel.rb
facter-4.2.13 lib/facter/resolvers/windows/kernel.rb
facter-4.2.12 lib/facter/resolvers/windows/kernel.rb
facter-4.2.11 lib/facter/resolvers/windows/kernel.rb
facter-4.2.10 lib/facter/resolvers/windows/kernel.rb
facter-4.2.9 lib/facter/resolvers/windows/kernel.rb
facter-4.2.8 lib/facter/resolvers/windows/kernel.rb
facter-4.2.7 lib/facter/resolvers/windows/kernel.rb
facter-4.2.6 lib/facter/resolvers/windows/kernel.rb
facter-4.2.5 lib/facter/resolvers/windows/kernel.rb
facter-4.2.4 lib/facter/resolvers/windows/kernel.rb
facter-4.2.3 lib/facter/resolvers/windows/kernel.rb
facter-4.2.2 lib/facter/resolvers/windows/kernel.rb
facter-4.2.1 lib/facter/resolvers/windows/kernel.rb
facter-4.2.0 lib/facter/resolvers/windows/kernel.rb
facter-4.1.1 lib/facter/resolvers/windows/kernel.rb
facter-4.1.0 lib/facter/resolvers/windows/kernel.rb
facter-4.0.52 lib/facter/resolvers/windows/kernel.rb