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

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: fix sorting 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>
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) {
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 // Also disable the_CALL_REPORTFAULT behavior, since it has the sideffect of
rvargas (doing something else) 2012/03/22 02:55:59 nit: the <space> _CALL_RE...
eroman 2012/03/22 04:30:23 Done.
87 // clearing our exception filter, which means we don't get any crash.
88 _set_abort_behavior(0, _WRITE_ABORT_MSG);
89 _set_abort_behavior(0, _CALL_REPORTFAULT);
rvargas (doing something else) 2012/03/22 02:55:59 _set_abort_bahavior(0, _WRITE_A_M | _CALL_R); ? (I
eroman 2012/03/22 04:30:23 Done.
90
91 signal(SIGABRT, ForceCrashOnAbort);
92 }
93
72 } // namespace 94 } // namespace
73 95
74 RendererMainPlatformDelegate::RendererMainPlatformDelegate( 96 RendererMainPlatformDelegate::RendererMainPlatformDelegate(
75 const content::MainFunctionParams& parameters) 97 const content::MainFunctionParams& parameters)
76 : parameters_(parameters), 98 : parameters_(parameters),
77 sandbox_test_module_(NULL) { 99 sandbox_test_module_(NULL) {
78 } 100 }
79 101
80 RendererMainPlatformDelegate::~RendererMainPlatformDelegate() { 102 RendererMainPlatformDelegate::~RendererMainPlatformDelegate() {
81 } 103 }
82 104
83 void RendererMainPlatformDelegate::PlatformInitialize() { 105 void RendererMainPlatformDelegate::PlatformInitialize() {
106 InitExitInterceptions();
107
84 // Be mindful of what resources you acquire here. They can be used by 108 // Be mindful of what resources you acquire here. They can be used by
85 // malicious code if the renderer gets compromised. 109 // malicious code if the renderer gets compromised.
86 const CommandLine& command_line = parameters_.command_line; 110 const CommandLine& command_line = parameters_.command_line;
87 bool no_sandbox = command_line.HasSwitch(switches::kNoSandbox); 111 bool no_sandbox = command_line.HasSwitch(switches::kNoSandbox);
88 EnableThemeSupportForRenderer(no_sandbox); 112 EnableThemeSupportForRenderer(no_sandbox);
89 113
90 if (!no_sandbox) { 114 if (!no_sandbox) {
91 // ICU DateFormat class (used in base/time_format.cc) needs to get the 115 // ICU DateFormat class (used in base/time_format.cc) needs to get the
92 // Olson timezone ID by accessing the registry keys under 116 // Olson timezone ID by accessing the registry keys under
93 // HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones. 117 // HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones.
94 // After TimeZone::createDefault is called once here, the timezone ID is 118 // 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 119 // 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. 120 // is disabled, we don't have to make this dummy call.
97 scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault()); 121 scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault());
98 SetSkiaEnsureTypefaceAccessible(SkiaPreCacheFont); 122 SetSkiaEnsureTypefaceAccessible(SkiaPreCacheFont);
99 } 123 }
100 } 124 }
101 125
102 void RendererMainPlatformDelegate::PlatformUninitialize() { 126 void RendererMainPlatformDelegate::PlatformUninitialize() {
127 // At this point we are shutting down in a normal code path, so undo our
128 // hack to crash on exit.
129 base::win::SetShouldCrashOnProcessDetach(false);
103 } 130 }
104 131
105 bool RendererMainPlatformDelegate::InitSandboxTests(bool no_sandbox) { 132 bool RendererMainPlatformDelegate::InitSandboxTests(bool no_sandbox) {
106 const CommandLine& command_line = parameters_.command_line; 133 const CommandLine& command_line = parameters_.command_line;
107 134
108 DVLOG(1) << "Started renderer with " << command_line.GetCommandLineString(); 135 DVLOG(1) << "Started renderer with " << command_line.GetCommandLineString();
109 136
110 sandbox::TargetServices* target_services = 137 sandbox::TargetServices* target_services =
111 parameters_.sandbox_info->target_services; 138 parameters_.sandbox_info->target_services;
112 139
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 kRenderTestCall)); 176 kRenderTestCall));
150 DCHECK(run_security_tests); 177 DCHECK(run_security_tests);
151 if (run_security_tests) { 178 if (run_security_tests) {
152 int test_count = 0; 179 int test_count = 0;
153 DVLOG(1) << "Running renderer security tests"; 180 DVLOG(1) << "Running renderer security tests";
154 BOOL result = run_security_tests(&test_count); 181 BOOL result = run_security_tests(&test_count);
155 CHECK(result) << "Test number " << test_count << " has failed."; 182 CHECK(result) << "Test number " << test_count << " has failed.";
156 } 183 }
157 } 184 }
158 } 185 }
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