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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 sizeof(g_shared_policy_size)); | 348 sizeof(g_shared_policy_size)); |
349 g_shared_policy_size = 0; | 349 g_shared_policy_size = 0; |
350 if (SBOX_ALL_OK != ret) { | 350 if (SBOX_ALL_OK != ret) { |
351 return (SBOX_ERROR_GENERIC == ret) ? | 351 return (SBOX_ERROR_GENERIC == ret) ? |
352 ::GetLastError() : ERROR_INVALID_FUNCTION; | 352 ::GetLastError() : ERROR_INVALID_FUNCTION; |
353 } | 353 } |
354 | 354 |
355 ipc_server_.reset( | 355 ipc_server_.reset( |
356 new SharedMemIPCServer(sandbox_process_info_.process_handle(), | 356 new SharedMemIPCServer(sandbox_process_info_.process_handle(), |
357 sandbox_process_info_.process_id(), | 357 sandbox_process_info_.process_id(), |
358 job_, thread_pool_, ipc_dispatcher)); | 358 thread_pool_, ipc_dispatcher)); |
359 | 359 |
360 if (!ipc_server_->Init(shared_memory, shared_IPC_size, kIPCChannelSize)) | 360 if (!ipc_server_->Init(shared_memory, shared_IPC_size, kIPCChannelSize)) |
361 return ERROR_NOT_ENOUGH_MEMORY; | 361 return ERROR_NOT_ENOUGH_MEMORY; |
362 | 362 |
363 // After this point we cannot use this handle anymore. | 363 // After this point we cannot use this handle anymore. |
364 ::CloseHandle(sandbox_process_info_.TakeThreadHandle()); | 364 ::CloseHandle(sandbox_process_info_.TakeThreadHandle()); |
365 | 365 |
366 return ERROR_SUCCESS; | 366 return ERROR_SUCCESS; |
367 } | 367 } |
368 | 368 |
369 void TargetProcess::Terminate() { | 369 void TargetProcess::Terminate() { |
370 if (!sandbox_process_info_.IsValid()) | 370 if (!sandbox_process_info_.IsValid()) |
371 return; | 371 return; |
372 | 372 |
373 ::TerminateProcess(sandbox_process_info_.process_handle(), 0); | 373 ::TerminateProcess(sandbox_process_info_.process_handle(), 0); |
374 } | 374 } |
375 | 375 |
376 TargetProcess* MakeTestTargetProcess(HANDLE process, HMODULE base_address) { | 376 TargetProcess* MakeTestTargetProcess(HANDLE process, HMODULE base_address) { |
377 TargetProcess* target = new TargetProcess(NULL, NULL, NULL, NULL); | 377 TargetProcess* target = new TargetProcess(NULL, NULL, NULL, NULL); |
378 PROCESS_INFORMATION process_info = {}; | 378 PROCESS_INFORMATION process_info = {}; |
379 process_info.hProcess = process; | 379 process_info.hProcess = process; |
380 target->sandbox_process_info_.Set(process_info); | 380 target->sandbox_process_info_.Set(process_info); |
381 target->base_address_ = base_address; | 381 target->base_address_ = base_address; |
382 return target; | 382 return target; |
383 } | 383 } |
384 | 384 |
385 } // namespace sandbox | 385 } // namespace sandbox |
OLD | NEW |