NTSTATUS PspAssignPrimaryToken( IN PEPROCESS Process, IN HANDLE Token OPTIONAL, IN PACCESS_TOKEN TokenPointer OPTIONAL ); Routine Description: This function performs the security portions of primary token assignment. It is expected that the proper access to the process and thread objects, as well as necessary privilege, has already been established. A primary token can only be replaced if the process has no threads, or has one thread. This is because the thread objects point to the primary token and must have those pointers updated when the primary token is changed. This is only expected to be necessary at logon time, when the process is in its infancy and either has zero threads or maybe one inactive thread. If the assignment is successful, the old token is dereferenced and the new one is referenced. Arguments: Process - A pointer to the process whose primary token is being replaced. Token - The handle value of the token to be assigned as the primary token. Return Value: STATUS_SUCCESS - Indicates the primary token has been successfully replaced. STATUS_BAD_TOKEN_TYPE - Indicates the token is not of type TokenPrimary. STATUS_TOKEN_IN_USE - Indicates the token is already in use by another process. Other status may be returned when attempting to reference the token object.