From 16e17526c770e2ab0b3855527afd6ce99ef548b5 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Tue, 9 Oct 2018 04:02:33 -0400 Subject: [PATCH] improve exception handler --- GUI/main.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/GUI/main.cpp b/GUI/main.cpp index 200f3eb..e536096 100644 --- a/GUI/main.cpp +++ b/GUI/main.cpp @@ -10,13 +10,22 @@ LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS* exception) GetModuleFileNameW((HMODULE)info.AllocationBase, moduleName, MAX_PATH); std::wstringstream errorMsg; - errorMsg << - std::uppercase << std::hex << + errorMsg << std::uppercase << std::hex << L"Error code: " << exception->ExceptionRecord->ExceptionCode << std::endl << - L"Error address: " << (DWORD)exception->ExceptionRecord->ExceptionAddress << std::endl << - L"Error in module: " << moduleName << std::endl << - L"Additional info: " << exception->ExceptionRecord->ExceptionInformation[1]; + L"Error address: " << (uint64_t)exception->ExceptionRecord->ExceptionAddress << std::endl << + L"Error in module: " << moduleName << std::endl; + +#ifndef _WIN64 + // See https://blogs.msdn.microsoft.com/oldnewthing/20100730-00/?p=13273 + if (exception->ExceptionRecord->ExceptionCode == 0xE06D7363) + errorMsg << "Additional info: " << ((char****)exception->ExceptionRecord->ExceptionInformation[2])[3][1][1] + 8 << std::endl; + else +#endif + for (int i = 0; i < exception->ExceptionRecord->NumberParameters; ++i) + errorMsg << L"Additional info: " << exception->ExceptionRecord->ExceptionInformation[i] << std::endl; + MessageBoxW(NULL, errorMsg.str().c_str(), L"Textractor ERROR", MB_ICONERROR); + return EXCEPTION_CONTINUE_SEARCH; }