How do I get the module name that caused a structured exception given a _EXCEPTION_POINTERS struct? (win32 C++)

1k Views Asked by At

(Win32 platform c++) Using __try and __finally, how can I get the module name (And address) of the cause for an exception? I call GetExceptionInformation() but from that I am not sure where this information is.

Given other resources online and in MSDN the Minidump handlers and other sample code seem to be able to get it, but I am not sure how.

Any references or more enlightening resources are appreciated.

2

There are 2 best solutions below

0
Kim Gräsman On

You want to walk the callstack, as described in this CodeProject article.

Either you can use Jochen's code as it is, or try to harvest enough details to extract the information you want.

1
Remy Lebeau On

The EXCEPTION_RECORD record provided by EXCEPTION_POINTERS includes the address where the exception occured. You can then probably use EnumProcessModules() and GetModuleInformation() to locate the module that the exception address falls within, and then use GetModuleFileNameEx() to get that module's filename.