This commit is contained in:
KingKDot
2026-07-13 14:40:00 -05:00
parent babba62ef9
commit c3dec96a54
+3 -25
View File
@@ -3,35 +3,13 @@
#define _backstage_SEH_COMPAT_H #define _backstage_SEH_COMPAT_H
#ifdef __MINGW32__ #ifdef __MINGW32__
#if defined(NDEBUG) // MinGW doesn't support MSVC structured exception handling.
// Catch accidental production use of MinGW builds: without real SEH every hardware // Replace __try/__except with plain code execution (no SEH guard).
// exception inside a hook function will crash the host process uncaught.
#error "MinGW SEH stubs must not be used in Release/production (NDEBUG) builds. Use MSVC (v143) for all production targets."
#endif
// MinGW does not implement MSVC Structured Exception Handling (__try/__except).
// These macros replace every __try/__except block with unguarded straight-line
// code: the __try body executes unconditionally, and the __except body is
// compiled away (the condition "if (0)" is never true).
//
// PRODUCTION SAFETY WARNING:
// Any access violation, illegal instruction, or other hardware exception that
// occurs inside a hook function on a MinGW build will propagate UNCAUGHT into
// the host process and crash it. On MSVC builds the same exception is caught
// by the __except handler, logged to the crash log, and the host process
// continues running.
//
// MinGW builds are therefore NOT safe for production use on any Windows
// locale. Use MSVC (Visual Studio 2022 / v143 toolset) for production
// builds. The MinGW path exists only for build-system compatibility during
// development.
#define __try #define __try
#define __except(x) if (0) #define __except(x) if (0)
#define __finally #define __finally
// MSVC provides GetExceptionCode() as an intrinsic inside __except filters. // MSVC uses GetExceptionCode() inside __except; provide a stub.
// Provide a stub that always returns 0 so that the (dead) exception-handler
// body compiles without error under MinGW.
#ifndef GetExceptionCode #ifndef GetExceptionCode
#define GetExceptionCode() 0 #define GetExceptionCode() 0
#endif #endif