setupapi: Create fake dlls in \system for the 16bit module [bug 21306]

Detlef Riekenberg wine.dev at web.de
Fri Jan 15 12:14:43 CST 2010


Fixes http://bugs.winehq.org/show_bug.cgi?id=21306

This patch creates an additional wildcard method (*16),
resulting in 48 fake modules (~13KB).

I didn't like to use the already supported wildcard method (*),
resulting in 398 fake modules (~27MB)

A different way to fix the bug is a line in wine.inf.in for every
needed 16bit fake module.

--
By by ... Detlef
---
 dlls/setupapi/fakedll.c |   45 ++++++++++++++++++++++++++++++++++-----------
 tools/wine.inf.in       |    1 +
 2 files changed, 35 insertions(+), 11 deletions(-)

diff --git a/dlls/setupapi/fakedll.c b/dlls/setupapi/fakedll.c
index 3b5a47c..eb9520f 100644
--- a/dlls/setupapi/fakedll.c
+++ b/dlls/setupapi/fakedll.c
@@ -386,6 +386,8 @@ static void *load_fake_dll( const WCHAR *name, size_t *size )
     WCHAR *p;
     int res = 0;
 
+    TRACE("(%s, %p)\n", debugstr_w(name), size);
+
     if ((p = strrchrW( name, '\\' ))) name = p + 1;
 
     i = 0;
@@ -466,7 +468,7 @@ static HANDLE create_dest_file( const WCHAR *name )
 }
 
 /* copy a fake dll file to the dest directory */
-static void install_fake_dll( WCHAR *dest, char *file, const char *ext )
+static void install_fake_dll( WCHAR *dest, char *file, const char *ext, const BOOL only_16bit )
 {
     int ret;
     size_t size;
@@ -476,10 +478,18 @@ static void install_fake_dll( WCHAR *dest, char *file, const char *ext )
     char *name = strrchr( file, '/' ) + 1;
     char *end = name + strlen(name);
 
+    TRACE("(%s, %s, %s, %d)\n", debugstr_w(dest), debugstr_a(file), debugstr_a(ext), only_16bit);
+
     if (ext) strcpy( end, ext );
+    if (end > name + 2 && !strncmp( end - 2, "16", 2 ))
+    {
+        end -= 2;  /* remove "16" suffix */
+    }
+    else
+        if (only_16bit) return;
+
     if (!(ret = read_file( file, &data, &size ))) return;
 
-    if (end > name + 2 && !strncmp( end - 2, "16", 2 )) end -= 2;  /* remove "16" suffix */
     dll_name_AtoW( destname, name, end - name );
     if (!add_handled_dll( destname )) ret = -1;
 
@@ -501,12 +511,14 @@ static void install_fake_dll( WCHAR *dest, char *file, const char *ext )
 }
 
 /* find and install all fake dlls in a given lib directory */
-static void install_lib_dir( WCHAR *dest, char *file, const char *default_ext )
+static void install_lib_dir( WCHAR *dest, char *file, const char *default_ext, const BOOL only_16bit )
 {
     DIR *dir;
     struct dirent *de;
     char *name;
 
+    TRACE("(%s, %s, %s, %d)\n", debugstr_w(dest), debugstr_a(file), debugstr_a(default_ext), only_16bit);
+
     if (!(dir = opendir( file ))) return;
     name = file + strlen(file);
     *name++ = '/';
@@ -521,21 +533,24 @@ static void install_lib_dir( WCHAR *dest, char *file, const char *default_ext )
             strcat( name, "/" );
             strcat( name, de->d_name );
             if (!strchr( de->d_name, '.' )) strcat( name, default_ext );
-            install_fake_dll( dest, file, ".fake" );
+            install_fake_dll( dest, file, ".fake", only_16bit );
         }
-        else install_fake_dll( dest, file, NULL );
+        else install_fake_dll( dest, file, NULL, only_16bit );
     }
     closedir( dir );
 }
 
 /* create fake dlls in dirname for all the files we can find */
-static BOOL create_wildcard_dlls( const WCHAR *dirname )
+static BOOL create_wildcard_dlls( const WCHAR *dirname, const BOOL only_16bit )
 {
     const char *build_dir = wine_get_build_dir();
     const char *path;
     unsigned int i, maxlen = 0;
     char *file;
     WCHAR *dest;
+    WCHAR *wildcard;
+
+    TRACE("(%s) build: %s\n", debugstr_w(dirname), debugstr_a(build_dir));
 
     if (build_dir) maxlen = strlen(build_dir) + sizeof("/programs/");
     for (i = 0; (path = wine_dll_enum_load_path(i)); i++) maxlen = max( maxlen, strlen(path) );
@@ -548,22 +563,23 @@ static BOOL create_wildcard_dlls( const WCHAR *dirname )
         return FALSE;
     }
     strcpyW( dest, dirname );
-    dest[strlenW(dest) - 1] = 0;  /* remove wildcard */
+    wildcard = strrchrW( dest, '\\' );
+    wildcard[1] = 0; /* remove wildcard */
 
     if (build_dir)
     {
         strcpy( file, build_dir );
         strcat( file, "/dlls" );
-        install_lib_dir( dest, file, ".dll" );
+        install_lib_dir( dest, file, ".dll", only_16bit );
         strcpy( file, build_dir );
         strcat( file, "/programs" );
-        install_lib_dir( dest, file, ".exe" );
+        install_lib_dir( dest, file, ".exe", only_16bit );
     }
     for (i = 0; (path = wine_dll_enum_load_path( i )); i++)
     {
         strcpy( file, path );
         strcat( file, "/fakedlls" );
-        install_lib_dir( dest, file, NULL );
+        install_lib_dir( dest, file, NULL, only_16bit );
     }
     HeapFree( GetProcessHeap(), 0, file );
     HeapFree( GetProcessHeap(), 0, dest );
@@ -575,12 +591,15 @@ static BOOL create_wildcard_dlls( const WCHAR *dirname )
  */
 BOOL create_fake_dll( const WCHAR *name, const WCHAR *source )
 {
+    static const WCHAR wildcard16W[] = {'*', '1', '6', 0};
     HANDLE h;
     BOOL ret;
     size_t size;
     const WCHAR *filename;
     void *buffer;
 
+    TRACE("(%s, %s)\n", debugstr_w(name), debugstr_w(source));
+
     if (!(filename = strrchrW( name, '\\' ))) filename = name;
     else filename++;
 
@@ -590,7 +609,11 @@ BOOL create_fake_dll( const WCHAR *name, const WCHAR *source )
         create_directories( name );
         return TRUE;
     }
-    if (filename[0] == '*' && !filename[1]) return create_wildcard_dlls( name );
+
+    if (!lstrcmpW(filename, wildcard16W))
+        return create_wildcard_dlls( name, TRUE );
+
+    if (filename[0] == '*' && !filename[1]) return create_wildcard_dlls( name, FALSE );
 
     add_handled_dll( filename );
 
diff --git a/tools/wine.inf.in b/tools/wine.inf.in
index e03a7e4..95ddc47 100644
--- a/tools/wine.inf.in
+++ b/tools/wine.inf.in
@@ -2435,6 +2435,7 @@ HKLM,%CurrentVersion%\Telephony\Country List\998,"SameAreaRule",,"G"
 10,,winhelp.exe,winhelp.exe16
 10,,winhlp32.exe
 10,command,start.exe
+10,system,*16
 11,,ddhelp.exe
 11,,dosx.exe
 11,,dsound.vxd
-- 
1.6.5




More information about the wine-patches mailing list