Skip to content

Commit 4d605ec

Browse files
authored
[NTOS:MM:PS] Little fixes for NTDLL loading (reactos#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`.
1 parent 7c23a2e commit 4d605ec

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

ntoskrnl/include/internal/mm.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,9 +1652,7 @@ MmUnloadSystemImage(
16521652
NTSTATUS
16531653
NTAPI
16541654
MmCheckSystemImage(
1655-
IN HANDLE ImageHandle,
1656-
IN BOOLEAN PurgeSection
1657-
);
1655+
_In_ HANDLE ImageHandle);
16581656

16591657
NTSTATUS
16601658
NTAPI

ntoskrnl/mm/ARM3/sysldr.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2751,8 +2751,8 @@ MmVerifyImageIsOkForMpUse(
27512751

27522752
NTSTATUS
27532753
NTAPI
2754-
MmCheckSystemImage(IN HANDLE ImageHandle,
2755-
IN BOOLEAN PurgeSection)
2754+
MmCheckSystemImage(
2755+
_In_ HANDLE ImageHandle)
27562756
{
27572757
NTSTATUS Status;
27582758
HANDLE SectionHandle;
@@ -2846,12 +2846,14 @@ MmCheckSystemImage(IN HANDLE ImageHandle,
28462846
goto Fail;
28472847
}
28482848

2849-
/* Check that it's a valid SMP image if we have more then one CPU */
2850-
if (!MmVerifyImageIsOkForMpUse(ViewBase))
2849+
#ifdef CONFIG_SMP
2850+
/* Check that it's a valid SMP image if we have more than one CPU */
2851+
if (!MiVerifyImageIsOkForMpUse(NtHeaders))
28512852
{
28522853
/* Otherwise it's not the right image */
28532854
Status = STATUS_IMAGE_MP_UP_MISMATCH;
28542855
}
2856+
#endif // CONFIG_SMP
28552857
}
28562858

28572859
/* Unmap the section, close the handle, and return status */
@@ -3180,7 +3182,7 @@ MmLoadSystemImage(IN PUNICODE_STRING FileName,
31803182
}
31813183

31823184
/* Validate it */
3183-
Status = MmCheckSystemImage(FileHandle, FALSE);
3185+
Status = MmCheckSystemImage(FileHandle);
31843186
if ((Status == STATUS_IMAGE_CHECKSUM_MISMATCH) ||
31853187
(Status == STATUS_IMAGE_MP_UP_MISMATCH) ||
31863188
(Status == STATUS_INVALID_IMAGE_PROTECT))

ntoskrnl/ps/psmgr.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ PsLocateSystemDll(VOID)
196196
/* Locate and open NTDLL to determine ImageBase and LdrStartup */
197197
InitializeObjectAttributes(&ObjectAttributes,
198198
&PsNtDllPathName,
199-
0,
199+
OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
200200
NULL,
201201
NULL);
202202
Status = ZwOpenFile(&FileHandle,
@@ -212,8 +212,8 @@ PsLocateSystemDll(VOID)
212212
}
213213

214214
/* Check if the image is valid */
215-
Status = MmCheckSystemImage(FileHandle, TRUE);
216-
if (Status == STATUS_IMAGE_CHECKSUM_MISMATCH)
215+
Status = MmCheckSystemImage(FileHandle);
216+
if (Status == STATUS_IMAGE_CHECKSUM_MISMATCH || Status == STATUS_INVALID_IMAGE_PROTECT)
217217
{
218218
/* Raise a hard error */
219219
HardErrorParameters = (ULONG_PTR)&PsNtDllPathName;

0 commit comments

Comments
 (0)