mirror of
https://github.com/Artikash/Textractor.git
synced 2024-12-24 01:14:12 +08:00
39 lines
1.4 KiB
C++
39 lines
1.4 KiB
C++
#include "mainwindow.h"
|
|
#include <sstream>
|
|
#include <QApplication>
|
|
|
|
LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS* exception)
|
|
{
|
|
MEMORY_BASIC_INFORMATION info = {};
|
|
VirtualQuery(exception->ExceptionRecord->ExceptionAddress, &info, sizeof(info));
|
|
wchar_t moduleName[MAX_PATH] = {};
|
|
GetModuleFileNameW((HMODULE)info.AllocationBase, moduleName, MAX_PATH);
|
|
|
|
std::wstringstream errorMsg;
|
|
errorMsg << std::uppercase << std::hex <<
|
|
L"Error code: " << exception->ExceptionRecord->ExceptionCode << std::endl <<
|
|
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 && exception->ExceptionRecord->ExceptionInformation[2])
|
|
errorMsg << "Additional info: " << ((char****)exception->ExceptionRecord->ExceptionInformation[2])[3][1][1] + 8 << std::endl;
|
|
#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;
|
|
}
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
SetUnhandledExceptionFilter(ExceptionHandler);
|
|
QApplication a(argc, argv);
|
|
MainWindow w;
|
|
w.show();
|
|
return a.exec();
|
|
}
|