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 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 } | 472 } |
473 | 473 |
474 // Adjust the token's privileges to enable |privilege_name|. If this privilege | 474 // Adjust the token's privileges to enable |privilege_name|. If this privilege |
475 // was already enabled, |previous_privileges_|.PrivilegeCount will be set to 0 | 475 // was already enabled, |previous_privileges_|.PrivilegeCount will be set to 0 |
476 // and we then know not to disable this privilege upon destruction. | 476 // and we then know not to disable this privilege upon destruction. |
477 TOKEN_PRIVILEGES tp; | 477 TOKEN_PRIVILEGES tp; |
478 tp.PrivilegeCount = 1; | 478 tp.PrivilegeCount = 1; |
479 tp.Privileges[0].Luid = privilege_luid; | 479 tp.Privileges[0].Luid = privilege_luid; |
480 tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; | 480 tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; |
481 DWORD return_length; | 481 DWORD return_length; |
482 if (!::AdjustTokenPrivileges(token_, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), | 482 if (!::AdjustTokenPrivileges(token_.Get(), FALSE, &tp, |
| 483 sizeof(TOKEN_PRIVILEGES), |
483 &previous_privileges_, &return_length)) { | 484 &previous_privileges_, &return_length)) { |
484 token_.Close(); | 485 token_.Close(); |
485 return; | 486 return; |
486 } | 487 } |
487 | 488 |
488 is_enabled_ = true; | 489 is_enabled_ = true; |
489 } | 490 } |
490 | 491 |
491 ScopedTokenPrivilege::~ScopedTokenPrivilege() { | 492 ScopedTokenPrivilege::~ScopedTokenPrivilege() { |
492 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) { | 493 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) { |
493 ::AdjustTokenPrivileges(token_, FALSE, &previous_privileges_, | 494 ::AdjustTokenPrivileges(token_.Get(), FALSE, &previous_privileges_, |
494 sizeof(TOKEN_PRIVILEGES), NULL, NULL); | 495 sizeof(TOKEN_PRIVILEGES), NULL, NULL); |
495 } | 496 } |
496 } | 497 } |
497 | 498 |
498 } // namespace installer | 499 } // namespace installer |
OLD | NEW |