mirror of
https://github.com/mirror/processhacker
synced 2026-06-08 16:03:24 +00:00
fixed -installkph and -uninstallkph command line options
git-svn-id: svn://svn.code.sf.net/p/processhacker/code@2103 21ef857c-d57f-4fe0-8362-d861dc6d29cd
This commit is contained in:
@@ -253,8 +253,14 @@ namespace ProcessHacker
|
||||
|
||||
try
|
||||
{
|
||||
// Only load KPH if we're on 32-bit and it's enabled.
|
||||
if (IntPtr.Size == 4 && Properties.Settings.Default.EnableKPH && !NoKph)
|
||||
if (
|
||||
// Only load KPH if we're on 32-bit and it's enabled.
|
||||
IntPtr.Size == 4 &&
|
||||
Properties.Settings.Default.EnableKPH &&
|
||||
!NoKph &&
|
||||
// Don't load KPH if we're going to install/uninstall it.
|
||||
!pArgs.ContainsKey("-installkph") && !pArgs.ContainsKey("-uninstallkph")
|
||||
)
|
||||
KProcessHacker.Instance = new KProcessHacker("KProcessHacker");
|
||||
}
|
||||
catch
|
||||
@@ -480,13 +486,20 @@ namespace ProcessHacker
|
||||
{
|
||||
using (var scm = new ServiceManagerHandle(ScManagerAccess.CreateService))
|
||||
{
|
||||
scm.CreateService(
|
||||
using (var shandle = scm.CreateService(
|
||||
"KProcessHacker",
|
||||
"KProcessHacker",
|
||||
ServiceType.KernelDriver,
|
||||
ServiceStartType.BootStart,
|
||||
Application.StartupPath + "\\kprocesshacker.sys"
|
||||
);
|
||||
ServiceStartType.SystemStart,
|
||||
ServiceErrorControl.Ignore,
|
||||
Application.StartupPath + "\\kprocesshacker.sys",
|
||||
null,
|
||||
null,
|
||||
null
|
||||
))
|
||||
{
|
||||
shandle.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (WindowsException ex)
|
||||
@@ -494,20 +507,29 @@ namespace ProcessHacker
|
||||
// Need to pass status back.
|
||||
Environment.Exit((int)ex.ErrorCode);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pArgs.ContainsKey("-uninstallkph"))
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var shandle = new ServiceHandle("KProcessHacker", (ServiceAccess)StandardRights.Delete))
|
||||
using (var shandle = new ServiceHandle("KProcessHacker", ServiceAccess.Stop | (ServiceAccess)StandardRights.Delete))
|
||||
{
|
||||
try { shandle.Control(ServiceControl.Stop); }
|
||||
catch { }
|
||||
|
||||
shandle.Delete();
|
||||
}
|
||||
}
|
||||
catch (WindowsException ex)
|
||||
{
|
||||
// Need to pass status back.
|
||||
Environment.Exit((int)ex.ErrorCode);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pArgs.ContainsKey("-ip"))
|
||||
|
||||
Reference in New Issue
Block a user