コード例 #1
0
        public HFSPlusCatalogFile(ref byte[] rawData) : base(ref rawData)
        {
            ushort flags = dataOperations.convToLE(BitConverter.ToUInt16(rawData, 2));

            this.fileLockedBit    = (fileFlags.kHFSFileLockedBit & (fileFlags)flags) == fileFlags.kHFSFileLockedBit;
            this.fileLockedMask   = (fileFlags.kHFSFileLockedMask & (fileFlags)flags) == fileFlags.kHFSFileLockedMask;
            this.threadExistsBit  = (fileFlags.kHFSThreadExistsBit & (fileFlags)flags) == fileFlags.kHFSThreadExistsBit;
            this.threadExistsMask = (fileFlags.kHFSThreadExistsMask & (fileFlags)flags) == fileFlags.kHFSThreadExistsMask;
            this.reserved1        = dataOperations.convToLE(BitConverter.ToUInt32(rawData, 4));
            this.fileID           = dataOperations.convToLE(BitConverter.ToUInt32(rawData, 8));
            this.createDate       = HFSPlus.FromHFSPlusTime(dataOperations.convToLE(BitConverter.ToUInt32(rawData, 12)));
            this.contentModDate   = HFSPlus.FromHFSPlusTime(dataOperations.convToLE(BitConverter.ToUInt32(rawData, 16)));
            this.attributeModDate = HFSPlus.FromHFSPlusTime(dataOperations.convToLE(BitConverter.ToUInt32(rawData, 20)));
            this.accessDate       = HFSPlus.FromHFSPlusTime(dataOperations.convToLE(BitConverter.ToUInt32(rawData, 24)));
            this.backupDate       = HFSPlus.FromHFSPlusTime(dataOperations.convToLE(BitConverter.ToUInt32(rawData, 28)));

            byte[] filePermissions = new byte[16];
            Array.Copy(rawData, 32, filePermissions, 0, 16);
            byte[] fileUserInfo = new byte[16];
            Array.Copy(rawData, 48, fileUserInfo, 0, 16);
            byte[] fileFinderInfo = new byte[16];
            Array.Copy(rawData, 64, fileFinderInfo, 0, 16);

            this.userInfo    = HFSPlusFinderInfo.getFileUserInfo(ref fileUserInfo);
            this.finderInfo  = HFSPlusFinderInfo.getFileFinderInfo(ref fileFinderInfo);
            this.permissions = getHFSPlusPermissions(ref filePermissions);

            this.textEncoding = dataOperations.convToLE(BitConverter.ToUInt32(rawData, 80));
            this.reserved2    = dataOperations.convToLE(BitConverter.ToUInt32(rawData, 84));

            this.dataFork     = new hfsPlusForkData(ref rawData, 88);
            this.resourceFork = new hfsPlusForkData(ref rawData, 168);
        }
コード例 #2
0
        public void addDataExtentsToFork(hfsPlusForkData.HFSPlusExtentRecord anExtent)
        {
            fileContent.dataExtents.Add(anExtent);

            getKnownDataBlocks();
            this.allDataBlocksKnown = knownDataBlocks == totalDataBlocks;
        }
コード例 #3
0
        public HFSPlusFile(hfsPlusForkData forkEntry, forkStream.forkType type)
        {
            fileContent.dataExtents = new List<hfsPlusForkData.HFSPlusExtentRecord>();
            fileContent.resourceExtents = new List<hfsPlusForkData.HFSPlusExtentRecord>();

            switch (type)
            {
                case forkStream.forkType.data:
                    addDataFork(forkEntry);
                    break;
                case forkStream.forkType.resource:
                    addResourceFork(forkEntry);
                    break;
            }
        }
コード例 #4
0
        public HFSPlusFile(hfsPlusForkData forkEntry, forkStream.forkType type)
        {
            fileContent.dataExtents     = new List <hfsPlusForkData.HFSPlusExtentRecord>();
            fileContent.resourceExtents = new List <hfsPlusForkData.HFSPlusExtentRecord>();

            switch (type)
            {
            case forkStream.forkType.data:
                addDataFork(forkEntry);
                break;

            case forkStream.forkType.resource:
                addResourceFork(forkEntry);
                break;
            }
        }
コード例 #5
0
        public void addResourceFork(hfsPlusForkData resourceFork)
        {
            int i = 0;

            while (resourceFork.forkDataValues.extents[i].blockCount > 0 && i < 8)
            {
                this.fileContent.resourceExtents.Add(resourceFork.forkDataValues.extents[i]);
                i++;
            }

            this.rsrcClumpSize       = resourceFork.forkDataValues.clumpSize;
            this.rsrcLogicalSize     = resourceFork.forkDataValues.logicalSize;
            this.totalResourceBlocks = resourceFork.forkDataValues.totalBlocks;

            getKnownResourceBlocks();
            this.allResourceBlocksKnown = knownResourceBlocks == totalResourceBlocks;
        }
コード例 #6
0
        public void addDataFork(hfsPlusForkData dataFork)
        {
            int i = 0;

            while (i < 8 && dataFork.forkDataValues.extents[i].blockCount > 0)
            {
                this.fileContent.dataExtents.Add(dataFork.forkDataValues.extents[i]);
                i++;
            }

            this.dataClumpSize   = dataFork.forkDataValues.clumpSize;
            this.dataLogicalSize = dataFork.forkDataValues.logicalSize;
            this.totalDataBlocks = dataFork.forkDataValues.totalBlocks;

            getKnownDataBlocks();
            this.allDataBlocksKnown = knownDataBlocks == totalDataBlocks;
        }
コード例 #7
0
        protected volumeHeader getVolumeHeader(byte[] rawHeader)
        {
            volumeHeader vh = new volumeHeader();

            vh.signature  = BitConverter.ToUInt16(rawHeader, 0);
            vh.version    = BitConverter.ToUInt16(rawHeader, 2);
            vh.attributes = BitConverter.ToUInt32(rawHeader, 4);
            volAttributes volAttr = new volAttributes();

            byte[] attrBytes = new byte[4];
            Array.Copy(rawHeader, 4, attrBytes, 0, 4);

            volAttr.kHFSVolumeHardwareLockBit     = ((vh.attributes & 0x80000000) == 0x80000000);
            volAttr.kHFSVolumeUnmountedBit        = ((vh.attributes & 0x00010000) == 0x00010000);
            volAttr.kHFSVolumeSparedBlocksBit     = ((vh.attributes & 0x00020000) == 0x00020000);
            volAttr.kHFSVolumeNoCacheRequiredBit  = ((vh.attributes & 0x00040000) == 0x00040000);
            volAttr.kHFSBootVolumeInconsistentBit = ((vh.attributes & 0x0008000) == 0x00080000);
            volAttr.kHFSCatalogNodeIDsReusedBit   = ((vh.attributes & 0x00100000) == 0x00100000);
            volAttr.kHFSVolumeJournaledBit        = ((vh.attributes & 0x00200000) == 0x00200000);
            volAttr.kHFSVolumeSoftwareLockBit     = ((vh.attributes & 0x00800000) == 0x00800000);

            vh.volAttr = volAttr;

            vh.lastMountedVersion = BitConverter.ToUInt32(rawHeader, 8);
            vh.journalInfoBlock   = dataOperations.convToLE(BitConverter.ToUInt32(rawHeader, 12));

            vh.createDate  = FromHFSPlusTime(dataOperations.convToLE(BitConverter.ToUInt32(rawHeader, 16)));
            vh.modifyDate  = FromHFSPlusTime(dataOperations.convToLE(BitConverter.ToUInt32(rawHeader, 20)));
            vh.backupDate  = FromHFSPlusTime(dataOperations.convToLE(BitConverter.ToUInt32(rawHeader, 24)));
            vh.checkedDate = FromHFSPlusTime(dataOperations.convToLE(BitConverter.ToUInt32(rawHeader, 28)));

            vh.fileCount   = dataOperations.convToLE(BitConverter.ToUInt32(rawHeader, 32));
            vh.folderCount = dataOperations.convToLE(BitConverter.ToUInt32(rawHeader, 36));

            vh.blockSize   = dataOperations.convToLE(BitConverter.ToUInt32(rawHeader, 40));
            this.blockSize = vh.blockSize;

            vh.totalBlocks = dataOperations.convToLE(BitConverter.ToUInt32(rawHeader, 44));
            vh.freeBlocks  = dataOperations.convToLE(BitConverter.ToUInt32(rawHeader, 48));

            vh.nextAllocation  = dataOperations.convToLE(BitConverter.ToUInt32(rawHeader, 52));
            vh.rsrcClumpSize   = dataOperations.convToLE(BitConverter.ToUInt32(rawHeader, 56));
            vh.dataClumpSize   = dataOperations.convToLE(BitConverter.ToUInt32(rawHeader, 60));
            vh.nextCatalogID   = dataOperations.convToLE(BitConverter.ToUInt32(rawHeader, 64));
            vh.writeCount      = dataOperations.convToLE(BitConverter.ToUInt32(rawHeader, 68));
            vh.encodingsBitmap = BitConverter.ToUInt64(rawHeader, 72);

            vh.finderInfo = new UInt32[8];

            for (int i = 0; i < 8; i++)
            {
                vh.finderInfo[i] = BitConverter.ToUInt32(rawHeader, 80 + (4 * i));
            }

            hfsPlusForkData volAllocationFile = new hfsPlusForkData(ref rawHeader, 112);
            hfsPlusForkData volExtentsFile    = new hfsPlusForkData(ref rawHeader, 192);
            hfsPlusForkData volCatalogFile    = new hfsPlusForkData(ref rawHeader, 272);
            hfsPlusForkData volAttributesFile = new hfsPlusForkData(ref rawHeader, 352);
            hfsPlusForkData volStartupFile    = new hfsPlusForkData(ref rawHeader, 432);

            vh.allocationFile = volAllocationFile;
            vh.extentsFile    = volExtentsFile;
            vh.catalogFile    = volCatalogFile;
            vh.attributesFile = volAttributesFile;
            vh.startupFile    = volStartupFile;

            vh.partitionNo = this.partitionNo;
            vh.path        = this.path;

            return(vh);
        }
コード例 #8
0
        public void addResourceFork(hfsPlusForkData resourceFork)
        {
            int i = 0;
            while (resourceFork.forkDataValues.extents[i].blockCount > 0 && i < 8)
            {
                this.fileContent.resourceExtents.Add(resourceFork.forkDataValues.extents[i]);
                i++;
            }

            this.rsrcClumpSize = resourceFork.forkDataValues.clumpSize;
            this.rsrcLogicalSize=resourceFork.forkDataValues.logicalSize;
            this.totalResourceBlocks = resourceFork.forkDataValues.totalBlocks;

            getKnownResourceBlocks();
            this.allResourceBlocksKnown = knownResourceBlocks == totalResourceBlocks;
        }
コード例 #9
0
        public void addResourceExtentsToFork(hfsPlusForkData.HFSPlusExtentRecord[] extents)
        {
            foreach (hfsPlusForkData.HFSPlusExtentRecord anExtent in extents)
            {
                fileContent.resourceExtents.Add(anExtent);
            }

            getKnownResourceBlocks();
            this.allResourceBlocksKnown = knownResourceBlocks == totalDataBlocks;
        }
コード例 #10
0
        public void addDataFork(hfsPlusForkData dataFork)
        {
            int i = 0;
            while (i < 8 && dataFork.forkDataValues.extents[i].blockCount > 0)
            {
                this.fileContent.dataExtents.Add(dataFork.forkDataValues.extents[i]);
                i++;
            }

            this.dataClumpSize = dataFork.forkDataValues.clumpSize;
            this.dataLogicalSize = dataFork.forkDataValues.logicalSize;
            this.totalDataBlocks = dataFork.forkDataValues.totalBlocks;

            getKnownDataBlocks();
            this.allDataBlocksKnown = knownDataBlocks == totalDataBlocks;
        }
コード例 #11
0
ファイル: HFSPlus.cs プロジェクト: scherma/hfs-plus-reader
        protected volumeHeader getVolumeHeader(byte[] rawHeader)
        {
            volumeHeader vh = new volumeHeader();

            vh.signature = BitConverter.ToUInt16(rawHeader, 0);
            vh.version = BitConverter.ToUInt16(rawHeader, 2);
            vh.attributes = BitConverter.ToUInt32(rawHeader, 4);
            volAttributes volAttr = new volAttributes();
            byte[] attrBytes = new byte[4];
            Array.Copy(rawHeader, 4, attrBytes, 0, 4);

            volAttr.kHFSVolumeHardwareLockBit = ((vh.attributes & 0x80000000) == 0x80000000);
            volAttr.kHFSVolumeUnmountedBit = ((vh.attributes & 0x00010000) == 0x00010000);
            volAttr.kHFSVolumeSparedBlocksBit = ((vh.attributes & 0x00020000) == 0x00020000);
            volAttr.kHFSVolumeNoCacheRequiredBit = ((vh.attributes & 0x00040000) == 0x00040000);
            volAttr.kHFSBootVolumeInconsistentBit = ((vh.attributes & 0x0008000) == 0x00080000);
            volAttr.kHFSCatalogNodeIDsReusedBit = ((vh.attributes & 0x00100000) == 0x00100000);
            volAttr.kHFSVolumeJournaledBit = ((vh.attributes & 0x00200000) == 0x00200000);
            volAttr.kHFSVolumeSoftwareLockBit = ((vh.attributes & 0x00800000) == 0x00800000);

            vh.volAttr = volAttr;

            vh.lastMountedVersion = BitConverter.ToUInt32(rawHeader, 8);
            vh.journalInfoBlock = dataOperations.convToLE(BitConverter.ToUInt32(rawHeader, 12));

            vh.createDate = FromHFSPlusTime(dataOperations.convToLE(BitConverter.ToUInt32(rawHeader, 16)));
            vh.modifyDate = FromHFSPlusTime(dataOperations.convToLE(BitConverter.ToUInt32(rawHeader, 20)));
            vh.backupDate = FromHFSPlusTime(dataOperations.convToLE(BitConverter.ToUInt32(rawHeader, 24)));
            vh.checkedDate = FromHFSPlusTime(dataOperations.convToLE(BitConverter.ToUInt32(rawHeader, 28)));

            vh.fileCount = dataOperations.convToLE(BitConverter.ToUInt32(rawHeader, 32));
            vh.folderCount = dataOperations.convToLE(BitConverter.ToUInt32(rawHeader, 36));

            vh.blockSize = dataOperations.convToLE(BitConverter.ToUInt32(rawHeader, 40));
            this.blockSize = vh.blockSize;

            vh.totalBlocks = dataOperations.convToLE(BitConverter.ToUInt32(rawHeader, 44));
            vh.freeBlocks = dataOperations.convToLE(BitConverter.ToUInt32(rawHeader, 48));

            vh.nextAllocation = dataOperations.convToLE(BitConverter.ToUInt32(rawHeader, 52));
            vh.rsrcClumpSize = dataOperations.convToLE(BitConverter.ToUInt32(rawHeader, 56));
            vh.dataClumpSize = dataOperations.convToLE(BitConverter.ToUInt32(rawHeader, 60));
            vh.nextCatalogID = dataOperations.convToLE(BitConverter.ToUInt32(rawHeader, 64));
            vh.writeCount = dataOperations.convToLE(BitConverter.ToUInt32(rawHeader, 68));
            vh.encodingsBitmap = BitConverter.ToUInt64(rawHeader, 72);

            vh.finderInfo = new UInt32[8];

            for (int i = 0; i < 8; i++)
            {
                vh.finderInfo[i]= BitConverter.ToUInt32(rawHeader, 80+(4*i));
            }

            hfsPlusForkData volAllocationFile = new hfsPlusForkData(ref rawHeader, 112);
            hfsPlusForkData volExtentsFile = new hfsPlusForkData(ref rawHeader, 192);
            hfsPlusForkData volCatalogFile = new hfsPlusForkData(ref rawHeader, 272);
            hfsPlusForkData volAttributesFile = new hfsPlusForkData(ref rawHeader, 352);
            hfsPlusForkData volStartupFile = new hfsPlusForkData(ref rawHeader, 432);

            vh.allocationFile = volAllocationFile;
            vh.extentsFile = volExtentsFile;
            vh.catalogFile = volCatalogFile;
            vh.attributesFile = volAttributesFile;
            vh.startupFile = volStartupFile;

            vh.partitionNo = this.partitionNo;
            vh.path = this.path;

            return vh;
        }