Ejemplo n.º 1
0
void Catch_SEH_Exception(DWORD nSeCode, PEXCEPTION_POINTERS pException)
{
	g_theKernel.SetExceptionMode(true);

	//保存最后的错误代码
	DWORD	dwLastError = ::GetLastError();
	if(!pException) return;

	//生成基本描述文件
	TCHAR szSmallInfoFile[MAX_PATH] = {0};
	if(!CreateSmallDumpInfo(pException, szSmallInfoFile, dwLastError))
	{
		return;
	}

	//生成完整表述文件
	TCHAR szBigInfoFile[MAX_PATH] = {0};
	if(!CreateBigInfoFile(pException, szBigInfoFile, dwLastError))
	{
		return;
	}

	TCHAR szDumpFile[MAX_PATH] = {0};
	CreateDumpFile(pException, szDumpFile);

	//寻找CrashReport
	TCHAR szCrashReportFile[MAX_PATH] = {0};
	::GetModuleFileName(NULL, szCrashReportFile, MAX_PATH);
	::PathRemoveFileSpec(szCrashReportFile);
	::PathAppend(szCrashReportFile, _T("CrashReport.exe"));

	TCHAR szCmdLine[1024] = {0};
	_sntprintf(szCmdLine, 1024, _T("%s \"%s\" \"%s\" \"%s\""), 
		szCrashReportFile, 
		szSmallInfoFile, szBigInfoFile, szDumpFile);

	//启动CrashReport
	STARTUPINFO si;
	PROCESS_INFORMATION pi;
	ZeroMemory(&si,sizeof(STARTUPINFO));
	ZeroMemory(&pi,sizeof(PROCESS_INFORMATION));
	si.cb = sizeof(STARTUPINFO);
	si.dwFlags = STARTF_USESHOWWINDOW;
	si.wShowWindow = SW_SHOWNORMAL;

	if (::CreateProcess( NULL, szCmdLine, NULL, NULL, FALSE,CREATE_DEFAULT_ERROR_MODE, NULL, NULL, &si, &pi) == FALSE)
	{
		return;
	}
}
Ejemplo n.º 2
0
//--------------------------------------------------
// 分析SEH数据
VOID KYLIN_API tProcessException(PEXCEPTION_POINTERS pException, bool bRunCrashReport) throw()
{
	// 保存最后的错误代码
	UINT	dwLastError = ::GetLastError();
	if(!pException) 
		return;

	// 生成基本描述文件
	TCHAR szSmallInfoFile[MAX_PATH] = {0};
	if(!CreateSmallDumpInfo(pException, szSmallInfoFile, dwLastError))
	{
		return;
	}

	// 生成完整表述文件
	TCHAR szBigInfoFile[MAX_PATH] = {0};
	if(!CreateBigInfoFile(pException, szBigInfoFile, dwLastError))
	{
		return;
	}

	// 生成dump报告
	TCHAR szDumpFile[MAX_PATH] = {0};
	CreateDumpHelpFile(pException, szDumpFile);

	if(bRunCrashReport)
	{
		// 寻找ErrorReport
		TCHAR szCrashReportFile[MAX_PATH] = {0};
		::GetModuleFileName(NULL, szCrashReportFile, MAX_PATH);
		::PathRemoveFileSpec(szCrashReportFile);
		::PathAppend(szCrashReportFile, _T("ErrorReport.exe"));

		TCHAR szCmdLine[1024] = {0};
		_sntprintf(szCmdLine, 1024, _T("%s \"%s\" \"%s\" \"%s\""), szCrashReportFile, szSmallInfoFile, szBigInfoFile, szDumpFile);

		// 启动ErrorReport
		STARTUPINFO si;
		PROCESS_INFORMATION pi;
		ZeroMemory(&si,sizeof(STARTUPINFO));
		ZeroMemory(&pi,sizeof(PROCESS_INFORMATION));
		si.cb = sizeof(STARTUPINFO);
		si.dwFlags = STARTF_USESHOWWINDOW;
		si.wShowWindow = SW_SHOWNORMAL;

		::CreateProcess( NULL, szCmdLine, NULL, NULL, FALSE,CREATE_DEFAULT_ERROR_MODE, NULL, NULL, &si, &pi);
	}
}
Ejemplo n.º 3
0
INT tProcessInnerException(PEXCEPTION_POINTERS pException, HWND hParentWnd, LPCTSTR szTitle)
{
	DWORD dwLastError = ::GetLastError();

	// 生成基本描述文件
	TCHAR szSmallInfoFile[MAX_PATH] = {0};
	if(!CreateSmallDumpInfo(pException, szSmallInfoFile, dwLastError))
	{
		return 0;
	}

	// 生成dump报告
	TCHAR szDumpFile[MAX_PATH] = {0};
	CreateDumpHelpFile(pException, szDumpFile);

	g_strExceptionTitle = szTitle;
	g_strExceptionContents = szSmallInfoFile;
	g_strDumpFile = szDumpFile;

	return (INT)::DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_INNER_EXCEPTION), hParentWnd, (DLGPROC)_InnerExceptionDlgProc );

}