mirror of
https://github.com/reactos/reactos.git
synced 2025-04-20 12:29:56 +00:00
[NTOSKRNL/MM] Reduce use of MiIsRosSectionObject
This commit is contained in:
parent
b7d988ae5b
commit
4abda863ce
2 changed files with 67 additions and 101 deletions
|
@ -3716,7 +3716,7 @@ NtMapViewOfSection(IN HANDLE SectionHandle,
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MiIsRosSectionObject(Section) && Section->u.Flags.PhysicalMemory)
|
if (Section->u.Flags.PhysicalMemory)
|
||||||
{
|
{
|
||||||
if (PreviousMode == UserMode &&
|
if (PreviousMode == UserMode &&
|
||||||
SafeSectionOffset.QuadPart + SafeViewSize > MmHighestPhysicalPage << PAGE_SHIFT)
|
SafeSectionOffset.QuadPart + SafeViewSize > MmHighestPhysicalPage << PAGE_SHIFT)
|
||||||
|
@ -3764,8 +3764,7 @@ NtMapViewOfSection(IN HANDLE SectionHandle,
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
/* Check if this is an image for the current process */
|
/* Check if this is an image for the current process */
|
||||||
if (MiIsRosSectionObject(Section) &&
|
if ((Section->u.Flags.Image) &&
|
||||||
(Section->u.Flags.Image) &&
|
|
||||||
(Process == PsGetCurrentProcess()) &&
|
(Process == PsGetCurrentProcess()) &&
|
||||||
(Status != STATUS_IMAGE_NOT_AT_BASE))
|
(Status != STATUS_IMAGE_NOT_AT_BASE))
|
||||||
{
|
{
|
||||||
|
|
|
@ -4279,131 +4279,98 @@ NtQuerySection(
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MiIsRosSectionObject(Section))
|
switch(SectionInformationClass)
|
||||||
{
|
{
|
||||||
switch (SectionInformationClass)
|
case SectionBasicInformation:
|
||||||
{
|
{
|
||||||
case SectionBasicInformation:
|
SECTION_BASIC_INFORMATION Sbi;
|
||||||
|
|
||||||
|
Sbi.Size = Section->SizeOfSection;
|
||||||
|
Sbi.BaseAddress = (PVOID)Section->Address.StartingVpn;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
/* FIXME : Complete/test the list of flags passed back from NtCreateSection */
|
||||||
|
|
||||||
|
if (Section->u.Flags.Image)
|
||||||
{
|
{
|
||||||
PSECTION_BASIC_INFORMATION Sbi = (PSECTION_BASIC_INFORMATION)SectionInformation;
|
Sbi.BaseAddress = 0;
|
||||||
|
Sbi.Size.QuadPart = 0;
|
||||||
_SEH2_TRY
|
}
|
||||||
{
|
else if (MiIsRosSectionObject(Section))
|
||||||
Sbi->Attributes = 0;
|
{
|
||||||
if (Section->u.Flags.Image)
|
Sbi.BaseAddress = (PVOID)((PMM_SECTION_SEGMENT)Section->Segment)->Image.VirtualAddress;
|
||||||
Sbi->Attributes |= SEC_IMAGE;
|
Sbi.Size.QuadPart = ((PMM_SECTION_SEGMENT)Section->Segment)->Length.QuadPart;
|
||||||
if (Section->u.Flags.File)
|
}
|
||||||
Sbi->Attributes |= SEC_FILE;
|
else
|
||||||
if (Section->u.Flags.NoChange)
|
{
|
||||||
Sbi->Attributes |= SEC_NO_CHANGE;
|
DPRINT1("Unimplemented code path!");
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ResultLength != NULL)
|
|
||||||
{
|
|
||||||
*ResultLength = sizeof(SECTION_BASIC_INFORMATION);
|
|
||||||
}
|
|
||||||
Status = STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
||||||
{
|
|
||||||
Status = _SEH2_GetExceptionCode();
|
|
||||||
}
|
|
||||||
_SEH2_END;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case SectionImageInformation:
|
_SEH2_TRY
|
||||||
{
|
{
|
||||||
PSECTION_IMAGE_INFORMATION Sii = (PSECTION_IMAGE_INFORMATION)SectionInformation;
|
*((SECTION_BASIC_INFORMATION*)SectionInformation) = Sbi;
|
||||||
|
if (ResultLength)
|
||||||
_SEH2_TRY
|
*ResultLength = sizeof(Sbi);
|
||||||
{
|
|
||||||
if (Section->u.Flags.Image)
|
|
||||||
{
|
|
||||||
PMM_IMAGE_SECTION_OBJECT ImageSectionObject = ((PMM_IMAGE_SECTION_OBJECT)Section->Segment);
|
|
||||||
|
|
||||||
*Sii = ImageSectionObject->ImageInformation;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ResultLength != NULL)
|
|
||||||
{
|
|
||||||
*ResultLength = sizeof(SECTION_IMAGE_INFORMATION);
|
|
||||||
}
|
|
||||||
Status = STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
||||||
{
|
|
||||||
Status = _SEH2_GetExceptionCode();
|
|
||||||
}
|
|
||||||
_SEH2_END;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
{
|
||||||
|
Status = _SEH2_GetExceptionCode();
|
||||||
|
}
|
||||||
|
_SEH2_END;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
case SectionImageInformation:
|
||||||
else
|
|
||||||
{
|
|
||||||
switch(SectionInformationClass)
|
|
||||||
{
|
{
|
||||||
case SectionBasicInformation:
|
if (!Section->u.Flags.Image)
|
||||||
{
|
{
|
||||||
SECTION_BASIC_INFORMATION Sbi;
|
Status = STATUS_SECTION_NOT_IMAGE;
|
||||||
|
}
|
||||||
Sbi.Size = Section->SizeOfSection;
|
else if (MiIsRosSectionObject(Section))
|
||||||
Sbi.BaseAddress = (PVOID)Section->Address.StartingVpn;
|
{
|
||||||
|
PMM_IMAGE_SECTION_OBJECT ImageSectionObject = ((PMM_IMAGE_SECTION_OBJECT)Section->Segment);
|
||||||
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
|
_SEH2_TRY
|
||||||
{
|
{
|
||||||
*((SECTION_BASIC_INFORMATION*)SectionInformation) = Sbi;
|
PSECTION_IMAGE_INFORMATION Sii = (PSECTION_IMAGE_INFORMATION)SectionInformation;
|
||||||
if (ResultLength)
|
*Sii = ImageSectionObject->ImageInformation;
|
||||||
*ResultLength = sizeof(Sbi);
|
if (ResultLength != NULL)
|
||||||
|
*ResultLength = sizeof(*Sii);
|
||||||
}
|
}
|
||||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||||
{
|
{
|
||||||
Status = _SEH2_GetExceptionCode();
|
Status = _SEH2_GetExceptionCode();
|
||||||
}
|
}
|
||||||
_SEH2_END;
|
_SEH2_END;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case SectionImageInformation:
|
else
|
||||||
{
|
{
|
||||||
if (!Section->u.Flags.Image)
|
_SEH2_TRY
|
||||||
{
|
{
|
||||||
Status = STATUS_SECTION_NOT_IMAGE;
|
PSECTION_IMAGE_INFORMATION Sii = (PSECTION_IMAGE_INFORMATION)SectionInformation;
|
||||||
|
*Sii = *Section->Segment->u2.ImageInformation;
|
||||||
|
if (ResultLength != NULL)
|
||||||
|
*ResultLength = sizeof(*Sii);
|
||||||
}
|
}
|
||||||
else
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||||
{
|
{
|
||||||
/* Currently not supported */
|
Status = _SEH2_GetExceptionCode();
|
||||||
ASSERT(FALSE);
|
|
||||||
}
|
}
|
||||||
break;
|
_SEH2_END;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
DPRINT1("Unknown SectionInformationClass: %d\n", SectionInformationClass);
|
||||||
|
Status = STATUS_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObDereferenceObject(Section);
|
ObDereferenceObject(Section);
|
||||||
|
|
Loading…
Reference in a new issue