ntdll: Fixed handling of fake dlls when loading a builtin. Reported by Jacek Caban.
This commit is contained in:
parent
8d8b44089d
commit
96fc6e317e
|
@ -1244,11 +1244,18 @@ NTSTATUS WINAPI LdrGetProcedureAddress(HMODULE module, const ANSI_STRING *name,
|
|||
*
|
||||
* Check if a loaded native dll is a Wine fake dll.
|
||||
*/
|
||||
static BOOL is_fake_dll( const void *base )
|
||||
static BOOL is_fake_dll( HANDLE handle )
|
||||
{
|
||||
static const char fakedll_signature[] = "Wine placeholder DLL";
|
||||
const IMAGE_DOS_HEADER *dos = base;
|
||||
char buffer[sizeof(IMAGE_DOS_HEADER) + sizeof(fakedll_signature)];
|
||||
const IMAGE_DOS_HEADER *dos = (const IMAGE_DOS_HEADER *)buffer;
|
||||
IO_STATUS_BLOCK io;
|
||||
LARGE_INTEGER offset;
|
||||
|
||||
offset.QuadPart = 0;
|
||||
if (NtReadFile( handle, 0, NULL, 0, &io, buffer, sizeof(buffer), &offset, NULL )) return FALSE;
|
||||
if (io.Information < sizeof(buffer)) return FALSE;
|
||||
if (dos->e_magic != IMAGE_DOS_SIGNATURE) return FALSE;
|
||||
if (dos->e_lfanew >= sizeof(*dos) + sizeof(fakedll_signature) &&
|
||||
!memcmp( dos + 1, fakedll_signature, sizeof(fakedll_signature) )) return TRUE;
|
||||
return FALSE;
|
||||
|
@ -1427,13 +1434,6 @@ static NTSTATUS load_native_dll( LPCWSTR load_path, LPCWSTR name, HANDLE file,
|
|||
NtClose( mapping );
|
||||
if (status != STATUS_SUCCESS) return status;
|
||||
|
||||
if (is_fake_dll( module ))
|
||||
{
|
||||
TRACE( "%s is a fake dll, not loading it\n", debugstr_w(name) );
|
||||
NtUnmapViewOfSection( NtCurrentProcess(), module );
|
||||
return STATUS_DLL_NOT_FOUND;
|
||||
}
|
||||
|
||||
/* create the MODREF */
|
||||
|
||||
if (!(wm = alloc_module( module, name ))) return STATUS_NO_MEMORY;
|
||||
|
@ -1870,6 +1870,13 @@ static NTSTATUS load_dll( LPCWSTR load_path, LPCWSTR libname, DWORD flags, WINE_
|
|||
main_exe = get_modref( NtCurrentTeb()->Peb->ImageBaseAddress );
|
||||
loadorder = get_load_order( main_exe ? main_exe->ldr.BaseDllName.Buffer : NULL, filename );
|
||||
|
||||
if (handle && is_fake_dll( handle ))
|
||||
{
|
||||
TRACE( "%s is a fake Wine dll\n", debugstr_w(filename) );
|
||||
NtClose( handle );
|
||||
handle = 0;
|
||||
}
|
||||
|
||||
switch(loadorder)
|
||||
{
|
||||
case LO_INVALID:
|
||||
|
|
Loading…
Reference in New Issue