SepSetLogonSessionToken

VOID __fastcall SepSetLogonSessionToken(_TOKEN *Token){
  _SEP_LOGON_SESSION_REFERENCES *LogonSession; 
  unsigned int TokenFlags; 
  int v4; 
  struct _DMA_ADAPTER *v5; 
  _OBJECT_ATTRIBUTES ObjectAttributes; 
  PADAPTER_OBJECT DmaAdapter; 
  LogonSession = Token->LogonSession;
  *(&ObjectAttributes.Length + 1) = 0;
  *(&ObjectAttributes.Attributes + 1) = 0;
  if( !LogonSession->Token )
  {
    TokenFlags = Token->TokenFlags;
    if( (TokenFlags & 0x10) == 0 && (TokenFlags & 8) == 0 )
    {
      DmaAdapter = 0i64;
      memset(&ObjectAttributes.RootDirectory, 0, 20);
      ObjectAttributes.Length = 48;
      *(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
      if( (int)SepDuplicateToken(
                  Token,
                  &ObjectAttributes,
                  0,
                  TokenPrimary,
                  SecurityAnonymous,
                  0,
                  0,
                  (_TOKEN **)&DmaAdapter) >= 0 )
      {
        v4 = SepStopReferencingLogonSession((_TOKEN *)DmaAdapter);
        v5 = DmaAdapter;
        if( v4 < 0 )
        {
LABEL_9:
          HalPutDmaAdapter(v5);
          return;
        }
        if( _InterlockedCompareExchange64(
               (volatile signed __int64 *)&Token->LogonSession->Token,
               (signed __int64)DmaAdapter,
               0i64) )
        {
          v5 = DmaAdapter;
          goto LABEL_9;
        }
      }
    }
  }
}

Referenced by:

SepFilterToken