Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.9 KiB

  1. // --------------------------------------------------------------------------
  2. // Module Name: TokenUtil.h
  3. //
  4. // Copyright (c) 1999-2000, Microsoft Corporation
  5. //
  6. // Class to handle privilege enabling and restoring across function calls.
  7. //
  8. // History: 1999-08-18 vtan created
  9. // 1999-11-16 vtan separate file
  10. // 2000-02-01 vtan moved from Neptune to Whistler
  11. // 2000-03-31 vtan duplicated from ds to shell
  12. // --------------------------------------------------------------------------
  13. #ifndef _TokenUtil_
  14. #define _TokenUtil_
  15. STDAPI_(BOOL) OpenEffectiveToken (IN DWORD dwDesiredAccess, OUT HANDLE *phToken);
  16. // --------------------------------------------------------------------------
  17. // CPrivilegeEnable
  18. //
  19. // Purpose: This class enables a privilege for the duration of its scope.
  20. // The privilege is restored to its original state on
  21. // destruction.
  22. //
  23. // History: 1999-08-18 vtan created
  24. // 2000-02-01 vtan moved from Neptune to Whistler
  25. // 2000-03-31 vtan duplicated from ds to shell
  26. // --------------------------------------------------------------------------
  27. class CPrivilegeEnable
  28. {
  29. private:
  30. CPrivilegeEnable (void);
  31. CPrivilegeEnable (const CPrivilegeEnable& copyObject);
  32. const CPrivilegeEnable& operator = (const CPrivilegeEnable& assignObject);
  33. public:
  34. CPrivilegeEnable (const TCHAR *pszName);
  35. CPrivilegeEnable (ULONG ulPrivilegeValue);
  36. ~CPrivilegeEnable (void);
  37. private:
  38. bool _fSet;
  39. HANDLE _hToken;
  40. TOKEN_PRIVILEGES _tokenPrivilegePrevious;
  41. };
  42. #endif /* _TokenUtil_ */