PVOID
STDCALL
-MiCreatePebOrTeb(PEPROCESS Process,
+MiCreatePebOrTeb(PROS_EPROCESS Process,
PVOID BaseAddress)
{
NTSTATUS Status;
} while (Status != STATUS_SUCCESS);
/* Initialize the Region */
- MmInitialiseRegion(&MemoryArea->Data.VirtualMemoryData.RegionListHead,
+ MmInitializeRegion(&MemoryArea->Data.VirtualMemoryData.RegionListHead,
PAGE_SIZE,
MEM_COMMIT,
PAGE_READWRITE);
VOID
STDCALL
-MmDeleteTeb(PEPROCESS Process,
+MmDeleteTeb(PROS_EPROCESS Process,
PTEB Teb)
{
PMADDRESS_SPACE ProcessAddressSpace = &Process->AddressSpace;
PMEMORY_AREA StackArea;
ULONG i;
PHYSICAL_ADDRESS BoundaryAddressMultiple;
- PFN_TYPE Page[MM_STACK_SIZE / PAGE_SIZE];
+ ULONG StackSize = GuiStack ? KERNEL_LARGE_STACK_SIZE : KERNEL_STACK_SIZE;
+ PFN_TYPE Page[KERNEL_LARGE_STACK_SIZE / PAGE_SIZE];
PVOID KernelStack = NULL;
NTSTATUS Status;
Status = MmCreateMemoryArea(MmGetKernelAddressSpace(),
MEMORY_AREA_KERNEL_STACK,
&KernelStack,
- MM_STACK_SIZE,
+ StackSize,
PAGE_READWRITE,
&StackArea,
FALSE,
KEBUGCHECK(0);
}
- /* Mark the Stack in use */
- for (i = 0; i < (MM_STACK_SIZE / PAGE_SIZE); i++)
+ /*
+ * Mark the Stack in use.
+ * Note: Currently we mark all 60KB in use for a GUI Thread.
+ * We should only do this inside MmGrowKernelStack. TODO!
+ */
+ for (i = 0; i < (StackSize / PAGE_SIZE); i++)
{
Status = MmRequestPageMemoryConsumer(MC_NPPOOL, TRUE, &Page[i]);
}
KernelStack,
PAGE_READWRITE,
Page,
- MM_STACK_SIZE / PAGE_SIZE);
+ StackSize / PAGE_SIZE);
/* Check for success */
if (!NT_SUCCESS(Status))
KEBUGCHECK(0);
}
+ /* Return the stack */
return KernelStack;
}
+/*
+ * @implemented
+ */
+NTSTATUS
+STDCALL
+MmGrowKernelStack(PVOID StackPointer)
+{
+ PETHREAD Thread = PsGetCurrentThread();
+
+ /* Make sure we have reserved space for our grow */
+ ASSERT(((PCHAR)Thread->Tcb.StackBase - (PCHAR)Thread->Tcb.StackLimit) <=
+ (KERNEL_LARGE_STACK_SIZE + PAGE_SIZE));
+
+ /*
+ * We'll give you three more pages.
+ * NOTE: See note in MmCreateKernelStack. These pages are already being reserved.
+ * It would be more efficient to only grow them (commit them) here.
+ */
+ Thread->Tcb.StackLimit -= KERNEL_STACK_SIZE;
+
+ /* Return success */
+ return STATUS_SUCCESS;
+}
+
NTSTATUS
STDCALL
-MmCreatePeb(PEPROCESS Process)
+MmCreatePeb(PROS_EPROCESS Process)
{
PPEB Peb = NULL;
LARGE_INTEGER SectionOffset;
- ULONG ViewSize = 0;
+ SIZE_T ViewSize = 0;
PVOID TableBase = NULL;
PIMAGE_NT_HEADERS NtHeaders;
PIMAGE_LOAD_CONFIG_DIRECTORY ImageConfigData;
/* Allocate the PEB */
Peb = MiCreatePebOrTeb(Process,
(PVOID)((ULONG_PTR)MM_HIGHEST_VAD_ADDRESS + 1));
- ASSERT(Peb == (PVOID)0x7FFDF000)
+ ASSERT(Peb == (PVOID)0x7FFDF000);
/* Map NLS Tables */
DPRINT("Mapping NLS\n");
Status = MmMapViewOfSection(NlsSectionObject,
- Process,
+ (PEPROCESS)Process,
&TableBase,
0,
0,
PTEB
STDCALL
-MmCreateTeb(PEPROCESS Process,
+MmCreateTeb(PROS_EPROCESS Process,
PCLIENT_ID ClientId,
PINITIAL_TEB InitialTeb)
{
/* Attach to the process */
DPRINT("MmCreateTeb\n");
- if (Process != PsGetCurrentProcess())
+ if (Process != (PROS_EPROCESS)PsGetCurrentProcess())
{
/* Attach to Target */
KeAttachProcess(&Process->Pcb);
NTSTATUS
STDCALL
-MmCreateProcessAddressSpace(IN PEPROCESS Process,
- IN PSECTION_OBJECT Section OPTIONAL)
+MmCreateProcessAddressSpace(IN PROS_EPROCESS Process,
+ IN PROS_SECTION_OBJECT Section OPTIONAL)
{
NTSTATUS Status;
PMADDRESS_SPACE ProcessAddressSpace = &Process->AddressSpace;
PVOID BaseAddress;
PMEMORY_AREA MemoryArea;
PHYSICAL_ADDRESS BoundaryAddressMultiple;
- ULONG ViewSize = 0;
+ SIZE_T ViewSize = 0;
PVOID ImageBase = 0;
BoundaryAddressMultiple.QuadPart = 0;
DPRINT("Mapping process image. Section: %p, Process: %p, ImageBase: %p\n",
Section, Process, &ImageBase);
Status = MmMapViewOfSection(Section,
- Process,
+ (PEPROCESS)Process,
(PVOID*)&ImageBase,
0,
0,