OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2003 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2003 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 // Registry configuration wrapers class implementation | 11 // Registry configuration wrapers class implementation |
12 // | 12 // |
13 // Change made by S. Ganesh - ganesh@google.com: | 13 // Change made by S. Ganesh - ganesh@google.com: |
14 // Use SHQueryValueEx instead of RegQueryValueEx throughout. | 14 // Use SHQueryValueEx instead of RegQueryValueEx throughout. |
15 // A call to the SHLWAPI function is essentially a call to the standard | 15 // A call to the SHLWAPI function is essentially a call to the standard |
16 // function but with post-processing: | 16 // function but with post-processing: |
17 // * to fix REG_SZ or REG_EXPAND_SZ data that is not properly null-terminated; | 17 // * to fix REG_SZ or REG_EXPAND_SZ data that is not properly null-terminated; |
18 // * to expand REG_EXPAND_SZ data. | 18 // * to expand REG_EXPAND_SZ data. |
19 | 19 |
20 #include "webrtc/base/win32regkey.h" | 20 #include "webrtc/base/win32regkey.h" |
21 | 21 |
22 #include <shlwapi.h> | 22 #include <shlwapi.h> |
23 | 23 |
| 24 #include <memory> |
| 25 |
24 #include "webrtc/base/common.h" | 26 #include "webrtc/base/common.h" |
25 #include "webrtc/base/logging.h" | 27 #include "webrtc/base/logging.h" |
26 #include "webrtc/base/scoped_ptr.h" | |
27 | 28 |
28 namespace rtc { | 29 namespace rtc { |
29 | 30 |
30 RegKey::RegKey() { | 31 RegKey::RegKey() { |
31 h_key_ = NULL; | 32 h_key_ = NULL; |
32 } | 33 } |
33 | 34 |
34 RegKey::~RegKey() { | 35 RegKey::~RegKey() { |
35 Close(); | 36 Close(); |
36 } | 37 } |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 HRESULT RegKey::GetValue(const wchar_t* full_key_name, | 140 HRESULT RegKey::GetValue(const wchar_t* full_key_name, |
140 const wchar_t* value_name, | 141 const wchar_t* value_name, |
141 float* value) { | 142 float* value) { |
142 ASSERT(value != NULL); | 143 ASSERT(value != NULL); |
143 ASSERT(full_key_name != NULL); | 144 ASSERT(full_key_name != NULL); |
144 | 145 |
145 DWORD byte_count = 0; | 146 DWORD byte_count = 0; |
146 byte* buffer_raw = nullptr; | 147 byte* buffer_raw = nullptr; |
147 HRESULT hr = GetValueStaticHelper(full_key_name, value_name, | 148 HRESULT hr = GetValueStaticHelper(full_key_name, value_name, |
148 REG_BINARY, &buffer_raw, &byte_count); | 149 REG_BINARY, &buffer_raw, &byte_count); |
149 scoped_ptr<byte[]> buffer(buffer_raw); | 150 std::unique_ptr<byte[]> buffer(buffer_raw); |
150 if (SUCCEEDED(hr)) { | 151 if (SUCCEEDED(hr)) { |
151 ASSERT(byte_count == sizeof(*value)); | 152 ASSERT(byte_count == sizeof(*value)); |
152 if (byte_count == sizeof(*value)) { | 153 if (byte_count == sizeof(*value)) { |
153 *value = *reinterpret_cast<float*>(buffer.get()); | 154 *value = *reinterpret_cast<float*>(buffer.get()); |
154 } | 155 } |
155 } | 156 } |
156 return hr; | 157 return hr; |
157 } | 158 } |
158 | 159 |
159 HRESULT RegKey::GetValue(const wchar_t* full_key_name, | 160 HRESULT RegKey::GetValue(const wchar_t* full_key_name, |
160 const wchar_t* value_name, | 161 const wchar_t* value_name, |
161 double* value) { | 162 double* value) { |
162 ASSERT(value != NULL); | 163 ASSERT(value != NULL); |
163 ASSERT(full_key_name != NULL); | 164 ASSERT(full_key_name != NULL); |
164 | 165 |
165 DWORD byte_count = 0; | 166 DWORD byte_count = 0; |
166 byte* buffer_raw = nullptr; | 167 byte* buffer_raw = nullptr; |
167 HRESULT hr = GetValueStaticHelper(full_key_name, value_name, | 168 HRESULT hr = GetValueStaticHelper(full_key_name, value_name, |
168 REG_BINARY, &buffer_raw, &byte_count); | 169 REG_BINARY, &buffer_raw, &byte_count); |
169 scoped_ptr<byte[]> buffer(buffer_raw); | 170 std::unique_ptr<byte[]> buffer(buffer_raw); |
170 if (SUCCEEDED(hr)) { | 171 if (SUCCEEDED(hr)) { |
171 ASSERT(byte_count == sizeof(*value)); | 172 ASSERT(byte_count == sizeof(*value)); |
172 if (byte_count == sizeof(*value)) { | 173 if (byte_count == sizeof(*value)) { |
173 *value = *reinterpret_cast<double*>(buffer.get()); | 174 *value = *reinterpret_cast<double*>(buffer.get()); |
174 } | 175 } |
175 } | 176 } |
176 return hr; | 177 return hr; |
177 } | 178 } |
178 | 179 |
179 HRESULT RegKey::GetValue(const wchar_t* full_key_name, | 180 HRESULT RegKey::GetValue(const wchar_t* full_key_name, |
180 const wchar_t* value_name, | 181 const wchar_t* value_name, |
181 wchar_t** value) { | 182 wchar_t** value) { |
182 ASSERT(full_key_name != NULL); | 183 ASSERT(full_key_name != NULL); |
183 ASSERT(value != NULL); | 184 ASSERT(value != NULL); |
184 | 185 |
185 return GetValueStaticHelper(full_key_name, value_name, REG_SZ, value); | 186 return GetValueStaticHelper(full_key_name, value_name, REG_SZ, value); |
186 } | 187 } |
187 | 188 |
188 HRESULT RegKey::GetValue(const wchar_t* full_key_name, | 189 HRESULT RegKey::GetValue(const wchar_t* full_key_name, |
189 const wchar_t* value_name, | 190 const wchar_t* value_name, |
190 std::wstring* value) { | 191 std::wstring* value) { |
191 ASSERT(full_key_name != NULL); | 192 ASSERT(full_key_name != NULL); |
192 ASSERT(value != NULL); | 193 ASSERT(value != NULL); |
193 | 194 |
194 wchar_t* buffer_raw = nullptr; | 195 wchar_t* buffer_raw = nullptr; |
195 HRESULT hr = RegKey::GetValue(full_key_name, value_name, &buffer_raw); | 196 HRESULT hr = RegKey::GetValue(full_key_name, value_name, &buffer_raw); |
196 scoped_ptr<wchar_t[]> buffer(buffer_raw); | 197 std::unique_ptr<wchar_t[]> buffer(buffer_raw); |
197 if (SUCCEEDED(hr)) { | 198 if (SUCCEEDED(hr)) { |
198 value->assign(buffer.get()); | 199 value->assign(buffer.get()); |
199 } | 200 } |
200 return hr; | 201 return hr; |
201 } | 202 } |
202 | 203 |
203 HRESULT RegKey::GetValue(const wchar_t* full_key_name, | 204 HRESULT RegKey::GetValue(const wchar_t* full_key_name, |
204 const wchar_t* value_name, | 205 const wchar_t* value_name, |
205 std::vector<std::wstring>* value) { | 206 std::vector<std::wstring>* value) { |
206 ASSERT(full_key_name != NULL); | 207 ASSERT(full_key_name != NULL); |
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1096 } | 1097 } |
1097 CloseHandle(token); | 1098 CloseHandle(token); |
1098 } else { | 1099 } else { |
1099 LOG_GLE(LS_ERROR) << "OpenProcessToken(GetCurrentProcess) failed"; | 1100 LOG_GLE(LS_ERROR) << "OpenProcessToken(GetCurrentProcess) failed"; |
1100 } | 1101 } |
1101 | 1102 |
1102 return ret; | 1103 return ret; |
1103 } | 1104 } |
1104 | 1105 |
1105 } // namespace rtc | 1106 } // namespace rtc |
OLD | NEW |