Home | Info | Community | Development | myReactOS | Contact Us
Definition at line 427 of file procsup.c.
Referenced by MmGrowKernelStack().
{ PKTHREAD Thread = KeGetCurrentThread(); PMMPTE LimitPte, NewLimitPte, LastPte; KIRQL OldIrql; MMPTE TempPte, InvalidPte; PFN_NUMBER PageFrameIndex; // // Make sure the stack did not overflow // ASSERT(((ULONG_PTR)Thread->StackBase - (ULONG_PTR)Thread->StackLimit) <= (KERNEL_LARGE_STACK_SIZE + PAGE_SIZE)); // // Get the current stack limit // LimitPte = MiAddressToPte(Thread->StackLimit); ASSERT(LimitPte->u.Hard.Valid == 1); // // Get the new one and make sure this isn't a retarded request // NewLimitPte = MiAddressToPte((PVOID)((ULONG_PTR)StackPointer - GrowSize)); if (NewLimitPte == LimitPte) return STATUS_SUCCESS; // // Now make sure you're not going past the reserved space // LastPte = MiAddressToPte((PVOID)((ULONG_PTR)Thread->StackBase - KERNEL_LARGE_STACK_SIZE)); if (NewLimitPte < LastPte) { // // Sorry! // DPRINT1("Thread wants too much stack\n"); return STATUS_STACK_OVERFLOW; } // // Calculate the number of new pages // LimitPte--; /* Setup the temporary invalid PTE */ MI_MAKE_SOFTWARE_PTE(&InvalidPte, MM_NOACCESS); // // Acquire the PFN DB lock // OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); // // Loop each stack page // while (LimitPte >= NewLimitPte) { /* Get a page and write the current invalid PTE */ MI_SET_USAGE(MI_USAGE_KERNEL_STACK_EXPANSION); MI_SET_PROCESS2(PsGetCurrentProcess()->ImageFileName); PageFrameIndex = MiRemoveAnyPage(MI_GET_NEXT_COLOR()); MI_WRITE_INVALID_PTE(LimitPte, InvalidPte); /* Initialize the PFN entry for this page */ MiInitializePfn(PageFrameIndex, LimitPte, 1); /* Setup the template stack PTE */ MI_MAKE_HARDWARE_PTE_KERNEL(&TempPte, LimitPte, MM_READWRITE, PageFrameIndex); /* Write the valid PTE */ MI_WRITE_VALID_PTE(LimitPte--, TempPte); } // // Release the PFN lock // KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql); // // Set the new limit // Thread->StackLimit = (ULONG_PTR)MiPteToAddress(NewLimitPte); return STATUS_SUCCESS; }