Home
>
Fresh News > Create a dmp file from the application
Create a dmp file from the application
static LPTOP_LEVEL_EXCEPTION_FILTER m_previousFilter = NULL;
typedef BOOL (WINAPI *MINIDUMPWRITEDUMP)(HANDLE hProcess, DWORD dwPid, HANDLE hFile, MINIDUMP_TYPE DumpType,
CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,
CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,
CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam);
static LONG WINAPI MyUnhandledExceptionFilter(PEXCEPTION_POINTERS pExceptionInfo)
{
HMODULE hDll = ::LoadLibrary(_T("DBGHELP.DLL"));
MINIDUMPWRITEDUMP pDump = (MINIDUMPWRITEDUMP)::GetProcAddress(hDll, "MiniDumpWriteDump");
_MINIDUMP_EXCEPTION_INFORMATION ExInfo;
ExInfo.ThreadId = ::GetCurrentThreadId();
ExInfo.ExceptionPointers = pExceptionInfo;
ExInfo.ClientPointers = NULL;
MINIDUMP_CALLBACK_INFORMATION mci;
// HANDLE hFile - minidamp file name(for example, "test.dmp")
BOOL bOK = pDump(::GetCurrentProcess(), ::GetCurrentProcessId(),
hFile, 1, &ExInfo, NULL, &mci);
}
void main()
{
// setup our own ExceptionHandler
m_previousFilter = SetUnhandledExceptionFilter(MyUnhandledExceptionFilter);
// actial work
// befoe exit
if (m_previousFilter)
{
SetUnhandledExceptionFilter(m_previousFilter);
}
}