michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsCrashOnException.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsServiceManagerUtils.h" michael@0: michael@0: #ifdef MOZ_CRASHREPORTER michael@0: #include "nsICrashReporter.h" michael@0: #endif michael@0: michael@0: namespace mozilla { michael@0: michael@0: static int ReportException(EXCEPTION_POINTERS *aExceptionInfo) michael@0: { michael@0: #ifdef MOZ_CRASHREPORTER michael@0: nsCOMPtr cr = michael@0: do_GetService("@mozilla.org/toolkit/crash-reporter;1"); michael@0: if (cr) michael@0: cr->WriteMinidumpForException(aExceptionInfo); michael@0: #endif michael@0: return EXCEPTION_EXECUTE_HANDLER; michael@0: } michael@0: michael@0: XPCOM_API(LRESULT) michael@0: CallWindowProcCrashProtected(WNDPROC wndProc, HWND hWnd, UINT msg, michael@0: WPARAM wParam, LPARAM lParam) michael@0: { michael@0: MOZ_SEH_TRY { michael@0: return wndProc(hWnd, msg, wParam, lParam); michael@0: } michael@0: MOZ_SEH_EXCEPT(ReportException(GetExceptionInformation())) { michael@0: ::TerminateProcess(::GetCurrentProcess(), 253); michael@0: } michael@0: return 0; // not reached michael@0: } michael@0: michael@0: } michael@0: