mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 02:43:09 +00:00
[NTOS/MM] Infer that the Memory Area is an image mapping from its VAD node
This commit is contained in:
parent
c3bd70cfd1
commit
4f6fd6c42b
1 changed files with 12 additions and 45 deletions
|
@ -138,7 +138,7 @@ C_ASSERT(PEFMT_FIELDS_EQUAL(IMAGE_OPTIONAL_HEADER32, IMAGE_OPTIONAL_HEADER64, Si
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
PSECTION Section;
|
PMEMORY_AREA MemoryArea;
|
||||||
PMM_SECTION_SEGMENT Segment;
|
PMM_SECTION_SEGMENT Segment;
|
||||||
LARGE_INTEGER Offset;
|
LARGE_INTEGER Offset;
|
||||||
BOOLEAN WasDirty;
|
BOOLEAN WasDirty;
|
||||||
|
@ -899,7 +899,7 @@ MmSharePageEntrySectionSegment(PMM_SECTION_SEGMENT Segment,
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
NTAPI
|
NTAPI
|
||||||
MmUnsharePageEntrySectionSegment(PSECTION Section,
|
MmUnsharePageEntrySectionSegment(PMEMORY_AREA MemoryArea,
|
||||||
PMM_SECTION_SEGMENT Segment,
|
PMM_SECTION_SEGMENT Segment,
|
||||||
PLARGE_INTEGER Offset,
|
PLARGE_INTEGER Offset,
|
||||||
BOOLEAN Dirty,
|
BOOLEAN Dirty,
|
||||||
|
@ -939,7 +939,7 @@ MmUnsharePageEntrySectionSegment(PSECTION Section,
|
||||||
LARGE_INTEGER FileOffset;
|
LARGE_INTEGER FileOffset;
|
||||||
|
|
||||||
FileOffset.QuadPart = Offset->QuadPart + Segment->Image.FileOffset;
|
FileOffset.QuadPart = Offset->QuadPart + Segment->Image.FileOffset;
|
||||||
IsImageSection = Section->u.Flags.Image;
|
IsImageSection = MemoryArea->VadNode.u.VadFlags.VadType == VadImageMap;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Page = PFN_FROM_SSE(Entry);
|
Page = PFN_FROM_SSE(Entry);
|
||||||
|
@ -1112,7 +1112,7 @@ MiReadPage(PMEMORY_AREA MemoryArea,
|
||||||
SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
|
SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
|
||||||
RawLength = MemoryArea->SectionData.Segment->RawLength.QuadPart;
|
RawLength = MemoryArea->SectionData.Segment->RawLength.QuadPart;
|
||||||
FileOffset = SegOffset + MemoryArea->SectionData.Segment->Image.FileOffset;
|
FileOffset = SegOffset + MemoryArea->SectionData.Segment->Image.FileOffset;
|
||||||
IsImageSection = MemoryArea->SectionData.Section->u.Flags.Image;
|
IsImageSection = MemoryArea->VadNode.u.VadFlags.VadType == VadImageMap;
|
||||||
|
|
||||||
ASSERT(SharedCacheMap);
|
ASSERT(SharedCacheMap);
|
||||||
|
|
||||||
|
@ -1631,7 +1631,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
|
||||||
MmCreatePageFileMapping(Process, PAddress, MM_WAIT_ENTRY);
|
MmCreatePageFileMapping(Process, PAddress, MM_WAIT_ENTRY);
|
||||||
MmUnlockAddressSpace(AddressSpace);
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
|
|
||||||
if ((Offset.QuadPart >= (LONGLONG)PAGE_ROUND_UP(Segment->RawLength.QuadPart)) && Section->u.Flags.Image)
|
if ((Offset.QuadPart >= (LONGLONG)PAGE_ROUND_UP(Segment->RawLength.QuadPart)) && (MemoryArea->VadNode.u.VadFlags.VadType == VadImageMap))
|
||||||
{
|
{
|
||||||
MI_SET_USAGE(MI_USAGE_SECTION);
|
MI_SET_USAGE(MI_USAGE_SECTION);
|
||||||
if (Process) MI_SET_PROCESS2(Process->ImageFileName);
|
if (Process) MI_SET_PROCESS2(Process->ImageFileName);
|
||||||
|
@ -1812,7 +1812,6 @@ MmAccessFaultSectionView(PMMSUPPORT AddressSpace,
|
||||||
PVOID Address)
|
PVOID Address)
|
||||||
{
|
{
|
||||||
PMM_SECTION_SEGMENT Segment;
|
PMM_SECTION_SEGMENT Segment;
|
||||||
PSECTION Section;
|
|
||||||
PFN_NUMBER OldPage;
|
PFN_NUMBER OldPage;
|
||||||
PFN_NUMBER NewPage;
|
PFN_NUMBER NewPage;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
@ -1849,7 +1848,6 @@ MmAccessFaultSectionView(PMMSUPPORT AddressSpace,
|
||||||
+ MemoryArea->SectionData.ViewOffset.QuadPart;
|
+ MemoryArea->SectionData.ViewOffset.QuadPart;
|
||||||
|
|
||||||
Segment = MemoryArea->SectionData.Segment;
|
Segment = MemoryArea->SectionData.Segment;
|
||||||
Section = MemoryArea->SectionData.Section;
|
|
||||||
Region = MmFindRegion((PVOID)MA_GetStartingAddress(MemoryArea),
|
Region = MmFindRegion((PVOID)MA_GetStartingAddress(MemoryArea),
|
||||||
&MemoryArea->SectionData.RegionListHead,
|
&MemoryArea->SectionData.RegionListHead,
|
||||||
Address, NULL);
|
Address, NULL);
|
||||||
|
@ -1907,7 +1905,7 @@ MmAccessFaultSectionView(PMMSUPPORT AddressSpace,
|
||||||
DPRINT("Swapping page (Old %x New %x)\n", OldPage, NewPage);
|
DPRINT("Swapping page (Old %x New %x)\n", OldPage, NewPage);
|
||||||
MmDeleteVirtualMapping(Process, PAddress, NULL, NULL);
|
MmDeleteVirtualMapping(Process, PAddress, NULL, NULL);
|
||||||
MmDeleteRmap(OldPage, Process, PAddress);
|
MmDeleteRmap(OldPage, Process, PAddress);
|
||||||
MmUnsharePageEntrySectionSegment(Section, Segment, &Offset, FALSE, FALSE, NULL);
|
MmUnsharePageEntrySectionSegment(MemoryArea, Segment, &Offset, FALSE, FALSE, NULL);
|
||||||
MmUnlockSectionSegment(Segment);
|
MmUnlockSectionSegment(Segment);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1955,7 +1953,7 @@ MmPageOutDeleteMapping(PVOID Context, PEPROCESS Process, PVOID Address)
|
||||||
if (!PageOutContext->Private)
|
if (!PageOutContext->Private)
|
||||||
{
|
{
|
||||||
MmLockSectionSegment(PageOutContext->Segment);
|
MmLockSectionSegment(PageOutContext->Segment);
|
||||||
MmUnsharePageEntrySectionSegment(PageOutContext->Section,
|
MmUnsharePageEntrySectionSegment(PageOutContext->MemoryArea,
|
||||||
PageOutContext->Segment,
|
PageOutContext->Segment,
|
||||||
&PageOutContext->Offset,
|
&PageOutContext->Offset,
|
||||||
PageOutContext->WasDirty,
|
PageOutContext->WasDirty,
|
||||||
|
@ -2000,7 +1998,7 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace,
|
||||||
* Get the segment and section.
|
* Get the segment and section.
|
||||||
*/
|
*/
|
||||||
Context.Segment = MemoryArea->SectionData.Segment;
|
Context.Segment = MemoryArea->SectionData.Segment;
|
||||||
Context.Section = MemoryArea->SectionData.Section;
|
Context.MemoryArea = MemoryArea;
|
||||||
Context.SectionEntry = Entry;
|
Context.SectionEntry = Entry;
|
||||||
Context.CallingProcess = Process;
|
Context.CallingProcess = Process;
|
||||||
|
|
||||||
|
@ -2013,7 +2011,7 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace,
|
||||||
|
|
||||||
#ifndef NEWCC
|
#ifndef NEWCC
|
||||||
FileOffset = Context.Offset.QuadPart + Context.Segment->Image.FileOffset;
|
FileOffset = Context.Offset.QuadPart + Context.Segment->Image.FileOffset;
|
||||||
IsImageSection = Context.Section->u.Flags.Image;
|
IsImageSection = MemoryArea->VadNode.u.VadFlags.VadType == VadImageMap;
|
||||||
FileObject = Context.Segment->FileObject;
|
FileObject = Context.Segment->FileObject;
|
||||||
|
|
||||||
if (FileObject != NULL &&
|
if (FileObject != NULL &&
|
||||||
|
@ -2034,19 +2032,6 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This should never happen since mappings of physical memory are never
|
|
||||||
* placed in the rmap lists.
|
|
||||||
*/
|
|
||||||
if (Context.Section->u.Flags.PhysicalMemory)
|
|
||||||
{
|
|
||||||
DPRINT1("Trying to page out from physical memory section address 0x%p "
|
|
||||||
"process %p\n", Address,
|
|
||||||
Process ? Process->UniqueProcessId : 0);
|
|
||||||
KeBugCheck(MEMORY_MANAGEMENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the section segment entry and the physical address.
|
* Get the section segment entry and the physical address.
|
||||||
*/
|
*/
|
||||||
|
@ -2367,7 +2352,6 @@ MmWritePageSectionView(PMMSUPPORT AddressSpace,
|
||||||
ULONG PageEntry)
|
ULONG PageEntry)
|
||||||
{
|
{
|
||||||
LARGE_INTEGER Offset;
|
LARGE_INTEGER Offset;
|
||||||
PSECTION Section;
|
|
||||||
PMM_SECTION_SEGMENT Segment;
|
PMM_SECTION_SEGMENT Segment;
|
||||||
PFN_NUMBER Page;
|
PFN_NUMBER Page;
|
||||||
SWAPENTRY SwapEntry;
|
SWAPENTRY SwapEntry;
|
||||||
|
@ -2391,8 +2375,7 @@ MmWritePageSectionView(PMMSUPPORT AddressSpace,
|
||||||
* Get the segment and section.
|
* Get the segment and section.
|
||||||
*/
|
*/
|
||||||
Segment = MemoryArea->SectionData.Segment;
|
Segment = MemoryArea->SectionData.Segment;
|
||||||
Section = MemoryArea->SectionData.Section;
|
IsImageSection = MemoryArea->VadNode.u.VadFlags.VadType == VadImageMap;
|
||||||
IsImageSection = Section->u.Flags.Image;
|
|
||||||
|
|
||||||
FileObject = Segment->FileObject;
|
FileObject = Segment->FileObject;
|
||||||
DirectMapped = FALSE;
|
DirectMapped = FALSE;
|
||||||
|
@ -2415,18 +2398,6 @@ MmWritePageSectionView(PMMSUPPORT AddressSpace,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* This should never happen since mappings of physical memory are never
|
|
||||||
* placed in the rmap lists.
|
|
||||||
*/
|
|
||||||
if (Section->u.Flags.PhysicalMemory)
|
|
||||||
{
|
|
||||||
DPRINT1("Trying to write back page from physical memory mapped at %p "
|
|
||||||
"process %p\n", Address,
|
|
||||||
Process ? Process->UniqueProcessId : 0);
|
|
||||||
KeBugCheck(MEMORY_MANAGEMENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the section segment entry and the physical address.
|
* Get the section segment entry and the physical address.
|
||||||
*/
|
*/
|
||||||
|
@ -2557,7 +2528,6 @@ MmQuerySectionView(PMEMORY_AREA MemoryArea,
|
||||||
{
|
{
|
||||||
PMM_REGION Region;
|
PMM_REGION Region;
|
||||||
PVOID RegionBaseAddress;
|
PVOID RegionBaseAddress;
|
||||||
PSECTION Section;
|
|
||||||
PMM_SECTION_SEGMENT Segment;
|
PMM_SECTION_SEGMENT Segment;
|
||||||
|
|
||||||
Region = MmFindRegion((PVOID)MA_GetStartingAddress(MemoryArea),
|
Region = MmFindRegion((PVOID)MA_GetStartingAddress(MemoryArea),
|
||||||
|
@ -2568,8 +2538,7 @@ MmQuerySectionView(PMEMORY_AREA MemoryArea,
|
||||||
return STATUS_UNSUCCESSFUL;
|
return STATUS_UNSUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Section = MemoryArea->SectionData.Section;
|
if (MemoryArea->VadNode.u.VadFlags.VadType == VadImageMap)
|
||||||
if (Section->u.Flags.Image)
|
|
||||||
{
|
{
|
||||||
Segment = MemoryArea->SectionData.Segment;
|
Segment = MemoryArea->SectionData.Segment;
|
||||||
Info->AllocationBase = (PUCHAR)MA_GetStartingAddress(MemoryArea) - Segment->Image.VirtualAddress;
|
Info->AllocationBase = (PUCHAR)MA_GetStartingAddress(MemoryArea) - Segment->Image.VirtualAddress;
|
||||||
|
@ -3944,7 +3913,6 @@ MmFreeSectionPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address,
|
||||||
#endif
|
#endif
|
||||||
LARGE_INTEGER Offset;
|
LARGE_INTEGER Offset;
|
||||||
SWAPENTRY SavedSwapEntry;
|
SWAPENTRY SavedSwapEntry;
|
||||||
PSECTION Section;
|
|
||||||
PMM_SECTION_SEGMENT Segment;
|
PMM_SECTION_SEGMENT Segment;
|
||||||
PMMSUPPORT AddressSpace;
|
PMMSUPPORT AddressSpace;
|
||||||
PEPROCESS Process;
|
PEPROCESS Process;
|
||||||
|
@ -3957,7 +3925,6 @@ MmFreeSectionPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address,
|
||||||
Offset.QuadPart = ((ULONG_PTR)Address - MA_GetStartingAddress(MemoryArea)) +
|
Offset.QuadPart = ((ULONG_PTR)Address - MA_GetStartingAddress(MemoryArea)) +
|
||||||
MemoryArea->SectionData.ViewOffset.QuadPart;
|
MemoryArea->SectionData.ViewOffset.QuadPart;
|
||||||
|
|
||||||
Section = MemoryArea->SectionData.Section;
|
|
||||||
Segment = MemoryArea->SectionData.Segment;
|
Segment = MemoryArea->SectionData.Segment;
|
||||||
|
|
||||||
Entry = MmGetPageEntrySectionSegment(Segment, &Offset);
|
Entry = MmGetPageEntrySectionSegment(Segment, &Offset);
|
||||||
|
@ -4017,7 +3984,7 @@ MmFreeSectionPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MmDeleteRmap(Page, Process, Address);
|
MmDeleteRmap(Page, Process, Address);
|
||||||
MmUnsharePageEntrySectionSegment(Section, Segment, &Offset, Dirty, FALSE, NULL);
|
MmUnsharePageEntrySectionSegment(MemoryArea, Segment, &Offset, Dirty, FALSE, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue