| 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 "chrome_elf/chrome_elf_main.h" | 5 #include "chrome_elf/chrome_elf_main.h" |
| 6 | 6 |
| 7 #include <assert.h> | 7 #include <assert.h> |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 | 9 |
| 10 #include "base/message_loop/message_pump_win.h" |
| 10 #include "chrome/install_static/install_util.h" | 11 #include "chrome/install_static/install_util.h" |
| 11 #include "chrome_elf/blacklist/blacklist.h" | 12 #include "chrome_elf/blacklist/blacklist.h" |
| 12 #include "chrome_elf/crash/crash_helper.h" | 13 #include "chrome_elf/crash/crash_helper.h" |
| 13 | 14 |
| 14 // This function is a temporary workaround for https://crbug.com/655788. We | 15 // This function is a temporary workaround for https://crbug.com/655788. We |
| 15 // need to come up with a better way to initialize crash reporting that can | 16 // need to come up with a better way to initialize crash reporting that can |
| 16 // happen inside DllMain(). | 17 // happen inside DllMain(). |
| 17 void SignalInitializeCrashReporting() { | 18 void SignalInitializeCrashReporting() { |
| 18 if (!elf_crash::InitializeCrashReporting()) { | 19 if (!elf_crash::InitializeCrashReporting()) { |
| 19 #ifdef _DEBUG | 20 #ifdef _DEBUG |
| 20 assert(false); | 21 assert(false); |
| 21 #endif // _DEBUG | 22 #endif // _DEBUG |
| 22 } | 23 } |
| 23 } | 24 } |
| 24 | 25 |
| 25 void SignalChromeElf() { | 26 void SignalChromeElf() { |
| 26 blacklist::ResetBeacon(); | 27 blacklist::ResetBeacon(); |
| 27 } | 28 } |
| 28 | 29 |
| 29 BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID reserved) { | 30 BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID reserved) { |
| 31 base::MessagePumpForUI this_is_a_bad_idea; |
| 32 |
| 30 if (reason == DLL_PROCESS_ATTACH) { | 33 if (reason == DLL_PROCESS_ATTACH) { |
| 31 // CRT on initialization installs an exception filter which calls | 34 // CRT on initialization installs an exception filter which calls |
| 32 // TerminateProcess. We need to hook CRT's attempt to set an exception. | 35 // TerminateProcess. We need to hook CRT's attempt to set an exception. |
| 33 // NOTE: Do not hook if ASan is present, or ASan will fail to install | 36 // NOTE: Do not hook if ASan is present, or ASan will fail to install |
| 34 // its own unhandled exception filter. | 37 // its own unhandled exception filter. |
| 35 #if !defined(ADDRESS_SANITIZER) | 38 #if !defined(ADDRESS_SANITIZER) |
| 36 elf_crash::DisableSetUnhandledExceptionFilter(); | 39 elf_crash::DisableSetUnhandledExceptionFilter(); |
| 37 #endif // !defined (ADDRESS_SANITIZER) | 40 #endif // !defined (ADDRESS_SANITIZER) |
| 38 | 41 |
| 39 install_static::InitializeProcessType(); | 42 install_static::InitializeProcessType(); |
| 40 | 43 |
| 41 __try { | 44 __try { |
| 42 blacklist::Initialize(false); // Don't force, abort if beacon is present. | 45 blacklist::Initialize(false); // Don't force, abort if beacon is present. |
| 43 } __except (elf_crash::GenerateCrashDump(GetExceptionInformation())) { | 46 } __except (elf_crash::GenerateCrashDump(GetExceptionInformation())) { |
| 44 } | 47 } |
| 45 } else if (reason == DLL_PROCESS_DETACH) { | 48 } else if (reason == DLL_PROCESS_DETACH) { |
| 46 elf_crash::ShutdownCrashReporting(); | 49 elf_crash::ShutdownCrashReporting(); |
| 47 } | 50 } |
| 48 return TRUE; | 51 return TRUE; |
| 49 } | 52 } |
| OLD | NEW |