module Process
def get_process_info(handle)
def get_process_info(handle) hash = Hash.new { |h, k| h[k] = [] } pe = PROCESSENTRY32.new pe[:dwSize] = pe.size if Process32First(handle, pe) hash[pe[:th32ProcessID]] = ProcessSnapInfo.new( pe[:th32ProcessID], pe[:cntThreads], pe[:th32ParentProcessID], pe[:pcPriClassBase], pe[:dwFlags], pe[:szExeFile].to_s ) else if FFI.errno == ERROR_NO_MORE_FILES return hash else raise SystemCallError.new("Process32First", FFI.errno) end end while Process32Next(handle, pe) hash[pe[:th32ProcessID]] = ProcessSnapInfo.new( pe[:th32ProcessID], pe[:cntThreads], pe[:th32ParentProcessID], pe[:pcPriClassBase], pe[:dwFlags], pe[:szExeFile].to_s ) end hash end