Пример #1
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);
            }

            QNX6_AudiSuperBlock audiSb = new QNX6_AudiSuperBlock();
            IntPtr audiPtr             = Marshal.AllocHGlobal(Marshal.SizeOf(audiSb));

            Marshal.Copy(audiSector, 0, audiPtr, Marshal.SizeOf(audiSb));
            audiSb = (QNX6_AudiSuperBlock)Marshal.PtrToStructure(audiPtr, typeof(QNX6_AudiSuperBlock));
            Marshal.FreeHGlobal(audiPtr);

            QNX6_SuperBlock qnxSb = new QNX6_SuperBlock();
            IntPtr          sbPtr = Marshal.AllocHGlobal(Marshal.SizeOf(qnxSb));

            Marshal.Copy(sector, 0, sbPtr, Marshal.SizeOf(qnxSb));
            qnxSb = (QNX6_SuperBlock)Marshal.PtrToStructure(sbPtr, typeof(QNX6_SuperBlock));
            Marshal.FreeHGlobal(sbPtr);

            return(qnxSb.magic == QNX6_MAGIC || audiSb.magic == QNX6_MAGIC);
        }
Пример #2
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);
            }

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

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

            return(qnxSb.magic == QNX6_MAGIC || audiSb.magic == QNX6_MAGIC);
        }
Пример #3
0
        public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
                                   Encoding encoding)
        {
            Encoding    = encoding ?? Encoding.GetEncoding("iso-8859-15");
            information = "";
            StringBuilder sb          = new StringBuilder();
            uint          sectors     = QNX6_SUPER_BLOCK_SIZE / imagePlugin.Info.SectorSize;
            uint          bootSectors = QNX6_BOOT_BLOCKS_SIZE / imagePlugin.Info.SectorSize;

            byte[] audiSector = imagePlugin.ReadSectors(partition.Start, sectors);
            byte[] sector     = imagePlugin.ReadSectors(partition.Start + bootSectors, sectors);
            if (sector.Length < QNX6_SUPER_BLOCK_SIZE)
            {
                return;
            }

            QNX6_AudiSuperBlock audiSb = new QNX6_AudiSuperBlock();
            IntPtr audiPtr             = Marshal.AllocHGlobal(Marshal.SizeOf(audiSb));

            Marshal.Copy(audiSector, 0, audiPtr, Marshal.SizeOf(audiSb));
            audiSb = (QNX6_AudiSuperBlock)Marshal.PtrToStructure(audiPtr, typeof(QNX6_AudiSuperBlock));
            Marshal.FreeHGlobal(audiPtr);

            QNX6_SuperBlock qnxSb = new QNX6_SuperBlock();
            IntPtr          sbPtr = Marshal.AllocHGlobal(Marshal.SizeOf(qnxSb));

            Marshal.Copy(sector, 0, sbPtr, Marshal.SizeOf(qnxSb));
            qnxSb = (QNX6_SuperBlock)Marshal.PtrToStructure(sbPtr, typeof(QNX6_SuperBlock));
            Marshal.FreeHGlobal(sbPtr);

            bool audi = audiSb.magic == QNX6_MAGIC;

            if (audi)
            {
                sb.AppendLine("QNX6 (Audi) filesystem");
                sb.AppendFormat("Checksum: 0x{0:X8}", audiSb.checksum).AppendLine();
                sb.AppendFormat("Serial: 0x{0:X16}", audiSb.checksum).AppendLine();
                sb.AppendFormat("{0} bytes per block", audiSb.blockSize).AppendLine();
                sb.AppendFormat("{0} inodes free of {1}", audiSb.freeInodes, audiSb.numInodes).AppendLine();
                sb.AppendFormat("{0} blocks ({1} bytes) free of {2} ({3} bytes)", audiSb.freeBlocks,
                                audiSb.freeBlocks * audiSb.blockSize, audiSb.numBlocks,
                                audiSb.numBlocks * audiSb.blockSize).AppendLine();

                XmlFsType = new FileSystemType
                {
                    Type                  = "QNX6 (Audi) filesystem",
                    Clusters              = audiSb.numBlocks,
                    ClusterSize           = (int)audiSb.blockSize,
                    Bootable              = true,
                    Files                 = audiSb.numInodes - audiSb.freeInodes,
                    FilesSpecified        = true,
                    FreeClusters          = audiSb.freeBlocks,
                    FreeClustersSpecified = true,
                    VolumeSerial          = $"{audiSb.serial:X16}"
                };
                //xmlFSType.VolumeName = CurrentEncoding.GetString(audiSb.id);

                information = sb.ToString();
                return;
            }

            sb.AppendLine("QNX6 filesystem");
            sb.AppendFormat("Checksum: 0x{0:X8}", qnxSb.checksum).AppendLine();
            sb.AppendFormat("Serial: 0x{0:X16}", qnxSb.checksum).AppendLine();
            sb.AppendFormat("Created on {0}", DateHandlers.UnixUnsignedToDateTime(qnxSb.ctime)).AppendLine();
            sb.AppendFormat("Last mounted on {0}", DateHandlers.UnixUnsignedToDateTime(qnxSb.atime)).AppendLine();
            sb.AppendFormat("Flags: 0x{0:X8}", qnxSb.flags).AppendLine();
            sb.AppendFormat("Version1: 0x{0:X4}", qnxSb.version1).AppendLine();
            sb.AppendFormat("Version2: 0x{0:X4}", qnxSb.version2).AppendLine();
            //sb.AppendFormat("Volume ID: \"{0}\"", CurrentEncoding.GetString(qnxSb.volumeid)).AppendLine();
            sb.AppendFormat("{0} bytes per block", qnxSb.blockSize).AppendLine();
            sb.AppendFormat("{0} inodes free of {1}", qnxSb.freeInodes, qnxSb.numInodes).AppendLine();
            sb.AppendFormat("{0} blocks ({1} bytes) free of {2} ({3} bytes)", qnxSb.freeBlocks,
                            qnxSb.freeBlocks * qnxSb.blockSize, qnxSb.numBlocks, qnxSb.numBlocks * qnxSb.blockSize)
            .AppendLine();

            XmlFsType = new FileSystemType
            {
                Type                      = "QNX6 filesystem",
                Clusters                  = qnxSb.numBlocks,
                ClusterSize               = (int)qnxSb.blockSize,
                Bootable                  = true,
                Files                     = qnxSb.numInodes - qnxSb.freeInodes,
                FilesSpecified            = true,
                FreeClusters              = qnxSb.freeBlocks,
                FreeClustersSpecified     = true,
                VolumeSerial              = $"{qnxSb.serial:X16}",
                CreationDate              = DateHandlers.UnixUnsignedToDateTime(qnxSb.ctime),
                CreationDateSpecified     = true,
                ModificationDate          = DateHandlers.UnixUnsignedToDateTime(qnxSb.atime),
                ModificationDateSpecified = true
            };
            //xmlFSType.VolumeName = CurrentEncoding.GetString(qnxSb.volumeid);

            information = sb.ToString();
        }