Do not leave KeDelayExecutionThread prematurely
Fixes games waking up from Sleep() calls immediately
This commit is contained in:
parent
8b35389c71
commit
b7006e2b01
|
@ -84,6 +84,9 @@ namespace NtDll
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
|
|
||||||
|
#pragma warning(disable:4005) // Ignore redefined status values
|
||||||
|
#include <ntstatus.h>
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -727,7 +730,8 @@ XBSYSAPI EXPORTNUM(99) xbox::ntstatus_xt NTAPI xbox::KeDelayExecutionThread
|
||||||
NtDll::LARGE_INTEGER ExpireTime;
|
NtDll::LARGE_INTEGER ExpireTime;
|
||||||
ExpireTime.QuadPart = 0;
|
ExpireTime.QuadPart = 0;
|
||||||
NTSTATUS Status = NtDll::NtDelayExecution(Alertable, &ExpireTime);
|
NTSTATUS Status = NtDll::NtDelayExecution(Alertable, &ExpireTime);
|
||||||
if (Status == 0) { // STATUS_SUCCESS
|
// Any success codes that are not related to alerting should be masked out
|
||||||
|
if (Status >= 0 && Status != STATUS_ALERTED && Status != STATUS_USER_APC) {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
return std::make_optional<ntstatus_xt>(Status);
|
return std::make_optional<ntstatus_xt>(Status);
|
||||||
|
|
Loading…
Reference in New Issue