steam_helper: Only do steam.exe setup for the game process

This commit is contained in:
Andrew Eikum 2019-03-28 08:04:49 -05:00
parent 7a30e996ce
commit 17efb0bd3e

View file

@ -116,7 +116,7 @@ static void setup_steam_registry(void)
SteamAPI_Shutdown(); SteamAPI_Shutdown();
} }
static int run_process(void) static HANDLE run_process(void)
{ {
WCHAR *cmdline = GetCommandLineW(); WCHAR *cmdline = GetCommandLineW();
STARTUPINFOW si = { sizeof(si) }; STARTUPINFOW si = { sizeof(si) };
@ -135,7 +135,7 @@ static int run_process(void)
if (!cmdline) if (!cmdline)
{ {
WINE_ERR("Invalid command\n"); WINE_ERR("Invalid command\n");
return 1; return INVALID_HANDLE_VALUE;
} }
while (*cmdline == ' ') cmdline++; while (*cmdline == ' ') cmdline++;
@ -144,29 +144,46 @@ static int run_process(void)
if (!CreateProcessW(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) if (!CreateProcessW(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{ {
WINE_ERR("Failed to create process %s: %u\n", wine_dbgstr_w(cmdline), GetLastError()); WINE_ERR("Failed to create process %s: %u\n", wine_dbgstr_w(cmdline), GetLastError());
return 1; return INVALID_HANDLE_VALUE;
} }
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread); CloseHandle(pi.hThread);
return 0; return pi.hProcess;
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
HANDLE wait_handle = INVALID_HANDLE_VALUE;
WINE_TRACE("\n"); WINE_TRACE("\n");
if (getenv("SteamGameId"))
{
/* do setup only for game process */
CreateThread(NULL, 0, create_steam_window, NULL, 0, NULL); CreateThread(NULL, 0, create_steam_window, NULL, 0, NULL);
set_active_process_pid(); set_active_process_pid();
setup_steam_registry(); setup_steam_registry();
if (argc > 1) wait_handle = __wine_make_process_system();
{
int ret = run_process();
if (ret) return ret;
} }
WaitForSingleObject(__wine_make_process_system(), INFINITE); if (argc > 1)
{
HANDLE child;
child = run_process();
if (child == INVALID_HANDLE_VALUE)
return 1;
if (wait_handle == INVALID_HANDLE_VALUE)
wait_handle = child;
else
CloseHandle(child);
}
WaitForSingleObject(wait_handle, INFINITE);
return 0; return 0;
} }