crashhandler: immediately terminate the game in release mode

This commit is contained in:
goat 2024-06-17 21:23:31 +02:00
parent 5f51ca22e0
commit 979f78a8b6

View file

@ -965,7 +965,7 @@ int main() {
const TASKDIALOG_BUTTON buttons[]{
{IdButtonRestart, L"Restart\nRestart the game with the above-selected option."},
{IdButtonSaveTsPack, L"Save Troubleshooting Info\nSave a .tspack file containing information about this crash for analysis."},
{IdButtonExit, L"Exit\nExit the game."},
{IdButtonExit, L"Exit\nExit without doing anything."},
};
config.cbSize = sizeof(config);
@ -1061,11 +1061,20 @@ int main() {
pProgressDialog = NULL;
}
const auto kill_game = [&] { TerminateProcess(g_hProcess, exinfo.ExceptionRecord.ExceptionCode); };
if (shutup) {
TerminateProcess(g_hProcess, exinfo.ExceptionRecord.ExceptionCode);
kill_game();
return 0;
}
#if !_DEBUG
// In release mode, we can't resume the game, so just kill it. It's not safe to keep it running, as we
// don't know what state it's in and it may have crashed off-thread.
// Additionally, if the main thread crashed, Windows will show the ANR dialog, which will block our dialog.
kill_game();
#endif
int nButtonPressed = 0, nRadioButton = 0;
if (FAILED(TaskDialogIndirect(&config, &nButtonPressed, &nRadioButton, nullptr))) {
SetEvent(exinfo.hEventHandle);
@ -1073,7 +1082,7 @@ int main() {
switch (nButtonPressed) {
case IdButtonRestart:
{
TerminateProcess(g_hProcess, exinfo.ExceptionRecord.ExceptionCode);
kill_game();
restart_game_using_injector(nRadioButton, *launcherArgs);
break;
}
@ -1081,7 +1090,7 @@ int main() {
if (attemptResume)
SetEvent(exinfo.hEventHandle);
else
TerminateProcess(g_hProcess, exinfo.ExceptionRecord.ExceptionCode);
kill_game();
}
}
}