@@ -1356,8 +1356,10 @@ static BOOL steam_command_handler(int argc, char *argv[])
1356
1356
typedef NTSTATUS (WINAPI *__WINE_UNIX_SPAWNVP)(char *const argv[], int wait );
1357
1357
static __WINE_UNIX_SPAWNVP p__wine_unix_spawnvp;
1358
1358
NTSTATUS status = STATUS_UNSUCCESSFUL;
1359
+ BOOL restart_self = FALSE ;
1359
1360
char **unix_argv;
1360
1361
HMODULE module;
1362
+ const char *sgi;
1361
1363
int i, j;
1362
1364
static char *unix_steam[] =
1363
1365
{
@@ -1370,6 +1372,33 @@ static BOOL steam_command_handler(int argc, char *argv[])
1370
1372
if (argc > 1 && StrStrIA (argv[1 ], " steam://" ) != argv[1 ] && argv[1 ][0 ] != ' -' )
1371
1373
return FALSE ;
1372
1374
1375
+ if (argc > 2 && !strcmp (argv[1 ], " --" ) && (sgi = getenv (" SteamGameId" )))
1376
+ {
1377
+ char s[64 ];
1378
+
1379
+ snprintf (s, sizeof (s), " steam://launch/%s" , sgi);
1380
+ if (!(restart_self = !strcmp (argv[2 ], s)))
1381
+ {
1382
+ snprintf (s, sizeof (s), " steam://rungameid/%s" , sgi);
1383
+ restart_self = !strcmp (argv[2 ], s);
1384
+ }
1385
+ }
1386
+ if (restart_self)
1387
+ {
1388
+ HANDLE event;
1389
+
1390
+ event = OpenEventA (SYNCHRONIZE, FALSE , " PROTON_STEAM_EXE_RESTART_APP" );
1391
+ if (event)
1392
+ {
1393
+ SetEvent (event);
1394
+ CloseHandle (event);
1395
+ WINE_TRACE (" Signalled app restart.\n " );
1396
+ }
1397
+ else
1398
+ WINE_ERR (" Restart event not found.\n " );
1399
+ return TRUE ;
1400
+ }
1401
+
1373
1402
if (!p__wine_unix_spawnvp)
1374
1403
{
1375
1404
module = GetModuleHandleA (" ntdll.dll" );
@@ -1737,8 +1766,46 @@ int main(int argc, char *argv[])
1737
1766
1738
1767
if (wait_handle != INVALID_HANDLE_VALUE)
1739
1768
{
1769
+ HANDLE waits[2 ];
1770
+ DWORD ret;
1771
+ int wait_count;
1772
+
1773
+ waits[0 ] = wait_handle;
1774
+ waits[1 ] = NULL ;
1775
+ wait_count = 1 ;
1776
+ if (game_process)
1777
+ {
1778
+ if ((waits[1 ] = CreateEventA (NULL , FALSE , FALSE , " PROTON_STEAM_EXE_RESTART_APP" )))
1779
+ {
1780
+ ++wait_count;
1781
+ }
1782
+ else
1783
+ {
1784
+ WINE_ERR (" Failed to create restart event, err %lu.\n " , GetLastError ());
1785
+ }
1786
+ }
1740
1787
FreeConsole ();
1741
- WaitForSingleObject (wait_handle, INFINITE);
1788
+ while ((ret = WaitForMultipleObjects (wait_count, waits, FALSE , INFINITE) != WAIT_OBJECT_0))
1789
+ {
1790
+ BOOL should_await;
1791
+
1792
+ if (ret != WAIT_OBJECT_0 + 1 )
1793
+ {
1794
+ WINE_ERR (" Wait failed.\n " );
1795
+ break ;
1796
+ }
1797
+ if (child != INVALID_HANDLE_VALUE)
1798
+ {
1799
+ if (WaitForSingleObject (child, 0 ) == WAIT_TIMEOUT)
1800
+ {
1801
+ WINE_ERR (" Child is still running, not restarting.\n " );
1802
+ continue ;
1803
+ }
1804
+ CloseHandle (child);
1805
+ }
1806
+ child = run_process (&should_await, game_process);
1807
+ }
1808
+ CloseHandle (waits[1 ]);
1742
1809
}
1743
1810
1744
1811
if (event != INVALID_HANDLE_VALUE)
0 commit comments