Loader fix for pathes differing by extra backslashes
Mike McCormack
mike at codeweavers.com
Sat Jun 28 15:37:31 CDT 2003
Hi,
The loader seems to have a problem with extra backslashes in module
pathnames.
If "c:\\windows\\system\\ole32.dll" is loaded and unloaded, then
"c:\\windows\\system\\\\ole32.dll" is loaded, there will be trouble, as
the loader does not recognise these two as the same module, yet dlopen does.
This patch works around the problem. Can anybody think of a better fix?
Mike
ChangeLog:
* don't differenciate between module pathes names with extra slashes
-------------- next part --------------
Index: dlls/ntdll/loader.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/loader.c,v
retrieving revision 1.29
diff -u -r1.29 loader.c
--- dlls/ntdll/loader.c 27 Jun 2003 04:06:23 -0000 1.29
+++ dlls/ntdll/loader.c 28 Jun 2003 15:22:35 -0000
@@ -951,7 +951,7 @@
* init function into load_library).
* allocated_libdir is TRUE in the stack frame that allocated libdir
*/
-static NTSTATUS load_dll( LPCSTR libname, DWORD flags, WINE_MODREF** pwm )
+static NTSTATUS do_load_dll( LPCSTR libname, DWORD flags, WINE_MODREF** pwm )
{
int i;
enum loadorder_type loadorder[LOADORDER_NTYPES];
@@ -1101,6 +1101,33 @@
WARN("Failed to load module '%s'; status=%ld\n", filename, nts);
RtlFreeHeap( ntdll_get_process_heap(), 0, filename );
return nts;
+}
+
+/* clean the path before loading the dll */
+static NTSTATUS load_dll( LPCSTR libname, DWORD flags, WINE_MODREF** pwm )
+{
+ LPCSTR szLibName;
+ NTSTATUS r;
+ UINT i,j;
+
+ szLibName = RtlAllocateHeap( ntdll_get_process_heap(),
+ 0, strlen( libname) + 1 );
+ if ( !szLibName ) return STATUS_NO_MEMORY;
+
+ /* remove duplicate backslashes from the path */
+ for( i=0,j=0; libname[i]; i++)
+ {
+ if ( ( libname[i] == '\\' ) && j && ( szLibName[j-1] == '\\' ) )
+ continue;
+ szLibName[j++] = libname[i];
+ }
+ szLibName[j] = 0;
+
+ r = do_load_dll( szLibName, flags, pwm );
+
+ RtlFreeHeap( ntdll_get_process_heap(), 0, szLibName );
+
+ return r;
}
/******************************************************************
More information about the wine-patches
mailing list