Created
June 24, 2019 18:08
-
-
Save matterpreter/719a3eb4bc254992ac390164f52657e3 to your computer and use it in GitHub Desktop.
Set process to be critical
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Diagnostics; | |
using System.Runtime.InteropServices; | |
namespace UnkillableTest | |
{ | |
class Program | |
{ | |
[DllImport("ntdll.dll", SetLastError = true)] | |
private static extern void RtlSetProcessIsCritical(uint bNew, uint pbOld, uint bNeedScb); | |
public static void MakeProcessUnkillable() | |
{ | |
Process.EnterDebugMode(); | |
RtlSetProcessIsCritical(1, 0, 0); | |
} | |
public static void MakeProcessKillable() | |
{ | |
RtlSetProcessIsCritical(0, 0, 0); | |
} | |
static void Main() | |
{ | |
MakeProcessUnkillable(); | |
Environment.Exit(0); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment