- Removed the process member from the memory area structure.

- Add the copyright notice and all programmers.

svn path=/trunk/; revision=15832
This commit is contained in:
Hartmut Birr 2005-06-07 17:07:34 +00:00
parent cc0fc0d35c
commit b4f774ec1e
4 changed files with 185 additions and 52 deletions

View file

@ -1,5 +1,40 @@
/* /* $Id$
* Higher level memory managment definitions *
* Copyright (C) 1998-2005 ReactOS Team (and the authors from the programmers section)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/include/internal/mm.h
* PURPOSE: level memory managment definitions
*
* PROGRAMMERS: David Welch
* Casper Hornstrup
* Hartmut Birr
* Ge van Geldorp
* Eric Kohl
* silverblade
* James Tabor
* Alex Ionescu
* tamlin
* Thomas Weidenmueller
* Filip Navara
* KJK::Hyperion
* Gregor Anich
* Steven Edwards
*/ */
#ifndef __INCLUDE_INTERNAL_MM_H #ifndef __INCLUDE_INTERNAL_MM_H
@ -218,7 +253,6 @@ typedef struct _MEMORY_AREA
ULONG Type; ULONG Type;
ULONG Attributes; ULONG Attributes;
ULONG LockCount; ULONG LockCount;
struct _EPROCESS* Process; /* FIXME: We don't need this! */
BOOLEAN DeleteInProgress; BOOLEAN DeleteInProgress;
ULONG PageOpCount; ULONG PageOpCount;
union union

View file

@ -1,11 +1,42 @@
/* $Id$ /* $Id$
* *
* COPYRIGHT: See COPYING in the top level directory * Copyright (C) 2002-2005 ReactOS Team (and the authors from the programmers section)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/anonmem.c * FILE: ntoskrnl/mm/anonmem.c
* PURPOSE: Implementing anonymous memory. * PURPOSE: Implementing anonymous memory.
* *
* PROGRAMMERS: David Welch * PROGRAMMERS: David Welch
* Hartmut Birr
* Casper Hornstrup
* KJK::Hyperion
* Ge van Geldorp
* Eric Kohl
* Royce Mitchell III
* Aleksey Bragin
* Jason Filby
* Art Yerkes
* Gunnar Andre' Dalsnes
* Filip Navara
* Thomas Weidenmueller
* Alex Ionescu
* Trevor McCort
* Steven Edwards
*/ */
/* INCLUDE *****************************************************************/ /* INCLUDE *****************************************************************/
@ -42,7 +73,7 @@ MmWritePageVirtualMemory(PMADDRESS_SPACE AddressSpace,
/* /*
* Get that the page actually is dirty. * Get that the page actually is dirty.
*/ */
if (!MmIsDirtyPage(MemoryArea->Process, Address)) if (!MmIsDirtyPage(AddressSpace->Process, Address))
{ {
PageOp->Status = STATUS_SUCCESS; PageOp->Status = STATUS_SUCCESS;
KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE); KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
@ -53,7 +84,7 @@ MmWritePageVirtualMemory(PMADDRESS_SPACE AddressSpace,
/* /*
* Speculatively set the mapping to clean. * Speculatively set the mapping to clean.
*/ */
MmSetCleanPage(MemoryArea->Process, Address); MmSetCleanPage(AddressSpace->Process, Address);
/* /*
* If necessary, allocate an entry in the paging file for this page * If necessary, allocate an entry in the paging file for this page
@ -64,7 +95,7 @@ MmWritePageVirtualMemory(PMADDRESS_SPACE AddressSpace,
SwapEntry = MmAllocSwapPage(); SwapEntry = MmAllocSwapPage();
if (SwapEntry == 0) if (SwapEntry == 0)
{ {
MmSetDirtyPage(MemoryArea->Process, Address); MmSetDirtyPage(AddressSpace->Process, Address);
PageOp->Status = STATUS_PAGEFILE_QUOTA_EXCEEDED; PageOp->Status = STATUS_PAGEFILE_QUOTA_EXCEEDED;
KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE); KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
MmReleasePageOp(PageOp); MmReleasePageOp(PageOp);
@ -80,7 +111,7 @@ MmWritePageVirtualMemory(PMADDRESS_SPACE AddressSpace,
{ {
DPRINT1("MM: Failed to write to swap page (Status was 0x%.8X)\n", DPRINT1("MM: Failed to write to swap page (Status was 0x%.8X)\n",
Status); Status);
MmSetDirtyPage(MemoryArea->Process, Address); MmSetDirtyPage(AddressSpace->Process, Address);
PageOp->Status = STATUS_UNSUCCESSFUL; PageOp->Status = STATUS_UNSUCCESSFUL;
KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE); KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
MmReleasePageOp(PageOp); MmReleasePageOp(PageOp);
@ -125,7 +156,7 @@ MmPageOutVirtualMemory(PMADDRESS_SPACE AddressSpace,
/* /*
* Disable the virtual mapping. * Disable the virtual mapping.
*/ */
MmDisableVirtualMapping(MemoryArea->Process, Address, MmDisableVirtualMapping(AddressSpace->Process, Address,
&WasDirty, &Page); &WasDirty, &Page);
if (Page == 0) if (Page == 0)
@ -138,11 +169,11 @@ MmPageOutVirtualMemory(PMADDRESS_SPACE AddressSpace,
*/ */
if (!WasDirty) if (!WasDirty)
{ {
MmDeleteVirtualMapping(MemoryArea->Process, Address, FALSE, NULL, NULL); MmDeleteVirtualMapping(AddressSpace->Process, Address, FALSE, NULL, NULL);
MmDeleteAllRmaps(Page, NULL, NULL); MmDeleteAllRmaps(Page, NULL, NULL);
if ((SwapEntry = MmGetSavedSwapEntryPage(Page)) != 0) if ((SwapEntry = MmGetSavedSwapEntryPage(Page)) != 0)
{ {
MmCreatePageFileMapping(MemoryArea->Process, Address, SwapEntry); MmCreatePageFileMapping(AddressSpace->Process, Address, SwapEntry);
MmSetSavedSwapEntryPage(Page, 0); MmSetSavedSwapEntryPage(Page, 0);
} }
MmReleasePageMemoryConsumer(MC_USER, Page); MmReleasePageMemoryConsumer(MC_USER, Page);
@ -162,7 +193,7 @@ MmPageOutVirtualMemory(PMADDRESS_SPACE AddressSpace,
if (SwapEntry == 0) if (SwapEntry == 0)
{ {
MmShowOutOfSpaceMessagePagingFile(); MmShowOutOfSpaceMessagePagingFile();
MmEnableVirtualMapping(MemoryArea->Process, Address); MmEnableVirtualMapping(AddressSpace->Process, Address);
PageOp->Status = STATUS_UNSUCCESSFUL; PageOp->Status = STATUS_UNSUCCESSFUL;
KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE); KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
MmReleasePageOp(PageOp); MmReleasePageOp(PageOp);
@ -178,7 +209,7 @@ MmPageOutVirtualMemory(PMADDRESS_SPACE AddressSpace,
{ {
DPRINT1("MM: Failed to write to swap page (Status was 0x%.8X)\n", DPRINT1("MM: Failed to write to swap page (Status was 0x%.8X)\n",
Status); Status);
MmEnableVirtualMapping(MemoryArea->Process, Address); MmEnableVirtualMapping(AddressSpace->Process, Address);
PageOp->Status = STATUS_UNSUCCESSFUL; PageOp->Status = STATUS_UNSUCCESSFUL;
KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE); KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
MmReleasePageOp(PageOp); MmReleasePageOp(PageOp);
@ -189,8 +220,8 @@ MmPageOutVirtualMemory(PMADDRESS_SPACE AddressSpace,
* Otherwise we have succeeded, free the page * Otherwise we have succeeded, free the page
*/ */
DPRINT("MM: Swapped out virtual memory page 0x%.8X!\n", Page << PAGE_SHIFT); DPRINT("MM: Swapped out virtual memory page 0x%.8X!\n", Page << PAGE_SHIFT);
MmDeleteVirtualMapping(MemoryArea->Process, Address, FALSE, NULL, NULL); MmDeleteVirtualMapping(AddressSpace->Process, Address, FALSE, NULL, NULL);
MmCreatePageFileMapping(MemoryArea->Process, Address, SwapEntry); MmCreatePageFileMapping(AddressSpace->Process, Address, SwapEntry);
MmDeleteAllRmaps(Page, NULL, NULL); MmDeleteAllRmaps(Page, NULL, NULL);
MmSetSavedSwapEntryPage(Page, 0); MmSetSavedSwapEntryPage(Page, 0);
MmReleasePageMemoryConsumer(MC_USER, Page); MmReleasePageMemoryConsumer(MC_USER, Page);
@ -256,7 +287,7 @@ MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace,
/* /*
* Get or create a page operation * Get or create a page operation
*/ */
PageOp = MmGetPageOp(MemoryArea, MemoryArea->Process->UniqueProcessId, PageOp = MmGetPageOp(MemoryArea, AddressSpace->Process->UniqueProcessId,
(PVOID)PAGE_ROUND_DOWN(Address), NULL, 0, (PVOID)PAGE_ROUND_DOWN(Address), NULL, 0,
MM_PAGEOP_PAGEIN, FALSE); MM_PAGEOP_PAGEIN, FALSE);
if (PageOp == NULL) if (PageOp == NULL)
@ -344,7 +375,7 @@ MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace,
{ {
SWAPENTRY SwapEntry; SWAPENTRY SwapEntry;
MmDeletePageFileMapping(MemoryArea->Process, Address, &SwapEntry); MmDeletePageFileMapping(AddressSpace->Process, Address, &SwapEntry);
Status = MmReadFromSwapPage(SwapEntry, Page); Status = MmReadFromSwapPage(SwapEntry, Page);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
@ -357,7 +388,7 @@ MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace,
* Set the page. If we fail because we are out of memory then * Set the page. If we fail because we are out of memory then
* try again * try again
*/ */
Status = MmCreateVirtualMapping(MemoryArea->Process, Status = MmCreateVirtualMapping(AddressSpace->Process,
(PVOID)PAGE_ROUND_DOWN(Address), (PVOID)PAGE_ROUND_DOWN(Address),
Region->Protect, Region->Protect,
&Page, &Page,
@ -365,7 +396,7 @@ MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace,
while (Status == STATUS_NO_MEMORY) while (Status == STATUS_NO_MEMORY)
{ {
MmUnlockAddressSpace(AddressSpace); MmUnlockAddressSpace(AddressSpace);
Status = MmCreateVirtualMapping(MemoryArea->Process, Status = MmCreateVirtualMapping(AddressSpace->Process,
Address, Address,
Region->Protect, Region->Protect,
&Page, &Page,
@ -382,7 +413,7 @@ MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace,
/* /*
* Add the page to the process's working set * Add the page to the process's working set
*/ */
MmInsertRmap(Page, MemoryArea->Process, (PVOID)PAGE_ROUND_DOWN(Address)); MmInsertRmap(Page, AddressSpace->Process, (PVOID)PAGE_ROUND_DOWN(Address));
/* /*
* Finish the operation * Finish the operation

View file

@ -1,11 +1,44 @@
/* $Id$ /* $Id$
* *
* COPYRIGHT: See COPYING in the top level directory * Copyright (C) 1998-2005 ReactOS Team (and the authors from the programmers section)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/marea.c * FILE: ntoskrnl/mm/marea.c
* PURPOSE: Implements memory areas * PURPOSE: Implements memory areas
* *
* PROGRAMMERS: David Welch (welch@mcmail.com) * PROGRAMMERS: Rex Jolliff
* David Welch
* Eric Kohl
* Philip Susi
* Casper Hornstrup
* Hartmut Birr
* Eric Kohl
* Ge van Geldorp
* Royce Mitchell III
* Aleksey Bragin
* Jason Filby
* Thomas Weidenmueller
* Gunnar Andre' Dalsnes
* tamlin
* Alex Ionescu
* Filip Navara
* Herve Poussineau
* Steven Edwards
*/ */
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
@ -974,7 +1007,6 @@ MmCreateMemoryArea(PEPROCESS Process,
MemoryArea->EndingAddress = (PVOID)((ULONG_PTR)*BaseAddress + tmpLength); MemoryArea->EndingAddress = (PVOID)((ULONG_PTR)*BaseAddress + tmpLength);
MemoryArea->Attributes = Attributes; MemoryArea->Attributes = Attributes;
MemoryArea->LockCount = 0; MemoryArea->LockCount = 0;
MemoryArea->Process = Process;
MemoryArea->PageOpCount = 0; MemoryArea->PageOpCount = 0;
MemoryArea->DeleteInProgress = FALSE; MemoryArea->DeleteInProgress = FALSE;

View file

@ -1,11 +1,47 @@
/* $Id$ /* $Id$
* *
* COPYRIGHT: See COPYING in the top level directory * Copyright (C) 1998-2005 ReactOS Team (and the authors from the programmers section)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/section.c * FILE: ntoskrnl/mm/section.c
* PURPOSE: Implements section objects * PURPOSE: Implements section objects
* *
* PROGRAMMERS: David Welch (welch@mcmail.com) * PROGRAMMERS: Rex Jolliff
* David Welch
* Eric Kohl
* Emanuele Aliberti
* Eugene Ingerman
* Hartmut Birr
* Casper Hornstrup
* KJK::Hyperion
* Guido de Jong
* Ge van Geldorp
* Royce Mitchell III
* Filip Navara
* Aleksey Bragin
* Jason Filby
* Thomas Weidenmueller
* Gunnar Andre' Dalsnes
* tamlin
* Alex Ionescu
* Gregor Anich
* Steven Edwards
* Herve Poussineau
*/ */
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
@ -727,7 +763,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
/* FIXME: Should we call MmCreateVirtualMappingUnsafe if /* FIXME: Should we call MmCreateVirtualMappingUnsafe if
* (Section->AllocationAttributes & SEC_PHYSICALMEMORY) is true? * (Section->AllocationAttributes & SEC_PHYSICALMEMORY) is true?
*/ */
Status = MmCreateVirtualMapping(MemoryArea->Process, Status = MmCreateVirtualMapping(AddressSpace->Process,
Address, Address,
Attributes, Attributes,
&Page, &Page,
@ -737,7 +773,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
DbgPrint("Unable to create virtual mapping\n"); DbgPrint("Unable to create virtual mapping\n");
KEBUGCHECK(0); KEBUGCHECK(0);
} }
MmInsertRmap(Page, MemoryArea->Process, (PVOID)PAddress); MmInsertRmap(Page, AddressSpace->Process, (PVOID)PAddress);
} }
if (Locked) if (Locked)
{ {
@ -1540,14 +1576,14 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
*/ */
if (Context.Private) if (Context.Private)
{ {
Status = MmCreateVirtualMapping(MemoryArea->Process, Status = MmCreateVirtualMapping(AddressSpace->Process,
Address, Address,
MemoryArea->Attributes, MemoryArea->Attributes,
&Page, &Page,
1); 1);
MmSetDirtyPage(MemoryArea->Process, Address); MmSetDirtyPage(AddressSpace->Process, Address);
MmInsertRmap(Page, MmInsertRmap(Page,
MemoryArea->Process, AddressSpace->Process,
Address); Address);
} }
else else
@ -1557,14 +1593,14 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
* set it back into the section segment entry so we don't loose * set it back into the section segment entry so we don't loose
* our copy. Otherwise it will be handled by the cache manager. * our copy. Otherwise it will be handled by the cache manager.
*/ */
Status = MmCreateVirtualMapping(MemoryArea->Process, Status = MmCreateVirtualMapping(AddressSpace->Process,
Address, Address,
MemoryArea->Attributes, MemoryArea->Attributes,
&Page, &Page,
1); 1);
MmSetDirtyPage(MemoryArea->Process, Address); MmSetDirtyPage(AddressSpace->Process, Address);
MmInsertRmap(Page, MmInsertRmap(Page,
MemoryArea->Process, AddressSpace->Process,
Address); Address);
Entry = MAKE_SSE(Page << PAGE_SHIFT, 1); Entry = MAKE_SSE(Page << PAGE_SHIFT, 1);
MmSetPageEntrySectionSegment(Context.Segment, Context.Offset, Entry); MmSetPageEntrySectionSegment(Context.Segment, Context.Offset, Entry);
@ -1589,26 +1625,26 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
*/ */
if (Context.Private) if (Context.Private)
{ {
Status = MmCreateVirtualMapping(MemoryArea->Process, Status = MmCreateVirtualMapping(AddressSpace->Process,
Address, Address,
MemoryArea->Attributes, MemoryArea->Attributes,
&Page, &Page,
1); 1);
MmSetDirtyPage(MemoryArea->Process, Address); MmSetDirtyPage(AddressSpace->Process, Address);
MmInsertRmap(Page, MmInsertRmap(Page,
MemoryArea->Process, AddressSpace->Process,
Address); Address);
} }
else else
{ {
Status = MmCreateVirtualMapping(MemoryArea->Process, Status = MmCreateVirtualMapping(AddressSpace->Process,
Address, Address,
MemoryArea->Attributes, MemoryArea->Attributes,
&Page, &Page,
1); 1);
MmSetDirtyPage(MemoryArea->Process, Address); MmSetDirtyPage(AddressSpace->Process, Address);
MmInsertRmap(Page, MmInsertRmap(Page,
MemoryArea->Process, AddressSpace->Process,
Address); Address);
Entry = MAKE_SSE(Page << PAGE_SHIFT, 1); Entry = MAKE_SSE(Page << PAGE_SHIFT, 1);
MmSetPageEntrySectionSegment(Context.Segment, Context.Offset, Entry); MmSetPageEntrySectionSegment(Context.Segment, Context.Offset, Entry);
@ -1635,7 +1671,7 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
if (Context.Private) if (Context.Private)
{ {
Status = MmCreatePageFileMapping(MemoryArea->Process, Status = MmCreatePageFileMapping(AddressSpace->Process,
Address, Address,
SwapEntry); SwapEntry);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
@ -3641,7 +3677,6 @@ VOID STATIC
MmFreeSectionPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address, MmFreeSectionPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address,
PFN_TYPE Page, SWAPENTRY SwapEntry, BOOLEAN Dirty) PFN_TYPE Page, SWAPENTRY SwapEntry, BOOLEAN Dirty)
{ {
PMEMORY_AREA MArea;
ULONG Entry; ULONG Entry;
PFILE_OBJECT FileObject; PFILE_OBJECT FileObject;
PBCB Bcb; PBCB Bcb;
@ -3651,23 +3686,24 @@ MmFreeSectionPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address,
NTSTATUS Status; NTSTATUS Status;
PSECTION_OBJECT Section; PSECTION_OBJECT Section;
PMM_SECTION_SEGMENT Segment; PMM_SECTION_SEGMENT Segment;
PMADDRESS_SPACE AddressSpace;
MArea = (PMEMORY_AREA)Context; AddressSpace = (PMADDRESS_SPACE)Context;
Address = (PVOID)PAGE_ROUND_DOWN(Address); Address = (PVOID)PAGE_ROUND_DOWN(Address);
Offset = ((ULONG_PTR)Address - (ULONG_PTR)MArea->StartingAddress) + Offset = ((ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress) +
MemoryArea->Data.SectionData.ViewOffset; MemoryArea->Data.SectionData.ViewOffset;
Section = MArea->Data.SectionData.Section; Section = MemoryArea->Data.SectionData.Section;
Segment = MArea->Data.SectionData.Segment; Segment = MemoryArea->Data.SectionData.Segment;
PageOp = MmCheckForPageOp(MArea, NULL, NULL, Segment, Offset); PageOp = MmCheckForPageOp(MemoryArea, NULL, NULL, Segment, Offset);
while (PageOp) while (PageOp)
{ {
MmUnlockSectionSegment(Segment); MmUnlockSectionSegment(Segment);
MmUnlockAddressSpace(&MArea->Process->AddressSpace); MmUnlockAddressSpace(AddressSpace);
Status = MmspWaitForPageOpCompletionEvent(PageOp); Status = MmspWaitForPageOpCompletionEvent(PageOp);
if (Status != STATUS_SUCCESS) if (Status != STATUS_SUCCESS)
@ -3676,10 +3712,10 @@ MmFreeSectionPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address,
KEBUGCHECK(0); KEBUGCHECK(0);
} }
MmLockAddressSpace(&MArea->Process->AddressSpace); MmLockAddressSpace(AddressSpace);
MmLockSectionSegment(Segment); MmLockSectionSegment(Segment);
MmspCompleteAndReleasePageOp(PageOp); MmspCompleteAndReleasePageOp(PageOp);
PageOp = MmCheckForPageOp(MArea, NULL, NULL, Segment, Offset); PageOp = MmCheckForPageOp(MemoryArea, NULL, NULL, Segment, Offset);
} }
Entry = MmGetPageEntrySectionSegment(Segment, Offset); Entry = MmGetPageEntrySectionSegment(Segment, Offset);
@ -3733,12 +3769,12 @@ MmFreeSectionPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address,
MmFreeSwapPage(SavedSwapEntry); MmFreeSwapPage(SavedSwapEntry);
MmSetSavedSwapEntryPage(Page, 0); MmSetSavedSwapEntryPage(Page, 0);
} }
MmDeleteRmap(Page, MArea->Process, Address); MmDeleteRmap(Page, AddressSpace->Process, Address);
MmReleasePageMemoryConsumer(MC_USER, Page); MmReleasePageMemoryConsumer(MC_USER, Page);
} }
else else
{ {
MmDeleteRmap(Page, MArea->Process, Address); MmDeleteRmap(Page, AddressSpace->Process, Address);
MmUnsharePageEntrySectionSegment(Section, Segment, Offset, Dirty, FALSE); MmUnsharePageEntrySectionSegment(Section, Segment, Offset, Dirty, FALSE);
} }
} }
@ -3789,7 +3825,7 @@ MmUnmapViewOfSegment(PMADDRESS_SPACE AddressSpace,
Status = MmFreeMemoryArea(AddressSpace, Status = MmFreeMemoryArea(AddressSpace,
MemoryArea, MemoryArea,
MmFreeSectionPage, MmFreeSectionPage,
MemoryArea); AddressSpace);
} }
MmUnlockSectionSegment(Segment); MmUnlockSectionSegment(Segment);
ObDereferenceObject(Section); ObDereferenceObject(Section);