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); }
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); }
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); }
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; } var rbfSb = new IdSector(); var rbf9000Sb = new NewIdSector(); 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++; } byte[] sector = imagePlugin.ReadSectors(partition.Start + location, sbSize); if (sector.Length < Marshal.SizeOf <IdSector>()) { return; } rbfSb = Marshal.ByteArrayToStructureBigEndian <IdSector>(sector); 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) { 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 = (NewIdSector)Marshal.SwapStructureMembersEndian(rbf9000Sb); } var 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 = (uint)(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(); }
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 = Marshal.ByteArrayToStructureBigEndian <SGILabel>(sector); for (int i = 0; i < dvh.volume.Length; i++) { dvh.volume[i] = (SGIVolume)Marshal.SwapStructureMembersEndian(dvh.volume[i]); } for (int i = 0; i < dvh.partitions.Length; i++) { dvh.partitions[i] = (SGIPartition)Marshal.SwapStructureMembersEndian(dvh.partitions[i]); } AaruConsole.DebugWriteLine("SGIVH plugin", "dvh.magic = 0x{0:X8} (should be 0x{1:X8})", dvh.magic, SGI_MAGIC); if (dvh.magic != SGI_MAGIC) { return(false); } AaruConsole.DebugWriteLine("SGIVH plugin", "dvh.root_part_num = {0}", dvh.root_part_num); AaruConsole.DebugWriteLine("SGIVH plugin", "dvh.swap_part_num = {0}", dvh.swap_part_num); AaruConsole.DebugWriteLine("SGIVH plugin", "dvh.boot_file = \"{0}\"", StringHandlers.CToString(dvh.boot_file)); AaruConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_skew = {0}", dvh.device_params.dp_skew); AaruConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_gap1 = {0}", dvh.device_params.dp_gap1); AaruConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_gap2 = {0}", dvh.device_params.dp_gap2); AaruConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_spares_cyl = {0}", dvh.device_params.dp_spares_cyl); AaruConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_cyls = {0}", dvh.device_params.dp_cyls); AaruConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_shd0 = {0}", dvh.device_params.dp_shd0); AaruConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_trks0 = {0}", dvh.device_params.dp_trks0); AaruConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_ctq_depth = {0}", dvh.device_params.dp_ctq_depth); AaruConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_cylshi = {0}", dvh.device_params.dp_cylshi); AaruConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_secs = {0}", dvh.device_params.dp_secs); AaruConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_secbytes = {0}", dvh.device_params.dp_secbytes); AaruConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_interleave = {0}", dvh.device_params.dp_interleave); AaruConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_flags = {0}", dvh.device_params.dp_flags); AaruConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_datarate = {0}", dvh.device_params.dp_datarate); AaruConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_nretries = {0}", dvh.device_params.dp_nretries); AaruConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_mspw = {0}", dvh.device_params.dp_mspw); AaruConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_xgap1 = {0}", dvh.device_params.dp_xgap1); AaruConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_xsync = {0}", dvh.device_params.dp_xsync); AaruConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_xrdly = {0}", dvh.device_params.dp_xrdly); AaruConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_xgap2 = {0}", dvh.device_params.dp_xgap2); AaruConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_xrgate = {0}", dvh.device_params.dp_xrgate); AaruConsole.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++) { AaruConsole.DebugWriteLine("SGIVH plugin", "dvh.partitions[{0}].num_blocks = {1}", i, dvh.partitions[i].num_blocks); AaruConsole.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); AaruConsole.DebugWriteLine("SGIVH plugin", "dvh.partitions[{0}].type = {1}", i, dvh.partitions[i].type); var 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); }
public bool GetInformation(IMediaImage imagePlugin, out List <Partition> partitions, ulong sectorOffset) { partitions = new List <Partition>(); byte[] sector; ulong sectsPerUnit; AaruConsole.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); } Table table = Marshal.ByteArrayToStructureBigEndian <Table>(sector); AaruConsole.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] = (Entry)Marshal.SwapStructureMembersEndian(table.entries[i]); } AaruConsole.DebugWriteLine("Human68k plugin", "table.size = {0:X4}", table.size); AaruConsole.DebugWriteLine("Human68k plugin", "table.size2 = {0:X4}", table.size2); AaruConsole.DebugWriteLine("Human68k plugin", "table.unknown = {0:X4}", table.unknown); ulong counter = 0; foreach (Entry entry in table.entries) { AaruConsole.DebugWriteLine("Human68k plugin", "entry.name = {0}", StringHandlers.CToString(entry.name, Encoding.GetEncoding(932))); AaruConsole.DebugWriteLine("Human68k plugin", "entry.stateStart = {0}", entry.stateStart); AaruConsole.DebugWriteLine("Human68k plugin", "entry.length = {0}", entry.length); AaruConsole.DebugWriteLine("Human68k plugin", "sectsPerUnit = {0} {1}", sectsPerUnit, imagePlugin.Info.SectorSize); var 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); }