Class: HawatelPS::Windows::ProcControl

Inherits:
Object
  • Object
show all
Defined in:
lib/hawatel_ps/windows/proc_control.rb

Direct Known Subclasses

ProcInfo

Instance Method Summary collapse

Instance Method Details

#resumeString

Resume suspended process

Examples:

p = HawatelPS.search_by_pid('1020')
p.resume

Returns:

  • (String)


40
41
42
43
44
# File 'lib/hawatel_ps/windows/proc_control.rb', line 40

def resume
  # TODO There is no ResumeProcess API function in Windows.
  # This was described in article: http://www.codeproject.com/Articles/2964/Win-process-suspend-resume-tool
  # The resume method isn't not save
end

#statusString

Check current process status

Examples:

p = HawatelPS.search_by_name('notepad.exe')
p.status

Returns:

  • (String)

    ‘running’ or ‘not running’



12
13
14
15
16
17
18
19
# File 'lib/hawatel_ps/windows/proc_control.rb', line 12

def status
  Process.kill 0, @proc_attrs[:processid].to_i
  return "running"
rescue Errno::ESRCH
  return "not running"
rescue Errno::EPERM
  return 'non-privilaged operation'
end

#suspendString

Suspend process without loss data

Examples:

p = HawatelPS.search_by_pid('1020')
p.suspend

Returns:

  • (String)


28
29
30
31
32
# File 'lib/hawatel_ps/windows/proc_control.rb', line 28

def suspend
  # TODO There is no SuspendProcess API function in Windows.
  # This was described in article: http://www.codeproject.com/Articles/2964/Win-process-suspend-resume-tool
  # The suspend method isn't not save
end

#terminateInteger

Terminate process

Examples:

p = HawatelPS.search_by_pid('1020')
p.terminate

Returns:



60
61
62
63
64
65
# File 'lib/hawatel_ps/windows/proc_control.rb', line 60

def terminate
  return @proc_attrs[:wmi_object].Terminate if @proc_attrs[:wmi_object].ole_respond_to?('Terminate')
rescue WIN32OLERuntimeError => ex
  #raise HawatelPSException, :exception => ex, :message => "Cannot terminate process by WMI method Terminate()."
  return 1
end