Make behavior of builtin executables closer to that of builtin dlls.
Fixed case sensitivity of builtin executables.
diff --git a/loader/loadorder.c b/loader/loadorder.c
index a08a134..2f1107a 100644
--- a/loader/loadorder.c
+++ b/loader/loadorder.c
@@ -418,6 +418,62 @@
/***************************************************************************
+ * MODULE_GetBuiltinPath
+ *
+ * Get the path of a builtin module when the native file does not exist.
+ */
+BOOL MODULE_GetBuiltinPath( const char *libname, const char *ext, char *filename, UINT size )
+{
+ char *p;
+ BOOL ret = FALSE;
+ UINT len = GetSystemDirectoryA( filename, size );
+
+ if (FILE_contains_path( libname ))
+ {
+ char *tmp;
+
+ /* if the library name contains a path and can not be found,
+ * return an error.
+ * exception: if the path is the system directory, proceed,
+ * so that modules which are not PE modules can be loaded.
+ * If the library name does not contain a path and can not
+ * be found, assume the system directory is meant */
+
+ if (strlen(libname) >= size) return FALSE; /* too long */
+ if (strchr( libname, '/' )) /* need to convert slashes */
+ {
+ if (!(tmp = HeapAlloc( GetProcessHeap(), 0, strlen(libname)+1 ))) return FALSE;
+ strcpy( tmp, libname );
+ for (p = tmp; *p; p++) if (*p == '/') *p = '\\';
+ }
+ else tmp = (char *)libname;
+
+ if (!FILE_strncasecmp( filename, tmp, len ) && tmp[len] == '\\')
+ {
+ strcpy( filename, tmp );
+ ret = TRUE;
+ }
+ if (tmp != libname) HeapFree( GetProcessHeap(), 0, tmp );
+ if (!ret) return FALSE;
+ }
+ else
+ {
+ if (strlen(libname) >= size - len - 1) return FALSE;
+ filename[len] = '\\';
+ strcpy( filename+len+1, libname );
+ }
+
+ /* if the filename doesn't have an extension, append the default */
+ if (!(p = strrchr( filename, '.')) || strchr( p, '/' ) || strchr( p, '\\'))
+ {
+ if (strlen(filename) + strlen(ext) >= size) return FALSE;
+ strcat( filename, ext );
+ }
+ return TRUE;
+}
+
+
+/***************************************************************************
* MODULE_GetLoadOrder (internal)
*
* Locate the loadorder of a module.
diff --git a/loader/module.c b/loader/module.c
index 19a7a8e..637c693 100644
--- a/loader/module.c
+++ b/loader/module.c
@@ -1194,7 +1194,7 @@
WINE_MODREF *pwm;
int i;
enum loadorder_type loadorder[LOADORDER_NTYPES];
- LPSTR filename, p;
+ LPSTR filename;
const char *filetype = "";
DWORD found;
BOOL allocated_libdir = FALSE;
@@ -1222,28 +1222,7 @@
/* build the modules filename */
if (!found)
{
- if ( ! GetSystemDirectoryA ( filename, MAX_PATH ) )
- goto error;
-
- /* if the library name contains a path and can not be found,
- * return an error.
- * exception: if the path is the system directory, proceed,
- * so that modules which are not PE modules can be loaded.
- * If the library name does not contain a path and can not
- * be found, assume the system directory is meant */
-
- if ( ! FILE_strncasecmp ( filename, libname, strlen ( filename ) ))
- strcpy ( filename, libname );
- else
- {
- if (FILE_contains_path(libname)) goto error;
- strcat ( filename, "\\" );
- strcat ( filename, libname );
- }
-
- /* if the filename doesn't have an extension, append .DLL */
- if (!(p = strrchr( filename, '.')) || strchr( p, '/' ) || strchr( p, '\\'))
- strcat( filename, ".dll" );
+ if (!MODULE_GetBuiltinPath( libname, ".dll", filename, MAX_PATH )) goto error;
}
/* Check for already loaded module */