From fdf649fcece0688d4d9e6d715977d97166ccf4e4 Mon Sep 17 00:00:00 2001 From: Aiken Harris Date: Sat, 19 Jul 2025 17:41:38 +0200 Subject: [PATCH] Correctly initialize the boot stack pointer, as the stack grows downwards --- xtoskrnl/ke/krnlinit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xtoskrnl/ke/krnlinit.c b/xtoskrnl/ke/krnlinit.c index 15a1613..c2c0c4b 100644 --- a/xtoskrnl/ke/krnlinit.c +++ b/xtoskrnl/ke/krnlinit.c @@ -60,6 +60,6 @@ KeStartXtSystem(IN PKERNEL_INITIALIZATION_BLOCK Parameters) /* Raise to HIGH runlevel */ KeRaiseRunLevel(HIGH_LEVEL); - /* Switch boot stack aligning it to 4 byte boundary */ - KepSwitchBootStack((ULONG_PTR)&ArKernelBootStack & ~0x3); + /* Switch the boot stack, setting the pointer to the top of the buffer and aligning it to a 4-byte boundary */ + KepSwitchBootStack(((ULONG_PTR)&ArKernelBootStack + KERNEL_STACK_SIZE) & ~0x3); }