mirror of
https://github.com/reactos/reactos.git
synced 2025-01-04 21:38:43 +00:00
[NTDLL]
Raise harderror and terminate process when the image is of a foreign architecture. svn path=/trunk/; revision=50099
This commit is contained in:
parent
b1730a09db
commit
7f1fb18031
1 changed files with 11 additions and 3 deletions
|
@ -330,6 +330,7 @@ LdrpInit2(PCONTEXT Context,
|
|||
SYSTEM_BASIC_INFORMATION SystemInformation;
|
||||
NTSTATUS Status;
|
||||
PVOID BaseAddress = SystemArgument1;
|
||||
ULONG ErrorResponse;
|
||||
|
||||
DPRINT("LdrpInit()\n");
|
||||
DPRINT("Peb %p\n", Peb);
|
||||
|
@ -344,16 +345,25 @@ LdrpInit2(PCONTEXT Context,
|
|||
|
||||
/* If MZ header exists */
|
||||
PEDosHeader = (PIMAGE_DOS_HEADER) ImageBase;
|
||||
NTHeaders = (PIMAGE_NT_HEADERS)((ULONG_PTR)ImageBase + PEDosHeader->e_lfanew);
|
||||
DPRINT("PEDosHeader %p\n", PEDosHeader);
|
||||
|
||||
if (PEDosHeader->e_magic != IMAGE_DOS_SIGNATURE ||
|
||||
PEDosHeader->e_lfanew == 0L ||
|
||||
*(PULONG)((PUCHAR)ImageBase + PEDosHeader->e_lfanew) != IMAGE_NT_SIGNATURE)
|
||||
NTHeaders->Signature != IMAGE_NT_SIGNATURE)
|
||||
{
|
||||
DPRINT1("Image has bad header\n");
|
||||
ZwTerminateProcess(NtCurrentProcess(), STATUS_INVALID_IMAGE_FORMAT);
|
||||
}
|
||||
|
||||
if (NTHeaders->FileHeader.Machine != IMAGE_FILE_MACHINE_NATIVE)
|
||||
{
|
||||
DPRINT1("Image is for a foreign architecture (0x%x).\n",
|
||||
NTHeaders->FileHeader.Machine);
|
||||
NtRaiseHardError(STATUS_IMAGE_MACHINE_TYPE_MISMATCH, 0, 0, NULL, OptionOk, &ErrorResponse);
|
||||
ZwTerminateProcess(NtCurrentProcess(), STATUS_IMAGE_MACHINE_TYPE_MISMATCH);
|
||||
}
|
||||
|
||||
/* normalize process parameters */
|
||||
RtlNormalizeProcessParams(Peb->ProcessParameters);
|
||||
|
||||
|
@ -364,8 +374,6 @@ LdrpInit2(PCONTEXT Context,
|
|||
&NlsTable);
|
||||
RtlResetRtlTranslations(&NlsTable);
|
||||
|
||||
NTHeaders = (PIMAGE_NT_HEADERS)((ULONG_PTR)ImageBase + PEDosHeader->e_lfanew);
|
||||
|
||||
/* Get number of processors */
|
||||
DPRINT("Here\n");
|
||||
Status = ZwQuerySystemInformation(SystemBasicInformation,
|
||||
|
|
Loading…
Reference in a new issue