Commit fec23293 authored by Dave Pickles's avatar Dave Pickles Committed by Alexandre Julliard

Ensure that the command-line passed to the various *CreateProcess

functions contains the path to the program being invoked.
parent dfc46d94
...@@ -777,6 +777,12 @@ static BOOL MODULE_CreateUnixProcess( LPCSTR filename, LPCSTR lpCmdLine, ...@@ -777,6 +777,12 @@ static BOOL MODULE_CreateUnixProcess( LPCSTR filename, LPCSTR lpCmdLine,
|| lpStartupInfo->wShowWindow == SW_SHOWMINNOACTIVE ) || lpStartupInfo->wShowWindow == SW_SHOWMINNOACTIVE )
iconic = TRUE; iconic = TRUE;
/* Build argument list */
argptr = argv;
if ( !useWine )
{
char *p = strdup(lpCmdLine);
if ( strchr(filename, '/') if ( strchr(filename, '/')
|| strchr(filename, ':') || strchr(filename, ':')
|| strchr(filename, '\\') ) || strchr(filename, '\\') )
...@@ -784,19 +790,6 @@ static BOOL MODULE_CreateUnixProcess( LPCSTR filename, LPCSTR lpCmdLine, ...@@ -784,19 +790,6 @@ static BOOL MODULE_CreateUnixProcess( LPCSTR filename, LPCSTR lpCmdLine,
if ( DOSFS_GetFullName( filename, TRUE, &full_name ) ) if ( DOSFS_GetFullName( filename, TRUE, &full_name ) )
unixfilename = full_name.long_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; *argptr++ = unixfilename;
if (iconic) *argptr++ = "-iconic"; if (iconic) *argptr++ = "-iconic";
while (1) while (1)
...@@ -806,6 +799,7 @@ static BOOL MODULE_CreateUnixProcess( LPCSTR filename, LPCSTR lpCmdLine, ...@@ -806,6 +799,7 @@ static BOOL MODULE_CreateUnixProcess( LPCSTR filename, LPCSTR lpCmdLine,
*argptr++ = p; *argptr++ = p;
while (*p && *p != ' ' && *p != '\t') p++; while (*p && *p != ' ' && *p != '\t') p++;
} }
free (p);
} }
else else
{ {
...@@ -1129,8 +1123,10 @@ BOOL WINAPI CreateProcessA( LPCSTR lpApplicationName, LPSTR lpCommandLine, ...@@ -1129,8 +1123,10 @@ BOOL WINAPI CreateProcessA( LPCSTR lpApplicationName, LPSTR lpCommandLine,
HFILE hFile; HFILE hFile;
OFSTRUCT ofs; OFSTRUCT ofs;
DWORD type; DWORD type;
char name[256]; char name[256], dummy[256];
LPCSTR cmdline = NULL; LPCSTR cmdline = NULL;
LPSTR tidy_cmdline;
int len = 0;
/* Get name and command line */ /* Get name and command line */
...@@ -1140,16 +1136,24 @@ BOOL WINAPI CreateProcessA( LPCSTR lpApplicationName, LPSTR lpCommandLine, ...@@ -1140,16 +1136,24 @@ BOOL WINAPI CreateProcessA( LPCSTR lpApplicationName, LPSTR lpCommandLine,
return FALSE; 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'; name[0] = '\0';
if (lpApplicationName) { if (lpApplicationName) {
found_file = make_lpApplicationName_name( lpApplicationName, name, sizeof(name) ); 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 ); found_file = make_lpCommandLine_name( lpCommandLine, name, sizeof ( name ), &cmdline );
if (lpCommandLine) len = strlen(lpCommandLine);
}
if ( !found_file ) { if ( !found_file ) {
/* make an early exit if file not found - save second pass */ /* make an early exit if file not found - save second pass */
...@@ -1157,6 +1161,10 @@ BOOL WINAPI CreateProcessA( LPCSTR lpApplicationName, LPSTR lpCommandLine, ...@@ -1157,6 +1161,10 @@ BOOL WINAPI CreateProcessA( LPCSTR lpApplicationName, LPSTR lpCommandLine,
return FALSE; 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 */ /* Warn if unsupported features are used */
if (dwCreationFlags & CREATE_SUSPENDED) if (dwCreationFlags & CREATE_SUSPENDED)
...@@ -1217,14 +1225,17 @@ BOOL WINAPI CreateProcessA( LPCSTR lpApplicationName, LPSTR lpCommandLine, ...@@ -1217,14 +1225,17 @@ BOOL WINAPI CreateProcessA( LPCSTR lpApplicationName, LPSTR lpCommandLine,
/* When in WineLib, always fork new Unix process */ /* When in WineLib, always fork new Unix process */
if ( __winelib ) if ( __winelib ) {
return MODULE_CreateUnixProcess( name, cmdline, retv = MODULE_CreateUnixProcess( name, tidy_cmdline,
lpStartupInfo, lpProcessInfo, TRUE ); lpStartupInfo, lpProcessInfo, TRUE );
HeapFree( GetProcessHeap(), 0, tidy_cmdline );
return (retv);
}
/* Check for special case: second instance of NE module */ /* Check for special case: second instance of NE module */
lstrcpynA( ofs.szPathName, name, sizeof( ofs.szPathName ) ); 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, lpProcessAttributes, lpThreadAttributes,
bInheritHandles, dwCreationFlags, bInheritHandles, dwCreationFlags,
lpStartupInfo, lpProcessInfo ); lpStartupInfo, lpProcessInfo );
...@@ -1238,6 +1249,7 @@ BOOL WINAPI CreateProcessA( LPCSTR lpApplicationName, LPSTR lpCommandLine, ...@@ -1238,6 +1249,7 @@ BOOL WINAPI CreateProcessA( LPCSTR lpApplicationName, LPSTR lpCommandLine,
if ( (hFile = OpenFile( name, &ofs, OF_READ )) == HFILE_ERROR ) if ( (hFile = OpenFile( name, &ofs, OF_READ )) == HFILE_ERROR )
{ {
SetLastError( ERROR_FILE_NOT_FOUND ); SetLastError( ERROR_FILE_NOT_FOUND );
HeapFree( GetProcessHeap(), 0, tidy_cmdline );
return FALSE; return FALSE;
} }
...@@ -1246,10 +1258,13 @@ BOOL WINAPI CreateProcessA( LPCSTR lpApplicationName, LPSTR lpCommandLine, ...@@ -1246,10 +1258,13 @@ BOOL WINAPI CreateProcessA( LPCSTR lpApplicationName, LPSTR lpCommandLine,
CloseHandle( hFile ); CloseHandle( hFile );
/* FIXME: Try Unix executable only when appropriate! */ /* FIXME: Try Unix executable only when appropriate! */
if ( MODULE_CreateUnixProcess( name, cmdline, if ( MODULE_CreateUnixProcess( name, tidy_cmdline,
lpStartupInfo, lpProcessInfo, FALSE ) ) lpStartupInfo, lpProcessInfo, FALSE ) )
{
HeapFree( GetProcessHeap(), 0, tidy_cmdline );
return TRUE; return TRUE;
}
HeapFree( GetProcessHeap(), 0, tidy_cmdline );
SetLastError( ERROR_BAD_FORMAT ); SetLastError( ERROR_BAD_FORMAT );
return FALSE; return FALSE;
} }
...@@ -1260,21 +1275,21 @@ BOOL WINAPI CreateProcessA( LPCSTR lpApplicationName, LPSTR lpCommandLine, ...@@ -1260,21 +1275,21 @@ BOOL WINAPI CreateProcessA( LPCSTR lpApplicationName, LPSTR lpCommandLine,
switch ( type ) switch ( type )
{ {
case SCS_32BIT_BINARY: case SCS_32BIT_BINARY:
retv = PE_CreateProcess( hFile, &ofs, cmdline, lpEnvironment, retv = PE_CreateProcess( hFile, &ofs, tidy_cmdline, lpEnvironment,
lpProcessAttributes, lpThreadAttributes, lpProcessAttributes, lpThreadAttributes,
bInheritHandles, dwCreationFlags, bInheritHandles, dwCreationFlags,
lpStartupInfo, lpProcessInfo ); lpStartupInfo, lpProcessInfo );
break; break;
case SCS_DOS_BINARY: case SCS_DOS_BINARY:
retv = MZ_CreateProcess( hFile, &ofs, cmdline, lpEnvironment, retv = MZ_CreateProcess( hFile, &ofs, tidy_cmdline, lpEnvironment,
lpProcessAttributes, lpThreadAttributes, lpProcessAttributes, lpThreadAttributes,
bInheritHandles, dwCreationFlags, bInheritHandles, dwCreationFlags,
lpStartupInfo, lpProcessInfo ); lpStartupInfo, lpProcessInfo );
break; break;
case SCS_WOW_BINARY: case SCS_WOW_BINARY:
retv = NE_CreateProcess( hFile, &ofs, cmdline, lpEnvironment, retv = NE_CreateProcess( hFile, &ofs, tidy_cmdline, lpEnvironment,
lpProcessAttributes, lpThreadAttributes, lpProcessAttributes, lpThreadAttributes,
bInheritHandles, dwCreationFlags, bInheritHandles, dwCreationFlags,
lpStartupInfo, lpProcessInfo ); lpStartupInfo, lpProcessInfo );
...@@ -1294,6 +1309,7 @@ BOOL WINAPI CreateProcessA( LPCSTR lpApplicationName, LPSTR lpCommandLine, ...@@ -1294,6 +1309,7 @@ BOOL WINAPI CreateProcessA( LPCSTR lpApplicationName, LPSTR lpCommandLine,
CloseHandle( hFile ); CloseHandle( hFile );
} }
HeapFree( GetProcessHeap(), 0, tidy_cmdline );
return retv; return retv;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment