From 1cdb716ebcd800789a7636f0c19d1e22211fa855 Mon Sep 17 00:00:00 2001 From: wj32 Date: Mon, 13 Apr 2009 08:59:11 +0000 Subject: [PATCH] added dbghelp.dll warning git-svn-id: svn://svn.code.sf.net/p/processhacker/code@1053 21ef857c-d57f-4fe0-8362-d861dc6d29cd --- trunk/ProcessHacker/Forms/OptionsWindow.cs | 9 +- trunk/ProcessHacker/Forms/ProcessWindow.cs | 2 + trunk/ProcessHacker/Program.cs | 2 - .../Properties/Settings.Designer.cs | 12 +++ .../Properties/Settings.settings | 3 + .../ProcessHacker/Providers/ThreadProvider.cs | 2 +- trunk/ProcessHacker/Symbols/Symbols.cs | 86 ++++++++++++++++++- trunk/ProcessHacker/app.config | 3 + 8 files changed, 112 insertions(+), 7 deletions(-) diff --git a/trunk/ProcessHacker/Forms/OptionsWindow.cs b/trunk/ProcessHacker/Forms/OptionsWindow.cs index 2c5c0fff0..821741f8c 100644 --- a/trunk/ProcessHacker/Forms/OptionsWindow.cs +++ b/trunk/ProcessHacker/Forms/OptionsWindow.cs @@ -34,6 +34,7 @@ namespace ProcessHacker { public partial class OptionsWindow : Form { + private string _oldDbghelp; private string _oldTaskMgrDebugger; private bool _autoClosed = false; private Font _font; @@ -130,7 +131,7 @@ namespace ProcessHacker try { - textDbghelpPath.Text = Properties.Settings.Default.DbgHelpPath; + _oldDbghelp = textDbghelpPath.Text = Properties.Settings.Default.DbgHelpPath; textSearchPath.Text = Properties.Settings.Default.DbgHelpSearchPath; checkUndecorate.Checked = (Symbols.Options & Win32.SYMBOL_OPTIONS.UndName) != 0; } @@ -357,7 +358,11 @@ namespace ProcessHacker Program.SharedThreadProvider.Interval = Properties.Settings.Default.RefreshInterval; Program.SecondarySharedThreadProvider.Interval = Properties.Settings.Default.RefreshInterval; - Properties.Settings.Default.Save(); + Properties.Settings.Default.Save(); + + if (_oldDbghelp != textDbghelpPath.Text) + MessageBox.Show("One or more options you have changed require a restart of Process Hacker.", + "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Information); } private void ApplySettings() diff --git a/trunk/ProcessHacker/Forms/ProcessWindow.cs b/trunk/ProcessHacker/Forms/ProcessWindow.cs index 99ed72c3c..032ff511a 100644 --- a/trunk/ProcessHacker/Forms/ProcessWindow.cs +++ b/trunk/ProcessHacker/Forms/ProcessWindow.cs @@ -200,6 +200,8 @@ namespace ProcessHacker this.BeginInvoke(new MethodInvoker(this.LoadStage2)); }), null, 100, System.Threading.Timeout.Infinite); + + Symbols.ShowWarning(this, false); } private void LoadStage2() diff --git a/trunk/ProcessHacker/Program.cs b/trunk/ProcessHacker/Program.cs index 9636a04b3..fbf81a844 100644 --- a/trunk/ProcessHacker/Program.cs +++ b/trunk/ProcessHacker/Program.cs @@ -183,8 +183,6 @@ namespace ProcessHacker catch { } - ThreadPool.SetMaxThreads(3, 3); - Win32.CreateMutex(0, false, "Global\\ProcessHackerMutex"); if (Environment.OSVersion.Version.Major <= 5) diff --git a/trunk/ProcessHacker/Properties/Settings.Designer.cs b/trunk/ProcessHacker/Properties/Settings.Designer.cs index dc042dd6d..1a978141f 100644 --- a/trunk/ProcessHacker/Properties/Settings.Designer.cs +++ b/trunk/ProcessHacker/Properties/Settings.Designer.cs @@ -1284,5 +1284,17 @@ namespace ProcessHacker.Properties { this["DbgHelpUndecorate"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool DbgHelpWarningShown { + get { + return ((bool)(this["DbgHelpWarningShown"])); + } + set { + this["DbgHelpWarningShown"] = value; + } + } } } diff --git a/trunk/ProcessHacker/Properties/Settings.settings b/trunk/ProcessHacker/Properties/Settings.settings index c7507964c..b0af88ecd 100644 --- a/trunk/ProcessHacker/Properties/Settings.settings +++ b/trunk/ProcessHacker/Properties/Settings.settings @@ -317,5 +317,8 @@ True + + False + \ No newline at end of file diff --git a/trunk/ProcessHacker/Providers/ThreadProvider.cs b/trunk/ProcessHacker/Providers/ThreadProvider.cs index 365eb926b..1b16f0a61 100644 --- a/trunk/ProcessHacker/Providers/ThreadProvider.cs +++ b/trunk/ProcessHacker/Providers/ThreadProvider.cs @@ -81,7 +81,7 @@ namespace ProcessHacker _processHandle = new Win32.ProcessHandle(_pid, Program.MinProcessQueryRights); _symbols = new Symbols(_processHandle); - Symbols.Options = Win32.SYMBOL_OPTIONS.DeferredLoads | + Symbols.Options = Win32.SYMBOL_OPTIONS.DeferredLoads | (Properties.Settings.Default.DbgHelpUndecorate ? Win32.SYMBOL_OPTIONS.UndName : 0); if (Properties.Settings.Default.DbgHelpSearchPath != "") diff --git a/trunk/ProcessHacker/Symbols/Symbols.cs b/trunk/ProcessHacker/Symbols/Symbols.cs index 2461f009e..0f3d03d62 100644 --- a/trunk/ProcessHacker/Symbols/Symbols.cs +++ b/trunk/ProcessHacker/Symbols/Symbols.cs @@ -22,9 +22,11 @@ using System; using System.Collections.Generic; -using System.Text; +using System.IO; using System.Runtime.InteropServices; using System.Threading; +using System.Windows.Forms; +using Microsoft.Samples; namespace ProcessHacker { @@ -134,6 +136,86 @@ namespace ProcessHacker } } + public static void ShowWarning(IWin32Window window, bool force) + { + if (Properties.Settings.Default.DbgHelpWarningShown && !force) + return; + + try + { + var modules = Win32.ProcessHandle.FromHandle(Program.CurrentProcess).GetModules(); + + foreach (var module in modules) + { + if (module.FileName.ToLowerInvariant().EndsWith("dbghelp.dll")) + { + FileInfo fi = new FileInfo(module.FileName); + + if (!File.Exists(fi.DirectoryName + "\\symsrv.dll")) + { + if (!force) + Properties.Settings.Default.DbgHelpWarningShown = true; + + if (Program.WindowsVersion != WindowsVersion.XP) + { + TaskDialog td = new TaskDialog(); + bool verificationChecked; + + td.CommonButtons = TaskDialogCommonButtons.Ok; + td.WindowTitle = "Process Hacker"; + td.MainIcon = TaskDialogIcon.Warning; + td.MainInstruction = "Microsoft Symbol Server not supported"; + td.Content = "The Microsoft Symbol Server is not supported by your version of dbghelp.dll " + + "or could not be loaded. " + + "To ensure you have the latest version of dbghelp.dll, download " + + "Debugging " + + "Tools for Windows and configure Process Hacker to " + + "use its version of dbghelp.dll. If you have the latest version of dbghelp.dll, " + + "ensure that symsrv.dll resides in the same directory as dbghelp.dll."; + td.EnableHyperlinks = true; + td.Callback = (taskDialog, args, callbackData) => + { + if (args.Notification == TaskDialogNotification.HyperlinkClicked) + { + try + { + System.Diagnostics.Process.Start( + "http://www.microsoft.com/whdc/devtools/debugging/default.mspx"); + } + catch + { } + + return true; + } + + return false; + }; + td.VerificationText = force ? null : "Do not display this warning again"; + td.VerificationFlagChecked = true; + + td.Show(window, out verificationChecked); + + if (!force) + Properties.Settings.Default.DbgHelpWarningShown = verificationChecked; + } + else + { + MessageBox.Show(window, "The Microsoft Symbol Server is not supported by your version of dbghelp.dll " + + "or could not be loaded. To ensure you have the latest version of dbghelp.dll, download " + + "Debugging Tools for Windows and configure Process Hacker to use its version of dbghelp.dll. " + + "If you have the latest version of dbghelp.dll, ensure that symsrv.dll resides in the same " + + "directory as dbghelp.dll", "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + } + } + + break; + } + } + } + catch + { } + } + public void LoadModule(string fileName, long baseAddress) { this.LoadModule(fileName, baseAddress, 0); @@ -271,7 +353,7 @@ namespace ProcessHacker return "0x" + address.ToString("x8"); } - System.IO.FileInfo fi = new System.IO.FileInfo(modFileName); + FileInfo fi = new FileInfo(modFileName); fileName = fi.FullName; diff --git a/trunk/ProcessHacker/app.config b/trunk/ProcessHacker/app.config index 530899770..4d0af2555 100644 --- a/trunk/ProcessHacker/app.config +++ b/trunk/ProcessHacker/app.config @@ -322,6 +322,9 @@ True + + False + \ No newline at end of file