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 #include "base/win/registry.h" | 5 #include "base/win/registry.h" |
6 | 6 |
7 #include <shlwapi.h> | 7 #include <shlwapi.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 | 480 |
481 // Try again to delete the key. | 481 // Try again to delete the key. |
482 result = RegDeleteKeyExWrapper(root_key, name.c_str(), access, 0); | 482 result = RegDeleteKeyExWrapper(root_key, name.c_str(), access, 0); |
483 | 483 |
484 return result; | 484 return result; |
485 } | 485 } |
486 | 486 |
487 // RegistryValueIterator ------------------------------------------------------ | 487 // RegistryValueIterator ------------------------------------------------------ |
488 | 488 |
489 RegistryValueIterator::RegistryValueIterator(HKEY root_key, | 489 RegistryValueIterator::RegistryValueIterator(HKEY root_key, |
490 const wchar_t* folder_key) | 490 const wchar_t* folder_key, |
| 491 REGSAM wow64access) |
491 : name_(MAX_PATH, L'\0'), | 492 : name_(MAX_PATH, L'\0'), |
492 value_(MAX_PATH, L'\0') { | 493 value_(MAX_PATH, L'\0') { |
493 LONG result = RegOpenKeyEx(root_key, folder_key, 0, KEY_READ, &key_); | 494 DCHECK(!wow64access || wow64access & kWow64AccessMask); |
| 495 LONG result = |
| 496 RegOpenKeyEx(root_key, folder_key, 0, KEY_READ | wow64access, &key_); |
494 if (result != ERROR_SUCCESS) { | 497 if (result != ERROR_SUCCESS) { |
495 key_ = NULL; | 498 key_ = NULL; |
496 } else { | 499 } else { |
497 DWORD count = 0; | 500 DWORD count = 0; |
498 result = ::RegQueryInfoKey(key_, NULL, 0, NULL, NULL, NULL, NULL, &count, | 501 result = ::RegQueryInfoKey(key_, NULL, 0, NULL, NULL, NULL, NULL, &count, |
499 NULL, NULL, NULL, NULL); | 502 NULL, NULL, NULL, NULL); |
500 | 503 |
501 if (result != ERROR_SUCCESS) { | 504 if (result != ERROR_SUCCESS) { |
502 ::RegCloseKey(key_); | 505 ::RegCloseKey(key_); |
503 key_ = NULL; | 506 key_ = NULL; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 | 572 |
570 name_[0] = L'\0'; | 573 name_[0] = L'\0'; |
571 value_[0] = L'\0'; | 574 value_[0] = L'\0'; |
572 value_size_ = 0; | 575 value_size_ = 0; |
573 return false; | 576 return false; |
574 } | 577 } |
575 | 578 |
576 // RegistryKeyIterator -------------------------------------------------------- | 579 // RegistryKeyIterator -------------------------------------------------------- |
577 | 580 |
578 RegistryKeyIterator::RegistryKeyIterator(HKEY root_key, | 581 RegistryKeyIterator::RegistryKeyIterator(HKEY root_key, |
579 const wchar_t* folder_key) { | 582 const wchar_t* folder_key, |
580 LONG result = RegOpenKeyEx(root_key, folder_key, 0, KEY_READ, &key_); | 583 REGSAM wow64access) { |
| 584 DCHECK(!wow64access || wow64access & kWow64AccessMask); |
| 585 LONG result = |
| 586 RegOpenKeyEx(root_key, folder_key, 0, KEY_READ | wow64access, &key_); |
581 if (result != ERROR_SUCCESS) { | 587 if (result != ERROR_SUCCESS) { |
582 key_ = NULL; | 588 key_ = NULL; |
583 } else { | 589 } else { |
584 DWORD count = 0; | 590 DWORD count = 0; |
585 LONG result = ::RegQueryInfoKey(key_, NULL, 0, NULL, &count, NULL, NULL, | 591 LONG result = ::RegQueryInfoKey(key_, NULL, 0, NULL, &count, NULL, NULL, |
586 NULL, NULL, NULL, NULL, NULL); | 592 NULL, NULL, NULL, NULL, NULL); |
587 | 593 |
588 if (result != ERROR_SUCCESS) { | 594 if (result != ERROR_SUCCESS) { |
589 ::RegCloseKey(key_); | 595 ::RegCloseKey(key_); |
590 key_ = NULL; | 596 key_ = NULL; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 if (ERROR_SUCCESS == r) | 635 if (ERROR_SUCCESS == r) |
630 return true; | 636 return true; |
631 } | 637 } |
632 | 638 |
633 name_[0] = '\0'; | 639 name_[0] = '\0'; |
634 return false; | 640 return false; |
635 } | 641 } |
636 | 642 |
637 } // namespace win | 643 } // namespace win |
638 } // namespace base | 644 } // namespace base |
OLD | NEW |