Skip to content

Commit 7a80c49

Browse files
dt10812binarymaster
authored andcommitted
[FREELDR:UEFI] Refactor the memory stack setup (reactos#9092)
Add allocation failure handling and document the code in a better way. CORE-11954
1 parent 7eab8fa commit 7a80c49

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

‎boot/freeldr/freeldr/arch/uefi/uefildr.c‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,17 @@ EfiEntry(
7171
}
7272

7373
/* 0x32000 is what UEFI defines, but we can go smaller if we want */
74-
BasicStack = (PVOID)((ULONG_PTR)0x32000 + (ULONG_PTR)MmAllocateMemoryWithType(0x32000, LoaderOsloaderStack));
74+
SIZE_T StackSize = 0x32000;
75+
PVOID AllocatedStackMem = MmAllocateMemoryWithType(StackSize, LoaderOsloaderStack);
76+
77+
if (!AllocatedStackMem)
78+
{
79+
UiMessageBoxCritical("Unable to allocate OS loader stack.");
80+
goto Quit;
81+
}
82+
83+
/* Stacks grow downward so set the initial stack pointer to the top of the allocated region */
84+
BasicStack = (PVOID)((ULONG_PTR)AllocatedStackMem + StackSize);
7585
_changestack();
7686

7787
Quit:

0 commit comments

Comments
 (0)