Do not leave KeDelayExecutionThread prematurely

Fixes games waking up from Sleep() calls immediately
This commit is contained in:
Silent 2022-05-15 14:47:39 +02:00
parent 8b35389c71
commit b7006e2b01
No known key found for this signature in database
GPG Key ID: AE53149BB0C45AF1
1 changed files with 5 additions and 1 deletions

View File

@ -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);