completed System Information Window

git-svn-id: svn://svn.code.sf.net/p/processhacker/code@454 21ef857c-d57f-4fe0-8362-d861dc6d29cd
This commit is contained in:
wj32
2008-12-30 10:46:00 +00:00
parent 0faeedf075
commit a1cb2e9683
20 changed files with 1513 additions and 130 deletions
+17 -20
View File
@@ -1,26 +1,23 @@
Process Hacker
1.3.0.0
* NEW: Process tree
* NEW: Process properties window
* NEW: Process performance information and graphs
* NEW: Displays more information about tokens
* NEW: Displays information about Events, Mutants, Sections and Tokens
other processes have handles to
* NEW: Terminator tool - tries to terminate processes using many different
techniques
* NEW: Highlighting for UAC elevated processes and processes in job objects
* NEW: Struct reader (with support for user-defined structs)
* NEW: Tray icon now displays the current CPU usage, and the tooltip is almost
exactly the same as Process Explorer's (current CPU usage + process using most
of the CPU)
* FIXED: Shows SIDs without names in SDDL format
* FIXED: Less "Access denied" errors - uses PROCESS_QUERY_LIMITED_INFORMATION
on Vista
* FIXED: Major refactoring of Win32 code
* FIXED: Symbols are now bound to each process - no more weird stack traces/symbol
names
* FIXED: Handle filtering is now much faster - uses a cache for session ID checking
* NEW:
* Process tree using TreeViewAdv
* Process properties window with statistics and graphs
* System Information Window with statistics and graphs
* Detailed token information, including source, owner and primary group
* Information about remote handles to events, mutants, sections and tokens
* Terminator tool - tries many techniques to terminate processes
* Highlighting for UAC elevated processes and processes in job objects
* Struct reader for examining PEBs and TEBs - note that this can be
extended by writing your own definitions
* Better tray icon - displays a graph, and the tooltip contains the current
CPU usage and the process using most of the CPU
* FIXED:
* Shows SIDs without names (like Logon IDs) in SDDL format
* Uses PROCESS_QUERY_LIMITED_INFORMATION on Windows Vista - e.g. on audiodg.exe
* Symbols are now bound to each process - no more weird stack traces/symbols
* Handle filtering is now much faster - uses a cache for session ID checking
1.2.6.5
* A new member of the project - Dean
@@ -163,6 +163,11 @@ namespace ProcessHacker.Components
/// <param name="f2">A floating-point number less than or equal to 1.</param>
public void Add(float f1, float f2)
{
if (f1 > 1.0f)
f1 = 1.0f;
if (f2 > 1.0f)
f2 = 1.0f;
_listData1.Add(f1);
_listData2.Add(f2);
@@ -272,8 +272,10 @@ namespace ProcessHacker
{
SysInfoWindow = new SysInfoWindow();
}
SysInfoWindow.Show();
SysInfoWindow.Activate();
SysInfoWindow.Start();
}
#endregion
+55 -23
View File
@@ -40,6 +40,8 @@
this.checkHideWhenMinimized = new System.Windows.Forms.CheckBox();
this.checkShowTrayIcon = new System.Windows.Forms.CheckBox();
this.tabHighlighting = new System.Windows.Forms.TabPage();
this.label11 = new System.Windows.Forms.Label();
this.colorJobProcesses = new ProcessHacker.Components.ColorModifier();
this.label10 = new System.Windows.Forms.Label();
this.colorElevatedProcesses = new ProcessHacker.Components.ColorModifier();
this.label9 = new System.Windows.Forms.Label();
@@ -70,8 +72,8 @@
this.label16 = new System.Windows.Forms.Label();
this.colorCPUKT = new ProcessHacker.Components.ColorModifier();
this.label17 = new System.Windows.Forms.Label();
this.colorJobProcesses = new ProcessHacker.Components.ColorModifier();
this.label11 = new System.Windows.Forms.Label();
this.label18 = new System.Windows.Forms.Label();
this.comboSizeUnits = new System.Windows.Forms.ComboBox();
((System.ComponentModel.ISupportInitialize)(this.textUpdateInterval)).BeginInit();
this.tabControl.SuspendLayout();
this.tabGeneral.SuspendLayout();
@@ -133,7 +135,7 @@
//
this.checkShowProcessDomains.AutoSize = true;
this.checkShowProcessDomains.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.checkShowProcessDomains.Location = new System.Drawing.Point(6, 132);
this.checkShowProcessDomains.Location = new System.Drawing.Point(6, 159);
this.checkShowProcessDomains.Name = "checkShowProcessDomains";
this.checkShowProcessDomains.Size = new System.Drawing.Size(156, 18);
this.checkShowProcessDomains.TabIndex = 3;
@@ -144,7 +146,7 @@
//
this.checkWarnDangerous.AutoSize = true;
this.checkWarnDangerous.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.checkWarnDangerous.Location = new System.Drawing.Point(6, 108);
this.checkWarnDangerous.Location = new System.Drawing.Point(6, 135);
this.checkWarnDangerous.Name = "checkWarnDangerous";
this.checkWarnDangerous.Size = new System.Drawing.Size(228, 18);
this.checkWarnDangerous.TabIndex = 4;
@@ -164,9 +166,9 @@
//
this.textSearchEngine.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textSearchEngine.Location = new System.Drawing.Point(92, 33);
this.textSearchEngine.Location = new System.Drawing.Point(95, 33);
this.textSearchEngine.Name = "textSearchEngine";
this.textSearchEngine.Size = new System.Drawing.Size(241, 20);
this.textSearchEngine.Size = new System.Drawing.Size(238, 20);
this.textSearchEngine.TabIndex = 6;
//
// tabControl
@@ -185,6 +187,8 @@
//
// tabGeneral
//
this.tabGeneral.Controls.Add(this.comboSizeUnits);
this.tabGeneral.Controls.Add(this.label18);
this.tabGeneral.Controls.Add(this.checkHideWhenMinimized);
this.tabGeneral.Controls.Add(this.checkShowTrayIcon);
this.tabGeneral.Controls.Add(this.label1);
@@ -196,7 +200,7 @@
this.tabGeneral.Location = new System.Drawing.Point(4, 22);
this.tabGeneral.Name = "tabGeneral";
this.tabGeneral.Padding = new System.Windows.Forms.Padding(3);
this.tabGeneral.Size = new System.Drawing.Size(339, 226);
this.tabGeneral.Size = new System.Drawing.Size(339, 244);
this.tabGeneral.TabIndex = 0;
this.tabGeneral.Text = "General";
this.tabGeneral.UseVisualStyleBackColor = true;
@@ -205,7 +209,7 @@
//
this.checkHideWhenMinimized.AutoSize = true;
this.checkHideWhenMinimized.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.checkHideWhenMinimized.Location = new System.Drawing.Point(6, 83);
this.checkHideWhenMinimized.Location = new System.Drawing.Point(6, 110);
this.checkHideWhenMinimized.Name = "checkHideWhenMinimized";
this.checkHideWhenMinimized.Size = new System.Drawing.Size(131, 18);
this.checkHideWhenMinimized.TabIndex = 9;
@@ -216,7 +220,7 @@
//
this.checkShowTrayIcon.AutoSize = true;
this.checkShowTrayIcon.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.checkShowTrayIcon.Location = new System.Drawing.Point(6, 59);
this.checkShowTrayIcon.Location = new System.Drawing.Point(6, 86);
this.checkShowTrayIcon.Name = "checkShowTrayIcon";
this.checkShowTrayIcon.Size = new System.Drawing.Size(102, 18);
this.checkShowTrayIcon.TabIndex = 7;
@@ -252,6 +256,23 @@
this.tabHighlighting.Text = "Highlighting";
this.tabHighlighting.UseVisualStyleBackColor = true;
//
// label11
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(6, 217);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(79, 13);
this.label11.TabIndex = 9;
this.label11.Text = "Job Processes:";
//
// colorJobProcesses
//
this.colorJobProcesses.Color = System.Drawing.Color.Transparent;
this.colorJobProcesses.Location = new System.Drawing.Point(127, 215);
this.colorJobProcesses.Name = "colorJobProcesses";
this.colorJobProcesses.Size = new System.Drawing.Size(40, 20);
this.colorJobProcesses.TabIndex = 8;
//
// label10
//
this.label10.AutoSize = true;
@@ -415,7 +436,7 @@
this.tabPlotting.Location = new System.Drawing.Point(4, 22);
this.tabPlotting.Name = "tabPlotting";
this.tabPlotting.Padding = new System.Windows.Forms.Padding(3);
this.tabPlotting.Size = new System.Drawing.Size(339, 226);
this.tabPlotting.Size = new System.Drawing.Size(339, 244);
this.tabPlotting.TabIndex = 2;
this.tabPlotting.Text = "Plotting";
this.tabPlotting.UseVisualStyleBackColor = true;
@@ -533,22 +554,31 @@
this.label17.TabIndex = 10;
this.label17.Text = "CPU Kernel Time:";
//
// colorJobProcesses
// label18
//
this.colorJobProcesses.Color = System.Drawing.Color.Transparent;
this.colorJobProcesses.Location = new System.Drawing.Point(127, 215);
this.colorJobProcesses.Name = "colorJobProcesses";
this.colorJobProcesses.Size = new System.Drawing.Size(40, 20);
this.colorJobProcesses.TabIndex = 8;
this.label18.AutoSize = true;
this.label18.Location = new System.Drawing.Point(6, 62);
this.label18.Name = "label18";
this.label18.Size = new System.Drawing.Size(75, 13);
this.label18.TabIndex = 10;
this.label18.Text = "Max Size Unit:";
//
// label11
// comboSizeUnits
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(6, 217);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(79, 13);
this.label11.TabIndex = 9;
this.label11.Text = "Job Processes:";
this.comboSizeUnits.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboSizeUnits.FormattingEnabled = true;
this.comboSizeUnits.Items.AddRange(new object[] {
"B",
"kB",
"MB",
"GB",
"TB",
"PB",
"EB"});
this.comboSizeUnits.Location = new System.Drawing.Point(95, 59);
this.comboSizeUnits.Name = "comboSizeUnits";
this.comboSizeUnits.Size = new System.Drawing.Size(67, 21);
this.comboSizeUnits.TabIndex = 11;
//
// OptionsWindow
//
@@ -625,5 +655,7 @@
private System.Windows.Forms.CheckBox checkPlotterAntialias;
private System.Windows.Forms.Label label11;
private ProcessHacker.Components.ColorModifier colorJobProcesses;
private System.Windows.Forms.ComboBox comboSizeUnits;
private System.Windows.Forms.Label label18;
}
}
@@ -37,6 +37,8 @@ namespace ProcessHacker
textUpdateInterval.Value = Properties.Settings.Default.RefreshInterval;
textSearchEngine.Text = Properties.Settings.Default.SearchEngine;
comboSizeUnits.SelectedItem =
Misc.SizeUnitNames[Properties.Settings.Default.UnitSpecifier];
checkWarnDangerous.Checked = Properties.Settings.Default.WarnDangerous;
checkShowProcessDomains.Checked = Properties.Settings.Default.ShowAccountDomains;
checkShowTrayIcon.Checked = Properties.Settings.Default.ShowIcon;
@@ -83,6 +85,8 @@ namespace ProcessHacker
Properties.Settings.Default.ShowAccountDomains = checkShowProcessDomains.Checked;
Properties.Settings.Default.ShowIcon = checkShowTrayIcon.Checked;
Properties.Settings.Default.HideWhenMinimized = checkHideWhenMinimized.Checked;
Properties.Settings.Default.UnitSpecifier =
Array.IndexOf(Misc.SizeUnitNames, comboSizeUnits.SelectedItem);
Program.HackerWindow.NotifyIcon.Visible = Properties.Settings.Default.ShowIcon;
Program.HackerWindow.ProcessProvider.Interval = Properties.Settings.Default.RefreshInterval;
+14 -13
View File
@@ -66,8 +66,10 @@ namespace ProcessHacker
{
ProcessItem item = Program.HackerWindow.ProcessProvider.Dictionary[_pid];
_processStats.Add("System Idle",
Program.HackerWindow.ProcessProvider.ProcessorPerf.IdleTime);
_processStats.Add("System Other",
Program.HackerWindow.ProcessProvider.ProcessorPerf.IdleTime +
Program.HackerWindow.ProcessProvider.ProcessorPerf.DpcTime +
Program.HackerWindow.ProcessProvider.ProcessorPerf.InterruptTime);
_processStats.Add("System Kernel",
Program.HackerWindow.ProcessProvider.ProcessorPerf.KernelTime);
_processStats.Add("System User",
@@ -440,8 +442,10 @@ namespace ProcessHacker
ProcessItem item = Program.HackerWindow.ProcessProvider.Dictionary[_pid];
// update deltas
_processStats.Update("System Idle",
Program.HackerWindow.ProcessProvider.ProcessorPerf.IdleTime);
_processStats.Update("System Other",
Program.HackerWindow.ProcessProvider.ProcessorPerf.IdleTime +
Program.HackerWindow.ProcessProvider.ProcessorPerf.DpcTime +
Program.HackerWindow.ProcessProvider.ProcessorPerf.InterruptTime);
_processStats.Update("System Kernel",
Program.HackerWindow.ProcessProvider.ProcessorPerf.KernelTime);
_processStats.Update("System User",
@@ -467,18 +471,15 @@ namespace ProcessHacker
plotterIO.LineColor2 = Properties.Settings.Default.PlotterIOWColor;
// update graphs
long sysTotal = _processStats.GetDelta("System Kernel") + _processStats.GetDelta("System User");
long sysTotal = _processStats.GetDelta("System Kernel") + _processStats.GetDelta("System User")
+ _processStats.GetDelta("System Other");
float procKernel = (float)_processStats.GetDelta("Process Kernel") / sysTotal;
float procUser = (float)_processStats.GetDelta("Process User") / sysTotal;
int noProcs = Program.HackerWindow.ProcessProvider.System.NumberOfProcessors;
if (procKernel / noProcs <= 1 && procUser / noProcs <= 1)
{
plotterCPUUsage.Add(procKernel / noProcs, procUser / noProcs);
plotterCPUUsage.Text = ((procKernel + procUser) * 100 / noProcs).ToString("F2") +
"% (K: " + (procKernel * 100 / noProcs).ToString("F2") +
"%, U: " + (procUser * 100 / noProcs).ToString("F2") + "%)";
}
plotterCPUUsage.Add(procKernel, procUser);
plotterCPUUsage.Text = ((procKernel + procUser) * 100).ToString("F2") +
"% (K: " + (procKernel * 100).ToString("F2") +
"%, U: " + (procUser * 100).ToString("F2") + "%)";
plotterMemory.Add(item.Process.VirtualMemoryCounters.PrivateBytes,
item.Process.VirtualMemoryCounters.WorkingSetSize);
File diff suppressed because it is too large Load Diff
+115 -19
View File
@@ -32,6 +32,7 @@ namespace ProcessHacker
{
private Components.Plotter[] _cpuPlotters;
private int _noOfCPUs = Program.HackerWindow.ProcessProvider.System.NumberOfProcessors;
private int _pages = Program.HackerWindow.ProcessProvider.System.NumberOfPhysicalPages;
private int _pageSize = Program.HackerWindow.ProcessProvider.System.PageSize;
private DeltaManager<string, long> _deltaManager = new DeltaManager<string, long>(new Int64Subtractor());
private int _runCount = 0;
@@ -40,9 +41,8 @@ namespace ProcessHacker
{
InitializeComponent();
plotterCPU.UseSecondLine = true;
// intializse delta manager
// intialize delta manager
_deltaManager.Add("clock", (long)Win32.GetTickCount() * 10000);
_deltaManager.Add("cpu_kernel", 0);
_deltaManager.Add("cpu_user", 0);
_deltaManager.Add("cpu_other", 0);
@@ -62,6 +62,7 @@ namespace ProcessHacker
tableCPUs.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 1.0f / _noOfCPUs));
_cpuPlotters[i] = new ProcessHacker.Components.Plotter();
_cpuPlotters[i].BackColor = Color.Black;
_cpuPlotters[i].Dock = DockStyle.Fill;
_cpuPlotters[i].UseSecondLine = true;
tableCPUs.Controls.Add(_cpuPlotters[i], i, 0);
@@ -69,14 +70,17 @@ namespace ProcessHacker
_deltaManager.Add("cpu_" + i.ToString() + "_user", 0);
_deltaManager.Add("cpu_" + i.ToString() + "_other", 0);
}
tableCPUs.Visible = true;
tableCPUs.Visible = false;
checkShowOneGraphPerCPU.Checked = Properties.Settings.Default.ShowOneGraphPerCPU;
}
private void SysInfoWindow_Load(object sender, EventArgs e)
public void Start()
{
_runCount = 0;
checkShowOneGraphPerCPU.Checked = Properties.Settings.Default.ShowOneGraphPerCPU;
Program.HackerWindow.ProcessProvider.PerformanceEnabled = true;
Program.HackerWindow.ProcessProvider.Updated +=
Program.HackerWindow.ProcessProvider.Updated +=
new ProcessSystemProvider.ProviderUpdateOnce(ProcessProvider_Updated);
}
@@ -91,7 +95,22 @@ namespace ProcessHacker
this.Hide();
}
private void UpdateInfo()
private void UpdateDeltas()
{
Win32.SYSTEM_PERFORMANCE_INFORMATION perfInfo = Program.HackerWindow.ProcessProvider.Performance;
_deltaManager.Update("cpu_kernel", Program.HackerWindow.ProcessProvider.ProcessorPerf.KernelTime);
_deltaManager.Update("cpu_user", Program.HackerWindow.ProcessProvider.ProcessorPerf.UserTime);
_deltaManager.Update("cpu_other", Program.HackerWindow.ProcessProvider.ProcessorPerf.IdleTime +
Program.HackerWindow.ProcessProvider.ProcessorPerf.DpcTime +
Program.HackerWindow.ProcessProvider.ProcessorPerf.InterruptTime);
_deltaManager.Update("contextswitches", perfInfo.ContextSwitches);
_deltaManager.Update("io_r", perfInfo.IoReadTransferCount);
_deltaManager.Update("io_w", perfInfo.IoWriteTransferCount);
_deltaManager.Update("io_o", perfInfo.IoOtherTransferCount);
}
private void UpdateGraphs()
{
Win32.SYSTEM_PERFORMANCE_INFORMATION perfInfo = Program.HackerWindow.ProcessProvider.Performance;
@@ -102,17 +121,7 @@ namespace ProcessHacker
plotterMemory.LineColor1 = Properties.Settings.Default.PlotterMemoryPrivateColor;
plotterMemory.LineColor2 = Properties.Settings.Default.PlotterMemoryWSColor;
_deltaManager.Update("cpu_kernel", Program.HackerWindow.ProcessProvider.ProcessorPerf.KernelTime);
_deltaManager.Update("cpu_user", Program.HackerWindow.ProcessProvider.ProcessorPerf.UserTime);
_deltaManager.Update("cpu_other", Program.HackerWindow.ProcessProvider.ProcessorPerf.IdleTime +
Program.HackerWindow.ProcessProvider.ProcessorPerf.DpcTime +
Program.HackerWindow.ProcessProvider.ProcessorPerf.InterruptTime);
_deltaManager.Update("contextswitches", perfInfo.ContextSwitches);
_runCount++;
if (_runCount < 1)
return;
// update the CPU graph
long sysKernel = _deltaManager.GetDelta("cpu_kernel");
long sysUser = _deltaManager.GetDelta("cpu_user");
long sysOther = _deltaManager.GetDelta("cpu_other");
@@ -124,6 +133,7 @@ namespace ProcessHacker
"% (K: " + (kernelUsage * 100).ToString("F2") +
"%, U: " + (userUsage * 100).ToString("F2") + "%)";
// update the individual CPU graphs
for (int i = 0; i < _noOfCPUs; i++)
{
_cpuPlotters[i].LineColor1 = Properties.Settings.Default.PlotterCPUKernelColor;
@@ -149,11 +159,97 @@ namespace ProcessHacker
"% (K: " + (cpuKernelUsage * 100).ToString("F2") +
"%, U: " + (cpuUserUsage * 100).ToString("F2") + "%)";
}
// this hack is needed for some reason
if (_runCount < 4)
{
_deltaManager.SetDelta("io_r", 0);
_deltaManager.SetDelta("io_w", 0);
_deltaManager.SetDelta("io_o", 0);
}
// update the I/O graph
long ioR = _deltaManager.GetDelta("io_r");
long ioW = _deltaManager.GetDelta("io_w");
long ioO = _deltaManager.GetDelta("io_o");
plotterIO.Add(ioR + ioO, ioW);
plotterIO.Text = "R+O: " + Misc.GetNiceSizeName(ioR + ioO) +
", W: " + Misc.GetNiceSizeName(ioW);
// update the memory graph
long commitSize = perfInfo.CommittedPages * _pageSize;
long physMemoryUsage = (_pages - perfInfo.AvailablePages) * _pageSize;
plotterMemory.Add(commitSize, physMemoryUsage);
plotterMemory.Text = "Commit: " + Misc.GetNiceSizeName(commitSize) +
", Phys. Mem: " + Misc.GetNiceSizeName(physMemoryUsage);
_runCount++;
}
private void UpdateInfo()
{
Win32.SYSTEM_PERFORMANCE_INFORMATION perfInfo = Program.HackerWindow.ProcessProvider.Performance;
Win32.PERFORMANCE_INFORMATION info = new Win32.PERFORMANCE_INFORMATION();
Win32.GetPerformanceInfo(ref info, System.Runtime.InteropServices.Marshal.SizeOf(info));
Win32.SYSTEM_CACHE_INFORMATION cacheInfo = new Win32.SYSTEM_CACHE_INFORMATION();
int retLen;
Win32.ZwQuerySystemInformation(Win32.SYSTEM_INFORMATION_CLASS.SystemCacheInformation,
ref cacheInfo, System.Runtime.InteropServices.Marshal.SizeOf(cacheInfo), out retLen);
labelTotalsProcesses.Text = info.ProcessCount.ToString("N0");
labelTotalsThreads.Text = info.ThreadCount.ToString("N0");
labelTotalsHandles.Text = info.HandlesCount.ToString("N0");
labelCCC.Text = Misc.GetNiceSizeName(perfInfo.CommittedPages * _pageSize);
labelCCP.Text = Misc.GetNiceSizeName(perfInfo.PeakCommitment * _pageSize);
labelCCL.Text = Misc.GetNiceSizeName(perfInfo.CommitLimit * _pageSize);
labelPMC.Text = Misc.GetNiceSizeName((_pages - perfInfo.AvailablePages) * _pageSize);
labelPMT.Text = Misc.GetNiceSizeName(_pages * _pageSize);
labelCacheCurrent.Text = Misc.GetNiceSizeName(cacheInfo.SystemCacheWsSize);
labelCachePeak.Text = Misc.GetNiceSizeName(cacheInfo.SystemCacheWsPeakSize);
labelCacheMinimum.Text = Misc.GetNiceSizeName(cacheInfo.SystemCacheWsMinimum * _pageSize);
labelCacheMaximum.Text = Misc.GetNiceSizeName(cacheInfo.SystemCacheWsMaximum * _pageSize);
labelKPPPU.Text = Misc.GetNiceSizeName(perfInfo.PagedPoolPages * _pageSize);
labelKPPVU.Text = Misc.GetNiceSizeName(perfInfo.PagedPoolUsage * _pageSize);
labelKPPA.Text = perfInfo.PagedPoolAllocs.ToString("N0");
labelKPPF.Text = perfInfo.PagedPoolFrees.ToString("N0");
labelKPNPU.Text = Misc.GetNiceSizeName(perfInfo.NonPagedPoolUsage * _pageSize);
labelKPNPA.Text = perfInfo.NonPagedPoolAllocs.ToString("N0");
labelKPNPF.Text = perfInfo.NonPagedPoolFrees.ToString("N0");
labelPFTotal.Text = perfInfo.PageFaults.ToString("N0");
labelPFCOW.Text = perfInfo.CopyOnWriteFaults.ToString("N0");
labelPFTrans.Text = perfInfo.TransitionFaults.ToString("N0");
labelPFCacheTrans.Text = perfInfo.CacheTransitionFaults.ToString("N0");
labelPFDZ.Text = perfInfo.CacheTransitionFaults.ToString("N0");
labelPFCache.Text = cacheInfo.SystemCacheWsFaults.ToString("N0");
labelIOR.Text = perfInfo.IoReadOperationCount.ToString("N0");
labelIORB.Text = Misc.GetNiceSizeName(perfInfo.IoReadTransferCount);
labelIOW.Text = perfInfo.IoWriteOperationCount.ToString("N0");
labelIOWB.Text = Misc.GetNiceSizeName(perfInfo.IoWriteTransferCount);
labelIOO.Text = perfInfo.IoOtherOperationCount.ToString("N0");
labelIOOB.Text = Misc.GetNiceSizeName(perfInfo.IoOtherTransferCount);
labelCPUContextSwitches.Text = perfInfo.ContextSwitches.ToString("N0");
labelCPUInterrupts.Text = Program.HackerWindow.ProcessProvider.ProcessorPerf.InterruptCount.ToString("N0");
labelCPUSystemCalls.Text = perfInfo.SystemCalls.ToString("N0");
}
private void ProcessProvider_Updated()
{
this.BeginInvoke(new MethodInvoker(this.UpdateInfo));
this.BeginInvoke(new MethodInvoker(delegate
{
this.UpdateDeltas();
this.UpdateGraphs();
this.UpdateInfo();
}));
}
private void checkShowOneGraphPerCPU_CheckedChanged(object sender, EventArgs e)
+5
View File
@@ -95,6 +95,11 @@ namespace ProcessHacker
_deltas.Add(key, initialValue);
}
public void SetDelta(TKey key, TValue value)
{
_deltas[key] = value;
}
public TValue Update(TKey key, TValue value)
{
_deltas[key] = _subtractor.Subtract(value, _values[key]);
+5 -14
View File
@@ -32,6 +32,8 @@ namespace ProcessHacker
{
#region Constants
public static string[] SizeUnitNames = { "B", "kB", "MB", "GB", "TB", "PB", "EB" };
public static string[] DangerousNames = { "csrss.exe", "dwm.exe", "lsass.exe", "lsm.exe", "services.exe",
"smss.exe", "wininit.exe", "winlogon.exe" };
@@ -188,17 +190,7 @@ namespace ProcessHacker
/// <returns></returns>
public static string GetNiceSizeName(long size)
{
string[] names = { "B", "kB", "MB", "GB", "TB", "PB", "EB" };
int i = 0;
decimal s = (decimal)size;
while (s > 1024 && i < names.Length)
{
s /= 1024;
i++;
}
return String.Format("{0:f2}", s) + " " + names[i];
return GetNiceSizeName((ulong)size);
}
/// <summary>
@@ -208,17 +200,16 @@ namespace ProcessHacker
/// <returns></returns>
public static string GetNiceSizeName(ulong size)
{
string[] names = { "B", "kB", "MB", "GB", "TB", "PB", "EB" };
int i = 0;
decimal s = (decimal)size;
while (s > 1024 && i < names.Length)
while (s > 1024 && i < SizeUnitNames.Length && i < Properties.Settings.Default.UnitSpecifier)
{
s /= 1024;
i++;
}
return String.Format("{0:f2}", s) + " " + names[i];
return String.Format("{0:f2}", s) + " " + SizeUnitNames[i];
}
/// <summary>
+12
View File
@@ -826,5 +826,17 @@ namespace ProcessHacker.Properties {
this["ShowOneGraphPerCPU"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("6")]
public int UnitSpecifier {
get {
return ((int)(this["UnitSpecifier"]));
}
set {
this["UnitSpecifier"] = value;
}
}
}
}
@@ -203,5 +203,8 @@
<Setting Name="ShowOneGraphPerCPU" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="UnitSpecifier" Type="System.Int32" Scope="User">
<Value Profile="(Default)">6</Value>
</Setting>
</Settings>
</SettingsFile>
@@ -98,31 +98,33 @@ namespace ProcessHacker
Win32.ZwQuerySystemInformation(Win32.SYSTEM_INFORMATION_CLASS.SystemProcessorTimes,
data, data.Size, out retLen);
var newAverages = new Win32.SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION();
var newSums = new Win32.SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION();
// Thanks to:
// http://www.netperf.org/svn/netperf2/trunk/src/netcpu_ntperf.c
// for the critical information:
// "KernelTime needs to be fixed-up; it includes both idle & true kernel time".
// This is why I love free software.
for (int i = 0; i < this.ProcessorPerfArray.Length; i++)
{
this.ProcessorPerfArray[i] = data.ReadStruct<Win32.SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION>(
i);
newAverages.DpcTime += this.ProcessorPerfArray[i].DpcTime
/ this.ProcessorPerfArray.Length;
newAverages.IdleTime += this.ProcessorPerfArray[i].IdleTime
/ this.ProcessorPerfArray.Length;
newAverages.InterruptCount += this.ProcessorPerfArray[i].InterruptCount
/ this.ProcessorPerfArray.Length;
newAverages.InterruptTime += this.ProcessorPerfArray[i].InterruptTime
/ this.ProcessorPerfArray.Length;
newAverages.KernelTime += this.ProcessorPerfArray[i].KernelTime
/ this.ProcessorPerfArray.Length;
newAverages.UserTime += this.ProcessorPerfArray[i].UserTime
/ this.ProcessorPerfArray.Length;
this.ProcessorPerfArray[i] =
data.ReadStruct<Win32.SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION>(i);
this.ProcessorPerfArray[i].KernelTime -= this.ProcessorPerfArray[i].IdleTime +
this.ProcessorPerfArray[i].DpcTime + this.ProcessorPerfArray[i].InterruptTime;
newSums.DpcTime += this.ProcessorPerfArray[i].DpcTime;
newSums.IdleTime += this.ProcessorPerfArray[i].IdleTime;
newSums.InterruptCount += this.ProcessorPerfArray[i].InterruptCount;
newSums.InterruptTime += this.ProcessorPerfArray[i].InterruptTime;
newSums.KernelTime += this.ProcessorPerfArray[i].KernelTime;
newSums.UserTime += this.ProcessorPerfArray[i].UserTime;
}
this.ProcessorPerf = newAverages;
this.ProcessorPerf = newSums;
}
}
private void UpdatePerformance()
public void UpdatePerformance()
{
if (!this.PerformanceEnabled)
return;
@@ -160,7 +162,7 @@ namespace ProcessHacker
{
Win32.SystemProcess proc = procs[0];
proc.Process.KernelTime = this.ProcessorPerf.IdleTime * this.System.NumberOfProcessors;
proc.Process.KernelTime = this.ProcessorPerf.IdleTime;
procs.Remove(0);
procs.Add(0, proc);
}
@@ -172,7 +174,7 @@ namespace ProcessHacker
{
ProcessId = -2,
InheritedFromProcessId = 0,
KernelTime = this.ProcessorPerf.DpcTime * this.System.NumberOfProcessors,
KernelTime = this.ProcessorPerf.DpcTime,
SessionId = -1
}
});
@@ -184,7 +186,7 @@ namespace ProcessHacker
{
ProcessId = -3,
InheritedFromProcessId = 0,
KernelTime = this.ProcessorPerf.InterruptTime * this.System.NumberOfProcessors,
KernelTime = this.ProcessorPerf.InterruptTime,
SessionId = -1
}
});
@@ -358,8 +360,7 @@ namespace ProcessHacker
try
{
newitem.CPUUsage = (float)(newitem.LastTime - item.LastTime) * 100 / sysTime /
this.System.NumberOfProcessors;
newitem.CPUUsage = (float)(newitem.LastTime - item.LastTime) * 100 / (sysTime + otherTime);
if (pid != 0 && newitem.CPUUsage > mostCPUUsage)
{
@@ -412,7 +413,7 @@ namespace ProcessHacker
}
if (thisSysTime != 0)
this.CurrentCPUUsage = (float)(sysTime - otherTime) / sysTime;
this.CurrentCPUUsage = (float)sysTime / (sysTime + otherTime);
Dictionary = newdictionary;
@@ -99,6 +99,12 @@ namespace ProcessHacker.Structs
if (_eatResult || includeFile == "")
throw new ParserException(_fileName, _lineNumber, "String expected (file name)");
_eatResult = EatWhitespace(text, ref i);
string endSemicolon = EatSymbol(text, ref i);
if (_eatResult || endSemicolon != ";")
throw new ParserException(_fileName, _lineNumber, "Expected ';'");
System.IO.FileInfo info = new System.IO.FileInfo(_fileName);
// if the filename contains ':', use the absolute path. otherwise, append it to the
@@ -97,6 +97,9 @@ namespace ProcessHacker
#region Misc.
[DllImport("kernel32.dll")]
public static extern int GetTickCount();
#endregion
#region Processes
@@ -626,6 +629,10 @@ namespace ProcessHacker
public static extern uint ZwQuerySystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass,
ref SYSTEM_BASIC_INFORMATION SystemInformation, int SystemInformationLength, out int ReturnLength);
[DllImport("ntdll.dll", SetLastError = true)]
public static extern uint ZwQuerySystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass,
ref SYSTEM_CACHE_INFORMATION SystemInformation, int SystemInformationLength, out int ReturnLength);
[DllImport("ntdll.dll", SetLastError = true)]
public static extern uint ZwQuerySystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass,
ref SYSTEM_PERFORMANCE_INFORMATION SystemInformation, int SystemInformationLength, out int ReturnLength);
+26 -1
View File
@@ -346,7 +346,7 @@ namespace ProcessHacker
public int HandlesCount;
public int ProcessCount;
public int ThreadCouont;
public int ThreadCount;
}
[StructLayout(LayoutKind.Sequential)]
@@ -623,6 +623,31 @@ namespace ProcessHacker
public byte NumberOfProcessors;
}
[StructLayout(LayoutKind.Sequential)]
public struct SYSTEM_CACHE_INFORMATION
{
/// <summary>
/// The size of the system working set, in bytes.
/// </summary>
public int SystemCacheWsSize;
public int SystemCacheWsPeakSize;
public int SystemCacheWsFaults;
/// <summary>
/// Measured in pages.
/// </summary>
public int SystemCacheWsMinimum;
/// <summary>
/// Measured in pages.
/// </summary>
public int SystemCacheWsMaximum;
public int TransitionSharedPages;
public int TransitionSharedPagesPeak;
public int Reserved1;
public int Reserved2;
}
[StructLayout(LayoutKind.Sequential)]
public struct SYSTEM_HANDLE_INFORMATION
{
+3
View File
@@ -208,6 +208,9 @@
<setting name="ShowOneGraphPerCPU" serializeAs="String">
<value>False</value>
</setting>
<setting name="UnitSpecifier" serializeAs="String">
<value>6</value>
</setting>
</ProcessHacker.Properties.Settings>
</userSettings>
</configuration>
+1 -1
View File
@@ -5,7 +5,7 @@
* wj32.
*/
include "base.txt"
include "base.txt";
typedef int handle;
typedef int NTSTATUS; /* no enum support *yet* */
+1
View File
@@ -34,5 +34,6 @@ Process Hacker is brought to you by the small Process Hacker team:
* wj32 (Project Manager)
* Dean (Developer)
* Plotter
* System Information Window
* Speed improvements in handle filter
* Paul Pacheco (Developer)
@@ -46,6 +46,7 @@ namespace Aga.Controls.Tree
{
Column.Width = _initWidth + args.Location.X - _initLocation.X;
Tree.UpdateView();
Tree.Invalidate();
return true;
}
}