| 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 "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 <shellapi.h> | 9 #include <shellapi.h> |
| 10 #include <windows.h> | 10 #include <windows.h> |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 WaitForSingleObject(process_info.process_handle(), INFINITE); | 231 WaitForSingleObject(process_info.process_handle(), INFINITE); |
| 232 | 232 |
| 233 return Process(process_info.TakeProcessHandle()); | 233 return Process(process_info.TakeProcessHandle()); |
| 234 } | 234 } |
| 235 | 235 |
| 236 Process LaunchElevatedProcess(const CommandLine& cmdline, | 236 Process LaunchElevatedProcess(const CommandLine& cmdline, |
| 237 const LaunchOptions& options) { | 237 const LaunchOptions& options) { |
| 238 const string16 file = cmdline.GetProgram().value(); | 238 const string16 file = cmdline.GetProgram().value(); |
| 239 const string16 arguments = cmdline.GetArgumentsString(); | 239 const string16 arguments = cmdline.GetArgumentsString(); |
| 240 | 240 |
| 241 SHELLEXECUTEINFO shex_info = {0}; | 241 SHELLEXECUTEINFO shex_info = {}; |
| 242 shex_info.cbSize = sizeof(shex_info); | 242 shex_info.cbSize = sizeof(shex_info); |
| 243 shex_info.fMask = SEE_MASK_NOCLOSEPROCESS; | 243 shex_info.fMask = SEE_MASK_NOCLOSEPROCESS; |
| 244 shex_info.hwnd = GetActiveWindow(); | 244 shex_info.hwnd = GetActiveWindow(); |
| 245 shex_info.lpVerb = L"runas"; | 245 shex_info.lpVerb = L"runas"; |
| 246 shex_info.lpFile = file.c_str(); | 246 shex_info.lpFile = file.c_str(); |
| 247 shex_info.lpParameters = arguments.c_str(); | 247 shex_info.lpParameters = arguments.c_str(); |
| 248 shex_info.lpDirectory = NULL; | 248 shex_info.lpDirectory = NULL; |
| 249 shex_info.nShow = options.start_hidden ? SW_HIDE : SW_SHOW; | 249 shex_info.nShow = options.start_hidden ? SW_HIDE : SW_SHOW; |
| 250 shex_info.hInstApp = NULL; | 250 shex_info.hInstApp = NULL; |
| 251 | 251 |
| 252 if (!ShellExecuteEx(&shex_info)) { | 252 if (!ShellExecuteEx(&shex_info)) { |
| 253 DPLOG(ERROR); | 253 DPLOG(ERROR); |
| 254 return Process(); | 254 return Process(); |
| 255 } | 255 } |
| 256 | 256 |
| 257 if (options.wait) | 257 if (options.wait) |
| 258 WaitForSingleObject(shex_info.hProcess, INFINITE); | 258 WaitForSingleObject(shex_info.hProcess, INFINITE); |
| 259 | 259 |
| 260 return Process(shex_info.hProcess); | 260 return Process(shex_info.hProcess); |
| 261 } | 261 } |
| 262 | 262 |
| 263 bool SetJobObjectLimitFlags(HANDLE job_object, DWORD limit_flags) { | 263 bool SetJobObjectLimitFlags(HANDLE job_object, DWORD limit_flags) { |
| 264 JOBOBJECT_EXTENDED_LIMIT_INFORMATION limit_info = {0}; | 264 JOBOBJECT_EXTENDED_LIMIT_INFORMATION limit_info = {}; |
| 265 limit_info.BasicLimitInformation.LimitFlags = limit_flags; | 265 limit_info.BasicLimitInformation.LimitFlags = limit_flags; |
| 266 return 0 != SetInformationJobObject( | 266 return 0 != SetInformationJobObject( |
| 267 job_object, | 267 job_object, |
| 268 JobObjectExtendedLimitInformation, | 268 JobObjectExtendedLimitInformation, |
| 269 &limit_info, | 269 &limit_info, |
| 270 sizeof(limit_info)); | 270 sizeof(limit_info)); |
| 271 } | 271 } |
| 272 | 272 |
| 273 bool GetAppOutput(const CommandLine& cl, std::string* output) { | 273 bool GetAppOutput(const CommandLine& cl, std::string* output) { |
| 274 return GetAppOutput(cl.GetCommandLineString(), output); | 274 return GetAppOutput(cl.GetCommandLineString(), output); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 WaitForSingleObject(proc_info.process_handle(), INFINITE); | 344 WaitForSingleObject(proc_info.process_handle(), INFINITE); |
| 345 | 345 |
| 346 return true; | 346 return true; |
| 347 } | 347 } |
| 348 | 348 |
| 349 void RaiseProcessToHighPriority() { | 349 void RaiseProcessToHighPriority() { |
| 350 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); | 350 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); |
| 351 } | 351 } |
| 352 | 352 |
| 353 } // namespace base | 353 } // namespace base |
| OLD | NEW |