From 1d2cfbd9461983738150ebe51eb9d0bc02992435 Mon Sep 17 00:00:00 2001 From: wj32 Date: Sat, 17 Oct 2009 02:12:36 +0000 Subject: [PATCH] * ToLower -> ToLowerInvariant * InvariantCultureIgnoreCase -> OrdinalIgnoreCase * other optimizations git-svn-id: svn://svn.code.sf.net/p/processhacker/code@2245 21ef857c-d57f-4fe0-8362-d861dc6d29cd --- trunk/ProcessHacker.Common/BaseConverter.cs | 2 +- trunk/ProcessHacker.Native/FileUtils.cs | 2 +- .../ProcessHacker.Native/NativeTypeFactory.cs | 8 +++--- trunk/ProcessHacker.Native/NativeUtils.cs | 27 +++++++++---------- .../Objects/ProcessHandle.cs | 6 ++--- trunk/ProcessHacker.Native/Security/Sid.cs | 17 ++++++++++++ trunk/ProcessHacker/Common/PhUtils.cs | 2 +- trunk/ProcessHacker/Components/HandleList.cs | 6 ++--- trunk/ProcessHacker/Components/ModuleList.cs | 11 ++++---- .../ProcessTree/ProcessToolTipProvider.cs | 6 ++--- .../Components/ProcessTree/ProcessTree.cs | 2 +- .../ProcessTree/ProcessTreeModel.cs | 2 +- trunk/ProcessHacker/Components/ThreadList.cs | 2 +- .../Components/TokenProperties.cs | 2 +- trunk/ProcessHacker/Forms/HackerWindow.cs | 2 +- trunk/ProcessHacker/Forms/OptionsWindow.cs | 10 +++---- trunk/ProcessHacker/Forms/ResultsWindow.cs | 2 +- trunk/ProcessHacker/Forms/RunWindow.cs | 2 +- .../Forms/UpdaterDownloadWindow.cs | 2 +- trunk/ProcessHacker/Program/ExtendedCmd.cs | 4 +-- trunk/ProcessHacker/Program/Program.cs | 2 +- trunk/ProcessHacker/Program/Save.cs | 2 +- .../Providers/ProcessSystemProvider.cs | 2 +- trunk/ProcessHacker/Structs/StructParser.cs | 2 +- trunk/ProcessHacker/UI/Async/HandleFilter.cs | 8 +++--- 25 files changed, 74 insertions(+), 59 deletions(-) diff --git a/trunk/ProcessHacker.Common/BaseConverter.cs b/trunk/ProcessHacker.Common/BaseConverter.cs index 52bd7687d..6f3708cba 100644 --- a/trunk/ProcessHacker.Common/BaseConverter.cs +++ b/trunk/ProcessHacker.Common/BaseConverter.cs @@ -86,7 +86,7 @@ namespace ProcessHacker.Common length -= 1; } - number = ReverseString(number).ToLower(); + number = ReverseString(number).ToLowerInvariant(); for (int i = 0; i < length; i++) { diff --git a/trunk/ProcessHacker.Native/FileUtils.cs b/trunk/ProcessHacker.Native/FileUtils.cs index a6e27fe17..01d0d5c41 100644 --- a/trunk/ProcessHacker.Native/FileUtils.cs +++ b/trunk/ProcessHacker.Native/FileUtils.cs @@ -132,7 +132,7 @@ namespace ProcessHacker.Native bool alreadyCanonicalized = false; // If the path starts with "\SystemRoot", we can replace it with C:\ (or whatever it is). - if (fileName.ToLower().StartsWith("\\systemroot")) + if (fileName.StartsWith("\\systemroot", StringComparison.OrdinalIgnoreCase)) { fileName = System.IO.Path.GetFullPath(Environment.SystemDirectory + "\\.." + fileName.Substring(11)); alreadyCanonicalized = true; diff --git a/trunk/ProcessHacker.Native/NativeTypeFactory.cs b/trunk/ProcessHacker.Native/NativeTypeFactory.cs index ea165d020..6bec6bb77 100644 --- a/trunk/ProcessHacker.Native/NativeTypeFactory.cs +++ b/trunk/ProcessHacker.Native/NativeTypeFactory.cs @@ -510,15 +510,15 @@ namespace ProcessHacker.Native { foreach (string value in Enum.GetNames(typeof(ObjectType))) { - if (string.Equals(value, typeName, StringComparison.InvariantCultureIgnoreCase)) + if (value.Equals(typeName, StringComparison.OrdinalIgnoreCase)) return (ObjectType)Enum.Parse(typeof(ObjectType), value); } - if (string.Equals(typeName, "ALPC Port", StringComparison.InvariantCultureIgnoreCase)) + if (string.Equals(typeName, "ALPC Port", StringComparison.OrdinalIgnoreCase)) return ObjectType.AlpcPort; - if (string.Equals(typeName, "Port", StringComparison.InvariantCultureIgnoreCase)) + if (string.Equals(typeName, "Port", StringComparison.OrdinalIgnoreCase)) return ObjectType.AlpcPort; - if (string.Equals(typeName, "WaitablePort", StringComparison.InvariantCultureIgnoreCase)) + if (string.Equals(typeName, "WaitablePort", StringComparison.OrdinalIgnoreCase)) return ObjectType.AlpcPort; throw new NotSupportedException(); diff --git a/trunk/ProcessHacker.Native/NativeUtils.cs b/trunk/ProcessHacker.Native/NativeUtils.cs index 50db057ac..1e67aa963 100644 --- a/trunk/ProcessHacker.Native/NativeUtils.cs +++ b/trunk/ProcessHacker.Native/NativeUtils.cs @@ -2,6 +2,7 @@ using ProcessHacker.Native.Api; using ProcessHacker.Native.Objects; using System.Runtime.InteropServices; +using ProcessHacker.Native.Security; namespace ProcessHacker.Native { @@ -171,23 +172,21 @@ namespace ProcessHacker.Native public static string FormatNativeKeyName(string nativeKeyName) { - const string hklmString = "\\registry\\machine"; - const string hkcrString = "\\registry\\machine\\software\\classes"; - string hkcuString = "\\registry\\user\\" + - System.Security.Principal.WindowsIdentity.GetCurrent().User.ToString().ToLower(); - string hkcucrString = "\\registry\\user\\" + - System.Security.Principal.WindowsIdentity.GetCurrent().User.ToString().ToLower() + "_classes"; - const string hkuString = "\\registry\\user"; + const string hklmString = @"\REGISTRY\MACHINE"; + const string hkcrString = @"\REGISTRY\MACHINE\SOFTWARE\CLASSES"; + string hkcuString = @"\REGISTRY\USER\" + Sid.CurrentUser.StringSid; + string hkcucrString = @"\REGISTRY\USER\" + Sid.CurrentUser.StringSid + "_Classes"; + const string hkuString = @"\REGISTRY\USER"; - if (nativeKeyName.ToLower().StartsWith(hkcrString)) + if (nativeKeyName.StartsWith(hkcrString, StringComparison.OrdinalIgnoreCase)) return "HKCR" + nativeKeyName.Substring(hkcrString.Length); - else if (nativeKeyName.ToLower().StartsWith(hklmString)) + else if (nativeKeyName.StartsWith(hklmString, StringComparison.OrdinalIgnoreCase)) return "HKLM" + nativeKeyName.Substring(hklmString.Length); - else if (nativeKeyName.ToLower().StartsWith(hkcucrString)) - return "HKCU\\Software\\Classes" + nativeKeyName.Substring(hkcucrString.Length); - else if (nativeKeyName.ToLower().StartsWith(hkcuString)) + else if (nativeKeyName.StartsWith(hkcucrString, StringComparison.OrdinalIgnoreCase)) + return @"HKCU\Software\Classes" + nativeKeyName.Substring(hkcucrString.Length); + else if (nativeKeyName.StartsWith(hkcuString, StringComparison.OrdinalIgnoreCase)) return "HKCU" + nativeKeyName.Substring(hkcuString.Length); - else if (nativeKeyName.ToLower().StartsWith(hkuString)) + else if (nativeKeyName.StartsWith(hkuString, StringComparison.OrdinalIgnoreCase)) return "HKU" + nativeKeyName.Substring(hkuString.Length); else return nativeKeyName; @@ -245,7 +244,7 @@ namespace ProcessHacker.Native foreach (var obj in objects) { - if (obj.Name.Equals(lastPart, StringComparison.InvariantCultureIgnoreCase)) + if (obj.Name.Equals(lastPart, StringComparison.OrdinalIgnoreCase)) return true; } diff --git a/trunk/ProcessHacker.Native/Objects/ProcessHandle.cs b/trunk/ProcessHacker.Native/Objects/ProcessHandle.cs index b7394a847..b137c22d9 100644 --- a/trunk/ProcessHacker.Native/Objects/ProcessHandle.cs +++ b/trunk/ProcessHacker.Native/Objects/ProcessHandle.cs @@ -465,7 +465,7 @@ namespace ProcessHacker.Native.Objects foreach (var process in processes.Values) { - if (string.Equals(process.Name, processName, StringComparison.InvariantCultureIgnoreCase)) + if (string.Equals(process.Name, processName, StringComparison.OrdinalIgnoreCase)) { try { @@ -1633,9 +1633,9 @@ namespace ProcessHacker.Native.Objects string fileName = FileUtils.GetFileName(this.GetImageFileName()); - if (fileName.ToLower().StartsWith(Environment.SystemDirectory.ToLower())) + if (fileName.StartsWith(Environment.SystemDirectory, StringComparison.OrdinalIgnoreCase)) { - string baseName = fileName.Remove(0, Environment.SystemDirectory.Length).TrimStart('\\').ToLower(); + string baseName = fileName.Remove(0, Environment.SystemDirectory.Length).TrimStart('\\').ToLowerInvariant(); switch (baseName) { diff --git a/trunk/ProcessHacker.Native/Security/Sid.cs b/trunk/ProcessHacker.Native/Security/Sid.cs index c9419224e..b871190cf 100644 --- a/trunk/ProcessHacker.Native/Security/Sid.cs +++ b/trunk/ProcessHacker.Native/Security/Sid.cs @@ -41,6 +41,23 @@ namespace ProcessHacker.Native.Security private static readonly byte[] _nonUniqueAuthority = { 0, 0, 0, 0, 0, 4 }; private static readonly byte[] _ntAuthority = { 0, 0, 0, 0, 0, 5 }; private static readonly byte[] _resourceManagerAuthority = { 0, 0, 0, 0, 0, 9 }; + private static Sid _currentUser; + + public static Sid CurrentUser + { + get + { + Sid currentUser = _currentUser; + + if (currentUser == null) + { + using (var thandle = TokenHandle.OpenCurrentPrimary(TokenAccess.Query)) + _currentUser = currentUser = thandle.GetUser(); + } + + return currentUser; + } + } public static Sid FromName(string name) { diff --git a/trunk/ProcessHacker/Common/PhUtils.cs b/trunk/ProcessHacker/Common/PhUtils.cs index be58b49e9..48b53f9f2 100644 --- a/trunk/ProcessHacker/Common/PhUtils.cs +++ b/trunk/ProcessHacker/Common/PhUtils.cs @@ -100,7 +100,7 @@ namespace ProcessHacker.Common { if ((Environment.SystemDirectory + "\\" + s).Equals( FileUtils.GetFileName(FileUtils.GetFileName(phandle.GetImageFileName())), - StringComparison.InvariantCultureIgnoreCase)) + StringComparison.OrdinalIgnoreCase)) { return true; } diff --git a/trunk/ProcessHacker/Components/HandleList.cs b/trunk/ProcessHacker/Components/HandleList.cs index 1a599c3b4..fe2d460f3 100644 --- a/trunk/ProcessHacker/Components/HandleList.cs +++ b/trunk/ProcessHacker/Components/HandleList.cs @@ -66,7 +66,7 @@ namespace ProcessHacker.Components window.HandlePropertiesCallback += (control, name, typeName) => { - switch (typeName.ToLower()) + switch (typeName.ToLowerInvariant()) { // Objects with separate property windows: case "file": @@ -78,12 +78,12 @@ namespace ProcessHacker.Components Button b = new Button(); b.FlatStyle = FlatStyle.System; - b.Text = "Properties..."; + b.Text = "Properties"; b.Click += (sender, e) => { try { - switch (typeName.ToLower()) + switch (typeName.ToLowerInvariant()) { case "file": { diff --git a/trunk/ProcessHacker/Components/ModuleList.cs b/trunk/ProcessHacker/Components/ModuleList.cs index 8d4e1d266..28e6eeda7 100644 --- a/trunk/ProcessHacker/Components/ModuleList.cs +++ b/trunk/ProcessHacker/Components/ModuleList.cs @@ -175,7 +175,6 @@ namespace ProcessHacker.Components _mainModule = FileUtils.GetFileName(phandle.GetMainModule().FileName); } - _mainModule = _mainModule.ToLower(); SortedListViewComparer comparer = (SortedListViewComparer) (listModules.ListViewItemSorter = new SortedListViewComparer(listModules) { @@ -279,7 +278,7 @@ namespace ProcessHacker.Components litem.Tag = item; litem.NormalColor = this.GetModuleColor(item); - if (item.FileName.Equals(_mainModule, StringComparison.InvariantCultureIgnoreCase)) + if (item.FileName.Equals(_mainModule, StringComparison.OrdinalIgnoreCase)) litem.Font = new System.Drawing.Font(litem.Font, System.Drawing.FontStyle.Bold); lock (_needsAdd) @@ -487,7 +486,7 @@ namespace ProcessHacker.Components // If we didn't find the service name, use the driver base name. if (serviceName == null) { - if (moduleItem.Name.ToLower().EndsWith(".sys")) + if (moduleItem.Name.EndsWith(".sys", StringComparison.OrdinalIgnoreCase)) serviceName = moduleItem.Name.Remove(moduleItem.Name.Length - 4, 4); else serviceName = moduleItem.Name; @@ -613,7 +612,7 @@ namespace ProcessHacker.Components public ModuleListComparer(string mainModule) { - _mainModule = mainModule.ToLower(); + _mainModule = mainModule; } public int Compare(ListViewItem x, ListViewItem y, int column) @@ -621,9 +620,9 @@ namespace ProcessHacker.Components ModuleItem mx = (ModuleItem)x.Tag; ModuleItem my = (ModuleItem)y.Tag; - if (mx.FileName.Equals(_mainModule, StringComparison.InvariantCultureIgnoreCase)) + if (mx.FileName.Equals(_mainModule, StringComparison.OrdinalIgnoreCase)) return -1; - if (my.FileName.Equals(_mainModule, StringComparison.InvariantCultureIgnoreCase)) + if (my.FileName.Equals(_mainModule, StringComparison.OrdinalIgnoreCase)) return 1; return 0; diff --git a/trunk/ProcessHacker/Components/ProcessTree/ProcessToolTipProvider.cs b/trunk/ProcessHacker/Components/ProcessTree/ProcessToolTipProvider.cs index a8a7eb9fd..195c9a62b 100644 --- a/trunk/ProcessHacker/Components/ProcessTree/ProcessToolTipProvider.cs +++ b/trunk/ProcessHacker/Components/ProcessTree/ProcessToolTipProvider.cs @@ -90,7 +90,7 @@ namespace ProcessHacker if (pNode.ProcessItem.FileName != null && pNode.ProcessItem.FileName.Equals(Environment.SystemDirectory + "\\rundll32.exe", - StringComparison.InvariantCultureIgnoreCase) && + StringComparison.OrdinalIgnoreCase) && pNode.ProcessItem.CmdLine != null) { try @@ -118,7 +118,7 @@ namespace ProcessHacker if (pNode.ProcessItem.FileName != null && pNode.ProcessItem.FileName.Equals(Environment.SystemDirectory + "\\dllhost.exe", - StringComparison.InvariantCultureIgnoreCase) && + StringComparison.OrdinalIgnoreCase) && pNode.ProcessItem.CmdLine != null) { try @@ -198,7 +198,7 @@ namespace ProcessHacker else if (pNode.ProcessItem.VerifyResult != VerifyResult.NoSignature) otherNotes += "\n Signature present but invalid."; - if (Program.ImposterNames.Contains(pNode.Name.ToLower()) && + if (Program.ImposterNames.Contains(pNode.Name.ToLowerInvariant()) && pNode.ProcessItem.VerifyResult != VerifyResult.Trusted && pNode.ProcessItem.VerifyResult != VerifyResult.TrustedInstaller && pNode.ProcessItem.VerifyResult != VerifyResult.Unknown) diff --git a/trunk/ProcessHacker/Components/ProcessTree/ProcessTree.cs b/trunk/ProcessHacker/Components/ProcessTree/ProcessTree.cs index 4a5df2524..13cbe2b92 100644 --- a/trunk/ProcessHacker/Components/ProcessTree/ProcessTree.cs +++ b/trunk/ProcessHacker/Components/ProcessTree/ProcessTree.cs @@ -277,7 +277,7 @@ namespace ProcessHacker return Settings.Instance.ColorJobProcesses; else if (Settings.Instance.UseColorPackedProcesses && Settings.Instance.VerifySignatures && - Program.ImposterNames.Contains(p.Name.ToLower()) && + Program.ImposterNames.Contains(p.Name.ToLowerInvariant()) && p.VerifyResult != VerifyResult.Trusted && p.VerifyResult != VerifyResult.TrustedInstaller && p.VerifyResult != VerifyResult.Unknown && diff --git a/trunk/ProcessHacker/Components/ProcessTree/ProcessTreeModel.cs b/trunk/ProcessHacker/Components/ProcessTree/ProcessTreeModel.cs index 745c4d3b8..9fae0e82c 100644 --- a/trunk/ProcessHacker/Components/ProcessTree/ProcessTreeModel.cs +++ b/trunk/ProcessHacker/Components/ProcessTree/ProcessTreeModel.cs @@ -201,7 +201,7 @@ namespace ProcessHacker { foreach (TreeColumn column in _tree.Tree.Columns) if (column.SortOrder != SortOrder.None) - return column.Header.ToLower(); + return column.Header.ToLowerInvariant(); return ""; } diff --git a/trunk/ProcessHacker/Components/ThreadList.cs b/trunk/ProcessHacker/Components/ThreadList.cs index 8c24ae72c..5f12b49b6 100644 --- a/trunk/ProcessHacker/Components/ThreadList.cs +++ b/trunk/ProcessHacker/Components/ThreadList.cs @@ -1040,7 +1040,7 @@ namespace ProcessHacker.Components thandle.WalkStack(phandle, (stackFrame) => { uint address = stackFrame.PcAddress.ToUInt32(); - string name = _provider.Symbols.GetSymbolFromAddress(address).ToLower(); + string name = _provider.Symbols.GetSymbolFromAddress(address).ToLowerInvariant(); if (name == null) { diff --git a/trunk/ProcessHacker/Components/TokenProperties.cs b/trunk/ProcessHacker/Components/TokenProperties.cs index 9ab910b23..b22db1bd3 100644 --- a/trunk/ProcessHacker/Components/TokenProperties.cs +++ b/trunk/ProcessHacker/Components/TokenProperties.cs @@ -182,7 +182,7 @@ namespace ProcessHacker.Components { var privilege = privileges[i]; - ListViewItem item = listPrivileges.Items.Add(privilege.Name.ToLower(), privilege.Name, 0); + ListViewItem item = listPrivileges.Items.Add(privilege.Name.ToLowerInvariant(), privilege.Name, 0); item.BackColor = GetAttributeColor(privilege.Attributes); item.SubItems.Add(new ListViewItem.ListViewSubItem(item, GetAttributeString(privilege.Attributes))); diff --git a/trunk/ProcessHacker/Forms/HackerWindow.cs b/trunk/ProcessHacker/Forms/HackerWindow.cs index f76963b9e..92b780c7a 100644 --- a/trunk/ProcessHacker/Forms/HackerWindow.cs +++ b/trunk/ProcessHacker/Forms/HackerWindow.cs @@ -1830,7 +1830,7 @@ namespace ProcessHacker { if ( string.Equals(process.Name, "explorer.exe", - StringComparison.InvariantCultureIgnoreCase) && + StringComparison.OrdinalIgnoreCase) && process.ProcessItem.Username == Program.CurrentUsername) { treeProcesses.FindTreeNode(process).EnsureVisible2(); diff --git a/trunk/ProcessHacker/Forms/OptionsWindow.cs b/trunk/ProcessHacker/Forms/OptionsWindow.cs index 0da8b88a7..9a8667ad2 100644 --- a/trunk/ProcessHacker/Forms/OptionsWindow.cs +++ b/trunk/ProcessHacker/Forms/OptionsWindow.cs @@ -354,7 +354,7 @@ namespace ProcessHacker try { - if (!Array.Exists(key.GetSubKeyNames(), s => s.Equals("taskmgr.exe", StringComparison.InvariantCultureIgnoreCase))) + if (!Array.Exists(key.GetSubKeyNames(), s => s.Equals("taskmgr.exe", StringComparison.OrdinalIgnoreCase))) key.CreateSubKey("taskmgr.exe"); Microsoft.Win32.Registry.LocalMachine.OpenSubKey( @@ -379,8 +379,8 @@ namespace ProcessHacker false )) { - if ((_oldTaskMgrDebugger = (string)key.GetValue("Debugger", "")).ToLower().Trim('"') == - ProcessHandle.Current.GetMainModule().FileName.ToLower()) + if ((_oldTaskMgrDebugger = (string)key.GetValue("Debugger", "")).Trim('"').Equals( + ProcessHandle.Current.GetMainModule().FileName, StringComparison.OrdinalIgnoreCase)) { checkReplaceTaskManager.Checked = true; } @@ -439,7 +439,7 @@ namespace ProcessHacker Settings.Instance.StartHidden = checkStartHidden.Checked; Settings.Instance.EnableKPH = checkEnableKPH.Checked; Settings.Instance.EnableExperimentalFeatures = checkEnableExperimentalFeatures.Checked; - Settings.Instance.ImposterNames = textImposterNames.Text.ToLower(); + Settings.Instance.ImposterNames = textImposterNames.Text.ToLowerInvariant(); Settings.Instance.HideProcessHackerNetworkConnections = checkHidePhConnections.Checked; Settings.Instance.ElevationLevel = comboElevationLevel.SelectedIndex; @@ -539,7 +539,7 @@ namespace ProcessHacker { // If we were replacing Task Manager and the user unchecked the box, // don't replace Task Manager anymore. - if (_oldTaskMgrDebugger.ToLower().Trim('"') == fileName.ToLower()) + if (_oldTaskMgrDebugger.Trim('"').Equals(fileName, StringComparison.OrdinalIgnoreCase)) { key.DeleteValue("Debugger"); _oldTaskMgrDebugger = ""; diff --git a/trunk/ProcessHacker/Forms/ResultsWindow.cs b/trunk/ProcessHacker/Forms/ResultsWindow.cs index f3367e8f7..65c65be60 100644 --- a/trunk/ProcessHacker/Forms/ResultsWindow.cs +++ b/trunk/ProcessHacker/Forms/ResultsWindow.cs @@ -430,7 +430,7 @@ namespace ProcessHacker item = new MenuItem("Contains (case-insensitive)...", new EventHandler(filterMenuItem_Clicked)); item.Tag = new Matcher(delegate(string s1, string s2) { - return s1.ToLower().Contains(s2.ToLower()); + return s1.ToUpperInvariant().Contains(s2.ToUpperInvariant()); }); columnMenu.MenuItems.Add(item); diff --git a/trunk/ProcessHacker/Forms/RunWindow.cs b/trunk/ProcessHacker/Forms/RunWindow.cs index 56de91a8b..78aec7385 100644 --- a/trunk/ProcessHacker/Forms/RunWindow.cs +++ b/trunk/ProcessHacker/Forms/RunWindow.cs @@ -161,7 +161,7 @@ namespace ProcessHacker mailslotName = "ProcessHackerAssistant" + Utils.CreateRandomString(8); binPath = "\"" + Application.StartupPath + "\\Assistant.exe\" " + (omitUserAndType ? "" : - ("-u \"" + comboUsername.Text + "\" -t " + comboType.SelectedItem.ToString().ToLower() + " ")) + + ("-u \"" + comboUsername.Text + "\" -t " + comboType.SelectedItem.ToString().ToLowerInvariant() + " ")) + (_pid != -1 ? ("-P " + _pid.ToString() + " ") : "") + "-p \"" + textPassword.Text.Replace("\"", "\\\"") + "\" -s " + textSessionID.Text + " -c \"" + textCmdLine.Text.Replace("\"", "\\\"") + "\" -E " + mailslotName; diff --git a/trunk/ProcessHacker/Forms/UpdaterDownloadWindow.cs b/trunk/ProcessHacker/Forms/UpdaterDownloadWindow.cs index 932c2526d..1deaab73d 100644 --- a/trunk/ProcessHacker/Forms/UpdaterDownloadWindow.cs +++ b/trunk/ProcessHacker/Forms/UpdaterDownloadWindow.cs @@ -243,7 +243,7 @@ namespace ProcessHacker sb.AppendFormat("{0:x2}", b); } - if (_updateItem.Hash.Equals(sb.ToString(), StringComparison.InvariantCultureIgnoreCase)) + if (_updateItem.Hash.Equals(sb.ToString(), StringComparison.OrdinalIgnoreCase)) { labelProgress.Text = "Download completed and SHA1 verified successfully."; buttonInstall.Select(); diff --git a/trunk/ProcessHacker/Program/ExtendedCmd.cs b/trunk/ProcessHacker/Program/ExtendedCmd.cs index c625e2029..f84e3a11f 100644 --- a/trunk/ProcessHacker/Program/ExtendedCmd.cs +++ b/trunk/ProcessHacker/Program/ExtendedCmd.cs @@ -47,7 +47,7 @@ namespace ProcessHacker if (!args.ContainsKey("-type")) throw new Exception("-type switch required."); - string type = args["-type"].ToLower(); + string type = args["-type"].ToLowerInvariant(); if (!args.ContainsKey("-obj")) throw new Exception("-obj switch required."); @@ -57,7 +57,7 @@ namespace ProcessHacker if (!args.ContainsKey("-action")) throw new Exception("-action switch required."); - string action = args["-action"].ToLower(); + string action = args["-action"].ToLowerInvariant(); WindowFromHandle window = new WindowFromHandle(IntPtr.Zero); diff --git a/trunk/ProcessHacker/Program/Program.cs b/trunk/ProcessHacker/Program/Program.cs index 517f95f7c..fc49e5306 100644 --- a/trunk/ProcessHacker/Program/Program.cs +++ b/trunk/ProcessHacker/Program/Program.cs @@ -586,7 +586,7 @@ namespace ProcessHacker } if (pArgs.ContainsKey("")) - if (pArgs[""].Replace("\"", "").Trim().ToLower().EndsWith("taskmgr.exe")) + if (pArgs[""].Replace("\"", "").Trim().EndsWith("taskmgr.exe", StringComparison.OrdinalIgnoreCase)) StartVisible = true; if (pArgs.ContainsKey("-m")) diff --git a/trunk/ProcessHacker/Program/Save.cs b/trunk/ProcessHacker/Program/Save.cs index 89e03c5af..adb21907e 100644 --- a/trunk/ProcessHacker/Program/Save.cs +++ b/trunk/ProcessHacker/Program/Save.cs @@ -63,7 +63,7 @@ namespace ProcessHacker if (sfd.ShowDialog() == DialogResult.OK) { FileInfo fi = new FileInfo(sfd.FileName); - string ext = fi.Extension.ToLower(); + string ext = fi.Extension.ToLowerInvariant(); try { diff --git a/trunk/ProcessHacker/Providers/ProcessSystemProvider.cs b/trunk/ProcessHacker/Providers/ProcessSystemProvider.cs index c641f4533..df5892df4 100644 --- a/trunk/ProcessHacker/Providers/ProcessSystemProvider.cs +++ b/trunk/ProcessHacker/Providers/ProcessSystemProvider.cs @@ -574,7 +574,7 @@ namespace ProcessHacker { if (fileName != null) { - string uniName = global::System.IO.Path.GetFullPath(fileName).ToLower(); + string uniName = global::System.IO.Path.GetFullPath(fileName).ToLowerInvariant(); // No lock needed; verify results are never removed, only added. if (!forced && _fileResults.ContainsKey(uniName)) diff --git a/trunk/ProcessHacker/Structs/StructParser.cs b/trunk/ProcessHacker/Structs/StructParser.cs index cf57e6d03..d13909b90 100644 --- a/trunk/ProcessHacker/Structs/StructParser.cs +++ b/trunk/ProcessHacker/Structs/StructParser.cs @@ -53,7 +53,7 @@ namespace ProcessHacker.Structs foreach (string s in Enum.GetNames(typeof(FieldType))) if (s != "Pointer") - _typeDefs.Add(s.ToLower(), (FieldType)Enum.Parse(typeof(FieldType), s)); + _typeDefs.Add(s.ToLowerInvariant(), (FieldType)Enum.Parse(typeof(FieldType), s)); } private FieldType GetType(string typeName) diff --git a/trunk/ProcessHacker/UI/Async/HandleFilter.cs b/trunk/ProcessHacker/UI/Async/HandleFilter.cs index 7840f45f5..00c44052c 100644 --- a/trunk/ProcessHacker/UI/Async/HandleFilter.cs +++ b/trunk/ProcessHacker/UI/Async/HandleFilter.cs @@ -62,7 +62,7 @@ namespace ProcessHacker.FormHelper private void DoFilter(string strFilter) { - string lowerFilter = strFilter.ToLower(); + string lowerFilter = strFilter.ToLowerInvariant(); // Stop if cancel if (!CancelRequested) @@ -102,7 +102,7 @@ namespace ProcessHacker.FormHelper { phandle.EnumModules((module) => { - if (module.FileName.ToLower().Contains(lowerFilter)) + if (module.FileName.ToLowerInvariant().Contains(lowerFilter)) this.CallDllMatchListView(process.Key, module); return true; }); @@ -118,7 +118,7 @@ namespace ProcessHacker.FormHelper string name = phandle.GetMappedFileName(region.BaseAddress); - if (name != null && name.ToLower().Contains(lowerFilter)) + if (name != null && name.ToLowerInvariant().Contains(lowerFilter)) this.CallMappedFileMatchListView(process.Key, region.BaseAddress, name); return true; @@ -181,7 +181,7 @@ namespace ProcessHacker.FormHelper if (string.IsNullOrEmpty(info.BestName)) return; - if (!info.BestName.ToLower().Contains(lowerFilter)) + if (!info.BestName.ToLowerInvariant().Contains(lowerFilter)) return; CallHandleMatchListView(currhandle, info);