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);