| 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 "sandbox/win/src/target_process.h" | 5 #include "sandbox/win/src/target_process.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/win/pe_image.h" | 9 #include "base/win/pe_image.h" |
| 10 #include "base/win/startup_information.h" | 10 #include "base/win/startup_information.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // Creates the target (child) process suspended and assigns it to the job | 109 // Creates the target (child) process suspended and assigns it to the job |
| 110 // object. | 110 // object. |
| 111 DWORD TargetProcess::Create(const wchar_t* exe_path, | 111 DWORD TargetProcess::Create(const wchar_t* exe_path, |
| 112 const wchar_t* command_line, | 112 const wchar_t* command_line, |
| 113 bool inherit_handles, | 113 bool inherit_handles, |
| 114 const base::win::StartupInformation& startup_info, | 114 const base::win::StartupInformation& startup_info, |
| 115 base::win::ScopedProcessInformation* target_info) { | 115 base::win::ScopedProcessInformation* target_info) { |
| 116 exe_name_.reset(_wcsdup(exe_path)); | 116 exe_name_.reset(_wcsdup(exe_path)); |
| 117 | 117 |
| 118 // the command line needs to be writable by CreateProcess(). | 118 // the command line needs to be writable by CreateProcess(). |
| 119 scoped_ptr_malloc<wchar_t> cmd_line(_wcsdup(command_line)); | 119 scoped_ptr<wchar_t, base::FreeDeleter> cmd_line(_wcsdup(command_line)); |
| 120 | 120 |
| 121 // Start the target process suspended. | 121 // Start the target process suspended. |
| 122 DWORD flags = | 122 DWORD flags = |
| 123 CREATE_SUSPENDED | CREATE_UNICODE_ENVIRONMENT | DETACHED_PROCESS; | 123 CREATE_SUSPENDED | CREATE_UNICODE_ENVIRONMENT | DETACHED_PROCESS; |
| 124 | 124 |
| 125 if (startup_info.has_extended_startup_info()) | 125 if (startup_info.has_extended_startup_info()) |
| 126 flags |= EXTENDED_STARTUPINFO_PRESENT; | 126 flags |= EXTENDED_STARTUPINFO_PRESENT; |
| 127 | 127 |
| 128 if (job_ && base::win::GetVersion() < base::win::VERSION_WIN8) { | 128 if (job_ && base::win::GetVersion() < base::win::VERSION_WIN8) { |
| 129 // Windows 8 implements nested jobs, but for older systems we need to | 129 // Windows 8 implements nested jobs, but for older systems we need to |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 TargetProcess* MakeTestTargetProcess(HANDLE process, HMODULE base_address) { | 328 TargetProcess* MakeTestTargetProcess(HANDLE process, HMODULE base_address) { |
| 329 TargetProcess* target = new TargetProcess(NULL, NULL, NULL, NULL); | 329 TargetProcess* target = new TargetProcess(NULL, NULL, NULL, NULL); |
| 330 PROCESS_INFORMATION process_info = {}; | 330 PROCESS_INFORMATION process_info = {}; |
| 331 process_info.hProcess = process; | 331 process_info.hProcess = process; |
| 332 target->sandbox_process_info_.Set(process_info); | 332 target->sandbox_process_info_.Set(process_info); |
| 333 target->base_address_ = base_address; | 333 target->base_address_ = base_address; |
| 334 return target; | 334 return target; |
| 335 } | 335 } |
| 336 | 336 |
| 337 } // namespace sandbox | 337 } // namespace sandbox |
| OLD | NEW |