private void lvwProcesses_MouseDoubleClick(object sender, EventArgs e) { ListView.SelectedListViewItemCollection itemCollection = lvwProcesses.SelectedItems; if (itemCollection.Count == 0) { return; // No item selected } var pid = itemCollection[0].SubItems[1].Text; Process target = _procInfos.First(p => p.Process.Id == Convert.ToInt32(pid)).Process; string err; Inject.DoInject(target, Settings.DLL, out err); if (err != "") { MessageBox.Show(err); } else { Settings.LastProcessInjected = target.ProcessName; DllCommunication.SetTargetPid(target.Id); DllCommunication.StartPacketReaderMMF(); Program.mainForm.Text = "OSPE - PID: " + target.Id + " - " + target.ProcessName; Program.mainForm.processInyectedId = target.Id; Program.mainForm.ActionStartStopFiltering(false); Program.mainForm.ActionStopCapture(); Program.mainForm.ActionStartStopScript(false); Close(); } }
/// <summary> /// Injects the last process created (with higher StartTime) which has the same name of the latest injected process (using Select Process) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void InjectLastProcess() { if (!CheckDllFile() || Settings.LastProcessInjected == "") { return; } var procs = Process.GetProcessesByName(Settings.LastProcessInjected); if (procs.Length == 0) { return; } var lastProc = procs[0]; for (int i = 1; i < procs.Length; i++) { if (procs[i - 1].StartTime.CompareTo(procs[i].StartTime) < 0) { lastProc = procs[i]; } } string err; Inject.DoInject(lastProc, Settings.DLL, out err); if (err != "") { MessageBox.Show(err); } else { DllCommunication.SetTargetPid(lastProc.Id); DllCommunication.StartPacketReaderMMF(); this.Text = "OSPE - PID: " + lastProc.Id + " - " + lastProc.ProcessName; this.processInyectedId = lastProc.Id; ActionStartStopFiltering(false); ActionStopCapture(); ActionStartStopScript(false); } }