OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/process_thread_dispatcher.h" | 5 #include "sandbox/win/src/process_thread_dispatcher.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "sandbox/win/src/crosscall_client.h" | 9 #include "sandbox/win/src/crosscall_client.h" |
10 #include "sandbox/win/src/interception.h" | 10 #include "sandbox/win/src/interception.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
115 {IPC_NTOPENPROCESSTOKENEX_TAG, {VOIDPTR_TYPE, UINT32_TYPE, UINT32_TYPE}}, | 115 {IPC_NTOPENPROCESSTOKENEX_TAG, {VOIDPTR_TYPE, UINT32_TYPE, UINT32_TYPE}}, |
116 reinterpret_cast<CallbackGeneric>( | 116 reinterpret_cast<CallbackGeneric>( |
117 &ThreadProcessDispatcher::NtOpenProcessTokenEx)}; | 117 &ThreadProcessDispatcher::NtOpenProcessTokenEx)}; |
118 | 118 |
119 static const IPCCall create_params = { | 119 static const IPCCall create_params = { |
120 {IPC_CREATEPROCESSW_TAG, | 120 {IPC_CREATEPROCESSW_TAG, |
121 {WCHAR_TYPE, WCHAR_TYPE, WCHAR_TYPE, INOUTPTR_TYPE}}, | 121 {WCHAR_TYPE, WCHAR_TYPE, WCHAR_TYPE, INOUTPTR_TYPE}}, |
122 reinterpret_cast<CallbackGeneric>( | 122 reinterpret_cast<CallbackGeneric>( |
123 &ThreadProcessDispatcher::CreateProcessW)}; | 123 &ThreadProcessDispatcher::CreateProcessW)}; |
124 | 124 |
125 // NOTE(liamjm): 2nd param is size_t: Using VOIDPTR_TYPE as they are | |
126 // the same size on windows. | |
127 assert(sizeof(size_t) == sizeof(void*)); | |
Will Harris
2015/12/03 23:58:14
this should be static_assert - see https://groups.
liamjm (20p)
2016/02/01 23:36:39
Done.
| |
128 static const IPCCall create_thread_params = { | |
129 {IPC_CREATETHREAD_TAG, | |
130 {VOIDPTR_TYPE, VOIDPTR_TYPE, VOIDPTR_TYPE, VOIDPTR_TYPE, UINT32_TYPE}}, | |
131 reinterpret_cast<CallbackGeneric>( | |
132 &ThreadProcessDispatcher::CreateThread)}; | |
133 | |
125 ipc_calls_.push_back(open_thread); | 134 ipc_calls_.push_back(open_thread); |
126 ipc_calls_.push_back(open_process); | 135 ipc_calls_.push_back(open_process); |
127 ipc_calls_.push_back(process_token); | 136 ipc_calls_.push_back(process_token); |
128 ipc_calls_.push_back(process_tokenex); | 137 ipc_calls_.push_back(process_tokenex); |
129 ipc_calls_.push_back(create_params); | 138 ipc_calls_.push_back(create_params); |
139 ipc_calls_.push_back(create_thread_params); | |
130 } | 140 } |
131 | 141 |
132 bool ThreadProcessDispatcher::SetupService(InterceptionManager* manager, | 142 bool ThreadProcessDispatcher::SetupService(InterceptionManager* manager, |
133 int service) { | 143 int service) { |
134 switch (service) { | 144 switch (service) { |
135 case IPC_NTOPENTHREAD_TAG: | 145 case IPC_NTOPENTHREAD_TAG: |
136 case IPC_NTOPENPROCESS_TAG: | 146 case IPC_NTOPENPROCESS_TAG: |
137 case IPC_NTOPENPROCESSTOKEN_TAG: | 147 case IPC_NTOPENPROCESSTOKEN_TAG: |
138 case IPC_NTOPENPROCESSTOKENEX_TAG: | 148 case IPC_NTOPENPROCESSTOKENEX_TAG: |
139 // There is no explicit policy for these services. | 149 // There is no explicit policy for these services. |
140 NOTREACHED(); | 150 NOTREACHED(); |
141 return false; | 151 return false; |
142 | 152 |
143 case IPC_CREATEPROCESSW_TAG: | 153 case IPC_CREATEPROCESSW_TAG: |
144 return INTERCEPT_EAT(manager, kKerneldllName, CreateProcessW, | 154 return INTERCEPT_EAT(manager, kKerneldllName, CreateProcessW, |
145 CREATE_PROCESSW_ID, 44) && | 155 CREATE_PROCESSW_ID, 44) && |
146 INTERCEPT_EAT(manager, L"kernel32.dll", CreateProcessA, | 156 INTERCEPT_EAT(manager, L"kernel32.dll", CreateProcessA, |
147 CREATE_PROCESSA_ID, 44); | 157 CREATE_PROCESSA_ID, 44); |
148 | 158 |
159 case IPC_CREATETHREAD_TAG: | |
160 return INTERCEPT_EAT(manager, kKerneldllName, CreateThread, | |
161 CREATE_THREAD_ID, 28); | |
162 | |
149 default: | 163 default: |
150 return false; | 164 return false; |
151 } | 165 } |
152 } | 166 } |
153 | 167 |
154 bool ThreadProcessDispatcher::NtOpenThread(IPCInfo* ipc, | 168 bool ThreadProcessDispatcher::NtOpenThread(IPCInfo* ipc, |
155 uint32 desired_access, | 169 uint32 desired_access, |
156 uint32 thread_id) { | 170 uint32 thread_id) { |
157 HANDLE handle; | 171 HANDLE handle; |
158 NTSTATUS ret = ProcessPolicy::OpenThreadAction(*ipc->client_info, | 172 NTSTATUS ret = ProcessPolicy::OpenThreadAction(*ipc->client_info, |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
235 // Here we force the app_name to be the one we used for the policy lookup. | 249 // Here we force the app_name to be the one we used for the policy lookup. |
236 // If our logic was wrong, at least we wont allow create a random process. | 250 // If our logic was wrong, at least we wont allow create a random process. |
237 DWORD ret = ProcessPolicy::CreateProcessWAction(eval, *ipc->client_info, | 251 DWORD ret = ProcessPolicy::CreateProcessWAction(eval, *ipc->client_info, |
238 exe_name, *cmd_line, | 252 exe_name, *cmd_line, |
239 proc_info); | 253 proc_info); |
240 | 254 |
241 ipc->return_info.win32_result = ret; | 255 ipc->return_info.win32_result = ret; |
242 return true; | 256 return true; |
243 } | 257 } |
244 | 258 |
259 bool ThreadProcessDispatcher::CreateThread( | |
260 IPCInfo* ipc, | |
261 LPSECURITY_ATTRIBUTES thread_attributes, | |
262 SIZE_T stack_size, | |
263 LPTHREAD_START_ROUTINE start_address, | |
264 PVOID parameter, | |
265 DWORD creation_flags) { | |
266 if (!start_address) { | |
267 return false; | |
268 } | |
269 | |
270 HANDLE handle; | |
271 DWORD ret = ProcessPolicy::CreateThreadAction( | |
272 GIVE_ALLACCESS, *ipc->client_info, thread_attributes, stack_size, | |
273 start_address, parameter, creation_flags, NULL, &handle); | |
274 | |
275 ipc->return_info.nt_status = ret; | |
276 ipc->return_info.handle = handle; | |
277 return true; | |
278 } | |
279 | |
245 } // namespace sandbox | 280 } // namespace sandbox |
OLD | NEW |