https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4d605ec26f7516cb7368b83a7aeb7df5ce785cd1
commit 4d605ec26f7516cb7368b83a7aeb7df5ce785cd1 Author: Ratin Gao <ra...@knsoft.org> AuthorDate: Tue Mar 4 03:36:21 2025 +0800 Commit: GitHub <nore...@github.com> CommitDate: Mon Mar 3 20:36:21 2025 +0100 [NTOS:MM:PS] Little fixes for NTDLL loading (#7707) - [NTOS:PS] `STATUS_INVALID_IMAGE_PROTECT` returned by `MmCheckSystemImage` should be a fatal error too. - [NTOS:PS] Fix object attributes for opening NTDLL. - [NTOS:MM] Remove `MmCheckSystemImage` unused parameter. - [NTOS:MM] Inline `MmVerifyImageIsOkForMpUse` in `MmCheckSystemImage`, reducing a call to `RtlImageNtHeader`. --- ntoskrnl/include/internal/mm.h | 4 +--- ntoskrnl/mm/ARM3/sysldr.c | 12 +++++++----- ntoskrnl/ps/psmgr.c | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h index 1c3870d6370..29e84072abf 100644 --- a/ntoskrnl/include/internal/mm.h +++ b/ntoskrnl/include/internal/mm.h @@ -1652,9 +1652,7 @@ MmUnloadSystemImage( NTSTATUS NTAPI MmCheckSystemImage( - IN HANDLE ImageHandle, - IN BOOLEAN PurgeSection -); + _In_ HANDLE ImageHandle); NTSTATUS NTAPI diff --git a/ntoskrnl/mm/ARM3/sysldr.c b/ntoskrnl/mm/ARM3/sysldr.c index eb1544babbf..eaa1a7f76d4 100644 --- a/ntoskrnl/mm/ARM3/sysldr.c +++ b/ntoskrnl/mm/ARM3/sysldr.c @@ -2751,8 +2751,8 @@ MmVerifyImageIsOkForMpUse( NTSTATUS NTAPI -MmCheckSystemImage(IN HANDLE ImageHandle, - IN BOOLEAN PurgeSection) +MmCheckSystemImage( + _In_ HANDLE ImageHandle) { NTSTATUS Status; HANDLE SectionHandle; @@ -2846,12 +2846,14 @@ MmCheckSystemImage(IN HANDLE ImageHandle, goto Fail; } - /* Check that it's a valid SMP image if we have more then one CPU */ - if (!MmVerifyImageIsOkForMpUse(ViewBase)) +#ifdef CONFIG_SMP + /* Check that it's a valid SMP image if we have more than one CPU */ + if (!MiVerifyImageIsOkForMpUse(NtHeaders)) { /* Otherwise it's not the right image */ Status = STATUS_IMAGE_MP_UP_MISMATCH; } +#endif // CONFIG_SMP } /* Unmap the section, close the handle, and return status */ @@ -3180,7 +3182,7 @@ LoaderScan: } /* Validate it */ - Status = MmCheckSystemImage(FileHandle, FALSE); + Status = MmCheckSystemImage(FileHandle); if ((Status == STATUS_IMAGE_CHECKSUM_MISMATCH) || (Status == STATUS_IMAGE_MP_UP_MISMATCH) || (Status == STATUS_INVALID_IMAGE_PROTECT)) diff --git a/ntoskrnl/ps/psmgr.c b/ntoskrnl/ps/psmgr.c index bd642375a88..0d80257bd46 100644 --- a/ntoskrnl/ps/psmgr.c +++ b/ntoskrnl/ps/psmgr.c @@ -196,7 +196,7 @@ PsLocateSystemDll(VOID) /* Locate and open NTDLL to determine ImageBase and LdrStartup */ InitializeObjectAttributes(&ObjectAttributes, &PsNtDllPathName, - 0, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL); Status = ZwOpenFile(&FileHandle, @@ -212,8 +212,8 @@ PsLocateSystemDll(VOID) } /* Check if the image is valid */ - Status = MmCheckSystemImage(FileHandle, TRUE); - if (Status == STATUS_IMAGE_CHECKSUM_MISMATCH) + Status = MmCheckSystemImage(FileHandle); + if (Status == STATUS_IMAGE_CHECKSUM_MISMATCH || Status == STATUS_INVALID_IMAGE_PROTECT) { /* Raise a hard error */ HardErrorParameters = (ULONG_PTR)&PsNtDllPathName;