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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
130 // break out of any job we're in to enforce our restrictions. | 130 // break out of any job we're in to enforce our restrictions. |
131 flags |= CREATE_BREAKAWAY_FROM_JOB; | 131 flags |= CREATE_BREAKAWAY_FROM_JOB; |
132 } | 132 } |
133 | 133 |
134 PROCESS_INFORMATION temp_process_info = {}; | 134 base::win::ScopedProcessInformation process_info; |
| 135 |
135 if (!::CreateProcessAsUserW(lockdown_token_, | 136 if (!::CreateProcessAsUserW(lockdown_token_, |
136 exe_path, | 137 exe_path, |
137 cmd_line.get(), | 138 cmd_line.get(), |
138 NULL, // No security attribute. | 139 NULL, // No security attribute. |
139 NULL, // No thread attribute. | 140 NULL, // No thread attribute. |
140 inherit_handles, | 141 inherit_handles, |
141 flags, | 142 flags, |
142 NULL, // Use the environment of the caller. | 143 NULL, // Use the environment of the caller. |
143 NULL, // Use current directory of the caller. | 144 NULL, // Use current directory of the caller. |
144 startup_info.startup_info(), | 145 startup_info.startup_info(), |
145 &temp_process_info)) { | 146 process_info.Receive())) { |
146 return ::GetLastError(); | 147 return ::GetLastError(); |
147 } | 148 } |
148 base::win::ScopedProcessInformation process_info(temp_process_info); | |
149 lockdown_token_.Close(); | 149 lockdown_token_.Close(); |
150 | 150 |
151 DWORD win_result = ERROR_SUCCESS; | 151 DWORD win_result = ERROR_SUCCESS; |
152 | 152 |
153 if (job_) { | 153 if (job_) { |
154 // Assign the suspended target to the windows job object. | 154 // Assign the suspended target to the windows job object. |
155 if (!::AssignProcessToJobObject(job_, process_info.process_handle())) { | 155 if (!::AssignProcessToJobObject(job_, process_info.process_handle())) { |
156 win_result = ::GetLastError(); | 156 win_result = ::GetLastError(); |
157 ::TerminateProcess(process_info.process_handle(), 0); | 157 ::TerminateProcess(process_info.process_handle(), 0); |
158 return win_result; | 158 return win_result; |
(...skipping 169 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 |