/// <summary>Enumerates all pipes started by the ReClass.NET PipeServer.</summary> /// <param name="callbackProcess">The callback which gets called for every process.</param> public void EnumerateProcesses(EnumerateProcessCallback callbackProcess) { if (callbackProcess == null) { return; } foreach (var pipe in GetPipes()) { var platform = new DirectoryInfo(pipe).Parent?.Name ?? string.Empty; #if RECLASSNET64 if (platform.ToLower() == "x64") #else if (platform.ToLower() == "x86") #endif { var data = new EnumerateProcessData { Id = (IntPtr)pipe.GetHashCode(), Name = Path.GetFileName(pipe), Path = pipe }; callbackProcess(ref data); } } }
/// <summary>Opens a file browser dialog and reports the selected file.</summary> /// <param name="callbackProcess">The callback which gets called for the selected file.</param> public void EnumerateProcesses(EnumerateProcessCallback callbackProcess) { if (callbackProcess == null) { return; } using (var ofd = new OpenFileDialog()) { ofd.Filter = "All|*.*"; if (ofd.ShowDialog() == DialogResult.OK) { currentFile = ofd.FileName; var data = new EnumerateProcessData { Id = (IntPtr)currentFile.GetHashCode(), Name = Path.GetFileName(currentFile), Path = currentFile }; callbackProcess(ref data); } } }
public void EnumerateProcesses(EnumerateProcessCallback callbackProcess) { Process[] processes = Process.GetProcesses(); for (int i = 0; i < processes.Length; i++) { var Process = processes[i]; if (Process.Id == 0 || Process.Id == 4) { continue; } var Data = new EnumerateProcessData(); Data.Id = new IntPtr(Process.Id); try { Data.Name = Process.MainModule.ModuleName; Data.Path = Process.MainModule.FileName; } catch (Exception) { bool Fallback = Driver.GetProcessInfo(Process.Id, ref Data); if (!Fallback) { Data.Name = Process.ProcessName; } } callbackProcess.Invoke(ref Data); } }
/// <summary>Opens a file browser dialog and reports the selected file.</summary> /// <param name="callbackProcess">The callback which gets called for the selected file.</param> public void EnumerateProcesses(EnumerateProcessCallback callbackProcess) { if (callbackProcess == null) { return; } using (var ofd = new OpenFileDialog()) { ofd.Filter = "All|*.*"; if (ofd.ShowDialog() == DialogResult.OK) { currentFile = ofd.FileName; var data = new EnumerateProcessData { Id = (IntPtr)currentFile.GetHashCode(), Name = Path.GetFileName(currentFile), Path = currentFile }; // Parse index file into dictionary string IndexFilePath = Path.GetFullPath(currentFile); IndexFilePath += ".idx"; Console.WriteLine(IndexFilePath); parseIndexFile(IndexFilePath); callbackProcess(ref data); } } }
public void EnumerateProcesses(EnumerateProcessCallback callbackProcess) { enumerateProcessesDelegate(callbackProcess); }
/// <summary>Enumerates all pipes started by the ReClass.NET PipeServer.</summary> /// <param name="callbackProcess">The callback which gets called for every process.</param> public void EnumerateProcesses(EnumerateProcessCallback callbackProcess) { if (callbackProcess == null) { return; } lock (sync) { processToClientMapping.Clear(); var validClients = new List <MessageClient>(); foreach (var pipePath in GetPipes()) { var client = GetOrCreateClientForPipe(pipePath); try { client.Send(new EnumerateProcessHandlesRequest()); var abusedProcessName = Path.GetFileName(pipePath); while (true) { var message = client.Receive(); if (message is StatusResponse) { break; } if (message is EnumerateProcessHandlesResponse phr) { var mapping = new ProcessClientMapping(phr.RemoteId, client); processToClientMapping.Add(mapping.GetHashCode(), mapping); var targetProcessName = Path.GetFileName(phr.Path); var data = new EnumerateProcessData { Id = (IntPtr)mapping.GetHashCode(), Name = $"{abusedProcessName} -> {targetProcessName}", Path = phr.Path }; callbackProcess(ref data); } } validClients.Add(client); } catch (Exception ex) { host.Logger.Log(ex); } } foreach (var dormant in clients.Values.Except(validClients)) { dormant.Dispose(); } clients.RemoveWhere(kv => !validClients.Contains(kv.Value)); } }