NTSTATUS SepAdjustPrivileges( IN PTOKEN Token, IN BOOLEAN MakeChanges, IN BOOLEAN DisableAllPrivileges, IN ULONG PrivilegeCount OPTIONAL, IN PLUID_AND_ATTRIBUTES NewState OPTIONAL, OUT PTOKEN_PRIVILEGES PreviousState OPTIONAL, OUT PULONG ReturnLength, OUT PULONG ChangeCount, OUT PBOOLEAN ChangesMade ); Routine Description: This routine is used to walk the privileges array in a token as a result of a request to adjust privileges. If the MakeChanges parameter is FALSE, this routine simply determines what changes are needed and how much space is necessary to save the current state of changed privileges. If the MakeChanges parameter is TRUE, this routine will not only calculate the space necessary to save the current state, but will actually make the changes. This routine makes the following assumptions: 1) The token is locked for exclusive access. 2) The PrivilegeCount and NewState parameters (if passed) are captured and accesses to them will not result in access violations. 4) Any access violations encountered may leave the request partially completed. It is the calling routine's responsibility to catch exceptions. 5) The calling routine is responsible for inrementing the token's ModifiedId field. Arguments: Token - Pointer to the token to act upon. MakeChanges - A boolean value indicating whether the changes should actually be made, or just evaluated. A value of TRUE indicates the changes should be made. DisableAllPrivilegs - A boolean value indicating whether all privileges are to be disabled, or only select, specified privileges. A value of TRUE indicates all privileges are to be disabled. PrivilegeCount - This parameter is required only if the NewState parameter is used. In that case, this parameter indicates how many entries are in the NewState parameter. NewState - This parameter is ignored if the DisableAllPrivileges argument is TRUE. If the DisableAllPrivileges argument is FALSE, then this parameter must be provided and specifies the new state to set privileges to (enabled or disabled). PreviousState - This (optional) parameter points to a buffer to receive the state of any privileges actually changed by this request. This information is formated as a TOKEN_PRIVILEGES data structure which may be passed as the NewState parameter in a subsequent call to NtAdjustPrivileges to restore the original state of those privileges. It is the caller's responsibility to make sure this buffer is large enough to receive all the state information. ReturnLength - Points to a buffer to receive the number of bytes needed to retrieve the previous state information of changed privileges. This parameter is ignored if the PreviousState argument is not passed. ChangeCount - Points to a ULONG to receive the number of privileges which were adjusted (or would be adjusted, if changes are made). ChangesMade - Points to a boolean flag which is to receive an indication as to whether any changes were made as a result of this call. This is expected to be used to decide whether or not to increment the token's ModifiedId field. Return Value: STATUS_SUCCESS - Call completed successfully. STATUS_NOT_ALL_ASSIGNED - Indicates not all the specified adjustments have been made (or could be made, if update wasn't requested).