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_util.h" | 5 #include "base/process_util.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> |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 | 344 |
345 if (options.force_breakaway_from_job_) | 345 if (options.force_breakaway_from_job_) |
346 flags |= CREATE_BREAKAWAY_FROM_JOB; | 346 flags |= CREATE_BREAKAWAY_FROM_JOB; |
347 | 347 |
348 base::win::ScopedProcessInformation process_info; | 348 base::win::ScopedProcessInformation process_info; |
349 | 349 |
350 if (options.as_user) { | 350 if (options.as_user) { |
351 flags |= CREATE_UNICODE_ENVIRONMENT; | 351 flags |= CREATE_UNICODE_ENVIRONMENT; |
352 void* enviroment_block = NULL; | 352 void* enviroment_block = NULL; |
353 | 353 |
354 if (!CreateEnvironmentBlock(&enviroment_block, options.as_user, FALSE)) | 354 if (!CreateEnvironmentBlock(&enviroment_block, options.as_user, FALSE)) { |
| 355 DPLOG(ERROR); |
355 return false; | 356 return false; |
| 357 } |
356 | 358 |
357 BOOL launched = | 359 BOOL launched = |
358 CreateProcessAsUser(options.as_user, NULL, | 360 CreateProcessAsUser(options.as_user, NULL, |
359 const_cast<wchar_t*>(cmdline.c_str()), | 361 const_cast<wchar_t*>(cmdline.c_str()), |
360 NULL, NULL, options.inherit_handles, flags, | 362 NULL, NULL, options.inherit_handles, flags, |
361 enviroment_block, NULL, &startup_info, | 363 enviroment_block, NULL, &startup_info, |
362 process_info.Receive()); | 364 process_info.Receive()); |
363 DestroyEnvironmentBlock(enviroment_block); | 365 DestroyEnvironmentBlock(enviroment_block); |
364 if (!launched) | 366 if (!launched) { |
| 367 DPLOG(ERROR); |
365 return false; | 368 return false; |
| 369 } |
366 } else { | 370 } else { |
367 if (!CreateProcess(NULL, | 371 if (!CreateProcess(NULL, |
368 const_cast<wchar_t*>(cmdline.c_str()), NULL, NULL, | 372 const_cast<wchar_t*>(cmdline.c_str()), NULL, NULL, |
369 options.inherit_handles, flags, NULL, NULL, | 373 options.inherit_handles, flags, NULL, NULL, |
370 &startup_info, process_info.Receive())) { | 374 &startup_info, process_info.Receive())) { |
| 375 DPLOG(ERROR); |
371 return false; | 376 return false; |
372 } | 377 } |
373 } | 378 } |
374 | 379 |
375 if (options.job_handle) { | 380 if (options.job_handle) { |
376 if (0 == AssignProcessToJobObject(options.job_handle, | 381 if (0 == AssignProcessToJobObject(options.job_handle, |
377 process_info.process_handle())) { | 382 process_info.process_handle())) { |
378 DLOG(ERROR) << "Could not AssignProcessToObject."; | 383 DLOG(ERROR) << "Could not AssignProcessToObject."; |
379 KillProcess(process_info.process_handle(), kProcessKilledExitCode, true); | 384 KillProcess(process_info.process_handle(), kProcessKilledExitCode, true); |
380 return false; | 385 return false; |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 | 1019 |
1015 PERFORMANCE_INFORMATION info; | 1020 PERFORMANCE_INFORMATION info; |
1016 if (!InternalGetPerformanceInfo(&info, sizeof(info))) { | 1021 if (!InternalGetPerformanceInfo(&info, sizeof(info))) { |
1017 DLOG(ERROR) << "Failed to fetch internal performance info."; | 1022 DLOG(ERROR) << "Failed to fetch internal performance info."; |
1018 return 0; | 1023 return 0; |
1019 } | 1024 } |
1020 return (info.CommitTotal * system_info.dwPageSize) / 1024; | 1025 return (info.CommitTotal * system_info.dwPageSize) / 1024; |
1021 } | 1026 } |
1022 | 1027 |
1023 } // namespace base | 1028 } // namespace base |
OLD | NEW |