mirror of
https://github.com/mirror/processhacker
synced 2026-06-08 16:03:24 +00:00
ability to open key handles in regedit
git-svn-id: svn://svn.code.sf.net/p/processhacker/code@1611 21ef857c-d57f-4fe0-8362-d861dc6d29cd
This commit is contained in:
@@ -6,6 +6,7 @@ Process Hacker
|
||||
* Better handle granted access display
|
||||
* Thread list is more responsive
|
||||
* Process exit notification (in the process window) is now instant
|
||||
* Ability to open key handles in regedit
|
||||
* FIXED:
|
||||
* Properties menu item for handles was disabled most of the time
|
||||
* Handle names could not be viewed properly without KPH and
|
||||
|
||||
@@ -22,13 +22,13 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using Aga.Controls.Tree;
|
||||
using ProcessHacker.Native;
|
||||
using ProcessHacker.Native.Api;
|
||||
using ProcessHacker.Native.Objects;
|
||||
using ProcessHacker.UI;
|
||||
using System.Drawing;
|
||||
|
||||
namespace ProcessHacker.Common
|
||||
{
|
||||
@@ -105,6 +105,53 @@ namespace ProcessHacker.Common
|
||||
return Color.White;
|
||||
}
|
||||
|
||||
public static void OpenKeyInRegedit(string keyName)
|
||||
{
|
||||
OpenKeyInRegedit(null, keyName);
|
||||
}
|
||||
|
||||
public static void OpenKeyInRegedit(IWin32Window window, string keyName)
|
||||
{
|
||||
string lastKey = keyName;
|
||||
|
||||
// Expand the abbreviations.
|
||||
if (lastKey.ToLowerInvariant().StartsWith("hkcu"))
|
||||
lastKey = "HKEY_CURRENT_USER" + lastKey.Substring(4);
|
||||
else if (lastKey.ToLowerInvariant().StartsWith("hku"))
|
||||
lastKey = "HKEY_USERS" + lastKey.Substring(3);
|
||||
else if (lastKey.ToLowerInvariant().StartsWith("hkcr"))
|
||||
lastKey = "HKEY_CLASSES_ROOT" + lastKey.Substring(4);
|
||||
else if (lastKey.ToLowerInvariant().StartsWith("hklm"))
|
||||
lastKey = "HKEY_LOCAL_MACHINE" + lastKey.Substring(4);
|
||||
|
||||
using (var regeditKey =
|
||||
Microsoft.Win32.Registry.CurrentUser.OpenSubKey(
|
||||
@"Software\Microsoft\Windows\CurrentVersion\Applets\Regedit",
|
||||
true
|
||||
))
|
||||
{
|
||||
if (OSVersion.IsAboveOrEqual(WindowsVersion.Vista))
|
||||
regeditKey.SetValue("LastKey", "Computer\\" + lastKey);
|
||||
else
|
||||
regeditKey.SetValue("LastKey", lastKey);
|
||||
}
|
||||
|
||||
if (OSVersion.HasUac && Program.ElevationType == TokenElevationType.Limited)
|
||||
{
|
||||
Program.StartProgramAdmin(
|
||||
Environment.SystemDirectory + "\\..\\regedit.exe",
|
||||
"",
|
||||
null,
|
||||
ShowWindowType.Normal,
|
||||
window != null ? window.Handle : IntPtr.Zero
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
System.Diagnostics.Process.Start(Environment.SystemDirectory + "\\..\\regedit.exe");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Selects all of the specified nodes.
|
||||
/// </summary>
|
||||
|
||||
@@ -339,6 +339,7 @@ namespace ProcessHacker.Components
|
||||
// Objects with separate property windows:
|
||||
case "file":
|
||||
case "job":
|
||||
case "key":
|
||||
case "token":
|
||||
case "process":
|
||||
{
|
||||
@@ -367,6 +368,18 @@ namespace ProcessHacker.Components
|
||||
(new JobWindow(JobObjectHandle.FromHandle(dupHandle))).ShowDialog();
|
||||
}
|
||||
break;
|
||||
case "key":
|
||||
{
|
||||
try
|
||||
{
|
||||
PhUtils.OpenKeyInRegedit(Form.ActiveForm, name);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
PhUtils.ShowMessage("Error opening the registry editor", ex);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "token":
|
||||
{
|
||||
(new TokenWindow(new RemoteTokenHandle(phandle,
|
||||
|
||||
Reference in New Issue
Block a user