Пример #1
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;
        }
Пример #2
0
        public void hashAll()
        {
            TreeNode replaceFileTree = new TreeNode();

            setFileTreeFromImage(i);

            foreach (TreeNode child in fileTree.Nodes)
            {
                if (child.Tag is HFSPlus.volumeHeader)
                {
                    HFSPlus.volumeHeader vh = (HFSPlus.volumeHeader)child.Tag;

                    GPTScheme    gpts = new GPTScheme(i);
                    HFSPlus      hfsp = new HFSPlus(i, gpts.entries[vh.partitionNo]);
                    volumeStream vs   = new volumeStream(hfsp);

                    replaceFileTree.Nodes.Add(iterateHashChildren(child, vs));
                }
                else
                {
                    replaceFileTree.Nodes.Add(child);
                }
            }

            replaceFileTree.Tag = displayTree.Tag;

            this.fileTree = replaceFileTree;
        }
Пример #3
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;
                }
            }
        }
Пример #4
0
        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);
            }
        }
Пример #5
0
        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);
        }