1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/public/app/startup_helper_win.h"
10 #include "base/base_switches.h"
11 #include "base/command_line.h"
12 #include "base/win/windows_version.h"
13 #include "sandbox/win/src/process_mitigations.h"
14 #include "sandbox/win/src/sandbox_factory.h"
18 #pragma optimize("", off)
19 // Handlers for invalid parameter and pure call. They generate a breakpoint to
20 // tell breakpad that it needs to dump the process.
21 void InvalidParameter(const wchar_t* expression
, const wchar_t* function
,
22 const wchar_t* file
, unsigned int line
,
32 #pragma optimize("", on)
38 void InitializeSandboxInfo(sandbox::SandboxInterfaceInfo
* info
) {
39 info
->broker_services
= sandbox::SandboxFactory::GetBrokerServices();
40 if (!info
->broker_services
) {
41 info
->target_services
= sandbox::SandboxFactory::GetTargetServices();
43 // Ensure the proper mitigations are enforced for the browser process.
44 sandbox::ApplyProcessMitigationsToCurrentProcess(
45 sandbox::MITIGATION_DEP
|
46 sandbox::MITIGATION_DEP_NO_ATL_THUNK
);
50 // Register the invalid param handler and pure call handler to be able to
51 // notify breakpad when it happens.
52 void RegisterInvalidParamHandler() {
53 _set_invalid_parameter_handler(InvalidParameter
);
54 _set_purecall_handler(PureCall
);
55 // Also enable the new handler for malloc() based failures.
59 void SetupCRT(const CommandLine
& command_line
) {
60 #if defined(_CRTDBG_MAP_ALLOC)
61 _CrtSetReportFile(_CRT_WARN
, _CRTDBG_FILE_STDERR
);
62 _CrtSetReportMode(_CRT_WARN
, _CRTDBG_MODE_FILE
);
64 if (!command_line
.HasSwitch(switches::kDisableBreakpad
)) {
65 _CrtSetReportMode(_CRT_ASSERT
, 0);
70 } // namespace content