| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/registry_dispatcher.h" | 5 #include "sandbox/win/src/registry_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/win/scoped_handle.h" | 7 #include "base/win/scoped_handle.h" |
| 8 #include "base/win/windows_version.h" | 8 #include "base/win/windows_version.h" |
| 9 #include "sandbox/win/src/crosscall_client.h" | 9 #include "sandbox/win/src/crosscall_client.h" |
| 10 #include "sandbox/win/src/interception.h" | 10 #include "sandbox/win/src/interception.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 *complete_name = name; | 32 *complete_name = name; |
| 33 } | 33 } |
| 34 | 34 |
| 35 return true; | 35 return true; |
| 36 } | 36 } |
| 37 | 37 |
| 38 } | 38 } |
| 39 | 39 |
| 40 namespace sandbox { | 40 namespace sandbox { |
| 41 | 41 |
| 42 RegistryDispatcher::RegistryDispatcher(PolicyBase* policy_base) | 42 RegistryDispatcher::RegistryDispatcher(TargetPolicy* policy) |
| 43 : policy_base_(policy_base) { | 43 : policy_(policy) { |
| 44 static const IPCCall create_params = { | 44 static const IPCCall create_params = { |
| 45 {IPC_NTCREATEKEY_TAG, | 45 {IPC_NTCREATEKEY_TAG, |
| 46 {WCHAR_TYPE, | 46 {WCHAR_TYPE, |
| 47 UINT32_TYPE, | 47 UINT32_TYPE, |
| 48 VOIDPTR_TYPE, | 48 VOIDPTR_TYPE, |
| 49 UINT32_TYPE, | 49 UINT32_TYPE, |
| 50 UINT32_TYPE, | 50 UINT32_TYPE, |
| 51 UINT32_TYPE}}, | 51 UINT32_TYPE}}, |
| 52 reinterpret_cast<CallbackGeneric>(&RegistryDispatcher::NtCreateKey)}; | 52 reinterpret_cast<CallbackGeneric>(&RegistryDispatcher::NtCreateKey)}; |
| 53 | 53 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 } | 99 } |
| 100 | 100 |
| 101 if (!GetCompletePath(root, *name, &real_path)) | 101 if (!GetCompletePath(root, *name, &real_path)) |
| 102 return false; | 102 return false; |
| 103 | 103 |
| 104 const wchar_t* regname = real_path.c_str(); | 104 const wchar_t* regname = real_path.c_str(); |
| 105 CountedParameterSet<OpenKey> params; | 105 CountedParameterSet<OpenKey> params; |
| 106 params[OpenKey::NAME] = ParamPickerMake(regname); | 106 params[OpenKey::NAME] = ParamPickerMake(regname); |
| 107 params[OpenKey::ACCESS] = ParamPickerMake(desired_access); | 107 params[OpenKey::ACCESS] = ParamPickerMake(desired_access); |
| 108 | 108 |
| 109 EvalResult result = policy_base_->EvalPolicy(IPC_NTCREATEKEY_TAG, | 109 EvalResult result = |
| 110 params.GetBase()); | 110 policy_->EvalPolicy(IPC_NTCREATEKEY_TAG, params.GetBase()); |
| 111 | 111 |
| 112 HANDLE handle; | 112 HANDLE handle; |
| 113 NTSTATUS nt_status; | 113 NTSTATUS nt_status; |
| 114 ULONG disposition = 0; | 114 ULONG disposition = 0; |
| 115 if (!RegistryPolicy::CreateKeyAction(result, *ipc->client_info, *name, | 115 if (!RegistryPolicy::CreateKeyAction(result, *ipc->client_info, *name, |
| 116 attributes, root, desired_access, | 116 attributes, root, desired_access, |
| 117 title_index, create_options, &handle, | 117 title_index, create_options, &handle, |
| 118 &nt_status, &disposition)) { | 118 &nt_status, &disposition)) { |
| 119 ipc->return_info.nt_status = STATUS_ACCESS_DENIED; | 119 ipc->return_info.nt_status = STATUS_ACCESS_DENIED; |
| 120 return true; | 120 return true; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 146 } | 146 } |
| 147 | 147 |
| 148 if (!GetCompletePath(root, *name, &real_path)) | 148 if (!GetCompletePath(root, *name, &real_path)) |
| 149 return false; | 149 return false; |
| 150 | 150 |
| 151 const wchar_t* regname = real_path.c_str(); | 151 const wchar_t* regname = real_path.c_str(); |
| 152 CountedParameterSet<OpenKey> params; | 152 CountedParameterSet<OpenKey> params; |
| 153 params[OpenKey::NAME] = ParamPickerMake(regname); | 153 params[OpenKey::NAME] = ParamPickerMake(regname); |
| 154 params[OpenKey::ACCESS] = ParamPickerMake(desired_access); | 154 params[OpenKey::ACCESS] = ParamPickerMake(desired_access); |
| 155 | 155 |
| 156 EvalResult result = policy_base_->EvalPolicy(IPC_NTOPENKEY_TAG, | 156 EvalResult result = policy_->EvalPolicy(IPC_NTOPENKEY_TAG, params.GetBase()); |
| 157 params.GetBase()); | |
| 158 HANDLE handle; | 157 HANDLE handle; |
| 159 NTSTATUS nt_status; | 158 NTSTATUS nt_status; |
| 160 if (!RegistryPolicy::OpenKeyAction(result, *ipc->client_info, *name, | 159 if (!RegistryPolicy::OpenKeyAction(result, *ipc->client_info, *name, |
| 161 attributes, root, desired_access, &handle, | 160 attributes, root, desired_access, &handle, |
| 162 &nt_status)) { | 161 &nt_status)) { |
| 163 ipc->return_info.nt_status = STATUS_ACCESS_DENIED; | 162 ipc->return_info.nt_status = STATUS_ACCESS_DENIED; |
| 164 return true; | 163 return true; |
| 165 } | 164 } |
| 166 | 165 |
| 167 // Return operation status on the IPC. | 166 // Return operation status on the IPC. |
| 168 ipc->return_info.nt_status = nt_status; | 167 ipc->return_info.nt_status = nt_status; |
| 169 ipc->return_info.handle = handle; | 168 ipc->return_info.handle = handle; |
| 170 return true; | 169 return true; |
| 171 } | 170 } |
| 172 | 171 |
| 173 } // namespace sandbox | 172 } // namespace sandbox |
| OLD | NEW |