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

Side by Side Diff: base/process/launch_win.cc

Issue 98603007: Launches a privileged utility process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adds missing child_process_launcher files. Created 7 years 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
OLDNEW
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 "base/process/launch.h" 5 #include "base/process/launch.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <io.h> 8 #include <io.h>
9 #include <windows.h> 9 #include <windows.h>
10 #include <userenv.h> 10 #include <userenv.h>
11 #include <psapi.h> 11 #include <psapi.h>
12 #include <Shellapi.h>
12 13
13 #include <ios> 14 #include <ios>
14 15
15 #include "base/bind.h" 16 #include "base/bind.h"
16 #include "base/bind_helpers.h" 17 #include "base/bind_helpers.h"
17 #include "base/command_line.h" 18 #include "base/command_line.h"
18 #include "base/debug/stack_trace.h" 19 #include "base/debug/stack_trace.h"
19 #include "base/logging.h" 20 #include "base/logging.h"
20 #include "base/memory/scoped_ptr.h" 21 #include "base/memory/scoped_ptr.h"
21 #include "base/message_loop/message_loop.h" 22 #include "base/message_loop/message_loop.h"
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 // Let's wait for the process to finish. 273 // Let's wait for the process to finish.
273 WaitForSingleObject(proc_info.process_handle(), INFINITE); 274 WaitForSingleObject(proc_info.process_handle(), INFINITE);
274 275
275 return true; 276 return true;
276 } 277 }
277 278
278 void RaiseProcessToHighPriority() { 279 void RaiseProcessToHighPriority() {
279 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); 280 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
280 } 281 }
281 282
283 bool LaunchElevatedProcess(const CommandLine& cmdline,
284 const LaunchOptions& options,
285 ProcessHandle* process_handle) {
286 const std::wstring file = cmdline.GetProgram().value();
287 const std::wstring arguments = cmdline.GetArgumentsString();
288
289 SHELLEXECUTEINFO shex_info = {0};
290 shex_info.cbSize = sizeof(shex_info);
291 shex_info.fMask = SEE_MASK_NOCLOSEPROCESS;
292 shex_info.hwnd = GetActiveWindow();
293 shex_info.lpVerb = L"runas";
294 shex_info.lpFile = file.c_str();
295 shex_info.lpParameters = arguments.c_str();
296 shex_info.lpDirectory = NULL;
297 shex_info.nShow = options.start_hidden ? SW_HIDE : SW_SHOW;
298 shex_info.hInstApp = NULL;
299
300 if (!ShellExecuteEx(&shex_info)) {
301 DPLOG(ERROR);
302 return false;
303 }
304
305 if (options.wait)
306 WaitForSingleObject(shex_info.hProcess, INFINITE);
307
308 // If the caller wants the process handle, we won't close it.
309 if (process_handle)
mef 2013/12/18 21:02:10 don't you need to close it otherwise?
Drew Haven 2014/01/09 01:15:14 You know, this was just taken directly from the de
310 *process_handle = shex_info.hProcess;
311
312 return true;
313 }
314
282 } // namespace base 315 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698