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

Side by Side Diff: content/renderer/renderer_main_platform_delegate_win.cc

Issue 9803002: [windows] Make calls to exit(), _exit(), abort(), and ExitProcess() from the renderer process resul… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase just in case.... Created 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/app/breakpad_win.cc ('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 (c) 2011 The Chromium Authors. All rights reserved. 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 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 <signal.h>
brettw 2012/03/23 21:16:37 I'd put this after the first header file.
eroman 2012/03/23 21:26:23 Done.
6
5 #include "content/renderer/renderer_main_platform_delegate.h" 7 #include "content/renderer/renderer_main_platform_delegate.h"
6 8
7 #include "base/command_line.h" 9 #include "base/command_line.h"
8 #include "base/logging.h" 10 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/win/win_util.h"
10 #include "content/common/injection_test_dll.h" 13 #include "content/common/injection_test_dll.h"
11 #include "content/public/common/content_switches.h" 14 #include "content/public/common/content_switches.h"
12 #include "content/public/renderer/render_thread.h" 15 #include "content/public/renderer/render_thread.h"
13 #include "sandbox/src/sandbox.h" 16 #include "sandbox/src/sandbox.h"
14 #include "skia/ext/skia_sandbox_support_win.h" 17 #include "skia/ext/skia_sandbox_support_win.h"
15 #include "unicode/timezone.h" 18 #include "unicode/timezone.h"
16 19
17 namespace { 20 namespace {
18 21
19 // In order to have Theme support, we need to connect to the theme service. 22 // In order to have Theme support, we need to connect to the theme service.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 } 65 }
63 66
64 // Windows-only skia sandbox support 67 // Windows-only skia sandbox support
65 void SkiaPreCacheFont(LOGFONT logfont) { 68 void SkiaPreCacheFont(LOGFONT logfont) {
66 content::RenderThread* render_thread = content::RenderThread::Get(); 69 content::RenderThread* render_thread = content::RenderThread::Get();
67 if (render_thread) { 70 if (render_thread) {
68 render_thread->PreCacheFont(logfont); 71 render_thread->PreCacheFont(logfont);
69 } 72 }
70 } 73 }
71 74
75 void __cdecl ForceCrashOnAbort(int) {
brettw 2012/03/23 21:16:37 Can you call this ...SigAbort or something? At fir
eroman 2012/03/23 21:26:23 Done.
76 *((int*)0) = 0x1337;
77 }
78
79 void InitExitInterceptions() {
80 // If code subsequently tries to exit using exit(), _exit(), abort(), or
81 // ExitProcess(), force a crash (since otherwise these would be silent
82 // terminations and fly under the radar).
83 base::win::SetShouldCrashOnProcessDetach(true);
84
85 // Prevent CRT's abort code from prompting a dialog or trying to "report" it.
86 // Disabling the _CALL_REPORTFAULT behavior is important since otherwise it
87 // has the sideffect of clearing our exception filter, which means we
88 // don't get any crash.
89 _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
90
91 // Set a SIGABRT handler for good measure. We will crash even if the default
92 // is left in place, however this allows us to crash earlier. And it also
93 // lets us crash in response to code which might directly call raise(SIGABRT)
94 signal(SIGABRT, ForceCrashOnAbort);
95 }
96
72 } // namespace 97 } // namespace
73 98
74 RendererMainPlatformDelegate::RendererMainPlatformDelegate( 99 RendererMainPlatformDelegate::RendererMainPlatformDelegate(
75 const content::MainFunctionParams& parameters) 100 const content::MainFunctionParams& parameters)
76 : parameters_(parameters), 101 : parameters_(parameters),
77 sandbox_test_module_(NULL) { 102 sandbox_test_module_(NULL) {
78 } 103 }
79 104
80 RendererMainPlatformDelegate::~RendererMainPlatformDelegate() { 105 RendererMainPlatformDelegate::~RendererMainPlatformDelegate() {
81 } 106 }
82 107
83 void RendererMainPlatformDelegate::PlatformInitialize() { 108 void RendererMainPlatformDelegate::PlatformInitialize() {
109 InitExitInterceptions();
110
84 // Be mindful of what resources you acquire here. They can be used by 111 // Be mindful of what resources you acquire here. They can be used by
85 // malicious code if the renderer gets compromised. 112 // malicious code if the renderer gets compromised.
86 const CommandLine& command_line = parameters_.command_line; 113 const CommandLine& command_line = parameters_.command_line;
87 bool no_sandbox = command_line.HasSwitch(switches::kNoSandbox); 114 bool no_sandbox = command_line.HasSwitch(switches::kNoSandbox);
88 EnableThemeSupportForRenderer(no_sandbox); 115 EnableThemeSupportForRenderer(no_sandbox);
89 116
90 if (!no_sandbox) { 117 if (!no_sandbox) {
91 // ICU DateFormat class (used in base/time_format.cc) needs to get the 118 // ICU DateFormat class (used in base/time_format.cc) needs to get the
92 // Olson timezone ID by accessing the registry keys under 119 // Olson timezone ID by accessing the registry keys under
93 // HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones. 120 // HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones.
94 // After TimeZone::createDefault is called once here, the timezone ID is 121 // After TimeZone::createDefault is called once here, the timezone ID is
95 // cached and there's no more need to access the registry. If the sandbox 122 // cached and there's no more need to access the registry. If the sandbox
96 // is disabled, we don't have to make this dummy call. 123 // is disabled, we don't have to make this dummy call.
97 scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault()); 124 scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault());
98 SetSkiaEnsureTypefaceAccessible(SkiaPreCacheFont); 125 SetSkiaEnsureTypefaceAccessible(SkiaPreCacheFont);
99 } 126 }
100 } 127 }
101 128
102 void RendererMainPlatformDelegate::PlatformUninitialize() { 129 void RendererMainPlatformDelegate::PlatformUninitialize() {
130 // At this point we are shutting down in a normal code path, so undo our
131 // hack to crash on exit.
132 base::win::SetShouldCrashOnProcessDetach(false);
103 } 133 }
104 134
105 bool RendererMainPlatformDelegate::InitSandboxTests(bool no_sandbox) { 135 bool RendererMainPlatformDelegate::InitSandboxTests(bool no_sandbox) {
106 const CommandLine& command_line = parameters_.command_line; 136 const CommandLine& command_line = parameters_.command_line;
107 137
108 DVLOG(1) << "Started renderer with " << command_line.GetCommandLineString(); 138 DVLOG(1) << "Started renderer with " << command_line.GetCommandLineString();
109 139
110 sandbox::TargetServices* target_services = 140 sandbox::TargetServices* target_services =
111 parameters_.sandbox_info->target_services; 141 parameters_.sandbox_info->target_services;
112 142
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 kRenderTestCall)); 179 kRenderTestCall));
150 DCHECK(run_security_tests); 180 DCHECK(run_security_tests);
151 if (run_security_tests) { 181 if (run_security_tests) {
152 int test_count = 0; 182 int test_count = 0;
153 DVLOG(1) << "Running renderer security tests"; 183 DVLOG(1) << "Running renderer security tests";
154 BOOL result = run_security_tests(&test_count); 184 BOOL result = run_security_tests(&test_count);
155 CHECK(result) << "Test number " << test_count << " has failed."; 185 CHECK(result) << "Test number " << test_count << " has failed.";
156 } 186 }
157 } 187 }
158 } 188 }
OLDNEW
« no previous file with comments | « chrome/app/breakpad_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698