class Chef::ReservedNames::Win32::Process

Attributes

handle[R]

Public Class Methods

get_current_process() click to toggle source
# File lib/chef/win32/process.rb, line 51
def self.get_current_process
  Process.new(Handle.new(GetCurrentProcess()))
end
get_process_handle_count(handle) click to toggle source
# File lib/chef/win32/process.rb, line 55
def self.get_process_handle_count(handle)
  handle_count = FFI::MemoryPointer.new :uint32
  unless GetProcessHandleCount(handle.handle, handle_count)
    Chef::ReservedNames::Win32::Error.raise!
  end
  handle_count.read_uint32
end
get_process_id(handle) click to toggle source
# File lib/chef/win32/process.rb, line 63
def self.get_process_id(handle)
  # Must have PROCESS_QUERY_INFORMATION or PROCESS_QUERY_LIMITED_INFORMATION rights
  result = GetProcessId(handle.handle)
  if result == 0
    Chef::ReservedNames::Win32::Error.raise!
  end
  result
end
get_process_memory_info(handle) click to toggle source

Must have PROCESS_QUERY_INFORMATION or PROCESS_QUERY_LIMITED_INFORMATION rights, AND the PROCESS_VM_READ right

# File lib/chef/win32/process.rb, line 87
def self.get_process_memory_info(handle)
  memory_info = PROCESS_MEMORY_COUNTERS.new
  unless GetProcessMemoryInfo(handle.handle, memory_info, memory_info.size)
    Chef::ReservedNames::Win32::Error.raise!
  end
  memory_info
end
is_wow64_process() click to toggle source
# File lib/chef/win32/process.rb, line 72
def self.is_wow64_process
  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).
  (call_succeeded != 0) && (is_64_bit_process_result.get_int(0) != 0)
end
new(handle) click to toggle source
# File lib/chef/win32/process.rb, line 33
def initialize(handle)
  @handle = handle
end

Public Instance Methods

handle_count() click to toggle source
# File lib/chef/win32/process.rb, line 43
def handle_count
  Process.get_process_handle_count(handle)
end
id() click to toggle source
# File lib/chef/win32/process.rb, line 39
def id
  Process.get_process_id(handle)
end
memory_info() click to toggle source
# File lib/chef/win32/process.rb, line 47
def memory_info
  Process.get_process_memory_info(handle)
end