mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
🎨Converted all plugin types to interfaces.
This commit is contained in:
@@ -39,7 +39,7 @@ using DiscImageChef.DiscImages;
|
||||
|
||||
namespace DiscImageChef.Partitions
|
||||
{
|
||||
public class Acorn : PartitionPlugin
|
||||
public class Acorn : IPartition
|
||||
{
|
||||
const ulong ADFS_SB_POS = 0xC00;
|
||||
const uint LINUX_MAGIC = 0xDEAFA1DE;
|
||||
@@ -50,13 +50,10 @@ namespace DiscImageChef.Partitions
|
||||
const uint TYPE_RISCIX_SCSI = 2;
|
||||
const uint TYPE_MASK = 15;
|
||||
|
||||
public Acorn()
|
||||
{
|
||||
Name = "Acorn FileCore partitions";
|
||||
PluginUuid = new Guid("A7C8FEBE-8D00-4933-B9F3-42184C8BA808");
|
||||
}
|
||||
public virtual string Name => "Acorn FileCore partitions";
|
||||
public virtual Guid Id => new Guid("A7C8FEBE-8D00-4933-B9F3-42184C8BA808");
|
||||
|
||||
public override bool GetInformation(ImagePlugin imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
public virtual bool GetInformation(IMediaImage imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
{
|
||||
partitions = new List<Partition>();
|
||||
|
||||
@@ -65,8 +62,8 @@ namespace DiscImageChef.Partitions
|
||||
// RISC OS always checks for the partition on 0. Afaik no emulator chains it.
|
||||
if(sectorOffset != 0) return false;
|
||||
|
||||
if(imagePlugin.ImageInfo.SectorSize > ADFS_SB_POS) sbSector = 0;
|
||||
else sbSector = ADFS_SB_POS / imagePlugin.ImageInfo.SectorSize;
|
||||
if(imagePlugin.Info.SectorSize > ADFS_SB_POS) sbSector = 0;
|
||||
else sbSector = ADFS_SB_POS / imagePlugin.Info.SectorSize;
|
||||
|
||||
byte[] sector = imagePlugin.ReadSector(sbSector);
|
||||
|
||||
@@ -84,7 +81,7 @@ namespace DiscImageChef.Partitions
|
||||
int secCyl = bootBlock.discRecord.spt * heads;
|
||||
int mapSector = bootBlock.startCylinder * secCyl;
|
||||
|
||||
if((ulong)mapSector >= imagePlugin.ImageInfo.Sectors) return false;
|
||||
if((ulong)mapSector >= imagePlugin.Info.Sectors) return false;
|
||||
|
||||
byte[] map = imagePlugin.ReadSector((ulong)mapSector);
|
||||
|
||||
@@ -97,7 +94,7 @@ namespace DiscImageChef.Partitions
|
||||
Size = (ulong)bootBlock.discRecord.disc_size_high * 0x100000000 + bootBlock.discRecord.disc_size,
|
||||
Length =
|
||||
((ulong)bootBlock.discRecord.disc_size_high * 0x100000000 + bootBlock.discRecord.disc_size) /
|
||||
imagePlugin.ImageInfo.SectorSize,
|
||||
imagePlugin.Info.SectorSize,
|
||||
Type = "ADFS",
|
||||
Name = StringHandlers.CToString(bootBlock.discRecord.disc_name, Encoding.GetEncoding("iso-8859-1"))
|
||||
};
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace DiscImageChef.Partitions
|
||||
{
|
||||
// Information about structures learnt from Inside Macintosh
|
||||
// Constants from image testing
|
||||
public class AppleMap : PartitionPlugin
|
||||
public class AppleMap : IPartition
|
||||
{
|
||||
/// <summary>"ER", driver descriptor magic</summary>
|
||||
const ushort DDM_MAGIC = 0x4552;
|
||||
@@ -53,22 +53,19 @@ namespace DiscImageChef.Partitions
|
||||
/// <summary>Old indicator for HFS partition, "TFS1"</summary>
|
||||
const uint HFS_MAGIC_OLD = 0x54465331;
|
||||
|
||||
public AppleMap()
|
||||
{
|
||||
Name = "Apple Partition Map";
|
||||
PluginUuid = new Guid("36405F8D-4F1A-07F5-209C-223D735D6D22");
|
||||
}
|
||||
public virtual string Name => "Apple Partition Map";
|
||||
public virtual Guid Id => new Guid("36405F8D-4F1A-07F5-209C-223D735D6D22");
|
||||
|
||||
public override bool GetInformation(ImagePlugin imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
public virtual bool GetInformation(IMediaImage imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
{
|
||||
uint sectorSize;
|
||||
|
||||
if(imagePlugin.ImageInfo.SectorSize == 2352 || imagePlugin.ImageInfo.SectorSize == 2448) sectorSize = 2048;
|
||||
else sectorSize = imagePlugin.ImageInfo.SectorSize;
|
||||
if(imagePlugin.Info.SectorSize == 2352 || imagePlugin.Info.SectorSize == 2448) sectorSize = 2048;
|
||||
else sectorSize = imagePlugin.Info.SectorSize;
|
||||
|
||||
partitions = new List<Partition>();
|
||||
|
||||
if(sectorOffset + 2 >= imagePlugin.ImageInfo.Sectors) return false;
|
||||
if(sectorOffset + 2 >= imagePlugin.Info.Sectors) return false;
|
||||
|
||||
byte[] ddmSector = imagePlugin.ReadSector(sectorOffset);
|
||||
|
||||
@@ -313,24 +310,24 @@ namespace DiscImageChef.Partitions
|
||||
}
|
||||
|
||||
_partition.Description = sb.ToString();
|
||||
if(_partition.Start < imagePlugin.ImageInfo.Sectors && _partition.End < imagePlugin.ImageInfo.Sectors)
|
||||
if(_partition.Start < imagePlugin.Info.Sectors && _partition.End < imagePlugin.Info.Sectors)
|
||||
{
|
||||
partitions.Add(_partition);
|
||||
sequence++;
|
||||
}
|
||||
// Some CD and DVDs end with an Apple_Free that expands beyond the disc size...
|
||||
else if(_partition.Start < imagePlugin.ImageInfo.Sectors)
|
||||
else if(_partition.Start < imagePlugin.Info.Sectors)
|
||||
{
|
||||
DicConsole.DebugWriteLine("AppleMap Plugin", "Cutting last partition end ({0}) to media size ({1})",
|
||||
_partition.End, imagePlugin.ImageInfo.Sectors - 1);
|
||||
_partition.Length = imagePlugin.ImageInfo.Sectors - _partition.Start;
|
||||
_partition.End, imagePlugin.Info.Sectors - 1);
|
||||
_partition.Length = imagePlugin.Info.Sectors - _partition.Start;
|
||||
partitions.Add(_partition);
|
||||
sequence++;
|
||||
}
|
||||
else
|
||||
DicConsole.DebugWriteLine("AppleMap Plugin",
|
||||
"Not adding partition becaus start ({0}) is outside media size ({1})",
|
||||
_partition.Start, imagePlugin.ImageInfo.Sectors - 1);
|
||||
_partition.Start, imagePlugin.Info.Sectors - 1);
|
||||
}
|
||||
|
||||
return partitions.Count > 0;
|
||||
|
||||
@@ -39,7 +39,7 @@ using DiscImageChef.DiscImages;
|
||||
|
||||
namespace DiscImageChef.Partitions
|
||||
{
|
||||
public class Apricot : PartitionPlugin
|
||||
public class Apricot : IPartition
|
||||
{
|
||||
readonly int[] baudRates = {50, 75, 110, 134, 150, 300, 600, 1200, 1800, 2400, 3600, 4800, 7200, 9600, 19200};
|
||||
readonly string[] bootTypeCodes =
|
||||
@@ -56,13 +56,10 @@ namespace DiscImageChef.Partitions
|
||||
readonly string[] printDevices = {"Parallel", "Serial"};
|
||||
readonly double[] stopBits = {1, 1.5, 2};
|
||||
|
||||
public Apricot()
|
||||
{
|
||||
Name = "ACT Apricot partitions";
|
||||
PluginUuid = new Guid("8CBF5864-7B5A-47A0-8CEB-199C74FA22DE");
|
||||
}
|
||||
public virtual string Name => "ACT Apricot partitions";
|
||||
public virtual Guid Id => new Guid("8CBF5864-7B5A-47A0-8CEB-199C74FA22DE");
|
||||
|
||||
public override bool GetInformation(ImagePlugin imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
public virtual bool GetInformation(IMediaImage imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
{
|
||||
partitions = new List<Partition>();
|
||||
|
||||
@@ -79,7 +76,7 @@ namespace DiscImageChef.Partitions
|
||||
Marshal.FreeHGlobal(lblPtr);
|
||||
|
||||
// Not much to check but...
|
||||
ulong deviceSectors = imagePlugin.ImageInfo.Sectors;
|
||||
ulong deviceSectors = imagePlugin.Info.Sectors;
|
||||
ulong deviceSizeAccordingToLabel = label.cylinders * label.heads * label.spt;
|
||||
if(label.operatingSystem > 4 || label.bootType > 5 || label.partitionCount > 8 ||
|
||||
deviceSizeAccordingToLabel > deviceSectors || label.firstDataBlock > deviceSectors) return false;
|
||||
|
||||
@@ -40,7 +40,7 @@ using DiscImageChef.DiscImages;
|
||||
|
||||
namespace DiscImageChef.Partitions
|
||||
{
|
||||
public class AtariPartitions : PartitionPlugin
|
||||
public class AtariPartitions : IPartition
|
||||
{
|
||||
const uint TypeGEMDOS = 0x0047454D;
|
||||
const uint TypeBigGEMDOS = 0x0042474D;
|
||||
@@ -55,17 +55,14 @@ namespace DiscImageChef.Partitions
|
||||
const uint TypeMinix = 0x004D4958;
|
||||
const uint TypeMinix2 = 0x004D4E58;
|
||||
|
||||
public AtariPartitions()
|
||||
{
|
||||
Name = "Atari partitions";
|
||||
PluginUuid = new Guid("d1dd0f24-ec39-4c4d-9072-be31919a3b5e");
|
||||
}
|
||||
public virtual string Name => "Atari partitions";
|
||||
public virtual Guid Id => new Guid("d1dd0f24-ec39-4c4d-9072-be31919a3b5e");
|
||||
|
||||
public override bool GetInformation(ImagePlugin imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
public virtual bool GetInformation(IMediaImage imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
{
|
||||
partitions = new List<Partition>();
|
||||
|
||||
if(imagePlugin.ImageInfo.SectorSize < 512) return false;
|
||||
if(imagePlugin.Info.SectorSize < 512) return false;
|
||||
|
||||
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
||||
|
||||
@@ -159,13 +156,13 @@ namespace DiscImageChef.Partitions
|
||||
case TypeMinix2:
|
||||
validTable = true;
|
||||
|
||||
if(table.entries[i].start <= imagePlugin.ImageInfo.Sectors)
|
||||
if(table.entries[i].start <= imagePlugin.Info.Sectors)
|
||||
{
|
||||
if(table.entries[i].start + table.entries[i].length > imagePlugin.ImageInfo.Sectors)
|
||||
if(table.entries[i].start + table.entries[i].length > imagePlugin.Info.Sectors)
|
||||
DicConsole.DebugWriteLine("Atari partition plugin",
|
||||
"WARNING: End of partition goes beyond device size");
|
||||
|
||||
ulong sectorSize = imagePlugin.ImageInfo.SectorSize;
|
||||
ulong sectorSize = imagePlugin.Info.SectorSize;
|
||||
if(sectorSize == 2448 || sectorSize == 2352) sectorSize = 2048;
|
||||
|
||||
byte[] partType = new byte[3];
|
||||
@@ -253,14 +250,14 @@ namespace DiscImageChef.Partitions
|
||||
extendedType != TypeMinix2) continue;
|
||||
|
||||
validTable = true;
|
||||
if(extendedTable.entries[j].start > imagePlugin.ImageInfo.Sectors) continue;
|
||||
if(extendedTable.entries[j].start > imagePlugin.Info.Sectors) continue;
|
||||
|
||||
if(extendedTable.entries[j].start + extendedTable.entries[j].length >
|
||||
imagePlugin.ImageInfo.Sectors)
|
||||
imagePlugin.Info.Sectors)
|
||||
DicConsole.DebugWriteLine("Atari partition plugin",
|
||||
"WARNING: End of partition goes beyond device size");
|
||||
|
||||
ulong sectorSize = imagePlugin.ImageInfo.SectorSize;
|
||||
ulong sectorSize = imagePlugin.Info.SectorSize;
|
||||
if(sectorSize == 2448 || sectorSize == 2352) sectorSize = 2048;
|
||||
|
||||
byte[] partType = new byte[3];
|
||||
@@ -335,13 +332,13 @@ namespace DiscImageChef.Partitions
|
||||
type != TypeRAW && type != TypeNetBSD && type != TypeNetBSDSwap && type != TypeSysV &&
|
||||
type != TypeMac && type != TypeMinix && type != TypeMinix2) continue;
|
||||
|
||||
if(table.icdEntries[i].start > imagePlugin.ImageInfo.Sectors) continue;
|
||||
if(table.icdEntries[i].start > imagePlugin.Info.Sectors) continue;
|
||||
|
||||
if(table.icdEntries[i].start + table.icdEntries[i].length > imagePlugin.ImageInfo.Sectors)
|
||||
if(table.icdEntries[i].start + table.icdEntries[i].length > imagePlugin.Info.Sectors)
|
||||
DicConsole.DebugWriteLine("Atari partition plugin",
|
||||
"WARNING: End of partition goes beyond device size");
|
||||
|
||||
ulong sectorSize = imagePlugin.ImageInfo.SectorSize;
|
||||
ulong sectorSize = imagePlugin.Info.SectorSize;
|
||||
if(sectorSize == 2448 || sectorSize == 2352) sectorSize = 2048;
|
||||
|
||||
byte[] partType = new byte[3];
|
||||
|
||||
@@ -40,7 +40,7 @@ using DiscImageChef.DiscImages;
|
||||
|
||||
namespace DiscImageChef.Partitions
|
||||
{
|
||||
public class BSD : PartitionPlugin
|
||||
public class BSD : IPartition
|
||||
{
|
||||
const uint DISKMAGIC = 0x82564557;
|
||||
const uint DISKCIGAM = 0x57455682;
|
||||
@@ -51,24 +51,21 @@ namespace DiscImageChef.Partitions
|
||||
/// <summary>Known byte offsets for BSD disklabel</summary>
|
||||
readonly uint[] labelOffsets = {0, 9, 64, 128, 516};
|
||||
|
||||
public BSD()
|
||||
{
|
||||
Name = "BSD disklabel";
|
||||
PluginUuid = new Guid("246A6D93-4F1A-1F8A-344D-50187A5513A9");
|
||||
}
|
||||
public virtual string Name => "BSD disklabel";
|
||||
public virtual Guid Id => new Guid("246A6D93-4F1A-1F8A-344D-50187A5513A9");
|
||||
|
||||
public override bool GetInformation(ImagePlugin imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
public virtual bool GetInformation(IMediaImage imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
{
|
||||
partitions = new List<Partition>();
|
||||
uint run = (MAX_LABEL_SIZE + labelOffsets.Last()) / imagePlugin.ImageInfo.SectorSize;
|
||||
if((MAX_LABEL_SIZE + labelOffsets.Last()) % imagePlugin.ImageInfo.SectorSize > 0) run++;
|
||||
uint run = (MAX_LABEL_SIZE + labelOffsets.Last()) / imagePlugin.Info.SectorSize;
|
||||
if((MAX_LABEL_SIZE + labelOffsets.Last()) % imagePlugin.Info.SectorSize > 0) run++;
|
||||
|
||||
DiskLabel dl = new DiskLabel();
|
||||
bool found = false;
|
||||
|
||||
foreach(ulong location in labelLocations)
|
||||
{
|
||||
if(location + run + sectorOffset >= imagePlugin.ImageInfo.Sectors) return false;
|
||||
if(location + run + sectorOffset >= imagePlugin.Info.Sectors) return false;
|
||||
|
||||
byte[] tmp = imagePlugin.ReadSectors(location + sectorOffset, run);
|
||||
foreach(uint offset in labelOffsets)
|
||||
@@ -141,9 +138,9 @@ namespace DiscImageChef.Partitions
|
||||
dl.d_partitions[i].p_fstype, fsTypeToString(dl.d_partitions[i].p_fstype));
|
||||
Partition part = new Partition
|
||||
{
|
||||
Start = dl.d_partitions[i].p_offset * dl.d_secsize / imagePlugin.ImageInfo.SectorSize,
|
||||
Start = dl.d_partitions[i].p_offset * dl.d_secsize / imagePlugin.Info.SectorSize,
|
||||
Offset = dl.d_partitions[i].p_offset * dl.d_secsize,
|
||||
Length = dl.d_partitions[i].p_size * dl.d_secsize / imagePlugin.ImageInfo.SectorSize,
|
||||
Length = dl.d_partitions[i].p_size * dl.d_secsize / imagePlugin.Info.SectorSize,
|
||||
Size = dl.d_partitions[i].p_size * dl.d_secsize,
|
||||
Type = fsTypeToString(dl.d_partitions[i].p_fstype),
|
||||
Sequence = counter,
|
||||
@@ -156,7 +153,7 @@ namespace DiscImageChef.Partitions
|
||||
if(addSectorOffset)
|
||||
{
|
||||
part.Start += sectorOffset;
|
||||
part.Offset += sectorOffset * imagePlugin.ImageInfo.SectorSize;
|
||||
part.Offset += sectorOffset * imagePlugin.Info.SectorSize;
|
||||
}
|
||||
DicConsole.DebugWriteLine("BSD plugin", "part.start = {0}", part.Start);
|
||||
DicConsole.DebugWriteLine("BSD plugin", "Adding it...");
|
||||
|
||||
@@ -39,22 +39,19 @@ using DiscImageChef.DiscImages;
|
||||
|
||||
namespace DiscImageChef.Partitions
|
||||
{
|
||||
public class DEC : PartitionPlugin
|
||||
public class DEC : IPartition
|
||||
{
|
||||
const int PT_MAGIC = 0x032957;
|
||||
const int PT_VALID = 1;
|
||||
|
||||
public DEC()
|
||||
{
|
||||
Name = "DEC disklabel";
|
||||
PluginUuid = new Guid("58CEC3B7-3B93-4D47-86EE-D6DADE9D444F");
|
||||
}
|
||||
public virtual string Name => "DEC disklabel";
|
||||
public virtual Guid Id => new Guid("58CEC3B7-3B93-4D47-86EE-D6DADE9D444F");
|
||||
|
||||
public override bool GetInformation(ImagePlugin imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
public virtual bool GetInformation(IMediaImage imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
{
|
||||
partitions = new List<Partition>();
|
||||
|
||||
if(31 + sectorOffset >= imagePlugin.ImageInfo.Sectors) return false;
|
||||
if(31 + sectorOffset >= imagePlugin.Info.Sectors) return false;
|
||||
|
||||
byte[] sector = imagePlugin.ReadSector(31 + sectorOffset);
|
||||
if(sector.Length < 512) return false;
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
<Compile Include="Atari.cs" />
|
||||
<Compile Include="MBR.cs" />
|
||||
<Compile Include="NeXT.cs" />
|
||||
<Compile Include="PartitionPlugin.cs" />
|
||||
<Compile Include="IPartition.cs" />
|
||||
<Compile Include="RDB.cs" />
|
||||
<Compile Include="Sun.cs" />
|
||||
<Compile Include="GPT.cs" />
|
||||
|
||||
@@ -38,23 +38,20 @@ using DiscImageChef.DiscImages;
|
||||
|
||||
namespace DiscImageChef.Partitions
|
||||
{
|
||||
public class DragonFlyBSD : PartitionPlugin
|
||||
public class DragonFlyBSD : IPartition
|
||||
{
|
||||
const uint DISK_MAGIC64 = 0xC4464C59;
|
||||
|
||||
public DragonFlyBSD()
|
||||
{
|
||||
Name = "DragonFly BSD 64-bit disklabel";
|
||||
PluginUuid = new Guid("D49E41A6-D952-4760-9D94-03DAE2450C5F");
|
||||
}
|
||||
public virtual string Name => "DragonFly BSD 64-bit disklabel";
|
||||
public virtual Guid Id => new Guid("D49E41A6-D952-4760-9D94-03DAE2450C5F");
|
||||
|
||||
public override bool GetInformation(ImagePlugin imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
public virtual bool GetInformation(IMediaImage imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
{
|
||||
partitions = new List<Partition>();
|
||||
uint nSectors = 2048 / imagePlugin.ImageInfo.SectorSize;
|
||||
if(2048 % imagePlugin.ImageInfo.SectorSize > 0) nSectors++;
|
||||
uint nSectors = 2048 / imagePlugin.Info.SectorSize;
|
||||
if(2048 % imagePlugin.Info.SectorSize > 0) nSectors++;
|
||||
|
||||
if(sectorOffset + nSectors >= imagePlugin.ImageInfo.Sectors) return false;
|
||||
if(sectorOffset + nSectors >= imagePlugin.Info.Sectors) return false;
|
||||
|
||||
byte[] sectors = imagePlugin.ReadSectors(sectorOffset, nSectors);
|
||||
if(sectors.Length < 2048) return false;
|
||||
@@ -72,10 +69,10 @@ namespace DiscImageChef.Partitions
|
||||
{
|
||||
Partition part = new Partition
|
||||
{
|
||||
Start = entry.p_boffset / imagePlugin.ImageInfo.SectorSize + sectorOffset,
|
||||
Offset = entry.p_boffset + sectorOffset * imagePlugin.ImageInfo.SectorSize,
|
||||
Start = entry.p_boffset / imagePlugin.Info.SectorSize + sectorOffset,
|
||||
Offset = entry.p_boffset + sectorOffset * imagePlugin.Info.SectorSize,
|
||||
Size = entry.p_bsize,
|
||||
Length = entry.p_bsize / imagePlugin.ImageInfo.SectorSize,
|
||||
Length = entry.p_bsize / imagePlugin.Info.SectorSize,
|
||||
Name = entry.p_stor_uuid.ToString(),
|
||||
Sequence = counter,
|
||||
Scheme = Name,
|
||||
@@ -84,7 +81,7 @@ namespace DiscImageChef.Partitions
|
||||
: BSD.fsTypeToString((BSD.fsType)entry.p_fstype)
|
||||
};
|
||||
|
||||
if(entry.p_bsize % imagePlugin.ImageInfo.SectorSize > 0) part.Length++;
|
||||
if(entry.p_bsize % imagePlugin.Info.SectorSize > 0) part.Length++;
|
||||
|
||||
if(entry.p_bsize <= 0 || entry.p_boffset <= 0) continue;
|
||||
|
||||
|
||||
@@ -40,22 +40,19 @@ using DiscImageChef.DiscImages;
|
||||
|
||||
namespace DiscImageChef.Partitions
|
||||
{
|
||||
public class GuidPartitionTable : PartitionPlugin
|
||||
public class GuidPartitionTable : IPartition
|
||||
{
|
||||
const ulong GPT_MAGIC = 0x5452415020494645;
|
||||
const uint GPT_REVISION1 = 0x00010000;
|
||||
|
||||
public GuidPartitionTable()
|
||||
{
|
||||
Name = "GUID Partition Table";
|
||||
PluginUuid = new Guid("CBC9D281-C1D0-44E8-9038-4D66FD2678AB");
|
||||
}
|
||||
public virtual string Name => "GUID Partition Table";
|
||||
public virtual Guid Id => new Guid("CBC9D281-C1D0-44E8-9038-4D66FD2678AB");
|
||||
|
||||
public override bool GetInformation(ImagePlugin imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
public virtual bool GetInformation(IMediaImage imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
{
|
||||
partitions = new List<Partition>();
|
||||
|
||||
if(sectorOffset + 2 >= imagePlugin.ImageInfo.Sectors) return false;
|
||||
if(sectorOffset + 2 >= imagePlugin.Info.Sectors) return false;
|
||||
|
||||
byte[] hdrBytes = imagePlugin.ReadSector(1 + sectorOffset);
|
||||
GptHeader hdr;
|
||||
@@ -66,7 +63,7 @@ namespace DiscImageChef.Partitions
|
||||
DicConsole.DebugWriteLine("GPT Plugin", "hdr.signature = 0x{0:X16}", signature);
|
||||
|
||||
if(signature != GPT_MAGIC)
|
||||
if(imagePlugin.ImageInfo.XmlMediaType == XmlMediaType.OpticalDisc)
|
||||
if(imagePlugin.Info.XmlMediaType == XmlMediaType.OpticalDisc)
|
||||
{
|
||||
hdrBytes = imagePlugin.ReadSector(sectorOffset);
|
||||
signature = BitConverter.ToUInt64(hdrBytes, 512);
|
||||
@@ -121,11 +118,11 @@ namespace DiscImageChef.Partitions
|
||||
{
|
||||
divisor = 1;
|
||||
modulo = 0;
|
||||
sectorSize = imagePlugin.ImageInfo.SectorSize;
|
||||
sectorSize = imagePlugin.Info.SectorSize;
|
||||
}
|
||||
|
||||
uint totalEntriesSectors = hdr.entries * hdr.entriesSize / imagePlugin.ImageInfo.SectorSize;
|
||||
if(hdr.entries * hdr.entriesSize % imagePlugin.ImageInfo.SectorSize > 0) totalEntriesSectors++;
|
||||
uint totalEntriesSectors = hdr.entries * hdr.entriesSize / imagePlugin.Info.SectorSize;
|
||||
if(hdr.entries * hdr.entriesSize % imagePlugin.Info.SectorSize > 0) totalEntriesSectors++;
|
||||
|
||||
byte[] temp = imagePlugin.ReadSectors(hdr.entryLBA / divisor, totalEntriesSectors + modulo);
|
||||
byte[] entriesBytes = new byte[temp.Length - modulo * 512];
|
||||
@@ -165,8 +162,8 @@ namespace DiscImageChef.Partitions
|
||||
DicConsole.DebugWriteLine("GPT Plugin", "entry.attributes = 0x{0:X16}", entry.attributes);
|
||||
DicConsole.DebugWriteLine("GPT Plugin", "entry.name = {0}", entry.name);
|
||||
|
||||
if(entry.startLBA / divisor > imagePlugin.ImageInfo.Sectors ||
|
||||
entry.endLBA / divisor > imagePlugin.ImageInfo.Sectors) return false;
|
||||
if(entry.startLBA / divisor > imagePlugin.Info.Sectors ||
|
||||
entry.endLBA / divisor > imagePlugin.Info.Sectors) return false;
|
||||
|
||||
Partition part = new Partition
|
||||
{
|
||||
|
||||
@@ -40,28 +40,25 @@ using DiscImageChef.DiscImages;
|
||||
|
||||
namespace DiscImageChef.Partitions
|
||||
{
|
||||
public class Human68K : PartitionPlugin
|
||||
public class Human68K : IPartition
|
||||
{
|
||||
const uint X68K_MAGIC = 0x5836384B;
|
||||
|
||||
public Human68K()
|
||||
{
|
||||
Name = "Human 68k partitions";
|
||||
PluginUuid = new Guid("246A6D93-4F1A-1F8A-344D-50187A5513A9");
|
||||
}
|
||||
public virtual string Name => "Human 68k partitions";
|
||||
public virtual Guid Id => new Guid("246A6D93-4F1A-1F8A-344D-50187A5513A9");
|
||||
|
||||
public override bool GetInformation(ImagePlugin imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
public virtual 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.ImageInfo.SectorSize);
|
||||
DicConsole.DebugWriteLine("Human68k plugin", "sectorSize = {0}", imagePlugin.Info.SectorSize);
|
||||
|
||||
if(sectorOffset + 4 >= imagePlugin.ImageInfo.Sectors) return false;
|
||||
if(sectorOffset + 4 >= imagePlugin.Info.Sectors) return false;
|
||||
|
||||
switch(imagePlugin.ImageInfo.SectorSize)
|
||||
switch(imagePlugin.Info.SectorSize)
|
||||
{
|
||||
case 256:
|
||||
sector = imagePlugin.ReadSector(4 + sectorOffset);
|
||||
@@ -100,7 +97,7 @@ namespace DiscImageChef.Partitions
|
||||
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.ImageInfo.SectorSize);
|
||||
imagePlugin.Info.SectorSize);
|
||||
|
||||
Partition part = new Partition
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : PartitionPlugin.cs
|
||||
// Filename : IPartition.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Partitioning scheme plugins.
|
||||
@@ -41,12 +41,12 @@ namespace DiscImageChef.Partitions
|
||||
/// <summary>
|
||||
/// Abstract class to implement partitioning schemes interpreting plugins.
|
||||
/// </summary>
|
||||
public abstract class PartitionPlugin
|
||||
public interface IPartition
|
||||
{
|
||||
/// <summary>Plugin name.</summary>
|
||||
public string Name;
|
||||
string Name { get; }
|
||||
/// <summary>Plugin UUID.</summary>
|
||||
public Guid PluginUuid;
|
||||
Guid Id { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Interprets a partitioning scheme.
|
||||
@@ -55,7 +55,6 @@ namespace DiscImageChef.Partitions
|
||||
/// <param name="imagePlugin">Disk image.</param>
|
||||
/// <param name="partitions">Returns list of partitions.</param>
|
||||
/// <param name="sectorOffset">At which sector to start searching for the partition scheme.</param>
|
||||
public abstract bool GetInformation(ImagePlugin imagePlugin, out List<Partition> partitions,
|
||||
ulong sectorOffset);
|
||||
bool GetInformation(IMediaImage imagePlugin, out List<Partition> partitions, ulong sectorOffset);
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ using DiscImageChef.Helpers;
|
||||
namespace DiscImageChef.Partitions
|
||||
{
|
||||
// TODO: Support AAP extensions
|
||||
public class MBR : PartitionPlugin
|
||||
public class MBR : IPartition
|
||||
{
|
||||
const ulong GPT_MAGIC = 0x5452415020494645;
|
||||
|
||||
@@ -184,25 +184,22 @@ namespace DiscImageChef.Partitions
|
||||
"VMWare VMKCORE", "Linux RAID, FreeDOS", "SpeedStor, LANStep, PS/2 IML", "Xenix bad block"
|
||||
};
|
||||
|
||||
public MBR()
|
||||
{
|
||||
Name = "Master Boot Record";
|
||||
PluginUuid = new Guid("5E8A34E8-4F1A-59E6-4BF7-7EA647063A76");
|
||||
}
|
||||
public virtual string Name => "Master Boot Record";
|
||||
public virtual Guid Id => new Guid("5E8A34E8-4F1A-59E6-4BF7-7EA647063A76");
|
||||
|
||||
public override bool GetInformation(ImagePlugin imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
public virtual bool GetInformation(IMediaImage imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
{
|
||||
ulong counter = 0;
|
||||
|
||||
partitions = new List<Partition>();
|
||||
|
||||
if(imagePlugin.ImageInfo.SectorSize < 512) return false;
|
||||
if(imagePlugin.Info.SectorSize < 512) return false;
|
||||
|
||||
uint sectorSize = imagePlugin.ImageInfo.SectorSize;
|
||||
uint sectorSize = imagePlugin.Info.SectorSize;
|
||||
// Divider of sector size in MBR between real sector size
|
||||
ulong divider = 1;
|
||||
|
||||
if(imagePlugin.ImageInfo.XmlMediaType == XmlMediaType.OpticalDisc)
|
||||
if(imagePlugin.Info.XmlMediaType == XmlMediaType.OpticalDisc)
|
||||
{
|
||||
sectorSize = 512;
|
||||
divider = 4;
|
||||
@@ -229,7 +226,7 @@ namespace DiscImageChef.Partitions
|
||||
typeof(DiskManagerMasterBootRecord));
|
||||
handle.Free();
|
||||
|
||||
DicConsole.DebugWriteLine("MBR plugin", "xmlmedia = {0}", imagePlugin.ImageInfo.XmlMediaType);
|
||||
DicConsole.DebugWriteLine("MBR plugin", "xmlmedia = {0}", imagePlugin.Info.XmlMediaType);
|
||||
DicConsole.DebugWriteLine("MBR plugin", "mbr.magic = {0:X4}", mbr.magic);
|
||||
|
||||
if(mbr.magic != MBR_MAGIC) return false; // Not MBR
|
||||
@@ -242,7 +239,7 @@ namespace DiscImageChef.Partitions
|
||||
|
||||
if(signature == GPT_MAGIC) return false;
|
||||
|
||||
if(signature != GPT_MAGIC && imagePlugin.ImageInfo.XmlMediaType == XmlMediaType.OpticalDisc)
|
||||
if(signature != GPT_MAGIC && imagePlugin.Info.XmlMediaType == XmlMediaType.OpticalDisc)
|
||||
{
|
||||
hdrBytes = imagePlugin.ReadSector(sectorOffset);
|
||||
signature = BitConverter.ToUInt64(hdrBytes, 512);
|
||||
@@ -288,10 +285,10 @@ namespace DiscImageChef.Partitions
|
||||
entry.end_head != 0 || entry.end_sector != 0;
|
||||
if(entry.lba_start == 0 && entry.lba_sectors == 0 && valid)
|
||||
{
|
||||
lbaStart = CHS.ToLBA(startCylinder, entry.start_head, startSector, imagePlugin.ImageInfo.Heads,
|
||||
imagePlugin.ImageInfo.SectorsPerTrack);
|
||||
lbaSectors = CHS.ToLBA(endCylinder, entry.end_head, entry.end_sector, imagePlugin.ImageInfo.Heads,
|
||||
imagePlugin.ImageInfo.SectorsPerTrack) - lbaStart;
|
||||
lbaStart = CHS.ToLBA(startCylinder, entry.start_head, startSector, imagePlugin.Info.Heads,
|
||||
imagePlugin.Info.SectorsPerTrack);
|
||||
lbaSectors = CHS.ToLBA(endCylinder, entry.end_head, entry.end_sector, imagePlugin.Info.Heads,
|
||||
imagePlugin.Info.SectorsPerTrack) - lbaStart;
|
||||
}
|
||||
|
||||
// For optical media
|
||||
@@ -300,15 +297,15 @@ namespace DiscImageChef.Partitions
|
||||
|
||||
if(minix && lbaStart == sectorOffset) minix = false;
|
||||
|
||||
if(lbaStart > imagePlugin.ImageInfo.Sectors)
|
||||
if(lbaStart > imagePlugin.Info.Sectors)
|
||||
{
|
||||
valid = false;
|
||||
extended = false;
|
||||
}
|
||||
|
||||
// Some buggy implementations do some rounding errors getting a few sectors beyond device size
|
||||
if(lbaStart + lbaSectors > imagePlugin.ImageInfo.Sectors)
|
||||
lbaSectors = imagePlugin.ImageInfo.Sectors - lbaStart;
|
||||
if(lbaStart + lbaSectors > imagePlugin.Info.Sectors)
|
||||
lbaSectors = imagePlugin.Info.Sectors - lbaStart;
|
||||
|
||||
DicConsole.DebugWriteLine("MBR plugin", "entry.status {0}", entry.status);
|
||||
DicConsole.DebugWriteLine("MBR plugin", "entry.type {0}", entry.type);
|
||||
@@ -334,7 +331,7 @@ namespace DiscImageChef.Partitions
|
||||
if(valid && !minix)
|
||||
{
|
||||
Partition part = new Partition();
|
||||
if((lbaStart > 0 || imagePlugin.ImageInfo.XmlMediaType == XmlMediaType.OpticalDisc) &&
|
||||
if((lbaStart > 0 || imagePlugin.Info.XmlMediaType == XmlMediaType.OpticalDisc) &&
|
||||
lbaSectors > 0)
|
||||
{
|
||||
part.Start = lbaStart + sectorOffset;
|
||||
@@ -413,9 +410,9 @@ namespace DiscImageChef.Partitions
|
||||
if(ebrEntry.lba_start == 0 && ebrEntry.lba_sectors == 0 && extValid)
|
||||
{
|
||||
extStart = CHS.ToLBA(startCylinder, ebrEntry.start_head, startSector,
|
||||
imagePlugin.ImageInfo.Heads, imagePlugin.ImageInfo.SectorsPerTrack);
|
||||
imagePlugin.Info.Heads, imagePlugin.Info.SectorsPerTrack);
|
||||
extSectors = CHS.ToLBA(endCylinder, ebrEntry.end_head, ebrEntry.end_sector,
|
||||
imagePlugin.ImageInfo.Heads, imagePlugin.ImageInfo.SectorsPerTrack) -
|
||||
imagePlugin.Info.Heads, imagePlugin.Info.SectorsPerTrack) -
|
||||
extStart;
|
||||
}
|
||||
extMinix |= ebrEntry.type == 0x81 || ebrEntry.type == 0x80;
|
||||
@@ -437,11 +434,11 @@ namespace DiscImageChef.Partitions
|
||||
}
|
||||
|
||||
extStart += lbaStart;
|
||||
extValid &= extStart <= imagePlugin.ImageInfo.Sectors;
|
||||
extValid &= extStart <= imagePlugin.Info.Sectors;
|
||||
|
||||
// Some buggy implementations do some rounding errors getting a few sectors beyond device size
|
||||
if(extStart + extSectors > imagePlugin.ImageInfo.Sectors)
|
||||
extSectors = imagePlugin.ImageInfo.Sectors - extStart;
|
||||
if(extStart + extSectors > imagePlugin.Info.Sectors)
|
||||
extSectors = imagePlugin.Info.Sectors - extStart;
|
||||
|
||||
if(extValid && extMinix) // Let's mix the fun
|
||||
if(GetMinix(imagePlugin, lbaStart, divider, sectorOffset, sectorSize,
|
||||
@@ -474,7 +471,7 @@ namespace DiscImageChef.Partitions
|
||||
|
||||
DicConsole.DebugWriteLine("MBR plugin", "next_start {0}", nextStart);
|
||||
processingExtended &= nextStart != 0;
|
||||
processingExtended &= nextStart <= imagePlugin.ImageInfo.Sectors;
|
||||
processingExtended &= nextStart <= imagePlugin.Info.Sectors;
|
||||
lbaStart = nextStart;
|
||||
}
|
||||
}
|
||||
@@ -483,7 +480,7 @@ namespace DiscImageChef.Partitions
|
||||
return partitions.Count != 0;
|
||||
}
|
||||
|
||||
static bool GetMinix(ImagePlugin imagePlugin, ulong start, ulong divider, ulong sectorOffset, uint sectorSize,
|
||||
static bool GetMinix(IMediaImage imagePlugin, ulong start, ulong divider, ulong sectorOffset, uint sectorSize,
|
||||
out List<Partition> partitions)
|
||||
{
|
||||
partitions = new List<Partition>();
|
||||
@@ -529,10 +526,10 @@ namespace DiscImageChef.Partitions
|
||||
mnxEntry.end_head != 0 || mnxEntry.end_sector != 0;
|
||||
if(mnxEntry.lba_start == 0 && mnxEntry.lba_sectors == 0 && mnxValid)
|
||||
{
|
||||
mnxStart = CHS.ToLBA(startCylinder, mnxEntry.start_head, startSector, imagePlugin.ImageInfo.Heads,
|
||||
imagePlugin.ImageInfo.SectorsPerTrack);
|
||||
mnxStart = CHS.ToLBA(startCylinder, mnxEntry.start_head, startSector, imagePlugin.Info.Heads,
|
||||
imagePlugin.Info.SectorsPerTrack);
|
||||
mnxSectors = CHS.ToLBA(endCylinder, mnxEntry.end_head, mnxEntry.end_sector,
|
||||
imagePlugin.ImageInfo.Heads, imagePlugin.ImageInfo.SectorsPerTrack) -
|
||||
imagePlugin.Info.Heads, imagePlugin.Info.SectorsPerTrack) -
|
||||
mnxStart;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,34 +42,31 @@ using DiscImageChef.DiscImages;
|
||||
// Information learnt from XNU source and testing against real disks
|
||||
namespace DiscImageChef.Partitions
|
||||
{
|
||||
public class NeXTDisklabel : PartitionPlugin
|
||||
public class NeXTDisklabel : IPartition
|
||||
{
|
||||
/// <summary>"NeXT"</summary>
|
||||
const uint NEXT_MAGIC1 = 0x4E655854;
|
||||
// "NeXT"
|
||||
/// <summary>"dlV2"</summary>
|
||||
const uint NEXT_MAGIC2 = 0x646C5632;
|
||||
// "dlV2"
|
||||
/// <summary>"dlV3"</summary>
|
||||
const uint NEXT_MAGIC3 = 0x646C5633;
|
||||
// "dlV3"
|
||||
/// <summary>180</summary>
|
||||
const ushort DISKTAB_START = 0xB4;
|
||||
// 180
|
||||
/// <summary>44</summary>
|
||||
const ushort DISKTAB_ENTRY_SIZE = 0x2C;
|
||||
|
||||
// 44
|
||||
public NeXTDisklabel()
|
||||
{
|
||||
Name = "NeXT Disklabel";
|
||||
PluginUuid = new Guid("246A6D93-4F1A-1F8A-344D-50187A5513A9");
|
||||
}
|
||||
public virtual string Name => "NeXT Disklabel";
|
||||
public virtual Guid Id => new Guid("246A6D93-4F1A-1F8A-344D-50187A5513A9");
|
||||
|
||||
public override bool GetInformation(ImagePlugin imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
public virtual bool GetInformation(IMediaImage imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
{
|
||||
bool magicFound = false;
|
||||
byte[] labelSector;
|
||||
|
||||
uint sectorSize;
|
||||
|
||||
if(imagePlugin.ImageInfo.SectorSize == 2352 || imagePlugin.ImageInfo.SectorSize == 2448) sectorSize = 2048;
|
||||
else sectorSize = imagePlugin.ImageInfo.SectorSize;
|
||||
if(imagePlugin.Info.SectorSize == 2352 || imagePlugin.Info.SectorSize == 2448) sectorSize = 2048;
|
||||
else sectorSize = imagePlugin.Info.SectorSize;
|
||||
|
||||
partitions = new List<Partition>();
|
||||
|
||||
@@ -77,8 +74,7 @@ namespace DiscImageChef.Partitions
|
||||
|
||||
ulong labelPosition = 0;
|
||||
|
||||
foreach(ulong i in
|
||||
new ulong[] {0, 4, 15, 16}.TakeWhile(i => i + sectorOffset < imagePlugin.ImageInfo.Sectors))
|
||||
foreach(ulong i in new ulong[] {0, 4, 15, 16}.TakeWhile(i => i + sectorOffset < imagePlugin.Info.Sectors))
|
||||
{
|
||||
labelSector = imagePlugin.ReadSector(i + sectorOffset);
|
||||
uint magic = BigEndianBitConverter.ToUInt32(labelSector, 0x00);
|
||||
@@ -91,8 +87,8 @@ namespace DiscImageChef.Partitions
|
||||
|
||||
if(!magicFound) return false;
|
||||
|
||||
uint sectorsToRead = 7680 / imagePlugin.ImageInfo.SectorSize;
|
||||
if(7680 % imagePlugin.ImageInfo.SectorSize > 0) sectorsToRead++;
|
||||
uint sectorsToRead = 7680 / imagePlugin.Info.SectorSize;
|
||||
if(7680 % imagePlugin.Info.SectorSize > 0) sectorsToRead++;
|
||||
|
||||
labelSector = imagePlugin.ReadSectors(labelPosition, sectorsToRead);
|
||||
|
||||
@@ -184,10 +180,10 @@ namespace DiscImageChef.Partitions
|
||||
Scheme = Name
|
||||
};
|
||||
|
||||
if(part.Start + part.Length > imagePlugin.ImageInfo.Sectors)
|
||||
if(part.Start + part.Length > imagePlugin.Info.Sectors)
|
||||
{
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "Partition bigger than device, reducing...");
|
||||
part.Length = imagePlugin.ImageInfo.Sectors - part.Start;
|
||||
part.Length = imagePlugin.Info.Sectors - part.Start;
|
||||
part.Size = part.Length * sectorSize;
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_size = {1}", i,
|
||||
part.Length);
|
||||
|
||||
@@ -41,15 +41,12 @@ using DiscImageChef.Helpers;
|
||||
|
||||
namespace DiscImageChef.Partitions
|
||||
{
|
||||
public class PC98 : PartitionPlugin
|
||||
public class PC98 : IPartition
|
||||
{
|
||||
public PC98()
|
||||
{
|
||||
Name = "NEC PC-9800 partition table";
|
||||
PluginUuid = new Guid("27333401-C7C2-447D-961C-22AD0641A09A");
|
||||
}
|
||||
public virtual string Name => "NEC PC-9800 partition table";
|
||||
public virtual Guid Id => new Guid("27333401-C7C2-447D-961C-22AD0641A09A");
|
||||
|
||||
public override bool GetInformation(ImagePlugin imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
public virtual bool GetInformation(IMediaImage imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
{
|
||||
partitions = new List<Partition>();
|
||||
|
||||
@@ -84,27 +81,25 @@ namespace DiscImageChef.Partitions
|
||||
DicConsole.DebugWriteLine("PC98 plugin", "entry.dp_name = \"{0}\"",
|
||||
StringHandlers.CToString(entry.dp_name, Encoding.GetEncoding(932)));
|
||||
|
||||
if(entry.dp_scyl == entry.dp_ecyl || entry.dp_ecyl <= 0 ||
|
||||
entry.dp_scyl > imagePlugin.ImageInfo.Cylinders || entry.dp_ecyl > imagePlugin.ImageInfo.Cylinders ||
|
||||
entry.dp_shd > imagePlugin.ImageInfo.Heads || entry.dp_ehd > imagePlugin.ImageInfo.Heads ||
|
||||
entry.dp_ssect > imagePlugin.ImageInfo.SectorsPerTrack ||
|
||||
entry.dp_esect > imagePlugin.ImageInfo.SectorsPerTrack) continue;
|
||||
if(entry.dp_scyl == entry.dp_ecyl || entry.dp_ecyl <= 0 || entry.dp_scyl > imagePlugin.Info.Cylinders ||
|
||||
entry.dp_ecyl > imagePlugin.Info.Cylinders || entry.dp_shd > imagePlugin.Info.Heads ||
|
||||
entry.dp_ehd > imagePlugin.Info.Heads || entry.dp_ssect > imagePlugin.Info.SectorsPerTrack ||
|
||||
entry.dp_esect > imagePlugin.Info.SectorsPerTrack) continue;
|
||||
|
||||
Partition part = new Partition
|
||||
{
|
||||
Start =
|
||||
CHS.ToLBA(entry.dp_scyl, entry.dp_shd, (uint)(entry.dp_ssect + 1), imagePlugin.ImageInfo.Heads,
|
||||
imagePlugin.ImageInfo.SectorsPerTrack),
|
||||
CHS.ToLBA(entry.dp_scyl, entry.dp_shd, (uint)(entry.dp_ssect + 1), imagePlugin.Info.Heads,
|
||||
imagePlugin.Info.SectorsPerTrack),
|
||||
Type = DecodePC98Sid(entry.dp_sid),
|
||||
Name = StringHandlers.CToString(entry.dp_name, Encoding.GetEncoding(932)).Trim(),
|
||||
Sequence = counter,
|
||||
Scheme = Name
|
||||
};
|
||||
part.Offset = part.Start * imagePlugin.ImageInfo.SectorSize;
|
||||
part.Length = CHS.ToLBA(entry.dp_ecyl, entry.dp_ehd, (uint)(entry.dp_esect + 1),
|
||||
imagePlugin.ImageInfo.Heads, imagePlugin.ImageInfo.SectorsPerTrack) -
|
||||
part.Start;
|
||||
part.Size = part.Length * imagePlugin.ImageInfo.SectorSize;
|
||||
part.Offset = part.Start * imagePlugin.Info.SectorSize;
|
||||
part.Length = CHS.ToLBA(entry.dp_ecyl, entry.dp_ehd, (uint)(entry.dp_esect + 1), imagePlugin.Info.Heads,
|
||||
imagePlugin.Info.SectorsPerTrack) - part.Start;
|
||||
part.Size = part.Length * imagePlugin.Info.SectorSize;
|
||||
|
||||
DicConsole.DebugWriteLine("PC98 plugin", "part.Start = {0}", part.Start);
|
||||
DicConsole.DebugWriteLine("PC98 plugin", "part.Type = {0}", part.Type);
|
||||
@@ -115,7 +110,7 @@ namespace DiscImageChef.Partitions
|
||||
DicConsole.DebugWriteLine("PC98 plugin", "part.Size = {0}", part.Size);
|
||||
|
||||
if((entry.dp_mid & 0x20) != 0x20 && (entry.dp_mid & 0x44) != 0x44 ||
|
||||
part.Start >= imagePlugin.ImageInfo.Sectors || part.End > imagePlugin.ImageInfo.Sectors) continue;
|
||||
part.Start >= imagePlugin.Info.Sectors || part.End > imagePlugin.Info.Sectors) continue;
|
||||
|
||||
partitions.Add(part);
|
||||
counter++;
|
||||
|
||||
@@ -43,19 +43,16 @@ namespace DiscImageChef.Partitions
|
||||
// "part type start end\n"
|
||||
// One line per partition, start and end relative to offset
|
||||
// e.g.: "part nvram 10110 10112\npart fossil 10112 3661056\n"
|
||||
public class Plan9 : PartitionPlugin
|
||||
public class Plan9 : IPartition
|
||||
{
|
||||
public Plan9()
|
||||
{
|
||||
Name = "Plan9 partition table";
|
||||
PluginUuid = new Guid("F0BF4FFC-056E-4E7C-8B65-4EAEE250ADD9");
|
||||
}
|
||||
public virtual string Name => "Plan9 partition table";
|
||||
public virtual Guid Id => new Guid("F0BF4FFC-056E-4E7C-8B65-4EAEE250ADD9");
|
||||
|
||||
public override bool GetInformation(ImagePlugin imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
public virtual bool GetInformation(IMediaImage imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
{
|
||||
partitions = new List<Partition>();
|
||||
|
||||
if(sectorOffset + 2 >= imagePlugin.ImageInfo.Sectors) return false;
|
||||
if(sectorOffset + 2 >= imagePlugin.Info.Sectors) return false;
|
||||
|
||||
byte[] sector = imagePlugin.ReadSector(sectorOffset + 1);
|
||||
// While all of Plan9 is supposedly UTF-8, it uses ASCII strcmp for reading its partition table
|
||||
@@ -69,10 +66,10 @@ namespace DiscImageChef.Partitions
|
||||
Partition part = new Partition
|
||||
{
|
||||
Length = end - start + 1,
|
||||
Offset = (start + sectorOffset) * imagePlugin.ImageInfo.SectorSize,
|
||||
Offset = (start + sectorOffset) * imagePlugin.Info.SectorSize,
|
||||
Scheme = Name,
|
||||
Sequence = (ulong)partitions.Count,
|
||||
Size = (end - start + 1) * imagePlugin.ImageInfo.SectorSize,
|
||||
Size = (end - start + 1) * imagePlugin.Info.SectorSize,
|
||||
Start = start + sectorOffset,
|
||||
Type = tokens[1]
|
||||
};
|
||||
|
||||
@@ -41,7 +41,7 @@ using DiscImageChef.DiscImages;
|
||||
|
||||
namespace DiscImageChef.Partitions
|
||||
{
|
||||
public class AmigaRigidDiskBlock : PartitionPlugin
|
||||
public class AmigaRigidDiskBlock : IPartition
|
||||
{
|
||||
/// <summary>
|
||||
/// RDB magic number "RDSK"
|
||||
@@ -275,13 +275,10 @@ namespace DiscImageChef.Partitions
|
||||
/// </summary>
|
||||
const uint FLAGS_NO_AUTOMOUNT = 0x00000002;
|
||||
|
||||
public AmigaRigidDiskBlock()
|
||||
{
|
||||
Name = "Amiga Rigid Disk Block";
|
||||
PluginUuid = new Guid("8D72ED97-1854-4170-9CE4-6E8446FD9863");
|
||||
}
|
||||
public virtual string Name => "Amiga Rigid Disk Block";
|
||||
public virtual Guid Id => new Guid("8D72ED97-1854-4170-9CE4-6E8446FD9863");
|
||||
|
||||
public override bool GetInformation(ImagePlugin imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
public virtual bool GetInformation(IMediaImage imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
{
|
||||
partitions = new List<Partition>();
|
||||
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
||||
@@ -290,9 +287,9 @@ namespace DiscImageChef.Partitions
|
||||
|
||||
while(rdbBlock < 16)
|
||||
{
|
||||
if(imagePlugin.ImageInfo.Sectors <= rdbBlock) return false;
|
||||
if(imagePlugin.Info.Sectors <= rdbBlock) return false;
|
||||
|
||||
if(rdbBlock + sectorOffset >= imagePlugin.ImageInfo.Sectors) break;
|
||||
if(rdbBlock + sectorOffset >= imagePlugin.Info.Sectors) break;
|
||||
|
||||
byte[] tmpSector = imagePlugin.ReadSector(rdbBlock + sectorOffset);
|
||||
uint magic = BigEndianBitConverter.ToUInt32(tmpSector, 0);
|
||||
|
||||
@@ -39,18 +39,15 @@ using DiscImageChef.DiscImages;
|
||||
|
||||
namespace DiscImageChef.Partitions
|
||||
{
|
||||
public class RioKarma : PartitionPlugin
|
||||
public class RioKarma : IPartition
|
||||
{
|
||||
const ushort KARMA_MAGIC = 0xAB56;
|
||||
const byte ENTRY_MAGIC = 0x4D;
|
||||
|
||||
public RioKarma()
|
||||
{
|
||||
Name = "Rio Karma partitioning";
|
||||
PluginUuid = new Guid("246A6D93-4F1A-1F8A-344D-50187A5513A9");
|
||||
}
|
||||
public virtual string Name => "Rio Karma partitioning";
|
||||
public virtual Guid Id => new Guid("246A6D93-4F1A-1F8A-344D-50187A5513A9");
|
||||
|
||||
public override bool GetInformation(ImagePlugin imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
public virtual bool GetInformation(IMediaImage imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
{
|
||||
partitions = new List<Partition>();
|
||||
|
||||
|
||||
@@ -44,17 +44,14 @@ using DiscImageChef.DiscImages;
|
||||
namespace DiscImageChef.Partitions
|
||||
{
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class SGI : PartitionPlugin
|
||||
public class SGI : IPartition
|
||||
{
|
||||
const int SGI_MAGIC = 0x0BE5A941;
|
||||
|
||||
public SGI()
|
||||
{
|
||||
Name = "SGI Disk Volume Header";
|
||||
PluginUuid = new Guid("AEF5AB45-4880-4CE8-8735-F0A402E2E5F2");
|
||||
}
|
||||
public virtual string Name => "SGI Disk Volume Header";
|
||||
public virtual Guid Id => new Guid("AEF5AB45-4880-4CE8-8735-F0A402E2E5F2");
|
||||
|
||||
public override bool GetInformation(ImagePlugin imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
public virtual bool GetInformation(IMediaImage imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
{
|
||||
partitions = new List<Partition>();
|
||||
|
||||
@@ -121,12 +118,9 @@ namespace DiscImageChef.Partitions
|
||||
|
||||
Partition part = new Partition
|
||||
{
|
||||
Start =
|
||||
dvh.partitions[i].first_block * dvh.device_params.dp_secbytes /
|
||||
imagePlugin.ImageInfo.SectorSize,
|
||||
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.ImageInfo.SectorSize,
|
||||
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,
|
||||
|
||||
@@ -42,7 +42,7 @@ using DiscImageChef.DiscImages;
|
||||
namespace DiscImageChef.Partitions
|
||||
{
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class SunDisklabel : PartitionPlugin
|
||||
public class SunDisklabel : IPartition
|
||||
{
|
||||
/// <summary>Sun disklabel magic number</summary>
|
||||
const ushort DKL_MAGIC = 0xDABE;
|
||||
@@ -70,19 +70,16 @@ namespace DiscImageChef.Partitions
|
||||
const int LEN_DKL_PAD16 = DK_LABEL_SIZE - (456 + // sizeof(dk_vtoc16)
|
||||
4 * 4 + 12 * 2 + 2 * 2);
|
||||
|
||||
public SunDisklabel()
|
||||
{
|
||||
Name = "Sun Disklabel";
|
||||
PluginUuid = new Guid("50F35CC4-8375-4445-8DCB-1BA550C931A3");
|
||||
}
|
||||
public virtual string Name => "Sun Disklabel";
|
||||
public virtual Guid Id => new Guid("50F35CC4-8375-4445-8DCB-1BA550C931A3");
|
||||
|
||||
public override bool GetInformation(ImagePlugin imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
public virtual bool GetInformation(IMediaImage imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
{
|
||||
partitions = new List<Partition>();
|
||||
|
||||
if(imagePlugin.ImageInfo.SectorSize < 512) return false;
|
||||
if(imagePlugin.Info.SectorSize < 512) return false;
|
||||
|
||||
if(sectorOffset + 2 >= imagePlugin.ImageInfo.Sectors) return false;
|
||||
if(sectorOffset + 2 >= imagePlugin.Info.Sectors) return false;
|
||||
|
||||
bool useDkl = false, useDkl8 = false, useDkl16 = false;
|
||||
|
||||
@@ -162,16 +159,16 @@ namespace DiscImageChef.Partitions
|
||||
{
|
||||
Size = (ulong)dkl.dkl_map[i].dkl_nblk * DK_LABEL_SIZE,
|
||||
Length =
|
||||
(ulong)(dkl.dkl_map[i].dkl_nblk * DK_LABEL_SIZE / imagePlugin.ImageInfo.SectorSize),
|
||||
(ulong)(dkl.dkl_map[i].dkl_nblk * DK_LABEL_SIZE / imagePlugin.Info.SectorSize),
|
||||
Sequence = (ulong)i,
|
||||
Offset =
|
||||
((ulong)dkl.dkl_map[i].dkl_cylno * sectorsPerCylinder + sectorOffset) * DK_LABEL_SIZE,
|
||||
Start = ((ulong)dkl.dkl_map[i].dkl_cylno * sectorsPerCylinder + sectorOffset) *
|
||||
DK_LABEL_SIZE / imagePlugin.ImageInfo.SectorSize,
|
||||
DK_LABEL_SIZE / imagePlugin.Info.SectorSize,
|
||||
Type = "SunOS partition",
|
||||
Scheme = Name
|
||||
};
|
||||
if(part.Start < imagePlugin.ImageInfo.Sectors && part.End <= imagePlugin.ImageInfo.Sectors)
|
||||
if(part.Start < imagePlugin.Info.Sectors && part.End <= imagePlugin.Info.Sectors)
|
||||
partitions.Add(part);
|
||||
}
|
||||
}
|
||||
@@ -229,12 +226,12 @@ namespace DiscImageChef.Partitions
|
||||
Description = SunFlagsToString(dkl8.dkl_vtoc.v_part[i].p_flag),
|
||||
Size = (ulong)dkl8.dkl_map[i].dkl_nblk * DK_LABEL_SIZE,
|
||||
Length =
|
||||
(ulong)(dkl8.dkl_map[i].dkl_nblk * DK_LABEL_SIZE / imagePlugin.ImageInfo.SectorSize),
|
||||
(ulong)(dkl8.dkl_map[i].dkl_nblk * DK_LABEL_SIZE / imagePlugin.Info.SectorSize),
|
||||
Sequence = (ulong)i,
|
||||
Offset =
|
||||
((ulong)dkl8.dkl_map[i].dkl_cylno * sectorsPerCylinder + sectorOffset) * DK_LABEL_SIZE,
|
||||
Start = ((ulong)dkl8.dkl_map[i].dkl_cylno * sectorsPerCylinder + sectorOffset) *
|
||||
DK_LABEL_SIZE / imagePlugin.ImageInfo.SectorSize,
|
||||
DK_LABEL_SIZE / imagePlugin.Info.SectorSize,
|
||||
Type = SunIdToString(dkl8.dkl_vtoc.v_part[i].p_tag),
|
||||
Scheme = Name
|
||||
};
|
||||
@@ -242,7 +239,7 @@ namespace DiscImageChef.Partitions
|
||||
part.Description +=
|
||||
$"\nPartition timestamped on {DateHandlers.UnixToDateTime(dkl8.dkl_vtoc.v_timestamp[i])}";
|
||||
|
||||
if(part.Start < imagePlugin.ImageInfo.Sectors && part.End <= imagePlugin.ImageInfo.Sectors)
|
||||
if(part.Start < imagePlugin.Info.Sectors && part.End <= imagePlugin.Info.Sectors)
|
||||
partitions.Add(part);
|
||||
}
|
||||
}
|
||||
@@ -297,19 +294,19 @@ namespace DiscImageChef.Partitions
|
||||
Size = (ulong)dkl16.dkl_vtoc.v_part[i].p_size * dkl16.dkl_vtoc.v_sectorsz,
|
||||
Length =
|
||||
(ulong)(dkl16.dkl_vtoc.v_part[i].p_size * dkl16.dkl_vtoc.v_sectorsz /
|
||||
imagePlugin.ImageInfo.SectorSize),
|
||||
imagePlugin.Info.SectorSize),
|
||||
Sequence = (ulong)i,
|
||||
Offset =
|
||||
((ulong)dkl16.dkl_vtoc.v_part[i].p_start + sectorOffset) * dkl16.dkl_vtoc.v_sectorsz,
|
||||
Start = ((ulong)dkl16.dkl_vtoc.v_part[i].p_start + sectorOffset) *
|
||||
dkl16.dkl_vtoc.v_sectorsz / imagePlugin.ImageInfo.SectorSize,
|
||||
dkl16.dkl_vtoc.v_sectorsz / imagePlugin.Info.SectorSize,
|
||||
Type = SunIdToString(dkl16.dkl_vtoc.v_part[i].p_tag),
|
||||
Scheme = Name
|
||||
};
|
||||
if(dkl16.dkl_vtoc.v_timestamp[i] != 0)
|
||||
part.Description +=
|
||||
$"\nPartition timestamped on {DateHandlers.UnixToDateTime(dkl16.dkl_vtoc.v_timestamp[i])}";
|
||||
if(part.Start < imagePlugin.ImageInfo.Sectors && part.End <= imagePlugin.ImageInfo.Sectors)
|
||||
if(part.Start < imagePlugin.Info.Sectors && part.End <= imagePlugin.Info.Sectors)
|
||||
partitions.Add(part);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace DiscImageChef.Partitions
|
||||
// These partitions are hardwired in kernel sources for some UNIX versions predating System V.
|
||||
// They depend on exact device, indeed the kernel chooses what to use depending on the disk driver, so that's what we do.
|
||||
// Currently only DEC devices used in Ultrix are added, probably it's missing a lot of entries.
|
||||
public class UNIX : PartitionPlugin
|
||||
public class UNIX : IPartition
|
||||
{
|
||||
readonly Partition[] RA60 =
|
||||
{
|
||||
@@ -1369,20 +1369,17 @@ namespace DiscImageChef.Partitions
|
||||
}
|
||||
};
|
||||
|
||||
public UNIX()
|
||||
{
|
||||
Name = "UNIX hardwired";
|
||||
PluginUuid = new Guid("9ED7E30B-53BF-4619-87A0-5D2002155617");
|
||||
}
|
||||
public virtual string Name => "UNIX hardwired";
|
||||
public virtual Guid Id => new Guid("9ED7E30B-53BF-4619-87A0-5D2002155617");
|
||||
|
||||
public override bool GetInformation(ImagePlugin imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
public virtual bool GetInformation(IMediaImage imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
{
|
||||
partitions = new List<Partition>();
|
||||
Partition[] parts;
|
||||
|
||||
if(sectorOffset != 0) return false;
|
||||
|
||||
switch(imagePlugin.ImageInfo.MediaType)
|
||||
switch(imagePlugin.Info.MediaType)
|
||||
{
|
||||
case MediaType.RA60:
|
||||
parts = RA60;
|
||||
|
||||
@@ -40,7 +40,7 @@ using DiscImageChef.DiscImages;
|
||||
|
||||
namespace DiscImageChef.Partitions
|
||||
{
|
||||
public class VTOC : PartitionPlugin
|
||||
public class VTOC : IPartition
|
||||
{
|
||||
const uint PD_MAGIC = 0xCA5E600D;
|
||||
const uint VTOC_SANE = 0x600DDEEE;
|
||||
@@ -49,13 +49,10 @@ namespace DiscImageChef.Partitions
|
||||
const int V_NUMPAR = 16;
|
||||
const uint XPDVERS = 3; /* 1st version of extended pdinfo */
|
||||
|
||||
public VTOC()
|
||||
{
|
||||
Name = "UNIX VTOC";
|
||||
PluginUuid = new Guid("6D35A66F-8D77-426F-A562-D88F6A1F1702");
|
||||
}
|
||||
public virtual string Name => "UNIX VTOC";
|
||||
public virtual Guid Id => new Guid("6D35A66F-8D77-426F-A562-D88F6A1F1702");
|
||||
|
||||
public override bool GetInformation(ImagePlugin imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
public virtual bool GetInformation(IMediaImage imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
{
|
||||
partitions = new List<Partition>();
|
||||
|
||||
@@ -65,8 +62,7 @@ namespace DiscImageChef.Partitions
|
||||
bool magicFound = false;
|
||||
bool absolute = false;
|
||||
|
||||
foreach(ulong i in
|
||||
new ulong[] {0, 1, 8, 29}.TakeWhile(i => i + sectorOffset < imagePlugin.ImageInfo.Sectors))
|
||||
foreach(ulong i in new ulong[] {0, 1, 8, 29}.TakeWhile(i => i + sectorOffset < imagePlugin.Info.Sectors))
|
||||
{
|
||||
pdsector = imagePlugin.ReadSector(i + sectorOffset);
|
||||
magic = BitConverter.ToUInt32(pdsector, 4);
|
||||
@@ -205,14 +201,14 @@ namespace DiscImageChef.Partitions
|
||||
if(!magicFound)
|
||||
{
|
||||
DicConsole.DebugWriteLine("VTOC plugin", "Searching for VTOC on relative byte {0}", pd.vtoc_ptr);
|
||||
ulong relSecPtr = pd.vtoc_ptr / imagePlugin.ImageInfo.SectorSize;
|
||||
uint relSecOff = pd.vtoc_ptr % imagePlugin.ImageInfo.SectorSize;
|
||||
uint secCount = (relSecOff + pd.vtoc_len) / imagePlugin.ImageInfo.SectorSize;
|
||||
if((relSecOff + pd.vtoc_len) % imagePlugin.ImageInfo.SectorSize > 0) secCount++;
|
||||
ulong relSecPtr = pd.vtoc_ptr / imagePlugin.Info.SectorSize;
|
||||
uint relSecOff = pd.vtoc_ptr % imagePlugin.Info.SectorSize;
|
||||
uint secCount = (relSecOff + pd.vtoc_len) / imagePlugin.Info.SectorSize;
|
||||
if((relSecOff + pd.vtoc_len) % imagePlugin.Info.SectorSize > 0) secCount++;
|
||||
DicConsole.DebugWriteLine("VTOC plugin",
|
||||
"Going to read {0} sectors from sector {1}, getting VTOC from byte {2}",
|
||||
secCount, relSecPtr + sectorOffset, relSecOff);
|
||||
if(relSecPtr + sectorOffset + secCount >= imagePlugin.ImageInfo.Sectors)
|
||||
if(relSecPtr + sectorOffset + secCount >= imagePlugin.Info.Sectors)
|
||||
{
|
||||
DicConsole.DebugWriteLine("VTOC plugin", "Going to read past device size, aborting...");
|
||||
return false;
|
||||
@@ -331,8 +327,8 @@ namespace DiscImageChef.Partitions
|
||||
{
|
||||
Partition part = new Partition
|
||||
{
|
||||
Start = (ulong)(parts[i].p_start * bps) / imagePlugin.ImageInfo.SectorSize,
|
||||
Length = (ulong)(parts[i].p_size * bps) / imagePlugin.ImageInfo.SectorSize,
|
||||
Start = (ulong)(parts[i].p_start * bps) / imagePlugin.Info.SectorSize,
|
||||
Length = (ulong)(parts[i].p_size * bps) / imagePlugin.Info.SectorSize,
|
||||
Offset = (ulong)(parts[i].p_start * bps),
|
||||
Size = (ulong)(parts[i].p_size * bps),
|
||||
Sequence = (ulong)i,
|
||||
@@ -345,7 +341,7 @@ namespace DiscImageChef.Partitions
|
||||
if(!useOld && !absolute)
|
||||
{
|
||||
part.Start += sectorOffset;
|
||||
part.Offset += sectorOffset * imagePlugin.ImageInfo.SectorSize;
|
||||
part.Offset += sectorOffset * imagePlugin.Info.SectorSize;
|
||||
}
|
||||
|
||||
if(parts[i].p_flag.HasFlag(pFlag.V_VALID)) info += " (valid)";
|
||||
@@ -357,7 +353,7 @@ namespace DiscImageChef.Partitions
|
||||
|
||||
part.Description = "UNIX slice" + info + ".";
|
||||
|
||||
if(part.End < imagePlugin.ImageInfo.Sectors) partitions.Add(part);
|
||||
if(part.End < imagePlugin.Info.Sectors) partitions.Add(part);
|
||||
}
|
||||
|
||||
return partitions.Count > 0;
|
||||
|
||||
@@ -40,7 +40,7 @@ using DiscImageChef.DiscImages;
|
||||
namespace DiscImageChef.Partitions
|
||||
{
|
||||
// TODO: Find better documentation, this is working for XENIX 2 but not for SCO OpenServer...
|
||||
public class XENIX : PartitionPlugin
|
||||
public class XENIX : IPartition
|
||||
{
|
||||
const ushort PAMAGIC = 0x1234;
|
||||
const int MAXPARTS = 16;
|
||||
@@ -48,17 +48,14 @@ namespace DiscImageChef.Partitions
|
||||
// Can't find this in any documentation but everything is aligned to this offset (in sectors)
|
||||
const uint XENIX_OFFSET = 977;
|
||||
|
||||
public XENIX()
|
||||
{
|
||||
Name = "XENIX";
|
||||
PluginUuid = new Guid("53BE01DE-E68B-469F-A17F-EC2E4BD61CD9");
|
||||
}
|
||||
public virtual string Name => "XENIX";
|
||||
public virtual Guid Id => new Guid("53BE01DE-E68B-469F-A17F-EC2E4BD61CD9");
|
||||
|
||||
public override bool GetInformation(ImagePlugin imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
public virtual bool GetInformation(IMediaImage imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
{
|
||||
partitions = new List<Partition>();
|
||||
|
||||
if(42 + sectorOffset >= imagePlugin.ImageInfo.Sectors) return false;
|
||||
if(42 + sectorOffset >= imagePlugin.Info.Sectors) return false;
|
||||
|
||||
byte[] tblsector = imagePlugin.ReadSector(42 + sectorOffset);
|
||||
|
||||
@@ -80,19 +77,19 @@ namespace DiscImageChef.Partitions
|
||||
Partition part = new Partition
|
||||
{
|
||||
Start =
|
||||
(ulong)((xnxtbl.p[i].p_off + XENIX_OFFSET) * XENIX_BSIZE) / imagePlugin.ImageInfo.SectorSize +
|
||||
(ulong)((xnxtbl.p[i].p_off + XENIX_OFFSET) * XENIX_BSIZE) / imagePlugin.Info.SectorSize +
|
||||
sectorOffset,
|
||||
Length = (ulong)(xnxtbl.p[i].p_size * XENIX_BSIZE) / imagePlugin.ImageInfo.SectorSize,
|
||||
Length = (ulong)(xnxtbl.p[i].p_size * XENIX_BSIZE) / imagePlugin.Info.SectorSize,
|
||||
Offset =
|
||||
(ulong)((xnxtbl.p[i].p_off + XENIX_OFFSET) * XENIX_BSIZE) +
|
||||
imagePlugin.ImageInfo.SectorSize * sectorOffset,
|
||||
imagePlugin.Info.SectorSize * sectorOffset,
|
||||
Size = (ulong)(xnxtbl.p[i].p_size * XENIX_BSIZE),
|
||||
Sequence = (ulong)i,
|
||||
Type = "XENIX",
|
||||
Scheme = Name
|
||||
};
|
||||
|
||||
if(part.End < imagePlugin.ImageInfo.Sectors) partitions.Add(part);
|
||||
if(part.End < imagePlugin.Info.Sectors) partitions.Add(part);
|
||||
}
|
||||
|
||||
return partitions.Count > 0;
|
||||
|
||||
@@ -38,7 +38,7 @@ using DiscImageChef.DiscImages;
|
||||
|
||||
namespace DiscImageChef.Partitions
|
||||
{
|
||||
public class Xbox : PartitionPlugin
|
||||
public class Xbox : IPartition
|
||||
{
|
||||
const uint XboxCigam = 0x46415458;
|
||||
const uint XboxMagic = 0x58544146;
|
||||
@@ -60,13 +60,10 @@ namespace DiscImageChef.Partitions
|
||||
|
||||
const uint XBOX360_DEVKIT_MAGIC = 0x00020000;
|
||||
|
||||
public Xbox()
|
||||
{
|
||||
Name = "Xbox partitioning";
|
||||
PluginUuid = new Guid("E3F6FB91-D358-4F22-A550-81E92D50EB78");
|
||||
}
|
||||
public virtual string Name => "Xbox partitioning";
|
||||
public virtual Guid Id => new Guid("E3F6FB91-D358-4F22-A550-81E92D50EB78");
|
||||
|
||||
public override bool GetInformation(ImagePlugin imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
public virtual bool GetInformation(IMediaImage imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
{
|
||||
partitions = new List<Partition>();
|
||||
|
||||
@@ -79,17 +76,16 @@ namespace DiscImageChef.Partitions
|
||||
Xbox360DevKitPartitionTable table =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<Xbox360DevKitPartitionTable>(sector);
|
||||
|
||||
if(table.magic == XBOX360_DEVKIT_MAGIC &&
|
||||
table.contentOff + table.contentLen <= imagePlugin.ImageInfo.Sectors &&
|
||||
table.dashboardOff + table.dashboardLen <= imagePlugin.ImageInfo.Sectors)
|
||||
if(table.magic == XBOX360_DEVKIT_MAGIC && table.contentOff + table.contentLen <= imagePlugin.Info.Sectors &&
|
||||
table.dashboardOff + table.dashboardLen <= imagePlugin.Info.Sectors)
|
||||
{
|
||||
Partition contentPart = new Partition
|
||||
{
|
||||
Description = "Content volume",
|
||||
Size = (ulong)table.contentLen * imagePlugin.ImageInfo.SectorSize,
|
||||
Size = (ulong)table.contentLen * imagePlugin.Info.SectorSize,
|
||||
Length = table.contentLen,
|
||||
Sequence = 1,
|
||||
Offset = (ulong)table.contentOff * imagePlugin.ImageInfo.SectorSize,
|
||||
Offset = (ulong)table.contentOff * imagePlugin.Info.SectorSize,
|
||||
Start = table.contentOff,
|
||||
Scheme = Name
|
||||
};
|
||||
@@ -97,10 +93,10 @@ namespace DiscImageChef.Partitions
|
||||
Partition dashboardPart = new Partition
|
||||
{
|
||||
Description = "Dashboard volume",
|
||||
Size = (ulong)table.dashboardLen * imagePlugin.ImageInfo.SectorSize,
|
||||
Size = (ulong)table.dashboardLen * imagePlugin.Info.SectorSize,
|
||||
Length = table.dashboardLen,
|
||||
Sequence = 2,
|
||||
Offset = (ulong)table.dashboardOff * imagePlugin.ImageInfo.SectorSize,
|
||||
Offset = (ulong)table.dashboardOff * imagePlugin.Info.SectorSize,
|
||||
Start = table.dashboardOff,
|
||||
Scheme = Name
|
||||
};
|
||||
@@ -113,9 +109,9 @@ namespace DiscImageChef.Partitions
|
||||
|
||||
uint temp;
|
||||
|
||||
if(imagePlugin.ImageInfo.Sectors > (ulong)(MemoryUnitDataOff / imagePlugin.ImageInfo.SectorSize))
|
||||
if(imagePlugin.Info.Sectors > (ulong)(MemoryUnitDataOff / imagePlugin.Info.SectorSize))
|
||||
{
|
||||
sector = imagePlugin.ReadSector((ulong)(MemoryUnitDataOff / imagePlugin.ImageInfo.SectorSize));
|
||||
sector = imagePlugin.ReadSector((ulong)(MemoryUnitDataOff / imagePlugin.Info.SectorSize));
|
||||
temp = BitConverter.ToUInt32(sector, 0);
|
||||
|
||||
if(temp == XboxCigam)
|
||||
@@ -124,7 +120,7 @@ namespace DiscImageChef.Partitions
|
||||
{
|
||||
Description = "System cache",
|
||||
Size = MemoryUnitDataOff,
|
||||
Length = (ulong)(MemoryUnitDataOff / imagePlugin.ImageInfo.SectorSize),
|
||||
Length = (ulong)(MemoryUnitDataOff / imagePlugin.Info.SectorSize),
|
||||
Sequence = 1,
|
||||
Offset = 0,
|
||||
Start = 0,
|
||||
@@ -134,8 +130,8 @@ namespace DiscImageChef.Partitions
|
||||
Partition dataPart = new Partition
|
||||
{
|
||||
Description = "Data volume",
|
||||
Size = imagePlugin.ImageInfo.Sectors * imagePlugin.ImageInfo.SectorSize - MemoryUnitDataOff,
|
||||
Length = imagePlugin.ImageInfo.Sectors - sysCachePart.Length,
|
||||
Size = imagePlugin.Info.Sectors * imagePlugin.Info.SectorSize - MemoryUnitDataOff,
|
||||
Length = imagePlugin.Info.Sectors - sysCachePart.Length,
|
||||
Sequence = 2,
|
||||
Offset = MemoryUnitDataOff,
|
||||
Start = sysCachePart.Length,
|
||||
@@ -149,11 +145,10 @@ namespace DiscImageChef.Partitions
|
||||
}
|
||||
}
|
||||
|
||||
if(imagePlugin.ImageInfo.Sectors <= (ulong)(Xbox360DataOff / imagePlugin.ImageInfo.SectorSize))
|
||||
return false;
|
||||
if(imagePlugin.Info.Sectors <= (ulong)(Xbox360DataOff / imagePlugin.Info.SectorSize)) return false;
|
||||
|
||||
{
|
||||
sector = imagePlugin.ReadSector((ulong)(Xbox360DataOff / imagePlugin.ImageInfo.SectorSize));
|
||||
sector = imagePlugin.ReadSector((ulong)(Xbox360DataOff / imagePlugin.Info.SectorSize));
|
||||
temp = BitConverter.ToUInt32(sector, 0);
|
||||
|
||||
if(temp != XboxCigam) return false;
|
||||
@@ -162,10 +157,10 @@ namespace DiscImageChef.Partitions
|
||||
{
|
||||
Description = "Security sectors",
|
||||
Size = Xbox360SecuritySectorLen,
|
||||
Length = (ulong)(Xbox360SecuritySectorLen / imagePlugin.ImageInfo.SectorSize),
|
||||
Length = (ulong)(Xbox360SecuritySectorLen / imagePlugin.Info.SectorSize),
|
||||
Sequence = 1,
|
||||
Offset = Xbox360SecuritySectorOff,
|
||||
Start = (ulong)(Xbox360SecuritySectorOff / imagePlugin.ImageInfo.SectorSize),
|
||||
Start = (ulong)(Xbox360SecuritySectorOff / imagePlugin.Info.SectorSize),
|
||||
Scheme = Name
|
||||
};
|
||||
|
||||
@@ -173,10 +168,10 @@ namespace DiscImageChef.Partitions
|
||||
{
|
||||
Description = "System cache",
|
||||
Size = Xbox360SystemCacheLen,
|
||||
Length = (ulong)(Xbox360SystemCacheLen / imagePlugin.ImageInfo.SectorSize),
|
||||
Length = (ulong)(Xbox360SystemCacheLen / imagePlugin.Info.SectorSize),
|
||||
Sequence = 2,
|
||||
Offset = Xbox360SystemCacheOff,
|
||||
Start = (ulong)(Xbox360SystemCacheOff / imagePlugin.ImageInfo.SectorSize),
|
||||
Start = (ulong)(Xbox360SystemCacheOff / imagePlugin.Info.SectorSize),
|
||||
Scheme = Name
|
||||
};
|
||||
|
||||
@@ -184,10 +179,10 @@ namespace DiscImageChef.Partitions
|
||||
{
|
||||
Description = "Game cache",
|
||||
Size = Xbox360GameCacheLen,
|
||||
Length = (ulong)(Xbox360GameCacheLen / imagePlugin.ImageInfo.SectorSize),
|
||||
Length = (ulong)(Xbox360GameCacheLen / imagePlugin.Info.SectorSize),
|
||||
Sequence = 3,
|
||||
Offset = Xbox360GameCacheOff,
|
||||
Start = (ulong)(Xbox360GameCacheOff / imagePlugin.ImageInfo.SectorSize),
|
||||
Start = (ulong)(Xbox360GameCacheOff / imagePlugin.Info.SectorSize),
|
||||
Scheme = Name
|
||||
};
|
||||
|
||||
@@ -195,10 +190,10 @@ namespace DiscImageChef.Partitions
|
||||
{
|
||||
Description = "System volume",
|
||||
Size = Xbox368SysExtLen,
|
||||
Length = (ulong)(Xbox368SysExtLen / imagePlugin.ImageInfo.SectorSize),
|
||||
Length = (ulong)(Xbox368SysExtLen / imagePlugin.Info.SectorSize),
|
||||
Sequence = 4,
|
||||
Offset = Xbox368SysExtOff,
|
||||
Start = (ulong)(Xbox368SysExtOff / imagePlugin.ImageInfo.SectorSize),
|
||||
Start = (ulong)(Xbox368SysExtOff / imagePlugin.Info.SectorSize),
|
||||
Scheme = Name
|
||||
};
|
||||
|
||||
@@ -206,10 +201,10 @@ namespace DiscImageChef.Partitions
|
||||
{
|
||||
Description = "System volume 2",
|
||||
Size = Xbox360SysExt2Len,
|
||||
Length = (ulong)(Xbox360SysExt2Len / imagePlugin.ImageInfo.SectorSize),
|
||||
Length = (ulong)(Xbox360SysExt2Len / imagePlugin.Info.SectorSize),
|
||||
Sequence = 5,
|
||||
Offset = Xbox360SysExt2Off,
|
||||
Start = (ulong)(Xbox360SysExt2Off / imagePlugin.ImageInfo.SectorSize),
|
||||
Start = (ulong)(Xbox360SysExt2Off / imagePlugin.Info.SectorSize),
|
||||
Scheme = Name
|
||||
};
|
||||
|
||||
@@ -217,10 +212,10 @@ namespace DiscImageChef.Partitions
|
||||
{
|
||||
Description = "Xbox backwards compatibility",
|
||||
Size = Xbox360CompatLen,
|
||||
Length = (ulong)(Xbox360CompatLen / imagePlugin.ImageInfo.SectorSize),
|
||||
Length = (ulong)(Xbox360CompatLen / imagePlugin.Info.SectorSize),
|
||||
Sequence = 6,
|
||||
Offset = Xbox360CompatOff,
|
||||
Start = (ulong)(Xbox360CompatOff / imagePlugin.ImageInfo.SectorSize),
|
||||
Start = (ulong)(Xbox360CompatOff / imagePlugin.Info.SectorSize),
|
||||
Scheme = Name
|
||||
};
|
||||
|
||||
@@ -229,11 +224,11 @@ namespace DiscImageChef.Partitions
|
||||
Description = "Data volume",
|
||||
Sequence = 7,
|
||||
Offset = Xbox360DataOff,
|
||||
Start = (ulong)(Xbox360DataOff / imagePlugin.ImageInfo.SectorSize),
|
||||
Start = (ulong)(Xbox360DataOff / imagePlugin.Info.SectorSize),
|
||||
Scheme = Name
|
||||
};
|
||||
dataPart.Length = imagePlugin.ImageInfo.Sectors - dataPart.Start;
|
||||
dataPart.Size = dataPart.Length * imagePlugin.ImageInfo.SectorSize;
|
||||
dataPart.Length = imagePlugin.Info.Sectors - dataPart.Start;
|
||||
dataPart.Size = dataPart.Length * imagePlugin.Info.SectorSize;
|
||||
|
||||
partitions.Add(securityPart);
|
||||
partitions.Add(sysCachePart);
|
||||
|
||||
Reference in New Issue
Block a user