From 2f2819466bbc551ae37d72c7c9a759bd82d5e003 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 21 Mar 2006 11:31:23 +0100 Subject: [PATCH] ntdll: Detect the fake dlls created by setupapi and refuse to load them. --- dlls/ntdll/loader.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index efc2bed0c9..967c2989c9 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -1201,6 +1201,22 @@ NTSTATUS WINAPI LdrGetProcedureAddress(HMODULE module, const ANSI_STRING *name, } +/*********************************************************************** + * is_fake_dll + * + * Check if a loaded native dll is a Wine fake dll. + */ +static BOOL is_fake_dll( const void *base ) +{ + static const char fakedll_signature[] = "Wine placeholder DLL"; + const IMAGE_DOS_HEADER *dos = base; + + if (dos->e_lfanew >= sizeof(*dos) + sizeof(fakedll_signature) && + !memcmp( dos + 1, fakedll_signature, sizeof(fakedll_signature) )) return TRUE; + return FALSE; +} + + /*********************************************************************** * get_builtin_fullname * @@ -1371,6 +1387,13 @@ 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; -- 2.32.0.93.g670b81a890