From 0568563776f6b3c6a787b22ff54cff93731a49be Mon Sep 17 00:00:00 2001 From: rarified Date: Sat, 11 Jul 2020 19:50:03 -0600 Subject: [PATCH] Remove trap for avoiding debugger on client. Add exception handlers for pure function call traps (Cherry picked from 3fe3a1d H-uru/Plasma "Catch moar crashes") --- .../Sources/Plasma/Apps/plClient/plClient.cpp | 2 +- .../Sources/Plasma/Apps/plClient/winmain.cpp | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/plClient.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/plClient.cpp index de055c59..bcffb4e4 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/plClient.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/plClient.cpp @@ -1656,7 +1656,7 @@ hsBool plClient::MainLoop() } #endif -#ifdef PLASMA_EXTERNAL_RELEASE +#if defined(PLASMA_EXTERNAL_RELEASE) && defined(PLASMA_EXTERNAL_NODEBUGGER) if (DebugIsDebuggerPresent()) { NetCliAuthLogClientDebuggerConnect(); diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/winmain.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/winmain.cpp index 743427e7..cd1d7598 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/winmain.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/winmain.cpp @@ -231,6 +231,24 @@ const GUID NEXUS_GUID = { 0x5bfdb060, 0x6a4, 0x11d0, 0x9c, 0x4f, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e}; #endif +//============================================================================== +// Debugger hooks for common untracable faults + +#ifdef _MSC_VER +#include + +static void IInvalidParameter(const wchar_t* expression, const wchar_t* function, const wchar_t* file, unsigned int line, uintptr_t) +{ + __debugbreak(); +} + +static void IPureVirtualCall() +{ + __debugbreak(); +} + +#endif // _MSC_VER + // Detect whether we're running under TRANSGAMING Cider //============================================================================== @@ -1967,6 +1985,14 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nC // Reestablish exception handler after PhysX stole it SetUnhandledExceptionFilter( plCustomUnhandledExceptionFilter ); +#ifdef _MSC_VER + // Sigh... The Visual C++ Runtime likes to throw up dialogs sometimes. + // The user cares not about dialogs. We just want to get a minidump... + // See: http://www.altdevblogaday.com/2012/07/20/more-adventures-in-failing-to-crash-properly/ + _set_invalid_parameter_handler(IInvalidParameter); + _set_purecall_handler(IPureVirtualCall); +#endif // _MSC_VER + // I want it on top! I mean it! BringWindowToTop( gClient->GetWindowHandle() );