@@ -1993,7 +1993,53 @@ static BOOL SHELL_execute(LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc)
1993
1993
}
1994
1994
else
1995
1995
{
1996
- lpFile = sei_tmp.lpFile ;
1996
+ /* If the executable name is not quoted, we have to use this search loop here,
1997
+ that in CreateProcess() is not sufficient because it does not handle shell links. */
1998
+ WCHAR buffer[MAX_PATH], xlpFile[MAX_PATH], lpFilesave[MAX_PATH];
1999
+ WCHAR wszParamSave[MAX_PATH], wszAppNameSave[MAX_PATH];
2000
+ LPWSTR space, s;
2001
+
2002
+ /* Save inputs in case we need to revert them later */
2003
+ memcpy (lpFilesave, sei_tmp.lpFile , wcslen (sei_tmp.lpFile ) * sizeof (WCHAR) + 2 );
2004
+ memcpy (wszParamSave, sei_tmp.lpParameters , wcslen (sei_tmp.lpParameters ) * sizeof (WCHAR) + 2 );
2005
+ memcpy (wszAppNameSave, wszApplicationName, wcslen (wszApplicationName) * sizeof (WCHAR) + 2 );
2006
+
2007
+ LPWSTR beg = wszApplicationName/* sei_tmp.lpFile*/ ;
2008
+ for (s = beg; (space = const_cast <LPWSTR>(strchrW (s, L' ' ))); s = space + 1 )
2009
+ {
2010
+ int idx = space - sei_tmp.lpFile ;
2011
+ memcpy (buffer, sei_tmp.lpFile , idx * sizeof (WCHAR));
2012
+ buffer[idx] = ' \0 ' ;
2013
+
2014
+ /* FIXME This finds directory paths if the targeted file name contains spaces. */
2015
+ if (SearchPathW (*sei_tmp.lpDirectory ? sei_tmp.lpDirectory : NULL , buffer, wszExe, sizeof (xlpFile) / sizeof (xlpFile[0 ]), xlpFile, NULL ))
2016
+ {
2017
+ /* separate out command from parameter string */
2018
+ LPCWSTR p = space + 1 ;
2019
+
2020
+ while (isspaceW (*p))
2021
+ ++p;
2022
+
2023
+ strcpyW (wszParameters, p);
2024
+ *space = L' \0 ' ;
2025
+
2026
+ break ;
2027
+ }
2028
+ }
2029
+
2030
+ /* test if we end in '.exe' and if so keep changes.
2031
+ Revert to beginning values if we do not. */
2032
+ if (!wcsicmp (sei_tmp.lpFile + wcslen (sei_tmp.lpFile ) - 4 , wszExe))
2033
+ {
2034
+ lpFile = sei_tmp.lpFile ;
2035
+ }
2036
+ else
2037
+ {
2038
+ lpFile = lpFilesave;
2039
+ sei_tmp.lpFile = lpFilesave;
2040
+ strcpyW (wszParameters, wszParamSave);
2041
+ strcpyW (wszApplicationName, wszAppNameSave);
2042
+ }
1997
2043
}
1998
2044
}
1999
2045
else
0 commit comments