}                                                           // The start of the optional attribute name. Contains an UTF-16 little-endian without the end-of-string character

        public static AttributeListEntry ReadListEntry(byte[] data, int maxLength, int offset)
        {
            if (maxLength < 26)
            {
                throw new Exception("<<max length>> values is not valid.\n");
            }

            AttributeListEntry attribute = new AttributeListEntry();

            attribute.AttributeTypeCode   = (AttributeTypeCode)BitConverter.ToUInt32(data, offset);
            attribute.RecordLength        = BitConverter.ToUInt16(data, offset + 4);
            attribute.AttributeNameLength = data[offset + 6];
            attribute.AttributeNameOffset = data[offset + 7];
            attribute.LowestVcn           = BitConverter.ToUInt64(data, offset + 8);
            attribute.SegmentReference    = new MFTSegmentReference(BitConverter.ToUInt64(data, offset + 16));
            attribute.AttributeId         = BitConverter.ToUInt16(data, offset + 24);

            if (maxLength < attribute.AttributeNameOffset + attribute.AttributeNameLength * 2)
            {
                throw new Exception("Error!\n");
            }

            attribute.AttributeName = Encoding.Unicode.GetString(data, offset + attribute.AttributeNameOffset, attribute.AttributeNameOffset * 2);

            return(attribute);
        }
        internal override void ReadAttributeResident(byte[] data, int maxLength, int offset)
        {
            base.ReadAttributeResident(data, maxLength, offset);

            if (ResidentHeader.ValueLength > maxLength)
            {
                throw new Exception("Error!\n");
            }

            List <AttributeListEntry> entryList = new List <AttributeListEntry>();

            int offsetCpy = offset;

            while (offsetCpy + 26 <= offset + maxLength)
            {
                AttributeListEntry entry = AttributeListEntry.ReadListEntry(data, Math.Min(data.Length - offsetCpy, maxLength), offsetCpy);

                if (entry.AttributeTypeCode == AttributeTypeCode.EndOfAttributes)
                {
                    break;
                }

                entryList.Add(entry);
                offsetCpy += entry.RecordLength;
            }

            entries = entryList.ToArray();
        }