static dk_label16 SwapDiskLabel(dk_label16 label) { DicConsole.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); }
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)); }
public bool Close() { if (!IsWriting) { ErrorMessage = "Image is not opened for writing"; return(false); } if (!string.IsNullOrEmpty(imageInfo.Comments)) { vHdr.comments = imageInfo.Comments.Length > 255 ? imageInfo.Comments.Substring(0, 255) : imageInfo.Comments; } if (vHdr.cylinders == 0) { vHdr.cylinders = (uint)(imageInfo.Sectors / 16 / 63); vHdr.heads = 16; vHdr.spt = 63; while (vHdr.cylinders == 0) { vHdr.heads--; if (vHdr.heads == 0) { vHdr.spt--; vHdr.heads = 16; } vHdr.cylinders = (uint)(imageInfo.Sectors / vHdr.heads / vHdr.spt); if (vHdr.cylinders == 0 && vHdr.heads == 0 && vHdr.spt == 0) { break; } } } byte[] hdr = new byte[Marshal.SizeOf <VdiHeader>()]; IntPtr hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf <VdiHeader>()); System.Runtime.InteropServices.Marshal.StructureToPtr(vHdr, hdrPtr, true); System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length); System.Runtime.InteropServices.Marshal.FreeHGlobal(hdrPtr); writingStream.Seek(0, SeekOrigin.Begin); writingStream.Write(hdr, 0, hdr.Length); writingStream.Seek(vHdr.offsetBlocks, SeekOrigin.Begin); writingStream.Write(MemoryMarshal.Cast <uint, byte>(ibm).ToArray(), 0, 4 * ibm.Length); writingStream.Flush(); writingStream.Close(); IsWriting = false; ErrorMessage = ""; return(true); }
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); StringBuilder 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(); }
public void Open(string path) { FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); fs.Seek(0, SeekOrigin.Begin); byte[] hdr_b = new byte[128]; fs.Read(hdr_b, 0, 128); header = Marshal.ByteArrayToStructureBigEndian <MacBinaryHeader>(hdr_b); 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; }
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); }
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("koi8-r"); information = ""; StringBuilder sb = new StringBuilder(); byte[] bk0 = imagePlugin.ReadSector(0 + partition.Start); MicroDosBlock0 block0 = Marshal.ByteArrayToStructureLittleEndian <MicroDosBlock0>(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(); }
public void Open(Stream stream) { stream.Seek(0, SeekOrigin.Begin); byte[] hdr_b = new byte[128]; stream.Read(hdr_b, 0, 128); header = Marshal.ByteArrayToStructureBigEndian <MacBinaryHeader>(hdr_b); 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; this.stream = stream; }
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); }
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-1"); byte[] sector = imagePlugin.ReadSector(6); StringBuilder 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(); }
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); DicConsole.DebugWriteLine("UNICOS plugin", "magic = 0x{0:X16} (expected 0x{1:X16})", unicosSb.s_magic, UNICOS_MAGIC); return(unicosSb.s_magic == UNICOS_MAGIC); }
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); } DicConsole.DebugWriteLine("BTRFS Plugin", "sbSectorOff = {0}", sbSectorOff); DicConsole.DebugWriteLine("BTRFS Plugin", "sbSectorSize = {0}", sbSectorSize); DicConsole.DebugWriteLine("BTRFS Plugin", "partition.PartitionStartSector = {0}", partition.Start); DicConsole.DebugWriteLine("BTRFS Plugin", "btrfsSb.magic = 0x{0:X16}", btrfsSb.magic); return(btrfsSb.magic == BTRFS_MAGIC); }
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); }
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)); }
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); DicConsole.DebugWriteLine("Fossil plugin", "magic at 0x{0:X8} (expected 0x{1:X8})", hdr.magic, FOSSIL_HDR_MAGIC); StringBuilder 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); DicConsole.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(); }
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); DicConsole.DebugWriteLine("SegaCD IP.BIN Decoder", "segacd_ipbin.volume_name = \"{0}\"", Encoding.ASCII.GetString(ipbin.volume_name)); DicConsole.DebugWriteLine("SegaCD IP.BIN Decoder", "segacd_ipbin.system_name = \"{0}\"", Encoding.ASCII.GetString(ipbin.system_name)); DicConsole.DebugWriteLine("SegaCD IP.BIN Decoder", "segacd_ipbin.volume_version = \"{0:X}\"", ipbin.volume_version); DicConsole.DebugWriteLine("SegaCD IP.BIN Decoder", "segacd_ipbin.volume_type = 0x{0:X8}", ipbin.volume_type); DicConsole.DebugWriteLine("SegaCD IP.BIN Decoder", "segacd_ipbin.system_version = 0x{0:X8}", ipbin.system_version); DicConsole.DebugWriteLine("SegaCD IP.BIN Decoder", "segacd_ipbin.ip_address = 0x{0:X8}", ipbin.ip_address); DicConsole.DebugWriteLine("SegaCD IP.BIN Decoder", "segacd_ipbin.ip_loadsize = {0}", ipbin.ip_loadsize); DicConsole.DebugWriteLine("SegaCD IP.BIN Decoder", "segacd_ipbin.ip_entry_address = 0x{0:X8}", ipbin.ip_entry_address); DicConsole.DebugWriteLine("SegaCD IP.BIN Decoder", "segacd_ipbin.ip_work_ram_size = {0}", ipbin.ip_work_ram_size); DicConsole.DebugWriteLine("SegaCD IP.BIN Decoder", "segacd_ipbin.sp_address = 0x{0:X8}", ipbin.sp_address); DicConsole.DebugWriteLine("SegaCD IP.BIN Decoder", "segacd_ipbin.sp_loadsize = {0}", ipbin.sp_loadsize); DicConsole.DebugWriteLine("SegaCD IP.BIN Decoder", "segacd_ipbin.sp_entry_address = 0x{0:X8}", ipbin.sp_entry_address); DicConsole.DebugWriteLine("SegaCD IP.BIN Decoder", "segacd_ipbin.sp_work_ram_size = {0}", ipbin.sp_work_ram_size); DicConsole.DebugWriteLine("SegaCD IP.BIN Decoder", "segacd_ipbin.release_date = \"{0}\"", Encoding.ASCII.GetString(ipbin.release_date)); DicConsole.DebugWriteLine("SegaCD IP.BIN Decoder", "segacd_ipbin.release_date2 = \"{0}\"", Encoding.ASCII.GetString(ipbin.release_date2)); DicConsole.DebugWriteLine("SegaCD IP.BIN Decoder", "segacd_ipbin.developer_code = \"{0}\"", Encoding.ASCII.GetString(ipbin.developer_code)); DicConsole.DebugWriteLine("SegaCD IP.BIN Decoder", "segacd_ipbin.domestic_title = \"{0}\"", Encoding.ASCII.GetString(ipbin.domestic_title)); DicConsole.DebugWriteLine("SegaCD IP.BIN Decoder", "segacd_ipbin.overseas_title = \"{0}\"", Encoding.ASCII.GetString(ipbin.overseas_title)); DicConsole.DebugWriteLine("SegaCD IP.BIN Decoder", "segacd_ipbin.product_code = \"{0}\"", Encoding.ASCII.GetString(ipbin.product_code)); DicConsole.DebugWriteLine("SegaCD IP.BIN Decoder", "segacd_ipbin.peripherals = \"{0}\"", Encoding.ASCII.GetString(ipbin.peripherals)); DicConsole.DebugWriteLine("SegaCD IP.BIN Decoder", "segacd_ipbin.region_codes = \"{0}\"", Encoding.ASCII.GetString(ipbin.region_codes)); string id = Encoding.ASCII.GetString(ipbin.SegaHardwareID); return(id == "SEGADISCSYSTEM " || id == "SEGADATADISC " || id == "SEGAOS " ? ipbin : (IPBin?)null); }
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = new PETSCII(); byte[] sector; StringBuilder sbInformation = new StringBuilder(); sbInformation.AppendLine("Commodore file system"); XmlFsType = new FileSystemType { Type = "Commodore file system", Clusters = imagePlugin.Info.Sectors, ClusterSize = 256 }; if (imagePlugin.Info.Sectors == 3200) { sector = imagePlugin.ReadSector(1560); CommodoreHeader cbmHdr = Marshal.ByteArrayToStructureLittleEndian <CommodoreHeader>(sector); sbInformation.AppendFormat("Directory starts at track {0} sector {1}", cbmHdr.directoryTrack, cbmHdr.directorySector).AppendLine(); sbInformation .AppendFormat("Disk DOS Version: {0}", Encoding.ASCII.GetString(new[] { cbmHdr.diskDosVersion })) .AppendLine(); sbInformation.AppendFormat("DOS Version: {0}", Encoding.ASCII.GetString(new[] { cbmHdr.dosVersion })) .AppendLine(); sbInformation.AppendFormat("Disk Version: {0}", Encoding.ASCII.GetString(new[] { cbmHdr.diskVersion })) .AppendLine(); sbInformation.AppendFormat("Disk ID: {0}", cbmHdr.diskId).AppendLine(); sbInformation.AppendFormat("Disk name: {0}", StringHandlers.CToString(cbmHdr.name, Encoding)) .AppendLine(); XmlFsType.VolumeName = StringHandlers.CToString(cbmHdr.name, Encoding); XmlFsType.VolumeSerial = $"{cbmHdr.diskId}"; } else { sector = imagePlugin.ReadSector(357); CommodoreBam cbmBam = Marshal.ByteArrayToStructureLittleEndian <CommodoreBam>(sector); sbInformation.AppendFormat("Directory starts at track {0} sector {1}", cbmBam.directoryTrack, cbmBam.directorySector).AppendLine(); sbInformation.AppendFormat("Disk DOS type: {0}", Encoding.ASCII.GetString(BitConverter.GetBytes(cbmBam.dosType))) .AppendLine(); sbInformation.AppendFormat("DOS Version: {0}", Encoding.ASCII.GetString(new[] { cbmBam.dosVersion })) .AppendLine(); sbInformation.AppendFormat("Disk ID: {0}", cbmBam.diskId).AppendLine(); sbInformation.AppendFormat("Disk name: {0}", StringHandlers.CToString(cbmBam.name, Encoding)) .AppendLine(); XmlFsType.VolumeName = StringHandlers.CToString(cbmBam.name, Encoding); XmlFsType.VolumeSerial = $"{cbmBam.diskId}"; } information = sbInformation.ToString(); }
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; } StringBuilder 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" }; }
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; } StringBuilder 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() }; }
static dk_label SwapDiskLabel(dk_label label) { DicConsole.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); }
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); DicConsole.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++) { DicConsole.DebugWriteLine("XENIX plugin", "xnxtbl.p[{0}].p_off = {1}", i, xnxtbl.p[i].p_off); DicConsole.DebugWriteLine("XENIX plugin", "xnxtbl.p[{0}].p_size = {1}", i, xnxtbl.p[i].p_size); if (xnxtbl.p[i].p_size <= 0) { continue; } CommonTypes.Partition 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); }
public bool Identify(IMediaImage imagePlugin, Partition partition) { if(16 + partition.Start >= partition.End) return false; byte[] hpofsBpbSector = imagePlugin.ReadSector(0 + partition.Start); // Seek to BIOS parameter block, on logical sector 0 if(hpofsBpbSector.Length < 512) return false; BiosParameterBlock bpb = Marshal.ByteArrayToStructureLittleEndian<BiosParameterBlock>(hpofsBpbSector); return bpb.fs_type.SequenceEqual(hpofsType); }
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)); }
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); }
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); DicConsole.DebugWriteLine("LIF plugin", "magic 0x{0:X8} (expected 0x{1:X8})", lifSb.magic, LIF_MAGIC); return(lifSb.magic == LIF_MAGIC); }
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = new Radix50(); information = ""; StringBuilder 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(); }
public bool Identify(IMediaImage imagePlugin, Partition partition) { if (partition.Start >= partition.End) { return(false); } byte[] sector = imagePlugin.ReadSector(partition.Start); ApfsContainerSuperBlock nxSb; try { nxSb = Marshal.ByteArrayToStructureLittleEndian <ApfsContainerSuperBlock>(sector); } catch { return(false); } return(nxSb.magic == APFS_CONTAINER_MAGIC); }
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)); }
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); }
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); StringBuilder 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" }; }