Let LOAD_LIBRARY_AS_DATAFILE load the builtin dll if loading a native

DLL failed, so that winesetuptk's fake-windows installation work.
This commit is contained in:
Ove Kaaven 2001-04-16 19:32:48 +00:00 committed by Alexandre Julliard
parent e8ffcaa372
commit 10b3402c43
1 changed files with 13 additions and 14 deletions

View File

@ -1255,26 +1255,25 @@ HMODULE WINAPI LoadLibraryExA(LPCSTR libname, HANDLE hfile, DWORD flags)
if (flags & LOAD_LIBRARY_AS_DATAFILE) if (flags & LOAD_LIBRARY_AS_DATAFILE)
{ {
char filename[256]; char filename[256];
HANDLE hFile;
HMODULE hmod = 0; HMODULE hmod = 0;
/* This method allows searching for the 'native' libraries only */ /* 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 */ /* FIXME: maybe we should use the hfile parameter instead */
goto try_builtin; /* Fallback to normal behaviour */ 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 */ flags |= DONT_RESOLVE_DLL_REFERENCES; /* Just in case */
hFile = CreateFileA( filename, GENERIC_READ, FILE_SHARE_READ, /* Fallback to normal behaviour */
NULL, OPEN_EXISTING, 0, 0 );
if (hFile != INVALID_HANDLE_VALUE)
{
hmod = PE_LoadImage( hFile, filename, flags );
CloseHandle( hFile );
}
return hmod;
} }
try_builtin:
RtlAcquirePebLock(); RtlAcquirePebLock();
wm = MODULE_LoadLibraryExA( libname, hfile, flags ); wm = MODULE_LoadLibraryExA( libname, hfile, flags );