Exemplo n.º 1
0
        public FileResourceStream(Stream baseStream, ShortResourceHeader header, bool lzxCompression, int chunkSize)
        {
            _baseStream = baseStream;
            _header = header;
            _lzxCompression = lzxCompression;
            _chunkSize = chunkSize;

            if (baseStream.Length > uint.MaxValue)
            {
                throw new NotImplementedException("Large files >4GB");
            }

            int numChunks = (int)Utilities.Ceil(header.OriginalSize, _chunkSize);

            _chunkOffsets = new long[numChunks];
            _chunkLength = new long[numChunks];
            for (int i = 1; i < numChunks; ++i)
            {
                _chunkOffsets[i] = Utilities.ToUInt32LittleEndian(Utilities.ReadFully(_baseStream, 4), 0);
                _chunkLength[i - 1] = _chunkOffsets[i] - _chunkOffsets[i - 1];
            }

            _chunkLength[numChunks - 1] = (_baseStream.Length - _baseStream.Position) - _chunkOffsets[numChunks - 1];
            _offsetDelta = _baseStream.Position;

            _currentChunk = -1;
        }
Exemplo n.º 2
0
        public void Read(byte[] buffer, int offset)
        {
            Tag = Utilities.BytesToString(buffer, offset, 8);
            HeaderSize = Utilities.ToUInt32LittleEndian(buffer, 8);
            Version = Utilities.ToUInt32LittleEndian(buffer, 12);
            Flags = (FileFlags)Utilities.ToUInt32LittleEndian(buffer, 16);
            CompressionSize = Utilities.ToInt32LittleEndian(buffer, 20);
            WimGuid = Utilities.ToGuidLittleEndian(buffer, 24);
            PartNumber = Utilities.ToUInt16LittleEndian(buffer, 40);
            TotalParts = Utilities.ToUInt16LittleEndian(buffer, 42);
            ImageCount = Utilities.ToUInt32LittleEndian(buffer, 44);

            OffsetTableHeader = new ShortResourceHeader();
            OffsetTableHeader.Read(buffer, 48);

            XmlDataHeader = new ShortResourceHeader();
            XmlDataHeader.Read(buffer, 72);

            BootMetaData = new ShortResourceHeader();
            BootMetaData.Read(buffer, 96);

            BootIndex = Utilities.ToUInt32LittleEndian(buffer, 120);

            IntegrityHeader = new ShortResourceHeader();
            IntegrityHeader.Read(buffer, 124);
        }
Exemplo n.º 3
0
 public void Read(byte[] buffer, int offset)
 {
     Header = new ShortResourceHeader();
     Header.Read(buffer, offset);
     PartNumber = Utilities.ToUInt16LittleEndian(buffer, offset + ShortResourceHeader.Size);
     RefCount = Utilities.ToUInt32LittleEndian(buffer, offset + ShortResourceHeader.Size + 2);
     Hash = new byte[20];
     Array.Copy(buffer, offset + ShortResourceHeader.Size + 6, Hash, 0, 20);
 }
Exemplo n.º 4
0
        internal SparseStream OpenResourceStream(ShortResourceHeader hdr)
        {
            SparseStream fileSectionStream = new SubStream(_fileStream, Ownership.None, hdr.FileOffset, hdr.CompressedSize);
            if ((hdr.Flags & ResourceFlags.Compressed) == 0)
            {
                return fileSectionStream;
            }

            return new FileResourceStream(fileSectionStream, hdr, (_fileHeader.Flags & FileFlags.LzxCompression) != 0, _fileHeader.CompressionSize);
        }