|
Here is the sample code for Debugging
custom filters for unhandled exceptions article.
How to build and run the examples
List of examples
| MiniDump.cpp |
This example shows a simple custom filter for unhandled exceptions, which creates a minidump.
|
| MiniDumpCpp.cpp |
This example is identical to MiniDump.cpp, but raises unhandled C++ exception
instead of access violation.
|
| FilterExcept.cpp |
This example shows how to call a custom filter from __except clause,
thus making possible to debug the filter.
|
| FilterMsg.cpp |
This example demonstrates another approach to debugging custom filters -
using MessageBox to ask the user to attach debugger to the application.
|
| FilterChain.cpp |
This example shows how to implement a chain of custom filters.
|
| EnforceFilter.cpp |
This example shows how to ensure that our filter cannot be overwritten.
It is achieved by patching the beginning of SetUnhandledExceptionFilter function.
|
Download all examples
The following steps are needed to build the examples:
FilterChain and EnforceFilter examples
Create a console project and add the example's source file to the project.
Enable C++ exceptions in project settings (e.g, use /EHa compiler option).
After you have built the project, the example is ready to run.
MiniDump, MiniDumpCpp, FilterExcept and FilterMsg examples
1. Find the latest versions of DbgHelp.dll, DbgHelp.h and DbgHelp.lib files.
The latest versions of these files are always available with
Debugging Tools
for Windows package. Download and install Debugging Tools
for Windows (when installing, choose custom installation and install SDK).
2. Configure Visual Studio to find DbgHelp.h and DbgHelp.lib files.
These files are supplied with Visual Studio and Platform SDK, but it is necessary
to use the latest files – the files that come with Debugging Tools for Windows.
Thus it is necessary to configure Visual Studio include and library directories
so that the latest files will be found first.
Use the following directories:
Include -> %DebuggingTools%\sdk\inc
Library -> %DebuggingTools%\sdk\lib\i386
3. Create a console project and add the example's source file to the project.
Enable C++ exceptions in project settings (e.g, use /EHa compiler option).
4. When the project is built, make sure that the executable can find
the latest version of DbgHelp.dll.
Copy DbgHelp.dll from the installation directory of Debugging Tools
for Windows to the directory where the example executable resides.
|