|
ProcessHelperAdjustTokenPrivileges(IntPtr, Boolean, TokenPrivileges, Int32, IntPtr, IntPtr) Method |
The AdjustTokenPrivileges function enables or disables privileges in the specified access
token. Enabling or disabling privileges in an access token requires
access.
AdjustTokenPrivileges function Namespace: Xcalibur.NativeMethods.V2.ProcessesAssembly: Xcalibur.NativeMethods.V2 (in Xcalibur.NativeMethods.V2.dll) Version: 1.0.1.0
Syntax [DllImportAttribute("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static bool AdjustTokenPrivileges(
IntPtr tokenHandle,
bool disableAllPrivileges,
TokenPrivileges newState,
int bufferLength,
IntPtr previousState,
IntPtr returnLength
)
<DllImportAttribute("advapi32.dll", CharSet := CharSet.Auto, SetLastError := true>]
Public Shared Function AdjustTokenPrivileges (
tokenHandle As IntPtr,
disableAllPrivileges As Boolean,
newState As TokenPrivileges,
bufferLength As Integer,
previousState As IntPtr,
returnLength As IntPtr
) As Boolean
public:
[DllImportAttribute(L"advapi32.dll", CharSet = CharSet::Auto, SetLastError = true)]
static bool AdjustTokenPrivileges(
IntPtr tokenHandle,
bool disableAllPrivileges,
TokenPrivileges newState,
int bufferLength,
IntPtr previousState,
IntPtr returnLength
)
[<DllImportAttribute("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)>]
static member AdjustTokenPrivileges :
tokenHandle : IntPtr *
disableAllPrivileges : bool *
newState : TokenPrivileges *
bufferLength : int *
previousState : IntPtr *
returnLength : IntPtr -> bool
Parameters
- tokenHandle IntPtr
- A handle to the access token that contains the privileges to be
modified. The handle must have access
to the token. If the PreviousState parameter is not NULL, the handle must also have
access.
- disableAllPrivileges Boolean
- Specifies whether the function disables all of the
token's privileges. If this value is TRUE, the function disables all privileges and ignores
the newState parameter. If it is FALSE, the function modifies privileges based on the
information pointed to by the newState parameter.
- newState TokenPrivileges
- A pointer to a
structure that specifies an array of privileges and their attributes. If the
disableAllPrivileges parameter is FALSE, the AdjustTokenPrivileges function enables,
disables, or removes these privileges for the token. The following table describes the
action taken by the AdjustTokenPrivileges function, based on the privilege attribute.
- bufferLength Int32
- Specifies the size, in bytes, of the buffer pointed to by the
previousState parameter. This parameter can be zero if the previousState parameter is NULL.
- previousState IntPtr
- A pointer to a buffer that the function fills with a
structure that contains the previous
state of any privileges that the function modifies. That is, if a privilege has been
modified by this function, the privilege and its previous state are contained in the
structure referenced by previousState.
If the PrivilegeCount member of is
zero, then no privileges have been changed by this function. This parameter can be NULL.
- returnLength IntPtr
- A pointer to a variable that receives the required size, in
bytes, of the buffer pointed to by the previousState parameter. This parameter can be NULL
if previousState is NULL.
Return Value
BooleanIf the function succeeds, the return value is nonzero. To determine whether the
function adjusted all of the specified privileges, call
.
See Also