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

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

Issue 1460903002: Unify PolicyBase into TargetPolicy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@policy_dispatcher
Patch Set: Rebase. 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) 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(TargetPolicy* policy)
21 : policy_base_(policy_base) { 21 : policy_(policy) {
22 static const IPCCall create_params = { 22 static const IPCCall create_params = {
23 {IPC_CREATEEVENT_TAG, {WCHAR_TYPE, UINT32_TYPE, UINT32_TYPE}}, 23 {IPC_CREATEEVENT_TAG, {WCHAR_TYPE, UINT32_TYPE, UINT32_TYPE}},
24 reinterpret_cast<CallbackGeneric>(&SyncDispatcher::CreateEvent)}; 24 reinterpret_cast<CallbackGeneric>(&SyncDispatcher::CreateEvent)};
25 25
26 static const IPCCall open_params = { 26 static const IPCCall open_params = {
27 {IPC_OPENEVENT_TAG, {WCHAR_TYPE, UINT32_TYPE}}, 27 {IPC_OPENEVENT_TAG, {WCHAR_TYPE, UINT32_TYPE}},
28 reinterpret_cast<CallbackGeneric>(&SyncDispatcher::OpenEvent)}; 28 reinterpret_cast<CallbackGeneric>(&SyncDispatcher::OpenEvent)};
29 29
30 ipc_calls_.push_back(create_params); 30 ipc_calls_.push_back(create_params);
31 ipc_calls_.push_back(open_params); 31 ipc_calls_.push_back(open_params);
32 } 32 }
33 33
34 bool SyncDispatcher::SetupService(InterceptionManager* manager, 34 bool SyncDispatcher::SetupService(InterceptionManager* manager,
35 int service) { 35 int service) {
36 if (service == IPC_CREATEEVENT_TAG) { 36 if (service == IPC_CREATEEVENT_TAG) {
37 return INTERCEPT_NT(manager, NtCreateEvent, CREATE_EVENT_ID, 24); 37 return INTERCEPT_NT(manager, NtCreateEvent, CREATE_EVENT_ID, 24);
38 } 38 }
39 return (service == IPC_OPENEVENT_TAG) && 39 return (service == IPC_OPENEVENT_TAG) &&
40 INTERCEPT_NT(manager, NtOpenEvent, OPEN_EVENT_ID, 16); 40 INTERCEPT_NT(manager, NtOpenEvent, OPEN_EVENT_ID, 16);
41 } 41 }
42 42
43 bool SyncDispatcher::CreateEvent(IPCInfo* ipc, 43 bool SyncDispatcher::CreateEvent(IPCInfo* ipc,
44 base::string16* name, 44 base::string16* name,
45 uint32 event_type, 45 uint32 event_type,
46 uint32 initial_state) { 46 uint32 initial_state) {
47 const wchar_t* event_name = name->c_str(); 47 const wchar_t* event_name = name->c_str();
48 CountedParameterSet<NameBased> params; 48 CountedParameterSet<NameBased> params;
49 params[NameBased::NAME] = ParamPickerMake(event_name); 49 params[NameBased::NAME] = ParamPickerMake(event_name);
50 50
51 EvalResult result = policy_base_->EvalPolicy(IPC_CREATEEVENT_TAG, 51 EvalResult result =
52 params.GetBase()); 52 policy_->EvalPolicy(IPC_CREATEEVENT_TAG, params.GetBase());
53 HANDLE handle = NULL; 53 HANDLE handle = NULL;
54 // Return operation status on the IPC. 54 // Return operation status on the IPC.
55 ipc->return_info.nt_status = SyncPolicy::CreateEventAction( 55 ipc->return_info.nt_status = SyncPolicy::CreateEventAction(
56 result, *ipc->client_info, *name, event_type, initial_state, &handle); 56 result, *ipc->client_info, *name, event_type, initial_state, &handle);
57 ipc->return_info.handle = handle; 57 ipc->return_info.handle = handle;
58 return true; 58 return true;
59 } 59 }
60 60
61 bool SyncDispatcher::OpenEvent(IPCInfo* ipc, 61 bool SyncDispatcher::OpenEvent(IPCInfo* ipc,
62 base::string16* name, 62 base::string16* name,
63 uint32 desired_access) { 63 uint32 desired_access) {
64 const wchar_t* event_name = name->c_str(); 64 const wchar_t* event_name = name->c_str();
65 65
66 CountedParameterSet<OpenEventParams> params; 66 CountedParameterSet<OpenEventParams> params;
67 params[OpenEventParams::NAME] = ParamPickerMake(event_name); 67 params[OpenEventParams::NAME] = ParamPickerMake(event_name);
68 params[OpenEventParams::ACCESS] = ParamPickerMake(desired_access); 68 params[OpenEventParams::ACCESS] = ParamPickerMake(desired_access);
69 69
70 EvalResult result = policy_base_->EvalPolicy(IPC_OPENEVENT_TAG, 70 EvalResult result = policy_->EvalPolicy(IPC_OPENEVENT_TAG, params.GetBase());
71 params.GetBase());
72 HANDLE handle = NULL; 71 HANDLE handle = NULL;
73 // Return operation status on the IPC. 72 // Return operation status on the IPC.
74 ipc->return_info.nt_status = SyncPolicy::OpenEventAction( 73 ipc->return_info.nt_status = SyncPolicy::OpenEventAction(
75 result, *ipc->client_info, *name, desired_access, &handle); 74 result, *ipc->client_info, *name, desired_access, &handle);
76 ipc->return_info.handle = handle; 75 ipc->return_info.handle = handle;
77 return true; 76 return true;
78 } 77 }
79 78
80 } // namespace sandbox 79 } // namespace sandbox
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698