SepAssemblePrivileges

VOID __stdcall SepAssemblePrivileges(
        UINT64 PrivilegeCount,
        UINT8 SystemSecurity,
        UINT8 WriteOwner,
        UINT8 Relabel,
        PRIVILEGE_SET **Privileges){
  VOID **PoolWithTag; 
  PRIVILEGE_SET *v9; 
  __int64 v10; 

  if( Privileges )
  {
    if( (_DWORD)PrivilegeCount )
    {
      PoolWithTag = ExAllocatePoolWithTag(1ui64, (unsigned int)(12 * (PrivilegeCount - 1) + 20), 1917871443i64);
      v9 = (PRIVILEGE_SET *)PoolWithTag;
      if( PoolWithTag )
      {
        *(_DWORD *)PoolWithTag = 0;
        *((_DWORD *)PoolWithTag + 1) = 0;
        v10 = 0i64;
        if( SystemSecurity )
        {
          v9->Privilege[0].Luid = SeSecurityPrivilege;
          v9->Privilege[v9->PrivilegeCount++].Attributes = 0x80000000;
          v10 = v9->PrivilegeCount;
        }
        if( WriteOwner )
        {
          v9->Privilege[v10].Luid = (_LUID)SeTakeOwnershipPrivilege;
          v9->Privilege[v9->PrivilegeCount++].Attributes = 0x80000000;
          v10 = v9->PrivilegeCount;
        }
        if( Relabel )
        {
          v9->Privilege[v10].Luid = (_LUID)SeRelabelPrivilege;
          v9->Privilege[v9->PrivilegeCount++].Attributes = 0x80000000;
        }
        *Privileges = v9;
      }
    }
  }
}

Referenced by:

SepAccessCheck
SepAccessCheckEx