[NTOSKRNL] Use PSECTION struct where possible

This commit is contained in:
Jérôme Gardou 2020-10-23 16:39:15 +02:00
parent 462d9a0974
commit defbf63416
4 changed files with 9 additions and 20 deletions

View file

@ -221,7 +221,7 @@ typedef struct _MEMORY_AREA
{ {
struct struct
{ {
ROS_SECTION_OBJECT* Section; PROS_SECTION_OBJECT Section;
LARGE_INTEGER ViewOffset; LARGE_INTEGER ViewOffset;
PMM_SECTION_SEGMENT Segment; PMM_SECTION_SEGMENT Segment;
LIST_ENTRY RegionListHead; LIST_ENTRY RegionListHead;

View file

@ -1071,7 +1071,7 @@ FORCEINLINE
BOOLEAN BOOLEAN
MiIsRosSectionObject(IN PVOID Section) MiIsRosSectionObject(IN PVOID Section)
{ {
PROS_SECTION_OBJECT RosSection = Section; PSECTION RosSection = Section;
return RosSection->u.Flags.filler; return RosSection->u.Flags.filler;
} }

View file

@ -941,7 +941,6 @@ MmInitializeProcessAddressSpace(IN PEPROCESS Process,
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
SIZE_T ViewSize = 0; SIZE_T ViewSize = 0;
PVOID ImageBase = 0; PVOID ImageBase = 0;
PROS_SECTION_OBJECT SectionObject = Section;
PMMPTE PointerPte; PMMPTE PointerPte;
KIRQL OldIrql; KIRQL OldIrql;
PMMPDE PointerPde; PMMPDE PointerPde;
@ -1048,10 +1047,11 @@ MmInitializeProcessAddressSpace(IN PEPROCESS Process,
#endif #endif
/* Check if there's a Section Object */ /* Check if there's a Section Object */
if (SectionObject) if (Section)
{ {
/* Determine the image file name and save it to EPROCESS */ /* 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); Source = (PWCHAR)((PCHAR)FileName.Buffer + FileName.Length);
if (FileName.Buffer) if (FileName.Buffer)
{ {
@ -1083,9 +1083,7 @@ MmInitializeProcessAddressSpace(IN PEPROCESS Process,
if (AuditName) if (AuditName)
{ {
/* Setup the audit name */ /* Setup the audit name */
Status = SeInitializeProcessAuditName(SectionObject->FileObject, Status = SeInitializeProcessAuditName(FileObject, FALSE, AuditName);
FALSE,
AuditName);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
/* Fail */ /* Fail */

View file

@ -1831,19 +1831,10 @@ MmGetFileNameForSection(IN PVOID Section,
OUT POBJECT_NAME_INFORMATION *ModuleName) OUT POBJECT_NAME_INFORMATION *ModuleName)
{ {
PFILE_OBJECT FileObject; PFILE_OBJECT FileObject;
PSECTION SectionObject = Section;
/* Make sure it's an image section */ /* Make sure it's an image section */
if (MiIsRosSectionObject(Section) == FALSE) if (SectionObject->u.Flags.Image == 0)
{
/* 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))
{ {
/* It's not, fail */ /* It's not, fail */
DPRINT1("Not an image section\n"); DPRINT1("Not an image section\n");
@ -3594,7 +3585,7 @@ NtMapViewOfSection(IN HANDLE SectionHandle,
PVOID SafeBaseAddress; PVOID SafeBaseAddress;
LARGE_INTEGER SafeSectionOffset; LARGE_INTEGER SafeSectionOffset;
SIZE_T SafeViewSize; SIZE_T SafeViewSize;
PROS_SECTION_OBJECT Section; PSECTION Section;
PEPROCESS Process; PEPROCESS Process;
NTSTATUS Status; NTSTATUS Status;
ACCESS_MASK DesiredAccess; ACCESS_MASK DesiredAccess;