#ifndef _NTSEAPI_H
/**
* The NtSetInformationToken routine modifies information in a specified token. The calling process must have appropriate access rights to set the information.
*
* @param TokenHandle A handle to an existing access token which information is to be modified.
* @param TokenInformationClass A value from the TOKEN_INFORMATION_CLASS enumerated type identifying the type of information to be modified.
* @param TokenInformation Pointer to a caller-allocated buffer containing the information to be modified in the token.
* @param TokenInformationLength Length, in bytes, of the caller-allocated TokenInformation buffer.
* @return NTSTATUS Successful or errant status.
* @remarks https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/nf-ntifs-ntsetinformationtoken
*/
NTSYSCALLAPI
NTSTATUS
NTAPI
NtSetInformationToken(
_In_ HANDLE TokenHandle,
_In_ TOKEN_INFORMATION_CLASS TokenInformationClass,
_In_reads_bytes_(TokenInformationLength) PVOID TokenInformation,
_In_ ULONG TokenInformationLength
);
View code on GitHub
#ifndef _NTZWAPI_H
NTSYSCALLAPI
NTSTATUS
NTAPI
ZwSetInformationToken(
_In_ HANDLE TokenHandle,
_In_ TOKEN_INFORMATION_CLASS TokenInformationClass,
_In_reads_bytes_(TokenInformationLength) PVOID TokenInformation,
_In_ ULONG TokenInformationLength
);
View code on GitHub
Sets various information about the specified token. This function is partially documented in Windows Driver Kit here and here.
TokenHandle
- a handle to the token. For most information classes, the handle must grant TOKEN_ADJUST_DEFAULT
access.TokenInformationClass
- the type of information to set.TokenInformation
- a pointer to the buffer with the data specific to the request.TokenInformationLength
- the size of the provided buffer in bytes.For the list of supported info classes and required token access, see TOKEN_INFORMATION_CLASS
.
STATUS_TOKEN_ALREADY_IN_USE
indicates that the specified type of information cannot be changed for a token that is currently used as a primary token for a process.Note that as opposed to NtQueryInformationToken
, this function does not support token pseudo-handles.