1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xpcom/base/nsCrashOnException.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,41 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "nsCrashOnException.h" 1.10 +#include "nsCOMPtr.h" 1.11 +#include "nsServiceManagerUtils.h" 1.12 + 1.13 +#ifdef MOZ_CRASHREPORTER 1.14 +#include "nsICrashReporter.h" 1.15 +#endif 1.16 + 1.17 +namespace mozilla { 1.18 + 1.19 +static int ReportException(EXCEPTION_POINTERS *aExceptionInfo) 1.20 +{ 1.21 +#ifdef MOZ_CRASHREPORTER 1.22 + nsCOMPtr<nsICrashReporter> cr = 1.23 + do_GetService("@mozilla.org/toolkit/crash-reporter;1"); 1.24 + if (cr) 1.25 + cr->WriteMinidumpForException(aExceptionInfo); 1.26 +#endif 1.27 + return EXCEPTION_EXECUTE_HANDLER; 1.28 +} 1.29 + 1.30 +XPCOM_API(LRESULT) 1.31 +CallWindowProcCrashProtected(WNDPROC wndProc, HWND hWnd, UINT msg, 1.32 + WPARAM wParam, LPARAM lParam) 1.33 +{ 1.34 + MOZ_SEH_TRY { 1.35 + return wndProc(hWnd, msg, wParam, lParam); 1.36 + } 1.37 + MOZ_SEH_EXCEPT(ReportException(GetExceptionInformation())) { 1.38 + ::TerminateProcess(::GetCurrentProcess(), 253); 1.39 + } 1.40 + return 0; // not reached 1.41 +} 1.42 + 1.43 +} 1.44 +