Leaked source code of windows server 2003
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.

84 lines
2.7 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // CEnableThreadPrivilege.h
  7. //
  8. // Description:
  9. // Header file for CEnableThreadPrivilege class.
  10. //
  11. // The CEnableThreadPrivilege class enables a certain privilege for the
  12. // current thread in its constructor and automatically restores the
  13. // thread privileges in the destructor.
  14. //
  15. // Maintained By:
  16. // Vij Vasu (Vvasu) 03-MAR-2000
  17. //
  18. //////////////////////////////////////////////////////////////////////////////
  19. // Make sure that this file is included only once per compile path.
  20. #pragma once
  21. //////////////////////////////////////////////////////////////////////////////
  22. // Include Files
  23. //////////////////////////////////////////////////////////////////////////////
  24. // For the TOKEN_PRIVILEGES structure.
  25. #include <ntseapi.h>
  26. //////////////////////////////////////////////////////////////////////////////
  27. //++
  28. //
  29. // class CEnableThreadPrivilege
  30. //
  31. // Description:
  32. // The CEnableThreadPrivilege class enables a certain privilege for the
  33. // current thread in its constructor and automatically restores the
  34. // thread privileges in the destructor.
  35. //
  36. //--
  37. //////////////////////////////////////////////////////////////////////////////
  38. class CEnableThreadPrivilege
  39. {
  40. public:
  41. //////////////////////////////////////////////////////////////////////////
  42. // Constructors and destructors
  43. //////////////////////////////////////////////////////////////////////////
  44. // Construtor. Enables the privilege
  45. CEnableThreadPrivilege( const WCHAR * pcszPrivilegeNameIn );
  46. // Destructor. Restore the original state of the privilege.
  47. ~CEnableThreadPrivilege() throw();
  48. private:
  49. //////////////////////////////////////////////////////////////////////////
  50. // Private member functions
  51. //////////////////////////////////////////////////////////////////////////
  52. // Copy constructor
  53. CEnableThreadPrivilege( const CEnableThreadPrivilege & );
  54. // Assignment operator
  55. const CEnableThreadPrivilege & operator =( const CEnableThreadPrivilege & );
  56. //////////////////////////////////////////////////////////////////////////
  57. // Private data
  58. //////////////////////////////////////////////////////////////////////////
  59. // Previous state of this privilege.
  60. TOKEN_PRIVILEGES m_tpPreviousState;
  61. // Handle to the token for the thread that created this object.
  62. HANDLE m_hThreadToken;
  63. // Indicates if the privilege was successfully enabled or not.
  64. bool m_fPrivilegeEnabled;
  65. }; //*** class CEnableThreadPrivilege