From e36bc2f1075fe50ca8a2bd7a04da47172a71f0f1 Mon Sep 17 00:00:00 2001 From: wj32 Date: Mon, 27 Apr 2009 11:10:41 +0000 Subject: [PATCH] * fixed the tiny gaps at the ends of longdata plotters * added GetBasePriority to process and thread handles * fixed options & process windows not getting initialized git-svn-id: svn://svn.code.sf.net/p/processhacker/code@1175 21ef857c-d57f-4fe0-8362-d861dc6d29cd --- .../Objects/ProcessHandle.cs | 8 ++++ .../Objects/ThreadHandle.cs | 16 +++++++ trunk/ProcessHacker/Components/Plotter.cs | 8 ++-- .../Forms/OptionsWindow.Designer.cs | 1 - trunk/ProcessHacker/Forms/OptionsWindow.cs | 17 +++++-- .../Forms/ProcessWindow.Designer.cs | 1 - trunk/ProcessHacker/Forms/ProcessWindow.cs | 17 +++++-- .../ProcessHacker/Providers/ThreadProvider.cs | 44 +++++++++++++------ trunk/ProcessHacker/UI/Icons/PlotterIcon.cs | 2 +- 9 files changed, 85 insertions(+), 29 deletions(-) diff --git a/trunk/ProcessHacker.Native/Objects/ProcessHandle.cs b/trunk/ProcessHacker.Native/Objects/ProcessHandle.cs index fc1b604da..a81b15d5a 100644 --- a/trunk/ProcessHacker.Native/Objects/ProcessHandle.cs +++ b/trunk/ProcessHacker.Native/Objects/ProcessHandle.cs @@ -334,6 +334,14 @@ namespace ProcessHacker.Native.Objects Win32.ThrowLastError(); } + /// + /// Gets the base priority of the process. + /// + public int GetBasePriority() + { + return this.GetInformationInt32(ProcessInformationClass.ProcessBasePriority); + } + /// /// Gets the process' basic information through the undocumented Native API function /// NtQueryInformationProcess. This function requires the PROCESS_QUERY_LIMITED_INFORMATION diff --git a/trunk/ProcessHacker.Native/Objects/ThreadHandle.cs b/trunk/ProcessHacker.Native/Objects/ThreadHandle.cs index b48676753..708f81fef 100644 --- a/trunk/ProcessHacker.Native/Objects/ThreadHandle.cs +++ b/trunk/ProcessHacker.Native/Objects/ThreadHandle.cs @@ -89,6 +89,14 @@ namespace ProcessHacker.Native.Objects Win32.ThrowLastError(); } + /// + /// Gets the thread's base priority. + /// + public int GetBasePriority() + { + return this.GetInformationInt32(ThreadInformationClass.ThreadBasePriority); + } + /// /// Gets the thread's basic information. /// @@ -225,6 +233,14 @@ namespace ProcessHacker.Native.Objects return this.GetInformationInt32(ThreadInformationClass.ThreadPagePriority); } + /// + /// Gets the thread's priority. + /// + public int GetPriority() + { + return this.GetInformationInt32(ThreadInformationClass.ThreadPriority); + } + /// /// Gets the thread's priority level. /// diff --git a/trunk/ProcessHacker/Components/Plotter.cs b/trunk/ProcessHacker/Components/Plotter.cs index d2441f580..900687bca 100644 --- a/trunk/ProcessHacker/Components/Plotter.cs +++ b/trunk/ProcessHacker/Components/Plotter.cs @@ -265,10 +265,10 @@ namespace ProcessHacker.Components // restrict scaling to the currently visible data points int maxIndex = this.Width / this.EffectiveMoveStep; - for (int i = 0; i < _longData1.Count && i < maxIndex; i++) + for (int i = 0; i < _longData1.Count && i <= maxIndex; i++) if (_longData1[i] > max) max = _longData1[i]; - for (int i = 0; i < _longData2.Count && i < maxIndex; i++) + for (int i = 0; i < _longData2.Count && i <= maxIndex; i++) if (_longData2[i] > max) max = _longData2[i]; @@ -279,7 +279,7 @@ namespace ProcessHacker.Components _data1 = new List(); _data2 = new List(); - for (int i = 0; i < _longData1.Count && i < maxIndex; i++) + for (int i = 0; i < _longData1.Count && i <= maxIndex; i++) { if (max != 0) _data1.Add((float)_longData1[i] / max); @@ -287,7 +287,7 @@ namespace ProcessHacker.Components _data1.Add(0); } - for (int i = 0; i < _longData2.Count && i < maxIndex; i++) + for (int i = 0; i < _longData2.Count && i <= maxIndex; i++) { if (max != 0) _data2.Add((float)_longData2[i] / max); diff --git a/trunk/ProcessHacker/Forms/OptionsWindow.Designer.cs b/trunk/ProcessHacker/Forms/OptionsWindow.Designer.cs index 13a126bca..9c0e6a9a3 100644 --- a/trunk/ProcessHacker/Forms/OptionsWindow.Designer.cs +++ b/trunk/ProcessHacker/Forms/OptionsWindow.Designer.cs @@ -949,7 +949,6 @@ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Options"; this.Load += new System.EventHandler(this.OptionsWindow_Load); - this.Paint += new System.Windows.Forms.PaintEventHandler(this.OptionsWindow_Paint); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OptionsWindow_FormClosing); ((System.ComponentModel.ISupportInitialize)(this.textUpdateInterval)).EndInit(); this.tabControl.ResumeLayout(false); diff --git a/trunk/ProcessHacker/Forms/OptionsWindow.cs b/trunk/ProcessHacker/Forms/OptionsWindow.cs index b4819c6e4..f5b969198 100644 --- a/trunk/ProcessHacker/Forms/OptionsWindow.cs +++ b/trunk/ProcessHacker/Forms/OptionsWindow.cs @@ -75,14 +75,23 @@ namespace ProcessHacker } } - private void OptionsWindow_Paint(object sender, PaintEventArgs e) + protected override void WndProc(ref Message m) { - if (_isFirstPaint) + switch (m.Msg) { - this.LoadStage1(); + case (int)WindowMessage.Paint: + { + if (_isFirstPaint) + { + this.LoadStage1(); + } + + _isFirstPaint = false; + } + break; } - _isFirstPaint = false; + base.WndProc(ref m); } private void LoadStage1() diff --git a/trunk/ProcessHacker/Forms/ProcessWindow.Designer.cs b/trunk/ProcessHacker/Forms/ProcessWindow.Designer.cs index a7b9cccd6..284aa7ab1 100644 --- a/trunk/ProcessHacker/Forms/ProcessWindow.Designer.cs +++ b/trunk/ProcessHacker/Forms/ProcessWindow.Designer.cs @@ -1656,7 +1656,6 @@ this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "Process"; this.Load += new System.EventHandler(this.ProcessWindow_Load); - this.Paint += new System.Windows.Forms.PaintEventHandler(this.ProcessWindow_Paint); this.SizeChanged += new System.EventHandler(this.ProcessWindow_SizeChanged); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ProcessWindow_FormClosing); this.tabControl.ResumeLayout(false); diff --git a/trunk/ProcessHacker/Forms/ProcessWindow.cs b/trunk/ProcessHacker/Forms/ProcessWindow.cs index 933581af1..d9d598767 100644 --- a/trunk/ProcessHacker/Forms/ProcessWindow.cs +++ b/trunk/ProcessHacker/Forms/ProcessWindow.cs @@ -151,13 +151,22 @@ namespace ProcessHacker SymbolProvider.ShowWarning(this, false); } - private void ProcessWindow_Paint(object sender, PaintEventArgs e) + protected override void WndProc(ref Message m) { - if (_isFirstPaint) + switch (m.Msg) { - _isFirstPaint = false; - this.LoadStage1(); + case (int)WindowMessage.Paint: + { + if (_isFirstPaint) + { + _isFirstPaint = false; + this.LoadStage1(); + } + } + break; } + + base.WndProc(ref m); } private void FixTabs() diff --git a/trunk/ProcessHacker/Providers/ThreadProvider.cs b/trunk/ProcessHacker/Providers/ThreadProvider.cs index 3e71e97ae..33414c7bd 100644 --- a/trunk/ProcessHacker/Providers/ThreadProvider.cs +++ b/trunk/ProcessHacker/Providers/ThreadProvider.cs @@ -78,8 +78,11 @@ namespace ProcessHacker this.Name = this.GetType().Name; _pid = pid; - if (!Program.ProcessesWithThreads.ContainsKey(_pid)) - Program.ProcessesWithThreads.Add(_pid, null); + lock (Program.ProcessesWithThreads) + { + if (!Program.ProcessesWithThreads.ContainsKey(_pid)) + Program.ProcessesWithThreads.Add(_pid, null); + } this.ProviderUpdate += new ProviderUpdateOnce(UpdateOnce); this.Disposed += ThreadProvider_Disposed; @@ -93,8 +96,10 @@ namespace ProcessHacker // Needed (maybe) to display the EULA Win32.SymbolServerSetOptions(SymbolServerOption.Unattended, 0); } - catch - { } + catch (Exception ex) + { + Logging.Log(ex); + } // start loading symbols; avoid the UI blocking on the dbghelp call lock WorkQueue.GlobalQueueWorkItem(new Action(() => @@ -120,8 +125,10 @@ namespace ProcessHacker { _symbols.LoadModule(module.FileName, module.BaseAddress.ToInt32(), module.Size); } - catch - { } + catch (Exception ex) + { + Logging.Log(ex); + } } } } @@ -137,13 +144,17 @@ namespace ProcessHacker { _symbols.LoadModule(module.FileName, module.BaseAddress); } - catch - { } + catch (Exception ex) + { + Logging.Log(ex); + } } } } - catch - { } + catch (Exception ex) + { + Logging.Log(ex); + } lock (_moduleLoadCompletedEvent) { @@ -152,8 +163,10 @@ namespace ProcessHacker } })); } - catch - { } + catch (Exception ex) + { + Logging.Log(ex); + } } private void ThreadProvider_Disposed(IProvider provider) @@ -167,8 +180,11 @@ namespace ProcessHacker lock (_moduleLoadCompletedEvent) _moduleLoadCompletedEvent.Close(); - if (Program.ProcessesWithThreads.ContainsKey(_pid)) - Program.ProcessesWithThreads.Remove(_pid); + lock (Program.ProcessesWithThreads) + { + if (Program.ProcessesWithThreads.ContainsKey(_pid)) + Program.ProcessesWithThreads.Remove(_pid); + } foreach (int tid in this.Dictionary.Keys) { diff --git a/trunk/ProcessHacker/UI/Icons/PlotterIcon.cs b/trunk/ProcessHacker/UI/Icons/PlotterIcon.cs index 48e3310da..336a7b6a3 100644 --- a/trunk/ProcessHacker/UI/Icons/PlotterIcon.cs +++ b/trunk/ProcessHacker/UI/Icons/PlotterIcon.cs @@ -83,7 +83,7 @@ namespace ProcessHacker using (Bitmap bm = new Bitmap(_width, _height)) { _plotter.Draw(); - _plotter.DrawToBitmap(bm, new Rectangle(new Point(0, 0), bm.Size)); + _plotter.DrawToBitmap(bm, new Rectangle(new Point(0, 0), _plotter.Size)); newIcon = Icon.FromHandle(bm.GetHicon()); }