Esempio n. 1
0
        public IndexRootRecord(byte[] buffer, int offset) : base(buffer, offset)
        {
            IndexedAttributeType       = (AttributeType)LittleEndianConverter.ToUInt32(this.Data, 0x00);
            CollationRule              = (CollationRule)LittleEndianConverter.ToUInt32(this.Data, 0x04);
            IndexAllocationEntryLength = LittleEndianConverter.ToUInt32(this.Data, 0x08);
            ClustersPerIndexRecord     = ByteReader.ReadByte(this.Data, 0x0C);
            // 3 zero bytes (padding to 8-byte boundary)
            EntriesOffset   = LittleEndianConverter.ToUInt32(this.Data, 0x10);
            IndexLength     = LittleEndianConverter.ToUInt32(this.Data, 0x14);
            AllocatedLength = LittleEndianConverter.ToUInt32(this.Data, 0x18);
            IndexFlags      = (IndexRootFlags)ByteReader.ReadByte(this.Data, 0x1C);
            // 3 zero bytes (padding to 8-byte boundary)

            if (Name == FileNameIndexName)
            {
                int position = 0x10 + (int)EntriesOffset;
                if (IsLargeIndex)
                {
                    IndexNode node = new IndexNode(this.Data, position);
                    IndexEntries = node.Entries;
                }
                else
                {
                    FileNameIndexLeafNode leaf = new FileNameIndexLeafNode(this.Data, position);
                    FileNameEntries = leaf.Entries;
                }
            }
        }
Esempio n. 2
0
        public IndexRecord(byte[] buffer, int offset)
        {
            Signature = ByteReader.ReadAnsiString(buffer, offset + 0x00, 4);
            if (Signature != ValidSignature)
            {
                throw new InvalidDataException("Invalid INDX record signature");
            }
            ushort updateSequenceArrayOffset = LittleEndianConverter.ToUInt16(buffer, offset + 0x04);
            ushort updateSequenceArraySize   = LittleEndianConverter.ToUInt16(buffer, offset + 0x06);

            LogFileSequenceNumber = LittleEndianConverter.ToUInt64(buffer, offset + 0x08);
            RecordVCN             = LittleEndianConverter.ToUInt64(buffer, offset + 0x10);
            EntriesOffset         = LittleEndianConverter.ToUInt32(buffer, offset + 0x18);
            IndexLength           = LittleEndianConverter.ToUInt32(buffer, offset + 0x1C);
            AllocatedLength       = LittleEndianConverter.ToUInt32(buffer, offset + 0x20);
            HasChildren           = ByteReader.ReadByte(buffer, offset + 0x24) > 0;

            int position = offset + updateSequenceArrayOffset;

            UpdateSequenceNumber = LittleEndianConverter.ToUInt16(buffer, position);
            position            += 2;
            List <byte[]> updateSequenceReplacementData = new List <byte[]>();

            for (int index = 0; index < updateSequenceArraySize - 1; index++)
            {
                byte[] endOfSectorBytes = new byte[2];
                endOfSectorBytes[0] = buffer[position + 0];
                endOfSectorBytes[1] = buffer[position + 1];
                updateSequenceReplacementData.Add(endOfSectorBytes);
                position += 2;
            }

            MultiSectorHelper.DecodeSegmentBuffer(buffer, offset, UpdateSequenceNumber, updateSequenceReplacementData);

            position = 0x18 + (int)EntriesOffset;
            if (HasChildren)
            {
                IndexNode node = new IndexNode(buffer, position);
                IndexEntries = node.Entries;
            }
            else
            {
                FileNameIndexLeafNode leaf = new FileNameIndexLeafNode(buffer, position);
                FileNameEntries = leaf.Entries;
            }
        }