| 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/macros.h" |
| 8 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/win/pe_image.h" | 10 #include "base/win/pe_image.h" |
| 10 #include "base/win/startup_information.h" | 11 #include "base/win/startup_information.h" |
| 11 #include "base/win/windows_version.h" | 12 #include "base/win/windows_version.h" |
| 12 #include "sandbox/win/src/crosscall_server.h" | 13 #include "sandbox/win/src/crosscall_server.h" |
| 13 #include "sandbox/win/src/crosscall_client.h" | 14 #include "sandbox/win/src/crosscall_client.h" |
| 14 #include "sandbox/win/src/policy_low_level.h" | 15 #include "sandbox/win/src/policy_low_level.h" |
| 15 #include "sandbox/win/src/sandbox_types.h" | 16 #include "sandbox/win/src/sandbox_types.h" |
| 16 #include "sandbox/win/src/sharedmem_ipc_server.h" | 17 #include "sandbox/win/src/sharedmem_ipc_server.h" |
| 17 #include "sandbox/win/src/win_utils.h" | 18 #include "sandbox/win/src/win_utils.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 ::WaitForSingleObject(sandbox_process_info_.process_handle(), 50); | 93 ::WaitForSingleObject(sandbox_process_info_.process_handle(), 50); |
| 93 // At this point, the target process should have been killed. Check. | 94 // At this point, the target process should have been killed. Check. |
| 94 if (!::GetExitCodeProcess(sandbox_process_info_.process_handle(), | 95 if (!::GetExitCodeProcess(sandbox_process_info_.process_handle(), |
| 95 &exit_code) || (STILL_ACTIVE == exit_code)) { | 96 &exit_code) || (STILL_ACTIVE == exit_code)) { |
| 96 // Something went wrong. We don't know if the target is in a state where | 97 // Something went wrong. We don't know if the target is in a state where |
| 97 // it can manage to do another IPC call. If it can, and we've destroyed | 98 // it can manage to do another IPC call. If it can, and we've destroyed |
| 98 // the |ipc_server_|, it will crash the broker. So we intentionally leak | 99 // the |ipc_server_|, it will crash the broker. So we intentionally leak |
| 99 // that. | 100 // that. |
| 100 if (shared_section_.IsValid()) | 101 if (shared_section_.IsValid()) |
| 101 shared_section_.Take(); | 102 shared_section_.Take(); |
| 102 ipc_server_.release(); | 103 ignore_result(ipc_server_.release()); |
| 103 sandbox_process_info_.TakeProcessHandle(); | 104 sandbox_process_info_.TakeProcessHandle(); |
| 104 return; | 105 return; |
| 105 } | 106 } |
| 106 } | 107 } |
| 107 | 108 |
| 108 // ipc_server_ references our process handle, so make sure the former is shut | 109 // ipc_server_ references our process handle, so make sure the former is shut |
| 109 // down before the latter is closed (by ScopedProcessInformation). | 110 // down before the latter is closed (by ScopedProcessInformation). |
| 110 ipc_server_.reset(); | 111 ipc_server_.reset(); |
| 111 } | 112 } |
| 112 | 113 |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 base::win::ScopedHandle(), | 378 base::win::ScopedHandle(), |
| 378 NULL, NULL); | 379 NULL, NULL); |
| 379 PROCESS_INFORMATION process_info = {}; | 380 PROCESS_INFORMATION process_info = {}; |
| 380 process_info.hProcess = process; | 381 process_info.hProcess = process; |
| 381 target->sandbox_process_info_.Set(process_info); | 382 target->sandbox_process_info_.Set(process_info); |
| 382 target->base_address_ = base_address; | 383 target->base_address_ = base_address; |
| 383 return target; | 384 return target; |
| 384 } | 385 } |
| 385 | 386 |
| 386 } // namespace sandbox | 387 } // namespace sandbox |
| OLD | NEW |