Sign in to follow this  
The C modest god


Recommended Posts

I catch C exceptions in windows, convert them into C++ exceptions and then use MiniDumpWriteDump to write a dump file with the data from the C exception including the call stack. What I want to do is create a dump file that will point into somewhere in my code eventhough a C exception didnt occur. Including the call stack. So basically I would want a function that when called it will save data that will be used later to create a dump file. When loading this dump file into WinDbg and using the .ecxr command, it will point on the function that was called to create this data. Do you know how to do it? Thanks in advance.

Share this post

Link to post
Share on other sites
Just fire a dummy exception and send the information to MiniDumpWriteDump. The MSDN page for MiniDumpWriteDump describes how to do this.

By the way, there's no such thing as a "C exception." The exceptions you are handling (with __try, __except) are called structured exceptions. They're a service of the Windows platform and the Microsoft compilers (with some exceptions generated by hardware such as the CPU), not a particular language. Again MSDN has a good overview of how it all works.

Share this post

Link to post
Share on other sites
I have a problem.
I use:

static void
se_translator (unsigned int e, PEXCEPTION_POINTERS p)
WindowsError WinErr;

WinErr.Ptr = p;
throw WinErr;

This is used with the _set_se_translator function.
In order to retrieve the PEXCEPTION_POINTERS which will be used in the write mini dump.
When I do this on my general try, it works.
However, when I do:

ErrorHandle::BreakPlaceFunction ()

int i;

catch (const WindowsError & WinExp) {
Ptr = WinExp.Ptr;
return Ptr;

In order to catch a place in the code, I have a problem.
This is because it is done inside the main try{}catch{}, and when I reach the place where I do writeminidump, the content of the pointers of PEXCEPTION_POINTERS is lost!
PEXCEPTION_POINTERS is a pointer, and I dont know who allocated the data it points to and when does it being released.
I dont think its a class, in a sence it has a not default dtr.
So what should I do?
Copy all the internal structre of the PEXCEPTION_POINTERS?
Is there an elegant way to deal with this?

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this