ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
February 2021
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
30 participants
434 discussions
Start a n
N
ew thread
[reactos] 17/100: [NTOSKRNL/MM] Fix a few wine tests
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c3bd70cfd15772877629f…
commit c3bd70cfd15772877629fd53df547402cde572f6 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Mon Oct 26 12:19:18 2020 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:21 2021 +0100 [NTOSKRNL/MM] Fix a few wine tests --- ntoskrnl/mm/section.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index 5dd758f865d..f65c5c1ff64 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -4302,13 +4302,22 @@ NtQuerySection( if (Section->u.Flags.Image) { - Sbi.BaseAddress = 0; - Sbi.Size.QuadPart = 0; + if (MiIsRosSectionObject(Section)) + { + PMM_IMAGE_SECTION_OBJECT ImageSectionObject = ((PMM_IMAGE_SECTION_OBJECT)Section->Segment); + Sbi.BaseAddress = 0; + Sbi.Size.QuadPart = ImageSectionObject->ImageInformation.ImageFileSize; + } + else + { + /* Not supported yet */ + ASSERT(FALSE); + } } else if (MiIsRosSectionObject(Section)) { Sbi.BaseAddress = (PVOID)((PMM_SECTION_SEGMENT)Section->Segment)->Image.VirtualAddress; - Sbi.Size.QuadPart = ((PMM_SECTION_SEGMENT)Section->Segment)->Length.QuadPart; + Sbi.Size.QuadPart = ((PMM_SECTION_SEGMENT)Section->Segment)->RawLength.QuadPart; } else {
3 years, 10 months
1
0
0
0
[reactos] 16/100: [NTOSKRNL/MM] Reduce use of MiIsRosSectionObject
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4abda863ce273a58ddcd9…
commit 4abda863ce273a58ddcd97ecf48ab142b2b11c63 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Mon Oct 26 11:23:42 2020 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:21 2021 +0100 [NTOSKRNL/MM] Reduce use of MiIsRosSectionObject --- ntoskrnl/mm/ARM3/section.c | 5 +- ntoskrnl/mm/section.c | 157 ++++++++++++++++++--------------------------- 2 files changed, 64 insertions(+), 98 deletions(-) diff --git a/ntoskrnl/mm/ARM3/section.c b/ntoskrnl/mm/ARM3/section.c index 73c0e3050aa..511f11a5101 100644 --- a/ntoskrnl/mm/ARM3/section.c +++ b/ntoskrnl/mm/ARM3/section.c @@ -3716,7 +3716,7 @@ NtMapViewOfSection(IN HANDLE SectionHandle, return Status; } - if (MiIsRosSectionObject(Section) && Section->u.Flags.PhysicalMemory) + if (Section->u.Flags.PhysicalMemory) { if (PreviousMode == UserMode && SafeSectionOffset.QuadPart + SafeViewSize > MmHighestPhysicalPage << PAGE_SHIFT) @@ -3764,8 +3764,7 @@ NtMapViewOfSection(IN HANDLE SectionHandle, if (NT_SUCCESS(Status)) { /* Check if this is an image for the current process */ - if (MiIsRosSectionObject(Section) && - (Section->u.Flags.Image) && + if ((Section->u.Flags.Image) && (Process == PsGetCurrentProcess()) && (Status != STATUS_IMAGE_NOT_AT_BASE)) { diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index f43811e9f50..5dd758f865d 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -4279,131 +4279,98 @@ NtQuerySection( return Status; } - if (MiIsRosSectionObject(Section)) + switch(SectionInformationClass) { - switch (SectionInformationClass) + case SectionBasicInformation: { - case SectionBasicInformation: - { - PSECTION_BASIC_INFORMATION Sbi = (PSECTION_BASIC_INFORMATION)SectionInformation; + SECTION_BASIC_INFORMATION Sbi; - _SEH2_TRY - { - Sbi->Attributes = 0; - if (Section->u.Flags.Image) - Sbi->Attributes |= SEC_IMAGE; - if (Section->u.Flags.File) - Sbi->Attributes |= SEC_FILE; - if (Section->u.Flags.NoChange) - Sbi->Attributes |= SEC_NO_CHANGE; - - if (Section->u.Flags.Image) - { - Sbi->BaseAddress = 0; - Sbi->Size.QuadPart = 0; - } - else - { - Sbi->BaseAddress = (PVOID)((PMM_SECTION_SEGMENT)Section->Segment)->Image.VirtualAddress; - Sbi->Size.QuadPart = ((PMM_SECTION_SEGMENT)Section->Segment)->Length.QuadPart; - } + Sbi.Size = Section->SizeOfSection; + Sbi.BaseAddress = (PVOID)Section->Address.StartingVpn; - if (ResultLength != NULL) - { - *ResultLength = sizeof(SECTION_BASIC_INFORMATION); - } - Status = STATUS_SUCCESS; - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - Status = _SEH2_GetExceptionCode(); - } - _SEH2_END; + Sbi.Attributes = 0; + if (Section->u.Flags.Commit) + Sbi.Attributes |= SEC_COMMIT; + if (Section->u.Flags.Reserve) + Sbi.Attributes |= SEC_RESERVE; + if (Section->u.Flags.File) + Sbi.Attributes |= SEC_FILE; + if (Section->u.Flags.Image) + Sbi.Attributes |= SEC_IMAGE; - break; + /* FIXME : Complete/test the list of flags passed back from NtCreateSection */ + + if (Section->u.Flags.Image) + { + Sbi.BaseAddress = 0; + Sbi.Size.QuadPart = 0; + } + else if (MiIsRosSectionObject(Section)) + { + Sbi.BaseAddress = (PVOID)((PMM_SECTION_SEGMENT)Section->Segment)->Image.VirtualAddress; + Sbi.Size.QuadPart = ((PMM_SECTION_SEGMENT)Section->Segment)->Length.QuadPart; + } + else + { + DPRINT1("Unimplemented code path!"); } - case SectionImageInformation: + _SEH2_TRY + { + *((SECTION_BASIC_INFORMATION*)SectionInformation) = Sbi; + if (ResultLength) + *ResultLength = sizeof(Sbi); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + Status = _SEH2_GetExceptionCode(); + } + _SEH2_END; + break; + } + case SectionImageInformation: + { + if (!Section->u.Flags.Image) { - PSECTION_IMAGE_INFORMATION Sii = (PSECTION_IMAGE_INFORMATION)SectionInformation; + Status = STATUS_SECTION_NOT_IMAGE; + } + else if (MiIsRosSectionObject(Section)) + { + PMM_IMAGE_SECTION_OBJECT ImageSectionObject = ((PMM_IMAGE_SECTION_OBJECT)Section->Segment); _SEH2_TRY { - if (Section->u.Flags.Image) - { - PMM_IMAGE_SECTION_OBJECT ImageSectionObject = ((PMM_IMAGE_SECTION_OBJECT)Section->Segment); - - *Sii = ImageSectionObject->ImageInformation; - } - + PSECTION_IMAGE_INFORMATION Sii = (PSECTION_IMAGE_INFORMATION)SectionInformation; + *Sii = ImageSectionObject->ImageInformation; if (ResultLength != NULL) - { - *ResultLength = sizeof(SECTION_IMAGE_INFORMATION); - } - Status = STATUS_SUCCESS; + *ResultLength = sizeof(*Sii); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { Status = _SEH2_GetExceptionCode(); } _SEH2_END; - - break; } - } - } - else - { - switch(SectionInformationClass) - { - case SectionBasicInformation: + else { - SECTION_BASIC_INFORMATION Sbi; - - Sbi.Size = Section->SizeOfSection; - Sbi.BaseAddress = (PVOID)Section->Address.StartingVpn; - - Sbi.Attributes = 0; - if (Section->u.Flags.Image) - Sbi.Attributes |= SEC_IMAGE; - if (Section->u.Flags.Commit) - Sbi.Attributes |= SEC_COMMIT; - if (Section->u.Flags.Reserve) - Sbi.Attributes |= SEC_RESERVE; - if (Section->u.Flags.File) - Sbi.Attributes |= SEC_FILE; - if (Section->u.Flags.Image) - Sbi.Attributes |= SEC_IMAGE; - - /* FIXME : Complete/test the list of flags passed back from NtCreateSection */ - _SEH2_TRY { - *((SECTION_BASIC_INFORMATION*)SectionInformation) = Sbi; - if (ResultLength) - *ResultLength = sizeof(Sbi); + PSECTION_IMAGE_INFORMATION Sii = (PSECTION_IMAGE_INFORMATION)SectionInformation; + *Sii = *Section->Segment->u2.ImageInformation; + if (ResultLength != NULL) + *ResultLength = sizeof(*Sii); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { Status = _SEH2_GetExceptionCode(); } _SEH2_END; - break; - } - case SectionImageInformation: - { - if (!Section->u.Flags.Image) - { - Status = STATUS_SECTION_NOT_IMAGE; - } - else - { - /* Currently not supported */ - ASSERT(FALSE); - } - break; } + break; } + default: + DPRINT1("Unknown SectionInformationClass: %d\n", SectionInformationClass); + Status = STATUS_NOT_SUPPORTED; } ObDereferenceObject(Section);
3 years, 10 months
1
0
0
0
[reactos] 15/100: [NTOSKRNL] Get rid of MM_ROS_SECTION_OBJECT
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b7d988ae5b4948b0ab4be…
commit b7d988ae5b4948b0ab4be8a094c3b5536fdd187c Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Mon Oct 26 10:31:46 2020 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:21 2021 +0100 [NTOSKRNL] Get rid of MM_ROS_SECTION_OBJECT --- ntoskrnl/cache/newcc.h | 2 +- ntoskrnl/cache/section/newmm.h | 4 +-- ntoskrnl/include/internal/mm.h | 7 +--- ntoskrnl/mm/ARM3/section.c | 10 ++---- ntoskrnl/mm/section.c | 74 ++++++++++++++++++++---------------------- 5 files changed, 43 insertions(+), 54 deletions(-) diff --git a/ntoskrnl/cache/newcc.h b/ntoskrnl/cache/newcc.h index adbf1c5d926..8768d7aebd2 100644 --- a/ntoskrnl/cache/newcc.h +++ b/ntoskrnl/cache/newcc.h @@ -6,7 +6,7 @@ typedef struct _NOCC_BCB PUBLIC_BCB Bcb; struct _NOCC_CACHE_MAP *Map; - PROS_SECTION_OBJECT SectionObject; + PSECTION SectionObject; LARGE_INTEGER FileOffset; ULONG Length; PVOID BaseAddress; diff --git a/ntoskrnl/cache/section/newmm.h b/ntoskrnl/cache/section/newmm.h index d5f9998993c..edff99f3d85 100644 --- a/ntoskrnl/cache/section/newmm.h +++ b/ntoskrnl/cache/section/newmm.h @@ -96,7 +96,7 @@ typedef struct _MM_REQUIRED_RESOURCES NTSTATUS NTAPI -MmCreateCacheSection(PROS_SECTION_OBJECT *SectionObject, +MmCreateCacheSection(PSECTION *SectionObject, ACCESS_MASK DesiredAccess, POBJECT_ATTRIBUTES ObjectAttributes, PLARGE_INTEGER UMaximumSize, @@ -386,7 +386,7 @@ MiSwapInSectionPage(PMMSUPPORT AddressSpace, NTSTATUS NTAPI -MmExtendCacheSection(PROS_SECTION_OBJECT Section, +MmExtendCacheSection(PSECTION Section, PLARGE_INTEGER NewSize, BOOLEAN ExtendFile); diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h index 74cfcf7f11e..a8536c3d786 100644 --- a/ntoskrnl/include/internal/mm.h +++ b/ntoskrnl/include/internal/mm.h @@ -199,11 +199,6 @@ typedef struct _MM_IMAGE_SECTION_OBJECT PMM_SECTION_SEGMENT Segments; } MM_IMAGE_SECTION_OBJECT, *PMM_IMAGE_SECTION_OBJECT; -typedef struct _ROS_SECTION_OBJECT -{ - SECTION; -} ROS_SECTION_OBJECT, *PROS_SECTION_OBJECT; - #define MA_GetStartingAddress(_MemoryArea) ((_MemoryArea)->VadNode.StartingVpn << PAGE_SHIFT) #define MA_GetEndingAddress(_MemoryArea) (((_MemoryArea)->VadNode.EndingVpn + 1) << PAGE_SHIFT) @@ -219,7 +214,7 @@ typedef struct _MEMORY_AREA struct { - PROS_SECTION_OBJECT Section; + PSECTION Section; LARGE_INTEGER ViewOffset; PMM_SECTION_SEGMENT Segment; LIST_ENTRY RegionListHead; diff --git a/ntoskrnl/mm/ARM3/section.c b/ntoskrnl/mm/ARM3/section.c index a91cfe2ed4a..73c0e3050aa 100644 --- a/ntoskrnl/mm/ARM3/section.c +++ b/ntoskrnl/mm/ARM3/section.c @@ -1655,14 +1655,12 @@ MiGetFileObjectForSectionAddress( if (Vad->u.VadFlags.Spare != 0) { PMEMORY_AREA MemoryArea = (PMEMORY_AREA)Vad; - PROS_SECTION_OBJECT Section; /* Check if it's a section view (RosMm section) */ if (MemoryArea->Type == MEMORY_AREA_SECTION_VIEW) { /* Get the section pointer to the SECTION_OBJECT */ - Section = MemoryArea->SectionData.Section; - *FileObject = ((PMM_SECTION_SEGMENT)Section->Segment)->FileObject; + *FileObject = MemoryArea->SectionData.Segment->FileObject; } else { @@ -1732,14 +1730,12 @@ MiGetFileObjectForVad( if (Vad->u.VadFlags.Spare != 0) { PMEMORY_AREA MemoryArea = (PMEMORY_AREA)Vad; - PROS_SECTION_OBJECT Section; /* Check if it's a section view (RosMm section) */ if (MemoryArea->Type == MEMORY_AREA_SECTION_VIEW) { /* Get the section pointer to the SECTION_OBJECT */ - Section = MemoryArea->SectionData.Section; - FileObject = ((PMM_SECTION_SEGMENT)Section->Segment)->FileObject; + FileObject = MemoryArea->SectionData.Segment->FileObject; } else { @@ -3840,7 +3836,7 @@ NtExtendSection(IN HANDLE SectionHandle, IN OUT PLARGE_INTEGER NewMaximumSize) { LARGE_INTEGER SafeNewMaximumSize; - PROS_SECTION_OBJECT Section; + PSECTION Section; NTSTATUS Status; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index b975433e271..f43811e9f50 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -138,7 +138,7 @@ C_ASSERT(PEFMT_FIELDS_EQUAL(IMAGE_OPTIONAL_HEADER32, IMAGE_OPTIONAL_HEADER64, Si typedef struct { - PROS_SECTION_OBJECT Section; + PSECTION Section; PMM_SECTION_SEGMENT Segment; LARGE_INTEGER Offset; BOOLEAN WasDirty; @@ -899,7 +899,7 @@ MmSharePageEntrySectionSegment(PMM_SECTION_SEGMENT Segment, BOOLEAN NTAPI -MmUnsharePageEntrySectionSegment(PROS_SECTION_OBJECT Section, +MmUnsharePageEntrySectionSegment(PSECTION Section, PMM_SECTION_SEGMENT Segment, PLARGE_INTEGER Offset, BOOLEAN Dirty, @@ -1389,7 +1389,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace, LARGE_INTEGER Offset; PFN_NUMBER Page; NTSTATUS Status; - PROS_SECTION_OBJECT Section; + PSECTION Section; PMM_SECTION_SEGMENT Segment; ULONG_PTR Entry; ULONG_PTR Entry1; @@ -1812,7 +1812,7 @@ MmAccessFaultSectionView(PMMSUPPORT AddressSpace, PVOID Address) { PMM_SECTION_SEGMENT Segment; - PROS_SECTION_OBJECT Section; + PSECTION Section; PFN_NUMBER OldPage; PFN_NUMBER NewPage; NTSTATUS Status; @@ -1955,7 +1955,7 @@ MmPageOutDeleteMapping(PVOID Context, PEPROCESS Process, PVOID Address) if (!PageOutContext->Private) { MmLockSectionSegment(PageOutContext->Segment); - MmUnsharePageEntrySectionSegment((PROS_SECTION_OBJECT)PageOutContext->Section, + MmUnsharePageEntrySectionSegment(PageOutContext->Section, PageOutContext->Segment, &PageOutContext->Offset, PageOutContext->WasDirty, @@ -2367,7 +2367,7 @@ MmWritePageSectionView(PMMSUPPORT AddressSpace, ULONG PageEntry) { LARGE_INTEGER Offset; - PROS_SECTION_OBJECT Section; + PSECTION Section; PMM_SECTION_SEGMENT Segment; PFN_NUMBER Page; SWAPENTRY SwapEntry; @@ -2557,7 +2557,7 @@ MmQuerySectionView(PMEMORY_AREA MemoryArea, { PMM_REGION Region; PVOID RegionBaseAddress; - PROS_SECTION_OBJECT Section; + PSECTION Section; PMM_SECTION_SEGMENT Segment; Region = MmFindRegion((PVOID)MA_GetStartingAddress(MemoryArea), @@ -2635,7 +2635,7 @@ MmpFreePageFileSegment(PMM_SECTION_SEGMENT Segment) VOID NTAPI MmpDeleteSection(PVOID ObjectBody) { - PROS_SECTION_OBJECT Section = ObjectBody; + PSECTION Section = ObjectBody; /* Check if it's an ARM3, or ReactOS section */ if (!MiIsRosSectionObject(Section)) @@ -2739,7 +2739,7 @@ NTSTATUS NTAPI MmCreatePhysicalMemorySection(VOID) { - PROS_SECTION_OBJECT PhysSection; + PSECTION PhysSection; NTSTATUS Status; OBJECT_ATTRIBUTES Obj; UNICODE_STRING Name = RTL_CONSTANT_STRING(L"\\Device\\PhysicalMemory"); @@ -2764,7 +2764,7 @@ MmCreatePhysicalMemorySection(VOID) &Obj, ExGetPreviousMode(), NULL, - sizeof(ROS_SECTION_OBJECT), + sizeof(*PhysSection), 0, 0, (PVOID*)&PhysSection); @@ -2777,7 +2777,7 @@ MmCreatePhysicalMemorySection(VOID) /* * Initialize it */ - RtlZeroMemory(PhysSection, sizeof(ROS_SECTION_OBJECT)); + RtlZeroMemory(PhysSection, sizeof(*PhysSection)); /* Mark this as a "ROS Section" */ PhysSection->u.Flags.filler = 1; @@ -2838,7 +2838,7 @@ MmInitSectionImplementation(VOID) RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer)); RtlInitUnicodeString(&Name, L"Section"); ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer); - ObjectTypeInitializer.DefaultPagedPoolCharge = sizeof(ROS_SECTION_OBJECT); + ObjectTypeInitializer.DefaultPagedPoolCharge = sizeof(SECTION); ObjectTypeInitializer.PoolType = PagedPool; ObjectTypeInitializer.UseDefaultObject = TRUE; ObjectTypeInitializer.GenericMapping = MmpSectionMapping; @@ -2855,7 +2855,7 @@ MmInitSectionImplementation(VOID) NTSTATUS NTAPI -MmCreateDataFileSection(PROS_SECTION_OBJECT *SectionObject, +MmCreateDataFileSection(PSECTION *SectionObject, ACCESS_MASK DesiredAccess, POBJECT_ATTRIBUTES ObjectAttributes, PLARGE_INTEGER UMaximumSize, @@ -2866,7 +2866,7 @@ MmCreateDataFileSection(PROS_SECTION_OBJECT *SectionObject, * Create a section backed by a data file */ { - PROS_SECTION_OBJECT Section; + PSECTION Section; NTSTATUS Status; LARGE_INTEGER MaximumSize; PMM_SECTION_SEGMENT Segment; @@ -2881,7 +2881,7 @@ MmCreateDataFileSection(PROS_SECTION_OBJECT *SectionObject, ObjectAttributes, ExGetPreviousMode(), NULL, - sizeof(ROS_SECTION_OBJECT), + sizeof(*Section), 0, 0, (PVOID*)&Section); @@ -2893,7 +2893,7 @@ MmCreateDataFileSection(PROS_SECTION_OBJECT *SectionObject, /* * Initialize it */ - RtlZeroMemory(Section, sizeof(ROS_SECTION_OBJECT)); + RtlZeroMemory(Section, sizeof(*Section)); /* Mark this as a "ROS" section */ Section->u.Flags.filler = 1; @@ -3682,7 +3682,7 @@ ExeFmtpCreateImageSection(PFILE_OBJECT FileObject, } NTSTATUS -MmCreateImageSection(PROS_SECTION_OBJECT *SectionObject, +MmCreateImageSection(PSECTION *SectionObject, ACCESS_MASK DesiredAccess, POBJECT_ATTRIBUTES ObjectAttributes, PLARGE_INTEGER UMaximumSize, @@ -3690,7 +3690,7 @@ MmCreateImageSection(PROS_SECTION_OBJECT *SectionObject, ULONG AllocationAttributes, PFILE_OBJECT FileObject) { - PROS_SECTION_OBJECT Section; + PSECTION Section; NTSTATUS Status; PMM_SECTION_SEGMENT SectionSegments; PMM_IMAGE_SECTION_OBJECT ImageSectionObject; @@ -3715,7 +3715,7 @@ MmCreateImageSection(PROS_SECTION_OBJECT *SectionObject, ObjectAttributes, ExGetPreviousMode(), NULL, - sizeof(ROS_SECTION_OBJECT), + sizeof(*Section), 0, 0, (PVOID*)(PVOID)&Section); @@ -3728,7 +3728,7 @@ MmCreateImageSection(PROS_SECTION_OBJECT *SectionObject, /* * Initialize it */ - RtlZeroMemory(Section, sizeof(ROS_SECTION_OBJECT)); + RtlZeroMemory(Section, sizeof(*Section)); /* Mark this as a "ROS" Section */ Section->u.Flags.filler = 1; @@ -3858,7 +3858,7 @@ MmCreateImageSection(PROS_SECTION_OBJECT *SectionObject, static NTSTATUS MmMapViewOfSegment(PMMSUPPORT AddressSpace, - PROS_SECTION_OBJECT Section, + PSECTION Section, PMM_SECTION_SEGMENT Segment, PVOID* BaseAddress, SIZE_T ViewSize, @@ -3944,7 +3944,7 @@ MmFreeSectionPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address, #endif LARGE_INTEGER Offset; SWAPENTRY SavedSwapEntry; - PROS_SECTION_OBJECT Section; + PSECTION Section; PMM_SECTION_SEGMENT Segment; PMMSUPPORT AddressSpace; PEPROCESS Process; @@ -4028,7 +4028,7 @@ MmUnmapViewOfSegment(PMMSUPPORT AddressSpace, { NTSTATUS Status; PMEMORY_AREA MemoryArea; - PROS_SECTION_OBJECT Section; + PSECTION Section; PMM_SECTION_SEGMENT Segment; PLIST_ENTRY CurrentEntry; PMM_REGION CurrentRegion; @@ -4095,7 +4095,7 @@ MiRosUnmapViewOfSection(IN PEPROCESS Process, NTSTATUS Status; PMEMORY_AREA MemoryArea; PMMSUPPORT AddressSpace; - PROS_SECTION_OBJECT Section; + PSECTION Section; PVOID ImageBaseAddress = 0; DPRINT("Opening memory area Process %p BaseAddress %p\n", @@ -4281,8 +4281,6 @@ NtQuerySection( if (MiIsRosSectionObject(Section)) { - PROS_SECTION_OBJECT RosSection = (PROS_SECTION_OBJECT)Section; - switch (SectionInformationClass) { case SectionBasicInformation: @@ -4292,22 +4290,22 @@ NtQuerySection( _SEH2_TRY { Sbi->Attributes = 0; - if (RosSection->u.Flags.Image) + if (Section->u.Flags.Image) Sbi->Attributes |= SEC_IMAGE; - if (RosSection->u.Flags.File) + if (Section->u.Flags.File) Sbi->Attributes |= SEC_FILE; - if (RosSection->u.Flags.NoChange) + if (Section->u.Flags.NoChange) Sbi->Attributes |= SEC_NO_CHANGE; - if (RosSection->u.Flags.Image) + if (Section->u.Flags.Image) { Sbi->BaseAddress = 0; Sbi->Size.QuadPart = 0; } else { - Sbi->BaseAddress = (PVOID)((PMM_SECTION_SEGMENT)RosSection->Segment)->Image.VirtualAddress; - Sbi->Size.QuadPart = ((PMM_SECTION_SEGMENT)RosSection->Segment)->Length.QuadPart; + Sbi->BaseAddress = (PVOID)((PMM_SECTION_SEGMENT)Section->Segment)->Image.VirtualAddress; + Sbi->Size.QuadPart = ((PMM_SECTION_SEGMENT)Section->Segment)->Length.QuadPart; } if (ResultLength != NULL) @@ -4331,7 +4329,7 @@ NtQuerySection( _SEH2_TRY { - if (RosSection->u.Flags.Image) + if (Section->u.Flags.Image) { PMM_IMAGE_SECTION_OBJECT ImageSectionObject = ((PMM_IMAGE_SECTION_OBJECT)Section->Segment); @@ -4474,7 +4472,7 @@ MmMapViewOfSection(IN PVOID SectionObject, IN ULONG AllocationType, IN ULONG Protect) { - PROS_SECTION_OBJECT Section; + PSECTION Section; PMMSUPPORT AddressSpace; ULONG ViewOffset; NTSTATUS Status = STATUS_SUCCESS; @@ -4505,7 +4503,7 @@ MmMapViewOfSection(IN PVOID SectionObject, /* FIXME: We should keep this, but it would break code checking equality */ Protect &= ~PAGE_NOCACHE; - Section = (PROS_SECTION_OBJECT)SectionObject; + Section = SectionObject; AddressSpace = &Process->Vm; if (Section->u.Flags.NoChange) @@ -4815,7 +4813,7 @@ MmMapViewInSystemSpace (IN PVOID SectionObject, OUT PVOID * MappedBase, IN OUT PSIZE_T ViewSize) { - PROS_SECTION_OBJECT Section; + PSECTION Section; PMM_SECTION_SEGMENT Segment; PMMSUPPORT AddressSpace; NTSTATUS Status; @@ -4831,7 +4829,7 @@ MmMapViewInSystemSpace (IN PVOID SectionObject, DPRINT("MmMapViewInSystemSpace() called\n"); - Section = (PROS_SECTION_OBJECT)SectionObject; + Section = SectionObject; Segment = (PMM_SECTION_SEGMENT)Section->Segment; AddressSpace = MmGetKernelAddressSpace(); @@ -4953,7 +4951,7 @@ MmCreateSection (OUT PVOID * Section, { NTSTATUS Status; ULONG Protection; - PROS_SECTION_OBJECT *SectionObject = (PROS_SECTION_OBJECT *)Section; + PSECTION *SectionObject = (PSECTION *)Section; /* Check if an ARM3 section is being created instead */ if (!(AllocationAttributes & (SEC_IMAGE | SEC_PHYSICALMEMORY)))
3 years, 10 months
1
0
0
0
[reactos] 14/100: [NTOSKRNL] Store File Object in the segment instead of Section object
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8b98ff66eabba884a0299…
commit 8b98ff66eabba884a02993704b46174da1a0141a Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Mon Oct 26 09:04:49 2020 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:21 2021 +0100 [NTOSKRNL] Store File Object in the segment instead of Section object --- ntoskrnl/include/internal/mm.h | 6 ++++-- ntoskrnl/mm/ARM3/section.c | 9 ++++---- ntoskrnl/mm/section.c | 47 +++++++++++++++++++++++++++++------------- 3 files changed, 41 insertions(+), 21 deletions(-) diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h index 760b514de4a..74cfcf7f11e 100644 --- a/ntoskrnl/include/internal/mm.h +++ b/ntoskrnl/include/internal/mm.h @@ -166,8 +166,9 @@ typedef ULONG_PTR SWAPENTRY; typedef struct _MM_SECTION_SEGMENT { + PFILE_OBJECT FileObject; + FAST_MUTEX Lock; /* lock which protects the page directory */ - PFILE_OBJECT FileObject; LARGE_INTEGER RawLength; /* length of the segment which is part of the mapped file */ LARGE_INTEGER Length; /* absolute length of the segment */ ULONG ReferenceCount; @@ -190,6 +191,8 @@ typedef struct _MM_SECTION_SEGMENT typedef struct _MM_IMAGE_SECTION_OBJECT { + PFILE_OBJECT FileObject; + SECTION_IMAGE_INFORMATION ImageInformation; PVOID BasedAddress; ULONG NrSegments; @@ -199,7 +202,6 @@ typedef struct _MM_IMAGE_SECTION_OBJECT typedef struct _ROS_SECTION_OBJECT { SECTION; - PFILE_OBJECT FileObject; } ROS_SECTION_OBJECT, *PROS_SECTION_OBJECT; #define MA_GetStartingAddress(_MemoryArea) ((_MemoryArea)->VadNode.StartingVpn << PAGE_SHIFT) diff --git a/ntoskrnl/mm/ARM3/section.c b/ntoskrnl/mm/ARM3/section.c index 81ecdc9f8dc..a91cfe2ed4a 100644 --- a/ntoskrnl/mm/ARM3/section.c +++ b/ntoskrnl/mm/ARM3/section.c @@ -1662,7 +1662,7 @@ MiGetFileObjectForSectionAddress( { /* Get the section pointer to the SECTION_OBJECT */ Section = MemoryArea->SectionData.Section; - *FileObject = Section->FileObject; + *FileObject = ((PMM_SECTION_SEGMENT)Section->Segment)->FileObject; } else { @@ -1705,7 +1705,7 @@ PFILE_OBJECT NTAPI MmGetFileObjectForSection(IN PVOID SectionObject) { - PSECTION Section; + PSECTION Section = SectionObject; ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL); ASSERT(SectionObject != NULL); @@ -1713,12 +1713,11 @@ MmGetFileObjectForSection(IN PVOID SectionObject) if (MiIsRosSectionObject(SectionObject) == FALSE) { /* Return the file pointer stored in the control area */ - Section = SectionObject; return Section->Segment->ControlArea->FilePointer; } /* Return the file object */ - return ((PROS_SECTION_OBJECT)SectionObject)->FileObject; + return ((PMM_SECTION_SEGMENT)Section->Segment)->FileObject; } static @@ -1740,7 +1739,7 @@ MiGetFileObjectForVad( { /* Get the section pointer to the SECTION_OBJECT */ Section = MemoryArea->SectionData.Section; - FileObject = Section->FileObject; + FileObject = ((PMM_SECTION_SEGMENT)Section->Segment)->FileObject; } else { diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index 73711677d41..b975433e271 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -847,6 +847,7 @@ MmFreeSectionSegments(PFILE_OBJECT FileObject) } MmFreePageTablesSectionSegment(&SectionSegments[i], NULL); } + ObDereferenceObject(ImageSectionObject->FileObject); ExFreePool(ImageSectionObject->Segments); ExFreePool(ImageSectionObject); FileObject->SectionObjectPointer->ImageSectionObject = NULL; @@ -863,6 +864,7 @@ MmFreeSectionSegments(PFILE_OBJECT FileObject) DPRINT1("Data segment still referenced\n"); KeBugCheck(MEMORY_MANAGEMENT); } + ObDereferenceObject(Segment->FileObject); MmFreePageTablesSectionSegment(Segment, NULL); ExFreePool(Segment); FileObject->SectionObjectPointer->DataSectionObject = NULL; @@ -941,7 +943,7 @@ MmUnsharePageEntrySectionSegment(PROS_SECTION_OBJECT Section, #endif Page = PFN_FROM_SSE(Entry); - FileObject = Section->FileObject; + FileObject = Segment->FileObject; if (FileObject != NULL && !(Segment->Image.Characteristics & IMAGE_SCN_MEM_SHARED)) { @@ -1047,7 +1049,7 @@ BOOLEAN MiIsPageFromCache(PMEMORY_AREA MemoryArea, { PROS_SHARED_CACHE_MAP SharedCacheMap; PROS_VACB Vacb; - SharedCacheMap = MemoryArea->SectionData.Section->FileObject->SectionObjectPointer->SharedCacheMap; + SharedCacheMap = MemoryArea->SectionData.Segment->FileObject->SectionObjectPointer->SharedCacheMap; Vacb = CcRosLookupVacb(SharedCacheMap, SegOffset + MemoryArea->SectionData.Segment->Image.FileOffset); if (Vacb) { @@ -1106,7 +1108,7 @@ MiReadPage(PMEMORY_AREA MemoryArea, BOOLEAN IsImageSection; LONGLONG Length; - FileObject = MemoryArea->SectionData.Section->FileObject; + FileObject = MemoryArea->SectionData.Segment->FileObject; SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap; RawLength = MemoryArea->SectionData.Segment->RawLength.QuadPart; FileOffset = SegOffset + MemoryArea->SectionData.Segment->Image.FileOffset; @@ -2012,7 +2014,7 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace, #ifndef NEWCC FileOffset = Context.Offset.QuadPart + Context.Segment->Image.FileOffset; IsImageSection = Context.Section->u.Flags.Image; - FileObject = Context.Section->FileObject; + FileObject = Context.Segment->FileObject; if (FileObject != NULL && !(Context.Segment->Image.Characteristics & IMAGE_SCN_MEM_SHARED)) @@ -2392,7 +2394,7 @@ MmWritePageSectionView(PMMSUPPORT AddressSpace, Section = MemoryArea->SectionData.Section; IsImageSection = Section->u.Flags.Image; - FileObject = Section->FileObject; + FileObject = Segment->FileObject; DirectMapped = FALSE; if (FileObject != NULL && !(Segment->Image.Characteristics & IMAGE_SCN_MEM_SHARED)) @@ -2709,13 +2711,16 @@ MmpDeleteSection(PVOID ObjectBody) (void)InterlockedDecrementUL(&((PMM_SECTION_SEGMENT)Section->Segment)->ReferenceCount); } - if (Section->FileObject != NULL) + + if (Section->Segment) { -#ifndef NEWCC - CcRosDereferenceCache(Section->FileObject); -#endif - ObDereferenceObject(Section->FileObject); - Section->FileObject = NULL; + PMM_SECTION_SEGMENT Segment = (PMM_SECTION_SEGMENT)Section->Segment; + if (Segment->FileObject != NULL) + { + #ifndef NEWCC + CcRosDereferenceCache(Segment->FileObject); + #endif + } } } @@ -2986,6 +2991,7 @@ MmCreateDataFileSection(PROS_SECTION_OBJECT *SectionObject, Section->Segment = (PSEGMENT)Segment; Segment->ReferenceCount = 1; ExInitializeFastMutex(&Segment->Lock); + Segment->FileObject = FileObject; /* * Set the lock before assigning the segment to the file object */ @@ -3029,9 +3035,12 @@ MmCreateDataFileSection(PROS_SECTION_OBJECT *SectionObject, Segment->RawLength.QuadPart = MaximumSize.QuadPart; Segment->Length.QuadPart = PAGE_ROUND_UP(Segment->RawLength.QuadPart); } + + /* We let the segment reference the file object */ + ObDereferenceObject(FileObject); + FileObject = Segment->FileObject; } MmUnlockSectionSegment(Segment); - Section->FileObject = FileObject; Section->SizeOfSection = MaximumSize; #ifndef NEWCC CcRosReferenceCache(FileObject); @@ -3663,8 +3672,11 @@ ExeFmtpCreateImageSection(PFILE_OBJECT FileObject, ExInitializeFastMutex(&ImageSectionObject->Segments[i].Lock); ImageSectionObject->Segments[i].ReferenceCount = 1; MiInitializeSectionPageTable(&ImageSectionObject->Segments[i]); + ImageSectionObject->Segments[i].FileObject = FileObject; } + ImageSectionObject->FileObject = FileObject; + ASSERT(NT_SUCCESS(Status)); return Status; } @@ -3795,6 +3807,10 @@ MmCreateImageSection(PROS_SECTION_OBJECT *SectionObject, { (void)InterlockedIncrementUL(&SectionSegments[i].ReferenceCount); } + + /* We let the Image Section Object hold the reference */ + ObDereferenceObject(FileObject); + FileObject = ImageSectionObject->FileObject; } Status = StatusExeFmt; @@ -3824,9 +3840,12 @@ MmCreateImageSection(PROS_SECTION_OBJECT *SectionObject, (void)InterlockedIncrementUL(&SectionSegments[i].ReferenceCount); } + /* We let the Image Section Object hold the reference */ + ObDereferenceObject(FileObject); + FileObject = ImageSectionObject->FileObject; + Status = STATUS_SUCCESS; } - Section->FileObject = FileObject; #ifndef NEWCC CcRosReferenceCache(FileObject); #endif @@ -3963,7 +3982,7 @@ MmFreeSectionPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address, if (Page == PFN_FROM_SSE(Entry) && Dirty) { #ifndef NEWCC - FileObject = MemoryArea->SectionData.Section->FileObject; + FileObject = MemoryArea->SectionData.Segment->FileObject; SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap; CcRosMarkDirtyFile(SharedCacheMap, Offset.QuadPart + Segment->Image.FileOffset); #endif
3 years, 10 months
1
0
0
0
[reactos] 13/100: [NTOSKRNL] Store the MM_IMAGE_SECTION_OBJECT pointer in SECTION::Segment
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e980efebd4efe53a596ca…
commit e980efebd4efe53a596cab313e825160c6bf76fb Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Fri Oct 23 17:27:47 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:21 2021 +0100 [NTOSKRNL] Store the MM_IMAGE_SECTION_OBJECT pointer in SECTION::Segment --- ntoskrnl/include/internal/mm.h | 2 -- ntoskrnl/mm/ARM3/section.c | 8 +++++++- ntoskrnl/mm/ARM3/sysldr.c | 20 ++++++++++---------- ntoskrnl/mm/section.c | 21 ++++++++++----------- 4 files changed, 27 insertions(+), 24 deletions(-) diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h index a7affb0a49c..760b514de4a 100644 --- a/ntoskrnl/include/internal/mm.h +++ b/ntoskrnl/include/internal/mm.h @@ -200,8 +200,6 @@ typedef struct _ROS_SECTION_OBJECT { SECTION; PFILE_OBJECT FileObject; - - PMM_IMAGE_SECTION_OBJECT ImageSection; } ROS_SECTION_OBJECT, *PROS_SECTION_OBJECT; #define MA_GetStartingAddress(_MemoryArea) ((_MemoryArea)->VadNode.StartingVpn << PAGE_SHIFT) diff --git a/ntoskrnl/mm/ARM3/section.c b/ntoskrnl/mm/ARM3/section.c index 58d261e5476..81ecdc9f8dc 100644 --- a/ntoskrnl/mm/ARM3/section.c +++ b/ntoskrnl/mm/ARM3/section.c @@ -1789,8 +1789,14 @@ MmGetImageInformation (OUT PSECTION_IMAGE_INFORMATION ImageInformation) ASSERT(SectionObject != NULL); ASSERT(MiIsRosSectionObject(SectionObject) == TRUE); + if (SectionObject->u.Flags.Image == 0) + { + RtlZeroMemory(ImageInformation, sizeof(*ImageInformation)); + return; + } + /* Return the image information */ - *ImageInformation = ((PROS_SECTION_OBJECT)SectionObject)->ImageSection->ImageInformation; + *ImageInformation = ((PMM_IMAGE_SECTION_OBJECT)SectionObject->Segment)->ImageInformation; } NTSTATUS diff --git a/ntoskrnl/mm/ARM3/sysldr.c b/ntoskrnl/mm/ARM3/sysldr.c index 811defcde8b..0ebcae75e29 100644 --- a/ntoskrnl/mm/ARM3/sysldr.c +++ b/ntoskrnl/mm/ARM3/sysldr.c @@ -81,13 +81,13 @@ MiCacheImageSymbols(IN PVOID BaseAddress) NTSTATUS NTAPI -MiLoadImageSection(IN OUT PVOID *SectionPtr, - OUT PVOID *ImageBase, - IN PUNICODE_STRING FileName, - IN BOOLEAN SessionLoad, - IN PLDR_DATA_TABLE_ENTRY LdrEntry) +MiLoadImageSection(_Inout_ PSECTION *SectionPtr, + _Out_ PVOID *ImageBase, + _In_ PUNICODE_STRING FileName, + _In_ BOOLEAN SessionLoad, + _In_ PLDR_DATA_TABLE_ENTRY LdrEntry) { - PROS_SECTION_OBJECT Section = *SectionPtr; + PSECTION Section = *SectionPtr; NTSTATUS Status; PEPROCESS Process; PVOID Base = NULL; @@ -158,7 +158,7 @@ MiLoadImageSection(IN OUT PVOID *SectionPtr, } /* Reserve system PTEs needed */ - PteCount = ROUND_TO_PAGES(Section->ImageSection->ImageInformation.ImageFileSize) >> PAGE_SHIFT; + PteCount = ROUND_TO_PAGES(((PMM_IMAGE_SECTION_OBJECT)Section->Segment)->ImageInformation.ImageFileSize) >> PAGE_SHIFT; PointerPte = MiReserveSystemPtes(PteCount, SystemPteSpace); if (!PointerPte) { @@ -2837,7 +2837,7 @@ MmLoadSystemImage(IN PUNICODE_STRING FileName, PWCHAR MissingDriverName; HANDLE SectionHandle; ACCESS_MASK DesiredAccess; - PVOID Section = NULL; + PSECTION Section = NULL; BOOLEAN LockOwned = FALSE; PLIST_ENTRY NextEntry; IMAGE_INFO ImageInfo; @@ -3054,7 +3054,7 @@ LoaderScan: SECTION_MAP_EXECUTE, MmSectionObjectType, KernelMode, - &Section, + (PVOID*)&Section, NULL); ZwClose(SectionHandle); if (!NT_SUCCESS(Status)) goto Quickie; @@ -3085,7 +3085,7 @@ LoaderScan: ASSERT(Status != STATUS_ALREADY_COMMITTED); /* Get the size of the driver */ - DriverSize = ((PROS_SECTION_OBJECT)Section)->ImageSection->ImageInformation.ImageFileSize; + DriverSize = ((PMM_IMAGE_SECTION_OBJECT)Section->Segment)->ImageInformation.ImageFileSize; /* Make sure we're not being loaded into session space */ if (!Flags) diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index 59b6a22ec36..73711677d41 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -2633,7 +2633,7 @@ MmpFreePageFileSegment(PMM_SECTION_SEGMENT Segment) VOID NTAPI MmpDeleteSection(PVOID ObjectBody) { - PROS_SECTION_OBJECT Section = (PROS_SECTION_OBJECT)ObjectBody; + PROS_SECTION_OBJECT Section = ObjectBody; /* Check if it's an ARM3, or ReactOS section */ if (!MiIsRosSectionObject(Section)) @@ -2656,11 +2656,11 @@ MmpDeleteSection(PVOID ObjectBody) * until the image section is properly initialized we shouldn't * process further here. */ - if (Section->ImageSection == NULL) + if (Section->Segment == NULL) return; - SectionSegments = Section->ImageSection->Segments; - NrSegments = Section->ImageSection->NrSegments; + SectionSegments = ((PMM_IMAGE_SECTION_OBJECT)Section->Segment)->Segments; + NrSegments = ((PMM_IMAGE_SECTION_OBJECT)Section->Segment)->NrSegments; for (i = 0; i < NrSegments; i++) { @@ -3763,7 +3763,7 @@ MmCreateImageSection(PROS_SECTION_OBJECT *SectionObject, return(Status); } - Section->ImageSection = ImageSectionObject; + Section->Segment = (PSEGMENT)ImageSectionObject; ASSERT(ImageSectionObject->Segments); /* @@ -3788,7 +3788,7 @@ MmCreateImageSection(PROS_SECTION_OBJECT *SectionObject, ExFreePool(ImageSectionObject->Segments); ExFreePool(ImageSectionObject); ImageSectionObject = FileObject->SectionObjectPointer->ImageSectionObject; - Section->ImageSection = ImageSectionObject; + Section->Segment = (PSEGMENT)ImageSectionObject; SectionSegments = ImageSectionObject->Segments; for (i = 0; i < ImageSectionObject->NrSegments; i++) @@ -3813,7 +3813,7 @@ MmCreateImageSection(PROS_SECTION_OBJECT *SectionObject, } ImageSectionObject = FileObject->SectionObjectPointer->ImageSectionObject; - Section->ImageSection = ImageSectionObject; + Section->Segment = (PSEGMENT)ImageSectionObject; SectionSegments = ImageSectionObject->Segments; /* @@ -4114,7 +4114,7 @@ MiRosUnmapViewOfSection(IN PEPROCESS Process, PMM_SECTION_SEGMENT Segment; Segment = MemoryArea->SectionData.Segment; - ImageSectionObject = Section->ImageSection; + ImageSectionObject = ((PMM_IMAGE_SECTION_OBJECT)Section->Segment); SectionSegments = ImageSectionObject->Segments; NrSegments = ImageSectionObject->NrSegments; @@ -4314,8 +4314,7 @@ NtQuerySection( { if (RosSection->u.Flags.Image) { - PMM_IMAGE_SECTION_OBJECT ImageSectionObject; - ImageSectionObject = RosSection->ImageSection; + PMM_IMAGE_SECTION_OBJECT ImageSectionObject = ((PMM_IMAGE_SECTION_OBJECT)Section->Segment); *Sii = ImageSectionObject->ImageInformation; } @@ -4504,7 +4503,7 @@ MmMapViewOfSection(IN PVOID SectionObject, PMM_IMAGE_SECTION_OBJECT ImageSectionObject; PMM_SECTION_SEGMENT SectionSegments; - ImageSectionObject = Section->ImageSection; + ImageSectionObject = ((PMM_IMAGE_SECTION_OBJECT)Section->Segment); SectionSegments = ImageSectionObject->Segments; NrSegments = ImageSectionObject->NrSegments;
3 years, 10 months
1
0
0
0
[reactos] 12/100: [NTOSKRNL] Get rid of MEMORY_AREA::Protect
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c6a87f28bf4a0a3270adf…
commit c6a87f28bf4a0a3270adf6114ed2589e200c5b86 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Fri Oct 23 16:55:00 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:21 2021 +0100 [NTOSKRNL] Get rid of MEMORY_AREA::Protect Use the VAD node instead --- ntoskrnl/include/internal/mm.h | 1 - ntoskrnl/mm/marea.c | 10 +++++----- ntoskrnl/mm/section.c | 10 +++++----- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h index 4bb6d1a60ca..a7affb0a49c 100644 --- a/ntoskrnl/include/internal/mm.h +++ b/ntoskrnl/include/internal/mm.h @@ -212,7 +212,6 @@ typedef struct _MEMORY_AREA MMVAD VadNode; ULONG Type; - ULONG Protect; ULONG Flags; BOOLEAN DeleteInProgress; ULONG Magic; diff --git a/ntoskrnl/mm/marea.c b/ntoskrnl/mm/marea.c index 3736a5a36c8..cd7b9594f1d 100644 --- a/ntoskrnl/mm/marea.c +++ b/ntoskrnl/mm/marea.c @@ -165,12 +165,13 @@ MiMakeProtectionMask( static VOID MmInsertMemoryArea( PMMSUPPORT AddressSpace, - PMEMORY_AREA marea) + PMEMORY_AREA marea, + ULONG Protect) { PEPROCESS Process = MmGetAddressSpaceOwner(AddressSpace); marea->VadNode.u.VadFlags.Spare = 1; - marea->VadNode.u.VadFlags.Protection = MiMakeProtectionMask(marea->Protect); + marea->VadNode.u.VadFlags.Protection = MiMakeProtectionMask(Protect); /* Build a lame VAD if this is a user-space allocation */ if (marea->VadNode.EndingVpn + 1 < (ULONG_PTR)MmSystemRangeStart >> PAGE_SHIFT) @@ -457,7 +458,6 @@ MmCreateMemoryArea(PMMSUPPORT AddressSpace, RtlZeroMemory(MemoryArea, sizeof(MEMORY_AREA)); MemoryArea->Type = Type & ~MEMORY_AREA_STATIC; - MemoryArea->Protect = Protect; MemoryArea->Flags = AllocationFlags; MemoryArea->Magic = 'erAM'; MemoryArea->DeleteInProgress = FALSE; @@ -478,7 +478,7 @@ MmCreateMemoryArea(PMMSUPPORT AddressSpace, MemoryArea->VadNode.StartingVpn = (ULONG_PTR)*BaseAddress >> PAGE_SHIFT; MemoryArea->VadNode.EndingVpn = ((ULONG_PTR)*BaseAddress + tmpLength - 1) >> PAGE_SHIFT; - MmInsertMemoryArea(AddressSpace, MemoryArea); + MmInsertMemoryArea(AddressSpace, MemoryArea, Protect); } else { @@ -516,7 +516,7 @@ MmCreateMemoryArea(PMMSUPPORT AddressSpace, MemoryArea->VadNode.StartingVpn = (ULONG_PTR)*BaseAddress >> PAGE_SHIFT; MemoryArea->VadNode.EndingVpn = ((ULONG_PTR)*BaseAddress + tmpLength - 1) >> PAGE_SHIFT; - MmInsertMemoryArea(AddressSpace, MemoryArea); + MmInsertMemoryArea(AddressSpace, MemoryArea, Protect); } *Result = MemoryArea; diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index 91ef5133849..59b6a22ec36 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -2222,7 +2222,7 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace, { Status = MmCreateVirtualMapping(Process, Address, - MemoryArea->Protect, + MmProtectToValue[MemoryArea->VadNode.u.VadFlags.Protection], &Page, 1); MmSetDirtyPage(Process, Address); @@ -2243,7 +2243,7 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace, */ Status = MmCreateVirtualMapping(Process, Address, - MemoryArea->Protect, + MmProtectToValue[MemoryArea->VadNode.u.VadFlags.Protection], &Page, 1); MmSetDirtyPage(Process, Address); @@ -2280,7 +2280,7 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace, { Status = MmCreateVirtualMapping(Process, Address, - MemoryArea->Protect, + MmProtectToValue[MemoryArea->VadNode.u.VadFlags.Protection], &Page, 1); MmSetDirtyPage(Process, Address); @@ -2293,7 +2293,7 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace, MmLockSectionSegment(Context.Segment); Status = MmCreateVirtualMapping(Process, Address, - MemoryArea->Protect, + MmProtectToValue[MemoryArea->VadNode.u.VadFlags.Protection], &Page, 1); MmSetDirtyPage(Process, Address); @@ -2579,7 +2579,7 @@ MmQuerySectionView(PMEMORY_AREA MemoryArea, Info->Type = MEM_MAPPED; } Info->BaseAddress = RegionBaseAddress; - Info->AllocationProtect = MemoryArea->Protect; + Info->AllocationProtect = MmProtectToValue[MemoryArea->VadNode.u.VadFlags.Protection]; Info->RegionSize = Region->Length; Info->State = MEM_COMMIT; Info->Protect = Region->Protect;
3 years, 10 months
1
0
0
0
[reactos] 11/100: [NTOSKRNL/MM] Get rid of useless members of MEMORY_AREA struct
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c9f924940a954b0f55831…
commit c9f924940a954b0f558319e1df95c1c2d71e2dfe Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Fri Oct 23 16:44:24 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:21 2021 +0100 [NTOSKRNL/MM] Get rid of useless members of MEMORY_AREA struct --- ntoskrnl/include/internal/mm.h | 20 ++++------ ntoskrnl/mm/ARM3/section.c | 4 +- ntoskrnl/mm/rmap.c | 12 +++--- ntoskrnl/mm/section.c | 90 +++++++++++++++++++++--------------------- 4 files changed, 60 insertions(+), 66 deletions(-) diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h index 4ca7e6717aa..4bb6d1a60ca 100644 --- a/ntoskrnl/include/internal/mm.h +++ b/ntoskrnl/include/internal/mm.h @@ -217,20 +217,14 @@ typedef struct _MEMORY_AREA BOOLEAN DeleteInProgress; ULONG Magic; PVOID Vad; - union + + struct { - struct - { - PROS_SECTION_OBJECT Section; - LARGE_INTEGER ViewOffset; - PMM_SECTION_SEGMENT Segment; - LIST_ENTRY RegionListHead; - } SectionData; - struct - { - LIST_ENTRY RegionListHead; - } VirtualMemoryData; - } Data; + PROS_SECTION_OBJECT Section; + LARGE_INTEGER ViewOffset; + PMM_SECTION_SEGMENT Segment; + LIST_ENTRY RegionListHead; + } SectionData; } MEMORY_AREA, *PMEMORY_AREA; typedef struct _MM_RMAP_ENTRY diff --git a/ntoskrnl/mm/ARM3/section.c b/ntoskrnl/mm/ARM3/section.c index 1090a8dfada..58d261e5476 100644 --- a/ntoskrnl/mm/ARM3/section.c +++ b/ntoskrnl/mm/ARM3/section.c @@ -1661,7 +1661,7 @@ MiGetFileObjectForSectionAddress( if (MemoryArea->Type == MEMORY_AREA_SECTION_VIEW) { /* Get the section pointer to the SECTION_OBJECT */ - Section = MemoryArea->Data.SectionData.Section; + Section = MemoryArea->SectionData.Section; *FileObject = Section->FileObject; } else @@ -1739,7 +1739,7 @@ MiGetFileObjectForVad( if (MemoryArea->Type == MEMORY_AREA_SECTION_VIEW) { /* Get the section pointer to the SECTION_OBJECT */ - Section = MemoryArea->Data.SectionData.Section; + Section = MemoryArea->SectionData.Section; FileObject = Section->FileObject; } else diff --git a/ntoskrnl/mm/rmap.c b/ntoskrnl/mm/rmap.c index 9fea631dd09..9f5938d7496 100644 --- a/ntoskrnl/mm/rmap.c +++ b/ntoskrnl/mm/rmap.c @@ -132,19 +132,19 @@ MmPageOutPhysicalAddress(PFN_NUMBER Page) if (Type == MEMORY_AREA_SECTION_VIEW) { ULONG_PTR Entry; - Offset = MemoryArea->Data.SectionData.ViewOffset.QuadPart + + Offset = MemoryArea->SectionData.ViewOffset.QuadPart + ((ULONG_PTR)Address - MA_GetStartingAddress(MemoryArea)); - MmLockSectionSegment(MemoryArea->Data.SectionData.Segment); + MmLockSectionSegment(MemoryArea->SectionData.Segment); /* * Get or create a pageop */ - Entry = MmGetPageEntrySectionSegment(MemoryArea->Data.SectionData.Segment, + Entry = MmGetPageEntrySectionSegment(MemoryArea->SectionData.Segment, (PLARGE_INTEGER)&Offset); if (Entry && MM_IS_WAIT_PTE(Entry)) { - MmUnlockSectionSegment(MemoryArea->Data.SectionData.Segment); + MmUnlockSectionSegment(MemoryArea->SectionData.Segment); MmUnlockAddressSpace(AddressSpace); if (Address < MmSystemRangeStart) { @@ -154,12 +154,12 @@ MmPageOutPhysicalAddress(PFN_NUMBER Page) return(STATUS_UNSUCCESSFUL); } - MmSetPageEntrySectionSegment(MemoryArea->Data.SectionData.Segment, (PLARGE_INTEGER)&Offset, MAKE_SWAP_SSE(MM_WAIT_ENTRY)); + MmSetPageEntrySectionSegment(MemoryArea->SectionData.Segment, (PLARGE_INTEGER)&Offset, MAKE_SWAP_SSE(MM_WAIT_ENTRY)); /* * Release locks now we have a page op. */ - MmUnlockSectionSegment(MemoryArea->Data.SectionData.Segment); + MmUnlockSectionSegment(MemoryArea->SectionData.Segment); MmUnlockAddressSpace(AddressSpace); /* diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index 32ee1f48786..91ef5133849 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -1043,12 +1043,12 @@ BOOLEAN MiIsPageFromCache(PMEMORY_AREA MemoryArea, LONGLONG SegOffset) { #ifndef NEWCC - if (!(MemoryArea->Data.SectionData.Segment->Image.Characteristics & IMAGE_SCN_MEM_SHARED)) + if (!(MemoryArea->SectionData.Segment->Image.Characteristics & IMAGE_SCN_MEM_SHARED)) { PROS_SHARED_CACHE_MAP SharedCacheMap; PROS_VACB Vacb; - SharedCacheMap = MemoryArea->Data.SectionData.Section->FileObject->SectionObjectPointer->SharedCacheMap; - Vacb = CcRosLookupVacb(SharedCacheMap, SegOffset + MemoryArea->Data.SectionData.Segment->Image.FileOffset); + SharedCacheMap = MemoryArea->SectionData.Section->FileObject->SectionObjectPointer->SharedCacheMap; + Vacb = CcRosLookupVacb(SharedCacheMap, SegOffset + MemoryArea->SectionData.Segment->Image.FileOffset); if (Vacb) { CcRosReleaseVacb(SharedCacheMap, Vacb, Vacb->Valid, FALSE, TRUE); @@ -1106,11 +1106,11 @@ MiReadPage(PMEMORY_AREA MemoryArea, BOOLEAN IsImageSection; LONGLONG Length; - FileObject = MemoryArea->Data.SectionData.Section->FileObject; + FileObject = MemoryArea->SectionData.Section->FileObject; SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap; - RawLength = MemoryArea->Data.SectionData.Segment->RawLength.QuadPart; - FileOffset = SegOffset + MemoryArea->Data.SectionData.Segment->Image.FileOffset; - IsImageSection = MemoryArea->Data.SectionData.Section->u.Flags.Image; + RawLength = MemoryArea->SectionData.Segment->RawLength.QuadPart; + FileOffset = SegOffset + MemoryArea->SectionData.Segment->Image.FileOffset; + IsImageSection = MemoryArea->SectionData.Section->u.Flags.Image; ASSERT(SharedCacheMap); @@ -1123,7 +1123,7 @@ MiReadPage(PMEMORY_AREA MemoryArea, */ if (((FileOffset % PAGE_SIZE) == 0) && ((SegOffset + PAGE_SIZE <= RawLength) || !IsImageSection) && - !(MemoryArea->Data.SectionData.Segment->Image.Characteristics & IMAGE_SCN_MEM_SHARED)) + !(MemoryArea->SectionData.Segment->Image.Characteristics & IMAGE_SCN_MEM_SHARED)) { /* @@ -1282,9 +1282,9 @@ MiReadPage(PMEMORY_AREA MemoryArea, RtlZeroMemory(&Resources, sizeof(MM_REQUIRED_RESOURCES)); - Resources.Context = MemoryArea->Data.SectionData.Section->FileObject; + Resources.Context = MemoryArea->SectionData.Section->FileObject; Resources.FileOffset.QuadPart = SegOffset + - MemoryArea->Data.SectionData.Segment->Image.FileOffset; + MemoryArea->SectionData.Segment->Image.FileOffset; Resources.Consumer = MC_USER; Resources.Amount = PAGE_SIZE; @@ -1313,7 +1313,7 @@ MmAlterViewAttributes(PMMSUPPORT AddressSpace, MemoryArea = MmLocateMemoryAreaByAddress(AddressSpace, BaseAddress); ASSERT(MemoryArea != NULL); - Segment = MemoryArea->Data.SectionData.Segment; + Segment = MemoryArea->SectionData.Segment; MmLockSectionSegment(Segment); if ((Segment->WriteCopy) && @@ -1351,7 +1351,7 @@ MmAlterViewAttributes(PMMSUPPORT AddressSpace, PFN_NUMBER Page; Offset.QuadPart = (ULONG_PTR)Address - MA_GetStartingAddress(MemoryArea) - + MemoryArea->Data.SectionData.ViewOffset.QuadPart; + + MemoryArea->SectionData.ViewOffset.QuadPart; Entry = MmGetPageEntrySectionSegment(Segment, &Offset); /* * An MM_WAIT_ENTRY is ok in this case... It'll just count as @@ -1423,12 +1423,12 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace, PAddress = MM_ROUND_DOWN(Address, PAGE_SIZE); Offset.QuadPart = (ULONG_PTR)PAddress - MA_GetStartingAddress(MemoryArea) - + MemoryArea->Data.SectionData.ViewOffset.QuadPart; + + MemoryArea->SectionData.ViewOffset.QuadPart; - Segment = MemoryArea->Data.SectionData.Segment; - Section = MemoryArea->Data.SectionData.Section; + Segment = MemoryArea->SectionData.Segment; + Section = MemoryArea->SectionData.Section; Region = MmFindRegion((PVOID)MA_GetStartingAddress(MemoryArea), - &MemoryArea->Data.SectionData.RegionListHead, + &MemoryArea->SectionData.RegionListHead, Address, NULL); ASSERT(Region != NULL); @@ -1442,7 +1442,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace, { /* Remove it */ Status = MmAlterRegion(AddressSpace, (PVOID)MA_GetStartingAddress(MemoryArea), - &MemoryArea->Data.SectionData.RegionListHead, + &MemoryArea->SectionData.RegionListHead, Address, PAGE_SIZE, Region->Type, Region->Protect & ~PAGE_GUARD, MmAlterViewAttributes); @@ -1844,12 +1844,12 @@ MmAccessFaultSectionView(PMMSUPPORT AddressSpace, */ PAddress = MM_ROUND_DOWN(Address, PAGE_SIZE); Offset.QuadPart = (ULONG_PTR)PAddress - MA_GetStartingAddress(MemoryArea) - + MemoryArea->Data.SectionData.ViewOffset.QuadPart; + + MemoryArea->SectionData.ViewOffset.QuadPart; - Segment = MemoryArea->Data.SectionData.Segment; - Section = MemoryArea->Data.SectionData.Section; + Segment = MemoryArea->SectionData.Segment; + Section = MemoryArea->SectionData.Section; Region = MmFindRegion((PVOID)MA_GetStartingAddress(MemoryArea), - &MemoryArea->Data.SectionData.RegionListHead, + &MemoryArea->SectionData.RegionListHead, Address, NULL); ASSERT(Region != NULL); @@ -1997,13 +1997,13 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace, /* * Get the segment and section. */ - Context.Segment = MemoryArea->Data.SectionData.Segment; - Context.Section = MemoryArea->Data.SectionData.Section; + Context.Segment = MemoryArea->SectionData.Segment; + Context.Section = MemoryArea->SectionData.Section; Context.SectionEntry = Entry; Context.CallingProcess = Process; Context.Offset.QuadPart = (ULONG_PTR)Address - MA_GetStartingAddress(MemoryArea) - + MemoryArea->Data.SectionData.ViewOffset.QuadPart; + + MemoryArea->SectionData.ViewOffset.QuadPart; DirectMapped = FALSE; @@ -2383,13 +2383,13 @@ MmWritePageSectionView(PMMSUPPORT AddressSpace, Address = (PVOID)PAGE_ROUND_DOWN(Address); Offset.QuadPart = (ULONG_PTR)Address - MA_GetStartingAddress(MemoryArea) - + MemoryArea->Data.SectionData.ViewOffset.QuadPart; + + MemoryArea->SectionData.ViewOffset.QuadPart; /* * Get the segment and section. */ - Segment = MemoryArea->Data.SectionData.Segment; - Section = MemoryArea->Data.SectionData.Section; + Segment = MemoryArea->SectionData.Segment; + Section = MemoryArea->SectionData.Section; IsImageSection = Section->u.Flags.Image; FileObject = Section->FileObject; @@ -2528,7 +2528,7 @@ MmProtectSectionView(PMMSUPPORT AddressSpace, Length = (ULONG)MaxLength; Region = MmFindRegion((PVOID)MA_GetStartingAddress(MemoryArea), - &MemoryArea->Data.SectionData.RegionListHead, + &MemoryArea->SectionData.RegionListHead, BaseAddress, NULL); ASSERT(Region != NULL); @@ -2540,7 +2540,7 @@ MmProtectSectionView(PMMSUPPORT AddressSpace, *OldProtect = Region->Protect; Status = MmAlterRegion(AddressSpace, (PVOID)MA_GetStartingAddress(MemoryArea), - &MemoryArea->Data.SectionData.RegionListHead, + &MemoryArea->SectionData.RegionListHead, BaseAddress, Length, Region->Type, Protect, MmAlterViewAttributes); @@ -2559,17 +2559,17 @@ MmQuerySectionView(PMEMORY_AREA MemoryArea, PMM_SECTION_SEGMENT Segment; Region = MmFindRegion((PVOID)MA_GetStartingAddress(MemoryArea), - &MemoryArea->Data.SectionData.RegionListHead, + &MemoryArea->SectionData.RegionListHead, Address, &RegionBaseAddress); if (Region == NULL) { return STATUS_UNSUCCESSFUL; } - Section = MemoryArea->Data.SectionData.Section; + Section = MemoryArea->SectionData.Section; if (Section->u.Flags.Image) { - Segment = MemoryArea->Data.SectionData.Segment; + Segment = MemoryArea->SectionData.Segment; Info->AllocationBase = (PUCHAR)MA_GetStartingAddress(MemoryArea) - Segment->Image.VirtualAddress; Info->Type = MEM_IMAGE; } @@ -3899,15 +3899,15 @@ MmMapViewOfSegment(PMMSUPPORT AddressSpace, ObReferenceObject((PVOID)Section); - MArea->Data.SectionData.Segment = Segment; - MArea->Data.SectionData.Section = Section; - MArea->Data.SectionData.ViewOffset.QuadPart = ViewOffset; + MArea->SectionData.Segment = Segment; + MArea->SectionData.Section = Section; + MArea->SectionData.ViewOffset.QuadPart = ViewOffset; if (Section->u.Flags.Image) { MArea->VadNode.u.VadFlags.VadType = VadImageMap; } - MmInitializeRegion(&MArea->Data.SectionData.RegionListHead, + MmInitializeRegion(&MArea->SectionData.RegionListHead, ViewSize, 0, Protect); return(STATUS_SUCCESS); @@ -3936,10 +3936,10 @@ MmFreeSectionPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address, Address = (PVOID)PAGE_ROUND_DOWN(Address); Offset.QuadPart = ((ULONG_PTR)Address - MA_GetStartingAddress(MemoryArea)) + - MemoryArea->Data.SectionData.ViewOffset.QuadPart; + MemoryArea->SectionData.ViewOffset.QuadPart; - Section = MemoryArea->Data.SectionData.Section; - Segment = MemoryArea->Data.SectionData.Segment; + Section = MemoryArea->SectionData.Section; + Segment = MemoryArea->SectionData.Segment; Entry = MmGetPageEntrySectionSegment(Segment, &Offset); while (Entry && MM_IS_WAIT_PTE(Entry)) @@ -3963,7 +3963,7 @@ MmFreeSectionPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address, if (Page == PFN_FROM_SSE(Entry) && Dirty) { #ifndef NEWCC - FileObject = MemoryArea->Data.SectionData.Section->FileObject; + FileObject = MemoryArea->SectionData.Section->FileObject; SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap; CcRosMarkDirtyFile(SharedCacheMap, Offset.QuadPart + Segment->Image.FileOffset); #endif @@ -4022,8 +4022,8 @@ MmUnmapViewOfSegment(PMMSUPPORT AddressSpace, return(STATUS_UNSUCCESSFUL); } - Section = MemoryArea->Data.SectionData.Section; - Segment = MemoryArea->Data.SectionData.Segment; + Section = MemoryArea->SectionData.Section; + Segment = MemoryArea->SectionData.Segment; #ifdef NEWCC if (Segment->Flags & MM_DATAFILE_SEGMENT) @@ -4040,7 +4040,7 @@ MmUnmapViewOfSegment(PMMSUPPORT AddressSpace, MmLockSectionSegment(Segment); - RegionListHead = &MemoryArea->Data.SectionData.RegionListHead; + RegionListHead = &MemoryArea->SectionData.RegionListHead; while (!IsListEmpty(RegionListHead)) { CurrentEntry = RemoveHeadList(RegionListHead); @@ -4103,7 +4103,7 @@ MiRosUnmapViewOfSection(IN PEPROCESS Process, return STATUS_NOT_MAPPED_VIEW; } - Section = MemoryArea->Data.SectionData.Section; + Section = MemoryArea->SectionData.Section; if ((Section != NULL) && Section->u.Flags.Image) { @@ -4113,7 +4113,7 @@ MiRosUnmapViewOfSection(IN PEPROCESS Process, PMM_SECTION_SEGMENT SectionSegments; PMM_SECTION_SEGMENT Segment; - Segment = MemoryArea->Data.SectionData.Segment; + Segment = MemoryArea->SectionData.Segment; ImageSectionObject = Section->ImageSection; SectionSegments = ImageSectionObject->Segments; NrSegments = ImageSectionObject->NrSegments;
3 years, 10 months
1
0
0
0
[reactos] 10/100: [NTOSKRNL] Use PSECTION struct where possible
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=defbf63416fc622bdfbbb…
commit defbf63416fc622bdfbbbe8cb0283d559cbf84a9 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Fri Oct 23 16:39:15 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:21 2021 +0100 [NTOSKRNL] Use PSECTION struct where possible --- ntoskrnl/include/internal/mm.h | 2 +- ntoskrnl/mm/ARM3/miarm.h | 2 +- ntoskrnl/mm/ARM3/procsup.c | 10 ++++------ ntoskrnl/mm/ARM3/section.c | 15 +++------------ 4 files changed, 9 insertions(+), 20 deletions(-) diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h index 1fbe513524f..4ca7e6717aa 100644 --- a/ntoskrnl/include/internal/mm.h +++ b/ntoskrnl/include/internal/mm.h @@ -221,7 +221,7 @@ typedef struct _MEMORY_AREA { struct { - ROS_SECTION_OBJECT* Section; + PROS_SECTION_OBJECT Section; LARGE_INTEGER ViewOffset; PMM_SECTION_SEGMENT Segment; LIST_ENTRY RegionListHead; diff --git a/ntoskrnl/mm/ARM3/miarm.h b/ntoskrnl/mm/ARM3/miarm.h index ade2696cf1d..025cd6f6561 100644 --- a/ntoskrnl/mm/ARM3/miarm.h +++ b/ntoskrnl/mm/ARM3/miarm.h @@ -1071,7 +1071,7 @@ FORCEINLINE BOOLEAN MiIsRosSectionObject(IN PVOID Section) { - PROS_SECTION_OBJECT RosSection = Section; + PSECTION RosSection = Section; return RosSection->u.Flags.filler; } diff --git a/ntoskrnl/mm/ARM3/procsup.c b/ntoskrnl/mm/ARM3/procsup.c index a183f8a099f..eb8e68180d4 100644 --- a/ntoskrnl/mm/ARM3/procsup.c +++ b/ntoskrnl/mm/ARM3/procsup.c @@ -941,7 +941,6 @@ MmInitializeProcessAddressSpace(IN PEPROCESS Process, NTSTATUS Status = STATUS_SUCCESS; SIZE_T ViewSize = 0; PVOID ImageBase = 0; - PROS_SECTION_OBJECT SectionObject = Section; PMMPTE PointerPte; KIRQL OldIrql; PMMPDE PointerPde; @@ -1048,10 +1047,11 @@ MmInitializeProcessAddressSpace(IN PEPROCESS Process, #endif /* Check if there's a Section Object */ - if (SectionObject) + if (Section) { /* Determine the image file name and save it to EPROCESS */ - FileName = SectionObject->FileObject->FileName; + PFILE_OBJECT FileObject = MmGetFileObjectForSection(Section); + FileName = FileObject->FileName; Source = (PWCHAR)((PCHAR)FileName.Buffer + FileName.Length); if (FileName.Buffer) { @@ -1083,9 +1083,7 @@ MmInitializeProcessAddressSpace(IN PEPROCESS Process, if (AuditName) { /* Setup the audit name */ - Status = SeInitializeProcessAuditName(SectionObject->FileObject, - FALSE, - AuditName); + Status = SeInitializeProcessAuditName(FileObject, FALSE, AuditName); if (!NT_SUCCESS(Status)) { /* Fail */ diff --git a/ntoskrnl/mm/ARM3/section.c b/ntoskrnl/mm/ARM3/section.c index bff71dfe81c..1090a8dfada 100644 --- a/ntoskrnl/mm/ARM3/section.c +++ b/ntoskrnl/mm/ARM3/section.c @@ -1831,19 +1831,10 @@ MmGetFileNameForSection(IN PVOID Section, OUT POBJECT_NAME_INFORMATION *ModuleName) { PFILE_OBJECT FileObject; + PSECTION SectionObject = Section; /* Make sure it's an image section */ - if (MiIsRosSectionObject(Section) == FALSE) - { - /* Check ARM3 Section flag */ - if (((PSECTION)Section)->u.Flags.Image == 0) - { - /* It's not, fail */ - DPRINT1("Not an image section\n"); - return STATUS_SECTION_NOT_IMAGE; - } - } - else if (!(((PROS_SECTION_OBJECT)Section)->u.Flags.Image)) + if (SectionObject->u.Flags.Image == 0) { /* It's not, fail */ DPRINT1("Not an image section\n"); @@ -3594,7 +3585,7 @@ NtMapViewOfSection(IN HANDLE SectionHandle, PVOID SafeBaseAddress; LARGE_INTEGER SafeSectionOffset; SIZE_T SafeViewSize; - PROS_SECTION_OBJECT Section; + PSECTION Section; PEPROCESS Process; NTSTATUS Status; ACCESS_MASK DesiredAccess;
3 years, 10 months
1
0
0
0
[reactos] 09/100: [NTOSKRNL] Unload the cargo: We only use tiny bits of "NEWCC"
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=462d9a097483f6fdabeca…
commit 462d9a097483f6fdabeca18b7aa93b6b4bc9c993 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Fri Oct 23 16:16:51 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:21 2021 +0100 [NTOSKRNL] Unload the cargo: We only use tiny bits of "NEWCC" --- ntoskrnl/cache/section/data.c | 13 ++++++++----- ntoskrnl/cache/section/fault.c | 6 ++++++ ntoskrnl/cache/section/io.c | 2 ++ ntoskrnl/include/internal/mm.h | 2 ++ ntoskrnl/mm/ARM3/section.c | 9 +++++++++ ntoskrnl/mm/marea.c | 10 ++++++++++ ntoskrnl/mm/mmfault.c | 8 ++++---- ntoskrnl/mm/mminit.c | 5 +++++ ntoskrnl/mm/rmap.c | 2 ++ ntoskrnl/mm/section.c | 31 +++++++++++++++++++++++++++++-- ntoskrnl/ntos.cmake | 10 +++++----- 11 files changed, 82 insertions(+), 16 deletions(-) diff --git a/ntoskrnl/cache/section/data.c b/ntoskrnl/cache/section/data.c index cd92979ac1c..1ec6a3326d9 100644 --- a/ntoskrnl/cache/section/data.c +++ b/ntoskrnl/cache/section/data.c @@ -112,6 +112,7 @@ _MmUnlockSectionSegment(PMM_SECTION_SEGMENT Segment, const char *file, int line) //DPRINT("MmUnlockSectionSegment(%p,%s:%d)\n", Segment, file, line); } +#ifdef NEWCC /* MiFlushMappedSection @@ -265,7 +266,6 @@ This deletes a segment entirely including its page map. It must have been unmapped in every address space. */ - VOID NTAPI MmFinalizeSegment(PMM_SECTION_SEGMENT Segment) @@ -274,6 +274,8 @@ MmFinalizeSegment(PMM_SECTION_SEGMENT Segment) DPRINT("Finalize segment %p\n", Segment); + __debugbreak(); + MmLockSectionSegment(Segment); RemoveEntryList(&Segment->ListOfSegments); if (Segment->Flags & MM_DATAFILE_SEGMENT) { @@ -303,7 +305,6 @@ MmFinalizeSegment(PMM_SECTION_SEGMENT Segment) ExFreePoolWithTag(Segment, TAG_MM_SECTION_SEGMENT); } -#ifdef NEWCC NTSTATUS NTAPI MmCreateCacheSection(PROS_SECTION_OBJECT *SectionObject, @@ -534,7 +535,6 @@ MmCreateCacheSection(PROS_SECTION_OBJECT *SectionObject, *SectionObject = Section; return STATUS_SUCCESS; } -#endif NTSTATUS NTAPI @@ -605,6 +605,7 @@ _MiMapViewOfSegment(PMMSUPPORT AddressSpace, return STATUS_SUCCESS; } +#endif /* @@ -621,6 +622,8 @@ MiFreeSegmentPage(PMM_SECTION_SEGMENT Segment, ULONG_PTR Entry; PFILE_OBJECT FileObject = Segment->FileObject; + __debugbreak(); + Entry = MmGetPageEntrySectionSegment(Segment, FileOffset); DPRINTC("MiFreeSegmentPage(%p:%I64x -> Entry %Ix\n", Segment, @@ -710,6 +713,7 @@ MmFreeCacheSectionPage(PVOID Context, } } +#ifdef NEWCC NTSTATUS NTAPI MmUnmapViewOfCacheSegment(PMMSUPPORT AddressSpace, @@ -755,7 +759,6 @@ MmUnmapViewOfCacheSegment(PMMSUPPORT AddressSpace, return STATUS_SUCCESS; } -#ifdef NEWCC NTSTATUS NTAPI MmExtendCacheSection(PROS_SECTION_OBJECT Section, @@ -793,7 +796,6 @@ MmExtendCacheSection(PROS_SECTION_OBJECT Section, MmUnlockSectionSegment(Segment); return STATUS_SUCCESS; } -#endif NTSTATUS NTAPI @@ -844,5 +846,6 @@ MmUnmapCacheViewInSystemSpace (IN PVOID MappedBase) return Status; } +#endif /* NEWCC */ /* EOF */ diff --git a/ntoskrnl/cache/section/fault.c b/ntoskrnl/cache/section/fault.c index c70805a71ae..e869dac88fb 100644 --- a/ntoskrnl/cache/section/fault.c +++ b/ntoskrnl/cache/section/fault.c @@ -82,6 +82,8 @@ rmaps, so each mapping should be immediately followed by an rmap addition. #define DPRINTC DPRINT extern KEVENT MmWaitPageEvent; + +#ifdef NEWCC extern PMMWSL MmWorkingSetList; /* @@ -150,6 +152,7 @@ MmNotPresentFaultCachePage ( if (Segment->FileObject) { + __debugbreak(); DPRINT("FileName %wZ\n", &Segment->FileObject->FileName); } @@ -453,9 +456,11 @@ MiCowCacheSectionPage ( DPRINT("Address 0x%p\n", Address); return STATUS_SUCCESS; } +#endif KEVENT MmWaitPageEvent; +#ifdef NEWCC typedef struct _WORK_QUEUE_WITH_CONTEXT { WORK_QUEUE_ITEM WorkItem; @@ -960,3 +965,4 @@ MmNotPresentFaultCacheSection(KPROCESSOR_MODE Mode, return Status; } +#endif diff --git a/ntoskrnl/cache/section/io.c b/ntoskrnl/cache/section/io.c index 20454abb905..8ac93b06134 100644 --- a/ntoskrnl/cache/section/io.c +++ b/ntoskrnl/cache/section/io.c @@ -188,6 +188,7 @@ MiSimpleRead(PFILE_OBJECT FileObject, return Status; } +#ifdef NEWCC /* Convenience function for writing from kernel space. This issues a paging @@ -334,3 +335,4 @@ _MiWriteBackPage(PFILE_OBJECT FileObject, return Status; } +#endif diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h index c118866d5b5..1fbe513524f 100644 --- a/ntoskrnl/include/internal/mm.h +++ b/ntoskrnl/include/internal/mm.h @@ -69,7 +69,9 @@ typedef ULONG_PTR SWAPENTRY; #endif #define MEMORY_AREA_SECTION_VIEW (1) +#ifdef NEWCC #define MEMORY_AREA_CACHE (2) +#endif #define MEMORY_AREA_OWNED_BY_ARM3 (15) #define MEMORY_AREA_STATIC (0x80000000) diff --git a/ntoskrnl/mm/ARM3/section.c b/ntoskrnl/mm/ARM3/section.c index d1f1e5bbaf2..bff71dfe81c 100644 --- a/ntoskrnl/mm/ARM3/section.c +++ b/ntoskrnl/mm/ARM3/section.c @@ -1666,9 +1666,14 @@ MiGetFileObjectForSectionAddress( } else { +#ifdef NEWCC ASSERT(MemoryArea->Type == MEMORY_AREA_CACHE); DPRINT1("Address is a cache section!\n"); return STATUS_SECTION_NOT_IMAGE; +#else + ASSERT(FALSE); + return STATUS_SECTION_NOT_IMAGE; +#endif } } else @@ -1739,8 +1744,12 @@ MiGetFileObjectForVad( } else { +#ifdef NEWCC ASSERT(MemoryArea->Type == MEMORY_AREA_CACHE); DPRINT1("VAD is a cache section!\n"); +#else + ASSERT(FALSE); +#endif return NULL; } } diff --git a/ntoskrnl/mm/marea.c b/ntoskrnl/mm/marea.c index d953f422f96..3736a5a36c8 100644 --- a/ntoskrnl/mm/marea.c +++ b/ntoskrnl/mm/marea.c @@ -178,7 +178,11 @@ MmInsertMemoryArea( ASSERT(Process != NULL); if (marea->Type != MEMORY_AREA_OWNED_BY_ARM3) { +#ifdef NEWCC ASSERT(marea->Type == MEMORY_AREA_SECTION_VIEW || marea->Type == MEMORY_AREA_CACHE); +#else + ASSERT(marea->Type == MEMORY_AREA_SECTION_VIEW); +#endif /* Insert the VAD */ MiLockProcessWorkingSetUnsafe(PsGetCurrentProcess(), PsGetCurrentThread()); @@ -353,7 +357,11 @@ MmFreeMemoryArea( if (MemoryArea->Vad) { ASSERT(MemoryArea->VadNode.EndingVpn + 1 < (ULONG_PTR)MmSystemRangeStart >> PAGE_SHIFT); +#ifdef NEWCC ASSERT(MemoryArea->Type == MEMORY_AREA_SECTION_VIEW || MemoryArea->Type == MEMORY_AREA_CACHE); +#else + ASSERT(MemoryArea->Type == MEMORY_AREA_SECTION_VIEW); +#endif /* MmCleanProcessAddressSpace might have removed it (and this would be MmDeleteProcessAdressSpace) */ ASSERT(MemoryArea->VadNode.u.VadFlags.Spare != 0); @@ -545,10 +553,12 @@ MiRosCleanupMemoryArea( { Status = MiRosUnmapViewOfSection(Process, BaseAddress, Process->ProcessExiting); } +#ifdef NEWCC else if (MemoryArea->Type == MEMORY_AREA_CACHE) { Status = MmUnmapViewOfCacheSegment(&Process->Vm, BaseAddress); } +#endif else { /* There shouldn't be anything else! */ diff --git a/ntoskrnl/mm/mmfault.c b/ntoskrnl/mm/mmfault.c index 68910e7a2d9..75f7b584a22 100644 --- a/ntoskrnl/mm/mmfault.c +++ b/ntoskrnl/mm/mmfault.c @@ -79,7 +79,7 @@ MmpAccessFault(KPROCESSOR_MODE Mode, MemoryArea, (PVOID)Address); break; - +#ifdef NEWCC case MEMORY_AREA_CACHE: // This code locks for itself to keep from having to break a lock // passed in. @@ -89,7 +89,7 @@ MmpAccessFault(KPROCESSOR_MODE Mode, if (!FromMdl) MmLockAddressSpace(AddressSpace); break; - +#endif default: Status = STATUS_ACCESS_VIOLATION; break; @@ -171,7 +171,7 @@ MmNotPresentFault(KPROCESSOR_MODE Mode, (PVOID)Address, FromMdl); break; - +#ifdef NEWCC case MEMORY_AREA_CACHE: // This code locks for itself to keep from having to break a lock // passed in. @@ -181,7 +181,7 @@ MmNotPresentFault(KPROCESSOR_MODE Mode, if (!FromMdl) MmLockAddressSpace(AddressSpace); break; - +#endif default: Status = STATUS_ACCESS_VIOLATION; break; diff --git a/ntoskrnl/mm/mminit.c b/ntoskrnl/mm/mminit.c index 422ba568bb9..6c1a5f274d6 100644 --- a/ntoskrnl/mm/mminit.c +++ b/ntoskrnl/mm/mminit.c @@ -214,12 +214,17 @@ MmInitSystem(IN ULONG Phase, /* Initialize the kernel address space */ ASSERT(Phase == 1); +#ifdef NEWCC InitializeListHead(&MiSegmentList); ExInitializeFastMutex(&MiGlobalPageOperation); KeInitializeEvent(&MmWaitPageEvent, SynchronizationEvent, FALSE); // Until we're fully demand paged, we can do things the old way through // the balance manager + // CcInitView will override this... MmInitializeMemoryConsumer(MC_CACHE, MiRosTrimCache); +#else + KeInitializeEvent(&MmWaitPageEvent, SynchronizationEvent, FALSE); +#endif MmKernelAddressSpace = &PsIdleProcess->Vm; diff --git a/ntoskrnl/mm/rmap.c b/ntoskrnl/mm/rmap.c index aa6a7b0d6f2..9fea631dd09 100644 --- a/ntoskrnl/mm/rmap.c +++ b/ntoskrnl/mm/rmap.c @@ -167,12 +167,14 @@ MmPageOutPhysicalAddress(PFN_NUMBER Page) */ Status = MmPageOutSectionView(AddressSpace, MemoryArea, Address, Entry); } +#ifdef NEWCC else if (Type == MEMORY_AREA_CACHE) { /* NEWCC does locking itself */ MmUnlockAddressSpace(AddressSpace); Status = MmpPageOutPhysicalAddress(Page); } +#endif else { KeBugCheck(MEMORY_MANAGEMENT); diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index fbf44868d90..32ee1f48786 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -60,6 +60,29 @@ extern MMSESSION MmSession; +#ifndef NEWCC +KEVENT MmWaitPageEvent; + +VOID +NTAPI +_MmLockSectionSegment(PMM_SECTION_SEGMENT Segment, const char *file, int line) +{ + //DPRINT("MmLockSectionSegment(%p,%s:%d)\n", Segment, file, line); + ExAcquireFastMutex(&Segment->Lock); + Segment->Locked = TRUE; +} + +VOID +NTAPI +_MmUnlockSectionSegment(PMM_SECTION_SEGMENT Segment, const char *file, int line) +{ + ASSERT(Segment->Locked); + Segment->Locked = FALSE; + ExReleaseFastMutex(&Segment->Lock); + //DPRINT("MmUnlockSectionSegment(%p,%s:%d)\n", Segment, file, line); +} +#endif + NTSTATUS NTAPI MiMapViewInSystemSpace(IN PVOID Section, @@ -4067,9 +4090,13 @@ MiRosUnmapViewOfSection(IN PEPROCESS Process, MemoryArea = MmLocateMemoryAreaByAddress(AddressSpace, BaseAddress); if (MemoryArea == NULL || - ((MemoryArea->Type != MEMORY_AREA_SECTION_VIEW) && - (MemoryArea->Type != MEMORY_AREA_CACHE)) || +#ifdef NEWCC + ((MemoryArea->Type != MEMORY_AREA_SECTION_VIEW) && (MemoryArea->Type != MEMORY_AREA_CACHE)) || +#else + (MemoryArea->Type != MEMORY_AREA_SECTION_VIEW) || +#endif MemoryArea->DeleteInProgress) + { if (MemoryArea) ASSERT(MemoryArea->Type != MEMORY_AREA_OWNED_BY_ARM3); MmUnlockAddressSpace(AddressSpace); diff --git a/ntoskrnl/ntos.cmake b/ntoskrnl/ntos.cmake index 79317e880db..2a098336288 100644 --- a/ntoskrnl/ntos.cmake +++ b/ntoskrnl/ntos.cmake @@ -28,7 +28,11 @@ if(NEWCC) ${REACTOS_SOURCE_DIR}/ntoskrnl/cache/lazyrite.c ${REACTOS_SOURCE_DIR}/ntoskrnl/cache/logsup.c ${REACTOS_SOURCE_DIR}/ntoskrnl/cache/mdlsup.c - ${REACTOS_SOURCE_DIR}/ntoskrnl/cache/pinsup.c) + ${REACTOS_SOURCE_DIR}/ntoskrnl/cache/pinsup.c + ${REACTOS_SOURCE_DIR}/ntoskrnl/cache/section/fault.c + ${REACTOS_SOURCE_DIR}/ntoskrnl/cache/section/swapout.c + ${REACTOS_SOURCE_DIR}/ntoskrnl/cache/section/data.c + ${REACTOS_SOURCE_DIR}/ntoskrnl/cache/section/reqtools.c) else() list(APPEND SOURCE ${REACTOS_SOURCE_DIR}/ntoskrnl/cc/cacheman.c @@ -42,11 +46,7 @@ endif() list(APPEND SOURCE ${REACTOS_SOURCE_DIR}/ntoskrnl/cache/section/io.c - ${REACTOS_SOURCE_DIR}/ntoskrnl/cache/section/data.c - ${REACTOS_SOURCE_DIR}/ntoskrnl/cache/section/fault.c - ${REACTOS_SOURCE_DIR}/ntoskrnl/cache/section/reqtools.c ${REACTOS_SOURCE_DIR}/ntoskrnl/cache/section/sptab.c - ${REACTOS_SOURCE_DIR}/ntoskrnl/cache/section/swapout.c ${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmalloc.c ${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmapi.c ${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmboot.c
3 years, 10 months
1
0
0
0
[reactos] 08/100: [NTOSKRNL] Embed a SECTION struct inside MM_ROS_SECTION_OBJECT
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=25722e647e0f105d77ee2…
commit 25722e647e0f105d77ee28fa6d12999afe21cab8 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Fri Oct 23 14:42:21 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:21 2021 +0100 [NTOSKRNL] Embed a SECTION struct inside MM_ROS_SECTION_OBJECT --- ntoskrnl/include/internal/mm.h | 17 +++------------- ntoskrnl/mm/ARM3/miarm.h | 3 +-- ntoskrnl/mm/section.c | 45 +++++++++++++++++++++++++----------------- 3 files changed, 31 insertions(+), 34 deletions(-) diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h index 5700ad8ff65..c118866d5b5 100644 --- a/ntoskrnl/include/internal/mm.h +++ b/ntoskrnl/include/internal/mm.h @@ -196,21 +196,10 @@ typedef struct _MM_IMAGE_SECTION_OBJECT typedef struct _ROS_SECTION_OBJECT { - CSHORT Type; - CSHORT Size; - LARGE_INTEGER SizeOfSection; - ULONG InitialPageProtection; - union - { - ULONG LongFlags; - MMSECTION_FLAGS Flags; - } u; + SECTION; PFILE_OBJECT FileObject; - union - { - PMM_IMAGE_SECTION_OBJECT ImageSection; - PMM_SECTION_SEGMENT Segment; - }; + + PMM_IMAGE_SECTION_OBJECT ImageSection; } ROS_SECTION_OBJECT, *PROS_SECTION_OBJECT; #define MA_GetStartingAddress(_MemoryArea) ((_MemoryArea)->VadNode.StartingVpn << PAGE_SHIFT) diff --git a/ntoskrnl/mm/ARM3/miarm.h b/ntoskrnl/mm/ARM3/miarm.h index b374e94ad75..ade2696cf1d 100644 --- a/ntoskrnl/mm/ARM3/miarm.h +++ b/ntoskrnl/mm/ARM3/miarm.h @@ -1072,8 +1072,7 @@ BOOLEAN MiIsRosSectionObject(IN PVOID Section) { PROS_SECTION_OBJECT RosSection = Section; - if ((RosSection->Type == 'SC') && (RosSection->Size == 'TN')) return TRUE; - return FALSE; + return RosSection->u.Flags.filler; } #define MI_IS_ROS_PFN(x) ((x)->u4.AweAllocation == TRUE) diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index 9920f36ddcf..fbf44868d90 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -2684,7 +2684,7 @@ MmpDeleteSection(PVOID ObjectBody) if (Section->Segment == NULL) return; - (void)InterlockedDecrementUL(&Section->Segment->ReferenceCount); + (void)InterlockedDecrementUL(&((PMM_SECTION_SEGMENT)Section->Segment)->ReferenceCount); } if (Section->FileObject != NULL) { @@ -2750,8 +2750,9 @@ MmCreatePhysicalMemorySection(VOID) * Initialize it */ RtlZeroMemory(PhysSection, sizeof(ROS_SECTION_OBJECT)); - PhysSection->Type = 'SC'; - PhysSection->Size = 'TN'; + + /* Mark this as a "ROS Section" */ + PhysSection->u.Flags.filler = 1; PhysSection->InitialPageProtection = PAGE_EXECUTE_READWRITE; PhysSection->u.Flags.PhysicalMemory = 1; PhysSection->SizeOfSection = SectionSize; @@ -2763,7 +2764,7 @@ MmCreatePhysicalMemorySection(VOID) return(STATUS_NO_MEMORY); } RtlZeroMemory(Segment, sizeof(MM_SECTION_SEGMENT)); - PhysSection->Segment = Segment; + PhysSection->Segment = (PSEGMENT)Segment; Segment->ReferenceCount = 1; ExInitializeFastMutex(&Segment->Lock); Segment->Image.FileOffset = 0; @@ -2865,8 +2866,9 @@ MmCreateDataFileSection(PROS_SECTION_OBJECT *SectionObject, * Initialize it */ RtlZeroMemory(Section, sizeof(ROS_SECTION_OBJECT)); - Section->Type = 'SC'; - Section->Size = 'TN'; + + /* Mark this as a "ROS" section */ + Section->u.Flags.filler = 1; Section->InitialPageProtection = SectionPageProtection; Section->u.Flags.File = 1; if (AllocationAttributes & SEC_NO_CHANGE) @@ -2958,7 +2960,7 @@ MmCreateDataFileSection(PROS_SECTION_OBJECT *SectionObject, ObDereferenceObject(FileObject); return(STATUS_NO_MEMORY); } - Section->Segment = Segment; + Section->Segment = (PSEGMENT)Segment; Segment->ReferenceCount = 1; ExInitializeFastMutex(&Segment->Lock); /* @@ -2994,7 +2996,7 @@ MmCreateDataFileSection(PROS_SECTION_OBJECT *SectionObject, Segment = (PMM_SECTION_SEGMENT)FileObject->SectionObjectPointer-> DataSectionObject; - Section->Segment = Segment; + Section->Segment = (PSEGMENT)Segment; (void)InterlockedIncrementUL(&Segment->ReferenceCount); MmLockSectionSegment(Segment); @@ -3692,8 +3694,10 @@ MmCreateImageSection(PROS_SECTION_OBJECT *SectionObject, * Initialize it */ RtlZeroMemory(Section, sizeof(ROS_SECTION_OBJECT)); - Section->Type = 'SC'; - Section->Size = 'TN'; + + /* Mark this as a "ROS" Section */ + Section->u.Flags.filler = 1; + Section->InitialPageProtection = SectionPageProtection; Section->u.Flags.File = 1; Section->u.Flags.Image = 1; @@ -4256,8 +4260,8 @@ NtQuerySection( } else { - Sbi->BaseAddress = (PVOID)RosSection->Segment->Image.VirtualAddress; - Sbi->Size.QuadPart = RosSection->Segment->Length.QuadPart; + Sbi->BaseAddress = (PVOID)((PMM_SECTION_SEGMENT)RosSection->Segment)->Image.VirtualAddress; + Sbi->Size.QuadPart = ((PMM_SECTION_SEGMENT)RosSection->Segment)->Length.QuadPart; } if (ResultLength != NULL) @@ -4557,6 +4561,8 @@ MmMapViewOfSection(IN PVOID SectionObject, } else { + PMM_SECTION_SEGMENT Segment = (PMM_SECTION_SEGMENT)Section->Segment; + /* check for write access */ if ((Protect & (PAGE_READWRITE|PAGE_EXECUTE_READWRITE)) && !(Section->InitialPageProtection & (PAGE_READWRITE|PAGE_EXECUTE_READWRITE))) @@ -4605,16 +4611,16 @@ MmMapViewOfSection(IN PVOID SectionObject, *ViewSize = PAGE_ROUND_UP(*ViewSize); - MmLockSectionSegment(Section->Segment); + MmLockSectionSegment(Segment); Status = MmMapViewOfSegment(AddressSpace, Section, - Section->Segment, + Segment, BaseAddress, *ViewSize, Protect, ViewOffset, AllocationType & (MEM_TOP_DOWN|SEC_NO_CHANGE)); - MmUnlockSectionSegment(Section->Segment); + MmUnlockSectionSegment(Segment); if (!NT_SUCCESS(Status)) { MmUnlockAddressSpace(AddressSpace); @@ -4765,6 +4771,7 @@ MmMapViewInSystemSpace (IN PVOID SectionObject, IN OUT PSIZE_T ViewSize) { PROS_SECTION_OBJECT Section; + PMM_SECTION_SEGMENT Segment; PMMSUPPORT AddressSpace; NTSTATUS Status; PAGED_CODE(); @@ -4780,6 +4787,8 @@ MmMapViewInSystemSpace (IN PVOID SectionObject, DPRINT("MmMapViewInSystemSpace() called\n"); Section = (PROS_SECTION_OBJECT)SectionObject; + Segment = (PMM_SECTION_SEGMENT)Section->Segment; + AddressSpace = MmGetKernelAddressSpace(); MmLockAddressSpace(AddressSpace); @@ -4794,19 +4803,19 @@ MmMapViewInSystemSpace (IN PVOID SectionObject, (*ViewSize) = Section->SizeOfSection.u.LowPart; } - MmLockSectionSegment(Section->Segment); + MmLockSectionSegment(Segment); Status = MmMapViewOfSegment(AddressSpace, Section, - Section->Segment, + Segment, MappedBase, *ViewSize, PAGE_READWRITE, 0, 0); - MmUnlockSectionSegment(Section->Segment); + MmUnlockSectionSegment(Segment); MmUnlockAddressSpace(AddressSpace); return Status;
3 years, 10 months
1
0
0
0
← Newer
1
...
37
38
39
40
41
42
43
44
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Results per page:
10
25
50
100
200