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

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

Issue 41193002: Attempt3 at landing this. The previous attempt failed on Windows XP because the \Sessions\Session i… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « sandbox/win/src/sync_dispatcher.h ('k') | sandbox/win/src/sync_interception.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/sync_dispatcher.h" 5 #include "sandbox/win/src/sync_dispatcher.h"
6 6
7 #include "base/win/windows_version.h" 7 #include "base/win/windows_version.h"
8 #include "sandbox/win/src/crosscall_client.h" 8 #include "sandbox/win/src/crosscall_client.h"
9 #include "sandbox/win/src/interception.h" 9 #include "sandbox/win/src/interception.h"
10 #include "sandbox/win/src/interceptors.h" 10 #include "sandbox/win/src/interceptors.h"
11 #include "sandbox/win/src/ipc_tags.h" 11 #include "sandbox/win/src/ipc_tags.h"
12 #include "sandbox/win/src/policy_broker.h" 12 #include "sandbox/win/src/policy_broker.h"
13 #include "sandbox/win/src/policy_params.h" 13 #include "sandbox/win/src/policy_params.h"
14 #include "sandbox/win/src/sandbox.h" 14 #include "sandbox/win/src/sandbox.h"
15 #include "sandbox/win/src/sync_interception.h" 15 #include "sandbox/win/src/sync_interception.h"
16 #include "sandbox/win/src/sync_policy.h" 16 #include "sandbox/win/src/sync_policy.h"
17 17
18 namespace sandbox { 18 namespace sandbox {
19 19
20 SyncDispatcher::SyncDispatcher(PolicyBase* policy_base) 20 SyncDispatcher::SyncDispatcher(PolicyBase* policy_base)
21 : policy_base_(policy_base) { 21 : policy_base_(policy_base) {
22 static const IPCCall create_params = { 22 static const IPCCall create_params = {
23 {IPC_CREATEEVENT_TAG, WCHAR_TYPE, ULONG_TYPE, ULONG_TYPE}, 23 {IPC_CREATEEVENT_TAG, WCHAR_TYPE, ULONG_TYPE, ULONG_TYPE},
24 reinterpret_cast<CallbackGeneric>(&SyncDispatcher::CreateEvent) 24 reinterpret_cast<CallbackGeneric>(&SyncDispatcher::CreateEvent)
25 }; 25 };
26 26
27 static const IPCCall open_params = { 27 static const IPCCall open_params = {
28 {IPC_OPENEVENT_TAG, WCHAR_TYPE, ULONG_TYPE, ULONG_TYPE}, 28 {IPC_OPENEVENT_TAG, WCHAR_TYPE, ULONG_TYPE},
29 reinterpret_cast<CallbackGeneric>(&SyncDispatcher::OpenEvent) 29 reinterpret_cast<CallbackGeneric>(&SyncDispatcher::OpenEvent)
30 }; 30 };
31 31
32 ipc_calls_.push_back(create_params); 32 ipc_calls_.push_back(create_params);
33 ipc_calls_.push_back(open_params); 33 ipc_calls_.push_back(open_params);
34 } 34 }
35 35
36 bool SyncDispatcher::SetupService(InterceptionManager* manager, 36 bool SyncDispatcher::SetupService(InterceptionManager* manager,
37 int service) { 37 int service) {
38 bool ret = false;
39 // We need to intercept kernelbase.dll on Windows 7 and beyond and
40 // kernel32.dll for earlier versions.
41 static const wchar_t* kWin32SyncDllName =
42 base::win::GetVersion() >= base::win::VERSION_WIN7 ? kKernelBasedllName :
43 kKerneldllName;
44
45 if (IPC_CREATEEVENT_TAG == service) { 38 if (IPC_CREATEEVENT_TAG == service) {
46 ret = INTERCEPT_EAT(manager, kWin32SyncDllName, CreateEventW, 39 return INTERCEPT_NT(manager, NtCreateEvent, CREATE_EVENT_ID, 24);
47 CREATE_EVENTW_ID, 20);
48 if (ret) {
49 ret = INTERCEPT_EAT(manager, kWin32SyncDllName, CreateEventA,
50 CREATE_EVENTA_ID, 20);
51 }
52 } else if (IPC_OPENEVENT_TAG == service) { 40 } else if (IPC_OPENEVENT_TAG == service) {
53 ret = INTERCEPT_EAT(manager, kWin32SyncDllName, OpenEventW, OPEN_EVENTW_ID, 41 return INTERCEPT_NT(manager, NtOpenEvent, OPEN_EVENT_ID, 16);
54 16);
55 if (ret) {
56 ret = INTERCEPT_EAT(manager, kWin32SyncDllName, OpenEventA,
57 OPEN_EVENTA_ID, 16);
58 }
59 } 42 }
60 return ret; 43 return false;
61 } 44 }
62 45
63 bool SyncDispatcher::CreateEvent(IPCInfo* ipc, std::wstring* name, 46 bool SyncDispatcher::CreateEvent(IPCInfo* ipc, std::wstring* name,
64 DWORD manual_reset, DWORD initial_state) { 47 DWORD event_type, DWORD initial_state) {
65 const wchar_t* event_name = name->c_str(); 48 const wchar_t* event_name = name->c_str();
66 CountedParameterSet<NameBased> params; 49 CountedParameterSet<NameBased> params;
67 params[NameBased::NAME] = ParamPickerMake(event_name); 50 params[NameBased::NAME] = ParamPickerMake(event_name);
68 51
69 EvalResult result = policy_base_->EvalPolicy(IPC_CREATEEVENT_TAG, 52 EvalResult result = policy_base_->EvalPolicy(IPC_CREATEEVENT_TAG,
70 params.GetBase()); 53 params.GetBase());
71 HANDLE handle = NULL; 54 HANDLE handle = NULL;
72 DWORD ret = SyncPolicy::CreateEventAction(result, *ipc->client_info, *name, 55 DWORD ret = SyncPolicy::CreateEventAction(result, *ipc->client_info, *name,
73 manual_reset, initial_state, 56 event_type, initial_state,
74 &handle); 57 &handle);
75 // Return operation status on the IPC. 58 // Return operation status on the IPC.
76 ipc->return_info.win32_result = ret; 59 ipc->return_info.nt_status = ret;
77 ipc->return_info.handle = handle; 60 ipc->return_info.handle = handle;
78 return true; 61 return true;
79 } 62 }
80 63
81 bool SyncDispatcher::OpenEvent(IPCInfo* ipc, std::wstring* name, 64 bool SyncDispatcher::OpenEvent(IPCInfo* ipc, std::wstring* name,
82 DWORD desired_access, DWORD inherit_handle) { 65 DWORD desired_access) {
83 const wchar_t* event_name = name->c_str(); 66 const wchar_t* event_name = name->c_str();
84 67
85 CountedParameterSet<OpenEventParams> params; 68 CountedParameterSet<OpenEventParams> params;
86 params[OpenEventParams::NAME] = ParamPickerMake(event_name); 69 params[OpenEventParams::NAME] = ParamPickerMake(event_name);
87 params[OpenEventParams::ACCESS] = ParamPickerMake(desired_access); 70 params[OpenEventParams::ACCESS] = ParamPickerMake(desired_access);
88 71
89 EvalResult result = policy_base_->EvalPolicy(IPC_OPENEVENT_TAG, 72 EvalResult result = policy_base_->EvalPolicy(IPC_OPENEVENT_TAG,
90 params.GetBase()); 73 params.GetBase());
91 HANDLE handle = NULL; 74 HANDLE handle = NULL;
92 DWORD ret = SyncPolicy::OpenEventAction(result, *ipc->client_info, *name, 75 DWORD ret = SyncPolicy::OpenEventAction(result, *ipc->client_info, *name,
93 desired_access, inherit_handle, 76 desired_access, &handle);
94 &handle);
95 // Return operation status on the IPC. 77 // Return operation status on the IPC.
96 ipc->return_info.win32_result = ret; 78 ipc->return_info.win32_result = ret;
97 ipc->return_info.handle = handle; 79 ipc->return_info.handle = handle;
98 return true; 80 return true;
99 } 81 }
100 82
101 } // namespace sandbox 83 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/win/src/sync_dispatcher.h ('k') | sandbox/win/src/sync_interception.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698