[NTDLL:LDR] Fail if section creation fails in LdrpCreateDllSection. CORE-17284

Otherwise we'd call ZwQuerySection on an invalid handle and get:
(ntoskrnl/mm/section.c:4320) Failed to reference section: 0xc0000008

Also correctly check DllCharacteristics: If the argument is missing, the
file is _not_ a system file, i.e. we should check for restrictions.
This commit is contained in:
Thomas Faber 2020-09-27 16:41:34 +02:00
parent 2e1aeb12df
commit 1c404d838a
No known key found for this signature in database
GPG key ID: 076E7C3D44720826

View file

@ -641,10 +641,12 @@ LdrpCreateDllSection(IN PUNICODE_STRING FullName,
/* Increment the error count */
if (LdrpInLdrInit) LdrpFatalHardErrorCount++;
goto Exit;
}
/* Check for Safer restrictions */
if (DllCharacteristics &&
if (!DllCharacteristics ||
!(*DllCharacteristics & IMAGE_FILE_SYSTEM))
{
/* Make sure it's executable */
@ -683,6 +685,7 @@ LdrpCreateDllSection(IN PUNICODE_STRING FullName,
}
}
Exit:
/* Close the file handle, we don't need it */
NtClose(FileHandle);