Beispiel #1
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;

                uint sbSize = (uint)(Marshal.SizeOf <IdSector>() / imagePlugin.Info.SectorSize);

                if (Marshal.SizeOf <IdSector>() % 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 <IdSector>())
                {
                    return(false);
                }

                IdSector    rbfSb     = Marshal.ByteArrayToStructureBigEndian <IdSector>(sector);
                NewIdSector rbf9000Sb = Marshal.ByteArrayToStructureBigEndian <NewIdSector>(sector);

                AaruConsole.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);
        }
Beispiel #2
0
        public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
                                   Encoding encoding)
        {
            Encoding = encoding ?? Encoding.UTF8;
            ulong vmfsSuperOff = VXFS_BASE / imagePlugin.Info.SectorSize;

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

            SuperBlock vxSb = Marshal.ByteArrayToStructureLittleEndian <SuperBlock>(sector);

            var sbInformation = new StringBuilder();

            sbInformation.AppendLine("Veritas file system");

            sbInformation.AppendFormat("Volume version {0}", vxSb.vs_version).AppendLine();

            sbInformation.AppendFormat("Volume name {0}", StringHandlers.CToString(vxSb.vs_fname, Encoding)).
            AppendLine();

            sbInformation.AppendFormat("Volume has {0} blocks of {1} bytes each", vxSb.vs_bsize, vxSb.vs_size).
            AppendLine();

            sbInformation.AppendFormat("Volume has {0} inodes per block", vxSb.vs_inopb).AppendLine();
            sbInformation.AppendFormat("Volume has {0} free inodes", vxSb.vs_ifree).AppendLine();
            sbInformation.AppendFormat("Volume has {0} free blocks", vxSb.vs_free).AppendLine();

            sbInformation.AppendFormat("Volume created on {0}",
                                       DateHandlers.UnixUnsignedToDateTime(vxSb.vs_ctime, vxSb.vs_cutime)).AppendLine();

            sbInformation.AppendFormat("Volume last modified on {0}",
                                       DateHandlers.UnixUnsignedToDateTime(vxSb.vs_wtime, vxSb.vs_wutime)).AppendLine();

            if (vxSb.vs_clean != 0)
            {
                sbInformation.AppendLine("Volume is dirty");
            }

            information = sbInformation.ToString();

            XmlFsType = new FileSystemType
            {
                Type                      = "Veritas file system",
                CreationDate              = DateHandlers.UnixUnsignedToDateTime(vxSb.vs_ctime, vxSb.vs_cutime),
                CreationDateSpecified     = true,
                ModificationDate          = DateHandlers.UnixUnsignedToDateTime(vxSb.vs_wtime, vxSb.vs_wutime),
                ModificationDateSpecified = true,
                Clusters                  = (ulong)vxSb.vs_size,
                ClusterSize               = (uint)vxSb.vs_bsize,
                Dirty                     = vxSb.vs_clean != 0,
                FreeClusters              = (ulong)vxSb.vs_free,
                FreeClustersSpecified     = true
            };
        }
Beispiel #3
0
        static dk_label SwapDiskLabel(dk_label label)
        {
            AaruConsole.DebugWriteLine("Sun plugin", "Swapping dk_label");
            label = (dk_label)Marshal.SwapStructureMembersEndian(label);

            for (int i = 0; i < label.dkl_map.Length; i++)
            {
                label.dkl_map[i] = (dk_map)Marshal.SwapStructureMembersEndian(label.dkl_map[i]);
            }

            return(label);
        }
Beispiel #4
0
        public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
                                   Encoding encoding)
        {
            Encoding    = new Radix50();
            information = "";

            var sb = new StringBuilder();

            byte[] hbSector = imagePlugin.ReadSector(1 + partition.Start);

            HomeBlock homeblock = Marshal.ByteArrayToStructureLittleEndian <HomeBlock>(hbSector);

            /* TODO: Is this correct?
             * Assembler:
             *      MOV address, R0
             *      CLR R1
             *      MOV #255., R2
             * 10$: ADD (R0)+, R1
             *      SOB R2, 10$
             *      MOV 1,@R0
             */
            ushort check = 0;

            for (int i = 0; i < 512; i += 2)
            {
                check += BitConverter.ToUInt16(hbSector, i);
            }

            sb.AppendFormat("Volume format is {0}",
                            StringHandlers.SpacePaddedToString(homeblock.format, Encoding.ASCII)).AppendLine();

            sb.AppendFormat("{0} sectors per cluster ({1} bytes)", homeblock.cluster, homeblock.cluster * 512).
            AppendLine();

            sb.AppendFormat("First directory segment starts at block {0}", homeblock.rootBlock).AppendLine();
            sb.AppendFormat("Volume owner is \"{0}\"", Encoding.GetString(homeblock.ownername).TrimEnd()).AppendLine();
            sb.AppendFormat("Volume label: \"{0}\"", Encoding.GetString(homeblock.volname).TrimEnd()).AppendLine();
            sb.AppendFormat("Checksum: 0x{0:X4} (calculated 0x{1:X4})", homeblock.checksum, check).AppendLine();

            byte[] bootBlock = imagePlugin.ReadSector(0);

            XmlFsType = new FileSystemType
            {
                Type        = "RT-11",
                ClusterSize = (uint)(homeblock.cluster * 512),
                Clusters    = homeblock.cluster,
                VolumeName  = StringHandlers.SpacePaddedToString(homeblock.volname, Encoding),
                Bootable    = !ArrayHelpers.ArrayIsNullOrEmpty(bootBlock)
            };

            information = sb.ToString();
        }
Beispiel #5
0
        public bool Identify(IMediaImage imagePlugin, Partition partition)
        {
            if (partition.Start + 1 >= imagePlugin.Info.Sectors)
            {
                return(false);
            }

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

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

            Superblock qnxSb = Marshal.ByteArrayToStructureLittleEndian <Superblock>(sector);

            // Check root directory name
            if (!_rootDirFname.SequenceEqual(qnxSb.rootDir.di_fname))
            {
                return(false);
            }

            // Check sizes are multiple of blocks
            if (qnxSb.rootDir.di_size % 512 != 0 ||
                qnxSb.inode.di_size % 512 != 0 ||
                qnxSb.boot.di_size % 512 != 0 ||
                qnxSb.altBoot.di_size % 512 != 0)
            {
                return(false);
            }

            // Check extents are not past device
            if (qnxSb.rootDir.di_first_xtnt.block + partition.Start >= partition.End ||
                qnxSb.inode.di_first_xtnt.block + partition.Start >= partition.End ||
                qnxSb.boot.di_first_xtnt.block + partition.Start >= partition.End ||
                qnxSb.altBoot.di_first_xtnt.block + partition.Start >= partition.End)
            {
                return(false);
            }

            // Check inodes are in use
            if ((qnxSb.rootDir.di_status & 0x01) != 0x01 ||
                (qnxSb.inode.di_status & 0x01) != 0x01 ||
                (qnxSb.boot.di_status & 0x01) != 0x01)
            {
                return(false);
            }

            // All hail filesystems without identification marks
            return(true);
        }
Beispiel #6
0
        public bool Identify(IMediaImage imagePlugin, Partition partition)
        {
            if (imagePlugin.Info.SectorSize < 256)
            {
                return(false);
            }

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

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

            return(lifSb.magic == LIF_MAGIC);
        }
Beispiel #7
0
        public bool Identify(IMediaImage imagePlugin, Partition partition)
        {
            if (partition.Start > 0)
            {
                return(false);
            }

            if (imagePlugin.Info.SectorSize != 256)
            {
                return(false);
            }

            if (imagePlugin.Info.Sectors != 683 &&
                imagePlugin.Info.Sectors != 768 &&
                imagePlugin.Info.Sectors != 1366 &&
                imagePlugin.Info.Sectors != 3200)
            {
                return(false);
            }

            byte[] sector;

            if (imagePlugin.Info.Sectors == 3200)
            {
                sector = imagePlugin.ReadSector(1560);
                Header cbmHdr = Marshal.ByteArrayToStructureLittleEndian <Header>(sector);

                if (cbmHdr.diskDosVersion == 0x44 &&
                    cbmHdr.dosVersion == 0x33 &&
                    cbmHdr.diskVersion == 0x44)
                {
                    return(true);
                }
            }
            else
            {
                sector = imagePlugin.ReadSector(357);
                BAM cbmBam = Marshal.ByteArrayToStructureLittleEndian <BAM>(sector);

                if (cbmBam.dosVersion == 0x41 &&
                    (cbmBam.doubleSided == 0x00 || cbmBam.doubleSided == 0x80) &&
                    cbmBam.unused1 == 0x00 &&
                    cbmBam.directoryTrack == 0x12)
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #8
0
        public bool Identify(byte[] buffer)
        {
            if (buffer == null ||
                buffer.Length < 26)
            {
                return(false);
            }

            byte[] hdrB = new byte[26];
            Array.Copy(buffer, 0, hdrB, 0, 26);
            _header = Marshal.ByteArrayToStructureBigEndian <Header>(hdrB);

            return(_header.magic == MAGIC && (_header.version == VERSION || _header.version == VERSION2));
        }
Beispiel #9
0
        public bool Identify(Stream stream)
        {
            if (stream == null ||
                stream.Length < 26)
            {
                return(false);
            }

            byte[] hdrB = new byte[26];
            stream.Seek(0, SeekOrigin.Begin);
            stream.Read(hdrB, 0, 26);
            _header = Marshal.ByteArrayToStructureBigEndian <Header>(hdrB);

            return(_header.magic == MAGIC && (_header.version == VERSION || _header.version == VERSION2));
        }
Beispiel #10
0
        public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
                                   Encoding encoding)
        {
            Encoding = encoding ?? Encoding.UTF8;
            ulong vmfsSuperOff = VMFS_BASE / imagePlugin.Info.SectorSize;

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

            VolumeInfo volInfo = Marshal.ByteArrayToStructureLittleEndian <VolumeInfo>(sector);

            var sbInformation = new StringBuilder();

            sbInformation.AppendLine("VMware file system");

            uint ctimeSecs     = (uint)(volInfo.ctime / 1000000);
            uint ctimeNanoSecs = (uint)(volInfo.ctime % 1000000);
            uint mtimeSecs     = (uint)(volInfo.mtime / 1000000);
            uint mtimeNanoSecs = (uint)(volInfo.mtime % 1000000);

            sbInformation.AppendFormat("Volume version {0}", volInfo.version).AppendLine();

            sbInformation.AppendFormat("Volume name {0}", StringHandlers.CToString(volInfo.name, Encoding)).
            AppendLine();

            sbInformation.AppendFormat("Volume size {0} bytes", volInfo.size * 256).AppendLine();
            sbInformation.AppendFormat("Volume UUID {0}", volInfo.uuid).AppendLine();

            sbInformation.
            AppendFormat("Volume created on {0}", DateHandlers.UnixUnsignedToDateTime(ctimeSecs, ctimeNanoSecs)).
            AppendLine();

            sbInformation.AppendFormat("Volume last modified on {0}",
                                       DateHandlers.UnixUnsignedToDateTime(mtimeSecs, mtimeNanoSecs)).AppendLine();

            information = sbInformation.ToString();

            XmlFsType = new FileSystemType
            {
                Type                      = "VMware file system",
                CreationDate              = DateHandlers.UnixUnsignedToDateTime(ctimeSecs, ctimeNanoSecs),
                CreationDateSpecified     = true,
                ModificationDate          = DateHandlers.UnixUnsignedToDateTime(mtimeSecs, mtimeNanoSecs),
                ModificationDateSpecified = true,
                Clusters                  = (volInfo.size * 256) / imagePlugin.Info.SectorSize,
                ClusterSize               = imagePlugin.Info.SectorSize,
                VolumeSerial              = volInfo.uuid.ToString()
            };
        }
Beispiel #11
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 = Marshal.ByteArrayToStructureBigEndian <RootBlock>(tmp);

            root.hashTable = new uint[(block.Length - 224) / 4];

            for (int i = 0; i < root.hashTable.Length; i++)
            {
                root.hashTable[i] = BigEndianBitConverter.ToUInt32(block, 24 + (i * 4));
            }

            return(root);
        }
Beispiel #12
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);

            var  crSb         = new SuperBlock();
            bool littleEndian = true;

            switch (magic)
            {
            case CRAM_MAGIC:
                crSb = Marshal.ByteArrayToStructureLittleEndian <SuperBlock>(sector);

                break;

            case CRAM_CIGAM:
                crSb         = Marshal.ByteArrayToStructureBigEndian <SuperBlock>(sector);
                littleEndian = false;

                break;
            }

            var 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
            };
        }
Beispiel #13
0
        public bool Identify(IMediaImage imagePlugin, Partition partition)
        {
            ulong hdrSector = HEADER_POS / imagePlugin.Info.SectorSize;

            if (partition.Start + hdrSector > imagePlugin.Info.Sectors)
            {
                return(false);
            }

            byte[] sector = imagePlugin.ReadSector(partition.Start + hdrSector);
            Header hdr    = Marshal.ByteArrayToStructureBigEndian <Header>(sector);

            AaruConsole.DebugWriteLine("Fossil plugin", "magic at 0x{0:X8} (expected 0x{1:X8})", hdr.magic,
                                       FOSSIL_HDR_MAGIC);

            return(hdr.magic == FOSSIL_HDR_MAGIC);
        }
Beispiel #14
0
        public bool Identify(byte[] buffer)
        {
            if (buffer == null ||
                buffer.Length < 128)
            {
                return(false);
            }

            byte[] hdrB = new byte[128];
            Array.Copy(buffer, 0, hdrB, 0, 128);
            _header = Marshal.ByteArrayToStructureBigEndian <MacBinaryHeader>(hdrB);

            return(_header.magic == 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)));
        }
Beispiel #15
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);
            SystemBlock lifSb  = Marshal.ByteArrayToStructureBigEndian <SystemBlock>(sector);

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

            var 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              = partition.Size / 256,
                CreationDate          = DateHandlers.LifToDateTime(lifSb.creationDate),
                CreationDateSpecified = true,
                VolumeName            = StringHandlers.CToString(lifSb.volumeLabel, Encoding)
            };
        }
Beispiel #16
0
        public bool Identify(string path)
        {
            var fstream = new FileStream(path, FileMode.Open, FileAccess.Read);

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

            byte[] hdrB = new byte[26];
            fstream.Read(hdrB, 0, 26);
            _header = Marshal.ByteArrayToStructureBigEndian <AppleSingleHeader>(hdrB);

            fstream.Close();

            return(_header.magic == MAGIC && (_header.version == VERSION || _header.version == VERSION2));
        }
Beispiel #17
0
        public bool Identify(Stream stream)
        {
            if (stream == null ||
                stream.Length < 128)
            {
                return(false);
            }

            byte[] hdrB = new byte[128];
            stream.Seek(0, SeekOrigin.Begin);
            stream.Read(hdrB, 0, 128);
            _header = Marshal.ByteArrayToStructureBigEndian <MacBinaryHeader>(hdrB);

            return(_header.magic == 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)));
        }
Beispiel #18
0
        public bool Identify(IMediaImage imagePlugin, Partition partition)
        {
            if (imagePlugin.Info.SectorSize < 512)
            {
                return(false);
            }

            for (ulong location = 0; location <= 8; location++)
            {
                uint sbSize = (uint)(Marshal.SizeOf <Superblock>() / imagePlugin.Info.SectorSize);

                if (Marshal.SizeOf <Superblock>() % 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 <Superblock>())
                {
                    return(false);
                }

                Superblock locusSb = Marshal.ByteArrayToStructureLittleEndian <Superblock>(sector);

                AaruConsole.DebugWriteLine("Locus plugin", "magic at {1} = 0x{0:X8}", locusSb.s_magic, location);

                if (locusSb.s_magic == LOCUS_MAGIC ||
                    locusSb.s_magic == LOCUS_CIGAM ||
                    locusSb.s_magic == LOCUS_MAGIC_OLD ||
                    locusSb.s_magic == LOCUS_CIGAM_OLD)
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #19
0
        public bool Identify(IMediaImage imagePlugin, Partition partition)
        {
            int  sbSizeInBytes   = Marshal.SizeOf <SuperBlock>();
            uint sbSizeInSectors = (uint)(sbSizeInBytes / imagePlugin.Info.SectorSize);

            if (sbSizeInBytes % imagePlugin.Info.SectorSize > 0)
            {
                sbSizeInSectors++;
            }

            if (sbSizeInSectors + partition.Start >= partition.End)
            {
                return(false);
            }

            byte[]     sbSector = imagePlugin.ReadSectors(partition.Start, sbSizeInSectors);
            SuperBlock supblk   = Marshal.ByteArrayToStructureLittleEndian <SuperBlock>(sbSector);

            return(supblk.s_magic == XIAFS_SUPER_MAGIC);
        }
Beispiel #20
0
        public bool Identify(string path)
        {
            var fstream = new FileStream(path, FileMode.Open, FileAccess.Read);

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

            byte[] hdrB = new byte[128];
            fstream.Read(hdrB, 0, 128);
            _header = Marshal.ByteArrayToStructureBigEndian <MacBinaryHeader>(hdrB);

            fstream.Close();

            return(_header.magic == 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)));
        }
Beispiel #21
0
        public bool Identify(IMediaImage imagePlugin, Partition partition)
        {
            uint bootSectors = JFS_BOOT_BLOCKS_SIZE / imagePlugin.Info.SectorSize;

            if (partition.Start + bootSectors >= partition.End)
            {
                return(false);
            }

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

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

            SuperBlock jfsSb = Marshal.ByteArrayToStructureLittleEndian <SuperBlock>(sector);

            return(jfsSb.s_magic == JFS_MAGIC);
        }
Beispiel #22
0
        static DiskLabel SwapDiskLabel(DiskLabel dl)
        {
            dl = (DiskLabel)Marshal.SwapStructureMembersEndian(dl);

            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)Marshal.SwapStructureMembersEndian(dl.d_partitions[i]);
            }

            return(dl);
        }
Beispiel #23
0
        public bool Identify(IMediaImage imagePlugin, Partition partition)
        {
            if (imagePlugin.Info.SectorSize < 512)
            {
                return(false);
            }

            // It should be start of a tape or floppy or file
            if (partition.Start != 0)
            {
                return(false);
            }

            uint sbSize = (uint)(Marshal.SizeOf <s_spcl>() / imagePlugin.Info.SectorSize);

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

            byte[] sector = imagePlugin.ReadSectors(partition.Start, sbSize);

            if (sector.Length < Marshal.SizeOf <s_spcl>())
            {
                return(false);
            }

            spcl16   oldHdr = Marshal.ByteArrayToStructureLittleEndian <spcl16>(sector);
            spcl_aix aixHdr = Marshal.ByteArrayToStructureLittleEndian <spcl_aix>(sector);
            s_spcl   newHdr = Marshal.ByteArrayToStructureLittleEndian <s_spcl>(sector);

            AaruConsole.DebugWriteLine("dump(8) plugin", "old magic = 0x{0:X8}", oldHdr.c_magic);
            AaruConsole.DebugWriteLine("dump(8) plugin", "aix magic = 0x{0:X8}", aixHdr.c_magic);
            AaruConsole.DebugWriteLine("dump(8) plugin", "new magic = 0x{0:X8}", newHdr.c_magic);

            return(oldHdr.c_magic == OFS_MAGIC || aixHdr.c_magic == XIX_MAGIC || aixHdr.c_magic == XIX_CIGAM ||
                   newHdr.c_magic == OFS_MAGIC || newHdr.c_magic == NFS_MAGIC || newHdr.c_magic == OFS_CIGAM ||
                   newHdr.c_magic == NFS_CIGAM || newHdr.c_magic == UFS2_MAGIC || newHdr.c_magic == UFS2_CIGAM);
        }
Beispiel #24
0
        public void Open(byte[] buffer)
        {
            var ms = new MemoryStream(buffer);

            ms.Seek(0, SeekOrigin.Begin);

            byte[] hdrB = new byte[128];
            ms.Read(hdrB, 0, 128);
            _header = Marshal.ByteArrayToStructureBigEndian <MacBinaryHeader>(hdrB);

            uint blocks = 1;

            blocks += (uint)(_header.secondaryHeaderLength / 128);

            if (_header.secondaryHeaderLength % 128 > 0)
            {
                blocks++;
            }

            _dataForkOff = blocks * 128;
            blocks      += _header.dataLength / 128;

            if (_header.dataLength % 128 > 0)
            {
                blocks++;
            }

            _rsrcForkOff = blocks * 128;

            _filename      = StringHandlers.PascalToString(_header.filename, Encoding.GetEncoding("macintosh"));
            _creationTime  = DateHandlers.MacToDateTime(_header.creationTime);
            _lastWriteTime = DateHandlers.MacToDateTime(_header.modificationTime);

            ms.Close();
            _opened  = true;
            _isBytes = true;
            _bytes   = buffer;
        }
Beispiel #25
0
        public void Open(string path)
        {
            var fs = new FileStream(path, FileMode.Open, FileAccess.Read);

            fs.Seek(0, SeekOrigin.Begin);

            byte[] hdrB = new byte[128];
            fs.Read(hdrB, 0, 128);
            _header = Marshal.ByteArrayToStructureBigEndian <MacBinaryHeader>(hdrB);

            uint blocks = 1;

            blocks += (uint)(_header.secondaryHeaderLength / 128);

            if (_header.secondaryHeaderLength % 128 > 0)
            {
                blocks++;
            }

            _dataForkOff = blocks * 128;
            blocks      += _header.dataLength / 128;

            if (_header.dataLength % 128 > 0)
            {
                blocks++;
            }

            _rsrcForkOff = blocks * 128;

            _filename      = StringHandlers.PascalToString(_header.filename, Encoding.GetEncoding("macintosh"));
            _creationTime  = DateHandlers.MacToDateTime(_header.creationTime);
            _lastWriteTime = DateHandlers.MacToDateTime(_header.modificationTime);

            fs.Close();
            _opened   = true;
            _isPath   = true;
            _basePath = path;
        }
Beispiel #26
0
        public bool Identify(IMediaImage imagePlugin, Partition partition)
        {
            if (imagePlugin.Info.SectorSize < 512)
            {
                return(false);
            }

            uint sbAddr = REISER_SUPER_OFFSET / imagePlugin.Info.SectorSize;

            if (sbAddr == 0)
            {
                sbAddr = 1;
            }

            uint sbSize = (uint)(Marshal.SizeOf <Superblock>() / imagePlugin.Info.SectorSize);

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

            if (partition.Start + sbAddr + sbSize >= partition.End)
            {
                return(false);
            }

            byte[] sector = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize);

            if (sector.Length < Marshal.SizeOf <Superblock>())
            {
                return(false);
            }

            Superblock reiserSb = Marshal.ByteArrayToStructureLittleEndian <Superblock>(sector);

            return(_magic35.SequenceEqual(reiserSb.magic) || _magic36.SequenceEqual(reiserSb.magic) ||
                   _magicJr.SequenceEqual(reiserSb.magic));
        }
Beispiel #27
0
        public bool Identify(IMediaImage imagePlugin, Partition partition)
        {
            if (imagePlugin.Info.SectorSize < F2FS_MIN_SECTOR ||
                imagePlugin.Info.SectorSize > F2FS_MAX_SECTOR)
            {
                return(false);
            }

            uint sbAddr = F2FS_SUPER_OFFSET / imagePlugin.Info.SectorSize;

            if (sbAddr == 0)
            {
                sbAddr = 1;
            }

            uint sbSize = (uint)(Marshal.SizeOf <Superblock>() / imagePlugin.Info.SectorSize);

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

            if (partition.Start + sbAddr >= partition.End)
            {
                return(false);
            }

            byte[] sector = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize);

            if (sector.Length < Marshal.SizeOf <Superblock>())
            {
                return(false);
            }

            Superblock sb = Marshal.ByteArrayToStructureLittleEndian <Superblock>(sector);

            return(sb.magic == F2FS_MAGIC);
        }
Beispiel #28
0
        public void Open(Stream stream)
        {
            stream.Seek(0, SeekOrigin.Begin);

            byte[] hdrB = new byte[128];
            stream.Read(hdrB, 0, 128);
            _header = Marshal.ByteArrayToStructureBigEndian <Header>(hdrB);

            uint blocks = 1;

            blocks += (uint)(_header.secondaryHeaderLength / 128);

            if (_header.secondaryHeaderLength % 128 > 0)
            {
                blocks++;
            }

            _dataForkOff = blocks * 128;
            blocks      += _header.dataLength / 128;

            if (_header.dataLength % 128 > 0)
            {
                blocks++;
            }

            _rsrcForkOff = blocks * 128;

            _filename      = StringHandlers.PascalToString(_header.filename, Encoding.GetEncoding("macintosh"));
            _creationTime  = DateHandlers.MacToDateTime(_header.creationTime);
            _lastWriteTime = DateHandlers.MacToDateTime(_header.modificationTime);

            stream.Seek(0, SeekOrigin.Begin);
            _opened   = true;
            _isStream = true;
            _stream   = stream;
        }
Beispiel #29
0
        public bool Identify(IMediaImage imagePlugin, Partition partition)
        {
            uint sectors     = QNX6_SUPER_BLOCK_SIZE / imagePlugin.Info.SectorSize;
            uint bootSectors = QNX6_BOOT_BLOCKS_SIZE / imagePlugin.Info.SectorSize;

            if (partition.Start + bootSectors + sectors >= partition.End)
            {
                return(false);
            }

            byte[] audiSector = imagePlugin.ReadSectors(partition.Start, sectors);
            byte[] sector     = imagePlugin.ReadSectors(partition.Start + bootSectors, sectors);

            if (sector.Length < QNX6_SUPER_BLOCK_SIZE)
            {
                return(false);
            }

            AudiSuperBlock audiSb = Marshal.ByteArrayToStructureLittleEndian <AudiSuperBlock>(audiSector);

            SuperBlock qnxSb = Marshal.ByteArrayToStructureLittleEndian <SuperBlock>(sector);

            return(qnxSb.magic == QNX6_MAGIC || audiSb.magic == QNX6_MAGIC);
        }
Beispiel #30
0
        public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
                                   Encoding encoding)
        {
            Encoding    = encoding ?? Encoding.GetEncoding("iso-8859-15");
            information = "";
            byte[] sector = imagePlugin.ReadSector(partition.Start + 1);

            if (sector.Length < 512)
            {
                return;
            }

            Superblock qnxSb = Marshal.ByteArrayToStructureLittleEndian <Superblock>(sector);

            // Too much useless information

            /*
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.rootDir.di_fname = {0}", CurrentEncoding.GetString(qnxSb.rootDir.di_fname));
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.rootDir.di_size = {0}", qnxSb.rootDir.di_size);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.rootDir.di_first_xtnt.block = {0}", qnxSb.rootDir.di_first_xtnt.block);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.rootDir.di_first_xtnt.length = {0}", qnxSb.rootDir.di_first_xtnt.length);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.rootDir.di_xblk = {0}", qnxSb.rootDir.di_xblk);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.rootDir.di_ftime = {0}", DateHandlers.UNIXUnsignedToDateTime(qnxSb.rootDir.di_ftime));
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.rootDir.di_mtime = {0}", DateHandlers.UNIXUnsignedToDateTime(qnxSb.rootDir.di_mtime));
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.rootDir.di_atime = {0}", DateHandlers.UNIXUnsignedToDateTime(qnxSb.rootDir.di_atime));
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.rootDir.di_ctime = {0}", DateHandlers.UNIXUnsignedToDateTime(qnxSb.rootDir.di_ctime));
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.rootDir.di_num_xtnts = {0}", qnxSb.rootDir.di_num_xtnts);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.rootDir.di_mode = {0}", Convert.ToString(qnxSb.rootDir.di_mode, 8));
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.rootDir.di_uid = {0}", qnxSb.rootDir.di_uid);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.rootDir.di_gid = {0}", qnxSb.rootDir.di_gid);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.rootDir.di_nlink = {0}", qnxSb.rootDir.di_nlink);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.rootDir.di_zero = {0}", qnxSb.rootDir.di_zero);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.rootDir.di_type = {0}", qnxSb.rootDir.di_type);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.rootDir.di_status = {0}", qnxSb.rootDir.di_status);
             *
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.inode.di_fname = {0}", CurrentEncoding.GetString(qnxSb.inode.di_fname));
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.inode.di_size = {0}", qnxSb.inode.di_size);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.inode.di_first_xtnt.block = {0}", qnxSb.inode.di_first_xtnt.block);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.inode.di_first_xtnt.length = {0}", qnxSb.inode.di_first_xtnt.length);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.inode.di_xblk = {0}", qnxSb.inode.di_xblk);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.inode.di_ftime = {0}", DateHandlers.UNIXUnsignedToDateTime(qnxSb.inode.di_ftime));
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.inode.di_mtime = {0}", DateHandlers.UNIXUnsignedToDateTime(qnxSb.inode.di_mtime));
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.inode.di_atime = {0}", DateHandlers.UNIXUnsignedToDateTime(qnxSb.inode.di_atime));
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.inode.di_ctime = {0}", DateHandlers.UNIXUnsignedToDateTime(qnxSb.inode.di_ctime));
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.inode.di_num_xtnts = {0}", qnxSb.inode.di_num_xtnts);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.inode.di_mode = {0}", Convert.ToString(qnxSb.inode.di_mode, 8));
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.inode.di_uid = {0}", qnxSb.inode.di_uid);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.inode.di_gid = {0}", qnxSb.inode.di_gid);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.inode.di_nlink = {0}", qnxSb.inode.di_nlink);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.inode.di_zero = {0}", qnxSb.inode.di_zero);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.inode.di_type = {0}", qnxSb.inode.di_type);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.inode.di_status = {0}", qnxSb.inode.di_status);
             *
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.boot.di_fname = {0}", CurrentEncoding.GetString(qnxSb.boot.di_fname));
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.boot.di_size = {0}", qnxSb.boot.di_size);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.boot.di_first_xtnt.block = {0}", qnxSb.boot.di_first_xtnt.block);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.boot.di_first_xtnt.length = {0}", qnxSb.boot.di_first_xtnt.length);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.boot.di_xblk = {0}", qnxSb.boot.di_xblk);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.boot.di_ftime = {0}", DateHandlers.UNIXUnsignedToDateTime(qnxSb.boot.di_ftime));
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.boot.di_mtime = {0}", DateHandlers.UNIXUnsignedToDateTime(qnxSb.boot.di_mtime));
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.boot.di_atime = {0}", DateHandlers.UNIXUnsignedToDateTime(qnxSb.boot.di_atime));
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.boot.di_ctime = {0}", DateHandlers.UNIXUnsignedToDateTime(qnxSb.boot.di_ctime));
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.boot.di_num_xtnts = {0}", qnxSb.boot.di_num_xtnts);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.boot.di_mode = {0}", Convert.ToString(qnxSb.boot.di_mode, 8));
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.boot.di_uid = {0}", qnxSb.boot.di_uid);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.boot.di_gid = {0}", qnxSb.boot.di_gid);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.boot.di_nlink = {0}", qnxSb.boot.di_nlink);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.boot.di_zero = {0}", qnxSb.boot.di_zero);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.boot.di_type = {0}", qnxSb.boot.di_type);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.boot.di_status = {0}", qnxSb.boot.di_status);
             *
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.altBoot.di_fname = {0}", CurrentEncoding.GetString(qnxSb.altBoot.di_fname));
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.altBoot.di_size = {0}", qnxSb.altBoot.di_size);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.altBoot.di_first_xtnt.block = {0}", qnxSb.altBoot.di_first_xtnt.block);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.altBoot.di_first_xtnt.length = {0}", qnxSb.altBoot.di_first_xtnt.length);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.altBoot.di_xblk = {0}", qnxSb.altBoot.di_xblk);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.altBoot.di_ftime = {0}", DateHandlers.UNIXUnsignedToDateTime(qnxSb.altBoot.di_ftime));
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.altBoot.di_mtime = {0}", DateHandlers.UNIXUnsignedToDateTime(qnxSb.altBoot.di_mtime));
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.altBoot.di_atime = {0}", DateHandlers.UNIXUnsignedToDateTime(qnxSb.altBoot.di_atime));
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.altBoot.di_ctime = {0}", DateHandlers.UNIXUnsignedToDateTime(qnxSb.altBoot.di_ctime));
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.altBoot.di_num_xtnts = {0}", qnxSb.altBoot.di_num_xtnts);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.altBoot.di_mode = {0}", Convert.ToString(qnxSb.altBoot.di_mode, 8));
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.altBoot.di_uid = {0}", qnxSb.altBoot.di_uid);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.altBoot.di_gid = {0}", qnxSb.altBoot.di_gid);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.altBoot.di_nlink = {0}", qnxSb.altBoot.di_nlink);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.altBoot.di_zero = {0}", qnxSb.altBoot.di_zero);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.altBoot.di_type = {0}", qnxSb.altBoot.di_type);
             * AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.altBoot.di_status = {0}", qnxSb.altBoot.di_status);
             */

            information =
                $"QNX4 filesystem\nCreated on {DateHandlers.UnixUnsignedToDateTime(qnxSb.rootDir.di_ftime)}\n";

            XmlFsType = new FileSystemType
            {
                Type                      = "QNX4 filesystem",
                Clusters                  = partition.Length,
                ClusterSize               = 512,
                CreationDate              = DateHandlers.UnixUnsignedToDateTime(qnxSb.rootDir.di_ftime),
                CreationDateSpecified     = true,
                ModificationDate          = DateHandlers.UnixUnsignedToDateTime(qnxSb.rootDir.di_mtime),
                ModificationDateSpecified = true
            };

            XmlFsType.Bootable |= qnxSb.boot.di_size != 0 || qnxSb.altBoot.di_size != 0;
        }