Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: chrome_elf/chrome_elf_main.cc

Issue 2549593002: Revert of Make Crashpad use the user data dir, rather than always default location (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome_elf/chrome_elf.def ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
14 #include "chrome_elf/blacklist/blacklist.h" 13 #include "chrome_elf/blacklist/blacklist.h"
15 #include "chrome_elf/crash/crash_helper.h" 14 #include "chrome_elf/crash/crash_helper.h"
16 15
17 // This function is a temporary workaround for https://crbug.com/655788. We 16 // This function is a temporary workaround for https://crbug.com/655788. We
18 // need to come up with a better way to initialize crash reporting that can 17 // need to come up with a better way to initialize crash reporting that can
19 // happen inside DllMain(). 18 // happen inside DllMain().
20 void SignalInitializeCrashReporting() { 19 void SignalInitializeCrashReporting() {
21 if (!elf_crash::InitializeCrashReporting()) { 20 if (!elf_crash::InitializeCrashReporting()) {
22 #ifdef _DEBUG 21 #ifdef _DEBUG
23 assert(false); 22 assert(false);
24 #endif // _DEBUG 23 #endif // _DEBUG
25 } 24 }
26 } 25 }
27 26
28 void SignalChromeElf() { 27 void SignalChromeElf() {
29 blacklist::ResetBeacon(); 28 blacklist::ResetBeacon();
30 } 29 }
31 30
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 install_static::IgnoreUnused(ret);
41 wcsncpy_s(user_data_dir, user_data_dir_length, user_data_dir_str.c_str(),
42 _TRUNCATE);
43 wcsncpy_s(invalid_user_data_dir, invalid_user_data_dir_length,
44 invalid_user_data_dir_str.c_str(), _TRUNCATE);
45 }
46
47 // Returns the payload for the ELF's InstallDetails instance. For use by 31 // Returns the payload for the ELF's InstallDetails instance. For use by
48 // install_static::InstallDetails::InitializeFromPrimaryModule. 32 // install_static::InstallDetails::InitializeFromPrimaryModule.
49 extern "C" const install_static::InstallDetails::Payload* 33 extern "C" const install_static::InstallDetails::Payload*
50 GetInstallDetailsPayload() { 34 GetInstallDetailsPayload() {
51 return install_static::InstallDetails::Get().GetPayload(); 35 return install_static::InstallDetails::Get().GetPayload();
52 } 36 }
53 37
54 BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID reserved) { 38 BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID reserved) {
55 if (reason == DLL_PROCESS_ATTACH) { 39 if (reason == DLL_PROCESS_ATTACH) {
56 install_static::InitializeProductDetailsForPrimaryModule(); 40 install_static::InitializeProductDetailsForPrimaryModule();
57 41
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.
58 #if !defined(ADDRESS_SANITIZER) 46 #if !defined(ADDRESS_SANITIZER)
59 // CRT on initialization installs an exception filter which calls
60 // TerminateProcess. We need to hook CRT's attempt to set an exception.
61 // NOTE: Do not hook if ASan is present, or ASan will fail to install
62 // its own unhandled exception filter.
63 elf_crash::DisableSetUnhandledExceptionFilter(); 47 elf_crash::DisableSetUnhandledExceptionFilter();
64 #endif // !defined (ADDRESS_SANITIZER) 48 #endif // !defined (ADDRESS_SANITIZER)
65 49
66 install_static::InitializeProcessType(); 50 install_static::InitializeProcessType();
67 51
68 __try { 52 __try {
69 blacklist::Initialize(false); // Don't force, abort if beacon is present. 53 blacklist::Initialize(false); // Don't force, abort if beacon is present.
70 } __except (elf_crash::GenerateCrashDump(GetExceptionInformation())) { 54 } __except (elf_crash::GenerateCrashDump(GetExceptionInformation())) {
71 } 55 }
72 } else if (reason == DLL_PROCESS_DETACH) { 56 } else if (reason == DLL_PROCESS_DETACH) {
73 elf_crash::ShutdownCrashReporting(); 57 elf_crash::ShutdownCrashReporting();
74 } 58 }
75 return TRUE; 59 return TRUE;
76 } 60 }
OLDNEW
« no previous file with comments | « chrome_elf/chrome_elf.def ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698