Author: cwittich
Date: Sat Sep 6 05:27:40 2008
New Revision: 35976
URL:
http://svn.reactos.org/svn/reactos?rev=35976&view=rev
Log:
fix a version info winetest by allowing non dll files to be loaded with
LOAD_LIBRARY_AS_DATAFILE
Modified:
trunk/reactos/dll/ntdll/ldr/utils.c
Modified: trunk/reactos/dll/ntdll/ldr/utils.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/ldr/utils.c?rev=…
==============================================================================
--- trunk/reactos/dll/ntdll/ldr/utils.c [iso-8859-1] (original)
+++ trunk/reactos/dll/ntdll/ldr/utils.c [iso-8859-1] Sat Sep 6 05:27:40 2008
@@ -650,38 +650,43 @@
0,
FullNtFileName.Buffer);
- 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;
+ if (!MapAsDataFile)
+ {
+
+ 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 @@
{
*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)