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