TOKEN_PRIVILEGES (Structures)
Last changed: -142.126.162.230

.
Summary
Contains information about a set of privileges for an access token.

C# Definitions:

public const UInt32 SE_PRIVILEGE_ENABLED_BY_DEFAULT    = 0x00000001;
public const UInt32 SE_PRIVILEGE_ENABLED        = 0x00000002;
public const UInt32 SE_PRIVILEGE_REMOVED        = 0x00000004;
public const UInt32 SE_PRIVILEGE_USED_FOR_ACCESS    = 0x80000000;

public struct TOKEN_PRIVILEGES {
    public UInt32 PrivilegeCount;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst=ANYSIZE_ARRAY)]
    public LUID_AND_ATTRIBUTES [] Privileges;
}

Alternate simple structure for single privilege setting:

[StructLayout(LayoutKind.Sequential)]
public struct TOKEN_PRIVILEGES
{
    public UInt32 PrivilegeCount;
    public LUID Luid;
    public UInt32 Attributes;
}

VB Definition:

Structure TOKEN_PRIVILEGES
   Public PrivilegeCount As Integer
   Public TheLuid As LUID
   Public Attributes As Integer
End Structure

User-Defined Field Types:

LUID

LUID_AND_ATTRIBUTES

WINNT (for ANYSIZE_ARRAY)

Notes:

Do NOT define LUID as Uint64! Use the structure LUID consisted of two UInt32 because of memory alignment.

VB.Net Sample Code:

   ' Token Privilege
   Dim tp As New TOKEN_PRIVILEGES

   tp.PrivilegeCount = 1
   tp.TheLuid = luid_Restore
   tp.Attributes = SE_PRIVILEGE_ENABLED

Alternative Managed API:

Documentation