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