mirror of
https://github.com/reactos/reactos.git
synced 2024-07-14 08:26:08 +00:00
fix a version info winetest by allowing non dll files to be loaded with LOAD_LIBRARY_AS_DATAFILE
svn path=/trunk/; revision=35976
This commit is contained in:
parent
b0a663b4a6
commit
b5c636ee01
|
@ -650,38 +650,43 @@ LdrpMapDllImageFile(IN PWSTR SearchPath OPTIONAL,
|
|||
0,
|
||||
FullNtFileName.Buffer);
|
||||
|
||||
Status = NtReadFile(FileHandle,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&IoStatusBlock,
|
||||
BlockBuffer,
|
||||
sizeof(BlockBuffer),
|
||||
NULL,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
if (!MapAsDataFile)
|
||||
{
|
||||
DPRINT("Dll header read failed: Status = 0x%08lx\n", Status);
|
||||
NtClose(FileHandle);
|
||||
return Status;
|
||||
}
|
||||
/*
|
||||
* Overlay DOS and NT headers structures to the
|
||||
* buffer with DLL's header raw data.
|
||||
*/
|
||||
DosHeader = (PIMAGE_DOS_HEADER) BlockBuffer;
|
||||
NTHeaders = (PIMAGE_NT_HEADERS) (BlockBuffer + DosHeader->e_lfanew);
|
||||
/*
|
||||
* Check it is a PE image file.
|
||||
*/
|
||||
if ((DosHeader->e_magic != IMAGE_DOS_SIGNATURE)
|
||||
|| (DosHeader->e_lfanew == 0L)
|
||||
|| (*(PULONG)(NTHeaders) != IMAGE_NT_SIGNATURE))
|
||||
{
|
||||
DPRINT("NTDLL format invalid\n");
|
||||
NtClose(FileHandle);
|
||||
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
Status = NtReadFile(FileHandle,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&IoStatusBlock,
|
||||
BlockBuffer,
|
||||
sizeof(BlockBuffer),
|
||||
NULL,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("Dll header read failed: Status = 0x%08lx\n", Status);
|
||||
NtClose(FileHandle);
|
||||
return Status;
|
||||
}
|
||||
|
||||
/*
|
||||
* Overlay DOS and NT headers structures to the
|
||||
* buffer with DLL's header raw data.
|
||||
*/
|
||||
DosHeader = (PIMAGE_DOS_HEADER) BlockBuffer;
|
||||
NTHeaders = (PIMAGE_NT_HEADERS) (BlockBuffer + DosHeader->e_lfanew);
|
||||
/*
|
||||
* Check it is a PE image file.
|
||||
*/
|
||||
if ((DosHeader->e_magic != IMAGE_DOS_SIGNATURE)
|
||||
|| (DosHeader->e_lfanew == 0L)
|
||||
|| (*(PULONG)(NTHeaders) != IMAGE_NT_SIGNATURE))
|
||||
{
|
||||
DPRINT("NTDLL format invalid\n");
|
||||
NtClose(FileHandle);
|
||||
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2058,15 +2063,18 @@ LdrpLoadModule(IN PWSTR SearchPath OPTIONAL,
|
|||
{
|
||||
*BaseAddress = ImageBase;
|
||||
}
|
||||
/* Get and check the NT headers */
|
||||
NtHeaders = RtlImageNtHeader(ImageBase);
|
||||
if (NtHeaders == NULL)
|
||||
if (!MappedAsDataFile)
|
||||
{
|
||||
DPRINT1("RtlImageNtHeaders() failed\n");
|
||||
NtUnmapViewOfSection (NtCurrentProcess (), ImageBase);
|
||||
NtClose (SectionHandle);
|
||||
RtlFreeUnicodeString(&FullDosName);
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
/* Get and check the NT headers */
|
||||
NtHeaders = RtlImageNtHeader(ImageBase);
|
||||
if (NtHeaders == NULL)
|
||||
{
|
||||
DPRINT1("RtlImageNtHeaders() failed\n");
|
||||
NtUnmapViewOfSection (NtCurrentProcess (), ImageBase);
|
||||
NtClose (SectionHandle);
|
||||
RtlFreeUnicodeString(&FullDosName);
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
}
|
||||
DPRINT("Mapped %wZ at %x\n", &FullDosName, ImageBase);
|
||||
if (MappedAsDataFile)
|
||||
|
|
Loading…
Reference in a new issue