SepPrivilegeCheck

UINT8 __stdcall SepPrivilegeCheck(
        _TOKEN *Token,
        _LUID_AND_ATTRIBUTES *RequiredPrivileges,
        UINT64 RequiredPrivilegeCount,
        UINT64 PrivilegeSetControl,
        INT8 PreviousMode){
  int v5; 
  char v6; 
  __int64 v7; 
  unsigned int *p_Attributes; 
  __int64 v9; 
  int v10; 
  unsigned __int8 v11; 
  __int64 v13; 
  __int64 v14; 

  v5 = 0;
  v6 = PrivilegeSetControl;
  v14 = 0i64;
  v13 = 0i64;
  if( PreviousMode )
  {
    _InterlockedExchange64(&v14, Token->Privileges.Enabled);
    _InterlockedExchange64(&v13, Token->Privileges.Present);
    v7 = v14 & v13;
    _InterlockedOr((volatile signed __int32 *)&v13, 0);
    if( (_DWORD)RequiredPrivilegeCount )
    {
      p_Attributes = &RequiredPrivileges->Attributes;
      v9 = (unsigned int)RequiredPrivilegeCount;
      do
      {
        v10 = *p_Attributes & 0x7FFFFFFF;
        v11 = _bittest64(&v7, *(p_Attributes - 2));
        *p_Attributes = v10;
        if( v11 )
        {
          *p_Attributes = v10 | 0x80000000;
          ++v5;
        }
        p_Attributes += 3;
        --v9;
      }
      while( v9 );
    }
    if( (v6 & 1) != 0 )
    {
      if( v5 != (_DWORD)RequiredPrivilegeCount )
        return 0;
    }
    else if( !v5 )
    {
      return 0;
    }
  }
  return 1;
}

Referenced by:

IopCheckBackupRestorePrivilege
NtPrivilegeCheck
PfQuerySuperfetchInformation
SeCheckAuditPrivilege
SePrivilegeCheck
SePrivilegePolicyCheck
SepAccessCheck
SepAccessCheckEx