| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // A library to manage RLZ information for access-points shared | 5 // A library to manage RLZ information for access-points shared |
| 6 // across different client applications. | 6 // across different client applications. |
| 7 | 7 |
| 8 #include "rlz/win/lib/rlz_lib.h" | 8 #include "rlz/lib/rlz_lib.h" |
| 9 | 9 |
| 10 #include <windows.h> | 10 #include <windows.h> |
| 11 #include <aclapi.h> | 11 #include <aclapi.h> |
| 12 #include <winerror.h> | 12 #include <winerror.h> |
| 13 | 13 |
| 14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 15 #include "base/win/registry.h" | 15 #include "base/win/registry.h" |
| 16 #include "base/win/windows_version.h" | |
| 17 #include "rlz/lib/assert.h" | 16 #include "rlz/lib/assert.h" |
| 18 #include "rlz/lib/rlz_value_store.h" | 17 #include "rlz/lib/rlz_value_store.h" |
| 19 #include "rlz/win/lib/machine_deal.h" | 18 #include "rlz/win/lib/machine_deal.h" |
| 20 #include "rlz/win/lib/rlz_value_store_registry.h" | 19 #include "rlz/win/lib/rlz_value_store_registry.h" |
| 21 | 20 |
| 22 namespace { | |
| 23 | |
| 24 // Path to recursively copy into the replacemment hives. These are needed | |
| 25 // to make sure certain win32 APIs continue to run correctly once the real | |
| 26 // hives are replaced. | |
| 27 const wchar_t* kHKLMAccessProviders = | |
| 28 L"System\\CurrentControlSet\\Control\\Lsa\\AccessProviders"; | |
| 29 | |
| 30 // Helper functions | |
| 31 | |
| 32 void CopyRegistryTree(const base::win::RegKey& src, base::win::RegKey* dest) { | |
| 33 // First copy values. | |
| 34 for (base::win::RegistryValueIterator i(src.Handle(), L""); | |
| 35 i.Valid(); ++i) { | |
| 36 dest->WriteValue(i.Name(), reinterpret_cast<const void*>(i.Value()), | |
| 37 i.ValueSize(), i.Type()); | |
| 38 } | |
| 39 | |
| 40 // Next copy subkeys recursively. | |
| 41 for (base::win::RegistryKeyIterator i(src.Handle(), L""); | |
| 42 i.Valid(); ++i) { | |
| 43 base::win::RegKey subkey(dest->Handle(), i.Name(), KEY_ALL_ACCESS); | |
| 44 CopyRegistryTree(base::win::RegKey(src.Handle(), i.Name(), KEY_READ), | |
| 45 &subkey); | |
| 46 } | |
| 47 } | |
| 48 | |
| 49 } // namespace anonymous | |
| 50 | |
| 51 | |
| 52 namespace rlz_lib { | 21 namespace rlz_lib { |
| 53 | 22 |
| 54 // OEM Deal confirmation storage functions. | 23 // OEM Deal confirmation storage functions. |
| 55 | 24 |
| 56 template<class T> | 25 template<class T> |
| 57 class typed_buffer_ptr { | 26 class typed_buffer_ptr { |
| 58 scoped_ptr<char[]> buffer_; | 27 scoped_ptr<char[]> buffer_; |
| 59 | 28 |
| 60 public: | 29 public: |
| 61 typed_buffer_ptr() { | 30 typed_buffer_ptr() { |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 bool GetMachineDealCode(char* dcc, size_t dcc_size) { | 199 bool GetMachineDealCode(char* dcc, size_t dcc_size) { |
| 231 return MachineDealCode::Get(dcc, dcc_size); | 200 return MachineDealCode::Get(dcc, dcc_size); |
| 232 } | 201 } |
| 233 | 202 |
| 234 // Combined functions. | 203 // Combined functions. |
| 235 | 204 |
| 236 bool SetMachineDealCodeFromPingResponse(const char* response) { | 205 bool SetMachineDealCodeFromPingResponse(const char* response) { |
| 237 return MachineDealCode::SetFromPingResponse(response); | 206 return MachineDealCode::SetFromPingResponse(response); |
| 238 } | 207 } |
| 239 | 208 |
| 240 void InitializeTempHivesForTesting(const base::win::RegKey& temp_hklm_key, | |
| 241 const base::win::RegKey& temp_hkcu_key) { | |
| 242 // For the moment, the HKCU hive requires no initialization. | |
| 243 | |
| 244 if (base::win::GetVersion() >= base::win::VERSION_WIN7) { | |
| 245 // Copy the following HKLM subtrees to the temporary location so that the | |
| 246 // win32 APIs used by the tests continue to work: | |
| 247 // | |
| 248 // HKLM\System\CurrentControlSet\Control\Lsa\AccessProviders | |
| 249 // | |
| 250 // This seems to be required since Win7. | |
| 251 base::win::RegKey dest(temp_hklm_key.Handle(), kHKLMAccessProviders, | |
| 252 KEY_ALL_ACCESS); | |
| 253 CopyRegistryTree(base::win::RegKey(HKEY_LOCAL_MACHINE, | |
| 254 kHKLMAccessProviders, | |
| 255 KEY_READ), | |
| 256 &dest); | |
| 257 } | |
| 258 } | |
| 259 | |
| 260 } // namespace rlz_lib | 209 } // namespace rlz_lib |
| OLD | NEW |