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