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 // This file declares util functions for setup project. | 5 // This file declares util functions for setup project. |
6 | 6 |
7 #include "chrome/installer/setup/setup_util.h" | 7 #include "chrome/installer/setup/setup_util.h" |
8 | 8 |
9 #include <windows.h> | 9 #include <windows.h> |
10 | 10 |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 LOG(ERROR) << "Failed to delete value " << name << " in key " << path; | 622 LOG(ERROR) << "Failed to delete value " << name << " in key " << path; |
623 // Skip over this value on subsequent iterations. | 623 // Skip over this value on subsequent iterations. |
624 to_skip.insert(name); | 624 to_skip.insert(name); |
625 ++index; | 625 ++index; |
626 continue; | 626 continue; |
627 } | 627 } |
628 did_delete = true; | 628 did_delete = true; |
629 } | 629 } |
630 } | 630 } |
631 | 631 |
| 632 base::string16 GuidToSquid(const base::string16& guid) { |
| 633 base::string16 squid; |
| 634 squid.reserve(32); |
| 635 auto input = guid.begin(); |
| 636 auto output = std::back_inserter(squid); |
| 637 |
| 638 // Reverse-copy relevant characters, skipping separators. |
| 639 std::reverse_copy(input + 0, input + 8, output); |
| 640 std::reverse_copy(input + 9, input + 13, output); |
| 641 std::reverse_copy(input + 14, input + 18, output); |
| 642 std::reverse_copy(input + 19, input + 21, output); |
| 643 std::reverse_copy(input + 21, input + 23, output); |
| 644 std::reverse_copy(input + 24, input + 26, output); |
| 645 std::reverse_copy(input + 26, input + 28, output); |
| 646 std::reverse_copy(input + 28, input + 30, output); |
| 647 std::reverse_copy(input + 30, input + 32, output); |
| 648 std::reverse_copy(input + 32, input + 34, output); |
| 649 std::reverse_copy(input + 34, input + 36, output); |
| 650 return squid; |
| 651 } |
| 652 |
632 ScopedTokenPrivilege::ScopedTokenPrivilege(const wchar_t* privilege_name) | 653 ScopedTokenPrivilege::ScopedTokenPrivilege(const wchar_t* privilege_name) |
633 : is_enabled_(false) { | 654 : is_enabled_(false) { |
634 HANDLE temp_handle; | 655 HANDLE temp_handle; |
635 if (!::OpenProcessToken(::GetCurrentProcess(), | 656 if (!::OpenProcessToken(::GetCurrentProcess(), |
636 TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, | 657 TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, |
637 &temp_handle)) { | 658 &temp_handle)) { |
638 return; | 659 return; |
639 } | 660 } |
640 token_.Set(temp_handle); | 661 token_.Set(temp_handle); |
641 | 662 |
(...skipping 22 matching lines...) Expand all Loading... |
664 } | 685 } |
665 | 686 |
666 ScopedTokenPrivilege::~ScopedTokenPrivilege() { | 687 ScopedTokenPrivilege::~ScopedTokenPrivilege() { |
667 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) { | 688 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) { |
668 ::AdjustTokenPrivileges(token_.Get(), FALSE, &previous_privileges_, | 689 ::AdjustTokenPrivileges(token_.Get(), FALSE, &previous_privileges_, |
669 sizeof(TOKEN_PRIVILEGES), NULL, NULL); | 690 sizeof(TOKEN_PRIVILEGES), NULL, NULL); |
670 } | 691 } |
671 } | 692 } |
672 | 693 |
673 } // namespace installer | 694 } // namespace installer |
OLD | NEW |