| 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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 // The following status values represent failed uninstalls: | 445 // The following status values represent failed uninstalls: |
| 446 // 15: CHROME_NOT_INSTALLED | 446 // 15: CHROME_NOT_INSTALLED |
| 447 // 20: UNINSTALL_FAILED | 447 // 20: UNINSTALL_FAILED |
| 448 // 21: UNINSTALL_CANCELLED | 448 // 21: UNINSTALL_CANCELLED |
| 449 return (install_status == UNINSTALL_SUCCESSFUL || | 449 return (install_status == UNINSTALL_SUCCESSFUL || |
| 450 install_status == UNINSTALL_REQUIRES_REBOOT); | 450 install_status == UNINSTALL_REQUIRES_REBOOT); |
| 451 } | 451 } |
| 452 | 452 |
| 453 ScopedTokenPrivilege::ScopedTokenPrivilege(const wchar_t* privilege_name) | 453 ScopedTokenPrivilege::ScopedTokenPrivilege(const wchar_t* privilege_name) |
| 454 : is_enabled_(false) { | 454 : is_enabled_(false) { |
| 455 HANDLE temp_handle; | |
| 456 if (!::OpenProcessToken(::GetCurrentProcess(), | 455 if (!::OpenProcessToken(::GetCurrentProcess(), |
| 457 TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, | 456 TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, |
| 458 &temp_handle)) { | 457 token_.Receive())) { |
| 459 return; | 458 return; |
| 460 } | 459 } |
| 461 token_.Set(temp_handle); | |
| 462 | 460 |
| 463 LUID privilege_luid; | 461 LUID privilege_luid; |
| 464 if (!::LookupPrivilegeValue(NULL, privilege_name, &privilege_luid)) { | 462 if (!::LookupPrivilegeValue(NULL, privilege_name, &privilege_luid)) { |
| 465 token_.Close(); | 463 token_.Close(); |
| 466 return; | 464 return; |
| 467 } | 465 } |
| 468 | 466 |
| 469 // Adjust the token's privileges to enable |privilege_name|. If this privilege | 467 // Adjust the token's privileges to enable |privilege_name|. If this privilege |
| 470 // was already enabled, |previous_privileges_|.PrivilegeCount will be set to 0 | 468 // was already enabled, |previous_privileges_|.PrivilegeCount will be set to 0 |
| 471 // and we then know not to disable this privilege upon destruction. | 469 // and we then know not to disable this privilege upon destruction. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 484 } | 482 } |
| 485 | 483 |
| 486 ScopedTokenPrivilege::~ScopedTokenPrivilege() { | 484 ScopedTokenPrivilege::~ScopedTokenPrivilege() { |
| 487 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) { | 485 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) { |
| 488 ::AdjustTokenPrivileges(token_, FALSE, &previous_privileges_, | 486 ::AdjustTokenPrivileges(token_, FALSE, &previous_privileges_, |
| 489 sizeof(TOKEN_PRIVILEGES), NULL, NULL); | 487 sizeof(TOKEN_PRIVILEGES), NULL, NULL); |
| 490 } | 488 } |
| 491 } | 489 } |
| 492 | 490 |
| 493 } // namespace installer | 491 } // namespace installer |
| OLD | NEW |