SeAppendPrivileges

NTSTATUS __stdcall SeAppendPrivileges(PACCESS_STATE AccessState, PPRIVILEGE_SET Privileges){
  PVOID *v2; 
  unsigned int PrivilegeCount; 
  _PRIVILEGE_SET *v6; 
  int v7; 
  unsigned int v9; 
  int v10; 
  int v11; 
  UINT8 *PoolWithTag; 
  UINT8 *v13; 
  UINT64 v14; 
  v2 = (PVOID *)*((_QWORD *)AccessState + 9);
  PrivilegeCount = Privileges->PrivilegeCount;
  v6 = (_PRIVILEGE_SET *)*v2;
  v7 = *(_DWORD *)*v2;
  if( v7 + Privileges->PrivilegeCount <= 3 )
  {
    SepConcatenatePrivileges(v6, (UINT64)Privileges, Privileges);
    return 0;
  }
  v9 = 8;
  if( PrivilegeCount )
    v10 = 12 * PrivilegeCount + 8;
  else
    v10 = 8;
  if( v6 )
  {
    if( v7 )
      v11 = 12 * v7 + 8;
    else
      v11 = 8;
  }
  else
  {
    v11 = 0;
  }
  PoolWithTag = (UINT8 *)ExAllocatePoolWithTag(PagedPool, (unsigned int)(v11 + v10), 0x72506553ui64);
  if( PoolWithTag )
  {
    v13 = (UINT8 *)*v2;
    if( *v2 )
    {
      if( *(_DWORD *)v13 )
        v9 = 12 * *(_DWORD *)v13 + 8;
    }
    else
    {
      v9 = 0;
    }
    memmove(PoolWithTag, v13, v9);
    SepConcatenatePrivileges((_PRIVILEGE_SET *)PoolWithTag, v14, Privileges);
    if( *((_BYTE *)AccessState + 11) )
      ExFreePoolWithTag(*v2, 0);
    *v2 = PoolWithTag;
    *((_BYTE *)AccessState + 11) = 1;
    return 0;
  }
  return -1073741670;
}

Referenced by:

CMFCheckAccess
CmpCheckKeyBodyAccess
CmpCheckOpenAccessOnKeyBody
IopCheckBackupRestorePrivilege
IopCreateSecurityCheck
IopParseDevice
ObCheckCreateObjectAccess
ObCheckObjectAccess
ObpAdjustCreatorAccessState
ObpCheckTraverseAccess
ObpCreateHandle