public override int Parse(byte[] buffer, int offset)
        {
            VolumeDescriptorSequenceNumber = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 16);
            PrimaryVolumeDescriptorNumber  = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 20);
            VolumeIdentifier       = UdfUtilities.ReadDString(buffer, offset + 24, 32);
            VolumeSequenceNumber   = EndianUtilities.ToUInt16LittleEndian(buffer, offset + 56);
            MaxVolumeSquenceNumber = EndianUtilities.ToUInt16LittleEndian(buffer, offset + 58);
            InterchangeLevel       = EndianUtilities.ToUInt16LittleEndian(buffer, offset + 60);
            MaxInterchangeLevel    = EndianUtilities.ToUInt16LittleEndian(buffer, offset + 62);
            CharacterSetList       = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 64);
            MaxCharacterSetList    = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 68);
            VolumeSetIdentifier    = UdfUtilities.ReadDString(buffer, offset + 72, 128);
            DescriptorCharSet      = EndianUtilities.ToStruct <CharacterSetSpecification>(buffer, offset + 200);
            ExplanatoryCharSet     = EndianUtilities.ToStruct <CharacterSetSpecification>(buffer, offset + 264);
            VolumeAbstractExtent   = new ExtentDescriptor();
            VolumeAbstractExtent.ReadFrom(buffer, offset + 328);
            VolumeCopyrightNoticeExtent = new ExtentDescriptor();
            VolumeCopyrightNoticeExtent.ReadFrom(buffer, offset + 336);
            ApplicationIdentifier    = EndianUtilities.ToStruct <ApplicationEntityIdentifier>(buffer, offset + 344);
            RecordingTime            = UdfUtilities.ParseTimestamp(buffer, offset + 376);
            ImplementationIdentifier = EndianUtilities.ToStruct <ImplementationEntityIdentifier>(buffer, offset + 388);
            ImplementationUse        = EndianUtilities.ToByteArray(buffer, offset + 420, 64);
            PredecessorVolumeDescriptorSequenceLocation = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 484);
            Flags = EndianUtilities.ToUInt16LittleEndian(buffer, offset + 488);

            return(512);
        }
示例#2
0
        public override int ReadFrom(byte[] buffer, int offset)
        {
            DescriptorTag           = EndianUtilities.ToStruct <DescriptorTag>(buffer, offset);
            InformationControlBlock = EndianUtilities.ToStruct <InformationControlBlock>(buffer, offset + 16);
            Uid                         = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 36);
            Gid                         = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 40);
            Permissions                 = (FilePermissions)EndianUtilities.ToUInt32LittleEndian(buffer, offset + 44);
            FileLinkCount               = EndianUtilities.ToUInt16LittleEndian(buffer, offset + 48);
            RecordFormat                = buffer[offset + 50];
            RecordDisplayAttributes     = buffer[offset + 51];
            RecordLength                = EndianUtilities.ToUInt16LittleEndian(buffer, offset + 52);
            InformationLength           = EndianUtilities.ToUInt64LittleEndian(buffer, offset + 56);
            ObjectSize                  = EndianUtilities.ToUInt64LittleEndian(buffer, offset + 64);
            LogicalBlocksRecorded       = EndianUtilities.ToUInt64LittleEndian(buffer, offset + 72);
            AccessTime                  = UdfUtilities.ParseTimestamp(buffer, offset + 80);
            ModificationTime            = UdfUtilities.ParseTimestamp(buffer, offset + 92);
            CreationTime                = UdfUtilities.ParseTimestamp(buffer, offset + 104);
            AttributeTime               = UdfUtilities.ParseTimestamp(buffer, offset + 116);
            Checkpoint                  = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 128);
            ExtendedAttributeIcb        = EndianUtilities.ToStruct <LongAllocationDescriptor>(buffer, offset + 136);
            StreamDirectoryIcb          = EndianUtilities.ToStruct <LongAllocationDescriptor>(buffer, offset + 152);
            ImplementationIdentifier    = EndianUtilities.ToStruct <ImplementationEntityIdentifier>(buffer, offset + 168);
            UniqueId                    = EndianUtilities.ToUInt64LittleEndian(buffer, offset + 200);
            ExtendedAttributesLength    = EndianUtilities.ToInt32LittleEndian(buffer, offset + 208);
            AllocationDescriptorsLength = EndianUtilities.ToInt32LittleEndian(buffer, offset + 212);
            AllocationDescriptors       = EndianUtilities.ToByteArray(buffer, offset + 216 + ExtendedAttributesLength,
                                                                      AllocationDescriptorsLength);

            byte[] eaData = EndianUtilities.ToByteArray(buffer, offset + 216, ExtendedAttributesLength);
            ExtendedAttributes = ReadExtendedAttributes(eaData);

            return(216 + ExtendedAttributesLength + AllocationDescriptorsLength);
        }
示例#3
0
        public MetadataPartition(UdfContext context, LogicalVolumeDescriptor volumeDescriptor,
                                 MetadataPartitionMap partitionMap)
            : base(context, volumeDescriptor)
        {
            _partitionMap = partitionMap;

            PhysicalPartition physical = context.PhysicalPartitions[partitionMap.PartitionNumber];
            long fileEntryPos          = partitionMap.MetadataFileLocation * (long)volumeDescriptor.LogicalBlockSize;

            byte[] entryData = StreamUtilities.ReadExact(physical.Content, fileEntryPos, _context.PhysicalSectorSize);
            if (!DescriptorTag.IsValid(entryData, 0))
            {
                throw new IOException("Invalid descriptor tag looking for Metadata file entry");
            }

            DescriptorTag dt = EndianUtilities.ToStruct <DescriptorTag>(entryData, 0);

            if (dt.TagIdentifier == TagIdentifier.ExtendedFileEntry)
            {
                ExtendedFileEntry efe = EndianUtilities.ToStruct <ExtendedFileEntry>(entryData, 0);
                _metadataFile = new File(context, physical, efe, _volumeDescriptor.LogicalBlockSize);
            }
            else
            {
                throw new NotImplementedException("Only EFE implemented for Metadata file entry");
            }
        }
        public override int Parse(byte[] buffer, int offset)
        {
            VolumeDescriptorSequenceNumber = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 16);
            DescriptorCharset        = EndianUtilities.ToByteArray(buffer, offset + 20, 64);
            LogicalVolumeIdentifier  = UdfUtilities.ReadDString(buffer, offset + 84, 128);
            LogicalBlockSize         = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 212);
            DomainIdentifier         = EndianUtilities.ToStruct <DomainEntityIdentifier>(buffer, offset + 216);
            LogicalVolumeContentsUse = EndianUtilities.ToByteArray(buffer, offset + 248, 16);
            MapTableLength           = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 264);
            NumPartitionMaps         = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 268);
            ImplementationIdentifier = EndianUtilities.ToStruct <ImplementationEntityIdentifier>(buffer, offset + 272);
            ImplementationUse        = EndianUtilities.ToByteArray(buffer, offset + 304, 128);
            IntegritySequenceExtent  = new ExtentDescriptor();
            IntegritySequenceExtent.ReadFrom(buffer, offset + 432);

            int pmOffset = 0;

            PartitionMaps = new PartitionMap[NumPartitionMaps];
            for (int i = 0; i < NumPartitionMaps; ++i)
            {
                PartitionMaps[i] = PartitionMap.CreateFrom(buffer, offset + 440 + pmOffset);
                pmOffset        += PartitionMaps[i].Size;
            }

            return(440 + (int)MapTableLength);
        }
示例#5
0
        public static File FromDescriptor(UdfContext context, LongAllocationDescriptor icb)
        {
            LogicalPartition partition = context.LogicalPartitions[icb.ExtentLocation.Partition];

            byte[]        rootDirData = UdfUtilities.ReadExtent(context, icb);
            DescriptorTag rootDirTag  = EndianUtilities.ToStruct <DescriptorTag>(rootDirData, 0);

            if (rootDirTag.TagIdentifier == TagIdentifier.ExtendedFileEntry)
            {
                ExtendedFileEntry fileEntry = EndianUtilities.ToStruct <ExtendedFileEntry>(rootDirData, 0);
                if (fileEntry.InformationControlBlock.FileType == FileType.Directory)
                {
                    return(new Directory(context, partition, fileEntry));
                }
                return(new File(context, partition, fileEntry, (uint)partition.LogicalBlockSize));
            }
            if (rootDirTag.TagIdentifier == TagIdentifier.FileEntry)
            {
                FileEntry fileEntry = EndianUtilities.ToStruct <FileEntry>(rootDirData, 0);
                if (fileEntry.InformationControlBlock.FileType == FileType.Directory)
                {
                    return(new Directory(context, partition, fileEntry));
                }
                return(new File(context, partition, fileEntry, (uint)partition.LogicalBlockSize));
            }
            throw new NotImplementedException("Only ExtendedFileEntries implemented");
        }
示例#6
0
        public int ReadFrom(byte[] buffer, int offset)
        {
            Header = EndianUtilities.ToStruct <ExtentHeader>(buffer, offset + 0);
            if (Header.Magic != ExtentHeader.HeaderMagic)
            {
                throw new IOException("Invalid extent header reading inode");
            }

            if (Header.Depth == 0)
            {
                Index   = null;
                Extents = new Extent[Header.Entries];
                for (int i = 0; i < Extents.Length; ++i)
                {
                    Extents[i] = EndianUtilities.ToStruct <Extent>(buffer, offset + 12 + i * 12);
                }
            }
            else
            {
                Extents = null;
                Index   = new ExtentIndex[Header.Entries];
                for (int i = 0; i < Index.Length; ++i)
                {
                    Index[i] = EndianUtilities.ToStruct <ExtentIndex>(buffer, offset + 12 + i * 12);
                }
            }

            return(12 + Header.MaxEntries * 12);
        }
示例#7
0
        public int ReadFrom(byte[] buffer, int offset)
        {
            this.Signature             = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0);
            this.Version               = EndianUtilities.ToUInt32BigEndian(buffer, offset + 4);
            this.HeaderSize            = EndianUtilities.ToUInt32BigEndian(buffer, offset + 8);
            this.Flags                 = EndianUtilities.ToUInt32BigEndian(buffer, offset + 12);
            this.RunningDataForkOffset = EndianUtilities.ToUInt64BigEndian(buffer, offset + 16);
            this.DataForkOffset        = EndianUtilities.ToUInt64BigEndian(buffer, offset + 24);
            this.DataForkLength        = EndianUtilities.ToUInt64BigEndian(buffer, offset + 32);
            this.RsrcForkOffset        = EndianUtilities.ToUInt64BigEndian(buffer, offset + 40);
            this.RsrcForkLength        = EndianUtilities.ToUInt64BigEndian(buffer, offset + 48);
            this.SegmentNumber         = EndianUtilities.ToUInt32BigEndian(buffer, offset + 56);
            this.SegmentCount          = EndianUtilities.ToUInt32BigEndian(buffer, offset + 60);
            this.SegmentGuid           = EndianUtilities.ToGuidBigEndian(buffer, offset + 64);

            this.DataForkChecksum = EndianUtilities.ToStruct <UdifChecksum>(buffer, offset + 80);
            this.XmlOffset        = EndianUtilities.ToUInt64BigEndian(buffer, offset + 216);
            this.XmlLength        = EndianUtilities.ToUInt64BigEndian(buffer, offset + 224);

            this.MasterChecksum = EndianUtilities.ToStruct <UdifChecksum>(buffer, offset + 352);
            this.ImageVariant   = EndianUtilities.ToUInt32BigEndian(buffer, offset + 488);
            this.SectorCount    = EndianUtilities.ToInt64BigEndian(buffer, offset + 492);

            return(this.Size);
        }
示例#8
0
        public override int ReadFrom(byte[] buffer, int offset)
        {
            Inode        = EndianUtilities.ToStruct <InodeItem>(buffer, offset);
            Generation   = EndianUtilities.ToUInt64LittleEndian(buffer, offset + 160);
            RootDirId    = EndianUtilities.ToUInt64LittleEndian(buffer, offset + 168);
            ByteNr       = EndianUtilities.ToUInt64LittleEndian(buffer, offset + 176);
            ByteLimit    = EndianUtilities.ToUInt64LittleEndian(buffer, offset + 184);
            BytesUsed    = EndianUtilities.ToUInt64LittleEndian(buffer, offset + 192);
            LastSnapshot = EndianUtilities.ToUInt64LittleEndian(buffer, offset + 200);
            Flags        = EndianUtilities.ToUInt64LittleEndian(buffer, offset + 208);
            Refs         = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 216);
            DropProgress = EndianUtilities.ToStruct <Key>(buffer, offset + 220);
            DropLevel    = buffer[offset + 237];
            Level        = buffer[offset + 238];

            //The following fields depend on the subvol_uuids+subvol_times features
            //239   __le64  generation_v2   If equal to generation, indicates validity of the following fields.
            //If the root is modified using an older kernel, this field and generation will become out of sync. This is normal and recoverable.
            //247   u8[16]  uuid    This subvolume's UUID.
            //263   u8[16]  parent_uuid     The parent's UUID (for use with send/receive).
            //279   u8[16]  received_uuid   The received UUID (for used with send/receive).
            //295   __le64  ctransid    The transid of the last transaction that modified this tree, with some exceptions (like the internal caches or relocation).
            //303   __le64  otransid    The transid of the transaction that created this tree.
            //311   __le64  stransid    The transid for the transaction that sent this subvolume. Nonzero for received subvolume.
            //319   __le64  rtransid    The transid for the transaction that received this subvolume. Nonzero for received subvolume.
            //327   struct btrfs_timespec   ctime   Timestamp for ctransid.
            //339   struct btrfs_timespec   otime   Timestamp for otransid.
            //351   struct btrfs_timespec   stime   Timestamp for stransid.
            //363   struct btrfs_timespec   rtime   Timestamp for rtransid.
            //375   __le64[8]   reserved    Reserved for future use.

            return(Size);
        }
示例#9
0
        public int ReadFrom(byte[] buffer, int offset)
        {
            FileType    = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0);
            FileCreator = EndianUtilities.ToUInt32BigEndian(buffer, offset + 4);
            FinderFlags = (FinderFlags)EndianUtilities.ToUInt16BigEndian(buffer, offset + 8);
            Point       = EndianUtilities.ToStruct <Point>(buffer, offset + 10);

            return(16);
        }
        private ExtentBlock LoadExtentBlock(ExtentIndex idxEntry)
        {
            uint blockSize = _context.SuperBlock.BlockSize;

            _context.RawStream.Position = idxEntry.LeafPhysicalBlock * blockSize;
            byte[]      buffer   = StreamUtilities.ReadFully(_context.RawStream, (int)blockSize);
            ExtentBlock subBlock = EndianUtilities.ToStruct <ExtentBlock>(buffer, 0);

            return(subBlock);
        }
示例#11
0
 public override int ReadFrom(byte[] buffer, int offset)
 {
     ChildLocation = EndianUtilities.ToStruct <Key>(buffer, offset);
     TransId       = EndianUtilities.ToUInt64LittleEndian(buffer, offset + 0x11);
     DataLength    = EndianUtilities.ToUInt16LittleEndian(buffer, offset + 0x19);
     NameLength    = EndianUtilities.ToUInt16LittleEndian(buffer, offset + 0x1b);
     ChildType     = (DirItemChildType)buffer[offset + 0x1d];
     Name          = Encoding.UTF8.GetString(buffer, offset + 0x1e, NameLength);
     Data          = EndianUtilities.ToByteArray(buffer, offset + 0x1e + NameLength, DataLength);
     return(Size);
 }
示例#12
0
        public override int ReadFrom(byte[] buffer, int offset)
        {
            base.ReadFrom(buffer, offset);

            Flags    = EndianUtilities.ToUInt16BigEndian(buffer, offset + 2);
            FileInfo = EndianUtilities.ToStruct <FileInfo>(buffer, offset + 48);

            DataFork     = EndianUtilities.ToStruct <ForkData>(buffer, offset + 88);
            ResourceFork = EndianUtilities.ToStruct <ForkData>(buffer, offset + 168);

            return(0);
        }
示例#13
0
        public int ReadFrom(byte[] buffer, int offset)
        {
            Extents = new ExtentDescriptor[3];
            int curOff = offset;

            for (int i = 0; i < 3; ++i)
            {
                Extents[i] = EndianUtilities.ToStruct <ExtentDescriptor>(buffer, curOff);
                curOff    += Extents[i].Size;
            }

            return(StructSize);
        }
示例#14
0
        public int ReadFrom(byte[] buffer, int offset)
        {
            DescriptorTag           = EndianUtilities.ToStruct <DescriptorTag>(buffer, offset);
            FileVersionNumber       = EndianUtilities.ToUInt16LittleEndian(buffer, offset + 16);
            FileCharacteristics     = (FileCharacteristic)buffer[offset + 18];
            NameLength              = buffer[offset + 19];
            FileLocation            = EndianUtilities.ToStruct <LongAllocationDescriptor>(buffer, offset + 20);
            ImplementationUseLength = EndianUtilities.ToUInt16LittleEndian(buffer, offset + 36);
            ImplementationUse       = EndianUtilities.ToByteArray(buffer, offset + 38, ImplementationUseLength);
            Name = UdfUtilities.ReadDCharacters(buffer, offset + 38 + ImplementationUseLength, NameLength);

            return(MathUtilities.RoundUp(38 + ImplementationUseLength + NameLength, 4));
        }
示例#15
0
        public int ReadFrom(byte[] buffer, int offset)
        {
            Mode             = EndianUtilities.ToUInt16LittleEndian(buffer, offset + 0);
            UserIdLow        = EndianUtilities.ToUInt16LittleEndian(buffer, offset + 2);
            FileSize         = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 4);
            AccessTime       = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 8);
            CreationTime     = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 12);
            ModificationTime = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 16);
            DeletionTime     = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 20);
            GroupIdLow       = EndianUtilities.ToUInt16LittleEndian(buffer, offset + 24);
            LinksCount       = EndianUtilities.ToUInt16LittleEndian(buffer, offset + 26);
            BlocksCount      = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 28);
            Flags            = (InodeFlags)EndianUtilities.ToUInt32LittleEndian(buffer, offset + 32);

            FastSymlink  = null;
            Extents      = null;
            DirectBlocks = null;
            if (FileType == UnixFileType.Link && BlocksCount == 0)
            {
                FastSymlink = new byte[60];
                Array.Copy(buffer, offset + 40, FastSymlink, 0, 60);
            }
            else if ((Flags & InodeFlags.ExtentsUsed) != 0)
            {
                Extents = EndianUtilities.ToStruct <ExtentBlock>(buffer, offset + 40);
            }
            else
            {
                DirectBlocks = new uint[12];
                for (int i = 0; i < 12; ++i)
                {
                    DirectBlocks[i] = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 40 + i * 4);
                }

                IndirectBlock       = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 88);
                DoubleIndirectBlock = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 92);
                TripleIndirectBlock = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 96);
            }

            FileVersion  = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 100);
            FileAcl      = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 104);
            DirAcl       = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 108);
            FragAddress  = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 112);
            Fragment     = buffer[offset + 116];
            FragmentSize = buffer[offset + 117];
            UserIdHigh   = EndianUtilities.ToUInt16LittleEndian(buffer, offset + 120);
            GroupIdHigh  = EndianUtilities.ToUInt16LittleEndian(buffer, offset + 122);

            return(128);
        }
示例#16
0
        public int ReadFrom(byte[] buffer, int offset)
        {
            LogicalSize = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0);
            ClumpSize   = EndianUtilities.ToUInt32BigEndian(buffer, offset + 8);
            TotalBlocks = EndianUtilities.ToUInt32BigEndian(buffer, offset + 12);

            Extents = new ExtentDescriptor[8];
            for (int i = 0; i < 8; ++i)
            {
                Extents[i] = EndianUtilities.ToStruct <ExtentDescriptor>(buffer, offset + 16 + i * 8);
            }

            return(StructSize);
        }
示例#17
0
        public override int Parse(byte[] buffer, int offset)
        {
            VolumeDescriptorSequenceNumber = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 16);
            PartitionFlags            = EndianUtilities.ToUInt16LittleEndian(buffer, offset + 20);
            PartitionNumber           = EndianUtilities.ToUInt16LittleEndian(buffer, offset + 22);
            PartitionContents         = EndianUtilities.ToStruct <ApplicationEntityIdentifier>(buffer, offset + 24);
            PartitionContentsUse      = EndianUtilities.ToByteArray(buffer, offset + 56, 128);
            AccessType                = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 184);
            PartitionStartingLocation = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 188);
            PartitionLength           = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 192);
            ImplementationIdentifier  = EndianUtilities.ToStruct <ImplementationEntityIdentifier>(buffer, offset + 196);
            ImplementationUse         = EndianUtilities.ToByteArray(buffer, offset + 228, 128);

            return(512);
        }
        public override int Parse(byte[] buffer, int offset)
        {
            VolumeDescriptorSequenceNumber = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 16);

            uint numDescriptors = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 20);

            Extents = new ExtentAllocationDescriptor[numDescriptors];

            for (int i = 0; i < numDescriptors; ++i)
            {
                Extents[i] = EndianUtilities.ToStruct <ExtentAllocationDescriptor>(buffer, offset + 24 + i * 8);
            }

            return((int)(24 + numDescriptors * 8));
        }
        public int ReadFrom(byte[] buffer, int offset)
        {
            PriorDirectEntries = EndianUtilities.ToUInt32LittleEndian(buffer, offset);
            StrategyType       = EndianUtilities.ToUInt16LittleEndian(buffer, offset + 4);
            StrategyParameter  = EndianUtilities.ToUInt16LittleEndian(buffer, offset + 6);
            MaxEntries         = EndianUtilities.ToUInt16LittleEndian(buffer, offset + 8);
            FileType           = (FileType)buffer[offset + 11];
            ParentICBLocation  = EndianUtilities.ToStruct <LogicalBlockAddress>(buffer, offset + 12);

            ushort flagsField = EndianUtilities.ToUInt16LittleEndian(buffer, offset + 18);

            AllocationType = (AllocationType)(flagsField & 0x3);
            Flags          = (InformationControlBlockFlags)(flagsField & 0xFFFC);

            return(20);
        }
示例#20
0
        public int ReadFrom(byte[] buffer, int offset)
        {
            Signature = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0);
            if (!IsValid)
            {
                return(Size);
            }

            Version            = EndianUtilities.ToUInt16BigEndian(buffer, offset + 2);
            Attributes         = (VolumeAttributes)EndianUtilities.ToUInt32BigEndian(buffer, offset + 4);
            LastMountedVersion = EndianUtilities.ToUInt32BigEndian(buffer, offset + 8);
            JournalInfoBlock   = EndianUtilities.ToUInt32BigEndian(buffer, offset + 12);

            CreateDate  = HfsPlusUtilities.ReadHFSPlusDate(DateTimeKind.Local, buffer, offset + 16);
            ModifyDate  = HfsPlusUtilities.ReadHFSPlusDate(DateTimeKind.Utc, buffer, offset + 20);
            BackupDate  = HfsPlusUtilities.ReadHFSPlusDate(DateTimeKind.Utc, buffer, offset + 24);
            CheckedDate = HfsPlusUtilities.ReadHFSPlusDate(DateTimeKind.Utc, buffer, offset + 28);

            FileCount   = EndianUtilities.ToUInt32BigEndian(buffer, offset + 32);
            FolderCount = EndianUtilities.ToUInt32BigEndian(buffer, offset + 36);

            BlockSize   = EndianUtilities.ToUInt32BigEndian(buffer, offset + 40);
            TotalBlocks = EndianUtilities.ToUInt32BigEndian(buffer, offset + 44);
            FreeBlocks  = EndianUtilities.ToUInt32BigEndian(buffer, offset + 48);

            NextAllocation    = EndianUtilities.ToUInt32BigEndian(buffer, offset + 52);
            ResourceClumpSize = EndianUtilities.ToUInt32BigEndian(buffer, offset + 56);
            DataClumpSize     = EndianUtilities.ToUInt32BigEndian(buffer, offset + 60);
            NextCatalogId     = new CatalogNodeId(EndianUtilities.ToUInt32BigEndian(buffer, offset + 64));

            WriteCount      = EndianUtilities.ToUInt32BigEndian(buffer, offset + 68);
            EncodingsBitmap = EndianUtilities.ToUInt64BigEndian(buffer, offset + 72);

            FinderInfo = new uint[8];
            for (int i = 0; i < 8; ++i)
            {
                FinderInfo[i] = EndianUtilities.ToUInt32BigEndian(buffer, offset + 80 + i * 4);
            }

            AllocationFile = EndianUtilities.ToStruct <ForkData>(buffer, offset + 112);
            ExtentsFile    = EndianUtilities.ToStruct <ForkData>(buffer, offset + 192);
            CatalogFile    = EndianUtilities.ToStruct <ForkData>(buffer, offset + 272);
            AttributesFile = EndianUtilities.ToStruct <ForkData>(buffer, offset + 352);
            StartupFile    = EndianUtilities.ToStruct <ForkData>(buffer, offset + 432);

            return(512);
        }
示例#21
0
        public int ReadFrom(byte[] buffer, int offset)
        {
            //LogicalSize = EndianUtilities.ToUInt64BigEndian(buffer, offset + 0);
            //ClumpSize = EndianUtilities.ToUInt32BigEndian(buffer, offset + 8);
            //TotalBlocks = EndianUtilities.ToUInt32BigEndian(buffer, offset + 12);

            Extents = new ExtentDescriptor[3];
            int curOff = offset;

            for (int i = 0; i < 3; ++i)
            {
                Extents[i] = EndianUtilities.ToStruct <ExtentDescriptor>(buffer, curOff);
                curOff    += Extents[i].Size;
            }

            return(StructSize);
        }
示例#22
0
        public static BTreeNode ReadNode(BTree tree, byte[] buffer, int offset)
        {
            BTreeNodeDescriptor descriptor =
                EndianUtilities.ToStruct <BTreeNodeDescriptor>(buffer, offset);

            switch (descriptor.Kind)
            {
            case BTreeNodeKind.HeaderNode:
                return(new BTreeHeaderNode(tree, descriptor));

            case BTreeNodeKind.IndexNode:
            case BTreeNodeKind.LeafNode:
                throw new NotImplementedException("Attempt to read index/leaf node without key and data types");

            default:
                throw new NotImplementedException("Unrecognized BTree node kind: " + descriptor.Kind);
            }
        }
示例#23
0
        public int ReadFrom(byte[] buffer, int offset)
        {
            Array.Copy(buffer, offset, _headerData, 0, 32);

            Signature  = EndianUtilities.ToUInt64LittleEndian(_headerData, 0);
            EntryCount = EndianUtilities.ToUInt16LittleEndian(_headerData, 10);

            Entries = new Dictionary <MetadataEntryKey, MetadataEntry>();
            if (IsValid)
            {
                for (int i = 0; i < EntryCount; ++i)
                {
                    MetadataEntry entry = EndianUtilities.ToStruct <MetadataEntry>(buffer, offset + 32 + i * 32);
                    Entries[MetadataEntryKey.FromEntry(entry)] = entry;
                }
            }

            return(FixedSize);
        }
示例#24
0
        private Inode GetInode(uint inodeNum)
        {
            uint index = inodeNum - 1;

            SuperBlock superBlock = Context.SuperBlock;

            uint       group           = index / superBlock.InodesPerGroup;
            uint       groupOffset     = index - group * superBlock.InodesPerGroup;
            BlockGroup inodeBlockGroup = GetBlockGroup(group);

            uint inodesPerBlock = superBlock.BlockSize / superBlock.InodeSize;
            uint block          = groupOffset / inodesPerBlock;
            uint blockOffset    = groupOffset - block * inodesPerBlock;

            Context.RawStream.Position = (inodeBlockGroup.InodeTableBlock + block) * (long)superBlock.BlockSize +
                                         blockOffset * superBlock.InodeSize;
            byte[] inodeData = StreamUtilities.ReadFully(Context.RawStream, superBlock.InodeSize);

            return(EndianUtilities.ToStruct <Inode>(inodeData, 0));
        }
示例#25
0
 public override int ReadFrom(byte[] buffer, int offset)
 {
     Generation = EndianUtilities.ToUInt64LittleEndian(buffer, offset);
     TransId    = EndianUtilities.ToUInt64LittleEndian(buffer, offset + 8);
     FileSize   = EndianUtilities.ToUInt64LittleEndian(buffer, offset + 16);
     NBytes     = EndianUtilities.ToUInt64LittleEndian(buffer, offset + 24);
     BlockGroup = EndianUtilities.ToUInt64LittleEndian(buffer, offset + 32);
     LinkCount  = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 40);
     Uid        = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 44);
     Gid        = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 48);
     Mode       = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 52);
     RDev       = EndianUtilities.ToUInt64LittleEndian(buffer, offset + 56);
     Flags      = (InodeFlag)EndianUtilities.ToUInt64LittleEndian(buffer, offset + 64);
     Sequence   = EndianUtilities.ToUInt64LittleEndian(buffer, offset + 72);
     ATime      = EndianUtilities.ToStruct <TimeSpec>(buffer, offset + 112);
     CTime      = EndianUtilities.ToStruct <TimeSpec>(buffer, offset + 124);
     MTime      = EndianUtilities.ToStruct <TimeSpec>(buffer, offset + 136);
     OTime      = EndianUtilities.ToStruct <TimeSpec>(buffer, offset + 148);
     return(Size);
 }
示例#26
0
        public static BTreeNode ReadNode <TKey>(BTree tree, byte[] buffer, int offset)
            where TKey : BTreeKey, new()
        {
            BTreeNodeDescriptor descriptor =
                EndianUtilities.ToStruct <BTreeNodeDescriptor>(buffer, offset);

            switch (descriptor.Kind)
            {
            case BTreeNodeKind.HeaderNode:
                return(new BTreeHeaderNode(tree, descriptor));

            case BTreeNodeKind.LeafNode:
                return(new BTreeLeafNode <TKey>(tree, descriptor));

            case BTreeNodeKind.IndexNode:
                return(new BTreeIndexNode <TKey>(tree, descriptor));

            default:
                throw new NotImplementedException("Unrecognized BTree node kind: " + descriptor.Kind);
            }
        }
示例#27
0
        public int ReadFrom(byte[] buffer, int offset)
        {
            Array.Copy(buffer, offset, _data, 0, FixedSize);

            Signature  = EndianUtilities.ToUInt32LittleEndian(_data, 0);
            Checksum   = EndianUtilities.ToUInt32LittleEndian(_data, 4);
            EntryCount = EndianUtilities.ToUInt32LittleEndian(_data, 8);
            Reserved   = EndianUtilities.ToUInt32LittleEndian(_data, 12);
            Regions    = new Dictionary <Guid, RegionEntry>();

            if (IsValid)
            {
                for (int i = 0; i < EntryCount; ++i)
                {
                    RegionEntry entry = EndianUtilities.ToStruct <RegionEntry>(_data, 16 + 32 * i);
                    Regions.Add(entry.Guid, entry);
                }
            }

            return(Size);
        }
示例#28
0
        public static PartitionMap CreateFrom(byte[] buffer, int offset)
        {
            PartitionMap result = null;

            byte type = buffer[offset];

            if (type == 1)
            {
                result = new Type1PartitionMap();
            }
            else if (type == 2)
            {
                EntityIdentifier id = EndianUtilities.ToStruct <UdfEntityIdentifier>(buffer, offset + 4);
                switch (id.Identifier)
                {
                case "*UDF Virtual Partition":
                    result = new VirtualPartitionMap();
                    break;

                case "*UDF Sparable Partition":
                    result = new SparablePartitionMap();
                    break;

                case "*UDF Metadata Partition":
                    result = new MetadataPartitionMap();
                    break;

                default:
                    throw new InvalidDataException("Unrecognized partition map entity id: " + id);
                }
            }

            if (result != null)
            {
                result.ReadFrom(buffer, offset);
            }

            return(result);
        }
示例#29
0
        public int ReadFrom(byte[] buffer, int offset)
        {
            this.Signature   = EndianUtilities.ToUInt32BigEndian(buffer, offset + 0);
            this.InfoVersion = EndianUtilities.ToUInt32BigEndian(buffer, offset + 4);
            this.FirstSector = EndianUtilities.ToInt64BigEndian(buffer, offset + 8);
            this.SectorCount = EndianUtilities.ToInt64BigEndian(buffer, offset + 16);
            this.DataStart   = EndianUtilities.ToUInt64BigEndian(buffer, offset + 24);
            this.DecompressBufferRequested = EndianUtilities.ToUInt32BigEndian(buffer, offset + 32);
            this.BlocksDescriptor          = EndianUtilities.ToUInt32BigEndian(buffer, offset + 36);

            this.CheckSum = EndianUtilities.ToStruct <UdifChecksum>(buffer, offset + 60);

            this.Runs = new List <CompressedRun>();
            int numRuns = EndianUtilities.ToInt32BigEndian(buffer, offset + 200);

            for (int i = 0; i < numRuns; ++i)
            {
                this.Runs.Add(EndianUtilities.ToStruct <CompressedRun>(buffer, offset + 204 + (i * 40)));
            }

            return(0);
        }
示例#30
0
        public int ReadFrom(byte[] buffer, int offset)
        {
            DescriptorTag = EndianUtilities.ToStruct<DescriptorTag>(buffer, offset);
            RecordingTime = UdfUtilities.ParseTimestamp(buffer, offset + 16);
            InterchangeLevel = EndianUtilities.ToUInt16LittleEndian(buffer, offset + 28);
            MaximumInterchangeLevel = EndianUtilities.ToUInt16LittleEndian(buffer, offset + 30);
            CharacterSetList = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 32);
            MaximumCharacterSetList = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 36);
            FileSetNumber = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 40);
            FileSetDescriptorNumber = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 44);
            LogicalVolumeIdentifierCharset = EndianUtilities.ToStruct<CharacterSetSpecification>(buffer, offset + 48);
            LogicalVolumeIdentifier = UdfUtilities.ReadDString(buffer, offset + 112, 128);
            FileSetCharset = EndianUtilities.ToStruct<CharacterSetSpecification>(buffer, offset + 240);
            FileSetIdentifier = UdfUtilities.ReadDString(buffer, offset + 304, 32);
            CopyrightFileIdentifier = UdfUtilities.ReadDString(buffer, offset + 336, 32);
            AbstractFileIdentifier = UdfUtilities.ReadDString(buffer, offset + 368, 32);
            RootDirectoryIcb = EndianUtilities.ToStruct<LongAllocationDescriptor>(buffer, offset + 400);
            DomainIdentifier = EndianUtilities.ToStruct<DomainEntityIdentifier>(buffer, offset + 416);
            NextExtent = EndianUtilities.ToStruct<LongAllocationDescriptor>(buffer, offset + 448);
            SystemStreamDirectoryIcb = EndianUtilities.ToStruct<LongAllocationDescriptor>(buffer, offset + 464);

            return 512;
        }