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