improve error msg

This commit is contained in:
Akash Mozumdar 2018-09-01 15:31:18 -04:00
parent 072840e307
commit 7c2bddcc98

View File

@ -1,13 +1,20 @@
#include "mainwindow.h" #include "mainwindow.h"
#include <sstream>
#include <QApplication> #include <QApplication>
LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS* exception) LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS* exception)
{ {
std::wstring errorMsg(L""); std::wstringstream errorMsg;
errorMsg += L"Error code: " + std::to_wstring(exception->ExceptionRecord->ExceptionCode); errorMsg << std::uppercase << std::hex;
errorMsg += L"\r\nError address: " + std::to_wstring((DWORD)exception->ExceptionRecord->ExceptionAddress); errorMsg << L"Error code: " << exception->ExceptionRecord->ExceptionCode << std::endl;
errorMsg += L"\r\nAdditional info: " + std::to_wstring(exception->ExceptionRecord->ExceptionInformation[1]); errorMsg << L"Error address: " << (DWORD)exception->ExceptionRecord->ExceptionAddress << std::endl;
MessageBoxW(NULL, errorMsg.c_str(), L"NextHooker ERROR", MB_ICONERROR); MEMORY_BASIC_INFORMATION info = {};
VirtualQuery(exception->ExceptionRecord->ExceptionAddress, &info, sizeof(info));
wchar_t name[MAX_PATH] = {};
GetModuleFileNameW((HMODULE)info.AllocationBase, name, MAX_PATH);
errorMsg << L"Error in module: " << name << std::endl;
errorMsg << L"Additional info: " << exception->ExceptionRecord->ExceptionInformation[1];
MessageBoxW(NULL, errorMsg.str().c_str(), L"NextHooker ERROR", MB_ICONERROR);
return EXCEPTION_CONTINUE_SEARCH; return EXCEPTION_CONTINUE_SEARCH;
} }