Skip to content

Commit

Permalink
Merge pull request #2360 from CookiePLMonster/fix-sleep
Browse files Browse the repository at this point in the history
Do not leave KeDelayExecutionThread prematurely
  • Loading branch information
LukeUsher committed May 16, 2022
2 parents 5e928e5 + b7006e2 commit 95b789e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/core/kernel/exports/EmuKrnlKe.cpp
Expand Up @@ -84,6 +84,9 @@ namespace NtDll
#include "Timer.h"
#include "Util.h"

#pragma warning(disable:4005) // Ignore redefined status values
#include <ntstatus.h>

#include <chrono>
#include <thread>
#include <windows.h>
Expand Down Expand Up @@ -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<ntstatus_xt>(Status);
Expand Down

0 comments on commit 95b789e

Please sign in to comment.