From dab0a7746190acc10f1576a6287d190474f20930 Mon Sep 17 00:00:00 2001 From: Hartmut Birr Date: Fri, 30 Jan 2004 23:57:58 +0000 Subject: [PATCH] - Check for a privat page and change only the page protection for such a page in MmAccessFaultSectionView. svn path=/trunk/; revision=7932 --- reactos/ntoskrnl/mm/section.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/reactos/ntoskrnl/mm/section.c b/reactos/ntoskrnl/mm/section.c index acd41d4029d..a591a29f47c 100644 --- a/reactos/ntoskrnl/mm/section.c +++ b/reactos/ntoskrnl/mm/section.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: section.c,v 1.142 2004/01/27 20:13:08 hbirr Exp $ +/* $Id: section.c,v 1.143 2004/01/30 23:57:58 hbirr Exp $ * * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/section.c @@ -1218,6 +1218,7 @@ MmAccessFaultSectionView(PMADDRESS_SPACE AddressSpace, ULONG Offset; PMM_PAGEOP PageOp; PMM_REGION Region; + ULONG Entry; /* * Check if the page has been paged out or has already been set readwrite @@ -1253,15 +1254,11 @@ MmAccessFaultSectionView(PMADDRESS_SPACE AddressSpace, */ MmLockSectionSegment(Segment); - /* - * Sanity check. - */ - if (MmGetPageEntrySectionSegment(Segment, Offset) == 0) - { - DPRINT1("COW fault for page with PESS 0. Address was 0x%.8X\n", - Address); - } + OldPage = MmGetPhysicalAddressForProcess(NULL, Address); + Entry = MmGetPageEntrySectionSegment(Segment, Offset); + MmUnlockSectionSegment(Segment); + /* * Check if we are doing COW */ @@ -1273,6 +1270,18 @@ MmAccessFaultSectionView(PMADDRESS_SPACE AddressSpace, return(STATUS_UNSUCCESSFUL); } + if (IS_SWAP_FROM_SSE(Entry) || + PAGE_FROM_SSE(Entry) != OldPage.u.LowPart) + { + /* This is a private page. We must only change the page protection. */ + MmSetPageProtect(AddressSpace->Process, (PVOID)PAddress, Region->Protect); + if (Locked) + { + MmLockPage(OldPage); + } + return(STATUS_SUCCESS); + } + /* * Get or create a pageop */ @@ -1330,7 +1339,6 @@ MmAccessFaultSectionView(PMADDRESS_SPACE AddressSpace, /* * Copy the old page */ - OldPage = MmGetPhysicalAddressForProcess(NULL, Address); NewAddress = ExAllocatePageWithPhysPage(NewPage); memcpy(NewAddress, (PVOID)PAddress, PAGE_SIZE);