Пример #1
0
        public HFSPlus(absImageStream fileSet, GPTScheme.entry partition) : base(fileSet, partition)
        {
            this.blockSize = 4096; // default block size

            this.partitionNo = partition.partitionNo;
            this.path        = fileSet.bf.F.Name + "\\" + partition.name;


            byte[] rawHeader = new byte[512];
            ais.Seek(this.volumeStart + 1024, SeekOrigin.Begin);
            ais.Read(rawHeader, 0, 512);
            if (rawHeader[0] == 0x48 && rawHeader[1] == 0x2B)
            {
                volHead = getVolumeHeader(rawHeader);
            }

            long volEnd = this.volumeStart + (partition.partLength * ais.sectorSize) + ais.sectorSize;

            this.totalSize = partition.partLength * ais.sectorSize;
            ais.Seek(volEnd - 1024, SeekOrigin.Begin);
            ais.Read(rawHeader, 0, 512);
            if (rawHeader[0] == 0x48 && rawHeader[1] == 0x2B)
            {
                backupVolHead = getVolumeHeader(rawHeader);
            }
        }
Пример #2
0
        private void setFileTreeFromImage(absImageStream i)
        {
            TreeNode partitionTN = new TreeNode();

            fileTree = null;
            fileTree = new TreeNode();

            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;
                    fileTree.Nodes.Add(partitionTN);
                }
                break;

            default:
                break;
            }
        }
Пример #3
0
        public void getImageContents(string imagepath)
        {
            i = accessImage(imagepath);

            setFileTreeFromImage(i);
            fileTree.Text = i.bf.F.Name;

            absImageStream.imageProperties tag = new absImageStream.imageProperties();
            tag.imagepath     = i.bf.F.FullName;
            tag.componentSize = i.componentSize;
            tag.sectorSize    = i.sectorSize;

            i.Position = 0;

            tag.scheme    = i.scheme;
            tag.totalSize = i.Length;

            if (tag.scheme == absImageStream.schemeType.GPT)
            {
                tag.entries = new GPTScheme(i);
            }

            fileTree.Tag = tag;

            displayTree = stripFilesFromTree(fileTree);
        }
Пример #4
0
        public HFSPlus(absImageStream fileSet, GPTScheme.entry partition)
            : base(fileSet, partition)
        {
            this.blockSize = 4096; // default block size

            this.partitionNo = partition.partitionNo;
            this.path = fileSet.bf.F.Name + "\\" + partition.name;

            byte[] rawHeader = new byte[512];
            ais.Seek(this.volumeStart + 1024, SeekOrigin.Begin);
            ais.Read(rawHeader, 0, 512);
            if (rawHeader[0] == 0x48 && rawHeader[1] == 0x2B)
            {
                volHead = getVolumeHeader(rawHeader);
            }

            long volEnd = this.volumeStart + (partition.partLength * ais.sectorSize) + ais.sectorSize;
            this.totalSize = partition.partLength * ais.sectorSize;
            ais.Seek(volEnd - 1024, SeekOrigin.Begin);
            ais.Read(rawHeader, 0, 512);
            if (rawHeader[0] == 0x48 && rawHeader[1] == 0x2B)
            {
                backupVolHead = getVolumeHeader(rawHeader);
            }
        }
Пример #5
0
        public absVolume(absImageStream fileSet, GPTScheme.entry partition)
        {
            GPTScheme.entry partEntry = partition;
            ais = fileSet;

            blockSize    = 512;
            volumeStart  = (long)partition.partStartLBA * ais.sectorSize;
            volumeLength = (long)partition.partLength * ais.sectorSize;
        }
Пример #6
0
        public absVolume(absImageStream fileSet, GPTScheme.entry partition)
        {
            GPTScheme.entry partEntry = partition;
            ais = fileSet;

            blockSize = 512;
            volumeStart = (long)partition.partStartLBA * ais.sectorSize;
            volumeLength = (long)partition.partLength * ais.sectorSize;
        }
Пример #7
0
 public GPTScheme(absImageStream fileset) : base(fileset)
 {
     entries               = new List <GPTScheme.entry>();
     backupEntries         = new List <GPTScheme.entry>();
     headerMatchesCRC      = false;
     tableMatchesCRC       = false;
     headerFound           = false;
     backupFound           = false;
     backupMatchesCRC      = false;
     backupTableMatchesCRC = false;
     protectiveMBRExists   = false;
     header       = new GPTHeader();
     backupHeader = new GPTHeader();
     runChecks();
 }
Пример #8
0
 public GPTScheme(absImageStream fileset)
     : base(fileset)
 {
     entries = new List<GPTScheme.entry>();
     backupEntries = new List<GPTScheme.entry>();
     headerMatchesCRC = false;
     tableMatchesCRC = false;
     headerFound = false;
     backupFound = false;
     backupMatchesCRC = false;
     backupTableMatchesCRC = false;
     protectiveMBRExists = false;
     header = new GPTHeader();
     backupHeader = new GPTHeader();
     runChecks();
 }
Пример #9
0
        private absImageStream accessImage(string imagepath)
        {
            FileInfo       f = new FileInfo(imagepath);
            absImageStream ais;

            switch (f.Extension)
            {
            case ".001":
            case ".dmg":
                i   = new DDSetStream(imagepath);
                ais = new DDSetStream(imagepath);

                break;

            default:
                i   = new DDSetStream(imagepath);
                ais = new DDSetStream(imagepath);
                break;
            }

            return(i);
        }
Пример #10
0
        private GPTHeader getHeader(byte[] buffer, absImageStream fileset, GPTHeader theHeader)
        {
            byte[] findguid = new byte[16];
            Array.Copy(buffer, 0x38, findguid, 0, 16);

            theHeader.revision     = BitConverter.ToInt32(buffer, 0x08);
            theHeader.headersize   = BitConverter.ToInt32(buffer, 0x0C);
            theHeader.headercheck  = BitConverter.ToUInt32(buffer, 0x10);
            theHeader.mainheader   = BitConverter.ToInt64(buffer, 0x18);
            theHeader.backupheader = BitConverter.ToInt64(buffer, 0x20);
            theHeader.firstlba     = BitConverter.ToInt64(buffer, 0x28);
            theHeader.lastlba      = BitConverter.ToInt64(buffer, 0x30);
            theHeader.diskguid     = new Guid(findguid);
            theHeader.tablestart   = BitConverter.ToInt32(buffer, 0x48);
            numberofentries        = BitConverter.ToInt32(buffer, 0x50);
            sizeofentry            = BitConverter.ToInt32(buffer, 0x54);
            theHeader.tablecheck   = BitConverter.ToUInt32(buffer, 0x58);

            tablelength = numberofentries * sizeofentry;

            return(theHeader);
        }
Пример #11
0
 public absPartitionScheme(absImageStream fileset)
 {
     i = fileset;
 }
Пример #12
0
 public absPartitionScheme(absImageStream fileset)
 {
     i = fileset;
 }
Пример #13
0
        public imageMap(absImageStream ais)
        {
            if (ais.scheme == absImageStream.schemeType.GPT)
            {
                GPTScheme gpts = new GPTScheme(ais);

                mapBlock block = new mapBlock();
                block.location = 0;

                if (gpts.protectiveMBRExists)
                {
                    block.length = 1;
                    block.name = "MBR";
                    block.type = tileType.MBR;

                    partitionblocks.Add(block);
                }

                if (gpts.headerFound)
                {
                    block.location = 1;
                    block.length = 1;
                    block.name = "GPT Header";
                    block.type = tileType.GPT;

                    partitionblocks.Add(block);

                    block.location = gpts.tablestart;
                    block.length = gpts.tablelength / ais.sectorSize;
                    if (block.length < 1) block.length = 1;
                    block.name = "GPT Primary Table";
                    block.type = tileType.GPT;

                    partitionblocks.Add(block);
                }

                if (gpts.backupFound)
                {
                    block.location = gpts.backupHeader.mainheader;
                    block.length = 1;
                    block.name = "Backup GPT Header";
                    block.type = tileType.GPT;

                    partitionblocks.Add(block);

                    block.location = gpts.backupHeader.tablestart;
                    block.length = gpts.tablelength / ais.sectorSize;
                    if (block.length < 1) block.length = 1;
                    block.name = "GPT Backup Table";
                    block.type = tileType.GPT;

                    partitionblocks.Add(block);
                }

                foreach (GPTScheme.entry entry in gpts.entries)
                {
                    block.location = entry.partStartLBA;
                    block.length = entry.partLength;
                    block.name = entry.name;
                    block.type = tileType.vol_unknown;

                    if (gpts.findPartitionType(entry) == GPTScheme.partitionType.HFSPlus)
                    {
                        HFSPlus hfsp = new HFSPlus(ais, entry);

                        block.mapSectorsPerBlock = (int)hfsp.volHead.blockSize / ais.sectorSize;
                        forkStream fs = new forkStream(new volumeStream(hfsp), new HFSPlusFile(hfsp.volHead.allocationFile, forkStream.forkType.data), forkStream.forkType.data);

                        block.allocationMap = new byte[(int)fs.Length];
                        fs.Read(block.allocationMap, 0, (int)fs.Length);
                    }
                    else
                    {
                        block.allocationMap = null;
                    }

                    partitionblocks.Add(block);
                }

            }

            partitionblocks.Sort(CompareBlocksByPosition);
        }
Пример #14
0
        private void setFileTreeFromImage(absImageStream i)
        {
            TreeNode partitionTN = new TreeNode();

            fileTree = null;
            fileTree = new TreeNode();

            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;
                        fileTree.Nodes.Add(partitionTN);
                    }
                    break;
                default:
                    break;
            }
        }
Пример #15
0
        private absImageStream accessImage(string imagepath)
        {
            FileInfo f = new FileInfo(imagepath);
            absImageStream ais;

            switch (f.Extension)
            {
                case ".001": case ".dmg":
                    i = new DDSetStream(imagepath);
                    ais = new DDSetStream(imagepath);

                    break;
                default:
                    i = new DDSetStream(imagepath);
                    ais = new DDSetStream(imagepath);
                    break;
            }

            return i;
        }
Пример #16
0
        public void getImageContents(string imagepath)
        {
            i = accessImage(imagepath);

            setFileTreeFromImage(i);
            fileTree.Text = i.bf.F.Name;

            absImageStream.imageProperties tag = new absImageStream.imageProperties();
            tag.imagepath = i.bf.F.FullName;
            tag.componentSize = i.componentSize;
            tag.sectorSize = i.sectorSize;

            i.Position = 0;

            tag.scheme = i.scheme;
            tag.totalSize = i.Length;

            if (tag.scheme == absImageStream.schemeType.GPT)
            {
                tag.entries = new GPTScheme(i);
            }

            fileTree.Tag = tag;

            displayTree = stripFilesFromTree(fileTree);
        }
Пример #17
0
        private GPTHeader getHeader(byte[] buffer, absImageStream fileset, GPTHeader theHeader)
        {
            byte[] findguid = new byte[16];
            Array.Copy(buffer, 0x38, findguid, 0, 16);

            theHeader.revision = BitConverter.ToInt32(buffer, 0x08);
            theHeader.headersize = BitConverter.ToInt32(buffer, 0x0C);
            theHeader.headercheck = BitConverter.ToUInt32(buffer, 0x10);
            theHeader.mainheader = BitConverter.ToInt64(buffer, 0x18);
            theHeader.backupheader = BitConverter.ToInt64(buffer, 0x20);
            theHeader.firstlba = BitConverter.ToInt64(buffer, 0x28);
            theHeader.lastlba = BitConverter.ToInt64(buffer, 0x30);
            theHeader.diskguid = new Guid(findguid);
            theHeader.tablestart = BitConverter.ToInt32(buffer, 0x48);
            numberofentries = BitConverter.ToInt32(buffer, 0x50);
            sizeofentry = BitConverter.ToInt32(buffer, 0x54);
            theHeader.tablecheck = BitConverter.ToUInt32(buffer, 0x58);

            tablelength = numberofentries * sizeofentry;

            return theHeader;
        }
Пример #18
0
        public imageMap(absImageStream ais)
        {
            if (ais.scheme == absImageStream.schemeType.GPT)
            {
                GPTScheme gpts = new GPTScheme(ais);

                mapBlock block = new mapBlock();
                block.location = 0;

                if (gpts.protectiveMBRExists)
                {
                    block.length = 1;
                    block.name   = "MBR";
                    block.type   = tileType.MBR;

                    partitionblocks.Add(block);
                }

                if (gpts.headerFound)
                {
                    block.location = 1;
                    block.length   = 1;
                    block.name     = "GPT Header";
                    block.type     = tileType.GPT;

                    partitionblocks.Add(block);

                    block.location = gpts.tablestart;
                    block.length   = gpts.tablelength / ais.sectorSize;
                    if (block.length < 1)
                    {
                        block.length = 1;
                    }
                    block.name = "GPT Primary Table";
                    block.type = tileType.GPT;

                    partitionblocks.Add(block);
                }

                if (gpts.backupFound)
                {
                    block.location = gpts.backupHeader.mainheader;
                    block.length   = 1;
                    block.name     = "Backup GPT Header";
                    block.type     = tileType.GPT;

                    partitionblocks.Add(block);

                    block.location = gpts.backupHeader.tablestart;
                    block.length   = gpts.tablelength / ais.sectorSize;
                    if (block.length < 1)
                    {
                        block.length = 1;
                    }
                    block.name = "GPT Backup Table";
                    block.type = tileType.GPT;

                    partitionblocks.Add(block);
                }

                foreach (GPTScheme.entry entry in gpts.entries)
                {
                    block.location = entry.partStartLBA;
                    block.length   = entry.partLength;
                    block.name     = entry.name;
                    block.type     = tileType.vol_unknown;

                    if (gpts.findPartitionType(entry) == GPTScheme.partitionType.HFSPlus)
                    {
                        HFSPlus hfsp = new HFSPlus(ais, entry);

                        block.mapSectorsPerBlock = (int)hfsp.volHead.blockSize / ais.sectorSize;
                        forkStream fs = new forkStream(new volumeStream(hfsp), new HFSPlusFile(hfsp.volHead.allocationFile, forkStream.forkType.data), forkStream.forkType.data);

                        block.allocationMap = new byte[(int)fs.Length];
                        fs.Read(block.allocationMap, 0, (int)fs.Length);
                    }
                    else
                    {
                        block.allocationMap = null;
                    }

                    partitionblocks.Add(block);
                }
            }

            partitionblocks.Sort(CompareBlocksByPosition);
        }