Example #1
0
        public TreeNode getDirectoryChildren(HFSPlusCatalogFolder folderRecord, catalogFile cf, extentsOverflowFile eof)
        {
            TreeNode returnDir = new TreeNode();

            // get every file and directory inside the current one
            returnDir = cf.getDirectoryAndChildren(folderRecord, eof, this.partitionNo);

            foreach (TreeNode child in returnDir.Nodes)
            {
                if (child.Tag is HFSPlusCatalogFolder)
                {
                    TreeNode tn      = cf.getDirectoryAndChildren((HFSPlusCatalogFolder)child.Tag, eof, this.partitionNo);
                    int      counter = 0;
                    foreach (TreeNode childNode in tn.Nodes)
                    {
                        if (childNode.Tag is HFSPlusCatalogFolder)
                        {
                            counter++;
                        }
                    }

                    if (counter > 0)
                    {
                        // if there are children, add a placeholder
                        child.Nodes.Add("");
                    }
                }
            }

            return(returnDir);
        }
Example #2
0
        private void afterSelectNode(object sender, TreeViewEventArgs e)
        {
            dc.listViewRows.Clear();
            listView2.Items.Clear();

            if (e.Node.Tag is HFSPlusCatalogFolder)
            {
                HFSPlusCatalogFolder details = (HFSPlusCatalogFolder)e.Node.Tag;
                propertyGrid1.SelectedObject = details;
            }
            else if (e.Node.Tag is HFSPlus.volumeHeader)
            {
                HFSPlus.volumeHeader details = (HFSPlus.volumeHeader)e.Node.Tag;
                propertyGrid1.SelectedObject = details;
            }
            else if (e.Node.Tag is absImageStream.imageProperties)
            {
                absImageStream.imageProperties details = (absImageStream.imageProperties)e.Node.Tag;
                propertyGrid1.SelectedObject = details;
            }

            dc.generateListViewContent(e.Node);

            foreach (ListViewItem row in dc.listViewRows)
            {
                listView2.Items.Add(row);
            }

            hashFileToolStripMenuItem.Enabled = true;
        }
        private void getRecords()
        {
            foreach (rawKeyAndRecord record in this.rawRecords)
            {
                short thisRecordType = dataOperations.convToLE(BitConverter.ToInt16(record.recordData, 0));

                catalogFile.HFSPlusCatalogKey key = new catalogFile.HFSPlusCatalogKey();

                key.keyLength = record.keyLength;
                key.parentID  = dataOperations.convToLE(BitConverter.ToUInt32(record.keyData, 0));
                byte[] nodeName = new byte[record.keyLength - 6];
                Array.Copy(record.keyData, 6, nodeName, 0, record.keyLength - 6);
                key.nodeName = nodeName;

                byte[] rawData = record.recordData;

                switch ((recordType)thisRecordType)
                {
                case recordType.kHFSFileRecord:
                    HFSPlusCatalogFile fileRecord = new HFSPlusCatalogFile(ref rawData);

                    fileRecord.key = key;

                    fileRecords.Add(fileRecord);

                    break;

                case recordType.kHFSFolderRecord:
                    HFSPlusCatalogFolder folderRecord = new HFSPlusCatalogFolder(ref rawData);

                    folderRecord.key = key;

                    folderRecords.Add(folderRecord);

                    break;

                case recordType.kHFSFileThreadRecord:
                case recordType.kHFSFolderThreadRecord:
                    HFSPlusCatalogThread threadRecord = new HFSPlusCatalogThread();

                    threadRecord.key  = key;
                    threadRecord.type = (recordType)thisRecordType;

                    threadRecord.reserved = dataOperations.convToLE(BitConverter.ToInt16(rawData, 2));
                    threadRecord.parentID = dataOperations.convToLE(BitConverter.ToUInt32(rawData, 4));

                    threadRecord.nodeName = new byte[rawData.Length - 8];

                    Array.Copy(rawData, 8, threadRecord.nodeName, 0, rawData.Length - 8);

                    threadRecords.Add(threadRecord);

                    break;
                }
            }
        }
Example #4
0
        public TreeNode getFullDirectoryList(HFSPlusCatalogFolder folderRecord, catalogFile cf, extentsOverflowFile eof, attributesFile af)
        {
            TreeNode returnDir = new TreeNode();

            returnDir.Tag  = folderRecord;
            returnDir.Text = System.Text.Encoding.BigEndianUnicode.GetString(folderRecord.key.nodeName);

            returnDir = getDirectoryChildren(folderRecord, cf, eof, af);

            returnDir = buildDirectoryTree(returnDir, cf, eof, af);

            return(returnDir);
        }
Example #5
0
        public TreeNode getDirectoryChildren(HFSPlusCatalogFolder folderRecord, catalogFile cf, extentsOverflowFile eof, attributesFile af)
        {
            TreeNode returnDir = new TreeNode();

            // get every file and directory inside the current one
            returnDir = cf.getDirectoryAndChildren(folderRecord, eof, this.partitionNo);

            foreach (TreeNode child in returnDir.Nodes)
            {
                // check if there are any alternate data streams for the files
                if (child.Tag is HFSPlusCatalogFile)
                {
                    HFSPlusCatalogFile data = (HFSPlusCatalogFile)child.Tag;

                    attributesFile.HFSPlusAttrKey attrKey = new attributesFile.HFSPlusAttrKey();

                    attrKey.fileID     = data.fileID;
                    attrKey.startBlock = 0;
                    attributesLeafNode.attributesDataForFile allAttributes = af.getAttrFileDataWithKey(attrKey);

                    foreach (attributesLeafNode.HFSPlusAttrForkData fork in allAttributes.forks)
                    {
                        TreeNode attribute = new TreeNode();

                        attributesLeafNode.HFSPlusAttrForkData tag = fork;
                        tag.partitionAssoc = folderRecord.partitionAssoc;

                        attribute.Text = child.Text + " > " + System.Text.Encoding.BigEndianUnicode.GetString(fork.key.attrName);
                        attribute.Tag  = tag;

                        returnDir.Nodes.Add(attribute);
                    }
                    foreach (attributesLeafNode.HFSPlusAttrInlineData inline in allAttributes.inline)
                    {
                        TreeNode attribute = new TreeNode();

                        attributesLeafNode.HFSPlusAttrInlineData tag = inline;
                        tag.partitionAssoc = folderRecord.partitionAssoc;

                        attribute.Text = child.Text + " > " + System.Text.Encoding.BigEndianUnicode.GetString(inline.key.attrName);
                        attribute.Tag  = tag;
                        returnDir.Nodes.Add(attribute);
                    }
                }
            }

            return(returnDir);
        }
        public TreeNode getSubDirectories(TreeNode tn)
        {
            TreeNode  result = tn;
            GPTScheme gpts   = new GPTScheme(i);

            if (tn.Tag is HFSPlusCatalogFolder)
            {
                HFSPlusCatalogFolder folder = (HFSPlusCatalogFolder)tn.Tag;
                HFSPlus             hfsp    = new HFSPlus(i, gpts.getValidTable()[folder.partitionAssoc]);
                volumeStream        vs      = new volumeStream(hfsp);
                extentsOverflowFile eof     = new extentsOverflowFile(new HFSPlusFile(hfsp.volHead.extentsFile, forkStream.forkType.data), vs);
                catalogFile         cf      = new catalogFile(new HFSPlusFile(hfsp.volHead.catalogFile, forkStream.forkType.data), vs);

                result     = hfsp.getDirectoryChildren(folder, cf, eof);
                result.Tag = tn.Tag;
            }
            return(result);
        }
Example #7
0
        public TreeNode getRootDirectoryContents(catalogFile cf, extentsOverflowFile eof, attributesFile af)
        {
            HFSPlusCatalogFolder rootFolderParentRecord = new HFSPlusCatalogFolder();

            rootFolderParentRecord.folderID       = 1;
            rootFolderParentRecord.partitionAssoc = this.partitionNo;

            TreeNode rootDirParent = getDirectoryChildren(rootFolderParentRecord, cf, eof);

            HFSPlusCatalogFolder rootFolderRecord = new HFSPlusCatalogFolder();

            rootFolderRecord      = (HFSPlusCatalogFolder)rootDirParent.Nodes[0].Tag;
            rootFolderRecord.path = this.volHead.path;

            TreeNode rootDir = getDirectoryChildren(rootFolderRecord, cf, eof, af);

            addMetaFilesToTree(ref rootDir);

            foreach (TreeNode child in rootDir.Nodes)
            {
                if (child.Tag is HFSPlusCatalogFolder)
                {
                    TreeNode tn      = getDirectoryChildren((HFSPlusCatalogFolder)child.Tag, cf, eof);
                    int      counter = 0;
                    foreach (TreeNode childNode in tn.Nodes)
                    {
                        if (childNode.Tag is HFSPlusCatalogFolder)
                        {
                            counter++;
                        }
                    }

                    if (counter > 0)
                    {
                        // if there are children, add a placeholder
                        child.Nodes.Add("");
                    }
                }
            }

            return(rootDir);
        }
        private TreeNode getHFSPTree(HFSPlus hfsp, HFSPlusCatalogFolder folderID)
        {
            TreeNode     tn      = new TreeNode();
            volumeStream hfsp_vs = new volumeStream(hfsp);

            HFSPlusFile rawCatalog         = new HFSPlusFile(hfsp.volHead.catalogFile, forkStream.forkType.data);
            HFSPlusFile rawAttributes      = new HFSPlusFile(hfsp.volHead.attributesFile, forkStream.forkType.data);
            HFSPlusFile rawExtentsOverflow = new HFSPlusFile(hfsp.volHead.extentsFile, forkStream.forkType.data);
            // need to get all attributes files

            HFSPlusCatalogFolder folderRecord = folderID;

            catalogFile         catalog    = new catalogFile(rawCatalog, hfsp_vs);
            attributesFile      attributes = new attributesFile(rawAttributes, hfsp_vs);
            extentsOverflowFile eof        = new extentsOverflowFile(rawExtentsOverflow, hfsp_vs);

            displayTree = hfsp.getFullDirectoryList(folderRecord, catalog, eof, attributes);

            tn = displayTree;

            return(tn);
        }
Example #9
0
        private TreeNode buildDirectoryTree(TreeNode parent, catalogFile cf, extentsOverflowFile eof, attributesFile af)
        {
            TreeNode replaceParent = new TreeNode();

            replaceParent.Tag  = parent.Tag;
            replaceParent.Text = parent.Text;

            foreach (TreeNode childItem in parent.Nodes)
            {
                if (childItem.Tag is HFSPlusCatalogFolder)
                {
                    HFSPlusCatalogFolder childDirectoryRecord = (HFSPlusCatalogFolder)childItem.Tag;

                    TreeNode contents = getDirectoryChildren(childDirectoryRecord, cf, eof, af);

                    contents = buildDirectoryTree(contents, cf, eof, af);

                    replaceParent.Nodes.Add(contents);
                    foldercount++;
                }
                else if (childItem.Tag is HFSPlusCatalogFile)
                {
                    replaceParent.Nodes.Add(childItem);
                    filecount++;
                }
                else if (childItem.Tag is attributesLeafNode.HFSPlusAttrInlineData)
                {
                    replaceParent.Nodes.Add(childItem);
                }
                else if (childItem.Tag is attributesLeafNode.HFSPlusAttrForkData)
                {
                    replaceParent.Nodes.Add(childItem);
                }
            }

            return(replaceParent);
        }
Example #10
0
        public TreeNode getDirectoryChildren(HFSPlusCatalogFolder folderRecord, catalogFile cf, extentsOverflowFile eof, attributesFile af)
        {
            TreeNode returnDir = new TreeNode();

            // get every file and directory inside the current one
            returnDir = cf.getDirectoryAndChildren(folderRecord, eof, this.partitionNo);

            foreach (TreeNode child in returnDir.Nodes)
            {
                // check if there are any alternate data streams for the files
                if (child.Tag is HFSPlusCatalogFile)
                {
                    HFSPlusCatalogFile data = (HFSPlusCatalogFile)child.Tag;

                    attributesFile.HFSPlusAttrKey attrKey = new attributesFile.HFSPlusAttrKey();

                    attrKey.fileID = data.fileID;
                    attrKey.startBlock = 0;
                    attributesLeafNode.attributesDataForFile allAttributes = af.getAttrFileDataWithKey(attrKey);

                    foreach (attributesLeafNode.HFSPlusAttrForkData fork in allAttributes.forks)
                    {
                        TreeNode attribute = new TreeNode();

                        attributesLeafNode.HFSPlusAttrForkData tag = fork;
                        tag.partitionAssoc = folderRecord.partitionAssoc;

                        attribute.Text = child.Text + " > " + System.Text.Encoding.BigEndianUnicode.GetString(fork.key.attrName);
                        attribute.Tag = tag;

                        returnDir.Nodes.Add(attribute);
                    }
                    foreach (attributesLeafNode.HFSPlusAttrInlineData inline in allAttributes.inline)
                    {
                        TreeNode attribute = new TreeNode();

                        attributesLeafNode.HFSPlusAttrInlineData tag = inline;
                        tag.partitionAssoc = folderRecord.partitionAssoc;

                        attribute.Text = child.Text + " > " + System.Text.Encoding.BigEndianUnicode.GetString(inline.key.attrName);
                        attribute.Tag = tag;
                        returnDir.Nodes.Add(attribute);
                    }
                }
            }

            return returnDir;
        }
Example #11
0
        public TreeNode getDirectoryAndChildren(HFSPlusCatalogFolder folderRecord, extentsOverflowFile eof, int partitionAssoc)
        {
            TreeNode returnDir = new TreeNode();
            if (folderRecord.key.nodeName != null)
            {
                returnDir.Text = System.Text.Encoding.BigEndianUnicode.GetString(folderRecord.key.nodeName);
                returnDir.Text = returnDir.Text.Replace('\0', ' ');
            }
            folderRecord.partitionAssoc = partitionAssoc;
            returnDir.Tag = folderRecord;

            HFSPlusCatalogKey matchParentDir = new HFSPlusCatalogKey();

            // find the first HFSPlusFileRecord for whom the current directory is the parent
            matchParentDir.parentID = folderRecord.folderID;
            if(folderRecord.key.nodeName != null) matchParentDir.nodeName = folderRecord.key.nodeName;
            uint readThisNode = getLeafNodeContainingRecord(matchParentDir);
            bool nextLeaf = true;

            // records with the same parent are stored sequentially in the file,
            // but may continue over into the next node
            while (nextLeaf)
            {
                byte[] leafData = new byte[this.nodeSize];

                fs.Seek(readThisNode * this.nodeSize, SeekOrigin.Begin);
                fs.Read(leafData, 0, this.nodeSize);

                catalogLeafNode currentLeaf = new catalogLeafNode(ref leafData);

                foreach (HFSPlusCatalogFolder folder in currentLeaf.folderRecords)
                {
                    if (folder.key.parentID == folderRecord.folderID)
                    {
                        TreeNode childDir = new TreeNode();
                        if (folder.key.nodeName != null)
                        {
                            childDir.Text = System.Text.Encoding.BigEndianUnicode.GetString(folder.key.nodeName);
                            childDir.Text = childDir.Text.Replace('\0', ' ');
                        }

                        // set the treenode data for the child item
                        folder.path = folderRecord.path + "\\" + childDir.Text;
                        folder.partitionAssoc = partitionAssoc;

                        childDir.Tag = folder;
                        returnDir.Nodes.Add(childDir);
                    }
                }

                foreach (HFSPlusCatalogFile file in currentLeaf.fileRecords)
                {
                    if (file.key.parentID == folderRecord.folderID)
                    {
                        TreeNode childFile = new TreeNode();

                        HFSPlusCatalogFile eachFile = file;
                        eachFile.partitionAssoc = partitionAssoc;

                        // HFSPlusFile should be able to get all of a file's blocks as part of the constructor
                        HFSPlusFile blockFinder = new HFSPlusFile(eachFile, eof);

                        //add the discovered extents back into the return object
                        //eachFile.dataFork.forkDataValues.extents.Clear();
                        //eachFile.resourceFork.forkDataValues.extents.Clear();
                        //foreach (hfsPlusForkData.HFSPlusExtentRecord extent in blockFinder.fileContent.dataExtents)
                        //{
                        //    eachFile.dataFork.forkDataValues.extents.Add(extent);
                        //}
                        //foreach (hfsPlusForkData.HFSPlusExtentRecord extent in blockFinder.fileContent.resourceExtents)
                        //{
                        //    eachFile.resourceFork.forkDataValues.extents.Add(extent);
                        //}

                        // if it can't... cry?
                        if (!(blockFinder.allDataBlocksKnown && blockFinder.allResourceBlocksKnown))
                        {
                            throw new Exception("Disk_Reader.HFSPlusFile class failed to get all blocks.");
                        }

                        // a handful of volume metadata files have highly specialised permissions
                        HFSPlusCatalogFolder tag = (HFSPlusCatalogFolder)returnDir.Tag;
                        if (tag.key.parentID == 2)
                        {
                            if (returnDir.Text == "    HFS+ Private Data")
                            {
                                HFSPlusCatalogRecord.HFSPlusPermissions resetPermissions = new HFSPlusCatalogRecord.HFSPlusPermissions();
                                resetPermissions = eachFile.permissions;
                                resetPermissions.type = HFSPlusCatalogRecord.HFSPlusPermissions.specialType.iNodeNum;

                                eachFile.permissions = resetPermissions;
                            }
                        }
                        else if (eachFile.userInfo.fileType == 0x686C6E6B && eachFile.userInfo.fileCreator == 0x6866732B)
                        {
                            HFSPlusCatalogRecord.HFSPlusPermissions resetPermissions = new HFSPlusCatalogRecord.HFSPlusPermissions();
                            resetPermissions = eachFile.permissions;
                            resetPermissions.type = HFSPlusCatalogRecord.HFSPlusPermissions.specialType.linkCount;

                            eachFile.permissions = resetPermissions;
                        }
                        else if (eachFile.permissions.fileMode.blockSpecial || eachFile.permissions.fileMode.charSpecial)
                        {
                            HFSPlusCatalogRecord.HFSPlusPermissions resetPermissions = new HFSPlusCatalogRecord.HFSPlusPermissions();
                            resetPermissions = eachFile.permissions;
                            resetPermissions.type = HFSPlusCatalogRecord.HFSPlusPermissions.specialType.rawDevice;

                            eachFile.permissions = resetPermissions;
                        }
                        else
                        {
                            HFSPlusCatalogRecord.HFSPlusPermissions resetPermissions = new HFSPlusCatalogRecord.HFSPlusPermissions();
                            resetPermissions = eachFile.permissions;
                            resetPermissions.type = HFSPlusCatalogRecord.HFSPlusPermissions.specialType.reserved;

                            eachFile.permissions = resetPermissions;
                        }

                        childFile.Text = System.Text.Encoding.BigEndianUnicode.GetString(file.key.nodeName);
                        if (folderRecord.key.nodeName != null)
                        {
                            childFile.Text = System.Text.Encoding.BigEndianUnicode.GetString(file.key.nodeName);
                            childFile.Text = childFile.Text.Replace('\0', ' ');
                        }

                        // set the treenode data for the child item
                        eachFile.path = folderRecord.path + "\\" + childFile.Text;

                        childFile.Tag = eachFile;

                        returnDir.Nodes.Add(childFile);
                    }
                }

                bool lastRecordMatchesKey =
                    matchParentDir.parentID == dataOperations.convToLE(
                        BitConverter.ToUInt32(
                            currentLeaf.rawRecords[currentLeaf.rawRecords.Count() - 1].keyData, 0));

                // if the last record in the current leaf is within the parent directory,
                // the records may continue in the next leaf, so skip to the node in flink
                // in the next instance of the loop
                if (returnDir.Nodes.Count < folderRecord.valence)
                {
                    readThisNode = currentLeaf.BTNodeDescriptor.fLink;
                }
                else
                {
                    nextLeaf = false;
                }
            }

            return returnDir;
        }
Example #12
0
        public TreeNode getRootDirectoryContents(catalogFile cf, extentsOverflowFile eof, attributesFile af)
        {
            HFSPlusCatalogFolder rootFolderParentRecord = new HFSPlusCatalogFolder();

            rootFolderParentRecord.folderID = 1;
            rootFolderParentRecord.partitionAssoc = this.partitionNo;

            TreeNode rootDirParent = getDirectoryChildren(rootFolderParentRecord, cf, eof);

            HFSPlusCatalogFolder rootFolderRecord = new HFSPlusCatalogFolder();
            rootFolderRecord = (HFSPlusCatalogFolder)rootDirParent.Nodes[0].Tag;
            rootFolderRecord.path = this.volHead.path;

            TreeNode rootDir = getDirectoryChildren(rootFolderRecord, cf, eof, af);

            addMetaFilesToTree(ref rootDir);

            foreach (TreeNode child in rootDir.Nodes)
            {
                if (child.Tag is HFSPlusCatalogFolder)
                {
                    TreeNode tn = getDirectoryChildren((HFSPlusCatalogFolder)child.Tag, cf, eof);
                    int counter = 0;
                    foreach(TreeNode childNode in tn.Nodes)
                    {
                        if (childNode.Tag is HFSPlusCatalogFolder)
                        {
                            counter++;
                        }
                    }

                    if (counter > 0)
                    {
                        // if there are children, add a placeholder
                        child.Nodes.Add("");
                    }
                }
            }

            return rootDir;
        }
Example #13
0
        public TreeNode getFullDirectoryList(HFSPlusCatalogFolder folderRecord, catalogFile cf, extentsOverflowFile eof, attributesFile af)
        {
            TreeNode returnDir = new TreeNode();
            returnDir.Tag = folderRecord;
            returnDir.Text = System.Text.Encoding.BigEndianUnicode.GetString(folderRecord.key.nodeName);

            returnDir = getDirectoryChildren(folderRecord, cf, eof, af);

            returnDir = buildDirectoryTree(returnDir, cf, eof, af);

            return returnDir;
        }
        private TreeNode getVolumeTree(GPTScheme.entry partition, GPTScheme.partitionType type, HFSPlusCatalogFolder folderID)
        {
            TreeNode tn = new TreeNode();
            try
            {
                if (type == GPTScheme.partitionType.HFSPlus)
                {
                    HFSPlus hfsp = new HFSPlus(this.i, partition);

                    tn = getHFSPTree(hfsp, folderID);
                }
            }
            catch (OutOfMemoryException)
            {
                return tn;
                throw new OutOfMemoryException( "The list view has been truncated as there are too many items to fit in system memory.\r\n\r\n"
                                            +   "Try viewing a sub directory instead.");
            }

            return tn;
        }
        private TreeNode getHFSPTree(HFSPlus hfsp, HFSPlusCatalogFolder folderID)
        {
            TreeNode tn = new TreeNode();
            volumeStream hfsp_vs = new volumeStream(hfsp);

            HFSPlusFile rawCatalog = new HFSPlusFile(hfsp.volHead.catalogFile, forkStream.forkType.data);
            HFSPlusFile rawAttributes = new HFSPlusFile(hfsp.volHead.attributesFile, forkStream.forkType.data);
            HFSPlusFile rawExtentsOverflow = new HFSPlusFile(hfsp.volHead.extentsFile, forkStream.forkType.data);
            // need to get all attributes files

            HFSPlusCatalogFolder folderRecord = folderID;

            catalogFile catalog = new catalogFile(rawCatalog, hfsp_vs);
            attributesFile attributes = new attributesFile(rawAttributes, hfsp_vs);
            extentsOverflowFile eof = new extentsOverflowFile(rawExtentsOverflow, hfsp_vs);
            displayTree = hfsp.getFullDirectoryList(folderRecord, catalog, eof, attributes);

            tn = displayTree;

            return tn;
        }
        public void generateListViewContent(TreeNode startDirectory)
        {
            TreeNode partitionTN = new TreeNode();

            if (startDirectory.Tag is absImageStream.imageProperties)
            {
                switch (i.scheme)
                {
                case absImageStream.schemeType.GPT:
                    GPTScheme ps = new GPTScheme(i);

                    foreach (GPTScheme.entry partition in ps.getValidTable())
                    {
                        GPTScheme.partitionType type = ps.findPartitionType(partition);

                        partitionTN      = getVolumeTree(partition, type);
                        partitionTN.Text = partition.name;
                    }
                    break;

                default:
                    break;
                }
            }
            else if (startDirectory.Tag is HFSPlusCatalogFolder)
            {
                HFSPlusCatalogFolder tag = (HFSPlusCatalogFolder)startDirectory.Tag;
                switch (i.scheme)
                {
                case absImageStream.schemeType.GPT:
                    GPTScheme ps = new GPTScheme(i);

                    // if used, the following line causes the program to display only the direct children of the selected directory
                    partitionTN = getSubDirectories(startDirectory);

                    // if used, the following line will cause the program to display the entire contents of a directory tree branch recursively
                    // partitionTN = getVolumeTree(ps.getValidTable()[tag.partitionAssoc], GPTScheme.partitionType.HFSPlus, tag);
                    partitionTN.Text = startDirectory.Text;

                    break;

                default:
                    break;
                }
            }
            else if (startDirectory.Tag is HFSPlus.volumeHeader)
            {
                HFSPlus.volumeHeader tag = (HFSPlus.volumeHeader)startDirectory.Tag;
                switch (i.scheme)
                {
                case absImageStream.schemeType.GPT:
                    GPTScheme ps = new GPTScheme(i);


                    partitionTN      = getVolumeTree(ps.getValidTable()[tag.partitionNo], GPTScheme.partitionType.HFSPlus);
                    partitionTN.Text = startDirectory.Text;

                    break;

                default:
                    break;
                }
            }

            if (startDirectory.Tag != null)
            {
                addRowsToList(partitionTN);
            }
        }
Example #17
0
        private void onRowClick(object sender, ListViewItemSelectionChangedEventArgs e)
        {
            comboBox1.Visible = false;
            if (e.Item.Tag is HFSPlusCatalogFolder)
            {
                HFSPlusCatalogFolder details = (HFSPlusCatalogFolder)e.Item.Tag;
                propertyGrid1.SelectedObject = details;
                resetHex();
            }
            else if (e.Item.Tag is HFSPlusCatalogFile)
            {
                resetHex();
                HFSPlusCatalogFile details = (HFSPlusCatalogFile)e.Item.Tag;
                propertyGrid1.SelectedObject = details;
                if (details.dataFork.forkDataValues.logicalSize > 0 || details.resourceFork.forkDataValues.logicalSize > 0)
                {
                    comboBox1.Visible = true;
                }
                if (details.dataFork.forkDataValues.logicalSize > 0)
                {
                    dc.showForkData(details, 0, forkStream.forkType.data);
                    dc.selectedFile = details;

                    hexText.Text         = dc.contentDisplay;
                    showTotalBlocks.Text = details.dataFork.forkDataValues.totalBlocks.ToString();

                    if (details.dataFork.forkDataValues.totalBlocks > 1)
                    {
                        nextBlock.Enabled   = true;
                        goToBlock.Enabled   = true;
                        blockNumBox.Enabled = true;
                    }

                    dc.fileDataBlock       = 1;
                    showCurrentBlock.Text  = dc.fileDataBlock.ToString();
                    comboBox1.SelectedItem = dc.forkview[0];
                }
                else if (details.resourceFork.forkDataValues.logicalSize > 0)
                {
                    dc.showForkData(details, 0, forkStream.forkType.resource);
                    dc.selectedFile = details;

                    hexText.Text         = dc.contentDisplay;
                    showTotalBlocks.Text = details.resourceFork.forkDataValues.totalBlocks.ToString();

                    if (details.resourceFork.forkDataValues.totalBlocks > 1)
                    {
                        nextBlock.Enabled   = true;
                        goToBlock.Enabled   = true;
                        blockNumBox.Enabled = true;
                    }

                    dc.fileDataBlock       = 1;
                    showCurrentBlock.Text  = dc.fileDataBlock.ToString();
                    comboBox1.SelectedItem = dc.forkview[1];
                }
                else
                {
                    hexText.Text          = "";
                    showCurrentBlock.Text = "";
                }
                comboBox1.DataSource = dc.forkview;
            }
            else if (e.Item.Tag is HFSPlus.volumeHeader)
            {
                HFSPlus.volumeHeader details = (HFSPlus.volumeHeader)e.Item.Tag;
                propertyGrid1.SelectedObject = details;
                resetHex();
            }
            else if (e.Item.Tag is attributesLeafNode.HFSPlusAttrInlineData)
            {
                resetHex();

                attributesLeafNode.HFSPlusAttrInlineData attrDetails = (attributesLeafNode.HFSPlusAttrInlineData)e.Item.Tag;
                propertyGrid1.SelectedObject = attrDetails;

                if (attrDetails.otherData.Length > 0)
                {
                    dc.showInlineAttrData((attributesLeafNode.HFSPlusAttrInlineData)e.Item.Tag);
                    hexText.Text = dc.contentDisplay;
                }
            }
        }
        private ListViewItem getNodeRowContents(TreeNode theTree)
        {
            ListViewItem row = new ListViewItem(theTree.Text);

            if (theTree.Tag != null)
            {
                string tagType = theTree.Tag.GetType().ToString();

                switch (tagType)
                {
                case "Disk_Reader.HFSPlusCatalogFolder":
                    HFSPlusCatalogFolder folderTag = (HFSPlusCatalogFolder)theTree.Tag;
                    row.Tag = folderTag;


                    row.SubItems.Add(folderTag.folderID.ToString());
                    if (folderTag.createDate > HFSPlus.FromHFSPlusTime(0))
                    {
                        row.SubItems.Add(folderTag.createDate.ToString());
                    }
                    else
                    {
                        row.SubItems.Add("");
                    }

                    if (folderTag.contentModDate > HFSPlus.FromHFSPlusTime(0))
                    {
                        row.SubItems.Add(folderTag.contentModDate.ToString());
                    }
                    else
                    {
                        row.SubItems.Add("");
                    }

                    if (folderTag.attributeModDate > HFSPlus.FromHFSPlusTime(0))
                    {
                        row.SubItems.Add(folderTag.attributeModDate.ToString());
                    }
                    else
                    {
                        row.SubItems.Add("");
                    }

                    if (folderTag.backupDate > HFSPlus.FromHFSPlusTime(0))
                    {
                        row.SubItems.Add(folderTag.backupDate.ToString());
                    }
                    else
                    {
                        row.SubItems.Add("");
                    }

                    if (folderTag.accessDate > HFSPlus.FromHFSPlusTime(0))
                    {
                        row.SubItems.Add(folderTag.accessDate.ToString());
                    }
                    else
                    {
                        row.SubItems.Add("");
                    }

                    string folderPermissions = "";
                    if (folderTag.permissions.fileMode.owner.read)
                    {
                        folderPermissions += "r";
                    }
                    else
                    {
                        folderPermissions += "-";
                    }
                    if (folderTag.permissions.fileMode.owner.write)
                    {
                        folderPermissions += "w";
                    }
                    else
                    {
                        folderPermissions += "-";
                    }
                    if (folderTag.permissions.fileMode.owner.execute)
                    {
                        folderPermissions += "x";
                    }
                    else
                    {
                        folderPermissions += "-";
                    }
                    folderPermissions += "/";
                    if (folderTag.permissions.fileMode.group.read)
                    {
                        folderPermissions += "r";
                    }
                    else
                    {
                        folderPermissions += "-";
                    }
                    if (folderTag.permissions.fileMode.group.write)
                    {
                        folderPermissions += "w";
                    }
                    else
                    {
                        folderPermissions += "-";
                    }
                    if (folderTag.permissions.fileMode.group.execute)
                    {
                        folderPermissions += "x";
                    }
                    else
                    {
                        folderPermissions += "-";
                    }
                    folderPermissions += "/";
                    if (folderTag.permissions.fileMode.other.read)
                    {
                        folderPermissions += "r";
                    }
                    else
                    {
                        folderPermissions += "-";
                    }
                    if (folderTag.permissions.fileMode.other.write)
                    {
                        folderPermissions += "w";
                    }
                    else
                    {
                        folderPermissions += "-";
                    }
                    if (folderTag.permissions.fileMode.other.execute)
                    {
                        folderPermissions += "x";
                    }
                    else
                    {
                        folderPermissions += "-";
                    }
                    row.SubItems.Add(folderPermissions);
                    row.SubItems.Add("");               // data fork size
                    row.SubItems.Add("");               // resource fork size
                    row.SubItems.Add("");               // data start sector LBA
                    row.SubItems.Add("");               // rsrc start sector
                    row.SubItems.Add("");               // data fragments count
                    row.SubItems.Add("");               // rsrc fragments count
                    row.SubItems.Add("");               // data fork MD5
                    row.SubItems.Add("");               // data fork SHA1
                    row.SubItems.Add("");               // resource fork MD5
                    row.SubItems.Add("");               // resource fork SHA1
                    row.SubItems.Add("");               // is deleted
                    row.SubItems.Add(folderTag.path);

                    break;

                case "Disk_Reader.HFSPlus+volumeHeader":
                    HFSPlus.volumeHeader headerTag = (HFSPlus.volumeHeader)theTree.Tag;
                    row.Tag = headerTag;

                    row.SubItems.Add("");               // CNID
                    if (headerTag.createDate > HFSPlus.FromHFSPlusTime(0))
                    {
                        row.SubItems.Add(headerTag.createDate.ToString());
                    }
                    else
                    {
                        row.SubItems.Add("");
                    }

                    if (headerTag.modifyDate > HFSPlus.FromHFSPlusTime(0))
                    {
                        row.SubItems.Add(headerTag.modifyDate.ToString());
                    }
                    else
                    {
                        row.SubItems.Add("");
                    }
                    row.SubItems.Add("");               // attribute mod date

                    if (headerTag.backupDate > HFSPlus.FromHFSPlusTime(0))
                    {
                        row.SubItems.Add(headerTag.backupDate.ToString());
                    }
                    else
                    {
                        row.SubItems.Add("");
                    }
                    row.SubItems.Add("");               // access date
                    row.SubItems.Add("");               // permissions
                    row.SubItems.Add("");               // data fork size
                    row.SubItems.Add("");               // resource fork size
                    row.SubItems.Add("");               // data start sector LBA
                    row.SubItems.Add("");               // rsrc start sector
                    row.SubItems.Add("");               // data fragments count
                    row.SubItems.Add("");               // rsrc fragments count
                    row.SubItems.Add("");               // data fork MD5
                    row.SubItems.Add("");               // data fork SHA1
                    row.SubItems.Add("");               // resource fork MD5
                    row.SubItems.Add("");               // resource fork SHA1
                    row.SubItems.Add("");               // is deleted
                    row.SubItems.Add(headerTag.path);

                    break;

                case "Disk_Reader.HFSPlusCatalogFile":

                    HFSPlusCatalogFile fileTag = (HFSPlusCatalogFile)theTree.Tag;
                    row.Tag = fileTag;

                    row.SubItems.Add(fileTag.fileID.ToString());
                    if (fileTag.createDate > HFSPlus.FromHFSPlusTime(0))                                    // creation date
                    {
                        row.SubItems.Add(fileTag.createDate.ToString());
                    }
                    else
                    {
                        row.SubItems.Add("");
                    }

                    if (fileTag.contentModDate > HFSPlus.FromHFSPlusTime(0))                                // content mod date
                    {
                        row.SubItems.Add(fileTag.contentModDate.ToString());
                    }
                    else
                    {
                        row.SubItems.Add("");
                    }

                    if (fileTag.attributeModDate > HFSPlus.FromHFSPlusTime(0))                              // attributes mod date
                    {
                        row.SubItems.Add(fileTag.attributeModDate.ToString());
                    }
                    else
                    {
                        row.SubItems.Add("");
                    }

                    if (fileTag.backupDate > HFSPlus.FromHFSPlusTime(0))                                    // backup date
                    {
                        row.SubItems.Add(fileTag.backupDate.ToString());
                    }
                    else
                    {
                        row.SubItems.Add("");
                    }

                    if (fileTag.accessDate > HFSPlus.FromHFSPlusTime(0))                                    // access date - Mac OS X does not use this - only POSIX implementations
                    {
                        row.SubItems.Add(fileTag.accessDate.ToString());
                    }
                    else
                    {
                        row.SubItems.Add("");
                    }

                    string filePermissions = "";
                    if (fileTag.permissions.fileMode.owner.read)
                    {
                        filePermissions += "r";
                    }
                    else
                    {
                        filePermissions += "-";
                    }
                    if (fileTag.permissions.fileMode.owner.write)
                    {
                        filePermissions += "w";
                    }
                    else
                    {
                        filePermissions += "-";
                    }
                    if (fileTag.permissions.fileMode.owner.execute)
                    {
                        filePermissions += "x";
                    }
                    else
                    {
                        filePermissions += "-";
                    }
                    filePermissions += "/";
                    if (fileTag.permissions.fileMode.group.read)
                    {
                        filePermissions += "r";
                    }
                    else
                    {
                        filePermissions += "-";
                    }
                    if (fileTag.permissions.fileMode.group.write)
                    {
                        filePermissions += "w";
                    }
                    else
                    {
                        filePermissions += "-";
                    }
                    if (fileTag.permissions.fileMode.group.execute)
                    {
                        filePermissions += "x";
                    }
                    else
                    {
                        filePermissions += "-";
                    }
                    filePermissions += "/";
                    if (fileTag.permissions.fileMode.other.read)
                    {
                        filePermissions += "r";
                    }
                    else
                    {
                        filePermissions += "-";
                    }
                    if (fileTag.permissions.fileMode.other.write)
                    {
                        filePermissions += "w";
                    }
                    else
                    {
                        filePermissions += "-";
                    }
                    if (fileTag.permissions.fileMode.other.execute)
                    {
                        filePermissions += "x";
                    }
                    else
                    {
                        filePermissions += "-";
                    }
                    row.SubItems.Add(filePermissions);                                                      // file permissions
                    row.SubItems.Add(fileTag.dataFork.forkDataValues.logicalSize.ToString());               // data fork size
                    int rsrccount = 0;
                    if (fileTag.resourceFork != null)
                    {
                        row.SubItems.Add(fileTag.resourceFork.forkDataValues.logicalSize.ToString());

                        // only try to iterate through resource fork extents if a resource fork exists
                        // (volume metadata files do not have a resource fork)
                        for (int i = 0; i < fileTag.dataFork.forkDataValues.extents.Count(); i++)
                        {
                            if (fileTag.resourceFork.forkDataValues.extents[i].blockCount > 0)
                            {
                                rsrccount++;
                            }
                        }
                    }
                    else
                    {
                        row.SubItems.Add("0");                                                              // resource fork size
                    }

                    if (fileTag.dataFork.forkDataValues.extents[0].startBlock > 0)
                    {
                        row.SubItems.Add(fileTag.dataFork.forkDataValues.extents[0].startBlock.ToString());
                    }
                    else
                    {
                        row.SubItems.Add("");                                                               // start sector LBA
                    }
                    if (fileTag.resourceFork != null)
                    {
                        if (fileTag.resourceFork.forkDataValues.extents[0].startBlock > 0)
                        {
                            row.SubItems.Add(fileTag.resourceFork.forkDataValues.extents[0].startBlock.ToString());
                        }
                        else
                        {
                            row.SubItems.Add("");                                                           // resource start sector
                        }
                    }
                    int datacount = 0;
                    for (int i = 0; i < fileTag.dataFork.forkDataValues.extents.Count(); i++)
                    {
                        if (fileTag.dataFork.forkDataValues.extents[i].blockCount > 0)
                        {
                            datacount++;
                        }
                    }
                    row.SubItems.Add(datacount.ToString());                                                 // data fragments count

                    row.SubItems.Add(rsrccount.ToString());                                                 // resource fragments count
                    row.SubItems.Add("");                                                                   // data fork MD5
                    row.SubItems.Add("");                                                                   // data fork SHA1
                    row.SubItems.Add("");                                                                   // resource fork MD5
                    row.SubItems.Add("");                                                                   // resource fork SHA1
                    row.SubItems.Add("");                                                                   // is deleted
                    row.SubItems.Add(fileTag.path);

                    break;

                case "Disk_Reader.attributesLeafNode+HFSPlusAttrForkData":
                    break;

                case "Disk_Reader.attributesLeafNode+HFSPlusAttrInlineData":
                    attributesLeafNode.HFSPlusAttrInlineData inlineTag = (attributesLeafNode.HFSPlusAttrInlineData)theTree.Tag;
                    row.Tag = inlineTag;


                    row.SubItems.Add(inlineTag.key.fileID.ToString());
                    row.SubItems.Add("");                                    // creation date
                    row.SubItems.Add("");                                    // content mod date
                    row.SubItems.Add("");                                    // attributes mod date
                    row.SubItems.Add("");                                    // backup date
                    row.SubItems.Add("");                                    // access date
                    row.SubItems.Add("");                                    // file permissions
                    row.SubItems.Add(inlineTag.otherData.Length.ToString()); // data fork size
                    row.SubItems.Add("");                                    // resource fork size
                    row.SubItems.Add("");                                    // data start sector LBA
                    row.SubItems.Add("");                                    // rsrc start sector LBA
                    row.SubItems.Add("");                                    // data fragments count
                    row.SubItems.Add("");                                    // rsrc fragments count
                    row.SubItems.Add("");                                    // data fork MD5
                    row.SubItems.Add("");                                    // data fork SHA1
                    row.SubItems.Add("");                                    // resource fork MD5
                    row.SubItems.Add("");                                    // resource fork SHA1
                    row.SubItems.Add("");                                    // is deleted
                    row.SubItems.Add("");                                    // path
                    break;
                }
            }
            return(row);
        }
Example #19
0
        public TreeNode getDirectoryAndChildren(HFSPlusCatalogFolder folderRecord, extentsOverflowFile eof, int partitionAssoc)
        {
            TreeNode returnDir = new TreeNode();

            if (folderRecord.key.nodeName != null)
            {
                returnDir.Text = System.Text.Encoding.BigEndianUnicode.GetString(folderRecord.key.nodeName);
                returnDir.Text = returnDir.Text.Replace('\0', ' ');
            }
            folderRecord.partitionAssoc = partitionAssoc;
            returnDir.Tag = folderRecord;

            HFSPlusCatalogKey matchParentDir = new HFSPlusCatalogKey();

            // find the first HFSPlusFileRecord for whom the current directory is the parent
            matchParentDir.parentID = folderRecord.folderID;
            if (folderRecord.key.nodeName != null)
            {
                matchParentDir.nodeName = folderRecord.key.nodeName;
            }
            uint readThisNode = getLeafNodeContainingRecord(matchParentDir);
            bool nextLeaf     = true;

            // records with the same parent are stored sequentially in the file,
            // but may continue over into the next node
            while (nextLeaf)
            {
                byte[] leafData = new byte[this.nodeSize];

                fs.Seek(readThisNode * this.nodeSize, SeekOrigin.Begin);
                fs.Read(leafData, 0, this.nodeSize);

                catalogLeafNode currentLeaf = new catalogLeafNode(ref leafData);

                foreach (HFSPlusCatalogFolder folder in currentLeaf.folderRecords)
                {
                    if (folder.key.parentID == folderRecord.folderID)
                    {
                        TreeNode childDir = new TreeNode();
                        if (folder.key.nodeName != null)
                        {
                            childDir.Text = System.Text.Encoding.BigEndianUnicode.GetString(folder.key.nodeName);
                            childDir.Text = childDir.Text.Replace('\0', ' ');
                        }

                        // set the treenode data for the child item
                        folder.path           = folderRecord.path + "\\" + childDir.Text;
                        folder.partitionAssoc = partitionAssoc;

                        childDir.Tag = folder;
                        returnDir.Nodes.Add(childDir);
                    }
                }

                foreach (HFSPlusCatalogFile file in currentLeaf.fileRecords)
                {
                    if (file.key.parentID == folderRecord.folderID)
                    {
                        TreeNode childFile = new TreeNode();

                        HFSPlusCatalogFile eachFile = file;
                        eachFile.partitionAssoc = partitionAssoc;

                        // HFSPlusFile should be able to get all of a file's blocks as part of the constructor
                        HFSPlusFile blockFinder = new HFSPlusFile(eachFile, eof);

                        //add the discovered extents back into the return object
                        //eachFile.dataFork.forkDataValues.extents.Clear();
                        //eachFile.resourceFork.forkDataValues.extents.Clear();
                        //foreach (hfsPlusForkData.HFSPlusExtentRecord extent in blockFinder.fileContent.dataExtents)
                        //{
                        //    eachFile.dataFork.forkDataValues.extents.Add(extent);
                        //}
                        //foreach (hfsPlusForkData.HFSPlusExtentRecord extent in blockFinder.fileContent.resourceExtents)
                        //{
                        //    eachFile.resourceFork.forkDataValues.extents.Add(extent);
                        //}

                        // if it can't... cry?
                        if (!(blockFinder.allDataBlocksKnown && blockFinder.allResourceBlocksKnown))
                        {
                            throw new Exception("Disk_Reader.HFSPlusFile class failed to get all blocks.");
                        }

                        // a handful of volume metadata files have highly specialised permissions
                        HFSPlusCatalogFolder tag = (HFSPlusCatalogFolder)returnDir.Tag;
                        if (tag.key.parentID == 2)
                        {
                            if (returnDir.Text == "    HFS+ Private Data")
                            {
                                HFSPlusCatalogRecord.HFSPlusPermissions resetPermissions = new HFSPlusCatalogRecord.HFSPlusPermissions();
                                resetPermissions      = eachFile.permissions;
                                resetPermissions.type = HFSPlusCatalogRecord.HFSPlusPermissions.specialType.iNodeNum;

                                eachFile.permissions = resetPermissions;
                            }
                        }
                        else if (eachFile.userInfo.fileType == 0x686C6E6B && eachFile.userInfo.fileCreator == 0x6866732B)
                        {
                            HFSPlusCatalogRecord.HFSPlusPermissions resetPermissions = new HFSPlusCatalogRecord.HFSPlusPermissions();
                            resetPermissions      = eachFile.permissions;
                            resetPermissions.type = HFSPlusCatalogRecord.HFSPlusPermissions.specialType.linkCount;

                            eachFile.permissions = resetPermissions;
                        }
                        else if (eachFile.permissions.fileMode.blockSpecial || eachFile.permissions.fileMode.charSpecial)
                        {
                            HFSPlusCatalogRecord.HFSPlusPermissions resetPermissions = new HFSPlusCatalogRecord.HFSPlusPermissions();
                            resetPermissions      = eachFile.permissions;
                            resetPermissions.type = HFSPlusCatalogRecord.HFSPlusPermissions.specialType.rawDevice;

                            eachFile.permissions = resetPermissions;
                        }
                        else
                        {
                            HFSPlusCatalogRecord.HFSPlusPermissions resetPermissions = new HFSPlusCatalogRecord.HFSPlusPermissions();
                            resetPermissions      = eachFile.permissions;
                            resetPermissions.type = HFSPlusCatalogRecord.HFSPlusPermissions.specialType.reserved;

                            eachFile.permissions = resetPermissions;
                        }

                        childFile.Text = System.Text.Encoding.BigEndianUnicode.GetString(file.key.nodeName);
                        if (folderRecord.key.nodeName != null)
                        {
                            childFile.Text = System.Text.Encoding.BigEndianUnicode.GetString(file.key.nodeName);
                            childFile.Text = childFile.Text.Replace('\0', ' ');
                        }

                        // set the treenode data for the child item
                        eachFile.path = folderRecord.path + "\\" + childFile.Text;

                        childFile.Tag = eachFile;

                        returnDir.Nodes.Add(childFile);
                    }
                }

                bool lastRecordMatchesKey =
                    matchParentDir.parentID == dataOperations.convToLE(
                        BitConverter.ToUInt32(
                            currentLeaf.rawRecords[currentLeaf.rawRecords.Count() - 1].keyData, 0));

                // if the last record in the current leaf is within the parent directory,
                // the records may continue in the next leaf, so skip to the node in flink
                // in the next instance of the loop
                if (returnDir.Nodes.Count < folderRecord.valence)
                {
                    readThisNode = currentLeaf.BTNodeDescriptor.fLink;
                }
                else
                {
                    nextLeaf = false;
                }
            }

            return(returnDir);
        }
Example #20
0
        public TreeNode getDirectoryChildren(HFSPlusCatalogFolder folderRecord, catalogFile cf, extentsOverflowFile eof)
        {
            TreeNode returnDir = new TreeNode();

            // get every file and directory inside the current one
            returnDir = cf.getDirectoryAndChildren(folderRecord, eof, this.partitionNo);

            foreach (TreeNode child in returnDir.Nodes)
            {
                if (child.Tag is HFSPlusCatalogFolder)
                {
                    TreeNode tn = cf.getDirectoryAndChildren((HFSPlusCatalogFolder)child.Tag, eof, this.partitionNo);
                    int counter = 0;
                    foreach (TreeNode childNode in tn.Nodes)
                    {
                        if (childNode.Tag is HFSPlusCatalogFolder)
                        {
                            counter++;
                        }
                    }

                    if (counter > 0)
                    {
                        // if there are children, add a placeholder
                        child.Nodes.Add("");
                    }
                }
            }

            return returnDir;
        }
        private TreeNode getVolumeTree(GPTScheme.entry partition, GPTScheme.partitionType type, HFSPlusCatalogFolder folderID)
        {
            TreeNode tn = new TreeNode();

            try
            {
                if (type == GPTScheme.partitionType.HFSPlus)
                {
                    HFSPlus hfsp = new HFSPlus(this.i, partition);

                    tn = getHFSPTree(hfsp, folderID);
                }
            }
            catch (OutOfMemoryException)
            {
                return(tn);

                throw new OutOfMemoryException("The list view has been truncated as there are too many items to fit in system memory.\r\n\r\n"
                                               + "Try viewing a sub directory instead.");
            }

            return(tn);
        }
        private void getRecords()
        {
            foreach(rawKeyAndRecord record in this.rawRecords)
            {
                short thisRecordType = dataOperations.convToLE(BitConverter.ToInt16(record.recordData, 0));

                catalogFile.HFSPlusCatalogKey key = new catalogFile.HFSPlusCatalogKey();

                key.keyLength = record.keyLength;
                key.parentID = dataOperations.convToLE(BitConverter.ToUInt32(record.keyData, 0));
                byte[] nodeName = new byte[record.keyLength - 6];
                Array.Copy(record.keyData, 6, nodeName, 0, record.keyLength - 6);
                key.nodeName = nodeName;

                byte[] rawData = record.recordData;

                switch ((recordType)thisRecordType)
                {
                    case recordType.kHFSFileRecord:
                        HFSPlusCatalogFile fileRecord = new HFSPlusCatalogFile(ref rawData);

                        fileRecord.key = key;

                        fileRecords.Add(fileRecord);

                        break;
                    case recordType.kHFSFolderRecord:
                        HFSPlusCatalogFolder folderRecord = new HFSPlusCatalogFolder(ref rawData);

                        folderRecord.key = key;

                        folderRecords.Add(folderRecord);

                        break;
                    case recordType.kHFSFileThreadRecord: case recordType.kHFSFolderThreadRecord:
                        HFSPlusCatalogThread threadRecord = new HFSPlusCatalogThread();

                        threadRecord.key = key;
                        threadRecord.type = (recordType)thisRecordType;

                        threadRecord.reserved = dataOperations.convToLE(BitConverter.ToInt16(rawData, 2));
                        threadRecord.parentID = dataOperations.convToLE(BitConverter.ToUInt32(rawData, 4));

                        threadRecord.nodeName = new byte[rawData.Length - 8];

                        Array.Copy(rawData, 8, threadRecord.nodeName, 0, rawData.Length - 8);

                        threadRecords.Add(threadRecord);

                        break;
                }
            }
        }