From 10b3402c43e297ce5250fc240f7a24f415ac4178 Mon Sep 17 00:00:00 2001 From: Ove Kaaven Date: Mon, 16 Apr 2001 19:32:48 +0000 Subject: [PATCH] Let LOAD_LIBRARY_AS_DATAFILE load the builtin dll if loading a native DLL failed, so that winesetuptk's fake-windows installation work. --- loader/module.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/loader/module.c b/loader/module.c index 9d905e6217d..ec69928e110 100644 --- a/loader/module.c +++ b/loader/module.c @@ -1255,26 +1255,25 @@ HMODULE WINAPI LoadLibraryExA(LPCSTR libname, HANDLE hfile, DWORD flags) if (flags & LOAD_LIBRARY_AS_DATAFILE) { char filename[256]; - HANDLE hFile; HMODULE hmod = 0; /* This method allows searching for the 'native' libraries only */ - if (!SearchPathA( NULL, libname, ".dll", sizeof(filename), filename, NULL )) + if (SearchPathA( NULL, libname, ".dll", sizeof(filename), filename, NULL )) { - flags |= DONT_RESOLVE_DLL_REFERENCES; /* Just in case */ - goto try_builtin; /* Fallback to normal behaviour */ + /* FIXME: maybe we should use the hfile parameter instead */ + HANDLE hFile = CreateFileA( filename, GENERIC_READ, FILE_SHARE_READ, + NULL, OPEN_EXISTING, 0, 0 ); + if (hFile != INVALID_HANDLE_VALUE) + { + hmod = PE_LoadImage( hFile, filename, flags ); + CloseHandle( hFile ); + } + if (hmod) return hmod; } - /* FIXME: maybe we should use the hfile parameter instead */ - hFile = CreateFileA( filename, GENERIC_READ, FILE_SHARE_READ, - NULL, OPEN_EXISTING, 0, 0 ); - if (hFile != INVALID_HANDLE_VALUE) - { - hmod = PE_LoadImage( hFile, filename, flags ); - CloseHandle( hFile ); - } - return hmod; + flags |= DONT_RESOLVE_DLL_REFERENCES; /* Just in case */ + /* Fallback to normal behaviour */ } - try_builtin: + RtlAcquirePebLock(); wm = MODULE_LoadLibraryExA( libname, hfile, flags );