protected override void Read(byte[] buffer, int offset, out int length) { _cookedDataRuns = null; base.Read(buffer, offset, out length); _startingVCN = Utilities.ToUInt64LittleEndian(buffer, offset + 0x10); _lastVCN = Utilities.ToUInt64LittleEndian(buffer, offset + 0x18); _dataRunsOffset = Utilities.ToUInt16LittleEndian(buffer, offset + 0x20); _compressionUnitSize = Utilities.ToUInt16LittleEndian(buffer, offset + 0x22); _dataAllocatedSize = Utilities.ToUInt64LittleEndian(buffer, offset + 0x28); _dataRealSize = Utilities.ToUInt64LittleEndian(buffer, offset + 0x30); _initializedDataSize = Utilities.ToUInt64LittleEndian(buffer, offset + 0x38); if ((Flags & AttributeFlags.Compressed) != 0) { _compressedSize = Utilities.ToUInt64LittleEndian(buffer, offset + 0x40); } var dataRuns = new List <DataRun>(); int pos = _dataRunsOffset; while (pos < length) { DataRun run = new DataRun(); int len = run.Read(buffer, offset + pos); // Length 1 means there was only a header byte (i.e. terminator) if (len == 1) { break; } dataRuns.Add(run); pos += len; } _cookedDataRuns = CookedDataRun.Cook(dataRuns); }
protected override void Read(byte[] buffer, int offset, out int length) { _dataRuns = null; base.Read(buffer, offset, out length); _startingVCN = Utilities.ToUInt64LittleEndian(buffer, offset + 0x10); _lastVCN = Utilities.ToUInt64LittleEndian(buffer, offset + 0x18); _dataRunsOffset = Utilities.ToUInt16LittleEndian(buffer, offset + 0x20); _compressionUnitSize = Utilities.ToUInt16LittleEndian(buffer, offset + 0x22); _dataAllocatedSize = Utilities.ToUInt64LittleEndian(buffer, offset + 0x28); _dataRealSize = Utilities.ToUInt64LittleEndian(buffer, offset + 0x30); _initializedDataSize = Utilities.ToUInt64LittleEndian(buffer, offset + 0x38); if ((Flags & (AttributeFlags.Compressed | AttributeFlags.Sparse)) != 0 && _dataRunsOffset > 0x40) { _compressedSize = Utilities.ToUInt64LittleEndian(buffer, offset + 0x40); } _dataRuns = new List<DataRun>(); int pos = _dataRunsOffset; while (pos < length) { DataRun run = new DataRun(); int len = run.Read(buffer, offset + pos); // Length 1 means there was only a header byte (i.e. terminator) if (len == 1) { break; } _dataRuns.Add(run); pos += len; } }