views:

104

answers:

2

(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.

+1  A: 

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.

Kim Gräsman
I'll look into that, thanks.
Tim
+3  A: 

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.

Remy Lebeau - TeamB
For some reason, even though I saw that I have access to the address I didn't think of using those calls - for some reason I thought there was information hidden somewhere, but I guess that would work and is possibly what other code is doing under the covers.
Tim