FileObject = MemoryArea->Data.SectionData.Section->FileObject;
Fcb = (PREACTOS_COMMON_FCB_HEADER)FileObject->FsContext;
+ assert(Fcb->Bcb);
+
/*
* If the file system is letting us go directly to the cache and the
* memory area was mapped at an offset in the file which is page aligned
if (PageOp->OpType != MM_PAGEOP_PAGEIN)
{
MmLockAddressSpace(AddressSpace);
+ KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
MmReleasePageOp(PageOp);
DPRINT("Address 0x%.8X\n", Address);
return(STATUS_MM_RESTART_OPERATION);
if (!NT_SUCCESS(PageOp->Status))
{
MmLockAddressSpace(AddressSpace);
+ Status = PageOp->Status;
+ KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
+ MmReleasePageOp(PageOp);
DPRINT("Address 0x%.8X\n", Address);
- return(PageOp->Status);
+ return(Status);
}
MmLockAddressSpace(AddressSpace);
MmLockSection(Section);
{
MmUnlockSectionSegment(Segment);
MmUnlockSection(Section);
+ KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
MmReleasePageOp(PageOp);
return(STATUS_MM_RESTART_OPERATION);
}
MmReferencePage(Page);
MmSharePageEntrySectionSegment(Segment, Offset.u.LowPart);
- Status = MmCreateVirtualMapping(PsGetCurrentProcess(),
+ Status = MmCreateVirtualMapping(MemoryArea->Process,
Address,
MemoryArea->Attributes,
Page,
DbgPrint("Unable to create virtual mapping\n");
KeBugCheck(0);
}
- MmInsertRmap(Page, PsGetCurrentProcess(),
+ MmInsertRmap(Page, MemoryArea->Process,
(PVOID)PAGE_ROUND_DOWN(Address));
}
if (Locked)
}
MmUnlockSectionSegment(Segment);
MmUnlockSection(Section);
+ PageOp->Status = STATUS_SUCCESS;
+ KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
MmReleasePageOp(PageOp);
DPRINT("Address 0x%.8X\n", Address);
return(STATUS_SUCCESS);
KeBugCheck(0);
}
- Status = MmCreateVirtualMapping(PsGetCurrentProcess(),
+ Status = MmCreateVirtualMapping(AddressSpace->Process,
Address,
Region->Protect,
Page,
while (Status == STATUS_NO_MEMORY)
{
MmUnlockAddressSpace(AddressSpace);
- Status = MmCreateVirtualMapping(PsGetCurrentProcess(),
+ Status = MmCreateVirtualMapping(AddressSpace->Process,
Address,
Region->Protect,
Page,
/*
* Add the page to the process's working set
*/
- MmInsertRmap(Page, PsGetCurrentProcess(),
+ MmInsertRmap(Page, AddressSpace->Process,
(PVOID)PAGE_ROUND_DOWN(Address));
/*
/*
* Just map the desired physical page
*/
- Status = MmCreateVirtualMapping(PsGetCurrentProcess(),
+ Status = MmCreateVirtualMapping(AddressSpace->Process,
Address,
Region->Protect,
Offset,
MmLockSectionSegment(Segment);
}
- Status = MmCreateVirtualMapping(PsGetCurrentProcess(),
+ Status = MmCreateVirtualMapping(AddressSpace->Process,
Address,
Region->Protect,
Page,
FALSE);
- MmInsertRmap(Page, PsGetCurrentProcess(),
+ MmInsertRmap(Page, AddressSpace->Process,
(PVOID)PAGE_ROUND_DOWN(Address));
if (Locked)
{
MmSetPageEntrySectionSegment(Segment, Offset.QuadPart, Entry);
MmSharePageEntrySectionSegment(Segment, Offset.QuadPart);
- Status = MmCreateVirtualMapping(PsGetCurrentProcess(),
+ Status = MmCreateVirtualMapping(AddressSpace->Process,
Address,
Attributes,
Page,
MmUnlockSectionSegment(Segment);
MmUnlockSection(Section);
MmUnlockAddressSpace(AddressSpace);
- Status = MmCreateVirtualMapping(PsGetCurrentProcess(),
+ Status = MmCreateVirtualMapping(AddressSpace->Process,
Address,
Attributes,
Page,
MmLockSection(Section);
MmLockSectionSegment(Segment);
}
- MmInsertRmap(Page, PsGetCurrentProcess(),
+ MmInsertRmap(Page, AddressSpace->Process,
(PVOID)PAGE_ROUND_DOWN(Address));
if (!NT_SUCCESS(Status))
{
*/
MmSetSavedSwapEntryPage(Page, SwapEntry);
- Status = MmCreateVirtualMapping(PsGetCurrentProcess(),
+ Status = MmCreateVirtualMapping(AddressSpace->Process,
Address,
Attributes,
Page,
FALSE);
- MmInsertRmap(Page, PsGetCurrentProcess(),
+ MmInsertRmap(Page, AddressSpace->Process,
(PVOID)PAGE_ROUND_DOWN(Address));
if (!NT_SUCCESS(Status))
{
MmReferencePage(Page);
MmSharePageEntrySectionSegment(Segment, Offset.QuadPart);
- Status = MmCreateVirtualMapping(PsGetCurrentProcess(),
+ Status = MmCreateVirtualMapping(AddressSpace->Process,
Address,
Attributes,
Page,
FALSE);
- MmInsertRmap(Page, PsGetCurrentProcess(),
+ MmInsertRmap(Page, AddressSpace->Process,
(PVOID)PAGE_ROUND_DOWN(Address));
if (!NT_SUCCESS(Status))
{
* Restart the operation
*/
MmLockAddressSpace(AddressSpace);
+ KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
MmReleasePageOp(PageOp);
return(STATUS_MM_RESTART_OPERATION);
}
/*
* 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
*/
MmLockAddressSpace(AddressSpace);
- Status = MmCreateVirtualMapping(PsGetCurrentProcess(),
+ Status = MmCreateVirtualMapping(AddressSpace->Process,
Address,
Region->Protect,
NewPage,
FALSE);
- MmInsertRmap(NewPage, PsGetCurrentProcess(),
+ MmInsertRmap(NewPage, AddressSpace->Process,
(PVOID)PAGE_ROUND_DOWN(Address));
if (!NT_SUCCESS(Status))
{
* Unshare the old page.
*/
MmUnsharePageEntrySectionSegment(Section, Segment, Offset.QuadPart, FALSE);
- MmDeleteRmap(OldPage, PsGetCurrentProcess(),
+ MmDeleteRmap(OldPage, AddressSpace->Process,
(PVOID)PAGE_ROUND_DOWN(Address));
MmReleasePageMemoryConsumer(MC_USER, OldPage);
NTSTATUS Status;
Length =
- min(Length, MemoryArea->BaseAddress + MemoryArea->Length - BaseAddress);
+ min(Length, (ULONG) (MemoryArea->BaseAddress + MemoryArea->Length - BaseAddress));
Region = MmFindRegion(MemoryArea->BaseAddress,
&MemoryArea->Data.SectionData.RegionListHead,
BaseAddress, NULL);
ObDereferenceObject(Section->FileObject);
Section->FileObject = NULL;
}
+
+ if (Section->Segments->Flags & MM_PAGEFILE_SEGMENT)
+ {
+ MmFreePageTablesSectionSegment(Section->Segments);
+ ExFreePool(Section->Segments);
+ }
}
VOID STDCALL
Segment->Length = MaximumSize.u.LowPart;
Segment->Flags = MM_PAGEFILE_SEGMENT;
Segment->WriteCopy = FALSE;
+ ObDereferenceObject(Section);
return(STATUS_SUCCESS);
}
PFILE_OBJECT FileObject;
PMM_SECTION_SEGMENT Segment;
ULONG FileAccess;
+ IO_STATUS_BLOCK Iosb;
+ LARGE_INTEGER Offset;
+ CHAR Buffer;
/*
* Check the protection
{
return(STATUS_INVALID_PAGE_PROTECTION);
}
-
+
+ /*
+ * Read a bit so caching is initiated for the file object.
+ * This is only needed because MiReadPage currently cannot
+ * handle non-cached streams.
+ */
+ Offset.QuadPart = 0;
+ Status = ZwReadFile(FileHandle,
+ NULL,
+ NULL,
+ NULL,
+ &Iosb,
+ &Buffer,
+ sizeof (Buffer),
+ &Offset,
+ 0);
+ if (!NT_SUCCESS(Status) && (Status != STATUS_END_OF_FILE))
+ {
+ return(Status);
+ }
+
/*
* Create the section
*/
MmFreeSwapPage(SavedSwapEntry);
MmSetSavedSwapEntryPage(PhysAddr, 0);
}
- MmDeleteRmap(PhysAddr, MArea->Process, Address);
- MmReleasePageMemoryConsumer(MC_USER, PhysAddr);
}
else
{
MArea->Data.SectionData.Segment,
Offset,
Dirty);
- MmDeleteRmap(PhysAddr, MArea->Process, Address);
- MmReleasePageMemoryConsumer(MC_USER, PhysAddr);
}
+ MmDeleteRmap(PhysAddr, MArea->Process, Address);
+ MmReleasePageMemoryConsumer(MC_USER, PhysAddr);
}
}
MmFlushImageSection (IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
IN MMFLUSH_TYPE FlushType)
{
- UNIMPLEMENTED;
- return (FALSE);
+ switch(FlushType)
+ {
+ case MmFlushForDelete:
+ if (SectionObjectPointer->ImageSectionObject ||
+ SectionObjectPointer->DataSectionObject)
+ {
+ return FALSE;
+ }
+ CcRosSetRemoveOnClose(SectionObjectPointer);
+ return TRUE;
+ case MmFlushForWrite:
+ break;
+ }
+ return FALSE;
}
BOOLEAN STDCALL