Chromium Code Reviews| 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 "chrome/install_static/install_details.h" | 10 #include "chrome/install_static/install_details.h" |
| 11 #include "chrome/install_static/install_util.h" | 11 #include "chrome/install_static/install_util.h" |
| 12 #include "chrome/install_static/product_install_details.h" | 12 #include "chrome/install_static/product_install_details.h" |
| 13 #include "chrome/install_static/user_data_dir.h" | |
| 13 #include "chrome_elf/blacklist/blacklist.h" | 14 #include "chrome_elf/blacklist/blacklist.h" |
| 14 #include "chrome_elf/crash/crash_helper.h" | 15 #include "chrome_elf/crash/crash_helper.h" |
| 15 | 16 |
| 16 // This function is a temporary workaround for https://crbug.com/655788. We | 17 // This function is a temporary workaround for https://crbug.com/655788. We |
| 17 // need to come up with a better way to initialize crash reporting that can | 18 // need to come up with a better way to initialize crash reporting that can |
| 18 // happen inside DllMain(). | 19 // happen inside DllMain(). |
| 19 void SignalInitializeCrashReporting() { | 20 void SignalInitializeCrashReporting() { |
| 20 if (!elf_crash::InitializeCrashReporting()) { | 21 if (!elf_crash::InitializeCrashReporting()) { |
| 21 #ifdef _DEBUG | 22 #ifdef _DEBUG |
| 22 assert(false); | 23 assert(false); |
| 23 #endif // _DEBUG | 24 #endif // _DEBUG |
| 24 } | 25 } |
| 25 } | 26 } |
| 26 | 27 |
| 27 void SignalChromeElf() { | 28 void SignalChromeElf() { |
| 28 blacklist::ResetBeacon(); | 29 blacklist::ResetBeacon(); |
| 29 } | 30 } |
| 30 | 31 |
| 32 extern "C" void GetUserDataDirectoryThunk(wchar_t* user_data_dir, | |
| 33 size_t user_data_dir_length, | |
| 34 wchar_t* invalid_user_data_dir, | |
| 35 size_t invalid_user_data_dir_length) { | |
| 36 std::wstring user_data_dir_str, invalid_user_data_dir_str; | |
| 37 bool ret = install_static::GetUserDataDirectory(&user_data_dir_str, | |
| 38 &invalid_user_data_dir_str); | |
| 39 assert(ret); | |
| 40 wcscpy_s(user_data_dir, user_data_dir_length, user_data_dir_str.c_str()); | |
|
grt (UTC plus 2)
2016/11/23 09:47:37
looks like this is counting on the crt's parameter
scottmg
2016/11/23 17:59:03
I think process_startup_helper.cc is fine (other t
| |
| 41 wcscpy_s(invalid_user_data_dir, invalid_user_data_dir_length, | |
| 42 invalid_user_data_dir_str.c_str()); | |
| 43 } | |
| 44 | |
| 31 // Returns the payload for the ELF's InstallDetails instance. For use by | 45 // Returns the payload for the ELF's InstallDetails instance. For use by |
| 32 // install_static::InstallDetails::InitializeFromPrimaryModule. | 46 // install_static::InstallDetails::InitializeFromPrimaryModule. |
| 33 extern "C" const install_static::InstallDetails::Payload* | 47 extern "C" const install_static::InstallDetails::Payload* |
| 34 GetInstallDetailsPayload() { | 48 GetInstallDetailsPayload() { |
| 35 return install_static::InstallDetails::Get().GetPayload(); | 49 return install_static::InstallDetails::Get().GetPayload(); |
| 36 } | 50 } |
| 37 | 51 |
| 38 BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID reserved) { | 52 BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID reserved) { |
| 39 if (reason == DLL_PROCESS_ATTACH) { | 53 if (reason == DLL_PROCESS_ATTACH) { |
| 40 install_static::InitializeProductDetailsForPrimaryModule(); | 54 install_static::InitializeProductDetailsForPrimaryModule(); |
| 41 | 55 |
| 42 // CRT on initialization installs an exception filter which calls | |
| 43 // TerminateProcess. We need to hook CRT's attempt to set an exception. | |
| 44 // NOTE: Do not hook if ASan is present, or ASan will fail to install | |
| 45 // its own unhandled exception filter. | |
| 46 #if !defined(ADDRESS_SANITIZER) | 56 #if !defined(ADDRESS_SANITIZER) |
| 57 // CRT on initialization installs an exception filter which calls | |
| 58 // TerminateProcess. We need to hook CRT's attempt to set an exception. | |
| 59 // NOTE: Do not hook if ASan is present, or ASan will fail to install | |
| 60 // its own unhandled exception filter. | |
| 47 elf_crash::DisableSetUnhandledExceptionFilter(); | 61 elf_crash::DisableSetUnhandledExceptionFilter(); |
| 48 #endif // !defined (ADDRESS_SANITIZER) | 62 #endif // !defined (ADDRESS_SANITIZER) |
| 49 | 63 |
| 50 install_static::InitializeProcessType(); | 64 install_static::InitializeProcessType(); |
| 51 | 65 |
| 52 __try { | 66 __try { |
| 53 blacklist::Initialize(false); // Don't force, abort if beacon is present. | 67 blacklist::Initialize(false); // Don't force, abort if beacon is present. |
| 54 } __except (elf_crash::GenerateCrashDump(GetExceptionInformation())) { | 68 } __except (elf_crash::GenerateCrashDump(GetExceptionInformation())) { |
| 55 } | 69 } |
| 56 } else if (reason == DLL_PROCESS_DETACH) { | 70 } else if (reason == DLL_PROCESS_DETACH) { |
| 57 elf_crash::ShutdownCrashReporting(); | 71 elf_crash::ShutdownCrashReporting(); |
| 58 } | 72 } |
| 59 return TRUE; | 73 return TRUE; |
| 60 } | 74 } |
| OLD | NEW |