Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: sandbox/win/src/process_thread_policy.cc

Issue 1225183003: CreateThread interception, to use CreateRemoteThread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tweaks from review Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_policy.h" 5 #include "sandbox/win/src/process_thread_policy.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "sandbox/win/src/ipc_tags.h" 10 #include "sandbox/win/src/ipc_tags.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 return false; 90 return false;
91 }; 91 };
92 } 92 }
93 93
94 if (!process->AddStringMatch(IF, NameBased::NAME, name, CASE_INSENSITIVE)) { 94 if (!process->AddStringMatch(IF, NameBased::NAME, name, CASE_INSENSITIVE)) {
95 return false; 95 return false;
96 } 96 }
97 if (!policy->AddRule(IPC_CREATEPROCESSW_TAG, process.get())) { 97 if (!policy->AddRule(IPC_CREATEPROCESSW_TAG, process.get())) {
98 return false; 98 return false;
99 } 99 }
100 if (!policy->AddRule(IPC_CREATETHREAD_TAG, process.get())) {
101 return false;
102 }
100 return true; 103 return true;
101 } 104 }
102 105
103 NTSTATUS ProcessPolicy::OpenThreadAction(const ClientInfo& client_info, 106 NTSTATUS ProcessPolicy::OpenThreadAction(const ClientInfo& client_info,
104 uint32 desired_access, 107 uint32 desired_access,
105 uint32 thread_id, 108 uint32 thread_id,
106 HANDLE* handle) { 109 HANDLE* handle) {
107 *handle = NULL; 110 *handle = NULL;
108 111
109 NtOpenThreadFunction NtOpenThread = NULL; 112 NtOpenThreadFunction NtOpenThread = NULL;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 BOOL should_give_full_access = (GIVE_ALLACCESS == eval_result); 232 BOOL should_give_full_access = (GIVE_ALLACCESS == eval_result);
230 if (!CreateProcessExWHelper(client_info.process, should_give_full_access, 233 if (!CreateProcessExWHelper(client_info.process, should_give_full_access,
231 app_name.c_str(), cmd_line.get(), NULL, NULL, 234 app_name.c_str(), cmd_line.get(), NULL, NULL,
232 FALSE, 0, NULL, NULL, &startup_info, 235 FALSE, 0, NULL, NULL, &startup_info,
233 process_info)) { 236 process_info)) {
234 return ERROR_ACCESS_DENIED; 237 return ERROR_ACCESS_DENIED;
235 } 238 }
236 return ERROR_SUCCESS; 239 return ERROR_SUCCESS;
237 } 240 }
238 241
242 DWORD ProcessPolicy::CreateThreadAction(
243 EvalResult eval_result,
244 const ClientInfo& client_info,
245 const LPSECURITY_ATTRIBUTES thread_attributes,
246 const SIZE_T stack_size,
247 const LPTHREAD_START_ROUTINE start_address,
248 const PVOID parameter,
249 const DWORD creation_flags,
250 LPDWORD thread_id,
251 HANDLE* handle) {
252 // The only action supported is ASK_BROKER which means create the process.
253 if (GIVE_ALLACCESS != eval_result && GIVE_READONLY != eval_result) {
254 return ERROR_ACCESS_DENIED;
255 }
256 HANDLE local_handle =
257 CreateRemoteThread(client_info.process, thread_attributes, stack_size,
258 start_address, parameter, creation_flags, thread_id);
259 if (!local_handle) {
260 return GetLastError();
Will Harris 2015/12/03 23:58:14 nit: use ::GetLastError() to be consistent.
261 }
262 if (!::DuplicateHandle(::GetCurrentProcess(), local_handle,
263 client_info.process, handle, 0, FALSE,
264 DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS)) {
265 return ERROR_ACCESS_DENIED;
266 }
267 return ERROR_SUCCESS;
268 }
269
239 } // namespace sandbox 270 } // namespace sandbox
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698