From f5a3caf53631de0f25aae5615535a8a364b89461 Mon Sep 17 00:00:00 2001 From: bicarus <202771338+bicarus-dev@users.noreply.github.com> Date: Tue, 3 Feb 2026 20:08:15 -0800 Subject: [PATCH] signal: avoid spamming log with hook hit messages (#550) ## Link to GitHub Issue, if one exists n/a ## Description of change Some people have weird DLLs that keep calling `AddVectoredExceptionHandler` which ends up spamming the log. ## Testing Tested IIDX with error + signaldisable to confirm the warning message being shown, ran Polaris Chord once to check "hook hit" message. --- src/spice2x/launcher/launcher.cpp | 12 ++++++++++++ src/spice2x/launcher/signal.cpp | 19 ++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/spice2x/launcher/launcher.cpp b/src/spice2x/launcher/launcher.cpp index ed1b5d4..dd8a8d1 100644 --- a/src/spice2x/launcher/launcher.cpp +++ b/src/spice2x/launcher/launcher.cpp @@ -1385,6 +1385,18 @@ int main_implementation(int argc, char *argv[]) { ); } + if (launcher::signal::DISABLE && !cfg::CONFIGURATOR_STANDALONE) { + log_warning( + "launcher", + "WARNING - user specified -signaldisable option\n\n\n" + "!!! !!!\n" + "!!! Using -signaldisable option disables all exception handling, !!!\n" + "!!! which means when the game crashes it will likely just vanish !!!\n" + "!!! without troubleshooting information in the logs. !!!\n" + "!!! !!!\n" + ); + } + if (options[launcher::Options::FullscreenResolution].is_active()) { std::pair result; if (parse_width_height(options[launcher::Options::FullscreenResolution].value_text(), result)) { diff --git a/src/spice2x/launcher/signal.cpp b/src/spice2x/launcher/signal.cpp index a0eebe5..764b269 100644 --- a/src/spice2x/launcher/signal.cpp +++ b/src/spice2x/launcher/signal.cpp @@ -185,21 +185,30 @@ static LONG WINAPI TopLevelExceptionFilter(struct _EXCEPTION_POINTERS *Exception } static BOOL WINAPI SetConsoleCtrlHandler_hook(PHANDLER_ROUTINE pHandlerRoutine, BOOL Add) { - log_misc("signal", "SetConsoleCtrlHandler hook hit"); + static std::once_flag printed; + std::call_once(printed, []() { + log_misc("signal", "SetConsoleCtrlHandler hook hit (printing once)"); + }); return TRUE; } static LPTOP_LEVEL_EXCEPTION_FILTER WINAPI SetUnhandledExceptionFilter_hook( - LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter) -{ - log_info("signal", "SetUnhandledExceptionFilter hook hit"); + LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter) { + + static std::once_flag printed; + std::call_once(printed, []() { + log_info("signal", "SetUnhandledExceptionFilter hook hit (printing once)"); + }); return nullptr; } static PVOID WINAPI AddVectoredExceptionHandler_hook(ULONG First, PVECTORED_EXCEPTION_HANDLER Handler) { - log_info("signal", "AddVectoredExceptionHandler hook hit"); + static std::once_flag printed; + std::call_once(printed, []() { + log_info("signal", "AddVectoredExceptionHandler hook hit (printing once)"); + }); return launcher::signal::USE_VEH_WORKAROUND ? INVALID_HANDLE_VALUE : nullptr; }