Files

Class/Module Index [+]

Quicksearch

Chef::Mixin::WindowsArchitectureHelper

Public Instance Methods

assert_valid_windows_architecture!(architecture) click to toggle source
# File lib/chef/mixin/windows_architecture_helper.rb, line 54
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 78
def disable_wow64_file_redirection( node )
  original_redirection_state = ['0'].pack('P')

  if ( ( node_windows_architecture(node) == :x86_64) && ::Chef::Platform.windows?)
    win32_wow_64_disable_wow_64_fs_redirection =
      ::Win32::API.new('Wow64DisableWow64FsRedirection', 'P', 'L', 'kernel32')

    succeeded = win32_wow_64_disable_wow_64_fs_redirection.call(original_redirection_state)

    if succeeded == 0
      raise Win32APIError "Failed to disable Wow64 file redirection"
    end

  end

  original_redirection_state
end
is_i386_process_on_x86_64_windows?() click to toggle source
# File lib/chef/mixin/windows_architecture_helper.rb, line 61
def is_i386_process_on_x86_64_windows?
  if Chef::Platform.windows?
    is_64_bit_process_result = FFI::MemoryPointer.new(:int)

    # The return value of IsWow64Process is nonzero value if the API call succeeds.
    # The result data are returned in the last parameter, not the return value.
    call_succeeded = IsWow64Process(GetCurrentProcess(), is_64_bit_process_result)

    # The result is nonzero if IsWow64Process's calling process, in the case here
    # this process, is running under WOW64, i.e. the result is nonzero if this
    # process is 32-bit (aka :i386).
    result = (call_succeeded != 0) && (is_64_bit_process_result.get_int(0) != 0)
  else
    false
  end
end
node_supports_windows_architecture?(node, desired_architecture) click to toggle source
# File lib/chef/mixin/windows_architecture_helper.rb, line 44
def node_supports_windows_architecture?(node, desired_architecture)
  assert_valid_windows_architecture!(desired_architecture)
  return (node_windows_architecture(node) == :x86_64 ||
          desired_architecture == :i386) ? true : false
end
node_windows_architecture(node) click to toggle source
# File lib/chef/mixin/windows_architecture_helper.rb, line 34
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 96
def restore_wow64_file_redirection( node, original_redirection_state )
  if ( (node_windows_architecture(node) == :x86_64) && ::Chef::Platform.windows?)
    win32_wow_64_revert_wow_64_fs_redirection =
      ::Win32::API.new('Wow64RevertWow64FsRedirection', 'P', 'L', 'kernel32')

    succeeded = win32_wow_64_revert_wow_64_fs_redirection.call(original_redirection_state)

    if succeeded == 0
      raise Win32APIError "Failed to revert Wow64 file redirection"
    end
  end
end
valid_windows_architecture?(architecture) click to toggle source
# File lib/chef/mixin/windows_architecture_helper.rb, line 50
def valid_windows_architecture?(architecture)
  return (architecture == :x86_64) || (architecture == :i386)
end
wow64_architecture_override_required?(node, desired_architecture) click to toggle source
# File lib/chef/mixin/windows_architecture_helper.rb, line 38
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

[Validate]

Generated with the Darkfish Rdoc Generator 2.