void CExceptionHandler::SetFailureReason(LPCSTR szReason, LPCSTR szLocation)
{
	if (szReason == NULL)
	{
		return;
	}

	LPSTR szExtraInformation = GetVersionInformation();

	if (szExtraInformation == NULL)
	{
		return;
	}

	stringstream szDetails;

	szDetails << szExtraInformation;

	free(szExtraInformation);
	
	szDetails << "Message=" << szReason << "\n";

	if (szLocation != NULL)
	{
		szDetails << "Location=" << szLocation << "\n";
	}

	if (g_szExtraInformation != NULL)
	{
		free(g_szExtraInformation);
	}

	g_szExtraInformation = _strdup(szDetails.str().c_str());
}
Beispiel #2
0
void ReadRegistryInformation()
  {
   DWORD theVersion;
   
   theVersion = GetVersionInformation();
   
   if (theVersion == CURRENT_VERSION)
     {
      RestoreWatchInformation();
      RestoreExecutionInformation();
      RestorePreferenceInformation();
     }
   else if (theVersion < CURRENT_VERSION)
     {
      SaveWatchInformation();
      SaveExecutionInformation();
      SavePreferenceInformation();
     }
   else 
     {
      SaveWatchInformation();
      SaveExecutionInformation();
      SavePreferenceInformation();
     }
   
   SaveVersionInformation();
  }
void CExceptionHandler::Register()
{
// (( scope ))
{
	ASSERT(g_lpExceptionHandler == NULL);

	// Build our required extra information.

	g_szExtraInformation = GetVersionInformation();

	if (g_szExtraInformation == NULL)
	{
		goto __failed;
	}

	// Find the path to create the dump files in and ensure it exists.

	wstring szCrashDumpPath(GetDirname(GetModuleFileNameEx()) + L"\\" + CRASH_DUMP_PATH);

	SetEnvironmentVariable(L"MOZ_CRASHREPORTER_DATA_DIRECTORY", szCrashDumpPath.c_str());

	DWORD dwAttr = GetFileAttributes(szCrashDumpPath.c_str());

	if (dwAttr == INVALID_FILE_ATTRIBUTES)
	{
		BOOL fResult = CreateDirectory(szCrashDumpPath.c_str(), NULL);

		if (!fResult)
		{
			goto __failed;
		}
	}

	// Set the module name as the first restart parameter so the crash
	// reporter displays the restart button.

	SetEnvironmentVariable(L"MOZ_CRASHREPORTER_RESTART_ARG_0", GetModuleFileNameEx().c_str());

	// Create the exception handler.

	g_lpExceptionHandler = new google_breakpad::ExceptionHandler(
		GetDirname(GetModuleFileNameEx()).c_str(),
		NULL,
		MinidumpCallback,
		NULL,
		google_breakpad::ExceptionHandler::HANDLER_ALL
	);

	return;
}

__failed:
	if (g_szExtraInformation != NULL)
	{
		free(g_szExtraInformation);

		g_szExtraInformation = NULL;
	}
}