示例#1
0
        public bool Identify(IFilter imageFilter)
        {
            Stream stream = imageFilter.GetDataForkStream();

            if (stream.Length < 512)
            {
                return(false);
            }

            stream.Seek(-Marshal.SizeOf(footer), SeekOrigin.End);
            byte[] footerB = new byte[Marshal.SizeOf(footer)];

            stream.Read(footerB, 0, Marshal.SizeOf(footer));
            footer = BigEndianMarshal.ByteArrayToStructureBigEndian <UdifFooter>(footerB);

            if (footer.signature == UDIF_SIGNATURE)
            {
                return(true);
            }

            // Old UDIF as created by DiskCopy 6.5 using "OBSOLETE" format. (DiskCopy 5 rumored format?)
            stream.Seek(0, SeekOrigin.Begin);
            byte[] headerB = new byte[Marshal.SizeOf(footer)];

            stream.Read(headerB, 0, Marshal.SizeOf(footer));
            footer = BigEndianMarshal.ByteArrayToStructureBigEndian <UdifFooter>(headerB);

            return(footer.signature == UDIF_SIGNATURE);
        }
示例#2
0
        public void Open(string path)
        {
            string parentFolder = Path.GetDirectoryName(path);
            string baseFilename = Path.GetFileName(path);

            FileStream finderDatStream =
                new FileStream(Path.Combine(parentFolder ?? throw new InvalidOperationException(), FINDER_INFO),
                               FileMode.Open, FileAccess.Read);

            while (finderDatStream.Position + 0x5C <= finderDatStream.Length)
            {
                PCExchangeEntry datEntry   = new PCExchangeEntry();
                byte[]          datEntry_b = new byte[Marshal.SizeOf(datEntry)];
                finderDatStream.Read(datEntry_b, 0, Marshal.SizeOf(datEntry));
                datEntry = BigEndianMarshal.ByteArrayToStructureBigEndian <PCExchangeEntry>(datEntry_b);
                string macName      = StringHandlers.PascalToString(datEntry.macName, Encoding.GetEncoding("macintosh"));
                byte[] tmpDosName_b = new byte[8];
                byte[] tmpDosExt_b  = new byte[3];
                Array.Copy(datEntry.dosName, 0, tmpDosName_b, 0, 8);
                Array.Copy(datEntry.dosName, 8, tmpDosExt_b, 0, 3);
                string dosName = Encoding.ASCII.GetString(tmpDosName_b).Trim() + "." +
                                 Encoding.ASCII.GetString(tmpDosExt_b).Trim();
                string dosNameLow = dosName.ToLower(CultureInfo.CurrentCulture);

                if (baseFilename != macName && baseFilename != dosName && baseFilename != dosNameLow)
                {
                    continue;
                }

                if (File.Exists(Path.Combine(parentFolder, macName ?? throw new InvalidOperationException())))
                {
                    dataPath = Path.Combine(parentFolder, macName);
                }
示例#3
0
        public bool Identify(IMediaImage imagePlugin, Partition partition)
        {
            if (imagePlugin.Info.SectorSize < 512)
            {
                return(false);
            }

            UNICOS_Superblock unicosSb = new UNICOS_Superblock();

            uint sbSize = (uint)(Marshal.SizeOf(unicosSb) / imagePlugin.Info.SectorSize);

            if (Marshal.SizeOf(unicosSb) % imagePlugin.Info.SectorSize != 0)
            {
                sbSize++;
            }

            byte[] sector = imagePlugin.ReadSectors(partition.Start, sbSize);
            if (sector.Length < Marshal.SizeOf(unicosSb))
            {
                return(false);
            }

            unicosSb = BigEndianMarshal.ByteArrayToStructureBigEndian <UNICOS_Superblock>(sector);

            DicConsole.DebugWriteLine("UNICOS plugin", "magic = 0x{0:X16} (expected 0x{1:X16})", unicosSb.s_magic,
                                      UNICOS_Magic);

            return(unicosSb.s_magic == UNICOS_Magic);
        }
示例#4
0
        public bool Identify(string path)
        {
            string parentFolder = Path.GetDirectoryName(path);

            if (!File.Exists(Path.Combine(parentFolder ?? throw new InvalidOperationException(), FINDER_INFO)))
            {
                return(false);
            }

            if (!Directory.Exists(Path.Combine(parentFolder, RESOURCES)))
            {
                return(false);
            }

            string baseFilename = Path.GetFileName(path);

            bool dataFound = false;
            bool rsrcFound = false;

            FileStream finderDatStream =
                new FileStream(Path.Combine(parentFolder, FINDER_INFO), FileMode.Open, FileAccess.Read);

            while (finderDatStream.Position + 0x5C <= finderDatStream.Length)
            {
                PCExchangeEntry datEntry   = new PCExchangeEntry();
                byte[]          datEntry_b = new byte[Marshal.SizeOf(datEntry)];
                finderDatStream.Read(datEntry_b, 0, Marshal.SizeOf(datEntry));
                datEntry = BigEndianMarshal.ByteArrayToStructureBigEndian <PCExchangeEntry>(datEntry_b);
                // TODO: Add support for encoding on filters
                string macName =
                    StringHandlers.PascalToString(datEntry.macName, Encoding.GetEncoding("macintosh"));
                byte[] tmpDosName_b = new byte[8];
                byte[] tmpDosExt_b  = new byte[3];
                Array.Copy(datEntry.dosName, 0, tmpDosName_b, 0, 8);
                Array.Copy(datEntry.dosName, 8, tmpDosExt_b, 0, 3);
                string dosName = Encoding.ASCII.GetString(tmpDosName_b).Trim() + "." +
                                 Encoding.ASCII.GetString(tmpDosExt_b).Trim();
                string dosNameLow = dosName.ToLower(CultureInfo.CurrentCulture);

                if (baseFilename != macName && baseFilename != dosName && baseFilename != dosNameLow)
                {
                    continue;
                }

                dataFound |=
                    File.Exists(Path.Combine(parentFolder, macName ?? throw new InvalidOperationException())) ||
                    File.Exists(Path.Combine(parentFolder, dosName)) ||
                    File.Exists(Path.Combine(parentFolder, dosNameLow));

                rsrcFound |= File.Exists(Path.Combine(parentFolder, RESOURCES, dosName)) ||
                             File.Exists(Path.Combine(parentFolder, RESOURCES, dosNameLow));

                break;
            }

            finderDatStream.Close();

            return(dataFound && rsrcFound);
        }
示例#5
0
        public bool Identify(IMediaImage imagePlugin, Partition partition)
        {
            if (imagePlugin.Info.SectorSize < 512)
            {
                return(false);
            }

            byte[] sector = imagePlugin.ReadSector(partition.Start);

            FATX_Superblock fatxSb = BigEndianMarshal.ByteArrayToStructureBigEndian <FATX_Superblock>(sector);

            return(fatxSb.magic == FATX_MAGIC);
        }
示例#6
0
        public bool Identify(IMediaImage imagePlugin, Partition partition)
        {
            if (imagePlugin.Info.SectorSize < 256)
            {
                return(false);
            }

            byte[]         sector = imagePlugin.ReadSector(partition.Start);
            LifSystemBlock lifSb  = BigEndianMarshal.ByteArrayToStructureBigEndian <LifSystemBlock>(sector);

            DicConsole.DebugWriteLine("LIF plugin", "magic 0x{0:X8} (expected 0x{1:X8})", lifSb.magic, LIF_MAGIC);

            return(lifSb.magic == LIF_MAGIC);
        }
示例#7
0
        public bool Identify(byte[] buffer)
        {
            if (buffer == null || buffer.Length < 26)
            {
                return(false);
            }

            byte[] hdr_b = new byte[26];
            Array.Copy(buffer, 0, hdr_b, 0, 26);
            header = BigEndianMarshal.ByteArrayToStructureBigEndian <AppleSingleHeader>(hdr_b);

            return(header.magic == AppleSingleMagic &&
                   (header.version == AppleSingleVersion || header.version == AppleSingleVersion2));
        }
示例#8
0
        public bool Identify(Stream stream)
        {
            if (stream == null || stream.Length < 26)
            {
                return(false);
            }

            byte[] hdr_b = new byte[26];
            stream.Seek(0, SeekOrigin.Begin);
            stream.Read(hdr_b, 0, 26);
            header = BigEndianMarshal.ByteArrayToStructureBigEndian <AppleSingleHeader>(hdr_b);

            return(header.magic == AppleSingleMagic &&
                   (header.version == AppleSingleVersion || header.version == AppleSingleVersion2));
        }
示例#9
0
        public bool Identify(byte[] buffer)
        {
            if (buffer == null || buffer.Length < 128)
            {
                return(false);
            }

            byte[] hdr_b = new byte[128];
            Array.Copy(buffer, 0, hdr_b, 0, 128);
            header = BigEndianMarshal.ByteArrayToStructureBigEndian <MacBinaryHeader>(hdr_b);

            return(header.magic == MACBINARY_MAGIC || header.version == 0 && header.filename[0] > 0 &&
                   header.filename[0] < 64 && header.zero1 == 0 && header.zero2 == 0 && header.reserved == 0 &&
                   (header.dataLength > 0 || header.resourceLength > 0));
        }
示例#10
0
        public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
                                   Encoding encoding)
        {
            Encoding = encoding ?? Encoding.GetEncoding("iso-8859-1");
            byte[]    rootBlockSector = imagePlugin.ReadSector(partition.Start);
            RootBlock rootBlock       = BigEndianMarshal.ByteArrayToStructureBigEndian <RootBlock>(rootBlockSector);

            StringBuilder sbInformation = new StringBuilder();

            sbInformation.AppendLine("SmartFileSystem");

            sbInformation.AppendFormat("Volume version {0}", rootBlock.version).AppendLine();
            sbInformation.AppendFormat("Volume starts on device byte {0} and ends on byte {1}", rootBlock.firstbyte,
                                       rootBlock.lastbyte).AppendLine();
            sbInformation
            .AppendFormat("Volume has {0} blocks of {1} bytes each", rootBlock.totalblocks, rootBlock.blocksize)
            .AppendLine();
            sbInformation.AppendFormat("Volume created on {0}",
                                       DateHandlers.UnixUnsignedToDateTime(rootBlock.datecreated).AddYears(8))
            .AppendLine();
            sbInformation.AppendFormat("Bitmap starts in block {0}", rootBlock.bitmapbase).AppendLine();
            sbInformation.AppendFormat("Admin space container starts in block {0}", rootBlock.adminspacecontainer)
            .AppendLine();
            sbInformation.AppendFormat("Root object container starts in block {0}", rootBlock.rootobjectcontainer)
            .AppendLine();
            sbInformation.AppendFormat("Root node of the extent B-tree resides in block {0}", rootBlock.extentbnoderoot)
            .AppendLine();
            sbInformation.AppendFormat("Root node of the object B-tree resides in block {0}", rootBlock.objectnoderoot)
            .AppendLine();
            if (rootBlock.bits.HasFlag(SFSFlags.CaseSensitive))
            {
                sbInformation.AppendLine("Volume is case sensitive");
            }
            if (rootBlock.bits.HasFlag(SFSFlags.RecyledFolder))
            {
                sbInformation.AppendLine("Volume moves deleted files to a recycled folder");
            }
            information = sbInformation.ToString();

            XmlFsType = new FileSystemType
            {
                CreationDate          = DateHandlers.UnixUnsignedToDateTime(rootBlock.datecreated).AddYears(8),
                CreationDateSpecified = true,
                Clusters    = rootBlock.totalblocks,
                ClusterSize = (int)rootBlock.blocksize,
                Type        = "SmartFileSystem"
            };
        }
示例#11
0
        public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
                                   Encoding encoding)
        {
            Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15");
            byte[] sector = imagePlugin.ReadSector(partition.Start);
            uint   magic  = BitConverter.ToUInt32(sector, 0x00);

            CramSuperBlock crSb         = new CramSuperBlock();
            bool           littleEndian = true;

            switch (magic)
            {
            case CRAM_MAGIC:
                IntPtr crSbPtr = Marshal.AllocHGlobal(Marshal.SizeOf(crSb));
                Marshal.Copy(sector, 0, crSbPtr, Marshal.SizeOf(crSb));
                crSb = (CramSuperBlock)Marshal.PtrToStructure(crSbPtr, typeof(CramSuperBlock));
                Marshal.FreeHGlobal(crSbPtr);
                break;

            case CRAM_CIGAM:
                crSb         = BigEndianMarshal.ByteArrayToStructureBigEndian <CramSuperBlock>(sector);
                littleEndian = false;
                break;
            }

            StringBuilder sbInformation = new StringBuilder();

            sbInformation.AppendLine("Cram file system");
            sbInformation.AppendLine(littleEndian ? "Little-endian" : "Big-endian");
            sbInformation.AppendFormat("Volume edition {0}", crSb.edition).AppendLine();
            sbInformation.AppendFormat("Volume name: {0}", StringHandlers.CToString(crSb.name, Encoding)).AppendLine();
            sbInformation.AppendFormat("Volume has {0} bytes", crSb.size).AppendLine();
            sbInformation.AppendFormat("Volume has {0} blocks", crSb.blocks).AppendLine();
            sbInformation.AppendFormat("Volume has {0} files", crSb.files).AppendLine();

            information = sbInformation.ToString();

            XmlFsType = new FileSystemType
            {
                VolumeName            = StringHandlers.CToString(crSb.name, Encoding),
                Type                  = "Cram file system",
                Clusters              = crSb.blocks,
                Files                 = crSb.files,
                FilesSpecified        = true,
                FreeClusters          = 0,
                FreeClustersSpecified = true
            };
        }
示例#12
0
        public bool Identify(Stream stream)
        {
            if (stream == null || stream.Length < 128)
            {
                return(false);
            }

            byte[] hdr_b = new byte[128];
            stream.Seek(0, SeekOrigin.Begin);
            stream.Read(hdr_b, 0, 128);
            header = BigEndianMarshal.ByteArrayToStructureBigEndian <MacBinaryHeader>(hdr_b);

            return(header.magic == MACBINARY_MAGIC || header.version == 0 && header.filename[0] > 0 &&
                   header.filename[0] < 64 && header.zero1 == 0 && header.zero2 == 0 && header.reserved == 0 &&
                   (header.dataLength > 0 || header.resourceLength > 0));
        }
示例#13
0
        static RootBlock MarshalRootBlock(byte[] block)
        {
            byte[] tmp = new byte[228];
            Array.Copy(block, 0, tmp, 0, 24);
            Array.Copy(block, block.Length - 200, tmp, 28, 200);
            RootBlock root = BigEndianMarshal.ByteArrayToStructureBigEndian <RootBlock>(tmp);

            root.hashTable = new uint[(block.Length - 224) / 4];
            BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
            for (int i = 0; i < root.hashTable.Length; i++)
            {
                root.hashTable[i] = BigEndianBitConverter.ToUInt32(block, 24 + i * 4);
            }

            return(root);
        }
示例#14
0
        public bool Identify(IMediaImage imagePlugin, Partition partition)
        {
            if (imagePlugin.Info.SectorSize < 256)
            {
                return(false);
            }

            // Documentation says ID should be sector 0
            // I've found that OS-9/X68000 has it on sector 4
            // I've read OS-9/Apple2 has it on sector 15
            foreach (int i in new[] { 0, 4, 15 })
            {
                ulong        location = (ulong)i;
                RBF_IdSector rbfSb    = new RBF_IdSector();

                uint sbSize = (uint)(Marshal.SizeOf(rbfSb) / imagePlugin.Info.SectorSize);
                if (Marshal.SizeOf(rbfSb) % imagePlugin.Info.SectorSize != 0)
                {
                    sbSize++;
                }

                if (partition.Start + location + sbSize >= imagePlugin.Info.Sectors)
                {
                    break;
                }

                byte[] sector = imagePlugin.ReadSectors(partition.Start + location, sbSize);
                if (sector.Length < Marshal.SizeOf(rbfSb))
                {
                    return(false);
                }

                rbfSb = BigEndianMarshal.ByteArrayToStructureBigEndian <RBF_IdSector>(sector);
                RBF_NewIdSector rbf9000Sb = BigEndianMarshal.ByteArrayToStructureBigEndian <RBF_NewIdSector>(sector);

                DicConsole.DebugWriteLine("RBF plugin",
                                          "magic at {0} = 0x{1:X8} or 0x{2:X8} (expected 0x{3:X8} or 0x{4:X8})",
                                          location, rbfSb.dd_sync, rbf9000Sb.rid_sync, RBF_SYNC, RBF_CNYS);

                if (rbfSb.dd_sync == RBF_SYNC || rbf9000Sb.rid_sync == RBF_SYNC || rbf9000Sb.rid_sync == RBF_CNYS)
                {
                    return(true);
                }
            }

            return(false);
        }
示例#15
0
        public bool Identify(IFilter imageFilter)
        {
            Stream stream = imageFilter.GetDataForkStream();

            stream.Seek(0, SeekOrigin.Begin);

            if (stream.Length < 512)
            {
                return(false);
            }

            byte[] qHdrB = new byte[48];
            stream.Read(qHdrB, 0, 48);
            qHdr = BigEndianMarshal.ByteArrayToStructureBigEndian <QCowHeader>(qHdrB);

            return(qHdr.magic == QCOW_MAGIC && qHdr.version == QCOW_VERSION);
        }
示例#16
0
        public bool Identify(string path)
        {
            FileStream fstream = new FileStream(path, FileMode.Open, FileAccess.Read);

            if (fstream.Length < 26)
            {
                return(false);
            }

            byte[] hdr_b = new byte[26];
            fstream.Read(hdr_b, 0, 26);
            header = BigEndianMarshal.ByteArrayToStructureBigEndian <AppleSingleHeader>(hdr_b);

            fstream.Close();
            return(header.magic == AppleSingleMagic &&
                   (header.version == AppleSingleVersion || header.version == AppleSingleVersion2));
        }
示例#17
0
        public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
                                   Encoding encoding)
        {
            Encoding    = encoding ?? Encoding.GetEncoding("iso-8859-15");
            information = "";

            if (imagePlugin.Info.SectorSize < 256)
            {
                return;
            }

            byte[]         sector = imagePlugin.ReadSector(partition.Start);
            LifSystemBlock lifSb  = BigEndianMarshal.ByteArrayToStructureBigEndian <LifSystemBlock>(sector);

            if (lifSb.magic != LIF_MAGIC)
            {
                return;
            }

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("HP Logical Interchange Format");
            sb.AppendFormat("Directory starts at cluster {0}", lifSb.directoryStart).AppendLine();
            sb.AppendFormat("LIF identifier: {0}", lifSb.lifId).AppendLine();
            sb.AppendFormat("Directory size: {0} clusters", lifSb.directorySize).AppendLine();
            sb.AppendFormat("LIF version: {0}", lifSb.lifVersion).AppendLine();
            // How is this related to volume size? I have only CDs to test and makes no sense there
            sb.AppendFormat("{0} tracks", lifSb.tracks).AppendLine();
            sb.AppendFormat("{0} heads", lifSb.heads).AppendLine();
            sb.AppendFormat("{0} sectors", lifSb.sectors).AppendLine();
            sb.AppendFormat("Volume name: {0}", StringHandlers.CToString(lifSb.volumeLabel, Encoding)).AppendLine();
            sb.AppendFormat("Volume created on {0}", DateHandlers.LifToDateTime(lifSb.creationDate)).AppendLine();

            information = sb.ToString();

            XmlFsType = new FileSystemType
            {
                Type                  = "HP Logical Interchange Format",
                ClusterSize           = 256,
                Clusters              = (long)(partition.Size / 256),
                CreationDate          = DateHandlers.LifToDateTime(lifSb.creationDate),
                CreationDateSpecified = true,
                VolumeName            = StringHandlers.CToString(lifSb.volumeLabel, Encoding)
            };
        }
示例#18
0
        public bool Identify(string path)
        {
            FileStream fstream = new FileStream(path, FileMode.Open, FileAccess.Read);

            if (fstream.Length < 128)
            {
                return(false);
            }

            byte[] hdr_b = new byte[128];
            fstream.Read(hdr_b, 0, 128);
            header = BigEndianMarshal.ByteArrayToStructureBigEndian <MacBinaryHeader>(hdr_b);

            fstream.Close();
            return(header.magic == MACBINARY_MAGIC || header.version == 0 && header.filename[0] > 0 &&
                   header.filename[0] < 64 && header.zero1 == 0 && header.zero2 == 0 && header.reserved == 0 &&
                   (header.dataLength > 0 || header.resourceLength > 0));
        }
示例#19
0
        static DiskLabel SwapDiskLabel(DiskLabel disklabel)
        {
            DiskLabel dl =
                (DiskLabel)BigEndianMarshal.SwapStructureMembersEndian(disklabel);

            for (int i = 0; i < dl.d_drivedata.Length; i++)
            {
                dl.d_drivedata[i] = Swapping.Swap(dl.d_drivedata[i]);
            }
            for (int i = 0; i < dl.d_spare.Length; i++)
            {
                dl.d_spare[i] = Swapping.Swap(dl.d_spare[i]);
            }
            for (int i = 0; i < dl.d_partitions.Length; i++)
            {
                dl.d_partitions[i] = (BSDPartition)BigEndianMarshal.SwapStructureMembersEndian(dl.d_partitions[i]);
            }

            return(dl);
        }
示例#20
0
        public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
                                   Encoding encoding)
        {
            Encoding    = Encoding.UTF8;
            information = "";
            if (imagePlugin.Info.SectorSize < 512)
            {
                return;
            }

            FATX_Superblock fatxSb;

            byte[] sector = imagePlugin.ReadSector(partition.Start);

            fatxSb = BigEndianMarshal.ByteArrayToStructureBigEndian <FATX_Superblock>(sector);

            if (fatxSb.magic != FATX_MAGIC)
            {
                return;
            }

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("FATX filesystem");
            sb.AppendFormat("Filesystem id {0}", fatxSb.id).AppendLine();
            sb.AppendFormat("{0} sectors ({1} bytes) per cluster", fatxSb.sectorsPerCluster,
                            fatxSb.sectorsPerCluster * imagePlugin.Info.SectorSize).AppendLine();
            sb.AppendFormat("Root directory starts on cluster {0}", fatxSb.rootDirectoryCluster).AppendLine();

            information = sb.ToString();

            XmlFsType = new FileSystemType
            {
                Type        = "FATX filesystem",
                ClusterSize = (int)(fatxSb.sectorsPerCluster * imagePlugin.Info.SectorSize)
            };
            XmlFsType.Clusters = (long)((partition.End - partition.Start + 1) * imagePlugin.Info.SectorSize /
                                        (ulong)XmlFsType.ClusterSize);
        }