| OLD | NEW |
| 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" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 {IPC_OPENEVENT_TAG, WCHAR_TYPE, ULONG_TYPE, ULONG_TYPE}, | 28 {IPC_OPENEVENT_TAG, WCHAR_TYPE, ULONG_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 manual_reset, 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()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 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, inherit_handle, |
| 94 &handle); | 77 &handle); |
| 95 // Return operation status on the IPC. | 78 // Return operation status on the IPC. |
| 96 ipc->return_info.win32_result = ret; | 79 ipc->return_info.win32_result = ret; |
| 97 ipc->return_info.handle = handle; | 80 ipc->return_info.handle = handle; |
| 98 return true; | 81 return true; |
| 99 } | 82 } |
| 100 | 83 |
| 101 } // namespace sandbox | 84 } // namespace sandbox |
| OLD | NEW |