コード例 #1
0
ファイル: Sun.cs プロジェクト: fossabot/DiscImageChef
        static dk_label16 SwapDiskLabel(dk_label16 label)
        {
            DicConsole.DebugWriteLine("Sun plugin", "Swapping dk_label16");
            dk_label16 lebal = (dk_label16)BigEndianMarshal.SwapStructureMembersEndian(label);

            for (int i = 0; i < label.dkl_vtoc.v_bootinfo.Length; i++)
            {
                lebal.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++)
            {
                lebal.dkl_vtoc.v_part[i].p_flag  = (SunFlags)Swapping.Swap((ushort)label.dkl_vtoc.v_part[i].p_flag);
                lebal.dkl_vtoc.v_part[i].p_tag   = (SunTag)Swapping.Swap((ushort)label.dkl_vtoc.v_part[i].p_tag);
                lebal.dkl_vtoc.v_part[i].p_size  = Swapping.Swap(label.dkl_vtoc.v_part[i].p_size);
                lebal.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++)
            {
                lebal.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++)
            {
                lebal.dkl_vtoc.v_reserved[i] = Swapping.Swap(label.dkl_vtoc.v_reserved[i]);
            }

            return(lebal);
        }
コード例 #2
0
ファイル: Sun.cs プロジェクト: fossabot/DiscImageChef
        static dk_label SwapDiskLabel(dk_label label)
        {
            DicConsole.DebugWriteLine("Sun plugin", "Swapping dk_label");
            dk_label lebal = (dk_label)BigEndianMarshal.SwapStructureMembersEndian(label);

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

            return(lebal);
        }
コード例 #3
0
        static DiskLabel SwapDiskLabel(DiskLabel disklabel)
        {
            DiskLabel dl =
                (DiskLabel)BigEndianMarshal.SwapStructureMembersEndian(disklabel);

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

            return(dl);
        }
コード例 #4
0
ファイル: SGI.cs プロジェクト: fossabot/DiscImageChef
        public bool GetInformation(IMediaImage imagePlugin, out List <Partition> partitions, ulong sectorOffset)
        {
            partitions = new List <Partition>();

            byte[] sector = imagePlugin.ReadSector(sectorOffset);
            if (sector.Length < 512)
            {
                return(false);
            }

            SGILabel dvh = BigEndianMarshal.ByteArrayToStructureBigEndian <SGILabel>(sector);

            for (int i = 0; i < dvh.volume.Length; i++)
            {
                dvh.volume[i] = (SGIVolume)BigEndianMarshal.SwapStructureMembersEndian(dvh.volume[i]);
            }
            for (int i = 0; i < dvh.partitions.Length; i++)
            {
                dvh.partitions[i] = (SGIPartition)BigEndianMarshal.SwapStructureMembersEndian(dvh.partitions[i]);
            }

            DicConsole.DebugWriteLine("SGIVH plugin", "dvh.magic = 0x{0:X8} (should be 0x{1:X8})", dvh.magic,
                                      SGI_MAGIC);

            if (dvh.magic != SGI_MAGIC)
            {
                return(false);
            }

            DicConsole.DebugWriteLine("SGIVH plugin", "dvh.root_part_num = {0}", dvh.root_part_num);
            DicConsole.DebugWriteLine("SGIVH plugin", "dvh.swap_part_num = {0}", dvh.swap_part_num);
            DicConsole.DebugWriteLine("SGIVH plugin", "dvh.boot_file = \"{0}\"",
                                      StringHandlers.CToString(dvh.boot_file));
            DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_skew = {0}", dvh.device_params.dp_skew);
            DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_gap1 = {0}", dvh.device_params.dp_gap1);
            DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_gap2 = {0}", dvh.device_params.dp_gap2);
            DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_spares_cyl = {0}",
                                      dvh.device_params.dp_spares_cyl);
            DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_cyls = {0}", dvh.device_params.dp_cyls);
            DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_shd0 = {0}", dvh.device_params.dp_shd0);
            DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_trks0 = {0}", dvh.device_params.dp_trks0);
            DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_ctq_depth = {0}",
                                      dvh.device_params.dp_ctq_depth);
            DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_cylshi = {0}", dvh.device_params.dp_cylshi);
            DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_secs = {0}", dvh.device_params.dp_secs);
            DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_secbytes = {0}",
                                      dvh.device_params.dp_secbytes);
            DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_interleave = {0}",
                                      dvh.device_params.dp_interleave);
            DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_flags = {0}", dvh.device_params.dp_flags);
            DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_datarate = {0}",
                                      dvh.device_params.dp_datarate);
            DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_nretries = {0}",
                                      dvh.device_params.dp_nretries);
            DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_mspw = {0}", dvh.device_params.dp_mspw);
            DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_xgap1 = {0}", dvh.device_params.dp_xgap1);
            DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_xsync = {0}", dvh.device_params.dp_xsync);
            DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_xrdly = {0}", dvh.device_params.dp_xrdly);
            DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_xgap2 = {0}", dvh.device_params.dp_xgap2);
            DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_xrgate = {0}", dvh.device_params.dp_xrgate);
            DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_xwcont = {0}", dvh.device_params.dp_xwcont);

            ulong counter = 0;

            for (int i = 0; i < dvh.partitions.Length; i++)
            {
                DicConsole.DebugWriteLine("SGIVH plugin", "dvh.partitions[{0}].num_blocks = {1}", i,
                                          dvh.partitions[i].num_blocks);
                DicConsole.DebugWriteLine("SGIVH plugin", "dvh.partitions[{0}].first_block = {1}", i,
                                          dvh.partitions[i].first_block);
                // TODO: Solve big endian marshal with enumerations
                dvh.partitions[i].type = (SGIType)Swapping.Swap((uint)dvh.partitions[i].type);
                DicConsole.DebugWriteLine("SGIVH plugin", "dvh.partitions[{0}].type = {1}", i, dvh.partitions[i].type);

                Partition part = new Partition
                {
                    Start =
                        dvh.partitions[i].first_block * dvh.device_params.dp_secbytes / imagePlugin.Info.SectorSize,
                    Offset = dvh.partitions[i].first_block * dvh.device_params.dp_secbytes,
                    Length = dvh.partitions[i].num_blocks * dvh.device_params.dp_secbytes /
                             imagePlugin.Info.SectorSize,
                    Size     = dvh.partitions[i].num_blocks * dvh.device_params.dp_secbytes,
                    Type     = TypeToString(dvh.partitions[i].type),
                    Sequence = counter,
                    Scheme   = Name
                };
                if (part.Size <= 0 || dvh.partitions[i].type == SGIType.Header ||
                    dvh.partitions[i].type == SGIType.Volume)
                {
                    continue;
                }

                partitions.Add(part);
                counter++;
            }

            return(true);
        }
コード例 #5
0
ファイル: RBF.cs プロジェクト: theMK2k/DiscImageChef
        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;
            }

            RBF_IdSector    rbfSb     = new RBF_IdSector();
            RBF_NewIdSector rbf9000Sb = new RBF_NewIdSector();

            foreach (ulong location in new[] { 0, 4, 15 })
            {
                uint sbSize = (uint)(Marshal.SizeOf(rbfSb) / imagePlugin.Info.SectorSize);
                if (Marshal.SizeOf(rbfSb) % imagePlugin.Info.SectorSize != 0)
                {
                    sbSize++;
                }

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

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

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

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

            if (rbfSb.dd_sync != RBF_SYNC && rbf9000Sb.rid_sync != RBF_SYNC && rbf9000Sb.rid_sync != RBF_CNYS)
            {
                return;
            }

            if (rbf9000Sb.rid_sync == RBF_CNYS)
            {
                rbf9000Sb = (RBF_NewIdSector)BigEndianMarshal.SwapStructureMembersEndian(rbf9000Sb);
            }

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("OS-9 Random Block File");

            if (rbf9000Sb.rid_sync == RBF_SYNC)
            {
                sb.AppendFormat("Volume ID: {0:X8}", rbf9000Sb.rid_diskid).AppendLine();
                sb.AppendFormat("{0} blocks in volume", rbf9000Sb.rid_totblocks).AppendLine();
                sb.AppendFormat("{0} cylinders", rbf9000Sb.rid_cylinders).AppendLine();
                sb.AppendFormat("{0} blocks in cylinder 0", rbf9000Sb.rid_cyl0size).AppendLine();
                sb.AppendFormat("{0} blocks per cylinder", rbf9000Sb.rid_cylsize).AppendLine();
                sb.AppendFormat("{0} heads", rbf9000Sb.rid_heads).AppendLine();
                sb.AppendFormat("{0} bytes per block", rbf9000Sb.rid_blocksize).AppendLine();
                // TODO: Convert to flags?
                sb.AppendLine((rbf9000Sb.rid_format & 0x01) == 0x01 ? "Disk is double sided" : "Disk is single sided");
                sb.AppendLine((rbf9000Sb.rid_format & 0x02) == 0x02
                                  ? "Disk is double density"
                                  : "Disk is single density");
                if ((rbf9000Sb.rid_format & 0x10) == 0x10)
                {
                    sb.AppendLine("Disk is 384 TPI");
                }
                else if ((rbf9000Sb.rid_format & 0x08) == 0x08)
                {
                    sb.AppendLine("Disk is 192 TPI");
                }
                else if ((rbf9000Sb.rid_format & 0x04) == 0x04)
                {
                    sb.AppendLine("Disk is 96 TPI or 135 TPI");
                }
                else
                {
                    sb.AppendLine("Disk is 48 TPI");
                }
                sb.AppendFormat("Allocation bitmap descriptor starts at block {0}",
                                rbf9000Sb.rid_bitmap == 0 ? 1 : rbf9000Sb.rid_bitmap).AppendLine();
                if (rbf9000Sb.rid_firstboot > 0)
                {
                    sb.AppendFormat("Debugger descriptor starts at block {0}", rbf9000Sb.rid_firstboot).AppendLine();
                }
                if (rbf9000Sb.rid_bootfile > 0)
                {
                    sb.AppendFormat("Boot file descriptor starts at block {0}", rbf9000Sb.rid_bootfile).AppendLine();
                }
                sb.AppendFormat("Root directory descriptor starts at block {0}", rbf9000Sb.rid_rootdir).AppendLine();
                sb.AppendFormat("Disk is owned by group {0} user {1}", rbf9000Sb.rid_group, rbf9000Sb.rid_owner)
                .AppendLine();
                sb.AppendFormat("Volume was created on {0}", DateHandlers.UnixToDateTime(rbf9000Sb.rid_ctime))
                .AppendLine();
                sb.AppendFormat("Volume's identification block was last written on {0}",
                                DateHandlers.UnixToDateTime(rbf9000Sb.rid_mtime)).AppendLine();
                sb.AppendFormat("Volume name: {0}", StringHandlers.CToString(rbf9000Sb.rid_name, Encoding))
                .AppendLine();

                XmlFsType = new FileSystemType
                {
                    Type                      = "OS-9 Random Block File",
                    Bootable                  = rbf9000Sb.rid_bootfile > 0,
                    ClusterSize               = rbf9000Sb.rid_blocksize,
                    Clusters                  = rbf9000Sb.rid_totblocks,
                    CreationDate              = DateHandlers.UnixToDateTime(rbf9000Sb.rid_ctime),
                    CreationDateSpecified     = true,
                    ModificationDate          = DateHandlers.UnixToDateTime(rbf9000Sb.rid_mtime),
                    ModificationDateSpecified = true,
                    VolumeName                = StringHandlers.CToString(rbf9000Sb.rid_name, Encoding),
                    VolumeSerial              = $"{rbf9000Sb.rid_diskid:X8}"
                };
            }
            else
            {
                sb.AppendFormat("Volume ID: {0:X4}", rbfSb.dd_dsk).AppendLine();
                sb.AppendFormat("{0} blocks in volume", LSNToUInt32(rbfSb.dd_tot)).AppendLine();
                sb.AppendFormat("{0} tracks", rbfSb.dd_tks).AppendLine();
                sb.AppendFormat("{0} sectors per track", rbfSb.dd_spt).AppendLine();
                sb.AppendFormat("{0} bytes per sector", 256 << rbfSb.dd_lsnsize).AppendLine();
                sb.AppendFormat("{0} sectors per cluster ({1} bytes)", rbfSb.dd_bit,
                                rbfSb.dd_bit * (256 << rbfSb.dd_lsnsize)).AppendLine();
                // TODO: Convert to flags?
                sb.AppendLine((rbfSb.dd_fmt & 0x01) == 0x01 ? "Disk is double sided" : "Disk is single sided");
                sb.AppendLine((rbfSb.dd_fmt & 0x02) == 0x02 ? "Disk is double density" : "Disk is single density");
                if ((rbfSb.dd_fmt & 0x10) == 0x10)
                {
                    sb.AppendLine("Disk is 384 TPI");
                }
                else if ((rbfSb.dd_fmt & 0x08) == 0x08)
                {
                    sb.AppendLine("Disk is 192 TPI");
                }
                else if ((rbfSb.dd_fmt & 0x04) == 0x04)
                {
                    sb.AppendLine("Disk is 96 TPI or 135 TPI");
                }
                else
                {
                    sb.AppendLine("Disk is 48 TPI");
                }
                sb.AppendFormat("Allocation bitmap descriptor starts at block {0}",
                                rbfSb.dd_maplsn == 0 ? 1 : rbfSb.dd_maplsn).AppendLine();
                sb.AppendFormat("{0} bytes in allocation bitmap", rbfSb.dd_map).AppendLine();
                if (LSNToUInt32(rbfSb.dd_bt) > 0 && rbfSb.dd_bsz > 0)
                {
                    sb.AppendFormat("Boot file starts at block {0} and has {1} bytes", LSNToUInt32(rbfSb.dd_bt),
                                    rbfSb.dd_bsz).AppendLine();
                }
                sb.AppendFormat("Root directory descriptor starts at block {0}", LSNToUInt32(rbfSb.dd_dir))
                .AppendLine();
                sb.AppendFormat("Disk is owned by user {0}", rbfSb.dd_own).AppendLine();
                sb.AppendFormat("Volume was created on {0}", DateHandlers.Os9ToDateTime(rbfSb.dd_dat)).AppendLine();
                sb.AppendFormat("Volume attributes: {0:X2}", rbfSb.dd_att).AppendLine();
                sb.AppendFormat("Volume name: {0}", StringHandlers.CToString(rbfSb.dd_nam, Encoding)).AppendLine();
                sb.AppendFormat("Path descriptor options: {0}", StringHandlers.CToString(rbfSb.dd_opt, Encoding))
                .AppendLine();

                XmlFsType = new FileSystemType
                {
                    Type                  = "OS-9 Random Block File",
                    Bootable              = LSNToUInt32(rbfSb.dd_bt) > 0 && rbfSb.dd_bsz > 0,
                    ClusterSize           = rbfSb.dd_bit * (256 << rbfSb.dd_lsnsize),
                    Clusters              = LSNToUInt32(rbfSb.dd_tot),
                    CreationDate          = DateHandlers.Os9ToDateTime(rbfSb.dd_dat),
                    CreationDateSpecified = true,
                    VolumeName            = StringHandlers.CToString(rbfSb.dd_nam, Encoding),
                    VolumeSerial          = $"{rbfSb.dd_dsk:X4}"
                };
            }

            information = sb.ToString();
        }
コード例 #6
0
ファイル: Human68k.cs プロジェクト: fossabot/DiscImageChef
        public bool GetInformation(IMediaImage imagePlugin, out List <Partition> partitions, ulong sectorOffset)
        {
            partitions = new List <Partition>();

            byte[] sector;
            ulong  sectsPerUnit;

            DicConsole.DebugWriteLine("Human68k plugin", "sectorSize = {0}", imagePlugin.Info.SectorSize);

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

            switch (imagePlugin.Info.SectorSize)
            {
            case 256:
                sector       = imagePlugin.ReadSector(4 + sectorOffset);
                sectsPerUnit = 1;
                break;

            case 512:
                sector       = imagePlugin.ReadSector(4 + sectorOffset);
                sectsPerUnit = 2;
                break;

            case 1024:
                sector       = imagePlugin.ReadSector(2 + sectorOffset);
                sectsPerUnit = 1;
                break;

            default: return(false);
            }

            X68kTable table = BigEndianMarshal.ByteArrayToStructureBigEndian <X68kTable>(sector);

            DicConsole.DebugWriteLine("Human68k plugin", "table.magic = {0:X4}", table.magic);

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

            for (int i = 0; i < table.entries.Length; i++)
            {
                table.entries[i] = (X68kEntry)BigEndianMarshal.SwapStructureMembersEndian(table.entries[i]);
            }

            DicConsole.DebugWriteLine("Human68k plugin", "table.size = {0:X4}", table.size);
            DicConsole.DebugWriteLine("Human68k plugin", "table.size2 = {0:X4}", table.size2);
            DicConsole.DebugWriteLine("Human68k plugin", "table.unknown = {0:X4}", table.unknown);

            ulong counter = 0;

            foreach (X68kEntry entry in table.entries)
            {
                DicConsole.DebugWriteLine("Human68k plugin", "entry.name = {0}",
                                          StringHandlers.CToString(entry.name, Encoding.GetEncoding(932)));
                DicConsole.DebugWriteLine("Human68k plugin", "entry.stateStart = {0}", entry.stateStart);
                DicConsole.DebugWriteLine("Human68k plugin", "entry.length = {0}", entry.length);
                DicConsole.DebugWriteLine("Human68k plugin", "sectsPerUnit = {0} {1}", sectsPerUnit,
                                          imagePlugin.Info.SectorSize);

                Partition part = new Partition
                {
                    Start    = (entry.stateStart & 0xFFFFFF) * sectsPerUnit,
                    Length   = entry.length * sectsPerUnit,
                    Type     = StringHandlers.CToString(entry.name, Encoding.GetEncoding(932)),
                    Sequence = counter,
                    Scheme   = Name
                };
                part.Offset = part.Start * (ulong)sector.Length;
                part.Size   = part.Length * (ulong)sector.Length;
                if (entry.length <= 0)
                {
                    continue;
                }

                partitions.Add(part);
                counter++;
            }

            return(true);
        }