steam_helper: separate parameters from command when using ShellExecuteW

ShellExecuteW ignores any extra information passed as part of lpFile
resulting in arguments being ignored.

Link: https://github.com/ValveSoftware/Proton/pull/6555
This commit is contained in:
Jan200101 2023-08-20 04:18:14 +02:00 committed by Arkadiusz Hiler
parent ea08ded0ca
commit e6cd3f8ec3

View file

@ -1028,22 +1028,33 @@ static BOOL streq_niw(const WCHAR *l, const WCHAR *r, size_t len)
return TRUE;
}
static BOOL should_use_shell_execute(const WCHAR *cmdline)
static WCHAR* get_end_of_excutable_name(WCHAR *cmdline)
{
BOOL use_shell_execute = TRUE;
BOOL quoted = FALSE;
const WCHAR *executable_name_end = cmdline;
WCHAR *executable_name_end = cmdline;
/* find the end of the first arg...*/
while (*executable_name_end != '\0' &&
(*executable_name_end != ' ' || quoted) &&
(*executable_name_end != '"' || !quoted))
(*executable_name_end != ' ' || quoted))
{
quoted ^= *executable_name_end == '"';
executable_name_end++;
}
return executable_name_end;
}
static BOOL should_use_shell_execute(WCHAR *cmdline)
{
BOOL use_shell_execute = TRUE;
const WCHAR *executable_name_end = (const WCHAR*)get_end_of_excutable_name(cmdline);
/* if the executable is quoted backtrack a bit */
if (*(executable_name_end - 1) == '"')
--executable_name_end;
/* backtrack to before the end of the arg
* and check if we end in .exe or not
* and determine whether to use ShellExecute
@ -1211,10 +1222,17 @@ run:
if (use_shell_execute)
{
WCHAR *param = NULL;
WCHAR *executable_name_end = get_end_of_excutable_name(cmdline);
if (*executable_name_end != '\0')
{
*executable_name_end = '\0';
param = executable_name_end+1;
}
static const WCHAR verb[] = { 'o', 'p', 'e', 'n', 0 };
INT_PTR ret;
if ((ret = (INT_PTR)ShellExecuteW(NULL, verb, cmdline, NULL, NULL, hide_window ? SW_HIDE : SW_SHOWNORMAL)) < 32)
if ((ret = (INT_PTR)ShellExecuteW(NULL, verb, cmdline, param, NULL, hide_window ? SW_HIDE : SW_SHOWNORMAL)) < 32)
{
WINE_ERR("Failed to execute %s, ret %u.\n", wine_dbgstr_w(cmdline), (unsigned int)ret);
if (game_process && ret == SE_ERR_NOASSOC && link2ea)