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

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

Issue 10783004: Move Windows Sandbox, trybots version (don't commit me!) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to top of tree Created 8 years, 5 months 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/src/sync_dispatcher.h ('k') | sandbox/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
(Empty)
1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "sandbox/src/sync_dispatcher.h"
6
7 #include "sandbox/src/crosscall_client.h"
8 #include "sandbox/src/interception.h"
9 #include "sandbox/src/interceptors.h"
10 #include "sandbox/src/ipc_tags.h"
11 #include "sandbox/src/policy_broker.h"
12 #include "sandbox/src/policy_params.h"
13 #include "sandbox/src/sandbox.h"
14 #include "sandbox/src/sync_interception.h"
15 #include "sandbox/src/sync_policy.h"
16
17 namespace sandbox {
18
19 SyncDispatcher::SyncDispatcher(PolicyBase* policy_base)
20 : policy_base_(policy_base) {
21 static const IPCCall create_params = {
22 {IPC_CREATEEVENT_TAG, WCHAR_TYPE, ULONG_TYPE, ULONG_TYPE},
23 reinterpret_cast<CallbackGeneric>(&SyncDispatcher::CreateEvent)
24 };
25
26 static const IPCCall open_params = {
27 {IPC_OPENEVENT_TAG, WCHAR_TYPE, ULONG_TYPE, ULONG_TYPE},
28 reinterpret_cast<CallbackGeneric>(&SyncDispatcher::OpenEvent)
29 };
30
31 ipc_calls_.push_back(create_params);
32 ipc_calls_.push_back(open_params);
33 }
34
35 bool SyncDispatcher::SetupService(InterceptionManager* manager,
36 int service) {
37 if (IPC_CREATEEVENT_TAG == service)
38 return INTERCEPT_EAT(manager, L"kernel32.dll", CreateEventW,
39 CREATE_EVENT_ID, 20);
40
41 if (IPC_OPENEVENT_TAG == service)
42 return INTERCEPT_EAT(manager, L"kernel32.dll", OpenEventW,
43 OPEN_EVENT_ID, 16);
44
45 return false;
46 }
47
48 bool SyncDispatcher::CreateEvent(IPCInfo* ipc, std::wstring* name,
49 DWORD manual_reset, DWORD initial_state) {
50 const wchar_t* event_name = name->c_str();
51 CountedParameterSet<NameBased> params;
52 params[NameBased::NAME] = ParamPickerMake(event_name);
53
54 EvalResult result = policy_base_->EvalPolicy(IPC_CREATEEVENT_TAG,
55 params.GetBase());
56 HANDLE handle = NULL;
57 DWORD ret = SyncPolicy::CreateEventAction(result, *ipc->client_info, *name,
58 manual_reset, initial_state,
59 &handle);
60 // Return operation status on the IPC.
61 ipc->return_info.win32_result = ret;
62 ipc->return_info.handle = handle;
63 return true;
64 }
65
66 bool SyncDispatcher::OpenEvent(IPCInfo* ipc, std::wstring* name,
67 DWORD desired_access, DWORD inherit_handle) {
68 const wchar_t* event_name = name->c_str();
69
70 CountedParameterSet<OpenEventParams> params;
71 params[OpenEventParams::NAME] = ParamPickerMake(event_name);
72 params[OpenEventParams::ACCESS] = ParamPickerMake(desired_access);
73
74 EvalResult result = policy_base_->EvalPolicy(IPC_OPENEVENT_TAG,
75 params.GetBase());
76 HANDLE handle = NULL;
77 DWORD ret = SyncPolicy::OpenEventAction(result, *ipc->client_info, *name,
78 desired_access, inherit_handle,
79 &handle);
80 // Return operation status on the IPC.
81 ipc->return_info.win32_result = ret;
82 ipc->return_info.handle = handle;
83 return true;
84 }
85
86 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/src/sync_dispatcher.h ('k') | sandbox/src/sync_interception.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698