SepDuplicateClaimAttributes

NTSTATUS __stdcall SepDuplicateClaimAttributes(
        _AUTHZBASEP_CLAIM_ATTRIBUTES_COLLECTION *ExistingClaimAttributes,
        _AUTHZBASEP_CLAIM_ATTRIBUTES_COLLECTION **NewClaimAttributes){
  NTSTATUS result; 
  int v5; 
  _AUTHZBASEP_SECURITY_ATTRIBUTES_INFORMATION *v6; 
  _AUTHZBASEP_SECURITY_ATTRIBUTES_INFORMATION *v7; 
  char v8; 
  _SID_AND_ATTRIBUTES *v9; 
  _AUTHZBASEP_CLAIM_ATTRIBUTES_COLLECTION *ClaimCollectionNoLists; 
  _AUTHZBASEP_SECURITY_ATTRIBUTES_INFORMATION *SecurityAttributesList; 
  _AUTHZBASEP_SECURITY_ATTRIBUTES_INFORMATION *v12; 
  _SID_AND_ATTRIBUTES *pDeviceGroups; 
  UINT64 DeviceGroupsCount; 
  int v15; 
  VOID **PoolWithTag; 
  UINT64 v17; 
  UINT64 CaptureBufferLength; 
  POOL_TYPE v19; 
  UINT8 v20; 
  char v21; 
  UINT64 AlignedArraySize; 
  _SID_AND_ATTRIBUTES *CapturedArray; 

  result = 0;
  v21 = 0;
  LODWORD(AlignedArraySize) = 0;
  v5 = 0;
  CapturedArray = 0i64;
  v6 = 0i64;
  v7 = 0i64;
  v8 = 0;
  v9 = 0i64;
  if( !NewClaimAttributes )
    return -1073741811;
  *NewClaimAttributes = 0i64;
  if( ExistingClaimAttributes )
  {
    ClaimCollectionNoLists = AuthzBasepAllocateClaimCollectionNoLists();
    if( !ClaimCollectionNoLists )
      return -1073741670;
    if( ExistingClaimAttributes->pUserSecurityAttributes )
    {
      SecurityAttributesList = AuthzBasepAllocateSecurityAttributesList();
      v6 = SecurityAttributesList;
      if( !SecurityAttributesList )
      {
        v5 = -1073741670;
LABEL_33:
        ExFreePoolWithTag(ClaimCollectionNoLists, 0);
        return v5;
      }
      v5 = AuthzBasepDuplicateSecurityAttributes(
             ExistingClaimAttributes->pUserSecurityAttributes,
             SecurityAttributesList,
             0);
      if( v5 < 0 )
      {
LABEL_23:
        if( v6 )
        {
          if( v8 )
            AuthzBasepFreeSecurityAttributesList(v6);
          ExFreePoolWithTag(v6, 0);
        }
        if( v7 )
        {
          if( v21 )
            AuthzBasepFreeSecurityAttributesList(v7);
          ExFreePoolWithTag(v7, 0);
        }
        if( v9 )
          ExFreePoolWithTag(v9, 0);
        goto LABEL_33;
      }
      v8 = 1;
      ClaimCollectionNoLists->pUserSecurityAttributes = v6;
    }
    if( ExistingClaimAttributes->pDeviceSecurityAttributes )
    {
      v12 = AuthzBasepAllocateSecurityAttributesList();
      v7 = v12;
      if( !v12 )
      {
LABEL_13:
        v5 = -1073741670;
        goto LABEL_23;
      }
      v5 = AuthzBasepDuplicateSecurityAttributes(ExistingClaimAttributes->pDeviceSecurityAttributes, v12, 0);
      if( v5 < 0 )
        goto LABEL_23;
      v21 = 1;
      ClaimCollectionNoLists->pDeviceSecurityAttributes = v7;
    }
    pDeviceGroups = ExistingClaimAttributes->pDeviceGroups;
    if( pDeviceGroups )
    {
      DeviceGroupsCount = ExistingClaimAttributes->DeviceGroupsCount;
      if( (_DWORD)DeviceGroupsCount )
      {
        v5 = SepLengthSidAndAttributesArray(pDeviceGroups, DeviceGroupsCount, &AlignedArraySize);
        if( v5 < 0 )
          goto LABEL_23;
        v15 = AlignedArraySize;
        PoolWithTag = ExAllocatePoolWithTag(1ui64, (unsigned int)AlignedArraySize, 1683252563i64);
        v9 = (_SID_AND_ATTRIBUTES *)PoolWithTag;
        if( !PoolWithTag )
          goto LABEL_13;
        LODWORD(CaptureBufferLength) = v15;
        v5 = SeCaptureSidAndAttributesArray(
               ExistingClaimAttributes->pDeviceGroups,
               ExistingClaimAttributes->DeviceGroupsCount,
               0i64,
               PoolWithTag,
               CaptureBufferLength,
               v19,
               v20,
               &CapturedArray,
               &AlignedArraySize);
        if( v5 < 0 )
          goto LABEL_23;
        v17 = ExistingClaimAttributes->DeviceGroupsCount;
        ClaimCollectionNoLists->DeviceGroupsCount = v17;
        ClaimCollectionNoLists->pDeviceGroups = v9;
        RtlSidHashInitialize(v9, v17, &ClaimCollectionNoLists->DeviceGroupsHash);
      }
    }
    *NewClaimAttributes = ClaimCollectionNoLists;
    if( v5 >= 0 )
      return v5;
    goto LABEL_23;
  }
  return result;
}

Referenced by:

SepConvertToOwnTokenClaims
SepDuplicateTokenClaims