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

Side by Side Diff: chrome/app/chrome_dll_main.cc

Issue 2458: Use the new dll injection blocking api of the sandbox to block... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 3 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 | « no previous file | chrome/browser/render_process_host.cc » ('j') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <atlbase.h> 5 #include <atlbase.h>
6 #include <atlapp.h> 6 #include <atlapp.h>
7 #include <malloc.h> 7 #include <malloc.h>
8 #include <new.h> 8 #include <new.h>
9 9
10 #include "base/at_exit.h" 10 #include "base/at_exit.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 // Get the breakpad pointer from chrome.exe 79 // Get the breakpad pointer from chrome.exe
80 typedef void (__stdcall *DumpProcessFunction)(); 80 typedef void (__stdcall *DumpProcessFunction)();
81 DumpProcessFunction DumpProcess = reinterpret_cast<DumpProcessFunction>( 81 DumpProcessFunction DumpProcess = reinterpret_cast<DumpProcessFunction>(
82 ::GetProcAddress(::GetModuleHandle(L"chrome.exe"), "DumpProcess")); 82 ::GetProcAddress(::GetModuleHandle(L"chrome.exe"), "DumpProcess"));
83 if (DumpProcess) 83 if (DumpProcess)
84 DumpProcess(); 84 DumpProcess();
85 } 85 }
86 86
87 #pragma optimize("", on) 87 #pragma optimize("", on)
88 88
89
90 // Try to unload DLLs that malfunction with the sandboxed processes.
91 static void EvictTroublesomeDlls() {
92 const wchar_t* troublesome_dlls[] = {
93 L"smumhook.dll", // spyware doctor version 5 and above.
94 NULL // Must be null. Here you can add with the debugger.
95 };
96
97 for(int ix = 0; ix != arraysize(troublesome_dlls); ++ix) {
98 if (!troublesome_dlls[ix])
99 break;
100 HMODULE module = ::GetModuleHandleW(troublesome_dlls[ix]);
101 if (module) {
102 LOG(WARNING) << "dll to evict found: " << ix;
103 if (::FreeLibrary(module)) {
104 DCHECK(NULL == ::GetModuleHandleW(troublesome_dlls[ix]));
105 }
106 }
107 }
108 }
109
110 } // namespace 89 } // namespace
111 90
112 DLLEXPORT int __cdecl ChromeMain(HINSTANCE instance, 91 DLLEXPORT int __cdecl ChromeMain(HINSTANCE instance,
113 sandbox::SandboxInterfaceInfo* sandbox_info, 92 sandbox::SandboxInterfaceInfo* sandbox_info,
114 TCHAR* command_line, int show_command) { 93 TCHAR* command_line, int show_command) {
115 // Register the invalid param handler and pure call handler to be able to 94 // Register the invalid param handler and pure call handler to be able to
116 // notify breakpad when it happens. 95 // notify breakpad when it happens.
117 _set_invalid_parameter_handler(InvalidParameter); 96 _set_invalid_parameter_handler(InvalidParameter);
118 _set_purecall_handler(PureCall); 97 _set_purecall_handler(PureCall);
119 // Gather allocation failure. 98 // Gather allocation failure.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 sandbox::TargetServices* target_services = NULL; 156 sandbox::TargetServices* target_services = NULL;
178 sandbox::BrokerServices* broker_services = NULL; 157 sandbox::BrokerServices* broker_services = NULL;
179 if (sandbox_info) { 158 if (sandbox_info) {
180 target_services = sandbox_info->target_services; 159 target_services = sandbox_info->target_services;
181 broker_services = sandbox_info->broker_services; 160 broker_services = sandbox_info->broker_services;
182 } 161 }
183 162
184 std::wstring process_type = 163 std::wstring process_type =
185 parsed_command_line.GetSwitchValue(switches::kProcessType); 164 parsed_command_line.GetSwitchValue(switches::kProcessType);
186 165
187 bool do_dll_eviction = false;
188
189 // Checks if the sandbox is enabled in this process and initializes it if this 166 // Checks if the sandbox is enabled in this process and initializes it if this
190 // is the case. The crash handler depends on this so it has to be done before 167 // is the case. The crash handler depends on this so it has to be done before
191 // its initialization. 168 // its initialization.
192 if (target_services && !parsed_command_line.HasSwitch(switches::kNoSandbox)) { 169 if (target_services && !parsed_command_line.HasSwitch(switches::kNoSandbox)) {
193 if ((process_type == switches::kRendererProcess) || 170 if ((process_type == switches::kRendererProcess) ||
194 (process_type == switches::kPluginProcess && 171 (process_type == switches::kPluginProcess &&
195 parsed_command_line.HasSwitch(switches::kSafePlugins))) { 172 parsed_command_line.HasSwitch(switches::kSafePlugins))) {
196 target_services->Init(); 173 target_services->Init();
197 do_dll_eviction = true;
198 } 174 }
199 } 175 }
200 176
201 _Module.Init(NULL, instance); 177 _Module.Init(NULL, instance);
202 178
203 // Notice a user data directory override if any 179 // Notice a user data directory override if any
204 const std::wstring user_data_dir = 180 const std::wstring user_data_dir =
205 parsed_command_line.GetSwitchValue(switches::kUserDataDir); 181 parsed_command_line.GetSwitchValue(switches::kUserDataDir);
206 if (!user_data_dir.empty()) 182 if (!user_data_dir.empty())
207 PathService::Override(chrome::DIR_USER_DATA, user_data_dir); 183 PathService::Override(chrome::DIR_USER_DATA, user_data_dir);
(...skipping 20 matching lines...) Expand all
228 } 204 }
229 #endif // NDEBUG 205 #endif // NDEBUG
230 206
231 if (!process_type.empty()) { 207 if (!process_type.empty()) {
232 // Initialize ResourceBundle which handles files loaded from external 208 // Initialize ResourceBundle which handles files loaded from external
233 // sources. The language should have been passed in to us from the 209 // sources. The language should have been passed in to us from the
234 // browser process as a command line flag. 210 // browser process as a command line flag.
235 ResourceBundle::InitSharedInstance(std::wstring()); 211 ResourceBundle::InitSharedInstance(std::wstring());
236 } 212 }
237 213
238 // Eviction of injected DLLs is done early enough that it is likely
239 // to only cover DLLs injected by means of appInit_dlls registry key.
240 if (do_dll_eviction)
241 EvictTroublesomeDlls();
242
243 startup_timer.Stop(); // End of Startup Time Measurement. 214 startup_timer.Stop(); // End of Startup Time Measurement.
244 215
245 int rv; 216 int rv;
246 if (process_type == switches::kRendererProcess) { 217 if (process_type == switches::kRendererProcess) {
247 rv = RendererMain(parsed_command_line, show_command, target_services); 218 rv = RendererMain(parsed_command_line, show_command, target_services);
248 } else if (process_type == switches::kPluginProcess) { 219 } else if (process_type == switches::kPluginProcess) {
249 rv = PluginMain(parsed_command_line, show_command, target_services); 220 rv = PluginMain(parsed_command_line, show_command, target_services);
250 } else if (process_type.empty()) { 221 } else if (process_type.empty()) {
251 int ole_result = OleInitialize(NULL); 222 int ole_result = OleInitialize(NULL);
252 DCHECK(ole_result == S_OK); 223 DCHECK(ole_result == S_OK);
(...skipping 12 matching lines...) Expand all
265 _CrtDumpMemoryLeaks(); 236 _CrtDumpMemoryLeaks();
266 #endif // _CRTDBG_MAP_ALLOC 237 #endif // _CRTDBG_MAP_ALLOC
267 238
268 _Module.Term(); 239 _Module.Term();
269 240
270 logging::CleanupChromeLogging(); 241 logging::CleanupChromeLogging();
271 242
272 return rv; 243 return rv;
273 } 244 }
274 245
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/render_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698