示例#1
0
        }                                                // Size of DMG when expanded, in sectors

        private DmgHeader(
            uint version,
            uint flags,
            ulong runningDataForkOffset,
            ulong dataForkOffset,
            ulong dataForkLength,
            ulong rsrcForkOffset,
            ulong rsrcForkLength,
            uint segmentNumber,
            uint segmentCount,
            IReadOnlyList <byte> segmentID,
            UdifChecksum dataChecksum,
            ulong xMLOffset,
            ulong xMLLength,
            UdifChecksum checksum,
            uint imageVariant,
            ulong sectorCount)
        {
            Version = version;
            Flags   = flags;
            RunningDataForkOffset = runningDataForkOffset;
            DataForkOffset        = dataForkOffset;
            DataForkLength        = dataForkLength;
            RsrcForkOffset        = rsrcForkOffset;
            RsrcForkLength        = rsrcForkLength;
            SegmentNumber         = segmentNumber;
            SegmentCount          = segmentCount;
            SegmentID             = segmentID;
            DataChecksum          = dataChecksum;
            XMLOffset             = xMLOffset;
            XMLLength             = xMLLength;
            Checksum     = checksum;
            ImageVariant = imageVariant;
            SectorCount  = sectorCount;
        }
示例#2
0
 private BlkxTable(
     uint version,
     ulong sectorNumber,
     ulong sectorCount,
     ulong dataOffset,
     uint buffersNeeded,
     uint blockDescriptors,
     UdifChecksum checksum,
     IReadOnlyList <BlkxChunk> chunks)
 {
     Version          = version;
     SectorNumber     = sectorNumber;
     SectorCount      = sectorCount;
     DataOffset       = dataOffset;
     BuffersNeeded    = buffersNeeded;
     BlockDescriptors = blockDescriptors;
     Checksum         = checksum;
     Chunks           = chunks;
 }
示例#3
0
        internal static bool TryRead(Stream input, out DmgHeader?header)
        {
            header = null;

            var buffer = new byte[HeaderSize];
            int count  = input.Read(buffer, 0, HeaderSize);

            if (count != HeaderSize)
            {
                return(false);
            }
            ReadOnlySpan <byte> data = buffer.AsSpan();

            uint sig = ReadUInt32(ref data);

            if (sig != Signature)
            {
                return(false);
            }

            uint version = ReadUInt32(ref data);

            uint size = ReadUInt32(ref data);

            if (size != (uint)HeaderSize)
            {
                return(false);
            }

            uint  flags = ReadUInt32(ref data);
            ulong runningDataForkOffset = ReadUInt64(ref data);
            ulong dataForkOffset        = ReadUInt64(ref data);
            ulong dataForkLength        = ReadUInt64(ref data);
            ulong rsrcForkOffset        = ReadUInt64(ref data);
            ulong rsrcForkLength        = ReadUInt64(ref data);
            uint  segmentNumber         = ReadUInt32(ref data);
            uint  segmentCount          = ReadUInt32(ref data);

            var segmentID = new byte[UuidSize];

            ReadUuid(ref data, segmentID);

            var dataChecksum = UdifChecksum.Read(ref data);

            ulong xmlOffset = ReadUInt64(ref data);
            ulong xmlLength = ReadUInt64(ref data);

            data = data.Slice(120); // Reserved bytes

            var checksum = UdifChecksum.Read(ref data);

            uint  imageVariant = ReadUInt32(ref data);
            ulong sectorCount  = ReadUInt64(ref data);

            header = new DmgHeader(
                version,
                flags,
                runningDataForkOffset,
                dataForkOffset,
                dataForkLength,
                rsrcForkOffset,
                rsrcForkLength,
                segmentNumber,
                segmentCount,
                segmentID,
                dataChecksum,
                xmlOffset,
                xmlLength,
                checksum,
                imageVariant,
                sectorCount);

            return(true);
        }