AdjustTokenPrivileges
▶Enables or disables privileges in the specified access token.
BOOL AdjustTokenPrivileges(
HANDLE TokenHandle,
BOOL DisableAllPrivileges,
PTOKEN_PRIVILEGES NewState,
DWORD BufferLength,
PTOKEN_PRIVILEGES PreviousState,
PDWORD ReturnLength
);
| Parameter | Description |
|---|---|
| TokenHandle | Handle to the access token. |
| DisableAllPrivileges | If TRUE, disables all privileges. |
| NewState | Pointer to a TOKEN_PRIVILEGES structure. |
| BufferLength | Size of the buffer pointed to by PreviousState. |
| PreviousState | Receives previous state of privileges. |
| ReturnLength | Receives required size of the buffer. |
OpenProcessToken
▶Opens the access token associated with a process.
BOOL OpenProcessToken(
HANDLE ProcessHandle,
DWORD DesiredAccess,
PHANDLE TokenHandle
);
| Parameter | Description |
|---|---|
| ProcessHandle | Handle to the process. |
| DesiredAccess | Access rights requested for the token. |
| TokenHandle | Receives the token handle. |
Related: GetTokenInformation
LookupPrivilegeValue
▶Retrieves the locally unique identifier (LUID) used on a specified system to locally represent the specified privilege name.
BOOL LookupPrivilegeValue(
LPCWSTR lpSystemName,
LPCWSTR lpName,
PLUID lpLuid
);
| Parameter | Description |
|---|---|
| lpSystemName | Name of the system; NULL for the local system. |
| lpName | Name of the privilege, e.g., "SeShutdownPrivilege". |
| lpLuid | Receives the LUID for the privilege. |
See also: Privilege Constants
SetTokenInformation
▶Sets information in an access token.
BOOL SetTokenInformation(
HANDLE TokenHandle,
TOKEN_INFORMATION_CLASS TokenInformationClass,
LPCVOID TokenInformation,
DWORD TokenInformationLength
);
| Parameter | Description |
|---|---|
| TokenHandle | Handle to the token to modify. |
| TokenInformationClass | Type of information to set. |
| TokenInformation | Pointer to the information buffer. |
| TokenInformationLength | Size of the information buffer in bytes. |
Examples: Setting Privileges Example