Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. |
michael@0 | 2 | // Use of this source code is governed by a BSD-style license that can be |
michael@0 | 3 | // found in the LICENSE file. |
michael@0 | 4 | |
michael@0 | 5 | #include "sandbox/win/src/sync_dispatcher.h" |
michael@0 | 6 | |
michael@0 | 7 | #include "sandbox/win/src/crosscall_client.h" |
michael@0 | 8 | #include "sandbox/win/src/interception.h" |
michael@0 | 9 | #include "sandbox/win/src/interceptors.h" |
michael@0 | 10 | #include "sandbox/win/src/ipc_tags.h" |
michael@0 | 11 | #include "sandbox/win/src/policy_broker.h" |
michael@0 | 12 | #include "sandbox/win/src/policy_params.h" |
michael@0 | 13 | #include "sandbox/win/src/sandbox.h" |
michael@0 | 14 | #include "sandbox/win/src/sync_interception.h" |
michael@0 | 15 | #include "sandbox/win/src/sync_policy.h" |
michael@0 | 16 | |
michael@0 | 17 | namespace sandbox { |
michael@0 | 18 | |
michael@0 | 19 | SyncDispatcher::SyncDispatcher(PolicyBase* policy_base) |
michael@0 | 20 | : policy_base_(policy_base) { |
michael@0 | 21 | static const IPCCall create_params = { |
michael@0 | 22 | {IPC_CREATEEVENT_TAG, WCHAR_TYPE, ULONG_TYPE, ULONG_TYPE}, |
michael@0 | 23 | reinterpret_cast<CallbackGeneric>(&SyncDispatcher::CreateEvent) |
michael@0 | 24 | }; |
michael@0 | 25 | |
michael@0 | 26 | static const IPCCall open_params = { |
michael@0 | 27 | {IPC_OPENEVENT_TAG, WCHAR_TYPE, ULONG_TYPE, ULONG_TYPE}, |
michael@0 | 28 | reinterpret_cast<CallbackGeneric>(&SyncDispatcher::OpenEvent) |
michael@0 | 29 | }; |
michael@0 | 30 | |
michael@0 | 31 | ipc_calls_.push_back(create_params); |
michael@0 | 32 | ipc_calls_.push_back(open_params); |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | bool SyncDispatcher::SetupService(InterceptionManager* manager, |
michael@0 | 36 | int service) { |
michael@0 | 37 | if (IPC_CREATEEVENT_TAG == service) |
michael@0 | 38 | return INTERCEPT_EAT(manager, L"kernel32.dll", CreateEventW, |
michael@0 | 39 | CREATE_EVENT_ID, 20); |
michael@0 | 40 | |
michael@0 | 41 | if (IPC_OPENEVENT_TAG == service) |
michael@0 | 42 | return INTERCEPT_EAT(manager, L"kernel32.dll", OpenEventW, |
michael@0 | 43 | OPEN_EVENT_ID, 16); |
michael@0 | 44 | |
michael@0 | 45 | return false; |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | bool SyncDispatcher::CreateEvent(IPCInfo* ipc, std::wstring* name, |
michael@0 | 49 | DWORD manual_reset, DWORD initial_state) { |
michael@0 | 50 | const wchar_t* event_name = name->c_str(); |
michael@0 | 51 | CountedParameterSet<NameBased> params; |
michael@0 | 52 | params[NameBased::NAME] = ParamPickerMake(event_name); |
michael@0 | 53 | |
michael@0 | 54 | EvalResult result = policy_base_->EvalPolicy(IPC_CREATEEVENT_TAG, |
michael@0 | 55 | params.GetBase()); |
michael@0 | 56 | HANDLE handle = NULL; |
michael@0 | 57 | DWORD ret = SyncPolicy::CreateEventAction(result, *ipc->client_info, *name, |
michael@0 | 58 | manual_reset, initial_state, |
michael@0 | 59 | &handle); |
michael@0 | 60 | // Return operation status on the IPC. |
michael@0 | 61 | ipc->return_info.win32_result = ret; |
michael@0 | 62 | ipc->return_info.handle = handle; |
michael@0 | 63 | return true; |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | bool SyncDispatcher::OpenEvent(IPCInfo* ipc, std::wstring* name, |
michael@0 | 67 | DWORD desired_access, DWORD inherit_handle) { |
michael@0 | 68 | const wchar_t* event_name = name->c_str(); |
michael@0 | 69 | |
michael@0 | 70 | CountedParameterSet<OpenEventParams> params; |
michael@0 | 71 | params[OpenEventParams::NAME] = ParamPickerMake(event_name); |
michael@0 | 72 | params[OpenEventParams::ACCESS] = ParamPickerMake(desired_access); |
michael@0 | 73 | |
michael@0 | 74 | EvalResult result = policy_base_->EvalPolicy(IPC_OPENEVENT_TAG, |
michael@0 | 75 | params.GetBase()); |
michael@0 | 76 | HANDLE handle = NULL; |
michael@0 | 77 | DWORD ret = SyncPolicy::OpenEventAction(result, *ipc->client_info, *name, |
michael@0 | 78 | desired_access, inherit_handle, |
michael@0 | 79 | &handle); |
michael@0 | 80 | // Return operation status on the IPC. |
michael@0 | 81 | ipc->return_info.win32_result = ret; |
michael@0 | 82 | ipc->return_info.handle = handle; |
michael@0 | 83 | return true; |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | } // namespace sandbox |