|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #include "nsCrashOnException.h" |
|
7 #include "nsCOMPtr.h" |
|
8 #include "nsServiceManagerUtils.h" |
|
9 |
|
10 #ifdef MOZ_CRASHREPORTER |
|
11 #include "nsICrashReporter.h" |
|
12 #endif |
|
13 |
|
14 namespace mozilla { |
|
15 |
|
16 static int ReportException(EXCEPTION_POINTERS *aExceptionInfo) |
|
17 { |
|
18 #ifdef MOZ_CRASHREPORTER |
|
19 nsCOMPtr<nsICrashReporter> cr = |
|
20 do_GetService("@mozilla.org/toolkit/crash-reporter;1"); |
|
21 if (cr) |
|
22 cr->WriteMinidumpForException(aExceptionInfo); |
|
23 #endif |
|
24 return EXCEPTION_EXECUTE_HANDLER; |
|
25 } |
|
26 |
|
27 XPCOM_API(LRESULT) |
|
28 CallWindowProcCrashProtected(WNDPROC wndProc, HWND hWnd, UINT msg, |
|
29 WPARAM wParam, LPARAM lParam) |
|
30 { |
|
31 MOZ_SEH_TRY { |
|
32 return wndProc(hWnd, msg, wParam, lParam); |
|
33 } |
|
34 MOZ_SEH_EXCEPT(ReportException(GetExceptionInformation())) { |
|
35 ::TerminateProcess(::GetCurrentProcess(), 253); |
|
36 } |
|
37 return 0; // not reached |
|
38 } |
|
39 |
|
40 } |
|
41 |