Функция _Security__AdjustTokenPrivileges

 ↑  ←  Описание функции


_Security__AdjustTokenPrivileges

Enables or disables privileges in the specified access token

#include <Security.au3>
_Security__AdjustTokenPrivileges($hToken, $fDisableAll, $pNewState, $iBufferLen [, $pPrevState = 0 [, $pRequired = 0]])

Параметры

$hToken Handle to the access token that contains privileges to be modified
$fDisableAll If True, the function disables all privileges and ignores the NewState parameter. If False, the
    function modifies privileges based on the information pointed to by the $pNewState parameter.
$pNewState Pointer to a $tagTOKEN_PRIVILEGES structure that contains the privilege and it's attributes
$iBufferLen Size, in bytes, of the buffer pointed to by $pNewState
$pPrevState [необязательный] Pointer to a $tagTOKEN_PRIVILEGES structure that specifies the previous state of the privilege
    that the function modified. This can be 0
$pRequired [необязательный] Pointer to a variable that receives the required size, in bytes, of the buffer pointed to by
    $pPrevState. This parameter can be 0 if $pPrevState is 0.

Возвращаемое значение

Успех:Возвращает True
Ошибка:Возвращает False

Примечания

This function cannot add new privileges to an access token. It can only enable or disable the token's existing
privileges.

См. также

$tagTOKEN_PRIVILEGES

См. также

Искать AdjustTokenPrivileges в библиотеке MSDN

Пример

#RequireAdmin ; for this example to have sense

#include <SecurityConstants.au3>
#include <Security.au3>
#include <WinAPI.au3>

Local $hToken = _Security__OpenProcessToken(_WinAPI_GetCurrentProcess(), $TOKEN_ALL_ACCESS)
If $hToken Then
    ; $hToken is this process' token with $TOKEN_ALL_ACCESS access

    ; Disable all privileges for this token
    If _Security__AdjustTokenPrivileges($hToken, True, 0, 0) Then
        ;... Do whatever with this token now and here...
        MsgBox(262144, "TokenPrivileges", "All TokenPrivileges disabled!")
    EndIf

    ; Close handle when done
    _WinAPI_CloseHandle($hToken)
EndIf