OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/crash/content/app/breakpad_win.h" | 5 #include "components/crash/content/app/breakpad_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <shellapi.h> | 8 #include <shellapi.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <tchar.h> | 10 #include <tchar.h> |
11 #include <userenv.h> | 11 #include <userenv.h> |
12 #include <winnt.h> | 12 #include <winnt.h> |
13 | 13 |
14 #include <algorithm> | 14 #include <algorithm> |
15 #include <map> | 15 #include <map> |
| 16 #include <memory> |
16 #include <vector> | 17 #include <vector> |
17 | 18 |
18 #include "base/base_switches.h" | 19 #include "base/base_switches.h" |
19 #include "base/command_line.h" | 20 #include "base/command_line.h" |
20 #include "base/debug/crash_logging.h" | 21 #include "base/debug/crash_logging.h" |
21 #include "base/debug/dump_without_crashing.h" | 22 #include "base/debug/dump_without_crashing.h" |
22 #include "base/environment.h" | 23 #include "base/environment.h" |
23 #include "base/files/file_path.h" | 24 #include "base/files/file_path.h" |
24 #include "base/macros.h" | 25 #include "base/macros.h" |
25 #include "base/memory/scoped_ptr.h" | |
26 #include "base/numerics/safe_conversions.h" | 26 #include "base/numerics/safe_conversions.h" |
27 #include "base/strings/string16.h" | 27 #include "base/strings/string16.h" |
28 #include "base/strings/string_split.h" | 28 #include "base/strings/string_split.h" |
29 #include "base/strings/string_util.h" | 29 #include "base/strings/string_util.h" |
30 #include "base/strings/stringprintf.h" | 30 #include "base/strings/stringprintf.h" |
31 #include "base/strings/utf_string_conversions.h" | 31 #include "base/strings/utf_string_conversions.h" |
32 #include "base/synchronization/lock.h" | 32 #include "base/synchronization/lock.h" |
33 #include "base/win/pe_image.h" | 33 #include "base/win/pe_image.h" |
34 #include "base/win/registry.h" | 34 #include "base/win/registry.h" |
35 #include "base/win/win_util.h" | 35 #include "base/win/win_util.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 MiniDumpWithProcessThreadData | // Get PEB and TEB. | 82 MiniDumpWithProcessThreadData | // Get PEB and TEB. |
83 MiniDumpWithHandleData | // Get all handle information. | 83 MiniDumpWithHandleData | // Get all handle information. |
84 MiniDumpWithUnloadedModules); // Get unloaded modules when available. | 84 MiniDumpWithUnloadedModules); // Get unloaded modules when available. |
85 | 85 |
86 const char kPipeNameVar[] = "CHROME_BREAKPAD_PIPE_NAME"; | 86 const char kPipeNameVar[] = "CHROME_BREAKPAD_PIPE_NAME"; |
87 | 87 |
88 const wchar_t kGoogleUpdatePipeName[] = L"\\\\.\\pipe\\GoogleCrashServices\\"; | 88 const wchar_t kGoogleUpdatePipeName[] = L"\\\\.\\pipe\\GoogleCrashServices\\"; |
89 const wchar_t kChromePipeName[] = L"\\\\.\\pipe\\ChromeCrashServices"; | 89 const wchar_t kChromePipeName[] = L"\\\\.\\pipe\\ChromeCrashServices"; |
90 | 90 |
91 // This is the well known SID for the system principal. | 91 // This is the well known SID for the system principal. |
92 const wchar_t kSystemPrincipalSid[] =L"S-1-5-18"; | 92 const wchar_t kSystemPrincipalSid[] = L"S-1-5-18"; |
93 | 93 |
94 google_breakpad::ExceptionHandler* g_breakpad = NULL; | 94 google_breakpad::ExceptionHandler* g_breakpad = NULL; |
95 google_breakpad::ExceptionHandler* g_dumphandler_no_crash = NULL; | 95 google_breakpad::ExceptionHandler* g_dumphandler_no_crash = NULL; |
96 | 96 |
97 #if !defined(_WIN64) | 97 #if !defined(_WIN64) |
98 EXCEPTION_POINTERS g_surrogate_exception_pointers = {0}; | 98 EXCEPTION_POINTERS g_surrogate_exception_pointers = {0}; |
99 EXCEPTION_RECORD g_surrogate_exception_record = {0}; | 99 EXCEPTION_RECORD g_surrogate_exception_record = {0}; |
100 CONTEXT g_surrogate_context = {0}; | 100 CONTEXT g_surrogate_context = {0}; |
101 #endif // !defined(_WIN64) | 101 #endif // !defined(_WIN64) |
102 | 102 |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 old_protect, | 459 old_protect, |
460 &dummy)); | 460 &dummy)); |
461 CHECK(::VirtualProtect(g_real_terminate_process_stub, | 461 CHECK(::VirtualProtect(g_real_terminate_process_stub, |
462 sidestep::kMaxPreambleStubSize, | 462 sidestep::kMaxPreambleStubSize, |
463 old_protect, | 463 old_protect, |
464 &old_protect)); | 464 &old_protect)); |
465 } | 465 } |
466 #endif | 466 #endif |
467 | 467 |
468 static void InitPipeNameEnvVar(bool is_per_user_install) { | 468 static void InitPipeNameEnvVar(bool is_per_user_install) { |
469 scoped_ptr<base::Environment> env(base::Environment::Create()); | 469 std::unique_ptr<base::Environment> env(base::Environment::Create()); |
470 if (env->HasVar(kPipeNameVar)) { | 470 if (env->HasVar(kPipeNameVar)) { |
471 // The Breakpad pipe name is already configured: nothing to do. | 471 // The Breakpad pipe name is already configured: nothing to do. |
472 return; | 472 return; |
473 } | 473 } |
474 | 474 |
475 // Check whether configuration management controls crash reporting. | 475 // Check whether configuration management controls crash reporting. |
476 bool crash_reporting_enabled = true; | 476 bool crash_reporting_enabled = true; |
477 bool controlled_by_policy = | 477 bool controlled_by_policy = |
478 GetCrashReporterClient()->ReportingIsEnforcedByPolicy( | 478 GetCrashReporterClient()->ReportingIsEnforcedByPolicy( |
479 &crash_reporting_enabled); | 479 &crash_reporting_enabled); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 callback = &DumpDoneCallback; | 577 callback = &DumpDoneCallback; |
578 default_filter = &ServiceExceptionFilter; | 578 default_filter = &ServiceExceptionFilter; |
579 } | 579 } |
580 | 580 |
581 if (GetCrashReporterClient()->ShouldCreatePipeName(process_type)) | 581 if (GetCrashReporterClient()->ShouldCreatePipeName(process_type)) |
582 InitPipeNameEnvVar(is_per_user_install); | 582 InitPipeNameEnvVar(is_per_user_install); |
583 | 583 |
584 if (process_type == L"browser") | 584 if (process_type == L"browser") |
585 GetCrashReporterClient()->InitBrowserCrashDumpsRegKey(); | 585 GetCrashReporterClient()->InitBrowserCrashDumpsRegKey(); |
586 | 586 |
587 scoped_ptr<base::Environment> env(base::Environment::Create()); | 587 std::unique_ptr<base::Environment> env(base::Environment::Create()); |
588 std::string pipe_name_ascii; | 588 std::string pipe_name_ascii; |
589 if (!env->GetVar(kPipeNameVar, &pipe_name_ascii)) { | 589 if (!env->GetVar(kPipeNameVar, &pipe_name_ascii)) { |
590 // Breakpad is not enabled. Configuration is managed or the user | 590 // Breakpad is not enabled. Configuration is managed or the user |
591 // did not allow Google Update to send crashes. We need to use | 591 // did not allow Google Update to send crashes. We need to use |
592 // our default crash handler instead, but only for the | 592 // our default crash handler instead, but only for the |
593 // browser/service processes. | 593 // browser/service processes. |
594 if (default_filter) | 594 if (default_filter) |
595 InitDefaultCrashCallback(default_filter); | 595 InitDefaultCrashCallback(default_filter); |
596 return; | 596 return; |
597 } | 597 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 g_dumphandler_no_crash->set_consume_invalid_handle_exceptions(true); | 664 g_dumphandler_no_crash->set_consume_invalid_handle_exceptions(true); |
665 } | 665 } |
666 } | 666 } |
667 | 667 |
668 // If the user has disabled crash reporting uploads and restarted Chrome, the | 668 // If the user has disabled crash reporting uploads and restarted Chrome, the |
669 // restarted instance will still contain the pipe environment variable, which | 669 // restarted instance will still contain the pipe environment variable, which |
670 // will allow the restarted process to still upload crash reports. This function | 670 // will allow the restarted process to still upload crash reports. This function |
671 // clears the environment variable, so that the restarted Chrome, which inherits | 671 // clears the environment variable, so that the restarted Chrome, which inherits |
672 // its environment from the current Chrome, will no longer contain the variable. | 672 // its environment from the current Chrome, will no longer contain the variable. |
673 extern "C" void __declspec(dllexport) __cdecl | 673 extern "C" void __declspec(dllexport) __cdecl |
674 ClearBreakpadPipeEnvironmentVariable() { | 674 ClearBreakpadPipeEnvironmentVariable() { |
675 scoped_ptr<base::Environment> env(base::Environment::Create()); | 675 std::unique_ptr<base::Environment> env(base::Environment::Create()); |
676 env->UnSetVar(kPipeNameVar); | 676 env->UnSetVar(kPipeNameVar); |
677 } | 677 } |
678 | 678 |
679 #ifdef _WIN64 | 679 #ifdef _WIN64 |
680 int CrashForExceptionInNonABICompliantCodeRange( | 680 int CrashForExceptionInNonABICompliantCodeRange( |
681 PEXCEPTION_RECORD ExceptionRecord, | 681 PEXCEPTION_RECORD ExceptionRecord, |
682 ULONG64 EstablisherFrame, | 682 ULONG64 EstablisherFrame, |
683 PCONTEXT ContextRecord, | 683 PCONTEXT ContextRecord, |
684 PDISPATCHER_CONTEXT DispatcherContext) { | 684 PDISPATCHER_CONTEXT DispatcherContext) { |
685 EXCEPTION_POINTERS info = { ExceptionRecord, ContextRecord }; | 685 EXCEPTION_POINTERS info = { ExceptionRecord, ContextRecord }; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 extern "C" void __declspec(dllexport) __cdecl | 739 extern "C" void __declspec(dllexport) __cdecl |
740 UnregisterNonABICompliantCodeRange(void* start) { | 740 UnregisterNonABICompliantCodeRange(void* start) { |
741 ExceptionHandlerRecord* record = | 741 ExceptionHandlerRecord* record = |
742 reinterpret_cast<ExceptionHandlerRecord*>(start); | 742 reinterpret_cast<ExceptionHandlerRecord*>(start); |
743 | 743 |
744 CHECK(RtlDeleteFunctionTable(&record->runtime_function)); | 744 CHECK(RtlDeleteFunctionTable(&record->runtime_function)); |
745 } | 745 } |
746 #endif | 746 #endif |
747 | 747 |
748 } // namespace breakpad | 748 } // namespace breakpad |
OLD | NEW |