| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/sync_interception.h" | 5 #include "sandbox/win/src/sync_interception.h" |
| 6 | 6 |
| 7 #include <stdint.h> |
| 8 |
| 7 #include "sandbox/win/src/crosscall_client.h" | 9 #include "sandbox/win/src/crosscall_client.h" |
| 8 #include "sandbox/win/src/ipc_tags.h" | 10 #include "sandbox/win/src/ipc_tags.h" |
| 9 #include "sandbox/win/src/policy_params.h" | 11 #include "sandbox/win/src/policy_params.h" |
| 10 #include "sandbox/win/src/policy_target.h" | 12 #include "sandbox/win/src/policy_target.h" |
| 11 #include "sandbox/win/src/sandbox_factory.h" | 13 #include "sandbox/win/src/sandbox_factory.h" |
| 12 #include "sandbox/win/src/sandbox_nt_util.h" | 14 #include "sandbox/win/src/sandbox_nt_util.h" |
| 13 #include "sandbox/win/src/sharedmem_ipc_client.h" | 15 #include "sandbox/win/src/sharedmem_ipc_client.h" |
| 14 #include "sandbox/win/src/target_services.h" | 16 #include "sandbox/win/src/target_services.h" |
| 15 | 17 |
| 16 namespace sandbox { | 18 namespace sandbox { |
| 17 | 19 |
| 18 ResultCode ProxyCreateEvent(LPCWSTR name, | 20 ResultCode ProxyCreateEvent(LPCWSTR name, |
| 19 uint32 initial_state, | 21 uint32_t initial_state, |
| 20 EVENT_TYPE event_type, | 22 EVENT_TYPE event_type, |
| 21 void* ipc_memory, | 23 void* ipc_memory, |
| 22 CrossCallReturn* answer) { | 24 CrossCallReturn* answer) { |
| 23 CountedParameterSet<NameBased> params; | 25 CountedParameterSet<NameBased> params; |
| 24 params[NameBased::NAME] = ParamPickerMake(name); | 26 params[NameBased::NAME] = ParamPickerMake(name); |
| 25 | 27 |
| 26 if (!QueryBroker(IPC_CREATEEVENT_TAG, params.GetBase())) | 28 if (!QueryBroker(IPC_CREATEEVENT_TAG, params.GetBase())) |
| 27 return SBOX_ERROR_GENERIC; | 29 return SBOX_ERROR_GENERIC; |
| 28 | 30 |
| 29 SharedMemIPCClient ipc(ipc_memory); | 31 SharedMemIPCClient ipc(ipc_memory); |
| 30 ResultCode code = CrossCall(ipc, IPC_CREATEEVENT_TAG, name, event_type, | 32 ResultCode code = CrossCall(ipc, IPC_CREATEEVENT_TAG, name, event_type, |
| 31 initial_state, answer); | 33 initial_state, answer); |
| 32 return code; | 34 return code; |
| 33 } | 35 } |
| 34 | 36 |
| 35 ResultCode ProxyOpenEvent(LPCWSTR name, | 37 ResultCode ProxyOpenEvent(LPCWSTR name, |
| 36 uint32 desired_access, | 38 uint32_t desired_access, |
| 37 void* ipc_memory, | 39 void* ipc_memory, |
| 38 CrossCallReturn* answer) { | 40 CrossCallReturn* answer) { |
| 39 CountedParameterSet<OpenEventParams> params; | 41 CountedParameterSet<OpenEventParams> params; |
| 40 params[OpenEventParams::NAME] = ParamPickerMake(name); | 42 params[OpenEventParams::NAME] = ParamPickerMake(name); |
| 41 params[OpenEventParams::ACCESS] = ParamPickerMake(desired_access); | 43 params[OpenEventParams::ACCESS] = ParamPickerMake(desired_access); |
| 42 | 44 |
| 43 if (!QueryBroker(IPC_OPENEVENT_TAG, params.GetBase())) | 45 if (!QueryBroker(IPC_OPENEVENT_TAG, params.GetBase())) |
| 44 return SBOX_ERROR_GENERIC; | 46 return SBOX_ERROR_GENERIC; |
| 45 | 47 |
| 46 SharedMemIPCClient ipc(ipc_memory); | 48 SharedMemIPCClient ipc(ipc_memory); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 72 | 74 |
| 73 void* memory = GetGlobalIPCMemory(); | 75 void* memory = GetGlobalIPCMemory(); |
| 74 if (memory == NULL) | 76 if (memory == NULL) |
| 75 break; | 77 break; |
| 76 | 78 |
| 77 OBJECT_ATTRIBUTES object_attribs_copy = *object_attributes; | 79 OBJECT_ATTRIBUTES object_attribs_copy = *object_attributes; |
| 78 // The RootDirectory points to BaseNamedObjects. We can ignore it. | 80 // The RootDirectory points to BaseNamedObjects. We can ignore it. |
| 79 object_attribs_copy.RootDirectory = NULL; | 81 object_attribs_copy.RootDirectory = NULL; |
| 80 | 82 |
| 81 wchar_t* name = NULL; | 83 wchar_t* name = NULL; |
| 82 uint32 attributes = 0; | 84 uint32_t attributes = 0; |
| 83 NTSTATUS ret = AllocAndCopyName(&object_attribs_copy, &name, &attributes, | 85 NTSTATUS ret = AllocAndCopyName(&object_attribs_copy, &name, &attributes, |
| 84 NULL); | 86 NULL); |
| 85 if (!NT_SUCCESS(ret) || name == NULL) | 87 if (!NT_SUCCESS(ret) || name == NULL) |
| 86 break; | 88 break; |
| 87 | 89 |
| 88 CrossCallReturn answer = {0}; | 90 CrossCallReturn answer = {0}; |
| 89 answer.nt_status = status; | 91 answer.nt_status = status; |
| 90 ResultCode code = ProxyCreateEvent(name, initial_state, event_type, memory, | 92 ResultCode code = ProxyCreateEvent(name, initial_state, event_type, memory, |
| 91 &answer); | 93 &answer); |
| 92 operator delete(name, NT_ALLOC); | 94 operator delete(name, NT_ALLOC); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 127 |
| 126 void* memory = GetGlobalIPCMemory(); | 128 void* memory = GetGlobalIPCMemory(); |
| 127 if (memory == NULL) | 129 if (memory == NULL) |
| 128 break; | 130 break; |
| 129 | 131 |
| 130 OBJECT_ATTRIBUTES object_attribs_copy = *object_attributes; | 132 OBJECT_ATTRIBUTES object_attribs_copy = *object_attributes; |
| 131 // The RootDirectory points to BaseNamedObjects. We can ignore it. | 133 // The RootDirectory points to BaseNamedObjects. We can ignore it. |
| 132 object_attribs_copy.RootDirectory = NULL; | 134 object_attribs_copy.RootDirectory = NULL; |
| 133 | 135 |
| 134 wchar_t* name = NULL; | 136 wchar_t* name = NULL; |
| 135 uint32 attributes = 0; | 137 uint32_t attributes = 0; |
| 136 NTSTATUS ret = AllocAndCopyName(&object_attribs_copy, &name, &attributes, | 138 NTSTATUS ret = AllocAndCopyName(&object_attribs_copy, &name, &attributes, |
| 137 NULL); | 139 NULL); |
| 138 if (!NT_SUCCESS(ret) || name == NULL) | 140 if (!NT_SUCCESS(ret) || name == NULL) |
| 139 break; | 141 break; |
| 140 | 142 |
| 141 CrossCallReturn answer = {0}; | 143 CrossCallReturn answer = {0}; |
| 142 answer.nt_status = status; | 144 answer.nt_status = status; |
| 143 ResultCode code = ProxyOpenEvent(name, desired_access, memory, &answer); | 145 ResultCode code = ProxyOpenEvent(name, desired_access, memory, &answer); |
| 144 operator delete(name, NT_ALLOC); | 146 operator delete(name, NT_ALLOC); |
| 145 | 147 |
| 146 if (code != SBOX_ALL_OK) { | 148 if (code != SBOX_ALL_OK) { |
| 147 status = answer.nt_status; | 149 status = answer.nt_status; |
| 148 break; | 150 break; |
| 149 } | 151 } |
| 150 __try { | 152 __try { |
| 151 *event_handle = answer.handle; | 153 *event_handle = answer.handle; |
| 152 status = STATUS_SUCCESS; | 154 status = STATUS_SUCCESS; |
| 153 } __except(EXCEPTION_EXECUTE_HANDLER) { | 155 } __except(EXCEPTION_EXECUTE_HANDLER) { |
| 154 break; | 156 break; |
| 155 } | 157 } |
| 156 } while (false); | 158 } while (false); |
| 157 | 159 |
| 158 return status; | 160 return status; |
| 159 } | 161 } |
| 160 | 162 |
| 161 } // namespace sandbox | 163 } // namespace sandbox |
| OLD | NEW |