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

Unified Diff: sandbox/win/src/process_thread_dispatcher.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 side-by-side diff with in-line comments
Download patch
Index: sandbox/win/src/process_thread_dispatcher.cc
diff --git a/sandbox/win/src/process_thread_dispatcher.cc b/sandbox/win/src/process_thread_dispatcher.cc
index 90cad6365f927d2f1aed9fadc3e0d9195ce8c01a..6df727e5e0654c3adda7388e8fc6c5bb569fce82 100644
--- a/sandbox/win/src/process_thread_dispatcher.cc
+++ b/sandbox/win/src/process_thread_dispatcher.cc
@@ -122,11 +122,21 @@ ThreadProcessDispatcher::ThreadProcessDispatcher(PolicyBase* policy_base)
reinterpret_cast<CallbackGeneric>(
&ThreadProcessDispatcher::CreateProcessW)};
+ // NOTE(liamjm): 2nd param is size_t: Using VOIDPTR_TYPE as they are
+ // the same size on windows.
+ 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.
+ static const IPCCall create_thread_params = {
+ {IPC_CREATETHREAD_TAG,
+ {VOIDPTR_TYPE, VOIDPTR_TYPE, VOIDPTR_TYPE, VOIDPTR_TYPE, UINT32_TYPE}},
+ reinterpret_cast<CallbackGeneric>(
+ &ThreadProcessDispatcher::CreateThread)};
+
ipc_calls_.push_back(open_thread);
ipc_calls_.push_back(open_process);
ipc_calls_.push_back(process_token);
ipc_calls_.push_back(process_tokenex);
ipc_calls_.push_back(create_params);
+ ipc_calls_.push_back(create_thread_params);
}
bool ThreadProcessDispatcher::SetupService(InterceptionManager* manager,
@@ -146,6 +156,10 @@ bool ThreadProcessDispatcher::SetupService(InterceptionManager* manager,
INTERCEPT_EAT(manager, L"kernel32.dll", CreateProcessA,
CREATE_PROCESSA_ID, 44);
+ case IPC_CREATETHREAD_TAG:
+ return INTERCEPT_EAT(manager, kKerneldllName, CreateThread,
+ CREATE_THREAD_ID, 28);
+
default:
return false;
}
@@ -242,4 +256,25 @@ bool ThreadProcessDispatcher::CreateProcessW(IPCInfo* ipc, base::string16* name,
return true;
}
+bool ThreadProcessDispatcher::CreateThread(
+ IPCInfo* ipc,
+ LPSECURITY_ATTRIBUTES thread_attributes,
+ SIZE_T stack_size,
+ LPTHREAD_START_ROUTINE start_address,
+ PVOID parameter,
+ DWORD creation_flags) {
+ if (!start_address) {
+ return false;
+ }
+
+ HANDLE handle;
+ DWORD ret = ProcessPolicy::CreateThreadAction(
+ GIVE_ALLACCESS, *ipc->client_info, thread_attributes, stack_size,
+ start_address, parameter, creation_flags, NULL, &handle);
+
+ ipc->return_info.nt_status = ret;
+ ipc->return_info.handle = handle;
+ return true;
+}
+
} // namespace sandbox

Powered by Google App Engine
This is Rietveld 408576698