mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r10948) -Add: [win32] crash.dmp support for MSVC release builds
This commit is contained in:
parent
a66008f04c
commit
ffdbaad8ec
|
@ -29,6 +29,9 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <shlobj.h>
|
||||
#if defined(_MSC_VER) && !defined(WINCE)
|
||||
#include <dbghelp.h>
|
||||
#endif
|
||||
|
||||
static bool _has_console;
|
||||
|
||||
|
@ -592,6 +595,41 @@ static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *ep)
|
|||
}
|
||||
}
|
||||
|
||||
#if !defined(_DEBUG)
|
||||
HMODULE dbghelp = LoadLibrary(_T("dbghelp.dll"));
|
||||
if (dbghelp != NULL) {
|
||||
typedef BOOL (WINAPI *MiniDumpWriteDump_t)(HANDLE, DWORD, HANDLE,
|
||||
MINIDUMP_TYPE,
|
||||
CONST PMINIDUMP_EXCEPTION_INFORMATION,
|
||||
CONST PMINIDUMP_USER_STREAM_INFORMATION,
|
||||
CONST PMINIDUMP_CALLBACK_INFORMATION);
|
||||
MiniDumpWriteDump_t funcMiniDumpWriteDump = (MiniDumpWriteDump_t)GetProcAddress(dbghelp, "MiniDumpWriteDump");
|
||||
if (funcMiniDumpWriteDump != NULL) {
|
||||
HANDLE file = CreateFile(_T("crash.dmp"), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
|
||||
HANDLE proc = GetCurrentProcess();
|
||||
DWORD procid = GetCurrentProcessId();
|
||||
MINIDUMP_EXCEPTION_INFORMATION mdei;
|
||||
MINIDUMP_USER_STREAM userstream;
|
||||
MINIDUMP_USER_STREAM_INFORMATION musi;
|
||||
char msg[] = "****** Built on " __DATE__ " " __TIME__ ". ******";
|
||||
|
||||
userstream.Type = LastReservedStream + 1;
|
||||
userstream.Buffer = msg;
|
||||
userstream.BufferSize = sizeof(msg);
|
||||
|
||||
musi.UserStreamCount = 1;
|
||||
musi.UserStreamArray = &userstream;
|
||||
|
||||
mdei.ThreadId = GetCurrentThreadId();
|
||||
mdei.ExceptionPointers = ep;
|
||||
mdei.ClientPointers = false;
|
||||
|
||||
funcMiniDumpWriteDump(proc, procid, file, MiniDumpWithDataSegs, &mdei, &musi, NULL);
|
||||
}
|
||||
FreeLibrary(dbghelp);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Close any possible log files */
|
||||
CloseConsoleLogIfActive();
|
||||
|
||||
|
|
Loading…
Reference in New Issue