SeGetLinkedToken

NTSTATUS __stdcall SeGetLinkedToken(_TOKEN_ELEVATION_TYPE Type, VOID *Token, VOID **NewToken){
  _SEP_LOGON_SESSION_REFERENCES *v3; 
  _TOKEN *v5; 
  NTSTATUS v8; 
  _SEP_LOGON_SESSION_REFERENCES *LogonSession; 
  unsigned int Flags; 
  NTSTATUS v11; 
  _OBJECT_ATTRIBUTES ObjectAttributes; 
  _SEP_LOGON_SESSION_REFERENCES *ReturnSession; 

  v3 = 0i64;
  *NewToken = 0i64;
  ReturnSession = 0i64;
  v5 = (_TOKEN *)Token;
  memset(&ObjectAttributes, 0, sizeof(ObjectAttributes));
  if( (unsigned int)(Type - 2) > 1 )
    return -1073741811;
  if( (*(_DWORD *)(*((_QWORD *)Token + 27) + 32i64) & 4) == 0
    || Type != TokenElevationTypeFull
    || !SeIsSModeAdminlessEnabled() )
  {
    LogonSession = v5->LogonSession;
    Flags = LogonSession->Flags;
    if( (Flags & 4) != 0 && Type == TokenElevationTypeFull || (Flags & 2) != 0 && Type == TokenElevationTypeLimited )
    {
      v11 = SepReferenceLogonSessionSilo(&LogonSession->BuddyLogonId, LogonSession->ServerSilo, &ReturnSession);
      v3 = ReturnSession;
      v8 = v11;
      if( v11 < 0 )
        goto LABEL_14;
      v5 = (_TOKEN *)ReturnSession->Token;
    }
    memset(&ObjectAttributes.RootDirectory, 0, 20);
    ObjectAttributes.Length = 48;
    *(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
    v8 = SepDuplicateToken(v5, &ObjectAttributes, 0, TokenPrimary, SecurityAnonymous, 0, 0, (_TOKEN **)NewToken);
LABEL_14:
    if( v3 )
      SepDeReferenceLogonSessionDirect(v3);
    return v8;
  }
  return -1073741729;
}

Referenced by:

No references.