Esempio n. 1
0
        public bool Identify(IMediaImage imagePlugin, Partition partition)
        {
            // Does AO-DOS support hard disks?
            if (partition.Start > 0)
            {
                return(false);
            }

            // How is it really?
            if (imagePlugin.Info.SectorSize != 512)
            {
                return(false);
            }

            // Does AO-DOS support any other kind of disk?
            if (imagePlugin.Info.Sectors != 800 &&
                imagePlugin.Info.Sectors != 1600)
            {
                return(false);
            }

            byte[]          sector = imagePlugin.ReadSector(0);
            AODOS_BootBlock bb     = Marshal.ByteArrayToStructureLittleEndian <AODOS_BootBlock>(sector);

            return(bb.identifier.SequenceEqual(AODOSIdentifier));
        }
Esempio n. 2
0
        public bool Identify(IMediaImage imagePlugin, Partition partition)
        {
            ulong sbSectorOff = SB_POS / imagePlugin.Info.SectorSize;
            uint  sbOff       = SB_POS % imagePlugin.Info.SectorSize;

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

            int  sbSizeInBytes   = Marshal.SizeOf <ext2FSSuperBlock>();
            uint sbSizeInSectors = (uint)(sbSizeInBytes / imagePlugin.Info.SectorSize);

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

            byte[] sbSector = imagePlugin.ReadSectors(sbSectorOff + partition.Start, sbSizeInSectors);
            byte[] sb       = new byte[sbSizeInBytes];

            if (sbOff + sbSizeInBytes > sbSector.Length)
            {
                return(false);
            }

            Array.Copy(sbSector, sbOff, sb, 0, sbSizeInBytes);

            ushort magic = BitConverter.ToUInt16(sb, 0x038);

            return(magic == EXT2_MAGIC || magic == EXT2_MAGIC_OLD);
        }
Esempio n. 3
0
        public bool Close()
        {
            if (!IsWriting)
            {
                ErrorMessage = "Image is not opened for writing";

                return(false);
            }

            byte[] hdr = new byte[Marshal.SizeOf <QedHeader>()];
            MemoryMarshal.Write(hdr, ref qHdr);

            writingStream.Seek(0, SeekOrigin.Begin);
            writingStream.Write(hdr, 0, hdr.Length);

            writingStream.Seek((long)qHdr.l1_table_offset, SeekOrigin.Begin);
            byte[] l1TableB = MemoryMarshal.Cast <ulong, byte>(l1Table).ToArray();
            writingStream.Write(l1TableB, 0, l1TableB.Length);

            writingStream.Flush();
            writingStream.Close();

            IsWriting    = false;
            ErrorMessage = "";

            return(true);
        }
Esempio n. 4
0
        public bool Identify(IMediaImage imagePlugin, Partition partition)
        {
            if (imagePlugin.Info.SectorSize < 512)
            {
                return(false);
            }

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

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

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

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

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

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

            return(unicosSb.s_magic == UNICOS_MAGIC);
        }
Esempio n. 5
0
        public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
                                   Encoding encoding)
        {
            Encoding    = encoding ?? Encoding.GetEncoding("koi8-r");
            information = "";

            var sb = new StringBuilder();

            byte[] bk0 = imagePlugin.ReadSector(0 + partition.Start);

            Block0 block0 = Marshal.ByteArrayToStructureLittleEndian <Block0>(bk0);

            sb.AppendLine("MicroDOS filesystem");
            sb.AppendFormat("Volume has {0} blocks ({1} bytes)", block0.blocks, block0.blocks * 512).AppendLine();

            sb.AppendFormat("Volume has {0} blocks used ({1} bytes)", block0.usedBlocks, block0.usedBlocks * 512).
            AppendLine();

            sb.AppendFormat("Volume contains {0} files", block0.files).AppendLine();
            sb.AppendFormat("First used block is {0}", block0.firstUsedBlock).AppendLine();

            XmlFsType = new FileSystemType
            {
                Type                  = "MicroDOS",
                ClusterSize           = 512,
                Clusters              = block0.blocks,
                Files                 = block0.files,
                FilesSpecified        = true,
                FreeClusters          = (ulong)(block0.blocks - block0.usedBlocks),
                FreeClustersSpecified = true
            };

            information = sb.ToString();
        }
Esempio n. 6
0
        public bool Identify(IMediaImage imagePlugin, Partition partition)
        {
            uint sbSize = (uint)(Marshal.SizeOf <RefsVolumeHeader>() / imagePlugin.Info.SectorSize);

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

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

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

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

            RefsVolumeHeader refsVhdr = Marshal.ByteArrayToStructureLittleEndian <RefsVolumeHeader>(sector);

            return(refsVhdr.identifier == FSRS && ArrayHelpers.ArrayIsNullOrEmpty(refsVhdr.mustBeZero) &&
                   refsVhdr.signature.SequenceEqual(refsSignature));
        }
Esempio n. 7
0
        public bool GetInformation(IMediaImage imagePlugin, out List <Partition> partitions, ulong sectorOffset)
        {
            partitions = null;
            byte[] sector = imagePlugin.ReadSector(sectorOffset);

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

            RioKarmaTable table = Marshal.ByteArrayToStructureLittleEndian <RioKarmaTable>(sector);

            if (table.magic != KARMA_MAGIC)
            {
                return(false);
            }

            ulong counter = 0;

            partitions = (from entry in table.entries let part = new Partition
            {
                Start = entry.offset, Offset = (ulong)(entry.offset * sector.Length),
                Size = entry.size, Length = (ulong)(entry.size * sector.Length),
                Type = "Rio Karma",
                Sequence = counter++, Scheme = Name
            } where entry.type == ENTRY_MAGIC select part).ToList();

            return(true);
        }
Esempio n. 8
0
        public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
                                   Encoding encoding)
        {
            // Technically everything on Plan 9 from Bell Labs is in UTF-8
            Encoding    = Encoding.UTF8;
            information = "";

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

            ulong hdrSector = HEADER_POS / imagePlugin.Info.SectorSize;

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

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

            var sb = new StringBuilder();

            sb.AppendLine("Fossil");
            sb.AppendFormat("Filesystem version {0}", hdr.version).AppendLine();
            sb.AppendFormat("{0} bytes per block", hdr.blockSize).AppendLine();
            sb.AppendFormat("Superblock resides in block {0}", hdr.super).AppendLine();
            sb.AppendFormat("Labels resides in block {0}", hdr.label).AppendLine();
            sb.AppendFormat("Data starts at block {0}", hdr.data).AppendLine();
            sb.AppendFormat("Volume has {0} blocks", hdr.end).AppendLine();

            ulong sbLocation = (hdr.super * (hdr.blockSize / imagePlugin.Info.SectorSize)) + partition.Start;

            XmlFsType = new FileSystemType
            {
                Type = "Fossil filesystem", ClusterSize = hdr.blockSize, Clusters = hdr.end
            };

            if (sbLocation <= partition.End)
            {
                sector = imagePlugin.ReadSector(sbLocation);
                FossilSuperBlock fsb = Marshal.ByteArrayToStructureBigEndian <FossilSuperBlock>(sector);

                AaruConsole.DebugWriteLine("Fossil plugin", "magic 0x{0:X8} (expected 0x{1:X8})", fsb.magic,
                                           FOSSIL_SB_MAGIC);

                if (fsb.magic == FOSSIL_SB_MAGIC)
                {
                    sb.AppendFormat("Epoch low {0}", fsb.epochLow).AppendLine();
                    sb.AppendFormat("Epoch high {0}", fsb.epochHigh).AppendLine();
                    sb.AppendFormat("Next QID {0}", fsb.qid).AppendLine();
                    sb.AppendFormat("Active root block {0}", fsb.active).AppendLine();
                    sb.AppendFormat("Next root block {0}", fsb.next).AppendLine();
                    sb.AppendFormat("Curren root block {0}", fsb.current).AppendLine();
                    sb.AppendFormat("Volume label: \"{0}\"", StringHandlers.CToString(fsb.name, Encoding)).AppendLine();
                    XmlFsType.VolumeName = StringHandlers.CToString(fsb.name, Encoding);
                }
            }

            information = sb.ToString();
        }
Esempio n. 9
0
        public bool Identify(IMediaImage imagePlugin, Partition partition)
        {
            if (partition.Start >= partition.End)
            {
                return(false);
            }

            ulong sbSectorOff  = 0x10000 / imagePlugin.Info.SectorSize;
            uint  sbSectorSize = 0x1000 / imagePlugin.Info.SectorSize;

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

            byte[]     sector = imagePlugin.ReadSectors(sbSectorOff + partition.Start, sbSectorSize);
            SuperBlock btrfsSb;

            try
            {
                btrfsSb = Marshal.ByteArrayToStructureLittleEndian <SuperBlock>(sector);
            }
            catch
            {
                return(false);
            }

            AaruConsole.DebugWriteLine("BTRFS Plugin", "sbSectorOff = {0}", sbSectorOff);
            AaruConsole.DebugWriteLine("BTRFS Plugin", "sbSectorSize = {0}", sbSectorSize);
            AaruConsole.DebugWriteLine("BTRFS Plugin", "partition.PartitionStartSector = {0}", partition.Start);
            AaruConsole.DebugWriteLine("BTRFS Plugin", "btrfsSb.magic = 0x{0:X16}", btrfsSb.magic);

            return(btrfsSb.magic == BTRFS_MAGIC);
        }
Esempio n. 10
0
        public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
                                   Encoding encoding)
        {
            Encoding = encoding ?? Encoding.GetEncoding("iso-8859-1");
            byte[] sector = imagePlugin.ReadSector(6);

            var sbInformation = new StringBuilder();

            VolumeLabel vol = Marshal.ByteArrayToStructureLittleEndian <VolumeLabel>(sector);

            sbInformation.AppendLine("ECMA-67");

            sbInformation.AppendFormat("Volume name: {0}", Encoding.ASCII.GetString(vol.volumeIdentifier)).AppendLine();
            sbInformation.AppendFormat("Volume owner: {0}", Encoding.ASCII.GetString(vol.owner)).AppendLine();

            XmlFsType = new FileSystemType
            {
                Type        = "ECMA-67",
                ClusterSize = 256,
                Clusters    = (partition.End - partition.Start) + 1,
                VolumeName  = Encoding.ASCII.GetString(vol.volumeIdentifier)
            };

            information = sbInformation.ToString();
        }
Esempio n. 11
0
        static dk_label16 SwapDiskLabel(dk_label16 label)
        {
            AaruConsole.DebugWriteLine("Sun plugin", "Swapping dk_label16");
            label = (dk_label16)Marshal.SwapStructureMembersEndian(label);

            for (int i = 0; i < label.dkl_vtoc.v_bootinfo.Length; i++)
            {
                label.dkl_vtoc.v_bootinfo[i] = Swapping.Swap(label.dkl_vtoc.v_bootinfo[i]);
            }

            for (int i = 0; i < label.dkl_vtoc.v_part.Length; i++)
            {
                label.dkl_vtoc.v_part[i].p_flag  = (SunFlags)Swapping.Swap((ushort)label.dkl_vtoc.v_part[i].p_flag);
                label.dkl_vtoc.v_part[i].p_tag   = (SunTag)Swapping.Swap((ushort)label.dkl_vtoc.v_part[i].p_tag);
                label.dkl_vtoc.v_part[i].p_size  = Swapping.Swap(label.dkl_vtoc.v_part[i].p_size);
                label.dkl_vtoc.v_part[i].p_start = Swapping.Swap(label.dkl_vtoc.v_part[i].p_start);
            }

            for (int i = 0; i < label.dkl_vtoc.v_timestamp.Length; i++)
            {
                label.dkl_vtoc.v_timestamp[i] = Swapping.Swap(label.dkl_vtoc.v_timestamp[i]);
            }

            for (int i = 0; i < label.dkl_vtoc.v_reserved.Length; i++)
            {
                label.dkl_vtoc.v_reserved[i] = Swapping.Swap(label.dkl_vtoc.v_reserved[i]);
            }

            return(label);
        }
Esempio n. 12
0
        public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
                                   Encoding encoding)
        {
            Encoding = Encoding.GetEncoding("koi8-r");
            byte[]          sector = imagePlugin.ReadSector(0);
            AODOS_BootBlock bb     = Marshal.ByteArrayToStructureLittleEndian <AODOS_BootBlock>(sector);

            var sbInformation = new StringBuilder();

            sbInformation.AppendLine("Alexander Osipov DOS file system");

            XmlFsType = new FileSystemType
            {
                Type           = "Alexander Osipov DOS file system",
                Clusters       = imagePlugin.Info.Sectors,
                ClusterSize    = imagePlugin.Info.SectorSize, Files = bb.files,
                FilesSpecified = true,
                FreeClusters   = imagePlugin.Info.Sectors - bb.usedSectors, FreeClustersSpecified = true,
                VolumeName     = StringHandlers.SpacePaddedToString(bb.volumeLabel, Encoding), Bootable = true
            };

            sbInformation.AppendFormat("{0} files on volume", bb.files).AppendLine();
            sbInformation.AppendFormat("{0} used sectors on volume", bb.usedSectors).AppendLine();

            sbInformation.AppendFormat("Disk name: {0}", StringHandlers.CToString(bb.volumeLabel, Encoding)).
            AppendLine();

            information = sbInformation.ToString();
        }
Esempio n. 13
0
        public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
                                   Encoding encoding)
        {
            // Always Shift-JIS
            Encoding    = Encoding.GetEncoding("shift_jis");
            information = "";

            byte[]     sector = imagePlugin.ReadSectors(partition.Start, 2);
            PcfxHeader header = Marshal.ByteArrayToStructureLittleEndian <PcfxHeader>(sector);

            string   date;
            DateTime dateTime = DateTime.MinValue;

            try
            {
                date = Encoding.GetString(header.date);
                int year  = int.Parse(date.Substring(0, 4));
                int month = int.Parse(date.Substring(4, 2));
                int day   = int.Parse(date.Substring(6, 2));
                dateTime = new DateTime(year, month, day);
            }
            catch
            {
                date = null;
            }

            var sb = new StringBuilder();

            sb.AppendLine("PC-FX executable:");
            sb.AppendFormat("Identifier: {0}", StringHandlers.CToString(header.signature, Encoding)).AppendLine();
            sb.AppendFormat("Copyright: {0}", StringHandlers.CToString(header.copyright, Encoding)).AppendLine();
            sb.AppendFormat("Title: {0}", StringHandlers.CToString(header.title, Encoding)).AppendLine();
            sb.AppendFormat("Maker ID: {0}", StringHandlers.CToString(header.makerId, Encoding)).AppendLine();
            sb.AppendFormat("Maker name: {0}", StringHandlers.CToString(header.makerName, Encoding)).AppendLine();
            sb.AppendFormat("Volume number: {0}", header.volumeNumber).AppendLine();
            sb.AppendFormat("Country code: {0}", header.country).AppendLine();
            sb.AppendFormat("Version: {0}.{1}", header.minorVersion, header.majorVersion).AppendLine();

            if (date != null)
            {
                sb.AppendFormat("Dated {0}", dateTime).AppendLine();
            }

            sb.AppendFormat("Load {0} sectors from sector {1}", header.loadCount, header.loadOffset).AppendLine();

            sb.AppendFormat("Load at 0x{0:X8} and jump to 0x{1:X8}", header.loadAddress, header.entryPoint).
            AppendLine();

            information = sb.ToString();

            XmlFsType = new FileSystemType
            {
                Type                = "PC-FX", Clusters = partition.Length, ClusterSize = 2048,
                Bootable            = true,
                CreationDate        = dateTime, CreationDateSpecified = date != null,
                PublisherIdentifier = StringHandlers.CToString(header.makerName, Encoding),
                VolumeName          = StringHandlers.CToString(header.title, Encoding), SystemIdentifier = "PC-FX"
            };
        }
Esempio n. 14
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       = Marshal.ByteArrayToStructureBigEndian <RootBlock>(rootBlockSector);

            var 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 = rootBlock.blocksize,
                Type = "SmartFileSystem"
            };
        }
Esempio n. 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 < 512)
            {
                return;
            }

            uint sbAddr = REISER4_SUPER_OFFSET / imagePlugin.Info.SectorSize;

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

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

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

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

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

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

            if (!reiser4_magic.SequenceEqual(reiserSb.magic))
            {
                return;
            }

            var sb = new StringBuilder();

            sb.AppendLine("Reiser 4 filesystem");
            sb.AppendFormat("{0} bytes per block", reiserSb.blocksize).AppendLine();
            sb.AppendFormat("Volume disk format: {0}", reiserSb.diskformat).AppendLine();
            sb.AppendFormat("Volume UUID: {0}", reiserSb.uuid).AppendLine();
            sb.AppendFormat("Volume name: {0}", StringHandlers.CToString(reiserSb.label, Encoding)).AppendLine();

            information = sb.ToString();

            XmlFsType = new FileSystemType
            {
                Type       = "Reiser 4 filesystem", ClusterSize = reiserSb.blocksize,
                Clusters   = ((partition.End - partition.Start) * imagePlugin.Info.SectorSize) / reiserSb.blocksize,
                VolumeName = StringHandlers.CToString(reiserSb.label, Encoding), VolumeSerial = reiserSb.uuid.ToString()
            };
        }
Esempio n. 16
0
        public bool Close()
        {
            if (!IsWriting)
            {
                ErrorMessage = "Image is not opened for writing";

                return(false);
            }

            if ((_imageInfo.MediaType == MediaType.Unknown || _imageInfo.MediaType == MediaType.GENERIC_HDD ||
                 _imageInfo.MediaType == MediaType.FlashDrive || _imageInfo.MediaType == MediaType.CompactFlash ||
                 _imageInfo.MediaType == MediaType.CompactFlashType2 || _imageInfo.MediaType == MediaType.PCCardTypeI ||
                 _imageInfo.MediaType == MediaType.PCCardTypeII || _imageInfo.MediaType == MediaType.PCCardTypeIII ||
                 _imageInfo.MediaType == MediaType.PCCardTypeIV) &&
                _fdihdr.cylinders == 0)
            {
                _fdihdr.cylinders = (int)(_imageInfo.Sectors / 8 / 33);
                _fdihdr.heads     = 8;
                _fdihdr.spt       = 33;

                while (_fdihdr.cylinders == 0)
                {
                    _fdihdr.heads--;

                    if (_fdihdr.heads == 0)
                    {
                        _fdihdr.spt--;
                        _fdihdr.heads = 8;
                    }

                    _fdihdr.cylinders = (int)_imageInfo.Sectors / _fdihdr.heads / _fdihdr.spt;

                    if (_fdihdr.cylinders == 0 &&
                        _fdihdr.heads == 0 &&
                        _fdihdr.spt == 0)
                    {
                        break;
                    }
                }
            }

            byte[] hdr = new byte[Marshal.SizeOf <Anex86Header>()];
            MemoryMarshal.Write(hdr, ref _fdihdr);

            _writingStream.Seek(0, SeekOrigin.Begin);
            _writingStream.Write(hdr, 0, hdr.Length);

            _writingStream.Flush();
            _writingStream.Close();

            IsWriting    = false;
            ErrorMessage = "";

            return(true);
        }
Esempio n. 17
0
        /// <summary>Decodes an IP.BIN sector in Saturn format</summary>
        /// <param name="ipbin_sector">IP.BIN sector</param>
        /// <returns>Decoded IP.BIN</returns>
        public static IPBin?DecodeIPBin(byte[] ipbin_sector)
        {
            if (ipbin_sector == null)
            {
                return(null);
            }

            if (ipbin_sector.Length < 512)
            {
                return(null);
            }

            IPBin ipbin = Marshal.ByteArrayToStructureLittleEndian <IPBin>(ipbin_sector);

            AaruConsole.DebugWriteLine("Saturn IP.BIN Decoder", "saturn_ipbin.maker_id = \"{0}\"",
                                       Encoding.ASCII.GetString(ipbin.maker_id));

            AaruConsole.DebugWriteLine("Saturn IP.BIN Decoder", "saturn_ipbin.product_no = \"{0}\"",
                                       Encoding.ASCII.GetString(ipbin.product_no));

            AaruConsole.DebugWriteLine("Saturn IP.BIN Decoder", "saturn_ipbin.product_version = \"{0}\"",
                                       Encoding.ASCII.GetString(ipbin.product_version));

            AaruConsole.DebugWriteLine("Saturn IP.BIN Decoder", "saturn_ipbin.release_datedate = \"{0}\"",
                                       Encoding.ASCII.GetString(ipbin.release_date));

            AaruConsole.DebugWriteLine("Saturn IP.BIN Decoder", "saturn_ipbin.saturn_media = \"{0}\"",
                                       Encoding.ASCII.GetString(ipbin.saturn_media));

            AaruConsole.DebugWriteLine("Saturn IP.BIN Decoder", "saturn_ipbin.disc_no = {0}", (char)ipbin.disc_no);

            AaruConsole.DebugWriteLine("Saturn IP.BIN Decoder", "saturn_ipbin.disc_no_separator = \"{0}\"",
                                       (char)ipbin.disc_no_separator);

            AaruConsole.DebugWriteLine("Saturn IP.BIN Decoder", "saturn_ipbin.disc_total_nos = {0}",
                                       (char)ipbin.disc_total_nos);

            AaruConsole.DebugWriteLine("Saturn IP.BIN Decoder", "saturn_ipbin.release_date = \"{0}\"",
                                       Encoding.ASCII.GetString(ipbin.release_date));

            AaruConsole.DebugWriteLine("Saturn IP.BIN Decoder", "saturn_ipbin.spare_space1 = \"{0}\"",
                                       Encoding.ASCII.GetString(ipbin.spare_space1));

            AaruConsole.DebugWriteLine("Saturn IP.BIN Decoder", "saturn_ipbin.region_codes = \"{0}\"",
                                       Encoding.ASCII.GetString(ipbin.region_codes));

            AaruConsole.DebugWriteLine("Saturn IP.BIN Decoder", "saturn_ipbin.peripherals = \"{0}\"",
                                       Encoding.ASCII.GetString(ipbin.peripherals));

            AaruConsole.DebugWriteLine("Saturn IP.BIN Decoder", "saturn_ipbin.product_name = \"{0}\"",
                                       Encoding.ASCII.GetString(ipbin.product_name));

            return(Encoding.ASCII.GetString(ipbin.SegaHardwareID) == "SEGA SEGASATURN " ? ipbin : (IPBin?)null);
        }
Esempio n. 18
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 <RBF_IdSector>() / imagePlugin.Info.SectorSize);

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

                RBF_IdSector    rbfSb     = Marshal.ByteArrayToStructureBigEndian <RBF_IdSector>(sector);
                RBF_NewIdSector rbf9000Sb = Marshal.ByteArrayToStructureBigEndian <RBF_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);
        }
Esempio n. 19
0
        public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
                                   Encoding encoding)
        {
            Encoding    = encoding ?? Encoding.GetEncoding("iso-8859-15");
            information = "";

            var sb = new StringBuilder();

            int  sbSizeInBytes   = Marshal.SizeOf <XiaSuperBlock>();
            uint sbSizeInSectors = (uint)(sbSizeInBytes / imagePlugin.Info.SectorSize);

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

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

            sb.AppendFormat("{0} bytes per zone", supblk.s_zone_size).AppendLine();

            sb.AppendFormat("{0} zones in volume ({1} bytes)", supblk.s_nzones, supblk.s_nzones * supblk.s_zone_size).
            AppendLine();

            sb.AppendFormat("{0} inodes", supblk.s_ninodes).AppendLine();

            sb.AppendFormat("{0} data zones ({1} bytes)", supblk.s_ndatazones,
                            supblk.s_ndatazones * supblk.s_zone_size).AppendLine();

            sb.AppendFormat("{0} imap zones ({1} bytes)", supblk.s_imap_zones,
                            supblk.s_imap_zones * supblk.s_zone_size).AppendLine();

            sb.AppendFormat("{0} zmap zones ({1} bytes)", supblk.s_zmap_zones,
                            supblk.s_zmap_zones * supblk.s_zone_size).AppendLine();

            sb.AppendFormat("First data zone: {0}", supblk.s_firstdatazone).AppendLine();

            sb.AppendFormat("Maximum filesize is {0} bytes ({1} MiB)", supblk.s_max_size, supblk.s_max_size / 1048576).
            AppendLine();

            sb.AppendFormat("{0} zones reserved for kernel images ({1} bytes)", supblk.s_kernzones,
                            supblk.s_kernzones * supblk.s_zone_size).AppendLine();

            sb.AppendFormat("First kernel zone: {0}", supblk.s_firstkernzone).AppendLine();

            XmlFsType = new FileSystemType
            {
                Bootable    = !ArrayHelpers.ArrayIsNullOrEmpty(supblk.s_boot_segment), Clusters = supblk.s_nzones,
                ClusterSize = supblk.s_zone_size, Type = "Xia filesystem"
            };

            information = sb.ToString();
        }
Esempio n. 20
0
        public bool GetInformation(IMediaImage imagePlugin, out List <CommonTypes.Partition> partitions,
                                   ulong sectorOffset)
        {
            partitions = new List <CommonTypes.Partition>();

            if (42 + sectorOffset >= imagePlugin.Info.Sectors)
            {
                return(false);
            }

            byte[] tblsector = imagePlugin.ReadSector(42 + sectorOffset);

            Partable xnxtbl = Marshal.ByteArrayToStructureLittleEndian <Partable>(tblsector);

            AaruConsole.DebugWriteLine("XENIX plugin", "xnxtbl.p_magic = 0x{0:X4} (should be 0x{1:X4})", xnxtbl.p_magic,
                                       PAMAGIC);

            if (xnxtbl.p_magic != PAMAGIC)
            {
                return(false);
            }

            for (int i = 0; i < MAXPARTS; i++)
            {
                AaruConsole.DebugWriteLine("XENIX plugin", "xnxtbl.p[{0}].p_off = {1}", i, xnxtbl.p[i].p_off);
                AaruConsole.DebugWriteLine("XENIX plugin", "xnxtbl.p[{0}].p_size = {1}", i, xnxtbl.p[i].p_size);

                if (xnxtbl.p[i].p_size <= 0)
                {
                    continue;
                }

                var part = new CommonTypes.Partition
                {
                    Start = ((ulong)((xnxtbl.p[i].p_off + XENIX_OFFSET) * XENIX_BSIZE) / imagePlugin.Info.SectorSize) +
                            sectorOffset,
                    Length = (ulong)(xnxtbl.p[i].p_size * XENIX_BSIZE) / imagePlugin.Info.SectorSize,
                    Offset = (ulong)((xnxtbl.p[i].p_off + XENIX_OFFSET) * XENIX_BSIZE) +
                             (imagePlugin.Info.SectorSize * sectorOffset),
                    Size     = (ulong)(xnxtbl.p[i].p_size * XENIX_BSIZE),
                    Sequence = (ulong)i,
                    Type     = "XENIX",
                    Scheme   = Name
                };

                if (part.End < imagePlugin.Info.Sectors)
                {
                    partitions.Add(part);
                }
            }

            return(partitions.Count > 0);
        }
Esempio n. 21
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);
        }
Esempio n. 22
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);
            }

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

            // Check root directory name
            if (!qnx4_rootDir_fname.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);
        }
Esempio n. 23
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);

            VxSuperBlock vxSb = Marshal.ByteArrayToStructureLittleEndian <VxSuperBlock>(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
            };
        }
Esempio n. 24
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);
                CommodoreHeader cbmHdr = Marshal.ByteArrayToStructureLittleEndian <CommodoreHeader>(sector);

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

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

            return(false);
        }
Esempio n. 25
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);

            RT11HomeBlock homeblock = Marshal.ByteArrayToStructureLittleEndian <RT11HomeBlock>(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();
        }
Esempio n. 26
0
        public bool Identify(IMediaImage imagePlugin, Partition partition)
        {
            if (imagePlugin.Info.SectorSize < 256)
            {
                return(false);
            }

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

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

            return(lifSb.magic == LIF_MAGIC);
        }
Esempio n. 27
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 = Marshal.ByteArrayToStructureBigEndian <AppleSingleHeader>(hdr_b);

            return(header.magic == AppleSingleMagic &&
                   (header.version == AppleSingleVersion || header.version == AppleSingleVersion2));
        }
Esempio n. 28
0
        public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
                                   Encoding encoding)
        {
            Encoding = Encoding.UTF8;
            var sbInformation = new StringBuilder();

            XmlFsType   = new FileSystemType();
            information = "";

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

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

            try
            {
                nxSb = Marshal.ByteArrayToStructureLittleEndian <ContainerSuperBlock>(sector);
            }
            catch
            {
                return;
            }

            if (nxSb.magic != APFS_CONTAINER_MAGIC)
            {
                return;
            }

            sbInformation.AppendLine("Apple File System");
            sbInformation.AppendLine();
            sbInformation.AppendFormat("{0} bytes per block", nxSb.blockSize).AppendLine();

            sbInformation.AppendFormat("Container has {0} bytes in {1} blocks", nxSb.containerBlocks * nxSb.blockSize,
                                       nxSb.containerBlocks).AppendLine();

            information = sbInformation.ToString();

            XmlFsType = new FileSystemType
            {
                Bootable    = false,
                Clusters    = nxSb.containerBlocks,
                ClusterSize = nxSb.blockSize,
                Type        = "Apple File System"
            };
        }
Esempio n. 29
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 = Marshal.ByteArrayToStructureBigEndian <AppleSingleHeader>(hdr_b);

            return(header.magic == AppleSingleMagic &&
                   (header.version == AppleSingleVersion || header.version == AppleSingleVersion2));
        }
Esempio n. 30
0
        public void Close()
        {
            var cmdPkt = new AaruPacketCmdClose
            {
                hdr = new AaruPacketHeader
                {
                    remote_id  = Consts.RemoteId, packet_id = Consts.PacketId,
                    len        = (uint)Marshal.SizeOf <AaruPacketCmdClose>(), version = Consts.PacketVersion,
                    packetType = AaruPacketType.CommandCloseDevice
                }
            };

            byte[] buf = Marshal.StructureToByteArrayLittleEndian(cmdPkt);

            _socket.Send(buf, SocketFlags.None);
        }