From 208955cada9378c20e88585364e1325f17392a39 Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Sun, 10 Sep 2000 03:14:00 +0000 Subject: [PATCH] Fixed loader - broken search for already loaded modules. --- loader/module.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/loader/module.c b/loader/module.c index 6fe61788ab5..f74358606d4 100644 --- a/loader/module.c +++ b/loader/module.c @@ -1293,13 +1293,35 @@ WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HFILE hfile, DWORD flags ) /* if the filename doesn't have an extension append .DLL */ if (!(p = strrchr( filename, '.')) || strchr( p, '/' ) || strchr( p, '\\')) - strcat( filename, ".DLL" ); + strcat( filename, ".DLL" ); } EnterCriticalSection(&PROCESS_Current()->crit_section); /* Check for already loaded module */ - if((pwm = MODULE_FindModule(filename))) + if (!(pwm = MODULE_FindModule(filename)) && + /* no path in libpath */ + !strchr( libname, '\\' ) && !strchr( libname, ':') && !strchr( libname, '/' )) + { + LPSTR fn = HeapAlloc ( GetProcessHeap(), 0, MAX_PATH + 1 ); + if (fn) + { + /* since the default loading mechanism uses a more detailed algorithm + * than SearchPath (like using PATH, which can even be modified between + * two attempts of loading the same DLL), the look-up above (with + * SearchPath) can have put the file in system directory, whereas it + * has already been loaded but with a different path. So do a specific + * look-up with filename (without any path) + */ + strcpy ( fn, libname ); + /* if the filename doesn't have an extension append .DLL */ + if (!strrchr( fn, '.')) strcat( fn, ".dll" ); + if ((pwm = MODULE_FindModule( fn )) != NULL) + strcpy( filename, fn ); + HeapFree( GetProcessHeap(), 0, fn ); + } + } + if (pwm) { if(!(pwm->flags & WINE_MODREF_MARKER)) pwm->refCount++;