25 #if defined(_WIN32) && !defined(_WIN64) && defined(_MSC_VER)
33 using MiniDumpWriteDumpFunction = decltype(&MiniDumpWriteDump);
35 static HINSTANCE m_DbgHelp;
36 static MiniDumpWriteDumpFunction s_WriteMiniDump;
37 static wchar_t s_DumpFileName[MAX_PATH];
38 static char s_ExceptionStack[128 * 1024];
39 static MINIDUMP_TYPE s_DumpFlags = MiniDumpNormal;
47 static LONG WINAPI LastChanceExceptionFilter(__in
struct _EXCEPTION_POINTERS * a_ExceptionInfo)
49 char * newStack = &s_ExceptionStack[
sizeof(s_ExceptionStack) - 1];
59 MINIDUMP_EXCEPTION_INFORMATION ExcInformation;
60 ExcInformation.ThreadId = GetCurrentThreadId();
61 ExcInformation.ExceptionPointers = a_ExceptionInfo;
62 ExcInformation.ClientPointers = 0;
65 HANDLE dumpFile = CreateFile(s_DumpFileName, GENERIC_WRITE, 0,
nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,
nullptr);
66 s_WriteMiniDump(GetCurrentProcess(), GetCurrentProcessId(), dumpFile, s_DumpFlags, (a_ExceptionInfo) ? &ExcInformation :
nullptr,
nullptr,
nullptr);
67 CloseHandle(dumpFile);
88 m_DbgHelp = LoadLibrary(L
"DBGHELP.DLL");
89 if (m_DbgHelp == INVALID_HANDLE_VALUE)
94 s_WriteMiniDump = (MiniDumpWriteDumpFunction)GetProcAddress(m_DbgHelp,
"MiniDumpWriteDump");
95 if (s_WriteMiniDump !=
nullptr)
97 ASSERT(swprintf(s_DumpFileName,
ARRAYCOUNT(s_DumpFileName), L
"crash_mcs_%x.dmp", GetCurrentProcessId()) > 0);
98 SetUnhandledExceptionFilter(LastChanceExceptionFilter);
110 s_DumpFlags =
static_cast<MINIDUMP_TYPE
>(s_DumpFlags | MINIDUMP_TYPE::MiniDumpWithDataSegs);
115 s_DumpFlags =
static_cast<MINIDUMP_TYPE
>(s_DumpFlags | MINIDUMP_TYPE::MiniDumpWithFullMemory);
123 FreeLibrary(m_DbgHelp);
#define ARRAYCOUNT(X)
Evaluates to the number of elements in an array (compile-time!)
MiniDumpFlags
Flags to control minidump contents on supported platforms.
static void AddDumpFlags(const MiniDumpFlags)