NtQuerySecurityAttributesToken - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
#ifndef _NTSEAPI_H
#if (PHNT_VERSION >= PHNT_WIN7)

// rev
NTSYSCALLAPI
NTSTATUS
NTAPI
NtQuerySecurityAttributesToken(
    _In_ HANDLE TokenHandle,
    _In_reads_opt_(NumberOfAttributes) PUNICODE_STRING Attributes,
    _In_ ULONG NumberOfAttributes,
    _Out_writes_bytes_(Length) PVOID Buffer, // PTOKEN_SECURITY_ATTRIBUTES_INFORMATION
    _In_ ULONG Length,
    _Out_ PULONG ReturnLength
    );

#endif
#endif

View code on GitHub
#ifndef _NTZWAPI_H

NTSYSCALLAPI
NTSTATUS
NTAPI
ZwQuerySecurityAttributesToken(
    _In_ HANDLE TokenHandle,
    _In_reads_opt_(NumberOfAttributes) PUNICODE_STRING Attributes,
    _In_ ULONG NumberOfAttributes,
    _Out_writes_bytes_(Length) PVOID Buffer, // PTOKEN_SECURITY_ATTRIBUTES_INFORMATION
    _In_ ULONG Length,
    _Out_ PULONG ReturnLength
    );

#endif

View code on GitHub

Queries details about one or more token security attributes by name.

Parameters

Pseudo-handles

This function supports the following pseudo-handle values on Windows 8 and above:

Notable return values

Remarks

The names of attributes are case-insensitive.

This function has a bug/inconsistency and might succeed without returning any attributes (i.e., returning an array with zero entries) when the provided token has no associated security attributes. Therefore, it is recommended to check the AttributeCount field in the returned buffer before accessing the rest of the data.

To enumerate all security attributes associated with a token, use NtQueryInformationToken with TokenSecurityAttributes info class.

See also