Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <windows.h> | 5 #include <windows.h> |
| 6 #include <shlwapi.h> | 6 #include <shlwapi.h> |
| 7 | 7 |
| 8 #include "base/base_paths.h" | 8 #include "base/base_paths.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 | 87 |
| 88 typedef int (*InitMetro)(); | 88 typedef int (*InitMetro)(); |
| 89 | 89 |
| 90 // Returns the directory in which the currently running executable resides. | 90 // Returns the directory in which the currently running executable resides. |
| 91 base::FilePath GetExecutableDir() { | 91 base::FilePath GetExecutableDir() { |
| 92 base::char16 path[MAX_PATH]; | 92 base::char16 path[MAX_PATH]; |
| 93 ::GetModuleFileNameW(nullptr, path, MAX_PATH); | 93 ::GetModuleFileNameW(nullptr, path, MAX_PATH); |
| 94 return base::FilePath(path).DirName(); | 94 return base::FilePath(path).DirName(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 bool IsSandboxedProcess() { | |
| 98 typedef bool (*IsSandboxedProcessFunc)(); | |
| 99 IsSandboxedProcessFunc is_sandboxed_process_func = | |
| 100 reinterpret_cast<IsSandboxedProcessFunc>( | |
| 101 GetProcAddress(GetModuleHandle(NULL), "IsSandboxedProcess")); | |
| 102 bool is_sandboxed_process = | |
| 103 is_sandboxed_process_func && is_sandboxed_process_func(); | |
| 104 return is_sandboxed_process; | |
| 105 } | |
| 106 | |
| 97 } // namespace | 107 } // namespace |
| 98 | 108 |
| 99 base::string16 GetCurrentModuleVersion() { | 109 base::string16 GetCurrentModuleVersion() { |
| 100 scoped_ptr<FileVersionInfo> file_version_info( | 110 scoped_ptr<FileVersionInfo> file_version_info( |
| 101 FileVersionInfo::CreateFileVersionInfoForCurrentModule()); | 111 FileVersionInfo::CreateFileVersionInfoForCurrentModule()); |
| 102 if (file_version_info.get()) { | 112 if (file_version_info.get()) { |
| 103 base::string16 version_string(file_version_info->file_version()); | 113 base::string16 version_string(file_version_info->file_version()); |
| 104 if (Version(base::UTF16ToASCII(version_string)).IsValid()) | 114 if (Version(base::UTF16ToASCII(version_string)).IsValid()) |
| 105 return version_string; | 115 return version_string; |
| 106 } | 116 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 228 if (!dll_) | 238 if (!dll_) |
| 229 return chrome::RESULT_CODE_MISSING_DATA; | 239 return chrome::RESULT_CODE_MISSING_DATA; |
| 230 | 240 |
| 231 scoped_ptr<base::Environment> env(base::Environment::Create()); | 241 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 232 env->SetVar(chrome::kChromeVersionEnvVar, base::WideToUTF8(version)); | 242 env->SetVar(chrome::kChromeVersionEnvVar, base::WideToUTF8(version)); |
| 233 | 243 |
| 234 OnBeforeLaunch(process_type_, file); | 244 OnBeforeLaunch(process_type_, file); |
| 235 DLL_MAIN chrome_main = | 245 DLL_MAIN chrome_main = |
| 236 reinterpret_cast<DLL_MAIN>(::GetProcAddress(dll_, "ChromeMain")); | 246 reinterpret_cast<DLL_MAIN>(::GetProcAddress(dll_, "ChromeMain")); |
| 237 int rc = chrome_main(instance, &sandbox_info); | 247 int rc = chrome_main(instance, &sandbox_info); |
| 238 return OnBeforeExit(rc, file); | 248 rc = OnBeforeExit(rc, file); |
| 249 // Sandboxed processes close some system DLL handles after lockdown so ignore | |
| 250 // EXCEPTION_INVALID_HANDLE generated on Windows 10 during shutdown of these | |
| 251 // processes. | |
| 252 // TODO(wfh): Check whether MS have fixed this in Win10 RTM. crbug.com/456193 | |
| 253 if (base::win::GetVersion() >= base::win::VERSION_WIN10 && | |
| 254 IsSandboxedProcess()) { | |
| 255 breakpad::ConsumeInvalidHandleExceptions(); | |
|
rvargas (doing something else)
2015/02/25 02:02:57
Drive by:
I don't know what this code does (don't
| |
| 256 } | |
| 257 return rc; | |
| 239 } | 258 } |
| 240 | 259 |
| 241 void MainDllLoader::RelaunchChromeBrowserWithNewCommandLineIfNeeded() { | 260 void MainDllLoader::RelaunchChromeBrowserWithNewCommandLineIfNeeded() { |
| 242 if (!dll_) | 261 if (!dll_) |
| 243 return; | 262 return; |
| 244 | 263 |
| 245 RelaunchChromeBrowserWithNewCommandLineIfNeededFunc relaunch_function = | 264 RelaunchChromeBrowserWithNewCommandLineIfNeededFunc relaunch_function = |
| 246 reinterpret_cast<RelaunchChromeBrowserWithNewCommandLineIfNeededFunc>( | 265 reinterpret_cast<RelaunchChromeBrowserWithNewCommandLineIfNeededFunc>( |
| 247 ::GetProcAddress(dll_, | 266 ::GetProcAddress(dll_, |
| 248 "RelaunchChromeBrowserWithNewCommandLineIfNeeded")); | 267 "RelaunchChromeBrowserWithNewCommandLineIfNeeded")); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 } | 323 } |
| 305 }; | 324 }; |
| 306 | 325 |
| 307 MainDllLoader* MakeMainDllLoader() { | 326 MainDllLoader* MakeMainDllLoader() { |
| 308 #if defined(GOOGLE_CHROME_BUILD) | 327 #if defined(GOOGLE_CHROME_BUILD) |
| 309 return new ChromeDllLoader(); | 328 return new ChromeDllLoader(); |
| 310 #else | 329 #else |
| 311 return new ChromiumDllLoader(); | 330 return new ChromiumDllLoader(); |
| 312 #endif | 331 #endif |
| 313 } | 332 } |
| OLD | NEW |