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

Side by Side Diff: chrome/installer/setup/setup_main.cc

Issue 2559053002: Instrument setup.exe in the SyzyAsan builds.
Patch Set: Rebase Created 3 years, 9 months 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/installer/setup/setup_main.h" 5 #include "chrome/installer/setup/setup_main.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <msi.h> 8 #include <msi.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #include <shlobj.h> 10 #include <shlobj.h>
11 #include <stddef.h> 11 #include <stddef.h>
12 #include <stdint.h> 12 #include <stdint.h>
13 13
14 #include <memory> 14 #include <memory>
15 #include <string> 15 #include <string>
16 16
17 #include "base/at_exit.h" 17 #include "base/at_exit.h"
18 #include "base/command_line.h" 18 #include "base/command_line.h"
19 #include "base/debug/asan_invalid_access.h"
grt (UTC plus 2) 2017/03/10 07:57:36 nit: put this in a #if defined(SYZYASAN) block aft
Sébastien Marchand 2017/04/05 21:07:02 Done.
19 #include "base/file_version_info.h" 20 #include "base/file_version_info.h"
20 #include "base/files/file_path.h" 21 #include "base/files/file_path.h"
21 #include "base/files/file_util.h" 22 #include "base/files/file_util.h"
22 #include "base/files/scoped_temp_dir.h" 23 #include "base/files/scoped_temp_dir.h"
23 #include "base/macros.h" 24 #include "base/macros.h"
24 #include "base/metrics/histogram_macros.h" 25 #include "base/metrics/histogram_macros.h"
25 #include "base/numerics/safe_conversions.h" 26 #include "base/numerics/safe_conversions.h"
26 #include "base/path_service.h" 27 #include "base/path_service.h"
27 #include "base/process/launch.h" 28 #include "base/process/launch.h"
28 #include "base/process/memory.h" 29 #include "base/process/memory.h"
(...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 installer::REENABLE_UPDATES_FAILED; 1036 installer::REENABLE_UPDATES_FAILED;
1036 } else if (cmd_line.HasSwitch( 1037 } else if (cmd_line.HasSwitch(
1037 installer::switches::kSetDisplayVersionProduct)) { 1038 installer::switches::kSetDisplayVersionProduct)) {
1038 const base::string16 registry_product( 1039 const base::string16 registry_product(
1039 cmd_line.GetSwitchValueNative( 1040 cmd_line.GetSwitchValueNative(
1040 installer::switches::kSetDisplayVersionProduct)); 1041 installer::switches::kSetDisplayVersionProduct));
1041 const base::string16 registry_value( 1042 const base::string16 registry_value(
1042 cmd_line.GetSwitchValueNative( 1043 cmd_line.GetSwitchValueNative(
1043 installer::switches::kSetDisplayVersionValue)); 1044 installer::switches::kSetDisplayVersionValue));
1044 *exit_code = OverwriteDisplayVersions(registry_product, registry_value); 1045 *exit_code = OverwriteDisplayVersions(registry_product, registry_value);
1046 #if defined(SYZYASAN)
1047 } else if (cmd_line.HasSwitch(installer::switches::kInduceAsanCrash)) {
1048 std::string crash_type =
1049 cmd_line.GetSwitchValueASCII(installer::switches::kInduceAsanCrash);
1050 if (crash_type == installer::switches::kAsanUseAfterFree) {
1051 base::debug::AsanHeapUseAfterFree();
1052 } else if (crash_type == installer::switches::kAsanHeapOverflow) {
1053 base::debug::AsanHeapOverflow();
1054 } else if (crash_type == installer::switches::kAsanHeapUnderflow) {
1055 base::debug::AsanHeapUnderflow();
1056 } else {
1057 LOG(ERROR) << "Invalid Asan error type: " << crash_type;
1058 handled = false;
1059 }
1060 #endif
1045 } else { 1061 } else {
1046 handled = false; 1062 handled = false;
1047 } 1063 }
1048 1064
1049 return handled; 1065 return handled;
1050 } 1066 }
1051 1067
1068 #if defined(SYZYASAN)
1069 // Initialize the SyzyAsan crash reporter. This should only be called once the
1070 // crash reporter has been initialized. There should be only one call to this
1071 // function.
1072 void SetupSyzyAsan() {
1073 typedef VOID(WINAPI * SyzyAsanInitializeCrashReporterFn)();
grt (UTC plus 2) 2017/03/10 07:57:36 nit: prefer "using" over "typedef"
Sébastien Marchand 2017/04/05 21:07:02 Done.
1074 HMODULE syzyasan_handle = ::GetModuleHandle(L"syzyasan_rtl.dll");
1075 if (!syzyasan_handle)
1076 return;
1077
1078 SyzyAsanInitializeCrashReporterFn syzyasan_init_crash_reporter =
1079 reinterpret_cast<SyzyAsanInitializeCrashReporterFn>(
1080 ::GetProcAddress(syzyasan_handle, "asan_InitializeCrashReporter"));
1081 if (syzyasan_init_crash_reporter) {
grt (UTC plus 2) 2017/03/10 07:57:36 nit: omit braces for one-liner
Sébastien Marchand 2017/04/05 21:07:02 Done.
1082 syzyasan_init_crash_reporter();
1083 }
1084 }
1085 #endif
1086
1052 } // namespace 1087 } // namespace
1053 1088
1054 namespace installer { 1089 namespace installer {
1055 1090
1056 InstallStatus InstallProductsHelper(const InstallationState& original_state, 1091 InstallStatus InstallProductsHelper(const InstallationState& original_state,
1057 const base::FilePath& setup_exe, 1092 const base::FilePath& setup_exe,
1058 const base::CommandLine& cmd_line, 1093 const base::CommandLine& cmd_line,
1059 const MasterPreferences& prefs, 1094 const MasterPreferences& prefs,
1060 const InstallerState& installer_state, 1095 const InstallerState& installer_state,
1061 base::FilePath* installer_directory, 1096 base::FilePath* installer_directory,
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1357 << installer_state.is_migrating_to_single(); 1392 << installer_state.is_migrating_to_single();
1358 1393
1359 persistent_histogram_storage.set_storage_dir( 1394 persistent_histogram_storage.set_storage_dir(
1360 installer::PersistentHistogramStorage::GetReportedStorageDir( 1395 installer::PersistentHistogramStorage::GetReportedStorageDir(
1361 installer_state.target_path())); 1396 installer_state.target_path()));
1362 1397
1363 installer::ConfigureCrashReporting(installer_state); 1398 installer::ConfigureCrashReporting(installer_state);
1364 installer::SetInitialCrashKeys(installer_state); 1399 installer::SetInitialCrashKeys(installer_state);
1365 installer::SetCrashKeysFromCommandLine(cmd_line); 1400 installer::SetCrashKeysFromCommandLine(cmd_line);
1366 1401
1402 #if defined(SYZYASAN)
1403 SetupSyzyAsan();
1404 #endif
1405
1367 // Make sure the process exits cleanly on unexpected errors. 1406 // Make sure the process exits cleanly on unexpected errors.
1368 base::EnableTerminationOnHeapCorruption(); 1407 base::EnableTerminationOnHeapCorruption();
1369 base::EnableTerminationOnOutOfMemory(); 1408 base::EnableTerminationOnOutOfMemory();
1370 base::win::RegisterInvalidParamHandler(); 1409 base::win::RegisterInvalidParamHandler();
1371 base::win::SetupCRT(cmd_line); 1410 base::win::SetupCRT(cmd_line);
1372 1411
1373 const bool is_uninstall = cmd_line.HasSwitch(installer::switches::kUninstall); 1412 const bool is_uninstall = cmd_line.HasSwitch(installer::switches::kUninstall);
1374 1413
1375 // Check to make sure current system is Win7 or later. If not, log 1414 // Check to make sure current system is Win7 or later. If not, log
1376 // error message and get out. 1415 // error message and get out.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT 1539 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT
1501 // to pass through, since this is only returned on uninstall which is 1540 // to pass through, since this is only returned on uninstall which is
1502 // never invoked directly by Google Update. 1541 // never invoked directly by Google Update.
1503 return_code = InstallUtil::GetInstallReturnCode(install_status); 1542 return_code = InstallUtil::GetInstallReturnCode(install_status);
1504 } 1543 }
1505 1544
1506 VLOG(1) << "Installation complete, returning: " << return_code; 1545 VLOG(1) << "Installation complete, returning: " << return_code;
1507 1546
1508 return return_code; 1547 return return_code;
1509 } 1548 }
OLDNEW
« no previous file with comments | « chrome/installer/setup/setup_constants.cc ('k') | chrome/tools/build/win/create_installer_archive.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698