@@ -414,7 +414,7 @@ void error_redirect( const gchar *domain, GLogLevelFlags log_level, const gchar
414414#define GETTEXT_PACKAGE " radiant"
415415#define LOCALEDIR " lang"
416416
417- int main ( int argc, char * argv[] ) {
417+ int mainRadiant ( int argc, char * argv[] ) {
418418 const char *libgl;
419419 int i, j, k;
420420
@@ -923,6 +923,76 @@ int main( int argc, char* argv[] ) {
923923 return 0 ;
924924}
925925
926+
927+ #if defined( _WIN32 ) && defined( _MSC_VER )
928+ #include < dbghelp.h>
929+ #include < shellapi.h>
930+ #include < shlobj.h>
931+ #include < strsafe.h> // StringCchPrintf
932+
933+ int GenerateDump ( EXCEPTION_POINTERS* pExceptionPointers ) {
934+ BOOL bMiniDumpSuccessful;
935+ char szPath[MAX_PATH];
936+ char szFileName[MAX_PATH];
937+ char szAppName[] = " GTKRadiant" ;
938+ char * szVersion = RADIANT_VERSION;
939+ DWORD dwBufferSize = MAX_PATH;
940+ HANDLE hDumpFile;
941+ SYSTEMTIME stLocalTime;
942+ MINIDUMP_EXCEPTION_INFORMATION ExpParam;
943+
944+ GetLocalTime ( &stLocalTime );
945+ GetTempPath ( dwBufferSize, szPath );
946+
947+ StringCchPrintf ( szFileName, MAX_PATH, " %s%s" , szPath, szAppName );
948+ CreateDirectory ( szFileName, NULL );
949+
950+ StringCchPrintf ( szFileName, MAX_PATH, " %s%s\\ %s-%s-%04d%02d%02d-%02d%02d%02d.dmp" ,
951+ szPath, szAppName, szAppName, szVersion,
952+ stLocalTime.wYear , stLocalTime.wMonth , stLocalTime.wDay ,
953+ stLocalTime.wHour , stLocalTime.wMinute , stLocalTime.wSecond );
954+ hDumpFile = CreateFile (szFileName, GENERIC_READ|GENERIC_WRITE,
955+ FILE_SHARE_WRITE|FILE_SHARE_READ, 0 , CREATE_ALWAYS, 0 , 0 );
956+
957+ ExpParam.ThreadId = GetCurrentThreadId ();
958+ ExpParam.ExceptionPointers = pExceptionPointers;
959+ ExpParam.ClientPointers = TRUE ;
960+
961+ bMiniDumpSuccessful = MiniDumpWriteDump (GetCurrentProcess (), GetCurrentProcessId (),
962+ hDumpFile, MiniDumpWithDataSegs, &ExpParam, NULL , NULL );
963+
964+ return EXCEPTION_EXECUTE_HANDLER;
965+ }
966+ #endif
967+
968+ int main ( int argc, char * argv[] ) {
969+
970+ #if defined( _WIN32 ) && defined( _MSC_VER )
971+ __try {
972+ return mainRadiant ( argc, argv );
973+ } __except ( GenerateDump ( GetExceptionInformation () ) ) {
974+
975+ char szPath[MAX_PATH];
976+ char szText[MAX_PATH];
977+ char szFileName[MAX_PATH];
978+ char szAppName[] = " GTKRadiant" ;
979+ SYSTEMTIME stLocalTime;
980+ DWORD dwBufferSize = MAX_PATH;
981+
982+ GetLocalTime ( &stLocalTime );
983+ GetTempPath ( dwBufferSize, szPath );
984+
985+ StringCchPrintf ( szFileName, MAX_PATH, " %s%s" , szPath, szAppName );
986+
987+ StringCchPrintf ( szText, MAX_PATH, _ (" Application crashed!\n Created a dump file in: \n %s" ), szFileName );
988+
989+ MessageBox ( NULL , szText, NULL , MB_ICONERROR );
990+ }
991+ #else
992+ return mainRadiant ( argc, argv );
993+ #endif
994+ }
995+
926996// ydnar: quick and dirty fix, just make the buffer bigger
927997#define BIG_PATH_MAX 4096
928998
0 commit comments