<!-- Link to demo file download -->
Download demo project - 24 Kb
<!-- Article image -->
When dealing with application crashes, customers don't always send details of the crash
when they report problems. They often don't realise they have to press the Details button,
they dont tell you which version it is, or they might get Dr Watson dumps. Either way, you
get either too much information, or not enough.
Having seen Martin Ziacek's article "SEH and C++ Exceptions - catch all in one" article, this
provided me with a method to get better application crash handling.
Martin's article shows how to gain control after an Exception, what was needed was to
present the information to the user. Firstly I added some code to traverse the stack
in a backwards fashion, and collect all the adresses of all the calls.
void SeTranslator(UINT nSeCode, _EXCEPTION_POINTERS* pExcPointers)
CSeException *se = new CSeException(nSeCode, pExcPointers);
DWORD * sp = (DWORD *)(pExcPointers->ContextRecord->Ebp);
if(!IsBadReadPtr(sp,sizeof(DWORD)) && *sp)
DWORD *np = (DWORD *)*sp;
se->m_StackTrace[i] = *(sp+1);
sp = np;
se->m_StackTrace[i] = 0;
This way, when the application regains control after the
stack at the time of the crash is known.
All that is needed now is to present the crash details to the user. This is done by deriving
your application object from
CDumpHandleApp instead of
CDumpHandleApp does the rest. In the
InitInstance you need to add a
call to the base class
CDumpHandleApp::InitInstance and to set the support email
m_strSupportEmail = "email@example.com";