From b7006e2b014049143b9b51d04c3f0e7aa9318ad5 Mon Sep 17 00:00:00 2001 From: Silent Date: Sun, 15 May 2022 14:47:39 +0200 Subject: [PATCH] Do not leave KeDelayExecutionThread prematurely Fixes games waking up from Sleep() calls immediately --- src/core/kernel/exports/EmuKrnlKe.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/kernel/exports/EmuKrnlKe.cpp b/src/core/kernel/exports/EmuKrnlKe.cpp index ed271fb56..e5bc338ac 100644 --- a/src/core/kernel/exports/EmuKrnlKe.cpp +++ b/src/core/kernel/exports/EmuKrnlKe.cpp @@ -84,6 +84,9 @@ namespace NtDll #include "Timer.h" #include "Util.h" +#pragma warning(disable:4005) // Ignore redefined status values +#include + #include #include #include @@ -727,7 +730,8 @@ XBSYSAPI EXPORTNUM(99) xbox::ntstatus_xt NTAPI xbox::KeDelayExecutionThread NtDll::LARGE_INTEGER ExpireTime; ExpireTime.QuadPart = 0; 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::make_optional(Status);