[FREELDR] Set LDRP_IMAGE_INTEGRITY_FORCED if necessary. (Part of PR #1905)

+ Add extra information.
Co-authored-by: Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
This commit is contained in:
Mark Harmstone 2019-10-09 21:28:33 +01:00 committed by Hermès Bélusca-Maïto
parent e83b256f65
commit 43a8d871bf
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
2 changed files with 25 additions and 0 deletions

View file

@ -658,6 +658,24 @@ PeLdrAllocateDataTableEntry(
DataTableEntry->Flags = LDRP_ENTRY_PROCESSED;
DataTableEntry->LoadCount = 1;
/* Honour the FORCE_INTEGRITY flag */
if (NtHeaders->OptionalHeader.DllCharacteristics & IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY)
{
/*
* On Vista and above, the LDRP_IMAGE_INTEGRITY_FORCED flag must be set
* if IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY is set in the image header.
* This is done after the image has been loaded and the digital signature
* check has passed successfully. (We do not do it yet!)
*
* Several OS functionality depend on the presence of this flag.
* For example, when using Object-Manager callbacks the latter will call
* MmVerifyCallbackFunction() to verify whether the flag is present.
* If not callbacks will not work.
* (See Windows Internals Part 1, 6th edition, p. 176.)
*/
DataTableEntry->Flags |= LDRP_IMAGE_INTEGRITY_FORCED;
}
/* Insert this DTE to a list in the LPB */
InsertTailList(ModuleListHead, &DataTableEntry->InLoadOrderLinks);
TRACE("Inserting DTE %p, name='%.*S' DllBase=%p \n", DataTableEntry,
@ -783,6 +801,12 @@ PeLdrLoadImage(
return FALSE;
}
/*
* On Vista and above, a digital signature check is performed when the image
* has the IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY flag set in its header.
* (We of course do not perform this check yet!)
*/
/* Reload the NT Header */
NtHeaders = RtlImageNtHeader(PhysicalBase);

View file

@ -38,6 +38,7 @@ Author:
#define LDRP_STATIC_LINK 0x00000002
#define LDRP_IMAGE_DLL 0x00000004
#define LDRP_SHIMENG_SUPPRESSED_ENTRY 0x00000008
#define LDRP_IMAGE_INTEGRITY_FORCED 0x00000020
#define LDRP_LOAD_IN_PROGRESS 0x00001000
#define LDRP_UNLOAD_IN_PROGRESS 0x00002000
#define LDRP_ENTRY_PROCESSED 0x00004000