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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
283 // releases that do not support nested jobs. | 283 // releases that do not support nested jobs. |
284 if (win::GetVersion() < win::VERSION_WIN8) | 284 if (win::GetVersion() < win::VERSION_WIN8) |
285 flags |= CREATE_BREAKAWAY_FROM_JOB; | 285 flags |= CREATE_BREAKAWAY_FROM_JOB; |
286 } | 286 } |
287 | 287 |
288 if (options.force_breakaway_from_job_) | 288 if (options.force_breakaway_from_job_) |
289 flags |= CREATE_BREAKAWAY_FROM_JOB; | 289 flags |= CREATE_BREAKAWAY_FROM_JOB; |
290 | 290 |
291 PROCESS_INFORMATION temp_process_info = {}; | 291 PROCESS_INFORMATION temp_process_info = {}; |
292 | 292 |
293 LPCTSTR current_directory = options.current_directory.empty() | |
294 ? NULL | |
Lei Zhang
2016/03/29 00:57:54
nullptr in new code?
Sergey Ulanov
2016/04/04 18:01:27
Done.
| |
295 : options.current_directory.value().c_str(); | |
296 | |
293 string16 writable_cmdline(cmdline); | 297 string16 writable_cmdline(cmdline); |
294 if (options.as_user) { | 298 if (options.as_user) { |
295 flags |= CREATE_UNICODE_ENVIRONMENT; | 299 flags |= CREATE_UNICODE_ENVIRONMENT; |
296 void* enviroment_block = NULL; | 300 void* enviroment_block = NULL; |
297 | 301 |
298 if (!CreateEnvironmentBlock(&enviroment_block, options.as_user, FALSE)) { | 302 if (!CreateEnvironmentBlock(&enviroment_block, options.as_user, FALSE)) { |
299 DPLOG(ERROR); | 303 DPLOG(ERROR); |
300 return Process(); | 304 return Process(); |
301 } | 305 } |
302 | 306 |
303 BOOL launched = | 307 BOOL launched = CreateProcessAsUser( |
304 CreateProcessAsUser(options.as_user, NULL, | 308 options.as_user, NULL, &writable_cmdline[0], NULL, NULL, |
305 &writable_cmdline[0], | 309 inherit_handles, flags, enviroment_block, current_directory, |
306 NULL, NULL, inherit_handles, flags, | 310 startup_info, &temp_process_info); |
307 enviroment_block, NULL, startup_info, | |
308 &temp_process_info); | |
309 DestroyEnvironmentBlock(enviroment_block); | 311 DestroyEnvironmentBlock(enviroment_block); |
310 if (!launched) { | 312 if (!launched) { |
311 DPLOG(ERROR) << "Command line:" << std::endl << UTF16ToUTF8(cmdline) | 313 DPLOG(ERROR) << "Command line:" << std::endl << UTF16ToUTF8(cmdline) |
312 << std::endl; | 314 << std::endl; |
313 return Process(); | 315 return Process(); |
314 } | 316 } |
315 } else { | 317 } else { |
316 if (!CreateProcess(NULL, | 318 if (!CreateProcess(NULL, &writable_cmdline[0], NULL, NULL, inherit_handles, |
317 &writable_cmdline[0], NULL, NULL, | 319 flags, NULL, current_directory, startup_info, |
318 inherit_handles, flags, NULL, NULL, | 320 &temp_process_info)) { |
319 startup_info, &temp_process_info)) { | |
320 DPLOG(ERROR) << "Command line:" << std::endl << UTF16ToUTF8(cmdline) | 321 DPLOG(ERROR) << "Command line:" << std::endl << UTF16ToUTF8(cmdline) |
321 << std::endl; | 322 << std::endl; |
322 return Process(); | 323 return Process(); |
323 } | 324 } |
324 } | 325 } |
325 base::win::ScopedProcessInformation process_info(temp_process_info); | 326 base::win::ScopedProcessInformation process_info(temp_process_info); |
326 | 327 |
327 if (options.job_handle) { | 328 if (options.job_handle) { |
328 if (0 == AssignProcessToJobObject(options.job_handle, | 329 if (0 == AssignProcessToJobObject(options.job_handle, |
329 process_info.process_handle())) { | 330 process_info.process_handle())) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
389 | 390 |
390 bool GetAppOutput(const StringPiece16& cl, std::string* output) { | 391 bool GetAppOutput(const StringPiece16& cl, std::string* output) { |
391 return GetAppOutputInternal(cl, false, output); | 392 return GetAppOutputInternal(cl, false, output); |
392 } | 393 } |
393 | 394 |
394 void RaiseProcessToHighPriority() { | 395 void RaiseProcessToHighPriority() { |
395 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); | 396 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); |
396 } | 397 } |
397 | 398 |
398 } // namespace base | 399 } // namespace base |
OLD | NEW |