dEEpEst Posted August 3, 2014 Share Posted August 3, 2014 Credits: affixiate A simple and efficient way of making a process critical. The code is listed below: [LENGUAJE=c#]using System; using System.Diagnostics; using System.Runtime.InteropServices; /* * Title: CCritical.cs * Description: Makes a process critical. Terminating it will result in a BSoD. * * Developed by: affixiate from DevBB ( This is the hidden content, please Sign In or Sign Up ) * Release date: December 15, 2010 * Released on: This is the hidden content, please Sign In or Sign Up * * Comments: If you use this code, I require you to give me credits. Don't be a ripper! ;] */ public class CCritical { /// /// Initializes a new instance of the class. /// public CCritical() { try { // Attempts to acquire debug privileges. Process.EnterDebugMode(); } catch { throw new Exception("Couldn't acqure debug privileges. This program must run under an Administrator account."); } } /// /// Makes our process critical. /// Terminating it now will cause a BSoD. /// public void Enable() { AdjustCritical(1); } /// /// Removes the critical attribute from our process. /// Terminating it now will not cause a BSoD. /// public void Disable() { AdjustCritical(0); } /// /// Internal method: Adjusts whether our process is critical or not. /// /// private static void AdjustCritical(int enable) { NtSetInformationProcess(Process.GetCurrentProcess().Handle, 29, ref enable, sizeof (int)); } #region WinAPI [DllImport("ntdll.dll", SetLastError = true)] private static extern int NtSetInformationProcess(IntPtr hProcess, int processInformationClass, ref int processInformation, int processInformationLength); #endregion }[/LENGUAJE] To use: [LENGUAJE=c#]var critical = new CCritical(); critical.Enable(); // Terminating the process now will cause a BSoD Environment.Exit(0); ... critical.Disable(); // Terminating the process now will not cause a BSoD Environment.Exit(0);[/LENGUAJE] If you use this code, it would be most excellent if you could maintain the credits. I'm not asking for cash or beer. This is the least you can do for such high quality work, no? Don't be a ripper. /affixiate P.S. All constructive criticism as well as questions and general comments are welcome. If you like my snippets and want to see more Link to comment Share on other sites More sharing options...
Recommended Posts