From 7c2bddcc98c97c87659385ca1d6535f275f7df05 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Sat, 1 Sep 2018 15:31:18 -0400 Subject: [PATCH] improve error msg --- GUI/main.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/GUI/main.cpp b/GUI/main.cpp index d6e074d..74f73d1 100644 --- a/GUI/main.cpp +++ b/GUI/main.cpp @@ -1,13 +1,20 @@ #include "mainwindow.h" +#include #include LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS* exception) { - std::wstring errorMsg(L""); - errorMsg += L"Error code: " + std::to_wstring(exception->ExceptionRecord->ExceptionCode); - errorMsg += L"\r\nError address: " + std::to_wstring((DWORD)exception->ExceptionRecord->ExceptionAddress); - errorMsg += L"\r\nAdditional info: " + std::to_wstring(exception->ExceptionRecord->ExceptionInformation[1]); - MessageBoxW(NULL, errorMsg.c_str(), L"NextHooker ERROR", MB_ICONERROR); + std::wstringstream errorMsg; + errorMsg << std::uppercase << std::hex; + errorMsg << L"Error code: " << exception->ExceptionRecord->ExceptionCode << std::endl; + errorMsg << L"Error address: " << (DWORD)exception->ExceptionRecord->ExceptionAddress << std::endl; + 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; }