diff --git a/PowerEditor/src/MISC/Exception/Win32Exception.cpp b/PowerEditor/src/MISC/Exception/Win32Exception.cpp index 5f9029f5..cb129c32 100644 --- a/PowerEditor/src/MISC/Exception/Win32Exception.cpp +++ b/PowerEditor/src/MISC/Exception/Win32Exception.cpp @@ -7,10 +7,11 @@ #include "Win32Exception.h" #include "eh.h" -Win32Exception::Win32Exception(const EXCEPTION_RECORD * info) { - _location = info->ExceptionAddress; - _code = info->ExceptionCode; - switch (info->ExceptionCode) { +Win32Exception::Win32Exception(EXCEPTION_POINTERS * info) { + _location = info->ExceptionRecord->ExceptionAddress; + _code = info->ExceptionRecord->ExceptionCode; + _info = info; + switch (_code) { case EXCEPTION_ACCESS_VIOLATION: _event = "Access violation"; break; @@ -35,14 +36,14 @@ void Win32Exception::translate(unsigned code, EXCEPTION_POINTERS * info) { // Windows guarantees that *(info->ExceptionRecord) is valid switch (code) { case EXCEPTION_ACCESS_VIOLATION: - throw Win32AccessViolation(info->ExceptionRecord); + throw Win32AccessViolation(info); break; default: - throw Win32Exception(info->ExceptionRecord); + throw Win32Exception(info); } } -Win32AccessViolation::Win32AccessViolation(const EXCEPTION_RECORD * info) : Win32Exception(info) { - _isWrite = info->ExceptionInformation[0] == 1; - _badAddress = reinterpret_cast(info->ExceptionInformation[1]); +Win32AccessViolation::Win32AccessViolation(EXCEPTION_POINTERS * info) : Win32Exception(info) { + _isWrite = info->ExceptionRecord->ExceptionInformation[0] == 1; + _badAddress = reinterpret_cast(info->ExceptionRecord->ExceptionInformation[1]); } diff --git a/PowerEditor/src/MISC/Exception/Win32Exception.h b/PowerEditor/src/MISC/Exception/Win32Exception.h index 651388f8..47dc2846 100644 --- a/PowerEditor/src/MISC/Exception/Win32Exception.h +++ b/PowerEditor/src/MISC/Exception/Win32Exception.h @@ -16,16 +16,19 @@ public: static void removeHandler(); virtual const char* what() const throw() { return _event; }; ExceptionAddress where() const { return _location; }; - unsigned code() const { return _code; }; - + unsigned int code() const { return _code; }; + EXCEPTION_POINTERS* info() const { return _info; }; + protected: - Win32Exception(const EXCEPTION_RECORD * info); //Constructor only accessible by exception handler + Win32Exception(EXCEPTION_POINTERS * info); //Constructor only accessible by exception handler static void translate(unsigned code, EXCEPTION_POINTERS * info); private: const char * _event; ExceptionAddress _location; unsigned int _code; + + EXCEPTION_POINTERS * _info; }; class Win32AccessViolation: public Win32Exception @@ -34,7 +37,7 @@ public: bool isWrite() const { return _isWrite; }; ExceptionAddress badAddress() const { return _badAddress; }; private: - Win32AccessViolation(const EXCEPTION_RECORD * info); + Win32AccessViolation(EXCEPTION_POINTERS * info); bool _isWrite; ExceptionAddress _badAddress; diff --git a/PowerEditor/src/winmain.cpp b/PowerEditor/src/winmain.cpp index b74cfacb..b88885c8 100644 --- a/PowerEditor/src/winmain.cpp +++ b/PowerEditor/src/winmain.cpp @@ -21,6 +21,7 @@ #include //default C++ exception #include "Win32Exception.h" //Win32 exception +#include "MiniDumper.h" //Write dump files typedef std::vector ParamVector; @@ -148,6 +149,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR cmdLineAnsi, int nCmdSh ParamVector params; parseCommandLine(cmdLine, params); + MiniDumper mdump(); //for debugging purposes. + bool TheFirstOne = true; ::SetLastError(NO_ERROR); ::CreateMutex(NULL, false, TEXT("nppInstance")); @@ -318,6 +321,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR cmdLineAnsi, int nCmdSh #endif ex.code(), ex.what(), ex.where()); printMsg(message, TEXT("Win32Exception"), MB_OK | MB_ICONERROR); + mdump.writeDump(ex.info()); doException(notepad_plus_plus); } catch(std::exception ex) { #ifdef UNICODE