private void Filter(int index, Matcher m) { PromptBox prompt = new PromptBox(); if (prompt.ShowDialog() == DialogResult.OK) { this.Cursor = Cursors.WaitCursor; ResultsWindow rw = Program.GetResultsWindow(_pid, new Program.ResultsWindowInvokeAction(delegate(ResultsWindow f) { f.ResultsList.VirtualListSize = 0; foreach (string[] s in Results) { if (m(s[index], prompt.Value)) { f.Results.Add(s); f.ResultsList.VirtualListSize++; } } f.Label = "Filter: " + f.Results.Count + " results."; f.Show(); })); this.Cursor = Cursors.Default; } }
private void buttonIntersect_Click(object sender, EventArgs e) { // this is a bit complex because the list needs to be sorted as well ContextMenu menu = new ContextMenu(); Dictionary <string, string> TextToId = new Dictionary <string, string>(); List <string> Texts = new List <string>(); foreach (string s in Program.ResultsWindows.Keys) { ResultsWindow window = Program.ResultsWindows[s]; Texts.Add(window.Text); TextToId.Add(window.Text, s); } Texts.Sort(); foreach (string s in Texts) { MenuItem item = new MenuItem(s); item.Tag = TextToId[s]; item.Click += new EventHandler(intersectItemClicked); menu.MenuItems.Add(item); vistaMenu.SetImage(item, global::ProcessHacker.Properties.Resources.table); } menu.Show(buttonIntersect, new System.Drawing.Point(buttonIntersect.Size.Width, 0)); }
private void buttonSave_Click(object sender, EventArgs e) { string filename = ""; DialogResult dr = DialogResult.Cancel; ResultsWindow rw = this; SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "Text Document (*.txt)|*.txt|All Files (*.*)|*.*"; dr = sfd.ShowDialog(); filename = sfd.FileName; if (dr == DialogResult.OK) { System.IO.StreamWriter sw = new System.IO.StreamWriter(filename); foreach (string[] s in _so.Searcher.Results) { sw.Write("0x{0:x} ({1}){2}\r\n", Int32.Parse(s[0].Replace("0x", ""), System.Globalization.NumberStyles.HexNumber) + Int32.Parse(s[1].Replace("0x", ""), System.Globalization.NumberStyles.HexNumber), Int32.Parse(s[2]), s[3] != "" ? (": " + s[3]) : ""); } sw.Close(); } }
private void intersectItemClicked(object sender, EventArgs e) { List <ListViewItem> newitems = new List <ListViewItem>(); List <long> windowitems = new List <long>(); string id = ((MenuItem)sender).Tag.ToString(); ResultsWindow window = Program.ResultsWindows[id]; this.Cursor = Cursors.WaitCursor; foreach (string[] s in window.Results) { windowitems.Add((long)BaseConverter.ToNumberParse(s[0]) + (long)BaseConverter.ToNumberParse(s[1])); } ResultsWindow rw = Program.GetResultsWindow(_pid, new Program.ResultsWindowInvokeAction(delegate(ResultsWindow f) { f.ResultsList.VirtualListSize = 0; foreach (string[] s in Results) { long location = (long)BaseConverter.ToNumberParse(s[0]) + (long)BaseConverter.ToNumberParse(s[1]); if (windowitems.Contains(location)) { f.Results.Add(s); f.ResultsList.VirtualListSize++; } } f.Label = "Intersection: " + f.Results.Count + " results."; f.Show(); })); this.Cursor = Cursors.Default; }
/// <summary> /// Creates an instance of the results window on a separate thread and invokes an action on that thread. /// </summary> /// <param name="action">The action to be performed.</param> public static ResultsWindow GetResultsWindow(int PID, ResultsWindowInvokeAction action) { ResultsWindow rw = null; string id = string.Empty; if (ResultsWindowsThreaded) { Thread t = new Thread(() => { rw = new ResultsWindow(PID); id = rw.Id; if (!rw.IsDisposed) action(rw); if (!rw.IsDisposed) Application.Run(rw); Program.ResultsThreads.Remove(id); }, Utils.SixteenthStackSize); t.SetApartmentState(ApartmentState.STA); t.Start(); while (string.IsNullOrEmpty(id)) Thread.Sleep(1); Program.ResultsThreads.Add(id, t); } else { rw = new ResultsWindow(PID); if (!rw.IsDisposed) action(rw); if (!rw.IsDisposed) rw.Show(); } return rw; }
public static ResultsWindow GetResultsWindow(int PID, ResultsWindowInvokeAction action) { ResultsWindow rw = null; string id = ""; if (ResultsWindowsThreaded) { Thread t = new Thread(new ThreadStart(delegate { rw = new ResultsWindow(PID); id = rw.Id; if (!rw.IsDisposed) action(rw); if (!rw.IsDisposed) Application.Run(rw); Program.ResultsThreads.Remove(id); })); t.SetApartmentState(ApartmentState.STA); t.Start(); while (id == "") Thread.Sleep(1); Program.ResultsThreads.Add(id, t); } else { rw = new ResultsWindow(PID); if (!rw.IsDisposed) action(rw); if (!rw.IsDisposed) rw.Show(); } return rw; }