示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="volumeName"></param>
        /// <param name="fileName"></param>
        /// <returns></returns>
        private static byte[] GetHeaderBytes(string volumeName, string fileName)
        {
            VolumeHeader volHeader = VolumeHeader.Get(volumeName);

            ExtentDescriptor extent = null;

            switch (fileName)
            {
            case "Catalog":
                extent = volHeader.CatalogFile.Extents[0];
                break;

            case "Attributes":
                extent = volHeader.AttributesFile.Extents[0];
                break;

            case "ExtentsOverflow":
                extent = volHeader.ExtentsOverflowFile.Extents[0];
                break;
            }

            // Read the smallest possible amount of bytes
            byte[] firstSectorBytes = Helper.readDrive(volumeName, extent.StartBlock * volHeader.BlockSize, 0x200);
            // Parse HeaderRecord to determine NodeSize
            HeaderRecord headerRecord = HeaderRecord.Get(firstSectorBytes, 0x0E, volumeName, fileName);

            // Read the full Header Node
            return(Helper.readDrive(volumeName, extent.StartBlock * volHeader.BlockSize, headerRecord.NodeSize));
        }
示例#2
0
        private Node(byte[] bytes, string volumeName, string fileName, uint nodeNumber)
        {
            VolumeName = volumeName;
            FileName   = fileName;
            NodeNumber = nodeNumber;

            NodeDescriptor = NodeDescriptor.Get(bytes, 0x00, volumeName, fileName);

            List <Record> recordList = new List <Record>();

            switch (NodeDescriptor.Kind)
            {
            case NodeDescriptor.NODE_KIND.kBTHeaderNode:
                recordList.Add(HeaderRecord.Get(bytes, Helper.SwapEndianness(BitConverter.ToUInt16(bytes, bytes.Length - 0x02)), volumeName, fileName));
                recordList.Add(UserDataRecord.Get(bytes, Helper.SwapEndianness(BitConverter.ToUInt16(bytes, bytes.Length - 0x04))));
                //recordList.Add(Helper.GetSubArray(bytes, Helper.SwapEndianness(BitConverter.ToUInt16(bytes, bytes.Length - 0x06)), ));
                break;

            case NodeDescriptor.NODE_KIND.kBTIndexNode:
                for (int i = 1; i <= NodeDescriptor.NumRecords; i++)
                {
                    ushort recordOffset = Helper.SwapEndianness(BitConverter.ToUInt16(bytes, bytes.Length - (0x02 * i)));
                    recordList.Add(PointerRecord.Get(bytes, recordOffset, volumeName, fileName));
                }
                break;

            case NodeDescriptor.NODE_KIND.kBTLeafNode:
                for (int i = 1; i <= NodeDescriptor.NumRecords; i++)
                {
                    ushort recordOffset = Helper.SwapEndianness(BitConverter.ToUInt16(bytes, bytes.Length - (0x02 * i)));

                    switch (fileName)
                    {
                    case "Catalog":
                        switch (DataRecord.GetRecordType(bytes, recordOffset))
                        {
                        case DataRecord.RECORD_TYPE.kHFSPlusFolderRecord:
                            recordList.Add(CatalogFolderRecord.Get(bytes, recordOffset, volumeName, fileName));
                            break;

                        case DataRecord.RECORD_TYPE.kHFSPlusFileRecord:
                            recordList.Add(CatalogFileRecord.Get(bytes, recordOffset, volumeName, fileName));
                            break;

                        case DataRecord.RECORD_TYPE.kHFSPlusFolderThreadRecord:
                            recordList.Add(CatalogThread.Get(bytes, recordOffset, volumeName, fileName));
                            break;

                        case DataRecord.RECORD_TYPE.kHFSPlusFileThreadRecord:
                            recordList.Add(CatalogThread.Get(bytes, recordOffset, volumeName, fileName));
                            break;
                        }
                        break;

                    case "ExtentsOverflow":
                        recordList.Add(ExtentsOverflowRecord.Get(bytes, recordOffset, volumeName, fileName));
                        break;
                    }
                }
                break;

            case NodeDescriptor.NODE_KIND.kBTMapNode:
                break;
            }

            Records = recordList.ToArray();
        }