[NTOS:MM] Implement MmCreateKernelStackEx

This allows to specify the amount of committed bytes.
This commit is contained in:
Timo Kreuzer 2023-11-07 15:35:17 +02:00
parent cb31f810c5
commit 6fe60acc1d
2 changed files with 41 additions and 5 deletions

View file

@ -866,7 +866,16 @@ MmAccessFault(
PVOID
NTAPI
MmCreateKernelStack(BOOLEAN GuiStack, UCHAR Node);
MmCreateKernelStack(
_In_ BOOLEAN GuiStack,
_In_ UCHAR Node);
PVOID
NTAPI
MmCreateKernelStackEx(
_In_ BOOLEAN GuiStack,
_In_ SIZE_T CommitSize,
_In_ UCHAR Node);
VOID
NTAPI

View file

@ -273,8 +273,10 @@ MmDeleteKernelStack(IN PVOID StackBase,
PVOID
NTAPI
MmCreateKernelStack(IN BOOLEAN GuiStack,
IN UCHAR Node)
MmCreateKernelStackEx(
_In_ BOOLEAN GuiStack,
_In_ SIZE_T CommitSize,
_In_ UCHAR Node)
{
PFN_COUNT StackPtes, StackPages;
PMMPTE PointerPte, StackPte;
@ -291,10 +293,23 @@ MmCreateKernelStack(IN BOOLEAN GuiStack,
if (GuiStack)
{
//
// We'll allocate 64KB stack, but only commit 12K
// We always reserve MmLargeStackSize
//
StackPtes = BYTES_TO_PAGES(MmLargeStackSize);
StackPages = BYTES_TO_PAGES(KERNEL_LARGE_STACK_COMMIT);
//
// If requested, use the whole thing, otherwise just the minimum
//
if (CommitSize != 0)
{
ASSERT(CommitSize >= KERNEL_LARGE_STACK_COMMIT);
ASSERT(CommitSize <= MmLargeStackSize);
StackPages = BYTES_TO_PAGES(CommitSize);
}
else
{
StackPages = BYTES_TO_PAGES(KERNEL_LARGE_STACK_COMMIT);
}
}
else
{
@ -384,6 +399,18 @@ MmCreateKernelStack(IN BOOLEAN GuiStack,
return BaseAddress;
}
PVOID
NTAPI
MmCreateKernelStack(
_In_ BOOLEAN GuiStack,
_In_ UCHAR Node)
{
//
// Call the extended version
//
return MmCreateKernelStackEx(GuiStack, 0, Node);
}
NTSTATUS
NTAPI
MmGrowKernelStackEx(IN PVOID StackPointer,