Changed LoadLibraryEx32W16 to use OpenFile16 to look for the file

instead of DIR_SearchPath.
This commit is contained in:
Alexandre Julliard 2004-03-25 05:32:05 +00:00
parent 09d2d47721
commit ed8a17fb1b
1 changed files with 17 additions and 18 deletions

View File

@ -32,7 +32,6 @@
#include "excpt.h" #include "excpt.h"
#include "winreg.h" #include "winreg.h"
#include "winternl.h" #include "winternl.h"
#include "file.h"
#include "miscemu.h" #include "miscemu.h"
#include "module.h" #include "module.h"
#include "stackframe.h" #include "stackframe.h"
@ -756,11 +755,9 @@ DWORD WINAPI GetVDMPointer32W16( SEGPTR vp, UINT16 fMode )
DWORD WINAPI LoadLibraryEx32W16( LPCSTR lpszLibFile, DWORD hFile, DWORD dwFlags ) DWORD WINAPI LoadLibraryEx32W16( LPCSTR lpszLibFile, DWORD hFile, DWORD dwFlags )
{ {
HMODULE hModule; HMODULE hModule;
DOS_FULL_NAME full_name;
DWORD mutex_count; DWORD mutex_count;
UNICODE_STRING libfileW; OFSTRUCT ofs;
LPCWSTR filenameW; const char *p;
static const WCHAR dllW[] = {'.','D','L','L',0};
if (!lpszLibFile) if (!lpszLibFile)
{ {
@ -768,25 +765,27 @@ DWORD WINAPI LoadLibraryEx32W16( LPCSTR lpszLibFile, DWORD hFile, DWORD dwFlags
return 0; return 0;
} }
if (!RtlCreateUnicodeStringFromAsciiz(&libfileW, lpszLibFile)) /* if the file can not be found, call LoadLibraryExA anyway, since it might be
a builtin module. This case is handled in MODULE_LoadLibraryExA */
if ((p = strrchr( lpszLibFile, '.' )) && !strchr( p, '\\' )) /* got an extension */
{ {
SetLastError(ERROR_NOT_ENOUGH_MEMORY); if (OpenFile16( lpszLibFile, &ofs, OF_EXIST ) != HFILE_ERROR16)
return 0; lpszLibFile = ofs.szPathName;
}
else
{
char buffer[MAX_PATH+4];
strcpy( buffer, lpszLibFile );
strcat( buffer, ".dll" );
if (OpenFile16( buffer, &ofs, OF_EXIST ) != HFILE_ERROR16)
lpszLibFile = ofs.szPathName;
} }
/* if the file can not be found, call LoadLibraryExA anyway, since it might be
a buildin module. This case is handled in MODULE_LoadLibraryExA */
filenameW = libfileW.Buffer;
if ( DIR_SearchPath( NULL, filenameW, dllW, &full_name, FALSE ) )
filenameW = full_name.short_name;
ReleaseThunkLock( &mutex_count ); ReleaseThunkLock( &mutex_count );
hModule = LoadLibraryExW( filenameW, (HANDLE)hFile, dwFlags ); hModule = LoadLibraryExA( lpszLibFile, (HANDLE)hFile, dwFlags );
RestoreThunkLock( mutex_count ); RestoreThunkLock( mutex_count );
RtlFreeUnicodeString(&libfileW);
return (DWORD)hModule; return (DWORD)hModule;
} }