This source file includes following definitions.
- InvalidParameter
- PureCall
- InitializeSandboxInfo
- RegisterInvalidParamHandler
- SetupCRT
#include "content/public/app/startup_helper_win.h"
#include <crtdbg.h>
#include <new.h>
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/win/windows_version.h"
#include "sandbox/win/src/process_mitigations.h"
#include "sandbox/win/src/sandbox_factory.h"
namespace {
#pragma optimize("", off)
void InvalidParameter(const wchar_t* expression, const wchar_t* function,
const wchar_t* file, unsigned int line,
uintptr_t reserved) {
__debugbreak();
_exit(1);
}
void PureCall() {
__debugbreak();
_exit(1);
}
#pragma optimize("", on)
}
namespace content {
void InitializeSandboxInfo(sandbox::SandboxInterfaceInfo* info) {
info->broker_services = sandbox::SandboxFactory::GetBrokerServices();
if (!info->broker_services) {
info->target_services = sandbox::SandboxFactory::GetTargetServices();
} else {
sandbox::ApplyProcessMitigationsToCurrentProcess(
sandbox::MITIGATION_DEP |
sandbox::MITIGATION_DEP_NO_ATL_THUNK);
}
}
void RegisterInvalidParamHandler() {
_set_invalid_parameter_handler(InvalidParameter);
_set_purecall_handler(PureCall);
_set_new_mode(1);
}
void SetupCRT(const CommandLine& command_line) {
#if defined(_CRTDBG_MAP_ALLOC)
_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
#else
if (!command_line.HasSwitch(switches::kDisableBreakpad)) {
_CrtSetReportMode(_CRT_ASSERT, 0);
}
#endif
}
}