[Corrected] NTDLL/loader.c: Remove spaces at end of name in import_dll

Uwe Bonnes bon at elektron.ikp.physik.tu-darmstadt.de
Sat Feb 18 15:40:36 CST 2006


Changelog:
        ntdll/loader.c import_dll()
        Remove spaces at end of name retrieved with get_rva( module,
        descr->Name )

This time with the length check as suggested by Vitaliy.

This lets me start an old wedit.exe from lcc.exe. Otherwise "crtdll.dll  "
(observe the two spaces at the end) is not found...
-- 
Uwe Bonnes                bon at elektron.ikp.physik.tu-darmstadt.de

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
Index: wine/dlls/ntdll/loader.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/loader.c,v
retrieving revision 1.119
diff -u -r1.119 loader.c
--- wine/dlls/ntdll/loader.c	9 Feb 2006 11:52:50 -0000	1.119
+++ wine/dlls/ntdll/loader.c	18 Feb 2006 21:24:34 -0000
@@ -126,6 +126,15 @@
     while (len--) *dst++ = (unsigned char)*src++;
 }
 
+/* Overwrite spaces at end of buffer with NULL */
+inline static void skip_spaces(WCHAR *buffer, size_t len)
+{
+    while (len > 1 && (buffer[len -2] == (WCHAR)' '))
+    {
+        buffer[len -2] = 0;
+        len --;
+    }
+}
 
 /*************************************************************************
  *		call_dll_entry_point
@@ -463,6 +472,7 @@
     if (len * sizeof(WCHAR) <= sizeof(buffer))
     {
         ascii_to_unicode( buffer, name, len );
+        skip_spaces(buffer, len);
         status = load_dll( load_path, buffer, 0, &wmImp );
     }
     else  /* need to allocate a larger buffer */
@@ -470,6 +480,7 @@
         WCHAR *ptr = RtlAllocateHeap( GetProcessHeap(), 0, len * sizeof(WCHAR) );
         if (!ptr) return NULL;
         ascii_to_unicode( ptr, name, len );
+        skip_spaces(buffer, len);
         status = load_dll( load_path, ptr, 0, &wmImp );
         RtlFreeHeap( GetProcessHeap(), 0, ptr );
     }



More information about the wine-patches mailing list