mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 17:05:46 +00:00
Signaled the event of pageop at return if the function have previous wait at this event.
Freed the section segments for a pagefile mapping in MmpDeleteSection. Dereferenced the section object at the end of MmCreatePageFileSection. Implemented MmFlushImageSection (not complete). svn path=/trunk/; revision=3973
This commit is contained in:
parent
14c1929fc2
commit
be6d0d37cd
1 changed files with 52 additions and 27 deletions
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: section.c,v 1.102 2002/12/15 17:01:52 chorns Exp $
|
/* $Id: section.c,v 1.103 2003/01/11 15:31:05 hbirr Exp $
|
||||||
*
|
*
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/mm/section.c
|
* FILE: ntoskrnl/mm/section.c
|
||||||
|
@ -564,6 +564,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
||||||
if (PageOp->OpType != MM_PAGEOP_PAGEIN)
|
if (PageOp->OpType != MM_PAGEOP_PAGEIN)
|
||||||
{
|
{
|
||||||
MmLockAddressSpace(AddressSpace);
|
MmLockAddressSpace(AddressSpace);
|
||||||
|
KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
|
||||||
MmReleasePageOp(PageOp);
|
MmReleasePageOp(PageOp);
|
||||||
DPRINT("Address 0x%.8X\n", Address);
|
DPRINT("Address 0x%.8X\n", Address);
|
||||||
return(STATUS_MM_RESTART_OPERATION);
|
return(STATUS_MM_RESTART_OPERATION);
|
||||||
|
@ -574,8 +575,11 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
||||||
if (!NT_SUCCESS(PageOp->Status))
|
if (!NT_SUCCESS(PageOp->Status))
|
||||||
{
|
{
|
||||||
MmLockAddressSpace(AddressSpace);
|
MmLockAddressSpace(AddressSpace);
|
||||||
|
Status = PageOp->Status;
|
||||||
|
KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
|
||||||
|
MmReleasePageOp(PageOp);
|
||||||
DPRINT("Address 0x%.8X\n", Address);
|
DPRINT("Address 0x%.8X\n", Address);
|
||||||
return(PageOp->Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
MmLockAddressSpace(AddressSpace);
|
MmLockAddressSpace(AddressSpace);
|
||||||
MmLockSection(Section);
|
MmLockSection(Section);
|
||||||
|
@ -591,6 +595,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
||||||
{
|
{
|
||||||
MmUnlockSectionSegment(Segment);
|
MmUnlockSectionSegment(Segment);
|
||||||
MmUnlockSection(Section);
|
MmUnlockSection(Section);
|
||||||
|
KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
|
||||||
MmReleasePageOp(PageOp);
|
MmReleasePageOp(PageOp);
|
||||||
return(STATUS_MM_RESTART_OPERATION);
|
return(STATUS_MM_RESTART_OPERATION);
|
||||||
}
|
}
|
||||||
|
@ -599,7 +604,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
||||||
MmReferencePage(Page);
|
MmReferencePage(Page);
|
||||||
MmSharePageEntrySectionSegment(Segment, Offset.u.LowPart);
|
MmSharePageEntrySectionSegment(Segment, Offset.u.LowPart);
|
||||||
|
|
||||||
Status = MmCreateVirtualMapping(PsGetCurrentProcess(),
|
Status = MmCreateVirtualMapping(MemoryArea->Process,
|
||||||
Address,
|
Address,
|
||||||
MemoryArea->Attributes,
|
MemoryArea->Attributes,
|
||||||
Page,
|
Page,
|
||||||
|
@ -609,7 +614,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, PsGetCurrentProcess(),
|
MmInsertRmap(Page, MemoryArea->Process,
|
||||||
(PVOID)PAGE_ROUND_DOWN(Address));
|
(PVOID)PAGE_ROUND_DOWN(Address));
|
||||||
}
|
}
|
||||||
if (Locked)
|
if (Locked)
|
||||||
|
@ -618,6 +623,8 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
||||||
}
|
}
|
||||||
MmUnlockSectionSegment(Segment);
|
MmUnlockSectionSegment(Segment);
|
||||||
MmUnlockSection(Section);
|
MmUnlockSection(Section);
|
||||||
|
PageOp->Status = STATUS_SUCCESS;
|
||||||
|
KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
|
||||||
MmReleasePageOp(PageOp);
|
MmReleasePageOp(PageOp);
|
||||||
DPRINT("Address 0x%.8X\n", Address);
|
DPRINT("Address 0x%.8X\n", Address);
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
|
@ -650,7 +657,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
||||||
KeBugCheck(0);
|
KeBugCheck(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = MmCreateVirtualMapping(PsGetCurrentProcess(),
|
Status = MmCreateVirtualMapping(AddressSpace->Process,
|
||||||
Address,
|
Address,
|
||||||
Region->Protect,
|
Region->Protect,
|
||||||
Page,
|
Page,
|
||||||
|
@ -658,7 +665,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
||||||
while (Status == STATUS_NO_MEMORY)
|
while (Status == STATUS_NO_MEMORY)
|
||||||
{
|
{
|
||||||
MmUnlockAddressSpace(AddressSpace);
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
Status = MmCreateVirtualMapping(PsGetCurrentProcess(),
|
Status = MmCreateVirtualMapping(AddressSpace->Process,
|
||||||
Address,
|
Address,
|
||||||
Region->Protect,
|
Region->Protect,
|
||||||
Page,
|
Page,
|
||||||
|
@ -680,7 +687,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
||||||
/*
|
/*
|
||||||
* Add the page to the process's working set
|
* Add the page to the process's working set
|
||||||
*/
|
*/
|
||||||
MmInsertRmap(Page, PsGetCurrentProcess(),
|
MmInsertRmap(Page, AddressSpace->Process,
|
||||||
(PVOID)PAGE_ROUND_DOWN(Address));
|
(PVOID)PAGE_ROUND_DOWN(Address));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -705,7 +712,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
||||||
/*
|
/*
|
||||||
* Just map the desired physical page
|
* Just map the desired physical page
|
||||||
*/
|
*/
|
||||||
Status = MmCreateVirtualMapping(PsGetCurrentProcess(),
|
Status = MmCreateVirtualMapping(AddressSpace->Process,
|
||||||
Address,
|
Address,
|
||||||
Region->Protect,
|
Region->Protect,
|
||||||
Offset,
|
Offset,
|
||||||
|
@ -748,12 +755,12 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
||||||
MmLockSectionSegment(Segment);
|
MmLockSectionSegment(Segment);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = MmCreateVirtualMapping(PsGetCurrentProcess(),
|
Status = MmCreateVirtualMapping(AddressSpace->Process,
|
||||||
Address,
|
Address,
|
||||||
Region->Protect,
|
Region->Protect,
|
||||||
Page,
|
Page,
|
||||||
FALSE);
|
FALSE);
|
||||||
MmInsertRmap(Page, PsGetCurrentProcess(),
|
MmInsertRmap(Page, AddressSpace->Process,
|
||||||
(PVOID)PAGE_ROUND_DOWN(Address));
|
(PVOID)PAGE_ROUND_DOWN(Address));
|
||||||
if (Locked)
|
if (Locked)
|
||||||
{
|
{
|
||||||
|
@ -842,7 +849,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
||||||
MmSetPageEntrySectionSegment(Segment, Offset.QuadPart, Entry);
|
MmSetPageEntrySectionSegment(Segment, Offset.QuadPart, Entry);
|
||||||
MmSharePageEntrySectionSegment(Segment, Offset.QuadPart);
|
MmSharePageEntrySectionSegment(Segment, Offset.QuadPart);
|
||||||
|
|
||||||
Status = MmCreateVirtualMapping(PsGetCurrentProcess(),
|
Status = MmCreateVirtualMapping(AddressSpace->Process,
|
||||||
Address,
|
Address,
|
||||||
Attributes,
|
Attributes,
|
||||||
Page,
|
Page,
|
||||||
|
@ -852,7 +859,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
||||||
MmUnlockSectionSegment(Segment);
|
MmUnlockSectionSegment(Segment);
|
||||||
MmUnlockSection(Section);
|
MmUnlockSection(Section);
|
||||||
MmUnlockAddressSpace(AddressSpace);
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
Status = MmCreateVirtualMapping(PsGetCurrentProcess(),
|
Status = MmCreateVirtualMapping(AddressSpace->Process,
|
||||||
Address,
|
Address,
|
||||||
Attributes,
|
Attributes,
|
||||||
Page,
|
Page,
|
||||||
|
@ -865,7 +872,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
||||||
MmLockSection(Section);
|
MmLockSection(Section);
|
||||||
MmLockSectionSegment(Segment);
|
MmLockSectionSegment(Segment);
|
||||||
}
|
}
|
||||||
MmInsertRmap(Page, PsGetCurrentProcess(),
|
MmInsertRmap(Page, AddressSpace->Process,
|
||||||
(PVOID)PAGE_ROUND_DOWN(Address));
|
(PVOID)PAGE_ROUND_DOWN(Address));
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
@ -943,12 +950,12 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
||||||
*/
|
*/
|
||||||
MmSetSavedSwapEntryPage(Page, SwapEntry);
|
MmSetSavedSwapEntryPage(Page, SwapEntry);
|
||||||
|
|
||||||
Status = MmCreateVirtualMapping(PsGetCurrentProcess(),
|
Status = MmCreateVirtualMapping(AddressSpace->Process,
|
||||||
Address,
|
Address,
|
||||||
Attributes,
|
Attributes,
|
||||||
Page,
|
Page,
|
||||||
FALSE);
|
FALSE);
|
||||||
MmInsertRmap(Page, PsGetCurrentProcess(),
|
MmInsertRmap(Page, AddressSpace->Process,
|
||||||
(PVOID)PAGE_ROUND_DOWN(Address));
|
(PVOID)PAGE_ROUND_DOWN(Address));
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
@ -978,12 +985,12 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
||||||
MmReferencePage(Page);
|
MmReferencePage(Page);
|
||||||
MmSharePageEntrySectionSegment(Segment, Offset.QuadPart);
|
MmSharePageEntrySectionSegment(Segment, Offset.QuadPart);
|
||||||
|
|
||||||
Status = MmCreateVirtualMapping(PsGetCurrentProcess(),
|
Status = MmCreateVirtualMapping(AddressSpace->Process,
|
||||||
Address,
|
Address,
|
||||||
Attributes,
|
Attributes,
|
||||||
Page,
|
Page,
|
||||||
FALSE);
|
FALSE);
|
||||||
MmInsertRmap(Page, PsGetCurrentProcess(),
|
MmInsertRmap(Page, AddressSpace->Process,
|
||||||
(PVOID)PAGE_ROUND_DOWN(Address));
|
(PVOID)PAGE_ROUND_DOWN(Address));
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
@ -1109,6 +1116,7 @@ MmAccessFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
||||||
* Restart the operation
|
* Restart the operation
|
||||||
*/
|
*/
|
||||||
MmLockAddressSpace(AddressSpace);
|
MmLockAddressSpace(AddressSpace);
|
||||||
|
KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
|
||||||
MmReleasePageOp(PageOp);
|
MmReleasePageOp(PageOp);
|
||||||
return(STATUS_MM_RESTART_OPERATION);
|
return(STATUS_MM_RESTART_OPERATION);
|
||||||
}
|
}
|
||||||
|
@ -1137,18 +1145,18 @@ MmAccessFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
||||||
/*
|
/*
|
||||||
* Delete the old entry.
|
* Delete the old entry.
|
||||||
*/
|
*/
|
||||||
MmDeleteVirtualMapping(PsGetCurrentProcess(), Address, FALSE, NULL, NULL);
|
MmDeleteVirtualMapping(AddressSpace->Process, Address, FALSE, NULL, NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the PTE to point to the new page
|
* Set the PTE to point to the new page
|
||||||
*/
|
*/
|
||||||
MmLockAddressSpace(AddressSpace);
|
MmLockAddressSpace(AddressSpace);
|
||||||
Status = MmCreateVirtualMapping(PsGetCurrentProcess(),
|
Status = MmCreateVirtualMapping(AddressSpace->Process,
|
||||||
Address,
|
Address,
|
||||||
Region->Protect,
|
Region->Protect,
|
||||||
NewPage,
|
NewPage,
|
||||||
FALSE);
|
FALSE);
|
||||||
MmInsertRmap(NewPage, PsGetCurrentProcess(),
|
MmInsertRmap(NewPage, AddressSpace->Process,
|
||||||
(PVOID)PAGE_ROUND_DOWN(Address));
|
(PVOID)PAGE_ROUND_DOWN(Address));
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
@ -1164,7 +1172,7 @@ MmAccessFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
||||||
* Unshare the old page.
|
* Unshare the old page.
|
||||||
*/
|
*/
|
||||||
MmUnsharePageEntrySectionSegment(Section, Segment, Offset.QuadPart, FALSE);
|
MmUnsharePageEntrySectionSegment(Section, Segment, Offset.QuadPart, FALSE);
|
||||||
MmDeleteRmap(OldPage, PsGetCurrentProcess(),
|
MmDeleteRmap(OldPage, AddressSpace->Process,
|
||||||
(PVOID)PAGE_ROUND_DOWN(Address));
|
(PVOID)PAGE_ROUND_DOWN(Address));
|
||||||
MmReleasePageMemoryConsumer(MC_USER, OldPage);
|
MmReleasePageMemoryConsumer(MC_USER, OldPage);
|
||||||
|
|
||||||
|
@ -1843,6 +1851,12 @@ MmpDeleteSection(PVOID ObjectBody)
|
||||||
ObDereferenceObject(Section->FileObject);
|
ObDereferenceObject(Section->FileObject);
|
||||||
Section->FileObject = NULL;
|
Section->FileObject = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Section->Segments->Flags & MM_PAGEFILE_SEGMENT)
|
||||||
|
{
|
||||||
|
MmFreePageTablesSectionSegment(Section->Segments);
|
||||||
|
ExFreePool(Section->Segments);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID STDCALL
|
VOID STDCALL
|
||||||
|
@ -2024,6 +2038,7 @@ MmCreatePageFileSection(PHANDLE SectionHandle,
|
||||||
Segment->Length = MaximumSize.u.LowPart;
|
Segment->Length = MaximumSize.u.LowPart;
|
||||||
Segment->Flags = MM_PAGEFILE_SEGMENT;
|
Segment->Flags = MM_PAGEFILE_SEGMENT;
|
||||||
Segment->WriteCopy = FALSE;
|
Segment->WriteCopy = FALSE;
|
||||||
|
ObDereferenceObject(Section);
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2987,8 +3002,6 @@ MmFreeSectionPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address,
|
||||||
MmFreeSwapPage(SavedSwapEntry);
|
MmFreeSwapPage(SavedSwapEntry);
|
||||||
MmSetSavedSwapEntryPage(PhysAddr, 0);
|
MmSetSavedSwapEntryPage(PhysAddr, 0);
|
||||||
}
|
}
|
||||||
MmDeleteRmap(PhysAddr, MArea->Process, Address);
|
|
||||||
MmReleasePageMemoryConsumer(MC_USER, PhysAddr);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2996,9 +3009,9 @@ MmFreeSectionPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address,
|
||||||
MArea->Data.SectionData.Segment,
|
MArea->Data.SectionData.Segment,
|
||||||
Offset,
|
Offset,
|
||||||
Dirty);
|
Dirty);
|
||||||
MmDeleteRmap(PhysAddr, MArea->Process, Address);
|
|
||||||
MmReleasePageMemoryConsumer(MC_USER, PhysAddr);
|
|
||||||
}
|
}
|
||||||
|
MmDeleteRmap(PhysAddr, MArea->Process, Address);
|
||||||
|
MmReleasePageMemoryConsumer(MC_USER, PhysAddr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3508,8 +3521,20 @@ BOOLEAN STDCALL
|
||||||
MmFlushImageSection (IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
|
MmFlushImageSection (IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
|
||||||
IN MMFLUSH_TYPE FlushType)
|
IN MMFLUSH_TYPE FlushType)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
switch(FlushType)
|
||||||
return (FALSE);
|
{
|
||||||
|
case MmFlushForDelete:
|
||||||
|
if (SectionObjectPointer->ImageSectionObject ||
|
||||||
|
SectionObjectPointer->DataSectionObject)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
CcRosSetRemoveOnClose(SectionObjectPointer);
|
||||||
|
return TRUE;
|
||||||
|
case MmFlushForWrite:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOLEAN STDCALL
|
BOOLEAN STDCALL
|
||||||
|
|
Loading…
Reference in a new issue