module Chef::Mixin::WindowsArchitectureHelper

Public Instance Methods

assert_valid_windows_architecture!(architecture) click to toggle source
# File lib/chef/mixin/windows_architecture_helper.rb, line 84
def assert_valid_windows_architecture!(architecture)
  if !valid_windows_architecture?(architecture)
    raise Chef::Exceptions::Win32ArchitectureIncorrect,
    "The specified architecture was not valid. It must be one of :i386 or :x86_64"
  end
end
disable_wow64_file_redirection( node ) click to toggle source
# File lib/chef/mixin/windows_architecture_helper.rb, line 99
def disable_wow64_file_redirection( node )
  if ( node_windows_architecture(node) == :x86_64) && ::Chef::Platform.windows?
    Chef::ReservedNames::Win32::System.wow64_disable_wow64_fs_redirection
  end
end
forced_32bit_override_required?(node, desired_architecture) click to toggle source
# File lib/chef/mixin/windows_architecture_helper.rb, line 38
def forced_32bit_override_required?(node, desired_architecture)
  desired_architecture == :i386 &&
    node_windows_architecture(node) == :x86_64 &&
    !is_i386_process_on_x86_64_windows?
end
is_i386_process_on_x86_64_windows?() click to toggle source
# File lib/chef/mixin/windows_architecture_helper.rb, line 91
def is_i386_process_on_x86_64_windows?
  if Chef::Platform.windows?
    Chef::ReservedNames::Win32::Process.is_wow64_process
  else
    false
  end
end
node_supports_windows_architecture?(node, desired_architecture) click to toggle source
# File lib/chef/mixin/windows_architecture_helper.rb, line 75
def node_supports_windows_architecture?(node, desired_architecture)
  assert_valid_windows_architecture!(desired_architecture)
  ( node_windows_architecture(node) == :x86_64 ) || ( desired_architecture == :i386 )
end
node_windows_architecture(node) click to toggle source
# File lib/chef/mixin/windows_architecture_helper.rb, line 28
def node_windows_architecture(node)
  node[:kernel][:machine].to_sym
end
restore_wow64_file_redirection( node, original_redirection_state ) click to toggle source
# File lib/chef/mixin/windows_architecture_helper.rb, line 105
def restore_wow64_file_redirection( node, original_redirection_state )
  if (node_windows_architecture(node) == :x86_64) && ::Chef::Platform.windows?
    Chef::ReservedNames::Win32::System.wow64_revert_wow64_fs_redirection(original_redirection_state)
  end
end
valid_windows_architecture?(architecture) click to toggle source
# File lib/chef/mixin/windows_architecture_helper.rb, line 80
def valid_windows_architecture?(architecture)
  ( architecture == :x86_64 ) || ( architecture == :i386 )
end
with_os_architecture(node, architecture: nil) { || ... } click to toggle source
# File lib/chef/mixin/windows_architecture_helper.rb, line 48
def with_os_architecture(node, architecture: nil)
  node ||= begin
    os_arch = ENV["PROCESSOR_ARCHITEW6432"] ||
      ENV["PROCESSOR_ARCHITECTURE"]
    Hash.new.tap do |n|
      n[:kernel] = Hash.new
      n[:kernel][:machine] = os_arch == "AMD64" ? :x86_64 : :i386
    end
  end

  architecture ||= node_windows_architecture(node)

  wow64_redirection_state = nil

  if wow64_architecture_override_required?(node, architecture)
    wow64_redirection_state = disable_wow64_file_redirection(node)
  end

  begin
    yield
  ensure
    if wow64_redirection_state
      restore_wow64_file_redirection(node, wow64_redirection_state)
    end
  end
end
wow64_architecture_override_required?(node, desired_architecture) click to toggle source
# File lib/chef/mixin/windows_architecture_helper.rb, line 32
def wow64_architecture_override_required?(node, desired_architecture)
  desired_architecture == :x86_64 &&
    node_windows_architecture(node) == :x86_64 &&
    is_i386_process_on_x86_64_windows?
end
wow64_directory() click to toggle source
# File lib/chef/mixin/windows_architecture_helper.rb, line 44
def wow64_directory
  Chef::ReservedNames::Win32::System.get_system_wow64_directory
end