| 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 <stdint.h> | |
| 8 | |
| 9 #include "base/win/scoped_handle.h" | 7 #include "base/win/scoped_handle.h" |
| 10 #include "base/win/windows_version.h" | 8 #include "base/win/windows_version.h" |
| 11 #include "sandbox/win/src/crosscall_client.h" | 9 #include "sandbox/win/src/crosscall_client.h" |
| 12 #include "sandbox/win/src/interception.h" | 10 #include "sandbox/win/src/interception.h" |
| 13 #include "sandbox/win/src/interceptors.h" | 11 #include "sandbox/win/src/interceptors.h" |
| 14 #include "sandbox/win/src/ipc_tags.h" | 12 #include "sandbox/win/src/ipc_tags.h" |
| 13 #include "sandbox/win/src/sandbox_nt_util.h" |
| 15 #include "sandbox/win/src/policy_broker.h" | 14 #include "sandbox/win/src/policy_broker.h" |
| 16 #include "sandbox/win/src/policy_params.h" | 15 #include "sandbox/win/src/policy_params.h" |
| 16 #include "sandbox/win/src/sandbox.h" |
| 17 #include "sandbox/win/src/registry_interception.h" | 17 #include "sandbox/win/src/registry_interception.h" |
| 18 #include "sandbox/win/src/registry_policy.h" | 18 #include "sandbox/win/src/registry_policy.h" |
| 19 #include "sandbox/win/src/sandbox.h" | |
| 20 #include "sandbox/win/src/sandbox_nt_util.h" | |
| 21 | 19 |
| 22 namespace { | 20 namespace { |
| 23 | 21 |
| 24 // Builds a path using the root directory and the name. | 22 // Builds a path using the root directory and the name. |
| 25 bool GetCompletePath(HANDLE root, const base::string16& name, | 23 bool GetCompletePath(HANDLE root, const base::string16& name, |
| 26 base::string16* complete_name) { | 24 base::string16* complete_name) { |
| 27 if (root) { | 25 if (root) { |
| 28 if (!sandbox::GetPathFromHandle(root, complete_name)) | 26 if (!sandbox::GetPathFromHandle(root, complete_name)) |
| 29 return false; | 27 return false; |
| 30 | 28 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 base::win::SUITE_SERVER)) | 72 base::win::SUITE_SERVER)) |
| 75 result &= INTERCEPT_NT(manager, NtOpenKeyEx, OPEN_KEY_EX_ID, 20); | 73 result &= INTERCEPT_NT(manager, NtOpenKeyEx, OPEN_KEY_EX_ID, 20); |
| 76 return result; | 74 return result; |
| 77 } | 75 } |
| 78 | 76 |
| 79 return false; | 77 return false; |
| 80 } | 78 } |
| 81 | 79 |
| 82 bool RegistryDispatcher::NtCreateKey(IPCInfo* ipc, | 80 bool RegistryDispatcher::NtCreateKey(IPCInfo* ipc, |
| 83 base::string16* name, | 81 base::string16* name, |
| 84 uint32_t attributes, | 82 uint32 attributes, |
| 85 HANDLE root, | 83 HANDLE root, |
| 86 uint32_t desired_access, | 84 uint32 desired_access, |
| 87 uint32_t title_index, | 85 uint32 title_index, |
| 88 uint32_t create_options) { | 86 uint32 create_options) { |
| 89 base::win::ScopedHandle root_handle; | 87 base::win::ScopedHandle root_handle; |
| 90 base::string16 real_path = *name; | 88 base::string16 real_path = *name; |
| 91 | 89 |
| 92 // If there is a root directory, we need to duplicate the handle to make | 90 // If there is a root directory, we need to duplicate the handle to make |
| 93 // it valid in this process. | 91 // it valid in this process. |
| 94 if (root) { | 92 if (root) { |
| 95 if (!::DuplicateHandle(ipc->client_info->process, root, | 93 if (!::DuplicateHandle(ipc->client_info->process, root, |
| 96 ::GetCurrentProcess(), &root, 0, FALSE, | 94 ::GetCurrentProcess(), &root, 0, FALSE, |
| 97 DUPLICATE_SAME_ACCESS)) | 95 DUPLICATE_SAME_ACCESS)) |
| 98 return false; | 96 return false; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 124 | 122 |
| 125 // Return operation status on the IPC. | 123 // Return operation status on the IPC. |
| 126 ipc->return_info.extended[0].unsigned_int = disposition; | 124 ipc->return_info.extended[0].unsigned_int = disposition; |
| 127 ipc->return_info.nt_status = nt_status; | 125 ipc->return_info.nt_status = nt_status; |
| 128 ipc->return_info.handle = handle; | 126 ipc->return_info.handle = handle; |
| 129 return true; | 127 return true; |
| 130 } | 128 } |
| 131 | 129 |
| 132 bool RegistryDispatcher::NtOpenKey(IPCInfo* ipc, | 130 bool RegistryDispatcher::NtOpenKey(IPCInfo* ipc, |
| 133 base::string16* name, | 131 base::string16* name, |
| 134 uint32_t attributes, | 132 uint32 attributes, |
| 135 HANDLE root, | 133 HANDLE root, |
| 136 uint32_t desired_access) { | 134 uint32 desired_access) { |
| 137 base::win::ScopedHandle root_handle; | 135 base::win::ScopedHandle root_handle; |
| 138 base::string16 real_path = *name; | 136 base::string16 real_path = *name; |
| 139 | 137 |
| 140 // If there is a root directory, we need to duplicate the handle to make | 138 // If there is a root directory, we need to duplicate the handle to make |
| 141 // it valid in this process. | 139 // it valid in this process. |
| 142 if (root) { | 140 if (root) { |
| 143 if (!::DuplicateHandle(ipc->client_info->process, root, | 141 if (!::DuplicateHandle(ipc->client_info->process, root, |
| 144 ::GetCurrentProcess(), &root, 0, FALSE, | 142 ::GetCurrentProcess(), &root, 0, FALSE, |
| 145 DUPLICATE_SAME_ACCESS)) | 143 DUPLICATE_SAME_ACCESS)) |
| 146 return false; | 144 return false; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 166 return true; | 164 return true; |
| 167 } | 165 } |
| 168 | 166 |
| 169 // Return operation status on the IPC. | 167 // Return operation status on the IPC. |
| 170 ipc->return_info.nt_status = nt_status; | 168 ipc->return_info.nt_status = nt_status; |
| 171 ipc->return_info.handle = handle; | 169 ipc->return_info.handle = handle; |
| 172 return true; | 170 return true; |
| 173 } | 171 } |
| 174 | 172 |
| 175 } // namespace sandbox | 173 } // namespace sandbox |
| OLD | NEW |