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 <stddef.h> | 7 #include "base/basictypes.h" |
8 #include <stdint.h> | |
9 | |
10 #include "base/macros.h" | 8 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
12 #include "base/win/pe_image.h" | 10 #include "base/win/pe_image.h" |
13 #include "base/win/startup_information.h" | 11 #include "base/win/startup_information.h" |
14 #include "base/win/windows_version.h" | 12 #include "base/win/windows_version.h" |
| 13 #include "sandbox/win/src/crosscall_server.h" |
15 #include "sandbox/win/src/crosscall_client.h" | 14 #include "sandbox/win/src/crosscall_client.h" |
16 #include "sandbox/win/src/crosscall_server.h" | |
17 #include "sandbox/win/src/policy_low_level.h" | 15 #include "sandbox/win/src/policy_low_level.h" |
18 #include "sandbox/win/src/sandbox_types.h" | 16 #include "sandbox/win/src/sandbox_types.h" |
19 #include "sandbox/win/src/sharedmem_ipc_server.h" | 17 #include "sandbox/win/src/sharedmem_ipc_server.h" |
20 #include "sandbox/win/src/win_utils.h" | 18 #include "sandbox/win/src/win_utils.h" |
21 | 19 |
22 namespace { | 20 namespace { |
23 | 21 |
24 void CopyPolicyToTarget(const void* source, size_t size, void* dest) { | 22 void CopyPolicyToTarget(const void* source, size_t size, void* dest) { |
25 if (!source || !size) | 23 if (!source || !size) |
26 return; | 24 return; |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 return SBOX_ERROR_GENERIC; | 259 return SBOX_ERROR_GENERIC; |
262 | 260 |
263 if (written != size) | 261 if (written != size) |
264 return SBOX_ERROR_GENERIC; | 262 return SBOX_ERROR_GENERIC; |
265 | 263 |
266 return SBOX_ALL_OK; | 264 return SBOX_ALL_OK; |
267 } | 265 } |
268 | 266 |
269 // Construct the IPC server and the IPC dispatcher. When the target does | 267 // Construct the IPC server and the IPC dispatcher. When the target does |
270 // an IPC it will eventually call the dispatcher. | 268 // an IPC it will eventually call the dispatcher. |
271 DWORD TargetProcess::Init(Dispatcher* ipc_dispatcher, | 269 DWORD TargetProcess::Init(Dispatcher* ipc_dispatcher, void* policy, |
272 void* policy, | 270 uint32 shared_IPC_size, uint32 shared_policy_size) { |
273 uint32_t shared_IPC_size, | |
274 uint32_t shared_policy_size) { | |
275 // We need to map the shared memory on the target. This is necessary for | 271 // We need to map the shared memory on the target. This is necessary for |
276 // any IPC that needs to take place, even if the target has not yet hit | 272 // any IPC that needs to take place, even if the target has not yet hit |
277 // the main( ) function or even has initialized the CRT. So here we set | 273 // the main( ) function or even has initialized the CRT. So here we set |
278 // the handle to the shared section. The target on the first IPC must do | 274 // the handle to the shared section. The target on the first IPC must do |
279 // the rest, which boils down to calling MapViewofFile() | 275 // the rest, which boils down to calling MapViewofFile() |
280 | 276 |
281 // We use this single memory pool for IPC and for policy. | 277 // We use this single memory pool for IPC and for policy. |
282 DWORD shared_mem_size = static_cast<DWORD>(shared_IPC_size + | 278 DWORD shared_mem_size = static_cast<DWORD>(shared_IPC_size + |
283 shared_policy_size); | 279 shared_policy_size); |
284 shared_section_.Set(::CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, | 280 shared_section_.Set(::CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 new TargetProcess(base::win::ScopedHandle(), base::win::ScopedHandle(), | 355 new TargetProcess(base::win::ScopedHandle(), base::win::ScopedHandle(), |
360 base::win::ScopedHandle(), NULL, NULL); | 356 base::win::ScopedHandle(), NULL, NULL); |
361 PROCESS_INFORMATION process_info = {}; | 357 PROCESS_INFORMATION process_info = {}; |
362 process_info.hProcess = process; | 358 process_info.hProcess = process; |
363 target->sandbox_process_info_.Set(process_info); | 359 target->sandbox_process_info_.Set(process_info); |
364 target->base_address_ = base_address; | 360 target->base_address_ = base_address; |
365 return target; | 361 return target; |
366 } | 362 } |
367 | 363 |
368 } // namespace sandbox | 364 } // namespace sandbox |
OLD | NEW |