Ensure that the command-line passed to the various *CreateProcess
functions contains the path to the program being invoked.
diff --git a/loader/module.c b/loader/module.c
index 48a062e..6b4222b 100644
--- a/loader/module.c
+++ b/loader/module.c
@@ -777,6 +777,12 @@
|| lpStartupInfo->wShowWindow == SW_SHOWMINNOACTIVE )
iconic = TRUE;
+ /* Build argument list */
+
+ argptr = argv;
+ if ( !useWine )
+ {
+ char *p = strdup(lpCmdLine);
if ( strchr(filename, '/')
|| strchr(filename, ':')
|| strchr(filename, '\\') )
@@ -784,19 +790,6 @@
if ( DOSFS_GetFullName( filename, TRUE, &full_name ) )
unixfilename = full_name.long_name;
}
-
- if ( !unixfilename )
- {
- SetLastError( ERROR_FILE_NOT_FOUND );
- return FALSE;
- }
-
- /* Build argument list */
-
- argptr = argv;
- if ( !useWine )
- {
- char *p = strdup(lpCmdLine);
*argptr++ = unixfilename;
if (iconic) *argptr++ = "-iconic";
while (1)
@@ -806,6 +799,7 @@
*argptr++ = p;
while (*p && *p != ' ' && *p != '\t') p++;
}
+ free (p);
}
else
{
@@ -1129,8 +1123,10 @@
HFILE hFile;
OFSTRUCT ofs;
DWORD type;
- char name[256];
+ char name[256], dummy[256];
LPCSTR cmdline = NULL;
+ LPSTR tidy_cmdline;
+ int len = 0;
/* Get name and command line */
@@ -1140,16 +1136,24 @@
return FALSE;
}
- /* Process the AppName or CmdLine to get module name and path */
+ /* Process the AppName and/or CmdLine to get module name and path */
name[0] = '\0';
if (lpApplicationName) {
found_file = make_lpApplicationName_name( lpApplicationName, name, sizeof(name) );
- cmdline = (lpCommandLine) ? lpCommandLine : lpApplicationName ;
+ if (lpCommandLine) {
+ make_lpCommandLine_name( lpCommandLine, dummy, sizeof ( dummy ), &cmdline );
}
- else
+ else {
+ cmdline = lpApplicationName;
+ }
+ len += strlen(lpApplicationName);
+ }
+ else {
found_file = make_lpCommandLine_name( lpCommandLine, name, sizeof ( name ), &cmdline );
+ if (lpCommandLine) len = strlen(lpCommandLine);
+ }
if ( !found_file ) {
/* make an early exit if file not found - save second pass */
@@ -1157,6 +1161,10 @@
return FALSE;
}
+ len += strlen(name) + 2;
+ tidy_cmdline = HeapAlloc( GetProcessHeap(), 0, len );
+ sprintf( tidy_cmdline, "\"%s\"%s", name, cmdline);
+
/* Warn if unsupported features are used */
if (dwCreationFlags & CREATE_SUSPENDED)
@@ -1217,14 +1225,17 @@
/* When in WineLib, always fork new Unix process */
- if ( __winelib )
- return MODULE_CreateUnixProcess( name, cmdline,
+ if ( __winelib ) {
+ retv = MODULE_CreateUnixProcess( name, tidy_cmdline,
lpStartupInfo, lpProcessInfo, TRUE );
+ HeapFree( GetProcessHeap(), 0, tidy_cmdline );
+ return (retv);
+ }
/* Check for special case: second instance of NE module */
lstrcpynA( ofs.szPathName, name, sizeof( ofs.szPathName ) );
- retv = NE_CreateProcess( HFILE_ERROR, &ofs, cmdline, lpEnvironment,
+ retv = NE_CreateProcess( HFILE_ERROR, &ofs, tidy_cmdline, lpEnvironment,
lpProcessAttributes, lpThreadAttributes,
bInheritHandles, dwCreationFlags,
lpStartupInfo, lpProcessInfo );
@@ -1238,6 +1249,7 @@
if ( (hFile = OpenFile( name, &ofs, OF_READ )) == HFILE_ERROR )
{
SetLastError( ERROR_FILE_NOT_FOUND );
+ HeapFree( GetProcessHeap(), 0, tidy_cmdline );
return FALSE;
}
@@ -1246,10 +1258,13 @@
CloseHandle( hFile );
/* FIXME: Try Unix executable only when appropriate! */
- if ( MODULE_CreateUnixProcess( name, cmdline,
+ if ( MODULE_CreateUnixProcess( name, tidy_cmdline,
lpStartupInfo, lpProcessInfo, FALSE ) )
+ {
+ HeapFree( GetProcessHeap(), 0, tidy_cmdline );
return TRUE;
-
+ }
+ HeapFree( GetProcessHeap(), 0, tidy_cmdline );
SetLastError( ERROR_BAD_FORMAT );
return FALSE;
}
@@ -1260,21 +1275,21 @@
switch ( type )
{
case SCS_32BIT_BINARY:
- retv = PE_CreateProcess( hFile, &ofs, cmdline, lpEnvironment,
+ retv = PE_CreateProcess( hFile, &ofs, tidy_cmdline, lpEnvironment,
lpProcessAttributes, lpThreadAttributes,
bInheritHandles, dwCreationFlags,
lpStartupInfo, lpProcessInfo );
break;
case SCS_DOS_BINARY:
- retv = MZ_CreateProcess( hFile, &ofs, cmdline, lpEnvironment,
+ retv = MZ_CreateProcess( hFile, &ofs, tidy_cmdline, lpEnvironment,
lpProcessAttributes, lpThreadAttributes,
bInheritHandles, dwCreationFlags,
lpStartupInfo, lpProcessInfo );
break;
case SCS_WOW_BINARY:
- retv = NE_CreateProcess( hFile, &ofs, cmdline, lpEnvironment,
+ retv = NE_CreateProcess( hFile, &ofs, tidy_cmdline, lpEnvironment,
lpProcessAttributes, lpThreadAttributes,
bInheritHandles, dwCreationFlags,
lpStartupInfo, lpProcessInfo );
@@ -1294,6 +1309,7 @@
CloseHandle( hFile );
}
+ HeapFree( GetProcessHeap(), 0, tidy_cmdline );
return retv;
}