mirror of
https://github.com/ZDoom/Raze.git
synced 2025-02-06 15:11:13 +00:00
Just cleaning up a dump(er)
git-svn-id: https://svn.eduke32.com/eduke32@7158 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
3cfda9858d
commit
22e1c21f47
1 changed files with 39 additions and 55 deletions
|
@ -20,18 +20,13 @@ MiniDumper::MiniDumper( LPCSTR szAppName )
|
||||||
|
|
||||||
LONG MiniDumper::TopLevelFilter(struct _EXCEPTION_POINTERS *pExceptionInfo)
|
LONG MiniDumper::TopLevelFilter(struct _EXCEPTION_POINTERS *pExceptionInfo)
|
||||||
{
|
{
|
||||||
LONG retval = EXCEPTION_CONTINUE_SEARCH;
|
|
||||||
//HWND hParent = NULL; // find a better value for your app
|
|
||||||
|
|
||||||
// firstly see if dbghelp.dll is around and has the function we need
|
|
||||||
// look next to the EXE first, as the one in System32 might be old
|
|
||||||
// (e.g. Windows 2000)
|
|
||||||
HMODULE hDll = NULL;
|
HMODULE hDll = NULL;
|
||||||
char szDbgHelpPath[_MAX_PATH];
|
char szDbgHelpPath[_MAX_PATH];
|
||||||
|
|
||||||
if (GetModuleFileName(NULL, szDbgHelpPath, _MAX_PATH))
|
if (GetModuleFileName(NULL, szDbgHelpPath, _MAX_PATH))
|
||||||
{
|
{
|
||||||
char *pSlash = _tcsrchr( szDbgHelpPath, '\\' );
|
auto pSlash = _tcsrchr(szDbgHelpPath, '\\');
|
||||||
|
|
||||||
if (pSlash)
|
if (pSlash)
|
||||||
{
|
{
|
||||||
_tcscpy(pSlash + 1, "DBGHELP.DLL");
|
_tcscpy(pSlash + 1, "DBGHELP.DLL");
|
||||||
|
@ -45,40 +40,29 @@ LONG MiniDumper::TopLevelFilter( struct _EXCEPTION_POINTERS *pExceptionInfo )
|
||||||
hDll = ::LoadLibrary("DBGHELP.DLL");
|
hDll = ::LoadLibrary("DBGHELP.DLL");
|
||||||
}
|
}
|
||||||
|
|
||||||
LPCTSTR szResult = "DBGHELP.DLL not found";;
|
LONG retval = EXCEPTION_CONTINUE_SEARCH;
|
||||||
|
LPCTSTR szResult = "DBGHELP.DLL not found";
|
||||||
char szScratch[_MAX_PATH];
|
char szScratch[_MAX_PATH];
|
||||||
|
|
||||||
if (hDll)
|
if (hDll)
|
||||||
{
|
{
|
||||||
MINIDUMPWRITEDUMP pDump = (MINIDUMPWRITEDUMP)::GetProcAddress( hDll, "MiniDumpWriteDump" );
|
auto pDump = MINIDUMPWRITEDUMP(::GetProcAddress(hDll, "MiniDumpWriteDump"));
|
||||||
|
|
||||||
if (pDump)
|
if (pDump)
|
||||||
{
|
{
|
||||||
char szDumpPath[_MAX_PATH];
|
char szDumpPath[_MAX_PATH];
|
||||||
|
|
||||||
// work out a good place for the dump file
|
sprintf(szDumpPath, "%s_%u.dmp", m_szAppName, timeGetTime());
|
||||||
/*if (!GetTempPath( _MAX_PATH, szDumpPath ))
|
|
||||||
_tcscpy( szDumpPath, "c:\\temp\\" );
|
|
||||||
*/
|
|
||||||
sprintf(szDumpPath,"%s_%u",m_szAppName,timeGetTime());
|
|
||||||
_tcscat( szDumpPath, ".dmp" );
|
|
||||||
|
|
||||||
// ask the user if they want to save a dump file
|
HANDLE hFile = ::CreateFile(szDumpPath, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, 0, NULL);
|
||||||
//if (::MessageBox( NULL, "Something bad happened in your program, would you like to save a diagnostic file?", m_szAppName, MB_YESNO )==IDYES)
|
|
||||||
{
|
|
||||||
// create the file
|
|
||||||
HANDLE hFile = ::CreateFile( szDumpPath, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS,
|
|
||||||
FILE_ATTRIBUTE_NORMAL, NULL );
|
|
||||||
|
|
||||||
if (hFile != INVALID_HANDLE_VALUE)
|
if (hFile != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
_MINIDUMP_EXCEPTION_INFORMATION ExInfo;
|
_MINIDUMP_EXCEPTION_INFORMATION ExInfo = { ::GetCurrentThreadId(), pExceptionInfo, NULL };
|
||||||
|
|
||||||
ExInfo.ThreadId = ::GetCurrentThreadId();
|
// take a dump
|
||||||
ExInfo.ExceptionPointers = pExceptionInfo;
|
|
||||||
ExInfo.ClientPointers = NULL;
|
|
||||||
|
|
||||||
// write the dump
|
|
||||||
BOOL bOK = pDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpNormal, &ExInfo, NULL, NULL);
|
BOOL bOK = pDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpNormal, &ExInfo, NULL, NULL);
|
||||||
|
|
||||||
if (bOK)
|
if (bOK)
|
||||||
{
|
{
|
||||||
sprintf(szScratch, "Saved dump file to \"%s\"", szDumpPath);
|
sprintf(szScratch, "Saved dump file to \"%s\"", szDumpPath);
|
||||||
|
@ -90,6 +74,7 @@ LONG MiniDumper::TopLevelFilter( struct _EXCEPTION_POINTERS *pExceptionInfo )
|
||||||
sprintf(szScratch, "Failed to save dump file to \"%s\" (error %d)", szDumpPath, GetLastError());
|
sprintf(szScratch, "Failed to save dump file to \"%s\" (error %d)", szDumpPath, GetLastError());
|
||||||
szResult = szScratch;
|
szResult = szScratch;
|
||||||
}
|
}
|
||||||
|
|
||||||
::CloseHandle(hFile);
|
::CloseHandle(hFile);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -98,7 +83,6 @@ LONG MiniDumper::TopLevelFilter( struct _EXCEPTION_POINTERS *pExceptionInfo )
|
||||||
szResult = szScratch;
|
szResult = szScratch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
szResult = "DBGHELP.DLL too old";
|
szResult = "DBGHELP.DLL too old";
|
||||||
|
|
Loading…
Reference in a new issue