1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/sandbox/win/src/handle_interception.cc Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,45 @@ 1.4 +// Copyright (c) 2012 The Chromium Authors. All rights reserved. 1.5 +// Use of this source code is governed by a BSD-style license that can be 1.6 +// found in the LICENSE file. 1.7 + 1.8 +#include "sandbox/win/src/handle_interception.h" 1.9 + 1.10 +#include "sandbox/win/src/crosscall_client.h" 1.11 +#include "sandbox/win/src/ipc_tags.h" 1.12 +#include "sandbox/win/src/sandbox_factory.h" 1.13 +#include "sandbox/win/src/sandbox_nt_util.h" 1.14 +#include "sandbox/win/src/sharedmem_ipc_client.h" 1.15 +#include "sandbox/win/src/target_services.h" 1.16 + 1.17 +namespace sandbox { 1.18 + 1.19 +ResultCode DuplicateHandleProxy(HANDLE source_handle, 1.20 + DWORD target_process_id, 1.21 + HANDLE* target_handle, 1.22 + DWORD desired_access, 1.23 + DWORD options) { 1.24 + *target_handle = NULL; 1.25 + 1.26 + void* memory = GetGlobalIPCMemory(); 1.27 + if (NULL == memory) 1.28 + return SBOX_ERROR_NO_SPACE; 1.29 + 1.30 + SharedMemIPCClient ipc(memory); 1.31 + CrossCallReturn answer = {0}; 1.32 + ResultCode code = CrossCall(ipc, IPC_DUPLICATEHANDLEPROXY_TAG, 1.33 + source_handle, target_process_id, 1.34 + desired_access, options, &answer); 1.35 + if (SBOX_ALL_OK != code) 1.36 + return code; 1.37 + 1.38 + if (answer.win32_result) { 1.39 + ::SetLastError(answer.nt_status); 1.40 + return SBOX_ERROR_GENERIC; 1.41 + } 1.42 + 1.43 + *target_handle = answer.handle; 1.44 + return SBOX_ALL_OK; 1.45 +} 1.46 + 1.47 +} // namespace sandbox 1.48 +