Fixed WinExec16 to handle quoted filenames correctly.
This commit is contained in:
parent
72140b02c3
commit
7096384d14
|
@ -720,35 +720,60 @@ BOOL WINAPI GetBinaryTypeW( LPCWSTR lpApplicationName, LPDWORD lpBinaryType )
|
||||||
*/
|
*/
|
||||||
HINSTANCE16 WINAPI WinExec16( LPCSTR lpCmdLine, UINT16 nCmdShow )
|
HINSTANCE16 WINAPI WinExec16( LPCSTR lpCmdLine, UINT16 nCmdShow )
|
||||||
{
|
{
|
||||||
LPCSTR p = NULL;
|
LPCSTR p, args = NULL;
|
||||||
|
LPCSTR name_beg, name_end;
|
||||||
LPSTR name, cmdline;
|
LPSTR name, cmdline;
|
||||||
int len;
|
int arglen;
|
||||||
HINSTANCE16 ret;
|
HINSTANCE16 ret;
|
||||||
char buffer[MAX_PATH];
|
char buffer[MAX_PATH];
|
||||||
|
|
||||||
if ( ( *lpCmdLine == '"' ) && ( p = strchr ( lpCmdLine+1, '"' ) ) )
|
if (*lpCmdLine == '"') /* has to be only one and only at beginning ! */
|
||||||
p = strchr ( p, ' ' );
|
|
||||||
else
|
|
||||||
p = strchr( lpCmdLine, ' ' );
|
|
||||||
if ( p )
|
|
||||||
{
|
{
|
||||||
if (!(name = HeapAlloc( GetProcessHeap(), 0, p - lpCmdLine + 1 )))
|
name_beg = lpCmdLine+1;
|
||||||
return ERROR_NOT_ENOUGH_MEMORY;
|
p = strchr ( lpCmdLine+1, '"' );
|
||||||
memcpy( name, lpCmdLine, p - lpCmdLine );
|
if (p)
|
||||||
name[p - lpCmdLine] = 0;
|
{
|
||||||
p++;
|
name_end = p;
|
||||||
len = strlen(p);
|
args = strchr ( p, ' ' );
|
||||||
cmdline = SEGPTR_ALLOC( len + 2 );
|
}
|
||||||
cmdline[0] = (BYTE)len;
|
else /* yes, even valid with trailing '"' missing */
|
||||||
strcpy( cmdline + 1, p );
|
name_end = lpCmdLine+strlen(lpCmdLine);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
name_beg = lpCmdLine;
|
||||||
|
args = strchr( lpCmdLine, ' ' );
|
||||||
|
name_end = args ? args : lpCmdLine+strlen(lpCmdLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((name_beg == lpCmdLine) && (!args))
|
||||||
|
{ /* just use the original cmdline string as file name */
|
||||||
name = (LPSTR)lpCmdLine;
|
name = (LPSTR)lpCmdLine;
|
||||||
cmdline = SEGPTR_ALLOC(2);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!(name = HeapAlloc( GetProcessHeap(), 0, name_end - name_beg + 1 )))
|
||||||
|
return ERROR_NOT_ENOUGH_MEMORY;
|
||||||
|
memcpy( name, name_beg, name_end - name_beg );
|
||||||
|
name[name_end - name_beg] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args)
|
||||||
|
{
|
||||||
|
args++;
|
||||||
|
arglen = strlen(args);
|
||||||
|
cmdline = SEGPTR_ALLOC( 2 + arglen );
|
||||||
|
cmdline[0] = (BYTE)arglen;
|
||||||
|
strcpy( cmdline + 1, args );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmdline = SEGPTR_ALLOC( 2 );
|
||||||
cmdline[0] = cmdline[1] = 0;
|
cmdline[0] = cmdline[1] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TRACE("name: %s, cmdline: %.*s\n", name, cmdline[0], &cmdline[1]);
|
||||||
|
|
||||||
if (SearchPathA( NULL, name, ".exe", sizeof(buffer), buffer, NULL ))
|
if (SearchPathA( NULL, name, ".exe", sizeof(buffer), buffer, NULL ))
|
||||||
{
|
{
|
||||||
LOADPARAMS16 params;
|
LOADPARAMS16 params;
|
||||||
|
|
Loading…
Reference in New Issue