public static ProcessInfo[] EnumProcesses() { List <ProcessInfo> result = new List <ProcessInfo>(); Process[] procList = Process.GetProcesses(); for (int i = 0; i < procList.Length; i++) { Process proc = procList[i]; try { ProcessInfo info = new ProcessInfo(); info.FileName = proc.MainModule.FileName; info.Id = proc.Id; info.Is64Bit = RemoteHooking.IsX64Process(proc.Id); info.User = RemoteHooking.GetProcessIdentity(proc.Id).Name; result.Add(info); } catch { } } return(result.ToArray()); }
public static ProcessInfo[] Enum() { List <ProcessInfo> Result = new List <ProcessInfo>(); Process[] ProcList = Process.GetProcesses(); for (int i = 0; i < ProcList.Length; i++) { Process Proc = ProcList[i]; try { ProcessInfo Info = new ProcessInfo(); Info.FileName = Proc.MainModule.FileName; Info.Id = Proc.Id; Info.Is64Bit = RemoteHooking.IsX64Process(Proc.Id); Info.Identity = RemoteHooking.GetProcessIdentity(Proc.Id).Owner.ToString(); Result.Add(Info); } catch { } } return(Result.ToArray()); }
public static ProcessEntry[] EnumerateProcesses() { var processEntries = new List <ProcessEntry>(); var processes = Process.GetProcesses(); foreach (var process in processes) { try { processEntries.Add(new ProcessEntry() { FullPath = process.MainModule.FileName, ImageName = process.ProcessName, Id = process.Id, IsX64 = RemoteHooking.IsX64Process(process.Id), Owner = RemoteHooking.GetProcessIdentity(process.Id).Name }); } catch { // Access will be denied to some processes even though we're running as a service continue; } } return(processEntries.ToArray()); }
private void EnumProcesses() { _processList.Clear(); foreach (var currentProc in from proc in Process.GetProcesses() orderby proc.ProcessName select proc) { try { // This can sometimes happen between calling GetProcesses and getting here. Save ourselves the throw. if (currentProc.HasExited) { continue; } _processList.Add(new ProcessInfo { FileName = currentProc.ProcessName, Id = currentProc.Id, Owner = RemoteHooking.GetProcessIdentity(currentProc.Id).Name }); } catch (AccessViolationException) { // noop, there's a lot of system processes we can't see. } catch (Win32Exception) { // noop, there's a lot of system processes we can't see. } catch (Exception aEx) { _log.Error(aEx); } } }
private void EnumProcesses() { Dispatcher.Invoke(() => { _processList.Clear(); }); Dispatcher.Invoke(() => { ProcessStatus = "Scanning Processes..."; }); var cp = Process.GetCurrentProcess().Id; const ProcessAccessRights flags = ProcessAccessRights.PROCESS_QUERY_INFORMATION | ProcessAccessRights.PROCESS_VM_READ; var procList = from proc in Process.GetProcesses() orderby proc.ProcessName select proc; Parallel.ForEach(procList, (currentProc) => { if (_scanningToken.IsCancellationRequested) { return; } var handle = IntPtr.Zero; try { // This can sometimes happen between calling GetProcesses and getting here. Save ourselves the throw. if (currentProc.HasExited || currentProc.Id == cp) { return; } // This is usually what throws, so do it before we invoke via dispatcher. var owner = RemoteHooking.GetProcessIdentity(currentProc.Id).Name; if ((handle = Native.OpenProcess(flags, false, currentProc.Id)) == IntPtr.Zero) { return; } var procInfo = new ProcessInfo { FileName = currentProc.ProcessName, Id = currentProc.Id, }; if (XInputMod.CanUseMod(handle)) { procInfo.Owner = owner; } if (UnityVRMod.CanUseMod(handle, currentProc.MainModule.FileName, out var module, out var frameworkVersion)) { procInfo.MonoModule = module; procInfo.FrameworkVersion = frameworkVersion; } if (procInfo.CanUseXInput || procInfo.CanUseMono) { Dispatcher.Invoke(() => { _log.Debug(procInfo); _processList.Add(procInfo); }); } }
private void EnumProcesses() { Dispatcher.Invoke(() => { _processList.Clear(); }); Dispatcher.Invoke(() => { ProcessError = "Scanning Processes..."; }); var cp = Process.GetCurrentProcess().Id; const ProcessAccessRights flags = ProcessAccessRights.PROCESS_QUERY_INFORMATION | ProcessAccessRights.PROCESS_VM_READ; foreach (var currentProc in from proc in Process.GetProcesses() orderby proc.ProcessName select proc) { var handle = IntPtr.Zero; try { // This can sometimes happen between calling GetProcesses and getting here. Save ourselves the throw. if (currentProc.HasExited || currentProc.Id == cp) { continue; } // This is usually what throws, so do it before we invoke via dispatcher. var owner = RemoteHooking.GetProcessIdentity(currentProc.Id).Name; if ((handle = Native.OpenProcess(flags, false, currentProc.Id)) == IntPtr.Zero) { continue; } var procInfo = new ProcessInfo { FileName = currentProc.ProcessName, Id = currentProc.Id, }; if (XInputMod.CanUseMod(handle)) { procInfo.Owner = owner; } if (UnityVRMod.CanUseMod(handle, currentProc.MainModule.FileName, out var module, out var frameworkVersion)) { procInfo.MonoModule = module; procInfo.FrameworkVersion = frameworkVersion; } if (procInfo.CanUseXInput || procInfo.CanUseMono) { Dispatcher.Invoke(() => { _log.Debug(procInfo); _processList.Add(procInfo); }); } } catch (AccessViolationException) { // noop, there's a lot of system processes we can't see. } catch (Win32Exception) { // noop, there's a lot of system processes we can't see. } catch (Exception aEx) { _log.Error(aEx); } finally { // Only close the if (handle != IntPtr.Zero) { Native.CloseHandle(handle); } } } Dispatcher.Invoke(() => { ProcessError = "Select Process to Inject"; }); _enumProcessTask = null; }