public ProcessProperties(ProcessInfo info) { InitializeComponent(); m_privateBytesChart = new MonitorChart(chartPrivateBytes, "PrivateBytes"); m_privateBytesChart.FormatValueEvent = ((value) => { return Util.FormatBytes2((long)value); }); m_privateBytesChart.LabelFormatAuto = "FormatBytes"; m_privateBytesChart.LabelFormatZoomed = "RelativeBytes"; m_handleChart = new MonitorChart(chartHandles, "Handle count"); m_handleChart.FormatValueEvent = ((value) => { return string.Format("{0}", (long)value); }); this.Text = "Monitor [ " + info.Name + " ]"; m_status.Text = "Process: " + info.Name + ", PID: " + info.PID; // events Closed += OnClosedEvent; m_process = ProcessMonitor.CreateProcessMonitor(info.PID); m_thread = new Thread(() => MonitoringLoop()); m_thread.IsBackground = true; m_end = false; m_thread.Start(); }
private void TIMER_Tick(object sender, EventArgs e) { TIMER.Stop(); try { /* * Add new monitoring entries... */ LIST_Accesses.BeginUpdate(); lock (MonitorQueue) { while (MonitorQueue.Count > 0) { MonitorEntry Entry = MonitorQueue.Dequeue(); ListViewItem Item = LIST_Accesses.Items.Insert(0, Entry.ClientPID.ToString()); Item.SubItems.Add(Entry.Timestamp.ToString("hh:mm:ss." + ((Entry.Timestamp.Ticks / 10000) % 1000).ToString())); Item.SubItems.Add(Entry.Access); } } LIST_Accesses.EndUpdate(); /* * Update internal process list... */ lock (ProcessList) { Boolean HasChanged = false; if (ProcessList.Count == LIST_Processes.Items.Count) { for (int i = 0; i < ProcessList.Count; i++) { if (ProcessList[i].Id != Int32.Parse(LIST_Processes.Items[i].SubItems[1].Text)) { HasChanged = true; break; } } } else { HasChanged = true; } if (HasChanged) { Int32 SelIndex = 0; if (LIST_Processes.SelectedIndices.Count > 0) { SelIndex = LIST_Processes.SelectedIndices[0]; } LIST_Processes.BeginUpdate(); LIST_Processes.Items.Clear(); for (int i = 0; i < ProcessList.Count; i++) { ProcessInfo Proc = ProcessList[i]; ListViewItem Item = LIST_Processes.Items.Add(""); Item.SubItems.Add(Proc.Id.ToString()); if (Proc.Is64Bit) { Item.SubItems.Add("x64"); } else { Item.SubItems.Add("x86"); } Item.SubItems.Add(System.IO.Path.GetFileName(Proc.FileName)); Item.SubItems.Add(Proc.User); Item.SubItems.Add(Proc.FileName); Item.Checked = HookedProcesses.Contains(Proc.Id); } if (SelIndex >= LIST_Processes.Items.Count) { SelIndex = LIST_Processes.Items.Count - 1; } LIST_Processes.Items[SelIndex].Selected = true; LIST_Processes.Items[SelIndex].EnsureVisible(); LIST_Processes.EndUpdate(); } /* * Update list of hooked processes... */ for (int i = 0; i < HookedProcesses.Count; i++) { if (!ActivePIDList.Contains(HookedProcesses[i])) { HookedProcesses.RemoveAt(i--); } } } } finally { TIMER.Start(); } }