https://git.reactos.org/?p=reactos.git;a=commitdiff;h=583be404ddc0a52091a7a…
commit 583be404ddc0a52091a7a22944520d94196cbf70
Author:     Timo Kreuzer <timo.kreuzer(a)reactos.org>
AuthorDate: Wed Aug 16 01:14:28 2023 +0300
Commit:     Timo Kreuzer <timo.kreuzer(a)reactos.org>
CommitDate: Thu Sep 7 01:16:14 2023 +0300
    [NTOSKRNL/x64] Fix bug in KiInitializeContextThread
    The function set CtxSwitchFrame->ApcBypass to FALSE, preventing APCs (like when
user mode sets the context while the thread is suspended) from being delivered as soon as
the thread lowers IRQL to PASSIVE_LEVEL. This resulted in the SetContext APC to be
delivered only after the user mode APC was initialized, overwriting the user mode APC
context in the trap frame. This caused kernel32_winetest process to break.
---
 ntoskrnl/ke/amd64/thrdini.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ntoskrnl/ke/amd64/thrdini.c b/ntoskrnl/ke/amd64/thrdini.c
index b2119c6e8a3..3185de21cd6 100644
--- a/ntoskrnl/ke/amd64/thrdini.c
+++ b/ntoskrnl/ke/amd64/thrdini.c
@@ -134,7 +134,7 @@ KiInitializeContextThread(IN PKTHREAD Thread,
     /* Set up the Context Switch Frame */
     CtxSwitchFrame->Return = (ULONG64)KiThreadStartup;
-    CtxSwitchFrame->ApcBypass = FALSE;
+    CtxSwitchFrame->ApcBypass = TRUE;
     StartFrame->P1Home = (ULONG64)StartRoutine;
     StartFrame->P2Home = (ULONG64)StartContext;