added ability to detach processes from debuggers

git-svn-id: svn://svn.code.sf.net/p/processhacker/code@1376 21ef857c-d57f-4fe0-8362-d861dc6d29cd
This commit is contained in:
wj32
2009-06-06 00:53:45 +00:00
parent fb07e556d8
commit 2c3c8a402f
38 changed files with 304 additions and 186 deletions
+1
View File
@@ -7,6 +7,7 @@ Process Hacker
* Thread wait analysis - right-click a thread and choose
Analyze > Wait to see what a thread is hanging on
* Added ability to create dump files for processes
* Added ability to detach processes from debuggers
* More detailed handle properties
* Event objects can now be modified - set, clear, pulse, reset
* Event pair objects can now be modified - set high, set low
Binary file not shown.
+1 -1
View File
@@ -1030,7 +1030,7 @@ NTSTATUS KphDispatchDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
/* KphOpenProcessJob
*
* Opens the job object that the process is assigned to. If the process is
* not assigned to any job object, the call will fail with STATUS_NO_SUCH_FILE.
* not assigned to any job object, the call will fail with STATUS_PROCESS_NOT_IN_JOB.
*/
case KPH_OPENPROCESSJOB:
{
+6 -3
View File
@@ -236,7 +236,7 @@ NTSTATUS KphOpenProcess(
return status;
}
/* let's hope our client isn't a virus... */
/* Let's hope our client isn't a virus... */
if (accessState.RemainingDesiredAccess & MAXIMUM_ALLOWED)
accessState.PreviouslyGrantedAccess |= ProcessAllAccess;
else
@@ -308,7 +308,7 @@ NTSTATUS KphOpenProcess(
*
* Opens the specified process' job object. If the process has
* not been assigned to a job object, the function returns
* STATUS_NO_SUCH_FILE.
* STATUS_PROCESS_NOT_IN_JOB.
*/
NTSTATUS KphOpenProcessJob(
HANDLE ProcessHandle,
@@ -351,6 +351,7 @@ NTSTATUS KphOpenProcessJob(
return status;
}
/* If we have PsGetProcessJob, use it. Otherwise, read the EPROCESS structure. */
if (PsGetProcessJob)
{
jobObject = PsGetProcessJob(processObject);
@@ -364,8 +365,10 @@ NTSTATUS KphOpenProcessJob(
if (jobObject == NULL)
{
/* No such job. Output a NULL handle and exit. */
SeDeleteAccessState(&accessState);
return STATUS_NO_SUCH_FILE;
*JobHandle = NULL;
return STATUS_PROCESS_NOT_IN_JOB;
}
ObReferenceObject(jobObject);
@@ -769,6 +769,15 @@ namespace ProcessHacker.Native.Api
[Out] [Optional] out int ReturnLength
);
[DllImport("ntdll.dll")]
public static extern NtStatus NtQueryInformationProcess(
[In] IntPtr ProcessHandle,
[In] ProcessInformationClass ProcessInformationClass,
[Out] out IntPtr ProcessInformation,
[In] int ProcessInformationLength,
[Out] [Optional] out int ReturnLength
);
[DllImport("ntdll.dll")]
public static extern NtStatus NtQueryInformationProcess(
[In] IntPtr ProcessHandle,
@@ -127,5 +127,7 @@ namespace ProcessHacker.Native.Api
InvalidParameter10 = 0xc00000f8,
InvalidParameter11 = 0xc00000f9,
InvalidParameter12 = 0xc00000fa,
PortNotSet = 0xc0000353,
DebuggerInactive = 0xc0000354
}
}
@@ -64,10 +64,24 @@ namespace ProcessHacker.Native.Objects
return new DebugObjectHandle(handle, true);
}
private DebugObjectHandle(IntPtr handle, bool owned)
public DebugObjectHandle FromHandle(IntPtr handle)
{
return new DebugObjectHandle(handle, false);
}
internal DebugObjectHandle(IntPtr handle, bool owned)
: base(handle, owned)
{ }
public DebugObjectHandle(ProcessHandle processHandle)
{
this.Handle = processHandle.GetDebugObjectHandle();
// Check if we got a handle. If we didn't the process is not being debugged.
if (this.Handle == IntPtr.Zero)
throw new WindowsException(NtStatus.DebuggerInactive);
}
public void Continue(ClientId cid, NtStatus continueStatus)
{
NtStatus status;
@@ -109,7 +109,7 @@ namespace ProcessHacker.Native.Objects
{ }
/// <summary>
/// Opens the job associated with the specified process.
/// Opens the job object associated with the specified process.
/// </summary>
/// <param name="processHandle">The process.</param>
/// <param name="access">The desired access to the job object.</param>
@@ -124,11 +124,13 @@ namespace ProcessHacker.Native.Objects
// Use KPH to set the handle's granted access.
this.Handle = new IntPtr(KProcessHacker.Instance.KphOpenProcessJob(processHandle,
(JobObjectAccess)StandardRights.Synchronize));
KProcessHacker.Instance.KphSetHandleGrantedAccess(this.Handle, (int)access);
if (this.Handle != IntPtr.Zero)
KProcessHacker.Instance.KphSetHandleGrantedAccess(this.Handle, (int)access);
}
// If we don't have a handle assume the process isn't in a job.
if (this.Handle == IntPtr.Zero)
Win32.ThrowLastError();
Win32.ThrowLastError(NtStatus.ProcessNotInJob);
}
private T QueryStruct<T>(JobObjectInformationClass informationClass)
@@ -642,6 +642,28 @@ namespace ProcessHacker.Native.Objects
return cycles;
}
/// <summary>
/// Opens the debug object associated with the process.
/// </summary>
/// <returns>A debug object handle.</returns>
public DebugObjectHandle GetDebugObject()
{
IntPtr handle;
handle = this.GetDebugObjectHandle();
// Check if we got a handle. If we didn't the process is not being debugged.
if (handle == IntPtr.Zero)
return null;
return new DebugObjectHandle(handle, true);
}
internal IntPtr GetDebugObjectHandle()
{
return this.GetInformationIntPtr(ProcessInformationClass.ProcessDebugObjectHandle);
}
/// <summary>
/// Gets the process' DEP policy.
/// </summary>
@@ -848,6 +870,24 @@ namespace ProcessHacker.Native.Objects
return value;
}
/// <summary>
/// Gets information about the process in an IntPtr.
/// </summary>
/// <param name="infoClass">The class of information to retrieve.</param>
/// <returns>An IntPtr.</returns>
private IntPtr GetInformationIntPtr(ProcessInformationClass infoClass)
{
NtStatus status;
IntPtr value;
int retLength;
if ((status = Win32.NtQueryInformationProcess(
this, infoClass, out value, IntPtr.Size, out retLength)) >= NtStatus.Error)
Win32.ThrowLastError(status);
return value;
}
/// <summary>
/// Gets the process' I/O priority, ranging from 0-7.
/// </summary>
@@ -858,12 +898,22 @@ namespace ProcessHacker.Native.Objects
}
/// <summary>
/// Opens the job associated with the process.
/// Opens the job object associated with the process.
/// </summary>
/// <returns>A job handle.</returns>
public JobObjectHandle GetJob(JobObjectAccess access)
/// <returns>A job object handle.</returns>
public JobObjectHandle GetJobObject(JobObjectAccess access)
{
return new JobObjectHandle(this, access);
try
{
return new JobObjectHandle(this, access);
}
catch (WindowsException ex)
{
if (ex.Status == NtStatus.ProcessNotInJob)
return null;
else
throw ex;
}
}
/// <summary>
@@ -1544,7 +1594,7 @@ namespace ProcessHacker.Native.Objects
/// <returns>A handle to the process' token.</returns>
public TokenHandle GetToken()
{
return GetToken(TokenAccess.All);
return this.GetToken(TokenAccess.All);
}
/// <summary>
@@ -21,8 +21,6 @@
*/
using System;
using System.Collections.Generic;
using System.Text;
using ProcessHacker.Native.Api;
namespace ProcessHacker.Native
+5
View File
@@ -130,5 +130,10 @@ namespace ProcessHacker.Common
{
Win32.SetWindowTheme(control.Handle, theme, null);
}
public static void ShowMessage(Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
@@ -1,12 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using ProcessHacker.Native.Objects;
using ProcessHacker.Native.Security;
using ProcessHacker.Common;
using ProcessHacker.Native.Objects;
namespace ProcessHacker.Components
{
@@ -29,7 +24,7 @@ namespace ProcessHacker.Components
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
}
@@ -41,7 +36,7 @@ namespace ProcessHacker.Components
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
}
}
@@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using ProcessHacker.Common;
using ProcessHacker.Native.Objects;
using ProcessHacker.Native.Security;
@@ -39,7 +35,7 @@ namespace ProcessHacker.Components
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
}
@@ -67,7 +67,7 @@ namespace ProcessHacker.Components
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
}
+5 -5
View File
@@ -405,7 +405,7 @@ namespace ProcessHacker.Components
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
};
@@ -467,7 +467,7 @@ namespace ProcessHacker.Components
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
}
@@ -527,7 +527,7 @@ namespace ProcessHacker.Components
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
}
@@ -548,7 +548,7 @@ namespace ProcessHacker.Components
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
}
@@ -565,7 +565,7 @@ namespace ProcessHacker.Components
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
}
}
@@ -226,7 +226,7 @@ namespace ProcessHacker.Components
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
}
}
+3 -3
View File
@@ -317,7 +317,7 @@ namespace ProcessHacker.Components
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
}
@@ -451,7 +451,7 @@ namespace ProcessHacker.Components
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
}
else
@@ -487,7 +487,7 @@ namespace ProcessHacker.Components
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
}
}
@@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms;
using ProcessHacker.Common;
using ProcessHacker.Native.Api;
using ProcessHacker.Native.Objects;
using ProcessHacker.Native.Security;
@@ -44,7 +40,7 @@ namespace ProcessHacker.Components
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
}
@@ -59,7 +55,7 @@ namespace ProcessHacker.Components
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
}
}
@@ -440,7 +440,7 @@ namespace ProcessHacker.Components
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
}
@@ -463,7 +463,7 @@ namespace ProcessHacker.Components
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
}
@@ -21,13 +21,9 @@
*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using Aga.Controls.Tree;
using ProcessHacker.Common;
using ProcessHacker.Structs;
using ProcessHacker.UI;
@@ -71,7 +67,7 @@ namespace ProcessHacker.Components
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
this.Error = true;
}
}
+2 -2
View File
@@ -805,7 +805,7 @@ namespace ProcessHacker.Components
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
}
@@ -1097,7 +1097,7 @@ namespace ProcessHacker.Components
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
}
@@ -1,11 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using ProcessHacker.Native.Api;
using System.Windows.Forms;
using ProcessHacker.Common;
using ProcessHacker.Native.Objects;
using ProcessHacker.Native.Security;
@@ -50,7 +45,7 @@ namespace ProcessHacker.Components
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
}
+2 -4
View File
@@ -21,10 +21,8 @@
*/
using System;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;
using ProcessHacker.Native;
using ProcessHacker.Common;
namespace ProcessHacker
{
@@ -57,7 +55,7 @@ namespace ProcessHacker
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
}
+2 -2
View File
@@ -22,10 +22,10 @@
using System;
using System.Windows.Forms;
using ProcessHacker.Common;
using ProcessHacker.Native.Api;
using ProcessHacker.Native.Objects;
using ProcessHacker.Native.Security;
using System.Runtime.InteropServices;
namespace ProcessHacker
{
@@ -118,7 +118,7 @@ namespace ProcessHacker
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
}
+38 -20
View File
@@ -40,6 +40,7 @@
this.virtualizationProcessMenuItem = new System.Windows.Forms.MenuItem();
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.affinityProcessMenuItem = new System.Windows.Forms.MenuItem();
this.createDumpFileProcessMenuItem = new System.Windows.Forms.MenuItem();
this.injectDllProcessMenuItem = new System.Windows.Forms.MenuItem();
this.protectionProcessMenuItem = new System.Windows.Forms.MenuItem();
this.setTokenProcessMenuItem = new System.Windows.Forms.MenuItem();
@@ -163,7 +164,8 @@
this.menuNetwork = new System.Windows.Forms.ContextMenu();
this.menuItem6 = new System.Windows.Forms.MenuItem();
this.selectAllNetworkMenuItem = new System.Windows.Forms.MenuItem();
this.createDumpFileProcessMenuItem = new System.Windows.Forms.MenuItem();
this.miscellaneousProcessMenuItem = new System.Windows.Forms.MenuItem();
this.detachFromDebuggerProcessMenuItem = new System.Windows.Forms.MenuItem();
((System.ComponentModel.ISupportInitialize)(this.statusGeneral)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.statusCPU)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.statusMemory)).BeginInit();
@@ -191,10 +193,8 @@
this.menuItem5,
this.affinityProcessMenuItem,
this.createDumpFileProcessMenuItem,
this.injectDllProcessMenuItem,
this.protectionProcessMenuItem,
this.setTokenProcessMenuItem,
this.terminatorProcessMenuItem,
this.miscellaneousProcessMenuItem,
this.priorityMenuItem,
this.runAsProcessMenuItem,
this.propertiesProcessMenuItem,
@@ -262,34 +262,40 @@
this.affinityProcessMenuItem.Text = "Affinity...";
this.affinityProcessMenuItem.Click += new System.EventHandler(this.affinityProcessMenuItem_Click);
//
// createDumpFileProcessMenuItem
//
this.createDumpFileProcessMenuItem.Index = 9;
this.createDumpFileProcessMenuItem.Text = "Create Dump File...";
this.createDumpFileProcessMenuItem.Click += new System.EventHandler(this.createDumpFileProcessMenuItem_Click);
//
// injectDllProcessMenuItem
//
this.injectDllProcessMenuItem.Index = 10;
this.injectDllProcessMenuItem.Index = 1;
this.injectDllProcessMenuItem.Text = "Inject DLL...";
this.injectDllProcessMenuItem.Click += new System.EventHandler(this.injectDllProcessMenuItem_Click);
//
// protectionProcessMenuItem
//
this.protectionProcessMenuItem.Index = 11;
this.protectionProcessMenuItem.Index = 2;
this.protectionProcessMenuItem.Text = "Protection...";
this.protectionProcessMenuItem.Click += new System.EventHandler(this.protectionProcessMenuItem_Click);
//
// setTokenProcessMenuItem
//
this.setTokenProcessMenuItem.Index = 12;
this.setTokenProcessMenuItem.Index = 3;
this.setTokenProcessMenuItem.Text = "Set Token...";
this.setTokenProcessMenuItem.Click += new System.EventHandler(this.setTokenProcessMenuItem_Click);
//
// terminatorProcessMenuItem
//
this.terminatorProcessMenuItem.Index = 13;
this.terminatorProcessMenuItem.Index = 10;
this.terminatorProcessMenuItem.Text = "Terminator...";
this.terminatorProcessMenuItem.Click += new System.EventHandler(this.terminatorProcessMenuItem_Click);
//
// priorityMenuItem
//
this.vistaMenu.SetImage(this.priorityMenuItem, global::ProcessHacker.Properties.Resources.control_equalizer_blue);
this.priorityMenuItem.Index = 14;
this.priorityMenuItem.Index = 12;
this.priorityMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.realTimeMenuItem,
this.highMenuItem,
@@ -343,7 +349,7 @@
//
// runAsProcessMenuItem
//
this.runAsProcessMenuItem.Index = 15;
this.runAsProcessMenuItem.Index = 13;
this.runAsProcessMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.launchAsUserProcessMenuItem,
this.launchAsThisUserProcessMenuItem});
@@ -365,37 +371,37 @@
//
this.propertiesProcessMenuItem.DefaultItem = true;
this.vistaMenu.SetImage(this.propertiesProcessMenuItem, global::ProcessHacker.Properties.Resources.application_form_magnify);
this.propertiesProcessMenuItem.Index = 16;
this.propertiesProcessMenuItem.Index = 14;
this.propertiesProcessMenuItem.Text = "&Properties...";
this.propertiesProcessMenuItem.Click += new System.EventHandler(this.propertiesProcessMenuItem_Click);
//
// menuItem7
//
this.menuItem7.Index = 17;
this.menuItem7.Index = 15;
this.menuItem7.Text = "-";
//
// searchProcessMenuItem
//
this.searchProcessMenuItem.Index = 18;
this.searchProcessMenuItem.Index = 16;
this.searchProcessMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlM;
this.searchProcessMenuItem.Text = "&Search Online...";
this.searchProcessMenuItem.Click += new System.EventHandler(this.searchProcessMenuItem_Click);
//
// reanalyzeProcessMenuItem
//
this.reanalyzeProcessMenuItem.Index = 19;
this.reanalyzeProcessMenuItem.Index = 17;
this.reanalyzeProcessMenuItem.Text = "Re-analyze";
this.reanalyzeProcessMenuItem.Click += new System.EventHandler(this.reanalyzeProcessMenuItem_Click);
//
// copyProcessMenuItem
//
this.vistaMenu.SetImage(this.copyProcessMenuItem, global::ProcessHacker.Properties.Resources.page_copy);
this.copyProcessMenuItem.Index = 20;
this.copyProcessMenuItem.Index = 18;
this.copyProcessMenuItem.Text = "&Copy";
//
// selectAllProcessMenuItem
//
this.selectAllProcessMenuItem.Index = 21;
this.selectAllProcessMenuItem.Index = 19;
this.selectAllProcessMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlA;
this.selectAllProcessMenuItem.Text = "Select &All";
this.selectAllProcessMenuItem.Click += new System.EventHandler(this.selectAllProcessMenuItem_Click);
@@ -1183,11 +1189,21 @@
this.selectAllNetworkMenuItem.Text = "Select &All";
this.selectAllNetworkMenuItem.Click += new System.EventHandler(this.selectAllNetworkMenuItem_Click);
//
// createDumpFileProcessMenuItem
// miscellaneousProcessMenuItem
//
this.createDumpFileProcessMenuItem.Index = 9;
this.createDumpFileProcessMenuItem.Text = "Create Dump File...";
this.createDumpFileProcessMenuItem.Click += new System.EventHandler(this.createDumpFileProcessMenuItem_Click);
this.miscellaneousProcessMenuItem.Index = 11;
this.miscellaneousProcessMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.detachFromDebuggerProcessMenuItem,
this.injectDllProcessMenuItem,
this.protectionProcessMenuItem,
this.setTokenProcessMenuItem});
this.miscellaneousProcessMenuItem.Text = "Miscellaneous";
//
// detachFromDebuggerProcessMenuItem
//
this.detachFromDebuggerProcessMenuItem.Index = 0;
this.detachFromDebuggerProcessMenuItem.Text = "Detach from Debugger";
this.detachFromDebuggerProcessMenuItem.Click += new System.EventHandler(this.detachFromDebuggerProcessMenuItem_Click);
//
// HackerWindow
//
@@ -1361,6 +1377,8 @@
private System.Windows.Forms.MenuItem closeNetworkMenuItem;
private System.Windows.Forms.MenuItem protectionProcessMenuItem;
private System.Windows.Forms.MenuItem createDumpFileProcessMenuItem;
private System.Windows.Forms.MenuItem miscellaneousProcessMenuItem;
private System.Windows.Forms.MenuItem detachFromDebuggerProcessMenuItem;
}
}
+75 -52
View File
@@ -30,13 +30,13 @@ using System.Threading;
using System.Windows.Forms;
using Aga.Controls.Tree;
using ProcessHacker.Common;
using ProcessHacker.Components;
using ProcessHacker.Native;
using ProcessHacker.Native.Api;
using ProcessHacker.Native.Objects;
using ProcessHacker.Native.Security;
using ProcessHacker.UI;
using ProcessHacker.UI.Actions;
using ProcessHacker.Components;
namespace ProcessHacker
{
@@ -267,7 +267,7 @@ namespace ProcessHacker
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
}
@@ -1107,7 +1107,7 @@ namespace ProcessHacker
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
}
@@ -1228,7 +1228,7 @@ namespace ProcessHacker
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
finally
{
@@ -1237,53 +1237,6 @@ namespace ProcessHacker
}
}
private void injectDllProcessMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "DLL Files (*.dll)|*.dll|All Files (*.*)|*.*";
if (ofd.ShowDialog() == DialogResult.OK)
{
try
{
using (var phandle = new ProcessHandle(processSelectedPID,
ProcessAccess.CreateThread | ProcessAccess.VmOperation | ProcessAccess.VmWrite))
{
phandle.InjectDll(ofd.FileName, 5000);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void protectionProcessMenuItem_Click(object sender, EventArgs e)
{
(new ProtectProcessWindow(processSelectedPID)).ShowDialog();
}
private void setTokenProcessMenuItem_Click(object sender, EventArgs e)
{
ProcessPickerWindow picker = new ProcessPickerWindow();
picker.Label = "Select the source of the token:";
if (picker.ShowDialog() == DialogResult.OK)
{
try
{
KProcessHacker.Instance.SetProcessToken(picker.SelectedPid, processSelectedPID);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void terminatorProcessMenuItem_Click(object sender, EventArgs e)
{
TerminatorWindow w = new TerminatorWindow(processSelectedPID);
@@ -1331,6 +1284,76 @@ namespace ProcessHacker
#endregion
#region Miscellaneous
private void detachFromDebuggerProcessMenuItem_Click(object sender, EventArgs e)
{
try
{
using (var phandle = new ProcessHandle(processSelectedPID, ProcessAccess.QueryInformation | ProcessAccess.SuspendResume))
{
using (var dhandle = phandle.GetDebugObject())
phandle.RemoveDebug(dhandle);
}
}
catch (WindowsException ex)
{
if (ex.Status == NtStatus.PortNotSet)
MessageBox.Show("The process is not being debugged.", "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Information);
else
PhUtils.ShowMessage(ex);
}
}
private void injectDllProcessMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "DLL Files (*.dll)|*.dll|All Files (*.*)|*.*";
if (ofd.ShowDialog() == DialogResult.OK)
{
try
{
using (var phandle = new ProcessHandle(processSelectedPID,
ProcessAccess.CreateThread | ProcessAccess.VmOperation | ProcessAccess.VmWrite))
{
phandle.InjectDll(ofd.FileName, 5000);
}
}
catch (Exception ex)
{
PhUtils.ShowMessage(ex);
}
}
}
private void protectionProcessMenuItem_Click(object sender, EventArgs e)
{
(new ProtectProcessWindow(processSelectedPID)).ShowDialog();
}
private void setTokenProcessMenuItem_Click(object sender, EventArgs e)
{
ProcessPickerWindow picker = new ProcessPickerWindow();
picker.Label = "Select the source of the token:";
if (picker.ShowDialog() == DialogResult.OK)
{
try
{
KProcessHacker.Instance.SetProcessToken(picker.SelectedPid, processSelectedPID);
}
catch (Exception ex)
{
PhUtils.ShowMessage(ex);
}
}
}
#endregion
#region Injector
private void startProcessProcessMenuItem_Click(object sender, EventArgs e)
@@ -1460,7 +1483,7 @@ namespace ProcessHacker
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
}
+17 -14
View File
@@ -123,12 +123,27 @@
<metadata name="vistaMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>141, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>113</value>
<metadata name="mainMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>249, 17</value>
</metadata>
<metadata name="timerMessages.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>359, 17</value>
</metadata>
<metadata name="toolStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>719, 17</value>
</metadata>
<metadata name="menuService.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>492, 17</value>
</metadata>
<metadata name="menuIcon.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>613, 17</value>
</metadata>
<metadata name="vistaMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>141, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>113</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
@@ -182,18 +197,6 @@
rEEAAaxBAAGsQQABrEEAAKxBAACsQQAArEHAAKxB8ACsQfB/rEH//6xB
</value>
</data>
<metadata name="mainMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>249, 17</value>
</metadata>
<metadata name="timerMessages.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>359, 17</value>
</metadata>
<metadata name="menuService.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>492, 17</value>
</metadata>
<metadata name="menuIcon.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>613, 17</value>
</metadata>
<metadata name="menuNetwork.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>817, 17</value>
</metadata>
@@ -243,7 +243,7 @@ namespace ProcessHacker
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
}
@@ -236,7 +236,7 @@ namespace ProcessHacker
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
}
}
+1 -1
View File
@@ -132,7 +132,7 @@ namespace ProcessHacker
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
}
}
+3 -3
View File
@@ -22,7 +22,7 @@
using System;
using System.Windows.Forms;
using ProcessHacker.Native.Api;
using ProcessHacker.Common;
using ProcessHacker.Native.Objects;
using ProcessHacker.Native.Security;
@@ -66,7 +66,7 @@ namespace ProcessHacker
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
this.Close();
return;
@@ -98,7 +98,7 @@ namespace ProcessHacker
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
}
}
+13 -6
View File
@@ -197,7 +197,11 @@ namespace ProcessHacker
try
{
using (var phandle = new ProcessHandle(_pid, Program.MinProcessQueryRights))
phandle.GetJob(JobObjectAccess.Query);
{
// Check if the process is in a job.
if (phandle.GetJobObject(JobObjectAccess.Query) == null)
tabControl.TabPages.Remove(tabJob);
}
}
catch
{
@@ -567,11 +571,14 @@ namespace ProcessHacker
{
using (var phandle = new ProcessHandle(_pid, Program.MinProcessQueryRights))
{
var jhandle = phandle.GetJob(JobObjectAccess.Query);
var jhandle = phandle.GetJobObject(JobObjectAccess.Query);
_jobProps = new JobProperties(jhandle);
_jobProps.Dock = DockStyle.Fill;
tabJob.Controls.Add(_jobProps);
if (jhandle != null)
{
_jobProps = new JobProperties(jhandle);
_jobProps.Dock = DockStyle.Fill;
tabJob.Controls.Add(_jobProps);
}
}
}
catch
@@ -898,7 +905,7 @@ namespace ProcessHacker
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
}
+1 -1
View File
@@ -216,7 +216,7 @@ namespace ProcessHacker
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
this.Cursor = Cursors.Default;
@@ -209,7 +209,9 @@ namespace ProcessHacker
{
using (var phandle = new ProcessHandle(_pid, Program.MinProcessQueryRights))
{
using (var jhandle = phandle.GetJob(JobObjectAccess.Query | JobObjectAccess.Terminate))
var jhandle = phandle.GetJobObject(JobObjectAccess.Query | JobObjectAccess.Terminate);
if (jhandle != null)
{
// Make sure we're not terminating more than one process
if (jhandle.GetProcessIdList().Length == 1)
+1 -1
View File
@@ -336,7 +336,7 @@ namespace ProcessHacker
catch (Exception ex)
{
if (!ex.Message.StartsWith("Cannot access a disposed object"))
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
}
}
+2 -2
View File
@@ -413,7 +413,7 @@ namespace ProcessHacker
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
return true;
@@ -469,7 +469,7 @@ namespace ProcessHacker
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
return true;
+3 -3
View File
@@ -20,13 +20,13 @@
* along with Process Hacker. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.IO;
using Aga.Controls.Tree;
using Aga.Controls.Tree.NodeControls;
using ProcessHacker.Common;
namespace ProcessHacker
{
@@ -69,7 +69,7 @@ namespace ProcessHacker
}
catch (IOException ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
PhUtils.ShowMessage(ex);
}
}
}
@@ -910,16 +910,21 @@ namespace ProcessHacker
{
try
{
using (var jhandle = queryLimitedHandle.GetJob(JobObjectAccess.Query))
var jhandle = queryLimitedHandle.GetJobObject(JobObjectAccess.Query);
if (jhandle != null)
{
var limits = jhandle.GetBasicLimitInformation();
item.IsInJob = true;
item.JobName = jhandle.GetObjectName();
if (limits.LimitFlags != JobObjectLimitFlags.SilentBreakawayOk)
using (jhandle)
{
item.IsInSignificantJob = true;
var limits = jhandle.GetBasicLimitInformation();
item.IsInJob = true;
item.JobName = jhandle.GetObjectName();
if (limits.LimitFlags != JobObjectLimitFlags.SilentBreakawayOk)
{
item.IsInSignificantJob = true;
}
}
}
}