Skip to content

This is a class to handle unhandled exceptions in a Windows application

License

Notifications You must be signed in to change notification settings

Furkanzmc/ExceptionHandler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ExceptionHandler

This is a class to handle unhandled exceptions in a Windowns application. This is entirely based on Jerry Coffin's code. This is just a slightly modified and easier to read version. All credit goes to Jerry Coffin. Thanks Jerry!

How to use

Don't forget to build the project with debug info. With CMake, use -DCMAKE_BUILD_TYPE=RelWithDebInfo or -DCMAKE_BUILD_TYPE=Debug

#include "ExceptionHandler.h"

LONG Win32FaultHandler(struct _EXCEPTION_POINTERS *ExInfo);
int main()
{
    SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)Win32FaultHandler);
    std::string *str = nullptr;
    str->append("s");
    return 0;
}

LONG Win32FaultHandler(struct _EXCEPTION_POINTERS *ExInfo)
{
    std::cerr << filterCrash(ExInfo);
    return EXCEPTION_EXECUTE_HANDLER;
}

Output:

Crash Reason: ACCESS VIOLATION
Walking stack.
0: main -> c:\users\furkanzmc\sourcetree\matchingjungle\proj.win32\main.cpp(20)
1: __tmainCRTStartup -> f:\dd\vctools\crt\crtw32\dllstuff\crtexe.c(626)
2: BaseThreadInitThunk -> 
3: RtlInitializeExceptionChain -> 
4: RtlInitializeExceptionChain -> 
End of stack walk.

About

This is a class to handle unhandled exceptions in a Windows application

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages