mirror of
https://github.com/reactos/reactos.git
synced 2025-05-20 01:24:11 +00:00
[NTOS]: Implement MmCleanProcessAddressSpace in ARM3, now the PEB/TEB VADs are removed when the process exits (although the pages are still leaking, for now), and the pool allocation for the VAD is also freed.
[NTOS]: Use ARM3 paged pool up until smss.exe starts. There's a last bug in the expansion code before we can get rid of the old paged pool. svn path=/trunk/; revision=48234
This commit is contained in:
parent
3ec9a11a16
commit
2384532846
5 changed files with 61 additions and 15 deletions
|
@ -297,7 +297,7 @@ FORCEINLINE
|
||||||
RtlpDeleteAvlTreeNode(IN PRTL_AVL_TABLE Table,
|
RtlpDeleteAvlTreeNode(IN PRTL_AVL_TABLE Table,
|
||||||
IN PRTL_BALANCED_LINKS Node)
|
IN PRTL_BALANCED_LINKS Node)
|
||||||
{
|
{
|
||||||
PRTL_BALANCED_LINKS DeleteNode, ParentNode;
|
PRTL_BALANCED_LINKS DeleteNode = NULL, ParentNode;
|
||||||
PRTL_BALANCED_LINKS *Node1, *Node2;
|
PRTL_BALANCED_LINKS *Node1, *Node2;
|
||||||
CHAR Balance;
|
CHAR Balance;
|
||||||
|
|
||||||
|
@ -320,15 +320,19 @@ RtlpDeleteAvlTreeNode(IN PRTL_AVL_TABLE Table,
|
||||||
|
|
||||||
/* Get the parent node */
|
/* Get the parent node */
|
||||||
ParentNode = RtlParentAvl(DeleteNode);
|
ParentNode = RtlParentAvl(DeleteNode);
|
||||||
|
DPRINT("Parent: %p\n", ParentNode);
|
||||||
|
|
||||||
/* Pick which now to use based on whether or not we have a left child */
|
/* Pick which now to use based on whether or not we have a left child */
|
||||||
Node1 = RtlLeftChildAvl(DeleteNode) ? &DeleteNode->LeftChild : &DeleteNode->RightChild;
|
Node1 = RtlLeftChildAvl(DeleteNode) ? &DeleteNode->LeftChild : &DeleteNode->RightChild;
|
||||||
|
DPRINT("Node 1: %p %p\n", Node1, *Node1);
|
||||||
|
|
||||||
/* Pick which node to swap based on if we're already a left child or not */
|
/* Pick which node to swap based on if we're already a left child or not */
|
||||||
Node2 = RtlIsLeftChildAvl(DeleteNode) ? &ParentNode->LeftChild : &ParentNode->RightChild;
|
Node2 = RtlIsLeftChildAvl(DeleteNode) ? &ParentNode->LeftChild : &ParentNode->RightChild;
|
||||||
|
DPRINT("Node 2: %p %p\n", Node2, *Node2);
|
||||||
|
|
||||||
/* Pick the correct balance depending on which side will get heavier */
|
/* Pick the correct balance depending on which side will get heavier */
|
||||||
Balance = RtlIsLeftChildAvl(DeleteNode) ? RtlLeftHeavyAvlTree : RtlRightHeavyAvlTree;
|
Balance = RtlIsLeftChildAvl(DeleteNode) ? RtlLeftHeavyAvlTree : RtlRightHeavyAvlTree;
|
||||||
|
DPRINT("Balance: %lx\n", Balance);
|
||||||
|
|
||||||
/* Swap the children nodes, making one side heavier */
|
/* Swap the children nodes, making one side heavier */
|
||||||
*Node2 = *Node1;
|
*Node2 = *Node1;
|
||||||
|
|
|
@ -1859,6 +1859,10 @@ Phase1InitializationDiscard(IN PVOID Context)
|
||||||
/* Allow strings to be displayed */
|
/* Allow strings to be displayed */
|
||||||
InbvEnableDisplayString(TRUE);
|
InbvEnableDisplayString(TRUE);
|
||||||
|
|
||||||
|
/* Enough fun for now */
|
||||||
|
extern BOOLEAN AllowPagedPool;
|
||||||
|
AllowPagedPool = FALSE;
|
||||||
|
|
||||||
/* Wait 5 seconds for it to initialize */
|
/* Wait 5 seconds for it to initialize */
|
||||||
Timeout.QuadPart = Int32x32To64(5, -10000000);
|
Timeout.QuadPart = Int32x32To64(5, -10000000);
|
||||||
Status = ZwWaitForSingleObject(ProcessInfo->ProcessHandle, FALSE, &Timeout);
|
Status = ZwWaitForSingleObject(ProcessInfo->ProcessHandle, FALSE, &Timeout);
|
||||||
|
|
|
@ -1083,6 +1083,57 @@ MmCreateProcessAddressSpace(IN ULONG MinWs,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
MmCleanProcessAddressSpace(IN PEPROCESS Process)
|
||||||
|
{
|
||||||
|
PMMVAD Vad;
|
||||||
|
PMM_AVL_TABLE VadTree;
|
||||||
|
PETHREAD Thread = PsGetCurrentThread();
|
||||||
|
|
||||||
|
/* Lock the process address space from changes */
|
||||||
|
MmLockAddressSpace(&Process->Vm);
|
||||||
|
|
||||||
|
/* Enumerate the VADs */
|
||||||
|
VadTree = &Process->VadRoot;
|
||||||
|
DPRINT("Cleaning up VADs: %d\n", VadTree->NumberGenericTableElements);
|
||||||
|
while (VadTree->NumberGenericTableElements)
|
||||||
|
{
|
||||||
|
/* Grab the current VAD */
|
||||||
|
Vad = (PMMVAD)VadTree->BalancedRoot.RightChild;
|
||||||
|
|
||||||
|
/* Lock the working set */
|
||||||
|
MiLockProcessWorkingSet(Process, Thread);
|
||||||
|
|
||||||
|
/* Remove this VAD from the tree */
|
||||||
|
ASSERT(VadTree->NumberGenericTableElements >= 1);
|
||||||
|
DPRINT("Removing node for VAD: %lx %lx\n", Vad->StartingVpn, Vad->EndingVpn);
|
||||||
|
MiRemoveNode((PMMADDRESS_NODE)Vad, VadTree);
|
||||||
|
DPRINT("Moving on: %d\n", VadTree->NumberGenericTableElements);
|
||||||
|
|
||||||
|
/* Check if this VAD was the hint */
|
||||||
|
if (VadTree->NodeHint == Vad)
|
||||||
|
{
|
||||||
|
/* Get a new hint, unless we're empty now, in which case nothing */
|
||||||
|
VadTree->NodeHint = VadTree->BalancedRoot.RightChild;
|
||||||
|
if (!VadTree->NumberGenericTableElements) VadTree->NodeHint = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Only PEB/TEB VADs supported for now */
|
||||||
|
ASSERT(Vad->u.VadFlags.PrivateMemory == 1);
|
||||||
|
ASSERT(Vad->u.VadFlags.VadType == VadNone);
|
||||||
|
|
||||||
|
/* Release the working set */
|
||||||
|
MiUnlockProcessWorkingSet(Process, Thread);
|
||||||
|
|
||||||
|
/* Free the VAD memory */
|
||||||
|
ExFreePool(Vad);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Release the address space */
|
||||||
|
MmUnlockAddressSpace(&Process->Vm);
|
||||||
|
}
|
||||||
|
|
||||||
/* SYSTEM CALLS ***************************************************************/
|
/* SYSTEM CALLS ***************************************************************/
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
|
|
@ -436,12 +436,6 @@ MmInitSystem(IN ULONG Phase,
|
||||||
/* Initialize the balance set manager */
|
/* Initialize the balance set manager */
|
||||||
MmInitBsmThread();
|
MmInitBsmThread();
|
||||||
}
|
}
|
||||||
else if (Phase == 2)
|
|
||||||
{
|
|
||||||
/* Enough fun for now */
|
|
||||||
extern BOOLEAN AllowPagedPool;
|
|
||||||
AllowPagedPool = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,13 +15,6 @@
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
VOID
|
|
||||||
NTAPI
|
|
||||||
MmCleanProcessAddressSpace(IN PEPROCESS Process)
|
|
||||||
{
|
|
||||||
/* FIXME: Add part of MmDeleteProcessAddressSpace here */
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
MmDeleteProcessAddressSpace(PEPROCESS Process)
|
MmDeleteProcessAddressSpace(PEPROCESS Process)
|
||||||
|
|
Loading…
Reference in a new issue