]> git.sesse.net Git - casparcg/blobdiff - shell/main.cpp
2.0. main: Added unhandled exception filter.
[casparcg] / shell / main.cpp
index 1b20e818c724426a8afa64abc5829250d4ecfb83..e5766290891cc3b8e03417873998cb12d08712c8 100644 (file)
@@ -36,6 +36,7 @@
 #define WIN32_LEAN_AND_MEAN\r
 \r
 #include <windows.h>\r
+#include <winnt.h>\r
 #include <mmsystem.h>\r
 #include <atlbase.h>\r
 \r
@@ -143,11 +144,25 @@ void print_info()
        CASPAR_LOG(info) << L"FFMPEG-swscale "  << caspar::get_swscale_version();\r
        CASPAR_LOG(info) << L"OpenGL " << caspar::core::ogl_device::get_version() << "\n\n";\r
 }\r
\r
+\r
+LONG WINAPI UserUnhandledExceptionFilter(EXCEPTION_POINTERS* info)\r
+{\r
+       CASPAR_LOG(fatal) << L"#######################\n UNHANDLED EXCEPTION: \n" \r
+               << L"Adress:" << info->ExceptionRecord->ExceptionAddress << L"\n"\r
+               << L"Code:" << info->ExceptionRecord->ExceptionCode << L"\n"\r
+               << L"Flag:" << info->ExceptionRecord->ExceptionFlags << L"\n"\r
+               << L"Info:" << info->ExceptionRecord->ExceptionInformation << L"\n"\r
+               << L"Continuing execution. \n#######################";\r
+\r
+    return EXCEPTION_CONTINUE_EXECUTION;\r
+}\r
+\r
 int main(int argc, wchar_t* argv[])\r
 {      \r
        static_assert(sizeof(void*) == 4, "64-bit code generation is not supported.");\r
        \r
+       SetUnhandledExceptionFilter(UserUnhandledExceptionFilter);\r
+\r
        CASPAR_LOG(info) << L"Type \"q\" to close application";\r
 \r
        CASPAR_LOG(info) << L"THIS IS AN ALPHA BUILD";\r