diff --git a/win32/lib/crt1.c b/win32/lib/crt1.c index 0e04fc0..e0ec5d5 100644 --- a/win32/lib/crt1.c +++ b/win32/lib/crt1.c @@ -4,6 +4,7 @@ // _UNICODE for tchar.h, UNICODE for API #include +#include #include #include @@ -37,9 +38,19 @@ extern int _tmain(int argc, _TCHAR * argv[], _TCHAR * env[]); /* Allow command-line globbing with "int _dowildcard = 1;" in the user source */ int _dowildcard; +#ifdef __x86_64__ +static LONG WINAPI catch_sig(EXCEPTION_POINTERS *ex) +{ + return _XcptFilter(ex->ExceptionRecord->ExceptionCode, ex); +} +#endif + void _tstart(void) { __TRY__ +#ifdef __x86_64__ + SetUnhandledExceptionFilter(catch_sig); +#endif _startupinfo start_info = {0}; // Sets the current application type diff --git a/win32/lib/wincrt1.c b/win32/lib/wincrt1.c index ce3a63f..bad3d95 100644 --- a/win32/lib/wincrt1.c +++ b/win32/lib/wincrt1.c @@ -26,6 +26,13 @@ int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int); typedef struct { int newmode; } _startupinfo; int __cdecl __tgetmainargs(int *pargc, _TCHAR ***pargv, _TCHAR ***penv, int globb, _startupinfo*); +#ifdef __x86_64__ +static LONG WINAPI catch_sig(EXCEPTION_POINTERS *ex) +{ + return _XcptFilter(ex->ExceptionRecord->ExceptionCode, ex); +} +#endif + static int go_winmain(TCHAR *arg1) { STARTUPINFO si; @@ -54,6 +61,9 @@ static int go_winmain(TCHAR *arg1) int _twinstart(void) { __TRY__ +#ifdef __x86_64__ + SetUnhandledExceptionFilter(catch_sig); +#endif _startupinfo start_info_con = {0}; __set_app_type(__GUI_APP); __tgetmainargs(&__argc, &__targv, &_tenviron, 0, &start_info_con);