Skip to content

Commit 7c23a2e

Browse files
committed
[NTOS:MM] Split MmVerifyImageIsOkForMpUse() into an auxiliary inlined helper.
This helper is used when an existing NtHeader is already available.
1 parent ccf1e97 commit 7c23a2e

File tree

1 file changed

+26
-17
lines changed

1 file changed

+26
-17
lines changed

ntoskrnl/mm/ARM3/sysldr.c

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2716,30 +2716,39 @@ MiEnablePagingOfDriver(IN PLDR_DATA_TABLE_ENTRY LdrEntry)
27162716
if (PointerPte) MiSetPagingOfDriver(PointerPte, LastPte);
27172717
}
27182718

2719+
FORCEINLINE
27192720
BOOLEAN
2720-
NTAPI
2721-
MmVerifyImageIsOkForMpUse(IN PVOID BaseAddress)
2721+
MiVerifyImageIsOkForMpUse(
2722+
_In_ PIMAGE_NT_HEADERS NtHeaders)
27222723
{
2723-
PIMAGE_NT_HEADERS NtHeader;
2724-
PAGED_CODE();
2725-
2726-
/* Get NT Headers */
2727-
NtHeader = RtlImageNtHeader(BaseAddress);
2728-
if (NtHeader)
2724+
/* Fail if we have 2+ CPUs, but the image is only safe for UP */
2725+
if ((KeNumberProcessors > 1) &&
2726+
(NtHeaders->FileHeader.Characteristics & IMAGE_FILE_UP_SYSTEM_ONLY))
27292727
{
2730-
/* Check if this image is only safe for UP while we have 2+ CPUs */
2731-
if ((KeNumberProcessors > 1) &&
2732-
(NtHeader->FileHeader.Characteristics & IMAGE_FILE_UP_SYSTEM_ONLY))
2733-
{
2734-
/* Fail */
2735-
return FALSE;
2736-
}
2728+
return FALSE;
27372729
}
2738-
2739-
/* Otherwise, it's safe */
2730+
/* Otherwise, it's safe to use */
27402731
return TRUE;
27412732
}
27422733

2734+
// TODO: Use this function to verify that the loaded boot drivers
2735+
// (in ExpLoadBootSymbols) are compatible with MP.
2736+
BOOLEAN
2737+
NTAPI
2738+
MmVerifyImageIsOkForMpUse(
2739+
_In_ PVOID BaseAddress)
2740+
{
2741+
PIMAGE_NT_HEADERS NtHeaders;
2742+
PAGED_CODE();
2743+
2744+
/* Get the NT headers. If none, suppose the image
2745+
* is safe to use, otherwise invoke the helper. */
2746+
NtHeaders = RtlImageNtHeader(BaseAddress);
2747+
if (!NtHeaders)
2748+
return TRUE;
2749+
return MiVerifyImageIsOkForMpUse(NtHeaders);
2750+
}
2751+
27432752
NTSTATUS
27442753
NTAPI
27452754
MmCheckSystemImage(IN HANDLE ImageHandle,

0 commit comments

Comments
 (0)