REFACTOR: Reformat code.

This commit is contained in:
2017-12-19 20:33:03 +00:00
parent 77edc7c91c
commit e6f6ace80b
704 changed files with 82627 additions and 83641 deletions

View File

@@ -63,18 +63,14 @@ namespace DiscImageChef.PartPlugins
ulong sbSector;
// RISC OS always checks for the partition on 0. Afaik no emulator chains it.
if(sectorOffset != 0)
return false;
if(sectorOffset != 0) return false;
if(imagePlugin.GetSectorSize() > ADFS_SB_POS)
sbSector = 0;
else
sbSector = ADFS_SB_POS / imagePlugin.GetSectorSize();
if(imagePlugin.GetSectorSize() > ADFS_SB_POS) sbSector = 0;
else sbSector = ADFS_SB_POS / imagePlugin.GetSectorSize();
byte[] sector = imagePlugin.ReadSector(sbSector);
if(sector.Length < 512)
return false;
if(sector.Length < 512) return false;
AcornBootBlock bootBlock = new AcornBootBlock();
IntPtr bbPtr = Marshal.AllocHGlobal(512);
@@ -83,15 +79,13 @@ namespace DiscImageChef.PartPlugins
Marshal.FreeHGlobal(bbPtr);
int checksum = 0;
for(int i = 0; i < 0x1FF; i++)
checksum = ((checksum & 0xFF) + (checksum >> 8) + sector[i]);
for(int i = 0; i < 0x1FF; i++) checksum = ((checksum & 0xFF) + (checksum >> 8) + sector[i]);
int heads = bootBlock.discRecord.heads + ((bootBlock.discRecord.lowsector >> 6) & 1);
int secCyl = bootBlock.discRecord.spt * heads;
int mapSector = bootBlock.startCylinder * secCyl;
if((ulong)mapSector >= imagePlugin.GetSectors())
return false;
if((ulong)mapSector >= imagePlugin.GetSectors()) return false;
byte[] map = imagePlugin.ReadSector((ulong)mapSector);
@@ -102,7 +96,9 @@ namespace DiscImageChef.PartPlugins
Partition part = new Partition
{
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,
Length =
((ulong)bootBlock.discRecord.disc_size_high * 0x100000000 + bootBlock.discRecord.disc_size) /
imagePlugin.ImageInfo.sectorSize,
Type = "ADFS",
Name = StringHandlers.CToString(bootBlock.discRecord.disc_name, Encoding.GetEncoding("iso-8859-1"))
};
@@ -191,23 +187,20 @@ namespace DiscImageChef.PartPlugins
public uint root;
public uint disc_size;
public ushort disc_id;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)]
public byte[] disc_name;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] public byte[] disc_name;
public uint disc_type;
public uint disc_size_high;
public byte flags;
public byte nzones_high;
public uint format_version;
public uint root_size;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public byte[] reserved;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] reserved;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct AcornBootBlock
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x1C0)]
public byte[] spare;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x1C0)] public byte[] spare;
public DiscRecord discRecord;
public byte flags;
public ushort startCylinder;
@@ -217,10 +210,8 @@ namespace DiscImageChef.PartPlugins
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct LinuxTable
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 42)]
public LinuxEntry[] entries;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public byte[] padding;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 42)] public LinuxEntry[] entries;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] padding;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
@@ -236,8 +227,7 @@ namespace DiscImageChef.PartPlugins
{
public uint magic;
public uint date;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public RiscIxEntry[] partitions;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public RiscIxEntry[] partitions;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
@@ -246,8 +236,7 @@ namespace DiscImageChef.PartPlugins
public uint start;
public uint length;
public uint one;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] name;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] name;
}
}
}

View File

@@ -57,19 +57,17 @@ namespace DiscImageChef.PartPlugins
PluginUUID = new Guid("36405F8D-4F1A-07F5-209C-223D735D6D22");
}
public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin, out List<CommonTypes.Partition> partitions, ulong sectorOffset)
public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin,
out List<CommonTypes.Partition> partitions, ulong sectorOffset)
{
uint sector_size;
if(imagePlugin.GetSectorSize() == 2352 || imagePlugin.GetSectorSize() == 2448)
sector_size = 2048;
else
sector_size = imagePlugin.GetSectorSize();
if(imagePlugin.GetSectorSize() == 2352 || imagePlugin.GetSectorSize() == 2448) sector_size = 2048;
else sector_size = imagePlugin.GetSectorSize();
partitions = new List<CommonTypes.Partition>();
if(sectorOffset + 2 >= imagePlugin.GetSectors())
return false;
if(sectorOffset + 2 >= imagePlugin.GetSectors()) return false;
byte[] ddm_sector = imagePlugin.ReadSector(sectorOffset);
AppleDriverDescriptorMap ddm;
@@ -83,9 +81,8 @@ namespace DiscImageChef.PartPlugins
ddm_sector = tmp;
max_drivers = 29;
}
else if(sector_size < 256)
return false;
else if(sector_size < 256) return false;
ddm = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDriverDescriptorMap>(ddm_sector);
DicConsole.DebugWriteLine("AppleMap Plugin", "ddm.sbSig = 0x{0:X4}", ddm.sbSig);
@@ -108,13 +105,15 @@ namespace DiscImageChef.PartPlugins
byte[] tmp = new byte[8];
Array.Copy(ddm_sector, 18 + i * 8, tmp, 0, 8);
ddm.sbMap[i] = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDriverEntry>(tmp);
DicConsole.DebugWriteLine("AppleMap Plugin", "ddm.sbMap[{1}].ddBlock = {0}", ddm.sbMap[i].ddBlock, i);
DicConsole.DebugWriteLine("AppleMap Plugin", "ddm.sbMap[{1}].ddSize = {0}", ddm.sbMap[i].ddSize, i);
DicConsole.DebugWriteLine("AppleMap Plugin", "ddm.sbMap[{1}].ddType = {0}", ddm.sbMap[i].ddType, i);
DicConsole.DebugWriteLine("AppleMap Plugin", "ddm.sbMap[{1}].ddBlock = {0}",
ddm.sbMap[i].ddBlock, i);
DicConsole.DebugWriteLine("AppleMap Plugin", "ddm.sbMap[{1}].ddSize = {0}", ddm.sbMap[i].ddSize,
i);
DicConsole.DebugWriteLine("AppleMap Plugin", "ddm.sbMap[{1}].ddType = {0}", ddm.sbMap[i].ddType,
i);
if(ddm.sbMap[i].ddSize == 0) continue;
if(ddm.sbMap[i].ddSize == 0)
continue;
CommonTypes.Partition part = new CommonTypes.Partition()
{
Size = (ulong)(ddm.sbMap[i].ddSize * 512),
@@ -125,8 +124,7 @@ namespace DiscImageChef.PartPlugins
Type = "Apple_Driver"
};
if((ddm.sbMap[i].ddSize * 512) % sector_size > 0)
part.Length++;
if((ddm.sbMap[i].ddSize * 512) % sector_size > 0) part.Length++;
partitions.Add(part);
@@ -136,24 +134,29 @@ namespace DiscImageChef.PartPlugins
}
byte[] part_sector = imagePlugin.ReadSector(1 + sectorOffset);
AppleOldDevicePartitionMap old_map = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleOldDevicePartitionMap>(part_sector);
AppleOldDevicePartitionMap old_map =
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleOldDevicePartitionMap>(part_sector);
// This is the easy one, no sector size mixing
if(old_map.pdSig == APM_MAGIC_OLD)
{
for(int i = 2; i < part_sector.Length; i+=12)
for(int i = 2; i < part_sector.Length; i += 12)
{
byte[] tmp = new byte[12];
Array.Copy(part_sector, i, tmp, 0, 12);
AppleMapOldPartitionEntry old_entry = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleMapOldPartitionEntry>(tmp);
DicConsole.DebugWriteLine("AppleMap Plugin", "old_map.sbMap[{1}].pdStart = {0}", old_entry.pdStart, (i - 2) / 12);
DicConsole.DebugWriteLine("AppleMap Plugin", "old_map.sbMap[{1}].pdSize = {0}", old_entry.pdSize, (i - 2) / 12);
DicConsole.DebugWriteLine("AppleMap Plugin", "old_map.sbMap[{1}].pdFSID = 0x{0:X8}", old_entry.pdFSID, (i - 2) / 12);
AppleMapOldPartitionEntry old_entry =
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleMapOldPartitionEntry>(tmp);
DicConsole.DebugWriteLine("AppleMap Plugin", "old_map.sbMap[{1}].pdStart = {0}", old_entry.pdStart,
(i - 2) / 12);
DicConsole.DebugWriteLine("AppleMap Plugin", "old_map.sbMap[{1}].pdSize = {0}", old_entry.pdSize,
(i - 2) / 12);
DicConsole.DebugWriteLine("AppleMap Plugin", "old_map.sbMap[{1}].pdFSID = 0x{0:X8}",
old_entry.pdFSID, (i - 2) / 12);
if(old_entry.pdSize == 0 && old_entry.pdFSID == 0)
{
if(old_entry.pdStart == 0)
break;
if(old_entry.pdStart == 0) break;
continue;
}
@@ -167,10 +170,8 @@ namespace DiscImageChef.PartPlugins
Scheme = Name
};
if(old_entry.pdFSID == HFS_MAGIC_OLD)
part.Type = "Apple_HFS";
else
part.Type = string.Format("0x{0:X8}", old_entry.pdFSID);
if(old_entry.pdFSID == HFS_MAGIC_OLD) part.Type = "Apple_HFS";
else part.Type = string.Format("0x{0:X8}", old_entry.pdFSID);
partitions.Add(part);
@@ -190,7 +191,7 @@ namespace DiscImageChef.PartPlugins
if(sector_size > 512)
{
byte[] tmp = new byte[512];
Array.Copy(ddm_sector, 512, tmp, 0, 512);
Array.Copy(ddm_sector, 512, tmp, 0, 512);
entry = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleMapPartitionEntry>(tmp);
// Check for a partition entry that's 512-byte aligned
if(entry.signature == APM_MAGIC)
@@ -212,8 +213,7 @@ namespace DiscImageChef.PartPlugins
skip_ddm = sector_size;
sectors_to_read = entry_count + 2;
}
else
return partitions.Count > 0;
else return partitions.Count > 0;
}
}
else
@@ -227,8 +227,7 @@ namespace DiscImageChef.PartPlugins
skip_ddm = sector_size;
sectors_to_read = entry_count + 2;
}
else
return partitions.Count > 0;
else return partitions.Count > 0;
}
byte[] entries = imagePlugin.ReadSectors(sectorOffset, sectors_to_read);
@@ -253,19 +252,29 @@ namespace DiscImageChef.PartPlugins
DicConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].entries = {1}", i, entry.entries);
DicConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].start = {1}", i, entry.start);
DicConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].sectors = {1}", i, entry.sectors);
DicConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].name = \"{1}\"", i, StringHandlers.CToString(entry.name));
DicConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].type = \"{1}\"", i, StringHandlers.CToString(entry.type));
DicConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].first_data_block = {1}", i, entry.first_data_block);
DicConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].name = \"{1}\"", i,
StringHandlers.CToString(entry.name));
DicConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].type = \"{1}\"", i,
StringHandlers.CToString(entry.type));
DicConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].first_data_block = {1}", i,
entry.first_data_block);
DicConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].data_sectors = {1}", i, entry.data_sectors);
DicConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].flags = {1}", i, (AppleMapFlags)entry.flags);
DicConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].first_boot_block = {1}", i, entry.first_boot_block);
DicConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].flags = {1}", i,
(AppleMapFlags)entry.flags);
DicConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].first_boot_block = {1}", i,
entry.first_boot_block);
DicConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].boot_size = {1}", i, entry.boot_size);
DicConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].load_address = 0x{1:X8}", i, entry.load_address);
DicConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].load_address2 = 0x{1:X8}", i, entry.load_address2);
DicConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].entry_point = 0x{1:X8}", i, entry.entry_point);
DicConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].entry_point2 = 0x{1:X8}", i, entry.entry_point2);
DicConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].load_address = 0x{1:X8}", i,
entry.load_address);
DicConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].load_address2 = 0x{1:X8}", i,
entry.load_address2);
DicConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].entry_point = 0x{1:X8}", i,
entry.entry_point);
DicConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].entry_point2 = 0x{1:X8}", i,
entry.entry_point2);
DicConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].checksum = 0x{1:X8}", i, entry.checksum);
DicConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].processor = \"{1}\"", i, StringHandlers.CToString(entry.processor));
DicConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].processor = \"{1}\"", i,
StringHandlers.CToString(entry.processor));
AppleMapFlags flags = (AppleMapFlags)entry.flags;
@@ -287,22 +296,17 @@ namespace DiscImageChef.PartPlugins
Scheme = Name
};
sb.AppendLine("Partition flags:");
if(flags.HasFlag(AppleMapFlags.Valid))
sb.AppendLine("Partition is valid.");
if(flags.HasFlag(AppleMapFlags.Allocated))
sb.AppendLine("Partition entry is allocated.");
if(flags.HasFlag(AppleMapFlags.InUse))
sb.AppendLine("Partition is in use.");
if(flags.HasFlag(AppleMapFlags.Bootable))
sb.AppendLine("Partition is bootable.");
if(flags.HasFlag(AppleMapFlags.Readable))
sb.AppendLine("Partition is readable.");
if(flags.HasFlag(AppleMapFlags.Writable))
sb.AppendLine("Partition is writable.");
if(flags.HasFlag(AppleMapFlags.Valid)) sb.AppendLine("Partition is valid.");
if(flags.HasFlag(AppleMapFlags.Allocated)) sb.AppendLine("Partition entry is allocated.");
if(flags.HasFlag(AppleMapFlags.InUse)) sb.AppendLine("Partition is in use.");
if(flags.HasFlag(AppleMapFlags.Bootable)) sb.AppendLine("Partition is bootable.");
if(flags.HasFlag(AppleMapFlags.Readable)) sb.AppendLine("Partition is readable.");
if(flags.HasFlag(AppleMapFlags.Writable)) sb.AppendLine("Partition is writable.");
if(flags.HasFlag(AppleMapFlags.Bootable))
{
sb.AppendFormat("First boot sector: {0}", (entry.first_boot_block * entry_size) / sector_size).AppendLine();
sb.AppendFormat("First boot sector: {0}",
(entry.first_boot_block * entry_size) / sector_size).AppendLine();
sb.AppendFormat("Boot is {0} bytes.", entry.boot_size).AppendLine();
sb.AppendFormat("Boot load address: 0x{0:X8}", entry.load_address).AppendLine();
sb.AppendFormat("Boot entry point: 0x{0:X8}", entry.entry_point).AppendLine();
@@ -314,7 +318,8 @@ namespace DiscImageChef.PartPlugins
}
_partition.Description = sb.ToString();
if(_partition.Start < imagePlugin.ImageInfo.sectors && _partition.End < imagePlugin.ImageInfo.sectors)
if(_partition.Start < imagePlugin.ImageInfo.sectors &&
_partition.End < imagePlugin.ImageInfo.sectors)
{
partitions.Add(_partition);
sequence++;
@@ -322,14 +327,18 @@ namespace DiscImageChef.PartPlugins
// Some CD and DVDs end with an Apple_Free that expands beyond the disc size...
else if(_partition.Start < imagePlugin.ImageInfo.sectors)
{
DicConsole.DebugWriteLine("AppleMap Plugin", "Cutting last partition end ({0}) to media size ({1})", _partition.End, imagePlugin.ImageInfo.sectors - 1);
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;
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);
DicConsole.DebugWriteLine("AppleMap Plugin",
"Not adding partition becaus start ({0}) is outside media size ({1})",
_partition.Start, imagePlugin.ImageInfo.sectors - 1);
}
}
}
@@ -356,8 +365,7 @@ namespace DiscImageChef.PartPlugins
/// <summary>Number of entries of the driver descriptor</summary>
public ushort sbDrvrCount;
/// <summary>Entries of the driver descriptor</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 61)]
public AppleDriverEntry[] sbMap;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 61)] public AppleDriverEntry[] sbMap;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
@@ -377,8 +385,7 @@ namespace DiscImageChef.PartPlugins
/// <summary>Signature <see cref="APM_MAGIC_OLD"/></summary>
public ushort pdSig;
/// <summary>Entries of the driver descriptor</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 42)]
public AppleMapOldPartitionEntry[] pdMap;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 42)] public AppleMapOldPartitionEntry[] pdMap;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
@@ -421,7 +428,6 @@ namespace DiscImageChef.PartPlugins
Reserved = 0xBFFFFC00,
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct AppleMapPartitionEntry
{
@@ -436,11 +442,9 @@ namespace DiscImageChef.PartPlugins
/// <summary>Number of sectos of the partition</summary>
public uint sectors;
/// <summary>Partition name, 32 bytes, null-padded</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public byte[] name;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public byte[] name;
/// <summary>Partition type. 32 bytes, null-padded</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public byte[] type;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public byte[] type;
/// <summary>First sector of the data area</summary>
public uint first_data_block;
/// <summary>Number of sectors of the data area</summary>
@@ -462,11 +466,9 @@ namespace DiscImageChef.PartPlugins
/// <summary>Boot code checksum</summary>
public uint checksum;
/// <summary>Processor type, 16 bytes, null-padded</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] processor;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] processor;
/// <summary>Boot arguments</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public uint[] boot_arguments;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public uint[] boot_arguments;
}
}
}

View File

@@ -41,15 +41,20 @@ namespace DiscImageChef.PartPlugins
{
public class Apricot : PartPlugin
{
readonly string[] operatingSystemCodes = { "Invalid", "MS-DOS", "UCSD Pascal", "CP/M", "Concurrent CP/M" };
readonly string[] bootTypeCodes = { "Non-bootable", "Apricot & XI RAM BIOS", "Generic ROM BIOS", "Apricot & XI ROM BIOS", "Apricot Portable ROM BIOS", "Apricot F1 ROM BIOS" };
readonly string[] diskTypeCodes = { "MF1DD 70-track", "MF1DD", "MF2DD", "Winchester 5M", "Winchester 10M", "Winchester 20M" };
readonly string[] printDevices = { "Parallel", "Serial" };
readonly int[] lineModes = { 256, 200 };
readonly int[] lineWidths = { 80, 40 };
readonly int[] baudRates = { 50, 75, 110, 134, 150, 300, 600, 1200, 1800, 2400, 3600, 4800, 7200, 9600, 19200 };
readonly double[] stopBits = { 1, 1.5, 2 };
readonly string[] parityTypes = { "None", "Odd", "Even", "Mark", "Space" };
readonly string[] operatingSystemCodes = {"Invalid", "MS-DOS", "UCSD Pascal", "CP/M", "Concurrent CP/M"};
readonly string[] bootTypeCodes =
{
"Non-bootable", "Apricot & XI RAM BIOS", "Generic ROM BIOS", "Apricot & XI ROM BIOS",
"Apricot Portable ROM BIOS", "Apricot F1 ROM BIOS"
};
readonly string[] diskTypeCodes =
{"MF1DD 70-track", "MF1DD", "MF2DD", "Winchester 5M", "Winchester 10M", "Winchester 20M"};
readonly string[] printDevices = {"Parallel", "Serial"};
readonly int[] lineModes = {256, 200};
readonly int[] lineWidths = {80, 40};
readonly int[] baudRates = {50, 75, 110, 134, 150, 300, 600, 1200, 1800, 2400, 3600, 4800, 7200, 9600, 19200};
readonly double[] stopBits = {1, 1.5, 2};
readonly string[] parityTypes = {"None", "Odd", "Even", "Mark", "Space"};
public Apricot()
{
@@ -62,13 +67,11 @@ namespace DiscImageChef.PartPlugins
partitions = new List<Partition>();
// I think Apricot can't chain partitions so.
if(sectorOffset != 0)
return false;
if(sectorOffset != 0) return false;
byte[] sector = imagePlugin.ReadSector(0);
if(sector.Length < 512)
return false;
if(sector.Length < 512) return false;
ApricotLabel label = new ApricotLabel();
IntPtr lblPtr = Marshal.AllocHGlobal(512);
@@ -79,14 +82,21 @@ namespace DiscImageChef.PartPlugins
// Not much to check but...
ulong deviceSectors = imagePlugin.GetSectors();
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;
if(label.operatingSystem > 4 || label.bootType > 5 || label.partitionCount > 8 ||
deviceSizeAccordingToLabel > deviceSectors || label.firstDataBlock > deviceSectors) return false;
DicConsole.DebugWriteLine("Apricot partitions", "label.version = \"{0}\"", StringHandlers.CToString(label.version));
DicConsole.DebugWriteLine("Apricot partitions", "label.operatingSystem = {0} ({1})", label.operatingSystem, label.operatingSystem < operatingSystemCodes.Length ? operatingSystemCodes[label.operatingSystem] : "Unknown");
DicConsole.DebugWriteLine("Apricot partitions", "label.version = \"{0}\"",
StringHandlers.CToString(label.version));
DicConsole.DebugWriteLine("Apricot partitions", "label.operatingSystem = {0} ({1})", label.operatingSystem,
label.operatingSystem < operatingSystemCodes.Length
? operatingSystemCodes[label.operatingSystem]
: "Unknown");
DicConsole.DebugWriteLine("Apricot partitions", "label.writeProtected = {0}", label.writeProtected);
DicConsole.DebugWriteLine("Apricot partitions", "label.copyProtected = {0}", label.copyProtected);
DicConsole.DebugWriteLine("Apricot partitions", "label.bootType = {0} ({1})", label.bootType, label.bootType < bootTypeCodes.Length ? bootTypeCodes[label.bootType] : "Unknown");
DicConsole.DebugWriteLine("Apricot partitions", "label.bootType = {0} ({1})", label.bootType,
label.bootType < bootTypeCodes.Length
? bootTypeCodes[label.bootType]
: "Unknown");
DicConsole.DebugWriteLine("Apricot partitions", "label.partitionCount = {0}", label.partitionCount);
DicConsole.DebugWriteLine("Apricot partitions", "label.winchester = {0}", label.winchester);
DicConsole.DebugWriteLine("Apricot partitions", "label.sectorSize = {0}", label.sectorSize);
@@ -98,14 +108,18 @@ namespace DiscImageChef.PartPlugins
DicConsole.DebugWriteLine("Apricot partitions", "label.bootLocation = {0}", label.bootLocation);
DicConsole.DebugWriteLine("Apricot partitions", "label.bootSize = {0}", label.bootSize);
DicConsole.DebugWriteLine("Apricot partitions", "label.bootAddress = 0x{0:X8}", label.bootAddress);
DicConsole.DebugWriteLine("Apricot partitions", "label.bootOffset:label.bootSegment = {0:X4}:{1:X4}", label.bootOffset, label.bootSegment);
DicConsole.DebugWriteLine("Apricot partitions", "label.bootOffset:label.bootSegment = {0:X4}:{1:X4}",
label.bootOffset, label.bootSegment);
DicConsole.DebugWriteLine("Apricot partitions", "label.firstDataBlock = {0}", label.firstDataBlock);
DicConsole.DebugWriteLine("Apricot partitions", "label.generation = {0}", label.generation);
DicConsole.DebugWriteLine("Apricot partitions", "label.copyCount = {0}", label.copyCount);
DicConsole.DebugWriteLine("Apricot partitions", "label.maxCopies = {0}", label.maxCopies);
DicConsole.DebugWriteLine("Apricot partitions", "label.serialNumber = \"{0}\"", StringHandlers.CToString(label.serialNumber));
DicConsole.DebugWriteLine("Apricot partitions", "label.partNumber = \"{0}\"", StringHandlers.CToString(label.partNumber));
DicConsole.DebugWriteLine("Apricot partitions", "label.copyright = \"{0}\"", StringHandlers.CToString(label.copyright));
DicConsole.DebugWriteLine("Apricot partitions", "label.serialNumber = \"{0}\"",
StringHandlers.CToString(label.serialNumber));
DicConsole.DebugWriteLine("Apricot partitions", "label.partNumber = \"{0}\"",
StringHandlers.CToString(label.partNumber));
DicConsole.DebugWriteLine("Apricot partitions", "label.copyright = \"{0}\"",
StringHandlers.CToString(label.copyright));
DicConsole.DebugWriteLine("Apricot partitions", "label.mainBPB.bps = {0}", label.mainBPB.bps);
DicConsole.DebugWriteLine("Apricot partitions", "label.mainBPB.spc = {0}", label.mainBPB.spc);
DicConsole.DebugWriteLine("Apricot partitions", "label.mainBPB.rsectors = {0}", label.mainBPB.rsectors);
@@ -114,14 +128,24 @@ namespace DiscImageChef.PartPlugins
DicConsole.DebugWriteLine("Apricot partitions", "label.mainBPB.sectors = {0}", label.mainBPB.sectors);
DicConsole.DebugWriteLine("Apricot partitions", "label.mainBPB.media = {0}", label.mainBPB.media);
DicConsole.DebugWriteLine("Apricot partitions", "label.mainBPB.spfat = {0}", label.mainBPB.spfat);
DicConsole.DebugWriteLine("Apricot partitions", "label.mainBPB.diskType = {0} ({1})", label.mainBPB.diskType, label.mainBPB.diskType < diskTypeCodes.Length ? diskTypeCodes[label.mainBPB.diskType] : "Unknown");
DicConsole.DebugWriteLine("Apricot partitions", "label.mainBPB.startSector = {0}", label.mainBPB.startSector);
DicConsole.DebugWriteLine("Apricot partitions", "label.fontName = \"{0}\"", StringHandlers.CToString(label.fontName));
DicConsole.DebugWriteLine("Apricot partitions", "label.keyboardName = \"{0}\"", StringHandlers.CToString(label.keyboardName));
DicConsole.DebugWriteLine("Apricot partitions", "label.mainBPB.diskType = {0} ({1})",
label.mainBPB.diskType,
label.mainBPB.diskType < diskTypeCodes.Length
? diskTypeCodes[label.mainBPB.diskType]
: "Unknown");
DicConsole.DebugWriteLine("Apricot partitions", "label.mainBPB.startSector = {0}",
label.mainBPB.startSector);
DicConsole.DebugWriteLine("Apricot partitions", "label.fontName = \"{0}\"",
StringHandlers.CToString(label.fontName));
DicConsole.DebugWriteLine("Apricot partitions", "label.keyboardName = \"{0}\"",
StringHandlers.CToString(label.keyboardName));
DicConsole.DebugWriteLine("Apricot partitions", "label.biosMajorVersion = {0}", label.biosMajorVersion);
DicConsole.DebugWriteLine("Apricot partitions", "label.biosMinorVersion = {0}", label.biosMinorVersion);
DicConsole.DebugWriteLine("Apricot partitions", "label.diagnosticsFlag = {0}", label.diagnosticsFlag);
DicConsole.DebugWriteLine("Apricot partitions", "label.prnDevice = {0} ({1})", label.prnDevice, label.prnDevice < printDevices.Length ? printDevices[label.prnDevice] : "Unknown");
DicConsole.DebugWriteLine("Apricot partitions", "label.prnDevice = {0} ({1})", label.prnDevice,
label.prnDevice < printDevices.Length
? printDevices[label.prnDevice]
: "Unknown");
DicConsole.DebugWriteLine("Apricot partitions", "label.bellVolume = {0}", label.bellVolume);
DicConsole.DebugWriteLine("Apricot partitions", "label.enableCache = {0}", label.enableCache);
DicConsole.DebugWriteLine("Apricot partitions", "label.enableGraphics = {0}", label.enableGraphics);
@@ -136,18 +160,28 @@ namespace DiscImageChef.PartPlugins
DicConsole.DebugWriteLine("Apricot partitions", "label.autorepeatLeadIn = {0}", label.autorepeatLeadIn);
DicConsole.DebugWriteLine("Apricot partitions", "label.autorepeatInterval = {0}", label.autorepeatInterval);
DicConsole.DebugWriteLine("Apricot partitions", "label.microscreenMode = {0}", label.microscreenMode);
DicConsole.DebugWriteLine("Apricot partitions", "label.spareKeyboard is null? = {0}", ArrayHelpers.ArrayIsNullOrEmpty(label.spareKeyboard));
DicConsole.DebugWriteLine("Apricot partitions", "label.lineMode = {0} ({1} lines)", label.lineMode, label.lineMode < lineModes.Length ? lineModes[label.lineMode] : 0);
DicConsole.DebugWriteLine("Apricot partitions", "label.lineWidth = {0} ({1} columns)", label.lineWidth, label.lineWidth < lineWidths.Length ? lineWidths[label.lineWidth] : 0);
DicConsole.DebugWriteLine("Apricot partitions", "label.spareKeyboard is null? = {0}",
ArrayHelpers.ArrayIsNullOrEmpty(label.spareKeyboard));
DicConsole.DebugWriteLine("Apricot partitions", "label.lineMode = {0} ({1} lines)", label.lineMode,
label.lineMode < lineModes.Length ? lineModes[label.lineMode] : 0);
DicConsole.DebugWriteLine("Apricot partitions", "label.lineWidth = {0} ({1} columns)", label.lineWidth,
label.lineWidth < lineWidths.Length ? lineWidths[label.lineWidth] : 0);
DicConsole.DebugWriteLine("Apricot partitions", "label.imageOff = {0}", label.imageOff);
DicConsole.DebugWriteLine("Apricot partitions", "label.spareScreen is null? = {0}", ArrayHelpers.ArrayIsNullOrEmpty(label.spareScreen));
DicConsole.DebugWriteLine("Apricot partitions", "label.txBaudRate = {0} ({1} bps)", label.txBaudRate, label.txBaudRate < baudRates.Length ? baudRates[label.txBaudRate] : 0);
DicConsole.DebugWriteLine("Apricot partitions", "label.rxBaudRate = {0} ({1} bps)", label.rxBaudRate, label.rxBaudRate < baudRates.Length ? baudRates[label.rxBaudRate] : 0);
DicConsole.DebugWriteLine("Apricot partitions", "label.spareScreen is null? = {0}",
ArrayHelpers.ArrayIsNullOrEmpty(label.spareScreen));
DicConsole.DebugWriteLine("Apricot partitions", "label.txBaudRate = {0} ({1} bps)", label.txBaudRate,
label.txBaudRate < baudRates.Length ? baudRates[label.txBaudRate] : 0);
DicConsole.DebugWriteLine("Apricot partitions", "label.rxBaudRate = {0} ({1} bps)", label.rxBaudRate,
label.rxBaudRate < baudRates.Length ? baudRates[label.rxBaudRate] : 0);
DicConsole.DebugWriteLine("Apricot partitions", "label.txBits = {0}", label.txBits);
DicConsole.DebugWriteLine("Apricot partitions", "label.rxBits = {0}", label.rxBits);
DicConsole.DebugWriteLine("Apricot partitions", "label.stopBits = {0} ({1} bits)", label.stopBits, label.stopBits < stopBits.Length ? stopBits[label.stopBits] : 0);
DicConsole.DebugWriteLine("Apricot partitions", "label.stopBits = {0} ({1} bits)", label.stopBits,
label.stopBits < stopBits.Length ? stopBits[label.stopBits] : 0);
DicConsole.DebugWriteLine("Apricot partitions", "label.parityCheck = {0}", label.parityCheck);
DicConsole.DebugWriteLine("Apricot partitions", "label.parityType = {0} ({1})", label.parityType, label.parityType < parityTypes.Length ? parityTypes[label.parityType] : "Unknown");
DicConsole.DebugWriteLine("Apricot partitions", "label.parityType = {0} ({1})", label.parityType,
label.parityType < parityTypes.Length
? parityTypes[label.parityType]
: "Unknown");
DicConsole.DebugWriteLine("Apricot partitions", "label.txXonXoff = {0}", label.txXonXoff);
DicConsole.DebugWriteLine("Apricot partitions", "label.rxXonXoff = {0}", label.rxXonXoff);
DicConsole.DebugWriteLine("Apricot partitions", "label.xonCharacter = {0}", label.xonCharacter);
@@ -158,39 +192,59 @@ namespace DiscImageChef.PartPlugins
DicConsole.DebugWriteLine("Apricot partitions", "label.nullsAfterCr = {0}", label.nullsAfterCr);
DicConsole.DebugWriteLine("Apricot partitions", "label.nullsAfterFF = {0}", label.nullsAfterFF);
DicConsole.DebugWriteLine("Apricot partitions", "label.lfAfterCRSerial = {0}", label.lfAfterCRSerial);
DicConsole.DebugWriteLine("Apricot partitions", "label.biosErrorReportSerial = {0}", label.biosErrorReportSerial);
DicConsole.DebugWriteLine("Apricot partitions", "label.spareSerial is null? = {0}", ArrayHelpers.ArrayIsNullOrEmpty(label.spareSerial));
DicConsole.DebugWriteLine("Apricot partitions", "label.biosErrorReportSerial = {0}",
label.biosErrorReportSerial);
DicConsole.DebugWriteLine("Apricot partitions", "label.spareSerial is null? = {0}",
ArrayHelpers.ArrayIsNullOrEmpty(label.spareSerial));
DicConsole.DebugWriteLine("Apricot partitions", "label.lfAfterCrParallel = {0}", label.lfAfterCrParallel);
DicConsole.DebugWriteLine("Apricot partitions", "label.selectLine = {0}", label.selectLine);
DicConsole.DebugWriteLine("Apricot partitions", "label.paperEmpty = {0}", label.paperEmpty);
DicConsole.DebugWriteLine("Apricot partitions", "label.faultLine = {0}", label.faultLine);
DicConsole.DebugWriteLine("Apricot partitions", "label.biosErrorReportParallel = {0}", label.biosErrorReportParallel);
DicConsole.DebugWriteLine("Apricot partitions", "label.spareParallel is null? = {0}", ArrayHelpers.ArrayIsNullOrEmpty(label.spareParallel));
DicConsole.DebugWriteLine("Apricot partitions", "label.spareWinchester is null? = {0}", ArrayHelpers.ArrayIsNullOrEmpty(label.spareWinchester));
DicConsole.DebugWriteLine("Apricot partitions", "label.biosErrorReportParallel = {0}",
label.biosErrorReportParallel);
DicConsole.DebugWriteLine("Apricot partitions", "label.spareParallel is null? = {0}",
ArrayHelpers.ArrayIsNullOrEmpty(label.spareParallel));
DicConsole.DebugWriteLine("Apricot partitions", "label.spareWinchester is null? = {0}",
ArrayHelpers.ArrayIsNullOrEmpty(label.spareWinchester));
DicConsole.DebugWriteLine("Apricot partitions", "label.parkingEnabled = {0}", label.parkingEnabled);
DicConsole.DebugWriteLine("Apricot partitions", "label.formatProtection = {0}", label.formatProtection);
DicConsole.DebugWriteLine("Apricot partitions", "label.spareRamDisk is null? = {0}", ArrayHelpers.ArrayIsNullOrEmpty(label.spareRamDisk));
DicConsole.DebugWriteLine("Apricot partitions", "label.spareRamDisk is null? = {0}",
ArrayHelpers.ArrayIsNullOrEmpty(label.spareRamDisk));
for(int i = 0; i < 32; i++)
DicConsole.DebugWriteLine("Apricot partitions", "label.badBlocks[{1}] = {0}", label.badBlocks[i], i);
for(int i = 0; i < 8; i++)
{
DicConsole.DebugWriteLine("Apricot partitions", "label.partitions[{1}].bps = {0}", label.partitions[i].bps, i);
DicConsole.DebugWriteLine("Apricot partitions", "label.partitions[{1}].spc = {0}", label.partitions[i].spc, i);
DicConsole.DebugWriteLine("Apricot partitions", "label.partitions[{1}].rsectors = {0}", label.partitions[i].rsectors, i);
DicConsole.DebugWriteLine("Apricot partitions", "label.partitions[{1}].fats_no = {0}", label.partitions[i].fats_no, i);
DicConsole.DebugWriteLine("Apricot partitions", "label.partitions[{1}].root_ent = {0}", label.partitions[i].root_ent, i);
DicConsole.DebugWriteLine("Apricot partitions", "label.partitions[{1}].sectors = {0}", label.partitions[i].sectors, i);
DicConsole.DebugWriteLine("Apricot partitions", "label.partitions[{1}].media = {0}", label.partitions[i].media, i);
DicConsole.DebugWriteLine("Apricot partitions", "label.partitions[{1}].spfat = {0}", label.partitions[i].spfat, i);
DicConsole.DebugWriteLine("Apricot partitions", "label.partitions[{1}].diskType = {0} ({2})", label.partitions[i].diskType, i, label.partitions[i].diskType < diskTypeCodes.Length ? diskTypeCodes[label.partitions[i].diskType] : "Unknown");
DicConsole.DebugWriteLine("Apricot partitions", "label.partitions[{1}].startSector = {0}", label.partitions[i].startSector, i);
DicConsole.DebugWriteLine("Apricot partitions", "label.partitions[{1}].bps = {0}",
label.partitions[i].bps, i);
DicConsole.DebugWriteLine("Apricot partitions", "label.partitions[{1}].spc = {0}",
label.partitions[i].spc, i);
DicConsole.DebugWriteLine("Apricot partitions", "label.partitions[{1}].rsectors = {0}",
label.partitions[i].rsectors, i);
DicConsole.DebugWriteLine("Apricot partitions", "label.partitions[{1}].fats_no = {0}",
label.partitions[i].fats_no, i);
DicConsole.DebugWriteLine("Apricot partitions", "label.partitions[{1}].root_ent = {0}",
label.partitions[i].root_ent, i);
DicConsole.DebugWriteLine("Apricot partitions", "label.partitions[{1}].sectors = {0}",
label.partitions[i].sectors, i);
DicConsole.DebugWriteLine("Apricot partitions", "label.partitions[{1}].media = {0}",
label.partitions[i].media, i);
DicConsole.DebugWriteLine("Apricot partitions", "label.partitions[{1}].spfat = {0}",
label.partitions[i].spfat, i);
DicConsole.DebugWriteLine("Apricot partitions", "label.partitions[{1}].diskType = {0} ({2})",
label.partitions[i].diskType, i,
label.partitions[i].diskType < diskTypeCodes.Length
? diskTypeCodes[label.partitions[i].diskType]
: "Unknown");
DicConsole.DebugWriteLine("Apricot partitions", "label.partitions[{1}].startSector = {0}",
label.partitions[i].startSector, i);
}
DicConsole.DebugWriteLine("Apricot partitions", "label.spare is null? = {0}", ArrayHelpers.ArrayIsNullOrEmpty(label.spare));
DicConsole.DebugWriteLine("Apricot partitions", "label.spare is null? = {0}",
ArrayHelpers.ArrayIsNullOrEmpty(label.spare));
DicConsole.DebugWriteLine("Apricot partitions", "label.cpmDoubleSided = {0}", label.cpmDoubleSided);
// Only hard disks can contain partitions
if(!label.winchester)
return false;
if(!label.winchester) return false;
for(byte i = 0; i < label.partitionCount; i++)
{
@@ -204,8 +258,7 @@ namespace DiscImageChef.PartPlugins
Scheme = Name,
Offset = (ulong)(label.partitions[i].startSector * label.sectorSize)
};
if(part.Start < deviceSectors && part.End < deviceSectors)
partitions.Add(part);
if(part.Start < deviceSectors && part.End < deviceSectors) partitions.Add(part);
}
return partitions.Count > 0;
@@ -216,23 +269,19 @@ namespace DiscImageChef.PartPlugins
public struct ApricotLabel
{
/// <summary>Version of format which created disk</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public byte[] version;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] version;
/// <summary>Operating system.</summary>
public byte operatingSystem;
/// <summary>Software write protection.</summary>
[MarshalAs(UnmanagedType.U1)]
public bool writeProtected;
[MarshalAs(UnmanagedType.U1)] public bool writeProtected;
/// <summary>Copy protected.</summary>
[MarshalAs(UnmanagedType.U1)]
public bool copyProtected;
[MarshalAs(UnmanagedType.U1)] public bool copyProtected;
/// <summary>Boot type.</summary>
public byte bootType;
/// <summary>Partitions.</summary>
public byte partitionCount;
/// <summary>Is hard disk?.</summary>
[MarshalAs(UnmanagedType.U1)]
public bool winchester;
[MarshalAs(UnmanagedType.U1)] public bool winchester;
/// <summary>Sector size.</summary>
public ushort sectorSize;
/// <summary>Sectors per track.</summary>
@@ -264,39 +313,31 @@ namespace DiscImageChef.PartPlugins
/// <summary>Maximum number of copies.</summary>
public ushort maxCopies;
/// <summary>Serial number.</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public byte[] serialNumber;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] serialNumber;
/// <summary>Part number.</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public byte[] partNumber;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] partNumber;
/// <summary>Copyright.</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 14)]
public byte[] copyright;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 14)] public byte[] copyright;
/// <summary>BPB for whole disk.</summary>
public ApricotParameterBlock mainBPB;
/// <summary>Name of FONT file.</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] fontName;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] fontName;
/// <summary>Name of KEYBOARD file.</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] keyboardName;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] keyboardName;
/// <summary>Minor BIOS version.</summary>
public byte biosMinorVersion;
/// <summary>Major BIOS version.</summary>
public byte biosMajorVersion;
/// <summary>Diagnostics enabled?.</summary>
[MarshalAs(UnmanagedType.U1)]
public bool diagnosticsFlag;
[MarshalAs(UnmanagedType.U1)] public bool diagnosticsFlag;
/// <summary>Printer device.</summary>
public byte prnDevice;
/// <summary>Bell volume.</summary>
public byte bellVolume;
/// <summary>Cache enabled?.</summary>
[MarshalAs(UnmanagedType.U1)]
public bool enableCache;
[MarshalAs(UnmanagedType.U1)] public bool enableCache;
/// <summary>Graphics enabled?.</summary>
[MarshalAs(UnmanagedType.U1)]
public bool enableGraphics;
[MarshalAs(UnmanagedType.U1)] public bool enableGraphics;
/// <summary>Length in sectors of DOS.</summary>
public byte dosLength;
/// <summary>Length in sectors of FONT file.</summary>
@@ -312,8 +353,7 @@ namespace DiscImageChef.PartPlugins
/// <summary>Keyboard click volume.</summary>
public byte keyboardVolume;
/// <summary>Auto-repeat enabled?.</summary>
[MarshalAs(UnmanagedType.U1)]
public bool autorepeat;
[MarshalAs(UnmanagedType.U1)] public bool autorepeat;
/// <summary>Auto-repeat lead-in.</summary>
public byte autorepeatLeadIn;
/// <summary>Auto-repeat interval.</summary>
@@ -321,18 +361,15 @@ namespace DiscImageChef.PartPlugins
/// <summary>Microscreen mode.</summary>
public byte microscreenMode;
/// <summary>Spare area for keyboard values expansion.</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)]
public byte[] spareKeyboard;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)] public byte[] spareKeyboard;
/// <summary>Screen line mode.</summary>
public byte lineMode;
/// <summary>Screen line width.</summary>
public byte lineWidth;
/// <summary>Screen disabled?.</summary>
[MarshalAs(UnmanagedType.U1)]
public bool imageOff;
[MarshalAs(UnmanagedType.U1)] public bool imageOff;
/// <summary>Spare area for screen values expansion.</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 13)]
public byte[] spareScreen;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 13)] public byte[] spareScreen;
/// <summary>TX baud rate.</summary>
public byte txBaudRate;
/// <summary>RX baud rate.</summary>
@@ -344,16 +381,13 @@ namespace DiscImageChef.PartPlugins
/// <summary>Stop bits.</summary>
public byte stopBits;
/// <summary>Parity enabled?.</summary>
[MarshalAs(UnmanagedType.U1)]
public bool parityCheck;
[MarshalAs(UnmanagedType.U1)] public bool parityCheck;
/// <summary>Parity type.</summary>
public byte parityType;
/// <summary>Xon/Xoff enabled on TX.</summary>
[MarshalAs(UnmanagedType.U1)]
public bool txXonXoff;
[MarshalAs(UnmanagedType.U1)] public bool txXonXoff;
/// <summary>Xon/Xoff enabled on RX.</summary>
[MarshalAs(UnmanagedType.U1)]
public bool rxXonXoff;
[MarshalAs(UnmanagedType.U1)] public bool rxXonXoff;
/// <summary>Xon character.</summary>
public byte xonCharacter;
/// <summary>Xoff character.</summary>
@@ -361,63 +395,45 @@ namespace DiscImageChef.PartPlugins
/// <summary>Xon/Xoff buffer on RX.</summary>
public ushort rxXonXoffBuffer;
/// <summary>DTR/DSR enabled?.</summary>
[MarshalAs(UnmanagedType.U1)]
public bool dtrDsr;
[MarshalAs(UnmanagedType.U1)] public bool dtrDsr;
/// <summary>CTS/RTS enabled?.</summary>
[MarshalAs(UnmanagedType.U1)]
public bool ctsRts;
[MarshalAs(UnmanagedType.U1)] public bool ctsRts;
/// <summary>NULLs after CR.</summary>
public byte nullsAfterCr;
/// <summary>NULLs after 0xFF.</summary>
public byte nullsAfterFF;
/// <summary>Send LF after CR in serial port.</summary>
[MarshalAs(UnmanagedType.U1)]
public bool lfAfterCRSerial;
[MarshalAs(UnmanagedType.U1)] public bool lfAfterCRSerial;
/// <summary>BIOS error report in serial port.</summary>
[MarshalAs(UnmanagedType.U1)]
public bool biosErrorReportSerial;
[MarshalAs(UnmanagedType.U1)] public bool biosErrorReportSerial;
/// <summary>Spare area for serial port values expansion.</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 13)]
public byte[] spareSerial;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 13)] public byte[] spareSerial;
/// <summary>Send LF after CR in parallel port.</summary>
[MarshalAs(UnmanagedType.U1)]
public bool lfAfterCrParallel;
[MarshalAs(UnmanagedType.U1)] public bool lfAfterCrParallel;
/// <summary>Select line supported?.</summary>
[MarshalAs(UnmanagedType.U1)]
public bool selectLine;
[MarshalAs(UnmanagedType.U1)] public bool selectLine;
/// <summary>Paper empty supported?.</summary>
[MarshalAs(UnmanagedType.U1)]
public bool paperEmpty;
[MarshalAs(UnmanagedType.U1)] public bool paperEmpty;
/// <summary>Fault line supported?.</summary>
[MarshalAs(UnmanagedType.U1)]
public bool faultLine;
[MarshalAs(UnmanagedType.U1)] public bool faultLine;
/// <summary>BIOS error report in parallel port.</summary>
[MarshalAs(UnmanagedType.U1)]
public bool biosErrorReportParallel;
[MarshalAs(UnmanagedType.U1)] public bool biosErrorReportParallel;
/// <summary>Spare area for parallel port values expansion.</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)]
public byte[] spareParallel;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)] public byte[] spareParallel;
/// <summary>Spare area for Winchester values expansion.</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 14)]
public byte[] spareWinchester;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 14)] public byte[] spareWinchester;
/// <summary>Parking enabled?.</summary>
[MarshalAs(UnmanagedType.U1)]
public bool parkingEnabled;
[MarshalAs(UnmanagedType.U1)] public bool parkingEnabled;
/// <summary>Format protection?.</summary>
[MarshalAs(UnmanagedType.U1)]
public bool formatProtection;
[MarshalAs(UnmanagedType.U1)] public bool formatProtection;
/// <summary>Spare area for RAM disk values expansion.</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] spareRamDisk;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] spareRamDisk;
/// <summary>List of bad blocks.</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public ushort[] badBlocks;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public ushort[] badBlocks;
/// <summary>Array of partition BPBs.</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public ApricotParameterBlock[] partitions;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public ApricotParameterBlock[] partitions;
/// <summary>Spare area.</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 63)]
public byte[] spare;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 63)] public byte[] spare;
/// <summary>CP/M double side indicator?.</summary>
public bool cpmDoubleSided;
}

View File

@@ -58,12 +58,12 @@ namespace DiscImageChef.PartPlugins
PluginUUID = new Guid("d1dd0f24-ec39-4c4d-9072-be31919a3b5e");
}
public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin, out List<CommonTypes.Partition> partitions, ulong sectorOffset)
public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin,
out List<CommonTypes.Partition> partitions, ulong sectorOffset)
{
partitions = new List<CommonTypes.Partition>();
if(imagePlugin.GetSectorSize() < 512)
return false;
if(imagePlugin.GetSectorSize() < 512) return false;
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
@@ -106,20 +106,28 @@ namespace DiscImageChef.PartPlugins
for(int i = 0; i < 8; i++)
{
DicConsole.DebugWriteLine("Atari partition plugin", "table.icdEntries[{0}].flag = 0x{1:X2}", i, (table.icdEntries[i].type & 0xFF000000) >> 24);
DicConsole.DebugWriteLine("Atari partition plugin", "table.icdEntries[{0}].type = 0x{1:X6}", i, (table.icdEntries[i].type & 0x00FFFFFF));
DicConsole.DebugWriteLine("Atari partition plugin", "table.icdEntries[{0}].start = {1}", i, table.icdEntries[i].start);
DicConsole.DebugWriteLine("Atari partition plugin", "table.icdEntries[{0}].length = {1}", i, table.icdEntries[i].length);
DicConsole.DebugWriteLine("Atari partition plugin", "table.icdEntries[{0}].flag = 0x{1:X2}", i,
(table.icdEntries[i].type & 0xFF000000) >> 24);
DicConsole.DebugWriteLine("Atari partition plugin", "table.icdEntries[{0}].type = 0x{1:X6}", i,
(table.icdEntries[i].type & 0x00FFFFFF));
DicConsole.DebugWriteLine("Atari partition plugin", "table.icdEntries[{0}].start = {1}", i,
table.icdEntries[i].start);
DicConsole.DebugWriteLine("Atari partition plugin", "table.icdEntries[{0}].length = {1}", i,
table.icdEntries[i].length);
}
DicConsole.DebugWriteLine("Atari partition plugin", "table.size = {0}", table.size);
for(int i = 0; i < 4; i++)
{
DicConsole.DebugWriteLine("Atari partition plugin", "table.entries[{0}].flag = 0x{1:X2}", i, (table.entries[i].type & 0xFF000000) >> 24);
DicConsole.DebugWriteLine("Atari partition plugin", "table.entries[{0}].type = 0x{1:X6}", i, (table.entries[i].type & 0x00FFFFFF));
DicConsole.DebugWriteLine("Atari partition plugin", "table.entries[{0}].start = {1}", i, table.entries[i].start);
DicConsole.DebugWriteLine("Atari partition plugin", "table.entries[{0}].length = {1}", i, table.entries[i].length);
DicConsole.DebugWriteLine("Atari partition plugin", "table.entries[{0}].flag = 0x{1:X2}", i,
(table.entries[i].type & 0xFF000000) >> 24);
DicConsole.DebugWriteLine("Atari partition plugin", "table.entries[{0}].type = 0x{1:X6}", i,
(table.entries[i].type & 0x00FFFFFF));
DicConsole.DebugWriteLine("Atari partition plugin", "table.entries[{0}].start = {1}", i,
table.entries[i].start);
DicConsole.DebugWriteLine("Atari partition plugin", "table.entries[{0}].length = {1}", i,
table.entries[i].length);
}
DicConsole.DebugWriteLine("Atari partition plugin", "table.badStart = {0}", table.badStart);
@@ -132,21 +140,20 @@ namespace DiscImageChef.PartPlugins
{
uint type = table.entries[i].type & 0x00FFFFFF;
if(type == TypeGEMDOS || type == TypeBigGEMDOS || type == TypeLinux ||
type == TypeSwap || type == TypeRAW || type == TypeNetBSD ||
type == TypeNetBSDSwap || type == TypeSysV || type == TypeMac ||
type == TypeMinix || type == TypeMinix2)
if(type == TypeGEMDOS || type == TypeBigGEMDOS || type == TypeLinux || type == TypeSwap ||
type == TypeRAW || type == TypeNetBSD || type == TypeNetBSDSwap || type == TypeSysV ||
type == TypeMac || type == TypeMinix || type == TypeMinix2)
{
validTable = true;
if(table.entries[i].start <= imagePlugin.GetSectors())
{
if((table.entries[i].start + table.entries[i].length) > imagePlugin.GetSectors())
DicConsole.DebugWriteLine("Atari partition plugin", "WARNING: End of partition goes beyond device size");
DicConsole.DebugWriteLine("Atari partition plugin",
"WARNING: End of partition goes beyond device size");
ulong sectorSize = imagePlugin.GetSectorSize();
if(sectorSize == 2448 || sectorSize == 2352)
sectorSize = 2048;
if(sectorSize == 2448 || sectorSize == 2352) sectorSize = 2048;
byte[] partType = new byte[3];
partType[0] = (byte)((type & 0xFF0000) >> 16);
@@ -215,9 +222,12 @@ namespace DiscImageChef.PartPlugins
for(int j = 0; j < 4; j++)
{
extendedTable.entries[j].type = BigEndianBitConverter.ToUInt32(extendedSector, 454 + j * 12 + 0);
extendedTable.entries[j].start = BigEndianBitConverter.ToUInt32(extendedSector, 454 + j * 12 + 4);
extendedTable.entries[j].length = BigEndianBitConverter.ToUInt32(extendedSector, 454 + j * 12 + 8);
extendedTable.entries[j].type =
BigEndianBitConverter.ToUInt32(extendedSector, 454 + j * 12 + 0);
extendedTable.entries[j].start =
BigEndianBitConverter.ToUInt32(extendedSector, 454 + j * 12 + 4);
extendedTable.entries[j].length =
BigEndianBitConverter.ToUInt32(extendedSector, 454 + j * 12 + 8);
}
for(int j = 0; j < 4; j++)
@@ -225,19 +235,20 @@ namespace DiscImageChef.PartPlugins
uint extendedType = extendedTable.entries[j].type & 0x00FFFFFF;
if(extendedType == TypeGEMDOS || extendedType == TypeBigGEMDOS || extendedType == TypeLinux ||
extendedType == TypeSwap || extendedType == TypeRAW || extendedType == TypeNetBSD ||
extendedType == TypeNetBSDSwap || extendedType == TypeSysV || extendedType == TypeMac ||
extendedType == TypeMinix || extendedType == TypeMinix2)
extendedType == TypeSwap || extendedType == TypeRAW || extendedType == TypeNetBSD ||
extendedType == TypeNetBSDSwap || extendedType == TypeSysV || extendedType == TypeMac ||
extendedType == TypeMinix || extendedType == TypeMinix2)
{
validTable = true;
if(extendedTable.entries[j].start <= imagePlugin.GetSectors())
{
if((extendedTable.entries[j].start + extendedTable.entries[j].length) > imagePlugin.GetSectors())
DicConsole.DebugWriteLine("Atari partition plugin", "WARNING: End of partition goes beyond device size");
if((extendedTable.entries[j].start + extendedTable.entries[j].length) >
imagePlugin.GetSectors())
DicConsole.DebugWriteLine("Atari partition plugin",
"WARNING: End of partition goes beyond device size");
ulong sectorSize = imagePlugin.GetSectorSize();
if(sectorSize == 2448 || sectorSize == 2352)
sectorSize = 2048;
if(sectorSize == 2448 || sectorSize == 2352) sectorSize = 2048;
byte[] partType = new byte[3];
partType[0] = (byte)((extendedType & 0xFF0000) >> 16);
@@ -307,19 +318,18 @@ namespace DiscImageChef.PartPlugins
{
uint type = table.icdEntries[i].type & 0x00FFFFFF;
if(type == TypeGEMDOS || type == TypeBigGEMDOS || type == TypeLinux ||
type == TypeSwap || type == TypeRAW || type == TypeNetBSD ||
type == TypeNetBSDSwap || type == TypeSysV || type == TypeMac ||
type == TypeMinix || type == TypeMinix2)
if(type == TypeGEMDOS || type == TypeBigGEMDOS || type == TypeLinux || type == TypeSwap ||
type == TypeRAW || type == TypeNetBSD || type == TypeNetBSDSwap || type == TypeSysV ||
type == TypeMac || type == TypeMinix || type == TypeMinix2)
{
if(table.icdEntries[i].start <= imagePlugin.GetSectors())
{
if((table.icdEntries[i].start + table.icdEntries[i].length) > imagePlugin.GetSectors())
DicConsole.DebugWriteLine("Atari partition plugin", "WARNING: End of partition goes beyond device size");
DicConsole.DebugWriteLine("Atari partition plugin",
"WARNING: End of partition goes beyond device size");
ulong sectorSize = imagePlugin.GetSectorSize();
if(sectorSize == 2448 || sectorSize == 2352)
sectorSize = 2048;
if(sectorSize == 2448 || sectorSize == 2352) sectorSize = 2048;
byte[] partType = new byte[3];
partType[0] = (byte)((type & 0xFF0000) >> 16);

View File

@@ -45,9 +45,9 @@ namespace DiscImageChef.PartPlugins
public const uint DISKMAGIC = 0x82564557;
public const uint DISKCIGAM = 0x57455682;
/// <summary>Known sector locations for BSD disklabel</summary>
readonly ulong[] labelLocations = { 0, 1, 2, 9 };
readonly ulong[] labelLocations = {0, 1, 2, 9};
/// <summary>Known byte offsets for BSD disklabel</summary>
readonly uint[] labelOffsets = { 0, 9, 64, 128, 516 };
readonly uint[] labelOffsets = {0, 9, 64, 128, 516};
/// <summary>Maximum size of a disklabel with 22 partitions</summary>
const uint maxLabelSize = 500;
@@ -61,8 +61,7 @@ namespace DiscImageChef.PartPlugins
{
partitions = new List<Partition>();
uint run = (maxLabelSize + labelOffsets.Last()) / imagePlugin.GetSectorSize();
if((maxLabelSize + labelOffsets.Last()) % imagePlugin.GetSectorSize() > 0)
run++;
if((maxLabelSize + labelOffsets.Last()) % imagePlugin.GetSectorSize() > 0) run++;
byte[] sector;
DiskLabel dl = new DiskLabel();
@@ -70,8 +69,7 @@ namespace DiscImageChef.PartPlugins
foreach(ulong location in labelLocations)
{
if(location + run + sectorOffset >= imagePlugin.GetSectors())
return false;
if(location + run + sectorOffset >= imagePlugin.GetSectors()) return false;
byte[] tmp = imagePlugin.ReadSectors(location + sectorOffset, run);
foreach(uint offset in labelOffsets)
@@ -79,7 +77,9 @@ namespace DiscImageChef.PartPlugins
sector = new byte[maxLabelSize];
Array.Copy(tmp, offset, sector, 0, maxLabelSize);
dl = GetDiskLabel(sector);
DicConsole.DebugWriteLine("BSD plugin", "dl.magic on sector {0} at offset {1} = 0x{2:X8} (expected 0x{3:X8})", location + sectorOffset, offset, dl.d_magic, DISKMAGIC);
DicConsole.DebugWriteLine("BSD plugin",
"dl.magic on sector {0} at offset {1} = 0x{2:X8} (expected 0x{3:X8})",
location + sectorOffset, offset, dl.d_magic, DISKMAGIC);
if((dl.d_magic == DISKMAGIC && dl.d_magic2 == DISKMAGIC) ||
(dl.d_magic == DISKCIGAM && dl.d_magic2 == DISKCIGAM))
{
@@ -88,15 +88,12 @@ namespace DiscImageChef.PartPlugins
}
}
if(found)
break;
if(found) break;
}
if(!found)
return false;
if(!found) return false;
if(dl.d_magic == DISKCIGAM && dl.d_magic2 == DISKCIGAM)
dl = SwapDiskLabel(dl);
if(dl.d_magic == DISKCIGAM && dl.d_magic2 == DISKCIGAM) dl = SwapDiskLabel(dl);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_type = {0}", dl.d_type);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_subtype = {0}", dl.d_subtype);
@@ -139,9 +136,11 @@ namespace DiscImageChef.PartPlugins
for(int i = 0; i < dl.d_npartitions && i < 22; i++)
{
DicConsole.DebugWriteLine("BSD plugin", "dl.d_partitions[i].p_offset = {0}", dl.d_partitions[i].p_offset);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_partitions[i].p_offset = {0}",
dl.d_partitions[i].p_offset);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_partitions[i].p_size = {0}", dl.d_partitions[i].p_size);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_partitions[i].p_fstype = {0} ({1})", dl.d_partitions[i].p_fstype, fsTypeToString(dl.d_partitions[i].p_fstype));
DicConsole.DebugWriteLine("BSD plugin", "dl.d_partitions[i].p_fstype = {0} ({1})",
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.GetSectorSize()),
@@ -155,8 +154,7 @@ namespace DiscImageChef.PartPlugins
if(dl.d_partitions[i].p_fstype != fsType.Unused)
{
// Crude and dirty way to know if the disklabel is relative to its parent partition...
if(dl.d_partitions[i].p_offset < sectorOffset && !addSectorOffset)
addSectorOffset = true;
if(dl.d_partitions[i].p_offset < sectorOffset && !addSectorOffset) addSectorOffset = true;
if(addSectorOffset)
{
@@ -331,11 +329,9 @@ namespace DiscImageChef.PartPlugins
/// <summary>Disk subtype</summary>
public ushort d_subtype;
/// <summary>Type name</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] d_typename;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] d_typename;
/// <summary>Pack identifier</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] d_packname;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] d_packname;
/// <summary>Bytes per sector</summary>
public uint d_secsize;
/// <summary>Sectors per track</summary>
@@ -369,8 +365,7 @@ namespace DiscImageChef.PartPlugins
/// <summary><see cref="dFlags"/></summary>
public dFlags d_flags;
/// <summary>Drive-specific information</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
public uint[] d_drivedata;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] public uint[] d_drivedata;
/// <summary>Reserved</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
/// <summary></summary>
@@ -386,8 +381,7 @@ namespace DiscImageChef.PartPlugins
/// <summary>Maximum size of superblock in bytes</summary>
public uint d_sbsize;
/// <summary>Partitions</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 22)]
public BSDPartition[] d_partitions;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 22)] public BSDPartition[] d_partitions;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
@@ -411,65 +405,36 @@ namespace DiscImageChef.PartPlugins
{
switch(typ)
{
case fsType.Unused:
return "Unused entry";
case fsType.Swap:
return "Swap partition";
case fsType.V6:
return "UNIX 6th Edition";
case fsType.V7:
return "UNIX 7th Edition";
case fsType.SystemV:
return "UNIX System V";
case fsType.V7_1K:
return "UNIX 7th Edition with 1K blocks";
case fsType.V8:
return "UNIX 8th Edition with 4K blocks";
case fsType.BSDFFS:
return "4.2BSD Fast File System";
case fsType.BSDLFS:
return "4.4LFS";
case fsType.HPFS:
return "HPFS";
case fsType.ISO9660:
return "ISO9660";
case fsType.Unused: return "Unused entry";
case fsType.Swap: return "Swap partition";
case fsType.V6: return "UNIX 6th Edition";
case fsType.V7: return "UNIX 7th Edition";
case fsType.SystemV: return "UNIX System V";
case fsType.V7_1K: return "UNIX 7th Edition with 1K blocks";
case fsType.V8: return "UNIX 8th Edition with 4K blocks";
case fsType.BSDFFS: return "4.2BSD Fast File System";
case fsType.BSDLFS: return "4.4LFS";
case fsType.HPFS: return "HPFS";
case fsType.ISO9660: return "ISO9660";
case fsType.Boot:
case fsType.SysVBoot:
return "Boot";
case fsType.AFFS:
return "Amiga FFS";
case fsType.HFS:
return "Apple HFS";
case fsType.ADVfs:
return "Digital Advanced File System";
case fsType.LSMpublic:
return "Digital LSM Public Region";
case fsType.LSMprivate:
return "Digital LSM Private Region";
case fsType.LSMsimple:
return "Digital LSM Simple Disk";
case fsType.CCD:
return "Concatenated disk";
case fsType.JFS2:
return "IBM JFS2";
case fsType.HAMMER:
return "Hammer";
case fsType.HAMMER2:
return "Hammer2";
case fsType.UDF:
return "UDF";
case fsType.EFS:
return "EFS";
case fsType.ZFS:
return "ZFS";
case fsType.NANDFS:
return "FreeBSD nandfs";
case fsType.MSDOS:
return "FAT";
case fsType.Other:
return "Other or unknown";
default:
return "Unknown";
case fsType.SysVBoot: return "Boot";
case fsType.AFFS: return "Amiga FFS";
case fsType.HFS: return "Apple HFS";
case fsType.ADVfs: return "Digital Advanced File System";
case fsType.LSMpublic: return "Digital LSM Public Region";
case fsType.LSMprivate: return "Digital LSM Private Region";
case fsType.LSMsimple: return "Digital LSM Simple Disk";
case fsType.CCD: return "Concatenated disk";
case fsType.JFS2: return "IBM JFS2";
case fsType.HAMMER: return "Hammer";
case fsType.HAMMER2: return "Hammer2";
case fsType.UDF: return "UDF";
case fsType.EFS: return "EFS";
case fsType.ZFS: return "ZFS";
case fsType.NANDFS: return "FreeBSD nandfs";
case fsType.MSDOS: return "FAT";
case fsType.Other: return "Other or unknown";
default: return "Unknown";
}
}
@@ -484,10 +449,8 @@ namespace DiscImageChef.PartPlugins
public static DiskLabel SwapDiskLabel(DiskLabel disklabel)
{
DiskLabel dl = BigEndianMarshal.SwapStructureMembersEndian(disklabel);
for(int i = 0; i < dl.d_drivedata.Length; i++)
dl.d_drivedata[i] = Swapping.Swap(dl.d_drivedata[i]);
for(int i = 0; i < dl.d_spare.Length; i++)
dl.d_spare[i] = Swapping.Swap(dl.d_spare[i]);
for(int i = 0; i < dl.d_drivedata.Length; i++) dl.d_drivedata[i] = Swapping.Swap(dl.d_drivedata[i]);
for(int i = 0; i < dl.d_spare.Length; i++) dl.d_spare[i] = Swapping.Swap(dl.d_spare[i]);
for(int i = 0; i < dl.d_partitions.Length; i++)
dl.d_partitions[i] = BigEndianMarshal.SwapStructureMembersEndian(dl.d_partitions[i]);

View File

@@ -53,12 +53,10 @@ namespace DiscImageChef.PartPlugins
{
partitions = new List<Partition>();
if(31 + sectorOffset >= imagePlugin.GetSectors())
return false;
if(31 + sectorOffset >= imagePlugin.GetSectors()) return false;
byte[] sector = imagePlugin.ReadSector(31 + sectorOffset);
if(sector.Length < 512)
return false;
if(sector.Length < 512) return false;
DECLabel table = new DECLabel();
IntPtr tablePtr = Marshal.AllocHGlobal(512);
@@ -66,8 +64,7 @@ namespace DiscImageChef.PartPlugins
table = (DECLabel)Marshal.PtrToStructure(tablePtr, typeof(DECLabel));
Marshal.FreeHGlobal(tablePtr);
if(table.pt_magic != PT_MAGIC || table.pt_valid != PT_VALID)
return false;
if(table.pt_magic != PT_MAGIC || table.pt_valid != PT_VALID) return false;
ulong counter = 0;
@@ -95,12 +92,10 @@ namespace DiscImageChef.PartPlugins
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct DECLabel
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 440)]
public byte[] padding;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 440)] public byte[] padding;
public int pt_magic;
public int pt_valid;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public DECPartition[] pt_part;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public DECPartition[] pt_part;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]

View File

@@ -52,15 +52,12 @@ namespace DiscImageChef.PartPlugins
{
partitions = new List<Partition>();
uint nSectors = 2048 / imagePlugin.GetSectorSize();
if(2048 % imagePlugin.GetSectorSize() > 0)
nSectors++;
if(2048 % imagePlugin.GetSectorSize() > 0) nSectors++;
if(sectorOffset + nSectors >= imagePlugin.GetSectors())
return false;
if(sectorOffset + nSectors >= imagePlugin.GetSectors()) return false;
byte[] sectors = imagePlugin.ReadSectors(sectorOffset, nSectors);
if(sectors.Length < 2048)
return false;
if(sectors.Length < 2048) return false;
Disklabel64 disklabel = new Disklabel64();
IntPtr labelPtr = Marshal.AllocHGlobal(2048);
@@ -68,8 +65,7 @@ namespace DiscImageChef.PartPlugins
disklabel = (Disklabel64)Marshal.PtrToStructure(labelPtr, typeof(Disklabel64));
Marshal.FreeHGlobal(labelPtr);
if(disklabel.d_magic != 0xC4464C59)
return false;
if(disklabel.d_magic != 0xC4464C59) return false;
ulong counter = 0;
@@ -86,13 +82,10 @@ namespace DiscImageChef.PartPlugins
Scheme = Name
};
if((entry.p_bsize % imagePlugin.GetSectorSize()) > 0)
part.Length++;
if((entry.p_bsize % imagePlugin.GetSectorSize()) > 0) part.Length++;
if((BSD.fsType)entry.p_fstype == BSD.fsType.Other)
part.Type = entry.p_type_uuid.ToString();
else
part.Type = BSD.fsTypeToString((BSD.fsType)entry.p_fstype);
if((BSD.fsType)entry.p_fstype == BSD.fsType.Other) part.Type = entry.p_type_uuid.ToString();
else part.Type = BSD.fsTypeToString((BSD.fsType)entry.p_fstype);
if(entry.p_bsize > 0 && entry.p_boffset > 0)
{
partitions.Add(part);
@@ -106,8 +99,7 @@ namespace DiscImageChef.PartPlugins
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct Disklabel64
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 512)]
public byte[] d_reserved0;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 512)] public byte[] d_reserved0;
public uint d_magic;
public uint d_crc;
public uint d_align;
@@ -118,12 +110,9 @@ namespace DiscImageChef.PartPlugins
public ulong d_pbase;
public ulong d_pstop;
public ulong d_abase;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
public byte[] d_packname;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
public byte[] d_reserved;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public Partition64[] d_partitions;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] public byte[] d_packname;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] public byte[] d_reserved;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public Partition64[] d_partitions;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]

View File

@@ -48,13 +48,13 @@ namespace DiscImageChef.PartPlugins
PluginUUID = new Guid("CBC9D281-C1D0-44E8-9038-4D66FD2678AB");
}
public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin, out List<CommonTypes.Partition> partitions, ulong sectorOffset)
public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin,
out List<CommonTypes.Partition> partitions, ulong sectorOffset)
{
partitions = new List<CommonTypes.Partition>();
if(sectorOffset + 2 >= imagePlugin.GetSectors())
return false;
if(sectorOffset + 2 >= imagePlugin.GetSectors()) return false;
byte[] hdrBytes = imagePlugin.ReadSector(1 + sectorOffset);
GptHeader hdr;
@@ -78,11 +78,9 @@ namespace DiscImageChef.PartPlugins
hdrBytes = real;
misaligned = true;
}
else
return false;
else return false;
}
else
return false;
else return false;
}
try
@@ -91,10 +89,7 @@ namespace DiscImageChef.PartPlugins
hdr = (GptHeader)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(GptHeader));
handle.Free();
}
catch
{
return false;
}
catch { return false; }
DicConsole.DebugWriteLine("GPT Plugin", "hdr.revision = 0x{0:X8}", hdr.revision);
DicConsole.DebugWriteLine("GPT Plugin", "hdr.headerSize = {0}", hdr.headerSize);
@@ -110,11 +105,9 @@ namespace DiscImageChef.PartPlugins
DicConsole.DebugWriteLine("GPT Plugin", "hdr.entriesSize = {0}", hdr.entriesSize);
DicConsole.DebugWriteLine("GPT Plugin", "hdr.entriesCrc = 0x{0:X8}", hdr.entriesCrc);
if(hdr.signature != GptMagic)
return false;
if(hdr.signature != GptMagic) return false;
if(hdr.myLBA != 1 + sectorOffset)
return false;
if(hdr.myLBA != 1 + sectorOffset) return false;
uint divisor, modulo, sectorSize;
@@ -132,8 +125,7 @@ namespace DiscImageChef.PartPlugins
}
uint totalEntriesSectors = (hdr.entries * hdr.entriesSize) / imagePlugin.GetSectorSize();
if((hdr.entries * hdr.entriesSize) % imagePlugin.GetSectorSize() > 0)
totalEntriesSectors++;
if((hdr.entries * hdr.entriesSize) % imagePlugin.GetSectorSize() > 0) totalEntriesSectors++;
byte[] temp = imagePlugin.ReadSectors(hdr.entryLBA / divisor, totalEntriesSectors + modulo);
byte[] entriesBytes = new byte[temp.Length - (modulo * 512)];
@@ -152,14 +144,11 @@ namespace DiscImageChef.PartPlugins
entries.Add(entry);
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
catch
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
{
}
catch { }
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
}
if(entries.Count == 0)
return false;
if(entries.Count == 0) return false;
ulong pseq = 0;
@@ -174,8 +163,8 @@ namespace DiscImageChef.PartPlugins
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.GetSectors() || (entry.endLBA / divisor) > imagePlugin.GetSectors())
return false;
if((entry.startLBA / divisor) > imagePlugin.GetSectors() ||
(entry.endLBA / divisor) > imagePlugin.GetSectors()) return false;
CommonTypes.Partition part = new CommonTypes.Partition
{
@@ -202,202 +191,106 @@ namespace DiscImageChef.PartPlugins
string strType = type.ToString().ToUpperInvariant();
switch(strType)
{
case "024DEE41-33E7-11D3-9D69-0008C781F39F":
return "MBR scheme";
case "C12A7328-F81F-11D2-BA4B-00A0C93EC93B":
return "EFI System";
case "21686148-6449-6E6F-744E-656564454649":
return "BIOS Boot";
case "D3BFE2DE-3DAF-11DF-BA40-E3A556D89593":
return "Intel Fast Flash (iFFS)";
case "F4019732-066E-4E12-8273-346C5641494F":
return "Sony boot";
case "BFBFAFE7-A34F-448A-9A5B-6213EB736C22":
return "Lenovo boot";
case "E3C9E316-0B5C-4DB8-817D-F92DF00215AE":
return "Microsoft Reserved (MSR)";
case "EBD0A0A2-B9E5-4433-87C0-68B6B72699C7":
return "Microsoft Basic data";
case "5808C8AA-7E8F-42E0-85D2-E1E90434CFB3":
return "Logical Disk Manager (LDM) metadata";
case "AF9B60A0-1431-4F62-BC68-3311714A69AD":
return "Logical Disk Manager data";
case "DE94BBA4-06D1-4D40-A16A-BFD50179D6AC":
return "Windows Recovery Environment";
case "37AFFC90-EF7D-4E96-91C3-2D7AE055B174":
return "IBM General Parallel File System (GPFS)";
case "E75CAF8F-F680-4CEE-AFA3-B001E56EFC2D":
return "Windows Storage Spaces";
case "75894C1E-3AEB-11D3-B7C1-7B03A0000000":
return "HP-UX Data";
case "E2A1E728-32E3-11D6-A682-7B03A0000000":
return "HP-UX Service";
case "0FC63DAF-8483-4772-8E79-3D69D8477DE4":
return "Linux filesystem";
case "A19D880F-05FC-4D3B-A006-743F0F84911E":
return "Linux RAID";
case "44479540-F297-41B2-9AF7-D131D5F0458A":
return "Linux Root (x86)";
case "4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709":
return "Linux Root (x86-64)";
case "69DAD710-2CE4-4E3C-B16C-21A1D49ABED3":
return "Linux Root (32-bit ARM)";
case "B921B045-1DF0-41C3-AF44-4C6F280D3FAE":
return "Linux Root (64-bit ARM/AArch64)";
case "0657FD6D-A4AB-43C4-84E5-0933C84B4F4F":
return "Linux Swap";
case "E6D6D379-F507-44C2-A23C-238F2A3DF928":
return "Logical Volume Manager (LVM)";
case "933AC7E1-2EB4-4F13-B844-0E14E2AEF915":
return "Linux /home";
case "3B8F8425-20E0-4F3B-907F-1A25A76F98E8":
return "Linux /srv";
case "7FFEC5C9-2D00-49B7-8941-3EA10A5586B7":
return "Plain dm-crypt";
case "CA7D7CCB-63ED-4C53-861C-1742536059CC":
return "LUKS";
case "8DA63339-0007-60C0-C436-083AC8230908":
return "Linux Reserved";
case "83BD6B9D-7F41-11DC-BE0B-001560B84F0F":
return "FreeBSD Boot";
case "516E7CB4-6ECF-11D6-8FF8-00022D09712B":
return "FreeBSD Data";
case "516E7CB5-6ECF-11D6-8FF8-00022D09712B":
return "FreeBSD Swap";
case "516E7CB6-6ECF-11D6-8FF8-00022D09712B":
return "FreeBSD UFS";
case "516E7CB7-6ECF-11D6-8FF8-00022D09712B":
return "FreeBSD UFS2";
case "516E7CB8-6ECF-11D6-8FF8-00022D09712B":
return "FreeBSD Vinum";
case "516E7CBA-6ECF-11D6-8FF8-00022D09712B":
return "FreeBSD ZFS";
case "74BA7DD9-A689-11E1-BD04-00E081286ACF":
return "FreeBSD nandfs";
case "48465300-0000-11AA-AA11-00306543ECAC":
return "Apple HFS";
case "55465300-0000-11AA-AA11-00306543ECAC":
return "Apple UFS";
case "52414944-0000-11AA-AA11-00306543ECAC":
return "Apple RAID";
case "52414944-5F4F-11AA-AA11-00306543ECAC":
return "Apple RAID, offline";
case "426F6F74-0000-11AA-AA11-00306543ECAC":
return "Apple Boot";
case "4C616265-6C00-11AA-AA11-00306543ECAC":
return "Apple Label";
case "5265636F-7665-11AA-AA11-00306543ECAC":
return "Apple TV Recovery";
case "53746F72-6167-11AA-AA11-00306543ECAC":
return "Apple Core Storage";
case "6A82CB45-1DD2-11B2-99A6-080020736631":
return "Solaris Boot";
case "6A85CF4D-1DD2-11B2-99A6-080020736631":
return "Solaris Root";
case "6A87C46F-1DD2-11B2-99A6-080020736631":
return "Solaris Swap";
case "6A8B642B-1DD2-11B2-99A6-080020736631":
return "Solaris Backup";
case "6A898CC3-1DD2-11B2-99A6-080020736631":
return "Solaris /usr or Apple ZFS";
case "6A8EF2E9-1DD2-11B2-99A6-080020736631":
return "Solaris /var";
case "6A90BA39-1DD2-11B2-99A6-080020736631":
return "Solaris /home";
case "6A9283A5-1DD2-11B2-99A6-080020736631":
return "Solaris Alternate sector";
case "024DEE41-33E7-11D3-9D69-0008C781F39F": return "MBR scheme";
case "C12A7328-F81F-11D2-BA4B-00A0C93EC93B": return "EFI System";
case "21686148-6449-6E6F-744E-656564454649": return "BIOS Boot";
case "D3BFE2DE-3DAF-11DF-BA40-E3A556D89593": return "Intel Fast Flash (iFFS)";
case "F4019732-066E-4E12-8273-346C5641494F": return "Sony boot";
case "BFBFAFE7-A34F-448A-9A5B-6213EB736C22": return "Lenovo boot";
case "E3C9E316-0B5C-4DB8-817D-F92DF00215AE": return "Microsoft Reserved (MSR)";
case "EBD0A0A2-B9E5-4433-87C0-68B6B72699C7": return "Microsoft Basic data";
case "5808C8AA-7E8F-42E0-85D2-E1E90434CFB3": return "Logical Disk Manager (LDM) metadata";
case "AF9B60A0-1431-4F62-BC68-3311714A69AD": return "Logical Disk Manager data";
case "DE94BBA4-06D1-4D40-A16A-BFD50179D6AC": return "Windows Recovery Environment";
case "37AFFC90-EF7D-4E96-91C3-2D7AE055B174": return "IBM General Parallel File System (GPFS)";
case "E75CAF8F-F680-4CEE-AFA3-B001E56EFC2D": return "Windows Storage Spaces";
case "75894C1E-3AEB-11D3-B7C1-7B03A0000000": return "HP-UX Data";
case "E2A1E728-32E3-11D6-A682-7B03A0000000": return "HP-UX Service";
case "0FC63DAF-8483-4772-8E79-3D69D8477DE4": return "Linux filesystem";
case "A19D880F-05FC-4D3B-A006-743F0F84911E": return "Linux RAID";
case "44479540-F297-41B2-9AF7-D131D5F0458A": return "Linux Root (x86)";
case "4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709": return "Linux Root (x86-64)";
case "69DAD710-2CE4-4E3C-B16C-21A1D49ABED3": return "Linux Root (32-bit ARM)";
case "B921B045-1DF0-41C3-AF44-4C6F280D3FAE": return "Linux Root (64-bit ARM/AArch64)";
case "0657FD6D-A4AB-43C4-84E5-0933C84B4F4F": return "Linux Swap";
case "E6D6D379-F507-44C2-A23C-238F2A3DF928": return "Logical Volume Manager (LVM)";
case "933AC7E1-2EB4-4F13-B844-0E14E2AEF915": return "Linux /home";
case "3B8F8425-20E0-4F3B-907F-1A25A76F98E8": return "Linux /srv";
case "7FFEC5C9-2D00-49B7-8941-3EA10A5586B7": return "Plain dm-crypt";
case "CA7D7CCB-63ED-4C53-861C-1742536059CC": return "LUKS";
case "8DA63339-0007-60C0-C436-083AC8230908": return "Linux Reserved";
case "83BD6B9D-7F41-11DC-BE0B-001560B84F0F": return "FreeBSD Boot";
case "516E7CB4-6ECF-11D6-8FF8-00022D09712B": return "FreeBSD Data";
case "516E7CB5-6ECF-11D6-8FF8-00022D09712B": return "FreeBSD Swap";
case "516E7CB6-6ECF-11D6-8FF8-00022D09712B": return "FreeBSD UFS";
case "516E7CB7-6ECF-11D6-8FF8-00022D09712B": return "FreeBSD UFS2";
case "516E7CB8-6ECF-11D6-8FF8-00022D09712B": return "FreeBSD Vinum";
case "516E7CBA-6ECF-11D6-8FF8-00022D09712B": return "FreeBSD ZFS";
case "74BA7DD9-A689-11E1-BD04-00E081286ACF": return "FreeBSD nandfs";
case "48465300-0000-11AA-AA11-00306543ECAC": return "Apple HFS";
case "55465300-0000-11AA-AA11-00306543ECAC": return "Apple UFS";
case "52414944-0000-11AA-AA11-00306543ECAC": return "Apple RAID";
case "52414944-5F4F-11AA-AA11-00306543ECAC": return "Apple RAID, offline";
case "426F6F74-0000-11AA-AA11-00306543ECAC": return "Apple Boot";
case "4C616265-6C00-11AA-AA11-00306543ECAC": return "Apple Label";
case "5265636F-7665-11AA-AA11-00306543ECAC": return "Apple TV Recovery";
case "53746F72-6167-11AA-AA11-00306543ECAC": return "Apple Core Storage";
case "6A82CB45-1DD2-11B2-99A6-080020736631": return "Solaris Boot";
case "6A85CF4D-1DD2-11B2-99A6-080020736631": return "Solaris Root";
case "6A87C46F-1DD2-11B2-99A6-080020736631": return "Solaris Swap";
case "6A8B642B-1DD2-11B2-99A6-080020736631": return "Solaris Backup";
case "6A898CC3-1DD2-11B2-99A6-080020736631": return "Solaris /usr or Apple ZFS";
case "6A8EF2E9-1DD2-11B2-99A6-080020736631": return "Solaris /var";
case "6A90BA39-1DD2-11B2-99A6-080020736631": return "Solaris /home";
case "6A9283A5-1DD2-11B2-99A6-080020736631": return "Solaris Alternate sector";
case "6A945A3B-1DD2-11B2-99A6-080020736631":
case "6A9630D1-1DD2-11B2-99A6-080020736631":
case "6A980767-1DD2-11B2-99A6-080020736631":
case "6A96237F-1DD2-11B2-99A6-080020736631":
case "6A8D2AC7-1DD2-11B2-99A6-080020736631":
return "Solaris Reserved";
case "49F48D32-B10E-11DC-B99B-0019D1879648":
return "NetBSD Swap";
case "49F48D5A-B10E-11DC-B99B-0019D1879648":
return "NetBSD FFS";
case "49F48D82-B10E-11DC-B99B-0019D1879648":
return "NetBSD LFS";
case "49F48DAA-B10E-11DC-B99B-0019D1879648":
return "NetBSD RAID";
case "2DB519C4-B10F-11DC-B99B-0019D1879648":
return "NetBSD Concatenated";
case "2DB519EC-B10F-11DC-B99B-0019D1879648":
return "NetBSD Encrypted";
case "FE3A2A5D-4F32-41A7-B725-ACCC3285A309":
return "ChromeOS kernel";
case "3CB8E202-3B7E-47DD-8A3C-7FF2A13CFCEC":
return "ChromeOS rootfs";
case "2E0A753D-9E48-43B0-8337-B15192CB1B5E":
return "ChromeOS future use";
case "42465331-3BA3-10F1-802A-4861696B7521":
return "Haiku BFS";
case "85D5E45E-237C-11E1-B4B3-E89A8F7FC3A7":
return "MidnightBSD Boot";
case "85D5E45A-237C-11E1-B4B3-E89A8F7FC3A7":
return "MidnightBSD Data";
case "85D5E45B-237C-11E1-B4B3-E89A8F7FC3A7":
return "MidnightBSD Swap";
case "0394EF8B-237E-11E1-B4B3-E89A8F7FC3A7":
return "MidnightBSD UFS";
case "85D5E45C-237C-11E1-B4B3-E89A8F7FC3A7":
return "MidnightBSD Vinum";
case "85D5E45D-237C-11E1-B4B3-E89A8F7FC3A7":
return "MidnightBSD ZFS";
case "45B0969E-9B03-4F30-B4C6-B4B80CEFF106":
return "Ceph Journal";
case "45B0969E-9B03-4F30-B4C6-5EC00CEFF106":
return "Ceph dm-crypt Encrypted Journal";
case "4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D":
return "Ceph OSD";
case "4FBD7E29-9D25-41B8-AFD0-5EC00CEFF05D":
return "Ceph dm-crypt OSD";
case "89C57F98-2FE5-4DC0-89C1-F3AD0CEFF2BE":
return "Ceph disk in creation";
case "89C57F98-2FE5-4DC0-89C1-5EC00CEFF2BE":
return "Ceph dm-crypt disk in creation";
case "824CC7A0-36A8-11E3-890A-952519AD3F61":
return "OpenBSD Data";
case "CEF5A9AD-73BC-4601-89F3-CDEEEEE321A1":
return "QNX Power-safe (QNX6)";
case "C91818F9-8025-47AF-89D2-F030D7000C2C":
return "Plan 9";
case "9D275380-40AD-11DB-BF97-000C2911D1B8":
return "VMware vmkcore (coredump)";
case "AA31E02A-400F-11DB-9590-000C2911D1B8":
return "VMware VMFS";
case "9198EFFC-31C0-11DB-8F78-000C2911D1B8":
return "VMware Reserved";
case "7412F7D5-A156-4B13-81DC-867174929325":
return "ONIE boot";
case "D4E6E2CD-4469-46F3-B5CB-1BFF57AFC149":
return "ONIE config";
case "9E1A2D38-C612-4316-AA26-8B49521E5A8B":
return "PowerPC PReP boot";
case "0311FC50-01CA-4725-AD77-9ADBB20ACE98":
return "Acronis Secure Zone";
case "7C3457EF-0000-11AA-AA11-00306543ECAC":
return "Apple File System";
case "9D087404-1CA5-11DC-8817-01301BB8A9F5":
return "DragonflyBSD Label";
case "9D58FDBD-1CA5-11DC-8817-01301BB8A9F5":
return "DragonflyBSD Swap";
case "9D94CE7C-1CA5-11DC-8817-01301BB8A9F5":
return "DragonflyBSD UFS";
case "9DD4478F-1CA5-11DC-8817-01301BB8A9F5":
return "DragonflyBSD Vinum";
case "DBD5211B-1CA5-11DC-8817-01301BB8A9F5":
return "DragonflyBSD CCD";
case "3D48CE54-1D16-11DC-8817-01301BB8A9F5":
return "DragonflyBSD Label";
case "BD215AB2-1D16-11DC-8696-01301BB8A9F5":
return "DragonflyBSD Legacy";
case "61DC63AC-6E38-11DC-8513-01301BB8A9F5":
return "DragonflyBSD Hammer";
case "5CBB9AD1-862D-11DC-A94D-01301BB8A9F5":
return "DragonflyBSD Hammer2";
default:
return "";
case "6A8D2AC7-1DD2-11B2-99A6-080020736631": return "Solaris Reserved";
case "49F48D32-B10E-11DC-B99B-0019D1879648": return "NetBSD Swap";
case "49F48D5A-B10E-11DC-B99B-0019D1879648": return "NetBSD FFS";
case "49F48D82-B10E-11DC-B99B-0019D1879648": return "NetBSD LFS";
case "49F48DAA-B10E-11DC-B99B-0019D1879648": return "NetBSD RAID";
case "2DB519C4-B10F-11DC-B99B-0019D1879648": return "NetBSD Concatenated";
case "2DB519EC-B10F-11DC-B99B-0019D1879648": return "NetBSD Encrypted";
case "FE3A2A5D-4F32-41A7-B725-ACCC3285A309": return "ChromeOS kernel";
case "3CB8E202-3B7E-47DD-8A3C-7FF2A13CFCEC": return "ChromeOS rootfs";
case "2E0A753D-9E48-43B0-8337-B15192CB1B5E": return "ChromeOS future use";
case "42465331-3BA3-10F1-802A-4861696B7521": return "Haiku BFS";
case "85D5E45E-237C-11E1-B4B3-E89A8F7FC3A7": return "MidnightBSD Boot";
case "85D5E45A-237C-11E1-B4B3-E89A8F7FC3A7": return "MidnightBSD Data";
case "85D5E45B-237C-11E1-B4B3-E89A8F7FC3A7": return "MidnightBSD Swap";
case "0394EF8B-237E-11E1-B4B3-E89A8F7FC3A7": return "MidnightBSD UFS";
case "85D5E45C-237C-11E1-B4B3-E89A8F7FC3A7": return "MidnightBSD Vinum";
case "85D5E45D-237C-11E1-B4B3-E89A8F7FC3A7": return "MidnightBSD ZFS";
case "45B0969E-9B03-4F30-B4C6-B4B80CEFF106": return "Ceph Journal";
case "45B0969E-9B03-4F30-B4C6-5EC00CEFF106": return "Ceph dm-crypt Encrypted Journal";
case "4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D": return "Ceph OSD";
case "4FBD7E29-9D25-41B8-AFD0-5EC00CEFF05D": return "Ceph dm-crypt OSD";
case "89C57F98-2FE5-4DC0-89C1-F3AD0CEFF2BE": return "Ceph disk in creation";
case "89C57F98-2FE5-4DC0-89C1-5EC00CEFF2BE": return "Ceph dm-crypt disk in creation";
case "824CC7A0-36A8-11E3-890A-952519AD3F61": return "OpenBSD Data";
case "CEF5A9AD-73BC-4601-89F3-CDEEEEE321A1": return "QNX Power-safe (QNX6)";
case "C91818F9-8025-47AF-89D2-F030D7000C2C": return "Plan 9";
case "9D275380-40AD-11DB-BF97-000C2911D1B8": return "VMware vmkcore (coredump)";
case "AA31E02A-400F-11DB-9590-000C2911D1B8": return "VMware VMFS";
case "9198EFFC-31C0-11DB-8F78-000C2911D1B8": return "VMware Reserved";
case "7412F7D5-A156-4B13-81DC-867174929325": return "ONIE boot";
case "D4E6E2CD-4469-46F3-B5CB-1BFF57AFC149": return "ONIE config";
case "9E1A2D38-C612-4316-AA26-8B49521E5A8B": return "PowerPC PReP boot";
case "0311FC50-01CA-4725-AD77-9ADBB20ACE98": return "Acronis Secure Zone";
case "7C3457EF-0000-11AA-AA11-00306543ECAC": return "Apple File System";
case "9D087404-1CA5-11DC-8817-01301BB8A9F5": return "DragonflyBSD Label";
case "9D58FDBD-1CA5-11DC-8817-01301BB8A9F5": return "DragonflyBSD Swap";
case "9D94CE7C-1CA5-11DC-8817-01301BB8A9F5": return "DragonflyBSD UFS";
case "9DD4478F-1CA5-11DC-8817-01301BB8A9F5": return "DragonflyBSD Vinum";
case "DBD5211B-1CA5-11DC-8817-01301BB8A9F5": return "DragonflyBSD CCD";
case "3D48CE54-1D16-11DC-8817-01301BB8A9F5": return "DragonflyBSD Label";
case "BD215AB2-1D16-11DC-8696-01301BB8A9F5": return "DragonflyBSD Legacy";
case "61DC63AC-6E38-11DC-8513-01301BB8A9F5": return "DragonflyBSD Hammer";
case "5CBB9AD1-862D-11DC-A94D-01301BB8A9F5": return "DragonflyBSD Hammer2";
default: return "";
}
}
@@ -428,9 +321,7 @@ namespace DiscImageChef.PartPlugins
public ulong startLBA;
public ulong endLBA;
public ulong attributes;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 36)]
public string name;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 36)] public string name;
}
}
}
}

View File

@@ -59,8 +59,7 @@ namespace DiscImageChef.PartPlugins
DicConsole.DebugWriteLine("Human68k plugin", "sectorSize = {0}", imagePlugin.GetSectorSize());
if(sectorOffset + 4 >= imagePlugin.GetSectors())
return false;
if(sectorOffset + 4 >= imagePlugin.GetSectors()) return false;
switch(imagePlugin.GetSectorSize())
{
@@ -76,16 +75,14 @@ namespace DiscImageChef.PartPlugins
sector = imagePlugin.ReadSector(2 + sectorOffset);
sectsPerUnit = 1;
break;
default:
return false;
default: return false;
}
X68kTable table = BigEndianMarshal.ByteArrayToStructureBigEndian<X68kTable>(sector);
DicConsole.DebugWriteLine("Human68k plugin", "table.magic = {0:X4}", table.magic);
if(table.magic != X68kMagic)
return false;
if(table.magic != X68kMagic) return false;
for(int i = 0; i < table.entries.Length; i++)
table.entries[i] = BigEndianMarshal.SwapStructureMembersEndian(table.entries[i]);
@@ -98,10 +95,12 @@ namespace DiscImageChef.PartPlugins
foreach(X68kEntry entry in table.entries)
{
DicConsole.DebugWriteLine("Human68k plugin", "entry.name = {0}", StringHandlers.CToString(entry.name, Encoding.GetEncoding(932)));
DicConsole.DebugWriteLine("Human68k plugin", "entry.name = {0}",
StringHandlers.CToString(entry.name, Encoding.GetEncoding(932)));
DicConsole.DebugWriteLine("Human68k plugin", "entry.stateStart = {0}", entry.stateStart);
DicConsole.DebugWriteLine("Human68k plugin", "entry.length = {0}", entry.length);
DicConsole.DebugWriteLine("Human68k plugin", "sectsPerUnit = {0} {1}", sectsPerUnit, imagePlugin.GetSectorSize());
DicConsole.DebugWriteLine("Human68k plugin", "sectsPerUnit = {0} {1}", sectsPerUnit,
imagePlugin.GetSectorSize());
Partition part = new Partition
{
@@ -130,15 +129,13 @@ namespace DiscImageChef.PartPlugins
public uint size;
public uint size2;
public uint unknown;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public X68kEntry[] entries;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public X68kEntry[] entries;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct X68kEntry
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public byte[] name;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] name;
public uint stateStart;
public uint length;
}

View File

@@ -50,14 +50,14 @@ namespace DiscImageChef.PartPlugins
PluginUUID = new Guid("5E8A34E8-4F1A-59E6-4BF7-7EA647063A76");
}
public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin, out List<CommonTypes.Partition> partitions, ulong sectorOffset)
public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin,
out List<CommonTypes.Partition> partitions, ulong sectorOffset)
{
ulong counter = 0;
partitions = new List<CommonTypes.Partition>();
if(imagePlugin.GetSectorSize() < 512)
return false;
if(imagePlugin.GetSectorSize() < 512) return false;
uint sectorSize = imagePlugin.GetSectorSize();
// Divider of sector size in MBR between real sector size
@@ -72,19 +72,28 @@ namespace DiscImageChef.PartPlugins
byte[] sector = imagePlugin.ReadSector(sectorOffset);
GCHandle handle = GCHandle.Alloc(sector, GCHandleType.Pinned);
MasterBootRecord mbr = (MasterBootRecord)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(MasterBootRecord));
TimedMasterBootRecord mbr_time = (TimedMasterBootRecord)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(TimedMasterBootRecord));
SerializedMasterBootRecord mbr_serial = (SerializedMasterBootRecord)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(SerializedMasterBootRecord));
ModernMasterBootRecord mbr_modern = (ModernMasterBootRecord)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(ModernMasterBootRecord));
NecMasterBootRecord mbr_nec = (NecMasterBootRecord)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(NecMasterBootRecord));
DiskManagerMasterBootRecord mbr_ontrack = (DiskManagerMasterBootRecord)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(DiskManagerMasterBootRecord));
MasterBootRecord mbr =
(MasterBootRecord)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(MasterBootRecord));
TimedMasterBootRecord mbr_time =
(TimedMasterBootRecord)Marshal.PtrToStructure(handle.AddrOfPinnedObject(),
typeof(TimedMasterBootRecord));
SerializedMasterBootRecord mbr_serial =
(SerializedMasterBootRecord)Marshal.PtrToStructure(handle.AddrOfPinnedObject(),
typeof(SerializedMasterBootRecord));
ModernMasterBootRecord mbr_modern =
(ModernMasterBootRecord)Marshal.PtrToStructure(handle.AddrOfPinnedObject(),
typeof(ModernMasterBootRecord));
NecMasterBootRecord mbr_nec =
(NecMasterBootRecord)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(NecMasterBootRecord));
DiskManagerMasterBootRecord mbr_ontrack =
(DiskManagerMasterBootRecord)Marshal.PtrToStructure(handle.AddrOfPinnedObject(),
typeof(DiskManagerMasterBootRecord));
handle.Free();
DicConsole.DebugWriteLine("MBR plugin", "xmlmedia = {0}", imagePlugin.ImageInfo.xmlMediaType);
DicConsole.DebugWriteLine("MBR plugin", "mbr.magic = {0:X4}", mbr.magic);
if(mbr.magic != MBR_Magic)
return false; // Not MBR
if(mbr.magic != MBR_Magic) return false; // Not MBR
byte[] hdrBytes = imagePlugin.ReadSector(1 + sectorOffset);
@@ -92,26 +101,21 @@ namespace DiscImageChef.PartPlugins
DicConsole.DebugWriteLine("MBR Plugin", "gpt.signature = 0x{0:X16}", signature);
if(signature == GptMagic)
return false;
if(signature == GptMagic) return false;
if(signature != GptMagic && imagePlugin.ImageInfo.xmlMediaType == XmlMediaType.OpticalDisc)
{
hdrBytes = imagePlugin.ReadSector(sectorOffset);
signature = BitConverter.ToUInt64(hdrBytes, 512);
DicConsole.DebugWriteLine("MBR Plugin", "gpt.signature @ 0x200 = 0x{0:X16}", signature);
if(signature == GptMagic)
return false;
if(signature == GptMagic) return false;
}
MBRPartitionEntry[] entries;
if(mbr_ontrack.dm_magic == DM_Magic)
entries = mbr_ontrack.entries;
else if(mbr_nec.nec_magic == NEC_Magic)
entries = mbr_nec.entries;
else
entries = mbr.entries;
if(mbr_ontrack.dm_magic == DM_Magic) entries = mbr_ontrack.entries;
else if(mbr_nec.nec_magic == NEC_Magic) entries = mbr_nec.entries;
else entries = mbr.entries;
foreach(MBRPartitionEntry entry in entries)
{
@@ -128,30 +132,35 @@ namespace DiscImageChef.PartPlugins
bool extended = false;
bool minix = false;
if(entry.status != 0x00 && entry.status != 0x80)
return false; // Maybe a FAT filesystem
if(entry.status != 0x00 && entry.status != 0x80) return false; // Maybe a FAT filesystem
valid &= entry.type != 0x00;
if(entry.type == 0x05 || entry.type == 0x0F || entry.type == 0x15 || entry.type == 0x1F || entry.type == 0x85 ||
entry.type == 0x91 || entry.type == 0x9B || entry.type == 0xC5 || entry.type == 0xCF || entry.type == 0xD5)
if(entry.type == 0x05 || entry.type == 0x0F || entry.type == 0x15 || entry.type == 0x1F ||
entry.type == 0x85 || entry.type == 0x91 || entry.type == 0x9B || entry.type == 0xC5 ||
entry.type == 0xCF || entry.type == 0xD5)
{
valid = false;
extended = true; // Extended partition
}
minix |= entry.type == 0x81 || entry.type == 0x80; // MINIX partition
valid &= entry.lba_start != 0 || entry.lba_sectors != 0 || entry.start_cylinder != 0 || entry.start_head != 0 || entry.start_sector != 0 || entry.end_cylinder != 0 || entry.end_head != 0 || entry.end_sector != 0;
valid &= entry.lba_start != 0 || entry.lba_sectors != 0 || entry.start_cylinder != 0 ||
entry.start_head != 0 || entry.start_sector != 0 || entry.end_cylinder != 0 ||
entry.end_head != 0 || entry.end_sector != 0;
if(entry.lba_start == 0 && entry.lba_sectors == 0 && valid)
{
lba_start = Helpers.CHS.ToLBA(start_cylinder, entry.start_head, start_sector, imagePlugin.ImageInfo.heads, imagePlugin.ImageInfo.sectorsPerTrack);
lba_sectors = Helpers.CHS.ToLBA(end_cylinder, entry.end_head, entry.end_sector, imagePlugin.ImageInfo.heads, imagePlugin.ImageInfo.sectorsPerTrack) - lba_start;
lba_start = Helpers.CHS.ToLBA(start_cylinder, entry.start_head, start_sector,
imagePlugin.ImageInfo.heads, imagePlugin.ImageInfo.sectorsPerTrack);
lba_sectors = Helpers.CHS.ToLBA(end_cylinder, entry.end_head, entry.end_sector,
imagePlugin.ImageInfo.heads,
imagePlugin.ImageInfo.sectorsPerTrack) - lba_start;
}
// For optical media
lba_start /= divider;
lba_sectors /= divider;
if(minix && lba_start == sectorOffset)
minix = false;
if(minix && lba_start == sectorOffset) minix = false;
if(lba_start > imagePlugin.GetSectors())
{
@@ -181,24 +190,23 @@ namespace DiscImageChef.PartPlugins
if(valid && minix) // Let's mix the fun
{
if(GetMinix(imagePlugin, lba_start, divider, sectorOffset, sectorSize, out List<Partition> mnx_parts))
partitions.AddRange(mnx_parts);
else
minix = false;
if(GetMinix(imagePlugin, lba_start, divider, sectorOffset, sectorSize,
out List<Partition> mnx_parts)) partitions.AddRange(mnx_parts);
else minix = false;
}
if(valid && !minix)
{
CommonTypes.Partition part = new CommonTypes.Partition();
if((lba_start > 0 || imagePlugin.ImageInfo.xmlMediaType == XmlMediaType.OpticalDisc) && lba_sectors > 0)
if((lba_start > 0 || imagePlugin.ImageInfo.xmlMediaType == XmlMediaType.OpticalDisc) &&
lba_sectors > 0)
{
part.Start = lba_start + sectorOffset;
part.Length = lba_sectors;
part.Offset = part.Start * sectorSize;
part.Size = part.Length * sectorSize;
}
else
valid = false;
else valid = false;
if(valid)
{
@@ -226,13 +234,14 @@ namespace DiscImageChef.PartPlugins
sector = imagePlugin.ReadSector(lba_start);
handle = GCHandle.Alloc(sector, GCHandleType.Pinned);
ExtendedBootRecord ebr = (ExtendedBootRecord)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(ExtendedBootRecord));
ExtendedBootRecord ebr =
(ExtendedBootRecord)Marshal.PtrToStructure(handle.AddrOfPinnedObject(),
typeof(ExtendedBootRecord));
handle.Free();
DicConsole.DebugWriteLine("MBR plugin", "ebr.magic == MBR_Magic = {0}", ebr.magic == MBR_Magic);
if(ebr.magic != MBR_Magic)
break;
if(ebr.magic != MBR_Magic) break;
ulong next_start = 0;
@@ -240,7 +249,8 @@ namespace DiscImageChef.PartPlugins
{
bool ext_valid = true;
start_sector = (byte)(ebr_entry.start_sector & 0x3F);
start_cylinder = (ushort)(((ebr_entry.start_sector & 0xC0) << 2) | ebr_entry.start_cylinder);
start_cylinder =
(ushort)(((ebr_entry.start_sector & 0xC0) << 2) | ebr_entry.start_cylinder);
end_sector = (byte)(ebr_entry.end_sector & 0x3F);
end_cylinder = (ushort)(((ebr_entry.end_sector & 0xC0) << 2) | ebr_entry.end_cylinder);
ulong ext_start = ebr_entry.lba_start;
@@ -261,12 +271,19 @@ namespace DiscImageChef.PartPlugins
// Let's start the fun...
ext_valid &= ebr_entry.status == 0x00 || ebr_entry.status == 0x80;
ext_valid &= ebr_entry.type != 0x00;
ext_valid &= ebr_entry.lba_start != 0 || ebr_entry.lba_sectors != 0 || ebr_entry.start_cylinder != 0 || ebr_entry.start_head != 0 ||
ebr_entry.start_sector != 0 || ebr_entry.end_cylinder != 0 || ebr_entry.end_head != 0 || ebr_entry.end_sector != 0;
ext_valid &= ebr_entry.lba_start != 0 || ebr_entry.lba_sectors != 0 ||
ebr_entry.start_cylinder != 0 || ebr_entry.start_head != 0 ||
ebr_entry.start_sector != 0 || ebr_entry.end_cylinder != 0 ||
ebr_entry.end_head != 0 || ebr_entry.end_sector != 0;
if(ebr_entry.lba_start == 0 && ebr_entry.lba_sectors == 0 && ext_valid)
{
ext_start = Helpers.CHS.ToLBA(start_cylinder, ebr_entry.start_head, start_sector, imagePlugin.ImageInfo.heads, imagePlugin.ImageInfo.sectorsPerTrack);
ext_sectors = Helpers.CHS.ToLBA(end_cylinder, ebr_entry.end_head, ebr_entry.end_sector, imagePlugin.ImageInfo.heads, imagePlugin.ImageInfo.sectorsPerTrack) - ext_start;
ext_start = Helpers.CHS.ToLBA(start_cylinder, ebr_entry.start_head, start_sector,
imagePlugin.ImageInfo.heads,
imagePlugin.ImageInfo.sectorsPerTrack);
ext_sectors =
Helpers.CHS.ToLBA(end_cylinder, ebr_entry.end_head, ebr_entry.end_sector,
imagePlugin.ImageInfo.heads,
imagePlugin.ImageInfo.sectorsPerTrack) - ext_start;
}
ext_minix |= (ebr_entry.type == 0x81 || ebr_entry.type == 0x80);
@@ -277,8 +294,10 @@ namespace DiscImageChef.PartPlugins
DicConsole.DebugWriteLine("MBR plugin", "ext_start {0}", ext_start);
DicConsole.DebugWriteLine("MBR plugin", "ext_sectors {0}", ext_sectors);
if(ebr_entry.type == 0x05 || ebr_entry.type == 0x0F || ebr_entry.type == 0x15 || ebr_entry.type == 0x1F || ebr_entry.type == 0x85 ||
ebr_entry.type == 0x91 || ebr_entry.type == 0x9B || ebr_entry.type == 0xC5 || ebr_entry.type == 0xCF || ebr_entry.type == 0xD5)
if(ebr_entry.type == 0x05 || ebr_entry.type == 0x0F || ebr_entry.type == 0x15 ||
ebr_entry.type == 0x1F || ebr_entry.type == 0x85 || ebr_entry.type == 0x91 ||
ebr_entry.type == 0x9B || ebr_entry.type == 0xC5 || ebr_entry.type == 0xCF ||
ebr_entry.type == 0xD5)
{
ext_valid = false;
next_start = chain_start + ext_start;
@@ -293,10 +312,9 @@ namespace DiscImageChef.PartPlugins
if(ext_valid && ext_minix) // Let's mix the fun
{
if(GetMinix(imagePlugin, lba_start, divider, sectorOffset, sectorSize, out List<Partition> mnx_parts))
partitions.AddRange(mnx_parts);
else
ext_minix = false;
if(GetMinix(imagePlugin, lba_start, divider, sectorOffset, sectorSize,
out List<Partition> mnx_parts)) partitions.AddRange(mnx_parts);
else ext_minix = false;
}
if(ext_valid && !ext_minix)
@@ -309,8 +327,7 @@ namespace DiscImageChef.PartPlugins
part.Offset = part.Start * sectorSize;
part.Size = part.Length * sectorSize;
}
else
ext_valid = false;
else ext_valid = false;
if(ext_valid)
{
@@ -338,20 +355,21 @@ namespace DiscImageChef.PartPlugins
return partitions.Count != 0;
}
static bool GetMinix(ImagePlugin imagePlugin, ulong start, ulong divider, ulong sectorOffset, uint sectorSize, out List<Partition> partitions)
static bool GetMinix(ImagePlugin imagePlugin, ulong start, ulong divider, ulong sectorOffset, uint sectorSize,
out List<Partition> partitions)
{
partitions = new List<Partition>();
byte[] sector = imagePlugin.ReadSector(start);
GCHandle handle = GCHandle.Alloc(sector, GCHandleType.Pinned);
ExtendedBootRecord mnx = (ExtendedBootRecord)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(ExtendedBootRecord));
ExtendedBootRecord mnx =
(ExtendedBootRecord)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(ExtendedBootRecord));
handle.Free();
DicConsole.DebugWriteLine("MBR plugin", "mnx.magic == MBR_Magic = {0}", mnx.magic == MBR_Magic);
if(mnx.magic != MBR_Magic)
return false;
if(mnx.magic != MBR_Magic) return false;
bool any_mnx = false;
@@ -378,12 +396,16 @@ namespace DiscImageChef.PartPlugins
mnx_valid &= mnx_entry.status == 0x00 || mnx_entry.status == 0x80;
mnx_valid &= mnx_entry.type == 0x81 || mnx_entry.type == 0x80;
mnx_valid &= mnx_entry.lba_start != 0 || mnx_entry.lba_sectors != 0 || mnx_entry.start_cylinder != 0 || mnx_entry.start_head != 0 ||
mnx_entry.start_sector != 0 || mnx_entry.end_cylinder != 0 || mnx_entry.end_head != 0 || mnx_entry.end_sector != 0;
mnx_valid &= mnx_entry.lba_start != 0 || mnx_entry.lba_sectors != 0 || mnx_entry.start_cylinder != 0 ||
mnx_entry.start_head != 0 || mnx_entry.start_sector != 0 || mnx_entry.end_cylinder != 0 ||
mnx_entry.end_head != 0 || mnx_entry.end_sector != 0;
if(mnx_entry.lba_start == 0 && mnx_entry.lba_sectors == 0 && mnx_valid)
{
mnx_start = Helpers.CHS.ToLBA(start_cylinder, mnx_entry.start_head, start_sector, imagePlugin.ImageInfo.heads, imagePlugin.ImageInfo.sectorsPerTrack);
mnx_sectors = Helpers.CHS.ToLBA(end_cylinder, mnx_entry.end_head, mnx_entry.end_sector, imagePlugin.ImageInfo.heads, imagePlugin.ImageInfo.sectorsPerTrack) - mnx_start;
mnx_start = Helpers.CHS.ToLBA(start_cylinder, mnx_entry.start_head, start_sector,
imagePlugin.ImageInfo.heads, imagePlugin.ImageInfo.sectorsPerTrack);
mnx_sectors = Helpers.CHS.ToLBA(end_cylinder, mnx_entry.end_head, mnx_entry.end_sector,
imagePlugin.ImageInfo.heads,
imagePlugin.ImageInfo.sectorsPerTrack) - mnx_start;
}
// For optical media
@@ -403,8 +425,7 @@ namespace DiscImageChef.PartPlugins
part.Offset = part.Start * sectorSize;
part.Size = part.Length * sectorSize;
}
else
mnx_valid = false;
else mnx_valid = false;
if(mnx_valid)
{
@@ -422,13 +443,15 @@ namespace DiscImageChef.PartPlugins
return any_mnx;
}
static readonly string[] MBRTypes = {
static readonly string[] MBRTypes =
{
// 0x00
"Empty", "FAT12", "XENIX root", "XENIX /usr",
// 0x04
"FAT16 < 32 MiB", "Extended", "FAT16", "IFS (HPFS/NTFS)",
// 0x08
"AIX boot, OS/2, Commodore DOS", "AIX data, Coherent, QNX", "Coherent swap, OPUS, OS/2 Boot Manager", "FAT32",
"AIX boot, OS/2, Commodore DOS", "AIX data, Coherent, QNX", "Coherent swap, OPUS, OS/2 Boot Manager",
"FAT32",
// 0x0C
"FAT32 (LBA)", "Unknown", "FAT16 (LBA)", "Extended (LBA)",
// 0x10
@@ -526,11 +549,13 @@ namespace DiscImageChef.PartPlugins
// 0xC8
"DR-DOS reserved", "DR-DOS reserved", "DR-DOS reserved", "DR-DOS secured FAT32",
// 0xCC
"DR-DOS secured FAT32 (LBA)", "DR-DOS reserved", "DR-DOS secured FAT16 (LBA)", "DR-DOS secured extended (LBA)",
"DR-DOS secured FAT32 (LBA)", "DR-DOS reserved", "DR-DOS secured FAT16 (LBA)",
"DR-DOS secured extended (LBA)",
// 0xD0
"Multiuser DOS secured FAT12", "Multiuser DOS secured FAT12", "Unknown", "Unknown",
// 0xD4
"Multiuser DOS secured FAT16 < 32 MiB", "Multiuser DOS secured extended", "Multiuser DOS secured FAT16", "Unknown",
"Multiuser DOS secured FAT16 < 32 MiB", "Multiuser DOS secured extended", "Multiuser DOS secured FAT16",
"Unknown",
// 0xD8
"CP/M", "Unknown", "Filesystem-less data", "CP/M, CCP/M, CTOS",
// 0xDC
@@ -566,11 +591,9 @@ namespace DiscImageChef.PartPlugins
public struct MasterBootRecord
{
/// <summary>Boot code</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 446)]
public byte[] boot_code;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 446)] public byte[] boot_code;
/// <summary>Partitions</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public MBRPartitionEntry[] entries;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public MBRPartitionEntry[] entries;
/// <summary><see cref="MBR_Magic"/></summary>
public ushort magic;
}
@@ -580,11 +603,9 @@ namespace DiscImageChef.PartPlugins
public struct ExtendedBootRecord
{
/// <summary>Boot code, almost always unused</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 446)]
public byte[] boot_code;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 446)] public byte[] boot_code;
/// <summary>Partitions or pointers</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public MBRPartitionEntry[] entries;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public MBRPartitionEntry[] entries;
/// <summary><see cref="MBR_Magic"/></summary>
public ushort magic;
}
@@ -593,8 +614,7 @@ namespace DiscImageChef.PartPlugins
public struct TimedMasterBootRecord
{
/// <summary>Boot code</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 218)]
public byte[] boot_code;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 218)] public byte[] boot_code;
/// <summary>Set to 0</summary>
public ushort zero;
/// <summary>Original physical drive</summary>
@@ -606,11 +626,9 @@ namespace DiscImageChef.PartPlugins
/// <summary>Disk timestamp, hours</summary>
public byte hours;
/// <summary>Boot code, continuation</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 222)]
public byte[] boot_code2;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 222)] public byte[] boot_code2;
/// <summary>Partitions</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public MBRPartitionEntry[] entries;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public MBRPartitionEntry[] entries;
/// <summary><see cref="MBR_Magic"/></summary>
public ushort magic;
}
@@ -619,15 +637,13 @@ namespace DiscImageChef.PartPlugins
public struct SerializedMasterBootRecord
{
/// <summary>Boot code</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 440)]
public byte[] boot_code;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 440)] public byte[] boot_code;
/// <summary>Disk serial number</summary>
public uint serial;
/// <summary>Set to 0</summary>
public ushort zero;
/// <summary>Partitions</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public MBRPartitionEntry[] entries;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public MBRPartitionEntry[] entries;
/// <summary><see cref="MBR_Magic"/></summary>
public ushort magic;
}
@@ -636,8 +652,7 @@ namespace DiscImageChef.PartPlugins
public struct ModernMasterBootRecord
{
/// <summary>Boot code</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 218)]
public byte[] boot_code;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 218)] public byte[] boot_code;
/// <summary>Set to 0</summary>
public ushort zero;
/// <summary>Original physical drive</summary>
@@ -649,15 +664,13 @@ namespace DiscImageChef.PartPlugins
/// <summary>Disk timestamp, hours</summary>
public byte hours;
/// <summary>Boot code, continuation</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 216)]
public byte[] boot_code2;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 216)] public byte[] boot_code2;
/// <summary>Disk serial number</summary>
public uint serial;
/// <summary>Set to 0</summary>
public ushort zero2;
/// <summary>Partitions</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public MBRPartitionEntry[] entries;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public MBRPartitionEntry[] entries;
/// <summary><see cref="MBR_Magic"/></summary>
public ushort magic;
}
@@ -666,13 +679,11 @@ namespace DiscImageChef.PartPlugins
public struct NecMasterBootRecord
{
/// <summary>Boot code</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 380)]
public byte[] boot_code;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 380)] public byte[] boot_code;
/// <summary><see cref="NEC_Magic"/></summary>
public ushort nec_magic;
/// <summary>Partitions</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public MBRPartitionEntry[] entries;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public MBRPartitionEntry[] entries;
/// <summary><see cref="MBR_Magic"/></summary>
public ushort magic;
}
@@ -681,13 +692,11 @@ namespace DiscImageChef.PartPlugins
public struct DiskManagerMasterBootRecord
{
/// <summary>Boot code</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 252)]
public byte[] boot_code;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 252)] public byte[] boot_code;
/// <summary><see cref="DM_Magic"/></summary>
public ushort dm_magic;
/// <summary>Partitions</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public MBRPartitionEntry[] entries;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public MBRPartitionEntry[] entries;
/// <summary><see cref="MBR_Magic"/></summary>
public ushort magic;
}

View File

@@ -50,6 +50,7 @@ namespace DiscImageChef.PartPlugins
const ushort disktabStart = 0xB4;
// 180
const ushort disktabEntrySize = 0x2C;
// 44
public NeXTDisklabel()
{
@@ -57,7 +58,8 @@ namespace DiscImageChef.PartPlugins
PluginUUID = new Guid("246A6D93-4F1A-1F8A-344D-50187A5513A9");
}
public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin, out List<CommonTypes.Partition> partitions, ulong sectorOffset)
public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin,
out List<CommonTypes.Partition> partitions, ulong sectorOffset)
{
bool magic_found = false;
byte[] label_sector;
@@ -65,10 +67,8 @@ namespace DiscImageChef.PartPlugins
uint magic;
uint sector_size;
if(imagePlugin.GetSectorSize() == 2352 || imagePlugin.GetSectorSize() == 2448)
sector_size = 2048;
else
sector_size = imagePlugin.GetSectorSize();
if(imagePlugin.GetSectorSize() == 2352 || imagePlugin.GetSectorSize() == 2448) sector_size = 2048;
else sector_size = imagePlugin.GetSectorSize();
partitions = new List<CommonTypes.Partition>();
@@ -76,11 +76,10 @@ namespace DiscImageChef.PartPlugins
ulong label_position = 0;
foreach(ulong i in new ulong[]{0, 4, 15, 16})
foreach(ulong i in new ulong[] {0, 4, 15, 16})
{
if(i + sectorOffset >= imagePlugin.GetSectors())
break;
if(i + sectorOffset >= imagePlugin.GetSectors()) break;
label_sector = imagePlugin.ReadSector(i + sectorOffset);
magic = BigEndianBitConverter.ToUInt32(label_sector, 0x00);
if(magic == NEXT_MAGIC1 || magic == NEXT_MAGIC2 || magic == NEXT_MAGIC3)
@@ -91,12 +90,10 @@ namespace DiscImageChef.PartPlugins
}
}
if(!magic_found)
return false;
if(!magic_found) return false;
uint sectors_to_read = 7680 / imagePlugin.ImageInfo.sectorSize;
if(7680 % imagePlugin.ImageInfo.sectorSize > 0)
sectors_to_read++;
if(7680 % imagePlugin.ImageInfo.sectorSize > 0) sectors_to_read++;
label_sector = imagePlugin.ReadSectors(label_position, sectors_to_read);
@@ -109,11 +106,14 @@ namespace DiscImageChef.PartPlugins
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_version = 0x{0:X8}", label.dl_version);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_label_blkno = {0}", label.dl_label_blkno);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_size = {0}", label.dl_size);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_label = \"{0}\"", StringHandlers.CToString(label.dl_label));
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_label = \"{0}\"",
StringHandlers.CToString(label.dl_label));
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_flags = {0}", label.dl_flags);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_tag = 0x{0:X8}", label.dl_tag);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_name = \"{0}\"", StringHandlers.CToString(label.dl_dt.d_name));
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_type = \"{0}\"", StringHandlers.CToString(label.dl_dt.d_type));
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_name = \"{0}\"",
StringHandlers.CToString(label.dl_dt.d_name));
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_type = \"{0}\"",
StringHandlers.CToString(label.dl_dt.d_type));
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_secsize = {0}", label.dl_dt.d_secsize);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_ntracks = {0}", label.dl_dt.d_ntracks);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_nsectors = {0}", label.dl_dt.d_nsectors);
@@ -125,10 +125,14 @@ namespace DiscImageChef.PartPlugins
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_ag_size = {0}", label.dl_dt.d_ag_size);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_ag_alts = {0}", label.dl_dt.d_ag_alts);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_ag_off = {0}", label.dl_dt.d_ag_off);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_boot0_blkno[0] = {0}", label.dl_dt.d_boot0_blkno[0]);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_boot0_blkno[1] = {0}", label.dl_dt.d_boot0_blkno[1]);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_bootfile = \"{0}\"", StringHandlers.CToString(label.dl_dt.d_bootfile));
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_hostname = \"{0}\"", StringHandlers.CToString(label.dl_dt.d_hostname));
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_boot0_blkno[0] = {0}",
label.dl_dt.d_boot0_blkno[0]);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_boot0_blkno[1] = {0}",
label.dl_dt.d_boot0_blkno[1]);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_bootfile = \"{0}\"",
StringHandlers.CToString(label.dl_dt.d_bootfile));
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_hostname = \"{0}\"",
StringHandlers.CToString(label.dl_dt.d_hostname));
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_rootpartition = {0}", label.dl_dt.d_rootpartition);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_rwpartition = {0}", label.dl_dt.d_rwpartition);
@@ -137,32 +141,47 @@ namespace DiscImageChef.PartPlugins
byte[] part_b = new byte[44];
Array.Copy(label_sector, 44 + 146 + 44 * i, part_b, 0, 44);
label.dl_dt.d_partitions[i] = BigEndianMarshal.ByteArrayToStructureBigEndian<NeXTEntry>(part_b);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_base = {1}", i, label.dl_dt.d_partitions[i].p_base);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_size = {1}", i, label.dl_dt.d_partitions[i].p_size);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_bsize = {1}", i, label.dl_dt.d_partitions[i].p_bsize);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_fsize = {1}", i, label.dl_dt.d_partitions[i].p_fsize);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_opt = {1}", i, label.dl_dt.d_partitions[i].p_opt);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_cpg = {1}", i, label.dl_dt.d_partitions[i].p_cpg);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_density = {1}", i, label.dl_dt.d_partitions[i].p_density);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_minfree = {1}", i, label.dl_dt.d_partitions[i].p_minfree);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_newfs = {1}", i, label.dl_dt.d_partitions[i].p_newfs);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_mountpt = \"{1}\"", i, StringHandlers.CToString(label.dl_dt.d_partitions[i].p_mountpt));
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_automnt = {1}", i, label.dl_dt.d_partitions[i].p_automnt);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_type = \"{1}\"", i, StringHandlers.CToString(label.dl_dt.d_partitions[i].p_type));
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_base = {1}", i,
label.dl_dt.d_partitions[i].p_base);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_size = {1}", i,
label.dl_dt.d_partitions[i].p_size);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_bsize = {1}", i,
label.dl_dt.d_partitions[i].p_bsize);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_fsize = {1}", i,
label.dl_dt.d_partitions[i].p_fsize);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_opt = {1}", i,
label.dl_dt.d_partitions[i].p_opt);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_cpg = {1}", i,
label.dl_dt.d_partitions[i].p_cpg);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_density = {1}", i,
label.dl_dt.d_partitions[i].p_density);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_minfree = {1}", i,
label.dl_dt.d_partitions[i].p_minfree);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_newfs = {1}", i,
label.dl_dt.d_partitions[i].p_newfs);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_mountpt = \"{1}\"", i,
StringHandlers.CToString(label.dl_dt.d_partitions[i].p_mountpt));
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_automnt = {1}", i,
label.dl_dt.d_partitions[i].p_automnt);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_type = \"{1}\"", i,
StringHandlers.CToString(label.dl_dt.d_partitions[i].p_type));
if(label.dl_dt.d_partitions[i].p_size > 0 && label.dl_dt.d_partitions[i].p_base >= 0 && label.dl_dt.d_partitions[i].p_bsize >= 0)
if(label.dl_dt.d_partitions[i].p_size > 0 && label.dl_dt.d_partitions[i].p_base >= 0 &&
label.dl_dt.d_partitions[i].p_bsize >= 0)
{
StringBuilder sb = new StringBuilder();
CommonTypes.Partition part = new CommonTypes.Partition()
{
Size = (ulong)(label.dl_dt.d_partitions[i].p_size * label.dl_dt.d_secsize),
Offset = (ulong)((label.dl_dt.d_partitions[i].p_base + label.dl_dt.d_front) * label.dl_dt.d_secsize),
Offset =
(ulong)((label.dl_dt.d_partitions[i].p_base + label.dl_dt.d_front) * label.dl_dt.d_secsize),
Type = StringHandlers.CToString(label.dl_dt.d_partitions[i].p_type),
Sequence = (ulong)i,
Name = StringHandlers.CToString(label.dl_dt.d_partitions[i].p_mountpt),
Length = (ulong)((label.dl_dt.d_partitions[i].p_size * label.dl_dt.d_secsize) / sector_size),
Start = (ulong)(((label.dl_dt.d_partitions[i].p_base + label.dl_dt.d_front) * label.dl_dt.d_secsize) / sector_size),
Start = (ulong)(((label.dl_dt.d_partitions[i].p_base + label.dl_dt.d_front) *
label.dl_dt.d_secsize) / sector_size),
Scheme = Name
};
@@ -171,20 +190,19 @@ namespace DiscImageChef.PartPlugins
DicConsole.DebugWriteLine("NeXT Plugin", "Partition bigger than device, reducing...");
part.Length = imagePlugin.ImageInfo.sectors - part.Start;
part.Size = part.Length * sector_size;
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_size = {1}", i, part.Length);
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_size = {1}", i,
part.Length);
}
sb.AppendFormat("{0} bytes per block", label.dl_dt.d_partitions[i].p_bsize).AppendLine();
sb.AppendFormat("{0} bytes per fragment", label.dl_dt.d_partitions[i].p_fsize).AppendLine();
if(label.dl_dt.d_partitions[i].p_opt == 's')
sb.AppendLine("Space optimized");
else if(label.dl_dt.d_partitions[i].p_opt == 't')
sb.AppendLine("Time optimized");
else
sb.AppendFormat("Unknown optimization {0:X2}", label.dl_dt.d_partitions[i].p_opt).AppendLine();
if(label.dl_dt.d_partitions[i].p_opt == 's') sb.AppendLine("Space optimized");
else if(label.dl_dt.d_partitions[i].p_opt == 't') sb.AppendLine("Time optimized");
else sb.AppendFormat("Unknown optimization {0:X2}", label.dl_dt.d_partitions[i].p_opt).AppendLine();
sb.AppendFormat("{0} cylinders per group", label.dl_dt.d_partitions[i].p_cpg).AppendLine();
sb.AppendFormat("{0} bytes per inode", label.dl_dt.d_partitions[i].p_density).AppendLine();
sb.AppendFormat("{0}% of space must be free at minimum", label.dl_dt.d_partitions[i].p_minfree).AppendLine();
sb.AppendFormat("{0}% of space must be free at minimum", label.dl_dt.d_partitions[i].p_minfree)
.AppendLine();
if(label.dl_dt.d_partitions[i].p_newfs != 1)
sb.AppendLine("Filesystem should be formatted at start");
if(label.dl_dt.d_partitions[i].p_automnt == 1)
@@ -212,8 +230,7 @@ namespace DiscImageChef.PartPlugins
/// <summary>Device size in blocks</summary>
public int dl_size;
/// <summary>Device name</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)]
public byte[] dl_label;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)] public byte[] dl_label;
/// <summary>Device flags</summary>
public uint dl_flags;
/// <summary>Device tag</summary>
@@ -237,8 +254,7 @@ namespace DiscImageChef.PartPlugins
/// <summary>Device size in blocks</summary>
public int dl_size;
/// <summary>Device name</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)]
public byte[] dl_label;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)] public byte[] dl_label;
/// <summary>Device flags</summary>
public uint dl_flags;
/// <summary>Device tag</summary>
@@ -246,8 +262,7 @@ namespace DiscImageChef.PartPlugins
/// <summary>Device info and partitions</summary>
public NeXTDiskTab dl_dt;
/// <summary>Bad sector table</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1670)]
public int[] dl_bad;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1670)] public int[] dl_bad;
/// <summary>Checksum</summary>
public ushort dl_checksum;
}
@@ -259,11 +274,9 @@ namespace DiscImageChef.PartPlugins
public struct NeXTDiskTab
{
/// <summary>Drive name</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)]
public byte[] d_name;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)] public byte[] d_name;
/// <summary>Drive type</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)]
public byte[] d_type;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)] public byte[] d_type;
/// <summary>Sector size</summary>
public int d_secsize;
/// <summary>tracks/cylinder</summary>
@@ -287,21 +300,17 @@ namespace DiscImageChef.PartPlugins
/// <summary>sector offset to first alternate</summary>
public short d_ag_off;
/// <summary>"blk 0" boot locations</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
public int[] d_boot0_blkno;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public int[] d_boot0_blkno;
/// <summary>default bootfile</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)]
public byte[] d_bootfile;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)] public byte[] d_bootfile;
/// <summary>host name</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public byte[] d_hostname;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public byte[] d_hostname;
/// <summary>root partition</summary>
public byte d_rootpartition;
/// <summary>r/w partition</summary>
public byte d_rwpartition;
/// <summary>partitions</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public NeXTEntry[] d_partitions;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public NeXTEntry[] d_partitions;
}
/// <summary>
@@ -329,13 +338,11 @@ namespace DiscImageChef.PartPlugins
/// <summary>Should newfs be run on first start?</summary>
public byte p_newfs;
/// <summary>Mount point or empty if mount where you want</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] p_mountpt;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] p_mountpt;
/// <summary>Should automount</summary>
public byte p_automnt;
/// <summary>Filesystem type, always "4.3BSD"?</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public byte[] p_type;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] p_type;
}
}
}

View File

@@ -54,13 +54,11 @@ namespace DiscImageChef.PartPlugins
{
partitions = new List<Partition>();
if(sectorOffset != 0)
return false;
if(sectorOffset != 0) return false;
byte[] bootSector = imagePlugin.ReadSector(0);
byte[] sector = imagePlugin.ReadSector(1);
if(bootSector[bootSector.Length-2] != 0x55 || bootSector[bootSector.Length - 1] != 0xAA)
return false;
if(bootSector[bootSector.Length - 2] != 0x55 || bootSector[bootSector.Length - 1] != 0xAA) return false;
PC98Table table = new PC98Table();
IntPtr tablePtr = Marshal.AllocHGlobal(256);
@@ -85,28 +83,29 @@ namespace DiscImageChef.PartPlugins
DicConsole.DebugWriteLine("PC98 plugin", "entry.dp_esect = {0}", entry.dp_esect);
DicConsole.DebugWriteLine("PC98 plugin", "entry.dp_ehd = {0}", entry.dp_ehd);
DicConsole.DebugWriteLine("PC98 plugin", "entry.dp_ecyl = {0}", entry.dp_ecyl);
DicConsole.DebugWriteLine("PC98 plugin", "entry.dp_name = \"{0}\"", StringHandlers.CToString(entry.dp_name, Encoding.GetEncoding(932)));
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 &&
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_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)
{
Partition part = new Partition
{
Start = Helpers.CHS.ToLBA(entry.dp_scyl, entry.dp_shd, (uint)(entry.dp_ssect + 1), imagePlugin.ImageInfo.heads, imagePlugin.ImageInfo.sectorsPerTrack),
Start = Helpers.CHS.ToLBA(entry.dp_scyl, entry.dp_shd, (uint)(entry.dp_ssect + 1),
imagePlugin.ImageInfo.heads, imagePlugin.ImageInfo.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.GetSectorSize();
part.Length = Helpers.CHS.ToLBA(entry.dp_ecyl, entry.dp_ehd, (uint)(entry.dp_esect + 1), imagePlugin.ImageInfo.heads, imagePlugin.ImageInfo.sectorsPerTrack) - part.Start;
part.Length = Helpers.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.GetSectorSize();
DicConsole.DebugWriteLine("PC98 plugin", "part.Start = {0}", part.Start);
@@ -117,10 +116,8 @@ namespace DiscImageChef.PartPlugins
DicConsole.DebugWriteLine("PC98 plugin", "part.Length = {0}", part.Length);
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)
part.Start < imagePlugin.ImageInfo.sectors && part.End <= imagePlugin.ImageInfo.sectors)
{
partitions.Add(part);
counter++;
@@ -135,36 +132,26 @@ namespace DiscImageChef.PartPlugins
{
switch(sid & 0x7F)
{
case 0x01:
return "FAT12";
case 0x04:
return "PC-UX";
case 0x06:
return "N88-BASIC(86)";
case 0x01: return "FAT12";
case 0x04: return "PC-UX";
case 0x06: return "N88-BASIC(86)";
// Supposedly for FAT16 < 32 MiB, seen in bigger partitions
case 0x11:
case 0x21:
return "FAT16";
case 0x21: return "FAT16";
case 0x28:
case 0x41:
case 0x48:
return "Windows Volume Set";
case 0x44:
return "FreeBSD";
case 0x61:
return "FAT32";
case 0x62:
return "Linux";
default:
return "Unknown";
case 0x48: return "Windows Volume Set";
case 0x44: return "FreeBSD";
case 0x61: return "FAT32";
case 0x62: return "Linux";
default: return "Unknown";
}
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct PC98Table
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public PC98Partition[] entries;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public PC98Partition[] entries;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
@@ -189,8 +176,7 @@ namespace DiscImageChef.PartPlugins
public byte dp_esect;
public byte dp_ehd;
public ushort dp_ecyl;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] dp_name;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] dp_name;
}
}
}

View File

@@ -46,9 +46,7 @@ namespace DiscImageChef.PartPlugins
/// <summary>Plugin UUID.</summary>
public Guid PluginUUID;
protected PartPlugin()
{
}
protected PartPlugin() { }
/// <summary>
/// Interprets a partitioning scheme.
@@ -57,6 +55,7 @@ namespace DiscImageChef.PartPlugins
/// <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(ImagePlugins.ImagePlugin imagePlugin, out List<CommonTypes.Partition> partitions, ulong sectorOffset);
public abstract bool GetInformation(ImagePlugins.ImagePlugin imagePlugin,
out List<CommonTypes.Partition> partitions, ulong sectorOffset);
}
}

View File

@@ -49,12 +49,12 @@ namespace DiscImageChef.PartPlugins
PluginUUID = new Guid("F0BF4FFC-056E-4E7C-8B65-4EAEE250ADD9");
}
public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin, out List<Partition> partitions, ulong sectorOffset)
public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin, out List<Partition> partitions,
ulong sectorOffset)
{
partitions = new List<Partition>();
if(sectorOffset + 2 >= imagePlugin.GetSectors())
return false;
if(sectorOffset + 2 >= imagePlugin.GetSectors()) 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
@@ -62,17 +62,13 @@ namespace DiscImageChef.PartPlugins
foreach(string part in really)
{
if(part.Length < 5 || part.Substring(0, 5) != "part ")
break;
if(part.Length < 5 || part.Substring(0, 5) != "part ") break;
string[] tokens = part.Split(new[] { ' ' });
string[] tokens = part.Split(new[] {' '});
if(tokens.Length != 4)
break;
if(tokens.Length != 4) break;
if(!ulong.TryParse(tokens[2], out ulong start) ||
!ulong.TryParse(tokens[3], out ulong end))
break;
if(!ulong.TryParse(tokens[2], out ulong start) || !ulong.TryParse(tokens[3], out ulong end)) break;
Partition _part = new Partition
{
@@ -88,7 +84,7 @@ namespace DiscImageChef.PartPlugins
partitions.Add(_part);
}
return partitions.Count>0;
return partitions.Count > 0;
}
}
}
}

View File

@@ -54,5 +54,4 @@ using System.Reflection;
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]
//[assembly: AssemblyKeyFile("")]

View File

@@ -889,7 +889,8 @@ namespace DiscImageChef.PartPlugins
public byte[] loadData;
}
public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin, out List<CommonTypes.Partition> partitions, ulong sectorOffset)
public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin,
out List<CommonTypes.Partition> partitions, ulong sectorOffset)
{
partitions = new List<CommonTypes.Partition>();
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
@@ -898,16 +899,15 @@ namespace DiscImageChef.PartPlugins
while(RDBBlock < 16 && !foundRDB)
{
if(imagePlugin.GetSectors() <= RDBBlock)
return false;
if(imagePlugin.GetSectors() <= RDBBlock) return false;
if(RDBBlock + sectorOffset >= imagePlugin.GetSectors()) break;
if(RDBBlock + sectorOffset >= imagePlugin.GetSectors())
break;
byte[] tmpSector = imagePlugin.ReadSector(RDBBlock + sectorOffset);
uint magic = BigEndianBitConverter.ToUInt32(tmpSector, 0);
DicConsole.DebugWriteLine("Amiga RDB plugin", "Possible magic at block {0} is 0x{1:X8}", RDBBlock, magic);
DicConsole.DebugWriteLine("Amiga RDB plugin", "Possible magic at block {0} is 0x{1:X8}", RDBBlock,
magic);
if(magic == RigidDiskBlockMagic)
{
@@ -920,8 +920,7 @@ namespace DiscImageChef.PartPlugins
RDBBlock++;
}
if(!foundRDB)
return false;
if(!foundRDB) return false;
RDBBlock += sectorOffset;
@@ -1067,13 +1066,13 @@ namespace DiscImageChef.PartPlugins
nextBlock = RDB.badblock_ptr;
while(nextBlock != 0xFFFFFFFF)
{
DicConsole.DebugWriteLine("Amiga RDB plugin", "Going to block {0} in search of a BadBlock block", nextBlock);
DicConsole.DebugWriteLine("Amiga RDB plugin", "Going to block {0} in search of a BadBlock block",
nextBlock);
sector = imagePlugin.ReadSector(nextBlock);
uint magic = BigEndianBitConverter.ToUInt32(sector, 0);
if(magic != BadBlockListMagic)
break;
if(magic != BadBlockListMagic) break;
DicConsole.DebugWriteLine("Amiga RDB plugin", "Found BadBlock block");
@@ -1090,7 +1089,8 @@ namespace DiscImageChef.PartPlugins
chainEntry.blockPairs = new BadBlockEntry[entries];
DicConsole.DebugWriteLine("Amiga RDB plugin", "chainEntry.magic = 0x{0:X8}", chainEntry.magic);
DicConsole.DebugWriteLine("Amiga RDB plugin", "chainEntry.size = {0} longs, {1} bytes", chainEntry.size, chainEntry.size * 4);
DicConsole.DebugWriteLine("Amiga RDB plugin", "chainEntry.size = {0} longs, {1} bytes", chainEntry.size,
chainEntry.size * 4);
DicConsole.DebugWriteLine("Amiga RDB plugin", "chainEntry.checksum = 0x{0:X8}", chainEntry.checksum);
DicConsole.DebugWriteLine("Amiga RDB plugin", "chainEntry.targetID = {0}", chainEntry.targetID);
DicConsole.DebugWriteLine("Amiga RDB plugin", "chainEntry.next_ptr = {0}", chainEntry.next_ptr);
@@ -1099,10 +1099,11 @@ namespace DiscImageChef.PartPlugins
for(ulong i = 0; i < entries; i++)
{
chainEntry.blockPairs[i].badBlock = BigEndianBitConverter.ToUInt32(sector, (int)(0x18 + i * 8 + 0));
chainEntry.blockPairs[i].goodBlock = BigEndianBitConverter.ToUInt32(sector, (int)(0x18 + i * 8 + 4));
chainEntry.blockPairs[i].goodBlock =
BigEndianBitConverter.ToUInt32(sector, (int)(0x18 + i * 8 + 4));
DicConsole.DebugWriteLine("Amiga RDB plugin", "Bad block at {0} replaced with good block at {1}",
chainEntry.blockPairs[i].badBlock, chainEntry.blockPairs[i].goodBlock);
chainEntry.blockPairs[i].badBlock, chainEntry.blockPairs[i].goodBlock);
}
BadBlockChain.Add(chainEntry);
@@ -1114,13 +1115,13 @@ namespace DiscImageChef.PartPlugins
nextBlock = RDB.partition_ptr;
while(nextBlock != 0xFFFFFFFF)
{
DicConsole.DebugWriteLine("Amiga RDB plugin", "Going to block {0} in search of a PartitionEntry block", nextBlock + sectorOffset);
DicConsole.DebugWriteLine("Amiga RDB plugin", "Going to block {0} in search of a PartitionEntry block",
nextBlock + sectorOffset);
sector = imagePlugin.ReadSector(nextBlock + sectorOffset);
uint magic = BigEndianBitConverter.ToUInt32(sector, 0);
if(magic != PartitionBlockMagic)
break;
if(magic != PartitionBlockMagic) break;
DicConsole.DebugWriteLine("Amiga RDB plugin", "Found PartitionEntry block");
@@ -1151,7 +1152,6 @@ namespace DiscImageChef.PartPlugins
reserved15 = BigEndianBitConverter.ToUInt32(sector, 0x74),
reserved16 = BigEndianBitConverter.ToUInt32(sector, 0x78),
reserved17 = BigEndianBitConverter.ToUInt32(sector, 0x7C),
dosEnvVec = new DOSEnvironmentVector
{
size = BigEndianBitConverter.ToUInt32(sector, 0x80),
@@ -1182,7 +1182,8 @@ namespace DiscImageChef.PartPlugins
partEntry.driveName = StringHandlers.PascalToString(driveName, Encoding.GetEncoding("iso-8859-1"));
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.magic = 0x{0:X8}", partEntry.magic);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.size = {0} longs, {1} bytes", partEntry.size, partEntry.size * 4);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.size = {0} longs, {1} bytes", partEntry.size,
partEntry.size * 4);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.checksum = 0x{0:X8}", partEntry.checksum);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.targetID = {0}", partEntry.targetID);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.next_ptr = {0}", partEntry.next_ptr);
@@ -1208,26 +1209,44 @@ namespace DiscImageChef.PartPlugins
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.reserved16 = 0x{0:X8}", partEntry.reserved16);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.reserved17 = 0x{0:X8}", partEntry.reserved17);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.size = {0} longs, {1} bytes", partEntry.dosEnvVec.size, partEntry.dosEnvVec.size * 4);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.block_size = {0} longs, {1} bytes", partEntry.dosEnvVec.block_size, partEntry.dosEnvVec.block_size * 4);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.sec_org = 0x{0:X8}", partEntry.dosEnvVec.sec_org);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.surfaces = {0}", partEntry.dosEnvVec.surfaces);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.size = {0} longs, {1} bytes",
partEntry.dosEnvVec.size, partEntry.dosEnvVec.size * 4);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.block_size = {0} longs, {1} bytes",
partEntry.dosEnvVec.block_size, partEntry.dosEnvVec.block_size * 4);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.sec_org = 0x{0:X8}",
partEntry.dosEnvVec.sec_org);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.surfaces = {0}",
partEntry.dosEnvVec.surfaces);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.spb = {0}", partEntry.dosEnvVec.spb);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.bpt = {0}", partEntry.dosEnvVec.bpt);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.reservedblocks = {0}", partEntry.dosEnvVec.reservedblocks);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.prealloc = {0}", partEntry.dosEnvVec.prealloc);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.interleave = {0}", partEntry.dosEnvVec.interleave);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.lowCylinder = {0}", partEntry.dosEnvVec.lowCylinder);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.highCylinder = {0}", partEntry.dosEnvVec.highCylinder);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.numBuffer = {0}", partEntry.dosEnvVec.numBuffer);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.bufMemType = {0}", partEntry.dosEnvVec.bufMemType);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.maxTransfer = {0}", partEntry.dosEnvVec.maxTransfer);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.Mask = 0x{0:X8}", partEntry.dosEnvVec.Mask);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.bootPriority = {0}", partEntry.dosEnvVec.bootPriority);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.dosType = {0}", AmigaDOSTypeToString(partEntry.dosEnvVec.dosType, true));
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.baud = {0}", partEntry.dosEnvVec.baud);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.control = 0x{0:X8}", partEntry.dosEnvVec.control);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.bootBlocks = {0}", partEntry.dosEnvVec.bootBlocks);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.reservedblocks = {0}",
partEntry.dosEnvVec.reservedblocks);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.prealloc = {0}",
partEntry.dosEnvVec.prealloc);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.interleave = {0}",
partEntry.dosEnvVec.interleave);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.lowCylinder = {0}",
partEntry.dosEnvVec.lowCylinder);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.highCylinder = {0}",
partEntry.dosEnvVec.highCylinder);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.numBuffer = {0}",
partEntry.dosEnvVec.numBuffer);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.bufMemType = {0}",
partEntry.dosEnvVec.bufMemType);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.maxTransfer = {0}",
partEntry.dosEnvVec.maxTransfer);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.Mask = 0x{0:X8}",
partEntry.dosEnvVec.Mask);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.bootPriority = {0}",
partEntry.dosEnvVec.bootPriority);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.dosType = {0}",
AmigaDOSTypeToString(partEntry.dosEnvVec.dosType, true));
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.baud = {0}",
partEntry.dosEnvVec.baud);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.control = 0x{0:X8}",
partEntry.dosEnvVec.control);
DicConsole.DebugWriteLine("Amiga RDB plugin", "partEntry.dosEnvVec.bootBlocks = {0}",
partEntry.dosEnvVec.bootBlocks);
PartitionEntries.Add(partEntry);
nextBlock = partEntry.next_ptr;
@@ -1239,13 +1258,13 @@ namespace DiscImageChef.PartPlugins
nextBlock = RDB.fsheader_ptr;
while(nextBlock != 0xFFFFFFFF)
{
DicConsole.DebugWriteLine("Amiga RDB plugin", "Going to block {0} in search of a FileSystemHeader block", nextBlock);
DicConsole.DebugWriteLine("Amiga RDB plugin",
"Going to block {0} in search of a FileSystemHeader block", nextBlock);
sector = imagePlugin.ReadSector(nextBlock);
uint magic = BigEndianBitConverter.ToUInt32(sector, 0);
if(magic != FilesystemHeaderMagic)
break;
if(magic != FilesystemHeaderMagic) break;
DicConsole.DebugWriteLine("Amiga RDB plugin", "Found FileSystemHeader block");
@@ -1277,7 +1296,8 @@ namespace DiscImageChef.PartPlugins
};
DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.magic = 0x{0:X8}", FSHD.magic);
DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.size = {0} longs, {1} bytes", FSHD.size, FSHD.size * 4);
DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.size = {0} longs, {1} bytes", FSHD.size,
FSHD.size * 4);
DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.checksum = 0x{0:X8}", FSHD.checksum);
DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.targetID = {0}", FSHD.targetID);
DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.next_ptr = {0}", FSHD.next_ptr);
@@ -1285,7 +1305,8 @@ namespace DiscImageChef.PartPlugins
DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.reserved1 = 0x{0:X8}", FSHD.reserved1);
DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.reserved2 = 0x{0:X8}", FSHD.reserved2);
DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.dosType = {0}", AmigaDOSTypeToString(FSHD.dosType));
DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.version = {0:D2}.{1:D2} (0x{2:X8})", (FSHD.version & 0xFFFF0000) >> 16, FSHD.version & 0xFFFF, FSHD.version);
DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.version = {0:D2}.{1:D2} (0x{2:X8})",
(FSHD.version & 0xFFFF0000) >> 16, FSHD.version & 0xFFFF, FSHD.version);
DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.patchFlags = 0x{0:X8}", FSHD.patchFlags);
DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.dnode.type = {0}", FSHD.dnode.type);
@@ -1296,7 +1317,8 @@ namespace DiscImageChef.PartPlugins
DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.dnode.priority = {0}", FSHD.dnode.priority);
DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.dnode.startup = {0}", FSHD.dnode.startup);
DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.dnode.seglist_ptr = {0}", FSHD.dnode.seglist_ptr);
DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.dnode.global_vec = 0x{0:X8}", FSHD.dnode.global_vec);
DicConsole.DebugWriteLine("Amiga RDB plugin", "FSHD.dnode.global_vec = 0x{0:X8}",
FSHD.dnode.global_vec);
nextBlock = FSHD.dnode.seglist_ptr;
bool thereAreLoadSegments = false;
@@ -1304,13 +1326,13 @@ namespace DiscImageChef.PartPlugins
sha1Ctx.Init();
while(nextBlock != 0xFFFFFFFF)
{
DicConsole.DebugWriteLine("Amiga RDB plugin", "Going to block {0} in search of a LoadSegment block", nextBlock);
DicConsole.DebugWriteLine("Amiga RDB plugin", "Going to block {0} in search of a LoadSegment block",
nextBlock);
sector = imagePlugin.ReadSector(nextBlock);
uint magicSeg = BigEndianBitConverter.ToUInt32(sector, 0);
if(magicSeg != LoadSegMagic)
break;
if(magicSeg != LoadSegMagic) break;
DicConsole.DebugWriteLine("Amiga RDB plugin", "Found LoadSegment block");
@@ -1325,7 +1347,8 @@ namespace DiscImageChef.PartPlugins
Array.Copy(sector, 0x14, loadSeg.loadData, 0, (loadSeg.size - 5) * 4);
DicConsole.DebugWriteLine("Amiga RDB plugin", "loadSeg.magic = 0x{0:X8}", loadSeg.magic);
DicConsole.DebugWriteLine("Amiga RDB plugin", "loadSeg.size = {0} longs, {1} bytes", loadSeg.size, loadSeg.size * 4);
DicConsole.DebugWriteLine("Amiga RDB plugin", "loadSeg.size = {0} longs, {1} bytes", loadSeg.size,
loadSeg.size * 4);
DicConsole.DebugWriteLine("Amiga RDB plugin", "loadSeg.checksum = 0x{0:X8}", loadSeg.checksum);
DicConsole.DebugWriteLine("Amiga RDB plugin", "loadSeg.targetID = {0}", loadSeg.targetID);
DicConsole.DebugWriteLine("Amiga RDB plugin", "loadSeg.next_ptr = {0}", loadSeg.next_ptr);
@@ -1335,6 +1358,7 @@ namespace DiscImageChef.PartPlugins
sha1Ctx.Update(loadSeg.loadData);
}
if(thereAreLoadSegments)
{
string loadSegSHA1 = sha1Ctx.End();
@@ -1353,8 +1377,11 @@ namespace DiscImageChef.PartPlugins
Description = AmigaDOSTypeToDescriptionString(RDBEntry.dosEnvVec.dosType),
Name = RDBEntry.driveName,
Sequence = sequence,
Length = (RDBEntry.dosEnvVec.highCylinder + 1 - RDBEntry.dosEnvVec.lowCylinder) * RDBEntry.dosEnvVec.surfaces * RDBEntry.dosEnvVec.bpt,
Start = RDBEntry.dosEnvVec.lowCylinder * RDBEntry.dosEnvVec.surfaces * RDBEntry.dosEnvVec.bpt + sectorOffset,
Length =
(RDBEntry.dosEnvVec.highCylinder + 1 - RDBEntry.dosEnvVec.lowCylinder) *
RDBEntry.dosEnvVec.surfaces * RDBEntry.dosEnvVec.bpt,
Start = RDBEntry.dosEnvVec.lowCylinder * RDBEntry.dosEnvVec.surfaces * RDBEntry.dosEnvVec.bpt +
sectorOffset,
Type = AmigaDOSTypeToString(RDBEntry.dosEnvVec.dosType),
Scheme = Name
};
@@ -1372,126 +1399,93 @@ namespace DiscImageChef.PartPlugins
{
switch(AmigaDOSType)
{
case TypeIDOFS:
return "Amiga Original File System";
case TypeIDFFS:
return "Amiga Fast File System";
case TypeIDOFSi:
return "Amiga Original File System with international characters";
case TypeIDFFSi:
return "Amiga Fast File System with international characters";
case TypeIDOFSc:
return "Amiga Original File System with directory cache";
case TypeIDFFSc:
return "Amiga Fast File System with directory cache";
case TypeIDOFS2:
return "Amiga Original File System with long filenames";
case TypeIDFFS2:
return "Amiga Fast File System with long filenames";
case TypeIDAMIXSysV:
return "Amiga UNIX System V filesystem";
case TypeIDAMIXBoot:
return "Amiga UNIX boot filesystem";
case TypeIDAMIXFFS:
return "Amiga UNIX BSD filesystem";
case TypeIDAMIXReserved:
return "Amiga UNIX Reserved partition (swap)";
case TypeIDOFS: return "Amiga Original File System";
case TypeIDFFS: return "Amiga Fast File System";
case TypeIDOFSi: return "Amiga Original File System with international characters";
case TypeIDFFSi: return "Amiga Fast File System with international characters";
case TypeIDOFSc: return "Amiga Original File System with directory cache";
case TypeIDFFSc: return "Amiga Fast File System with directory cache";
case TypeIDOFS2: return "Amiga Original File System with long filenames";
case TypeIDFFS2: return "Amiga Fast File System with long filenames";
case TypeIDAMIXSysV: return "Amiga UNIX System V filesystem";
case TypeIDAMIXBoot: return "Amiga UNIX boot filesystem";
case TypeIDAMIXFFS: return "Amiga UNIX BSD filesystem";
case TypeIDAMIXReserved: return "Amiga UNIX Reserved partition (swap)";
case TypeIDPFS:
case TypeIDPFS2:
case TypeIDPFSm:
case TypeIDAFS:
return "ProfessionalFileSystem";
case TypeIDSFS:
return "SmartFileSystem v1";
case TypeIDSFS2:
return "SmartFileSystem v2";
case TypeIDJXFS:
return "JXFS";
case TypeIDCrossDOS:
return "FAT, as set by CrossDOS";
case TypeIDCrossMac:
return "HFS, as set by CrossMac";
case TypeIDBFFS:
return "4.2UFS, for BFFS";
case TypeIDmuOFS:
return "Amiga Original File System with multi-user patches";
case TypeIDmuFFS:
return "Amiga Fast File System with multi-user patches";
case TypeIDAFS: return "ProfessionalFileSystem";
case TypeIDSFS: return "SmartFileSystem v1";
case TypeIDSFS2: return "SmartFileSystem v2";
case TypeIDJXFS: return "JXFS";
case TypeIDCrossDOS: return "FAT, as set by CrossDOS";
case TypeIDCrossMac: return "HFS, as set by CrossMac";
case TypeIDBFFS: return "4.2UFS, for BFFS";
case TypeIDmuOFS: return "Amiga Original File System with multi-user patches";
case TypeIDmuFFS: return "Amiga Fast File System with multi-user patches";
case TypeIDmuOFSi:
return "Amiga Original File System with international characters and multi-user patches";
case TypeIDmuFFSi:
return "Amiga Fast File System with international characters and multi-user patches";
case TypeIDmuOFSc:
return "Amiga Original File System with directory cache and multi-user patches";
case TypeIDmuFFSc:
return "Amiga Fast File System with directory cache and multi-user patches";
case TypeIDOldBSDUnused:
return "BSD unused";
case TypeIDOldBSDSwap:
return "BSD swap";
case TypeIDOldBSD42FFS:
return "BSD 4.2 FFS";
case TypeIDOldBSD44LFS:
return "BSD 4.4 LFS";
case TypeIDNetBSDRootUnused:
return "NetBSD unused root partition";
case TypeIDNetBSDRoot42FFS:
return "NetBSD 4.2 FFS root partition";
case TypeIDNetBSDRoot44LFS:
return "NetBSD 4.4 LFS root partition";
case TypeIDNetBSDUserUnused:
return "NetBSD unused user partition";
case TypeIDNetBSDUser42FFS:
return "NetBSD 4.2 FFS user partition";
case TypeIDNetBSDUser44LFS:
return "NetBSD 4.4 LFS user partition";
case TypeIDNetBSDSwap:
return "NetBSD swap partition";
case TypeIDLinux:
return "Linux filesystem partition";
case TypeIDLinuxSwap:
return "Linux swap partition";
case TypeIDmuFFSi: return "Amiga Fast File System with international characters and multi-user patches";
case TypeIDmuOFSc: return "Amiga Original File System with directory cache and multi-user patches";
case TypeIDmuFFSc: return "Amiga Fast File System with directory cache and multi-user patches";
case TypeIDOldBSDUnused: return "BSD unused";
case TypeIDOldBSDSwap: return "BSD swap";
case TypeIDOldBSD42FFS: return "BSD 4.2 FFS";
case TypeIDOldBSD44LFS: return "BSD 4.4 LFS";
case TypeIDNetBSDRootUnused: return "NetBSD unused root partition";
case TypeIDNetBSDRoot42FFS: return "NetBSD 4.2 FFS root partition";
case TypeIDNetBSDRoot44LFS: return "NetBSD 4.4 LFS root partition";
case TypeIDNetBSDUserUnused: return "NetBSD unused user partition";
case TypeIDNetBSDUser42FFS: return "NetBSD 4.2 FFS user partition";
case TypeIDNetBSDUser44LFS: return "NetBSD 4.4 LFS user partition";
case TypeIDNetBSDSwap: return "NetBSD swap partition";
case TypeIDLinux: return "Linux filesystem partition";
case TypeIDLinuxSwap: return "Linux swap partition";
case TypeIDRaidFrame:
case TypeIDRaidFrame0:
return "RaidFrame partition";
case TypeIDRaidFrame0: return "RaidFrame partition";
default:
{
if((AmigaDOSType & TypeIDOFS) == TypeIDOFS)
return string.Format("Unknown Amiga DOS filesystem type {0}", AmigaDOSTypeToString(AmigaDOSType));
{
if((AmigaDOSType & TypeIDOFS) == TypeIDOFS)
return string.Format("Unknown Amiga DOS filesystem type {0}",
AmigaDOSTypeToString(AmigaDOSType));
if((AmigaDOSType & TypeIDAMIXSysV) == TypeIDAMIXSysV)
return string.Format("Unknown Amiga UNIX filesystem type {0}", AmigaDOSTypeToString(AmigaDOSType));
if((AmigaDOSType & TypeIDAMIXSysV) == TypeIDAMIXSysV)
return string.Format("Unknown Amiga UNIX filesystem type {0}",
AmigaDOSTypeToString(AmigaDOSType));
if((AmigaDOSType & 0x50465300) == 0x50465300 ||
(AmigaDOSType & 0x41465300) == 0x41465300)
return string.Format("Unknown ProfessionalFileSystem type {0}", AmigaDOSTypeToString(AmigaDOSType));
if((AmigaDOSType & 0x50465300) == 0x50465300 || (AmigaDOSType & 0x41465300) == 0x41465300)
return string.Format("Unknown ProfessionalFileSystem type {0}",
AmigaDOSTypeToString(AmigaDOSType));
if((AmigaDOSType & TypeIDSFS) == TypeIDSFS)
return string.Format("Unknown SmartFileSystem type {0}", AmigaDOSTypeToString(AmigaDOSType));
if((AmigaDOSType & TypeIDSFS) == TypeIDSFS)
return string.Format("Unknown SmartFileSystem type {0}", AmigaDOSTypeToString(AmigaDOSType));
if((AmigaDOSType & TypeIDmuOFS) == TypeIDmuOFS)
return string.Format("Unknown Amiga DOS multi-user filesystem type {0}", AmigaDOSTypeToString(AmigaDOSType));
if((AmigaDOSType & TypeIDmuOFS) == TypeIDmuOFS)
return string.Format("Unknown Amiga DOS multi-user filesystem type {0}",
AmigaDOSTypeToString(AmigaDOSType));
if((AmigaDOSType & TypeIDOldBSDUnused) == TypeIDOldBSDUnused)
return string.Format("Unknown BSD filesystem type {0}", AmigaDOSTypeToString(AmigaDOSType));
if((AmigaDOSType & TypeIDOldBSDUnused) == TypeIDOldBSDUnused)
return string.Format("Unknown BSD filesystem type {0}", AmigaDOSTypeToString(AmigaDOSType));
if((AmigaDOSType & TypeIDNetBSDRootUnused) == TypeIDNetBSDRootUnused)
return string.Format("Unknown NetBSD root filesystem type {0}", AmigaDOSTypeToString(AmigaDOSType));
if((AmigaDOSType & TypeIDNetBSDRootUnused) == TypeIDNetBSDRootUnused)
return string.Format("Unknown NetBSD root filesystem type {0}",
AmigaDOSTypeToString(AmigaDOSType));
if((AmigaDOSType & TypeIDNetBSDUserUnused) == TypeIDNetBSDUserUnused)
return string.Format("Unknown NetBSD user filesystem type {0}", AmigaDOSTypeToString(AmigaDOSType));
if((AmigaDOSType & TypeIDNetBSDUserUnused) == TypeIDNetBSDUserUnused)
return string.Format("Unknown NetBSD user filesystem type {0}",
AmigaDOSTypeToString(AmigaDOSType));
if((AmigaDOSType & TypeIDNetBSDSwap) == TypeIDNetBSDSwap)
return string.Format("Unknown NetBSD swap filesystem type {0}", AmigaDOSTypeToString(AmigaDOSType));
if((AmigaDOSType & TypeIDNetBSDSwap) == TypeIDNetBSDSwap)
return string.Format("Unknown NetBSD swap filesystem type {0}",
AmigaDOSTypeToString(AmigaDOSType));
if((AmigaDOSType & TypeIDLinux) == TypeIDLinux ||
(AmigaDOSType & TypeIDLinuxSwap) == TypeIDLinuxSwap)
return string.Format("Unknown Linux filesystem type {0}", AmigaDOSTypeToString(AmigaDOSType));
if((AmigaDOSType & TypeIDLinux) == TypeIDLinux ||
(AmigaDOSType & TypeIDLinuxSwap) == TypeIDLinuxSwap)
return string.Format("Unknown Linux filesystem type {0}", AmigaDOSTypeToString(AmigaDOSType));
return string.Format("Unknown partition type {0}", AmigaDOSTypeToString(AmigaDOSType));
}
return string.Format("Unknown partition type {0}", AmigaDOSTypeToString(AmigaDOSType));
}
}
}
@@ -1511,7 +1505,9 @@ namespace DiscImageChef.PartPlugins
textPartString = Encoding.ASCII.GetString(textPart);
return quoted ? string.Format("\"{0}\\{1}\"", textPartString, AmigaDOSType & 0xFF) : string.Format("{0}\\{1}", textPartString, AmigaDOSType & 0xFF);
return quoted
? string.Format("\"{0}\\{1}\"", textPartString, AmigaDOSType & 0xFF)
: string.Format("{0}\\{1}", textPartString, AmigaDOSType & 0xFF);
}
}
}

View File

@@ -54,8 +54,7 @@ namespace DiscImageChef.PartPlugins
partitions = new List<Partition>();
byte[] sector = imagePlugin.ReadSector(sectorOffset);
if(sector.Length < 512)
return false;
if(sector.Length < 512) return false;
RioKarmaTable table = new RioKarmaTable();
IntPtr tablePtr = Marshal.AllocHGlobal(512);
@@ -63,8 +62,7 @@ namespace DiscImageChef.PartPlugins
table = (RioKarmaTable)Marshal.PtrToStructure(tablePtr, typeof(RioKarmaTable));
Marshal.FreeHGlobal(tablePtr);
if(table.magic != KarmaMagic)
return false;
if(table.magic != KarmaMagic) return false;
ulong counter = 0;
@@ -93,12 +91,9 @@ namespace DiscImageChef.PartPlugins
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct RioKarmaTable
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 270)]
public byte[] reserved;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
public RioKarmaEntry[] entries;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 208)]
public byte[] padding;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 270)] public byte[] reserved;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public RioKarmaEntry[] entries;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 208)] public byte[] padding;
public ushort magic;
}
@@ -107,8 +102,7 @@ namespace DiscImageChef.PartPlugins
{
public uint reserved;
public byte type;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public byte[] reserved2;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public byte[] reserved2;
public uint offset;
public uint size;
}

View File

@@ -54,39 +54,46 @@ namespace DiscImageChef.PartPlugins
partitions = new List<Partition>();
byte[] sector = imagePlugin.ReadSector(sectorOffset);
if(sector.Length < 512)
return false;
if(sector.Length < 512) return false;
SGILabel dvh = BigEndianMarshal.ByteArrayToStructureBigEndian<SGILabel>(sector);
for(int i = 0; i < dvh.volume.Length; i++)
dvh.volume[i] = BigEndianMarshal.SwapStructureMembersEndian(dvh.volume[i]);
for(int i = 0; i < dvh.partitions.Length; i++)
dvh.partitions[i] = BigEndianMarshal.SwapStructureMembersEndian(dvh.partitions[i]);
dvh.device_params = BigEndianMarshal.SwapStructureMembersEndian(dvh.device_params);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.magic = 0x{0:X8} (should be 0x{1:X8})", dvh.magic, SGI_MAGIC);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.magic = 0x{0:X8} (should be 0x{1:X8})", dvh.magic,
SGI_MAGIC);
if(dvh.magic != SGI_MAGIC)
return false;
if(dvh.magic != SGI_MAGIC) return false;
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.root_part_num = {0}", dvh.root_part_num);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.swap_part_num = {0}", dvh.swap_part_num);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.boot_file = \"{0}\"", StringHandlers.CToString(dvh.boot_file));
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.boot_file = \"{0}\"",
StringHandlers.CToString(dvh.boot_file));
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_skew = {0}", dvh.device_params.dp_skew);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_gap1 = {0}", dvh.device_params.dp_gap1);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_gap2 = {0}", dvh.device_params.dp_gap2);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_spares_cyl = {0}", dvh.device_params.dp_spares_cyl);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_spares_cyl = {0}",
dvh.device_params.dp_spares_cyl);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_cyls = {0}", dvh.device_params.dp_cyls);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_shd0 = {0}", dvh.device_params.dp_shd0);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_trks0 = {0}", dvh.device_params.dp_trks0);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_ctq_depth = {0}", dvh.device_params.dp_ctq_depth);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_ctq_depth = {0}",
dvh.device_params.dp_ctq_depth);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_cylshi = {0}", dvh.device_params.dp_cylshi);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_secs = {0}", dvh.device_params.dp_secs);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_secbytes = {0}", dvh.device_params.dp_secbytes);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_interleave = {0}", dvh.device_params.dp_interleave);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_secbytes = {0}",
dvh.device_params.dp_secbytes);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_interleave = {0}",
dvh.device_params.dp_interleave);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_flags = {0}", dvh.device_params.dp_flags);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_datarate = {0}", dvh.device_params.dp_datarate);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_nretries = {0}", dvh.device_params.dp_nretries);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_datarate = {0}",
dvh.device_params.dp_datarate);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_nretries = {0}",
dvh.device_params.dp_nretries);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_mspw = {0}", dvh.device_params.dp_mspw);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_xgap1 = {0}", dvh.device_params.dp_xgap1);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_xsync = {0}", dvh.device_params.dp_xsync);
@@ -99,23 +106,28 @@ namespace DiscImageChef.PartPlugins
for(int i = 0; i < dvh.partitions.Length; i++)
{
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.partitions[{0}].num_blocks = {1}", i, dvh.partitions[i].num_blocks);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.partitions[{0}].first_block = {1}", i, dvh.partitions[i].first_block);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.partitions[{0}].num_blocks = {1}", i,
dvh.partitions[i].num_blocks);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.partitions[{0}].first_block = {1}", i,
dvh.partitions[i].first_block);
// TODO: Solve big endian marshal with enumerations
dvh.partitions[i].type = (SGIType)Swapping.Swap((uint)dvh.partitions[i].type);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.partitions[{0}].type = {1}", i, dvh.partitions[i].type);
Partition part = new Partition
{
Start = (dvh.partitions[i].first_block * dvh.device_params.dp_secbytes) / imagePlugin.GetSectorSize(),
Start =
(dvh.partitions[i].first_block * dvh.device_params.dp_secbytes) / imagePlugin.GetSectorSize(),
Offset = (dvh.partitions[i].first_block * dvh.device_params.dp_secbytes),
Length = (dvh.partitions[i].num_blocks * dvh.device_params.dp_secbytes) / imagePlugin.GetSectorSize(),
Length =
(dvh.partitions[i].num_blocks * dvh.device_params.dp_secbytes) / imagePlugin.GetSectorSize(),
Size = (dvh.partitions[i].num_blocks * dvh.device_params.dp_secbytes),
Type = TypeToString(dvh.partitions[i].type),
Sequence = counter,
Scheme = Name
};
if(part.Size > 0 && dvh.partitions[i].type != SGIType.Header && dvh.partitions[i].type != SGIType.Volume)
if(part.Size > 0 && dvh.partitions[i].type != SGIType.Header && dvh.partitions[i].type != SGIType.Volume
)
{
partitions.Add(part);
counter++;
@@ -135,16 +147,13 @@ namespace DiscImageChef.PartPlugins
/// <summary></summary>
public short swap_part_num;
/// <summary></summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] boot_file;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] boot_file;
/// <summary></summary>
public SGIDeviceParameters device_params;
/// <summary></summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 15)]
public SGIVolume[] volume;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 15)] public SGIVolume[] volume;
/// <summary></summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public SGIPartition[] partitions;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public SGIPartition[] partitions;
/// <summary></summary>
public uint csum;
/// <summary></summary>
@@ -155,8 +164,7 @@ namespace DiscImageChef.PartPlugins
struct SGIVolume
{
/// <summary></summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public byte[] name;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] name;
/// <summary></summary>
public uint block_num;
/// <summary></summary>
@@ -188,44 +196,27 @@ namespace DiscImageChef.PartPlugins
{
switch(typ)
{
case SGIType.Header:
return "Volume header";
case SGIType.TrkRepl:
return "Track replacements";
case SGIType.SecRepl:
return "Sector replacements";
case SGIType.Swap:
return "Raw data (swap)";
case SGIType.Bsd:
return "4.2BSD Fast File System";
case SGIType.SystemV:
return "UNIX System V";
case SGIType.Volume:
return "Whole device";
case SGIType.EFS:
return "EFS";
case SGIType.Lvol:
return "Logical volume";
case SGIType.Rlvol:
return "Raw logical volume";
case SGIType.XFS:
return "XFS";
case SGIType.Xlvol:
return "XFS log device";
case SGIType.Rxlvol:
return "XLV volume";
case SGIType.Xvm:
return "SGI XVM";
case SGIType.LinuxSwap:
return "Linux swap";
case SGIType.Linux:
return "Linux";
case SGIType.LinuxRAID:
return "Linux RAID";
default:
return "Unknown";
case SGIType.Header: return "Volume header";
case SGIType.TrkRepl: return "Track replacements";
case SGIType.SecRepl: return "Sector replacements";
case SGIType.Swap: return "Raw data (swap)";
case SGIType.Bsd: return "4.2BSD Fast File System";
case SGIType.SystemV: return "UNIX System V";
case SGIType.Volume: return "Whole device";
case SGIType.EFS: return "EFS";
case SGIType.Lvol: return "Logical volume";
case SGIType.Rlvol: return "Raw logical volume";
case SGIType.XFS: return "XFS";
case SGIType.Xlvol: return "XFS log device";
case SGIType.Rxlvol: return "XLV volume";
case SGIType.Xvm: return "SGI XVM";
case SGIType.LinuxSwap: return "Linux swap";
case SGIType.Linux: return "Linux";
case SGIType.LinuxRAID: return "Linux RAID";
default: return "Unknown";
}
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct SGIPartition
{

View File

@@ -60,12 +60,10 @@ namespace DiscImageChef.PartPlugins
/// <summary>Size of padding in SunOS disk label</summary>
const int LEN_DKL_PAD = DK_LABEL_SIZE - (LEN_DKL_ASCII + NDKMAP * 8 + 14 * 2);
/// <summary>Size of padding in Solaris disk label with 8 partitions</summary>
const int LEN_DKL_PAD8 = DK_LABEL_SIZE - (LEN_DKL_ASCII +
136 + // sizeof(dk_vtoc8)
(NDKMAP * 8) + 14 * 2 + 2 * 2);
const int LEN_DKL_PAD16 = DK_LABEL_SIZE -
(456 + // sizeof(dk_vtoc16)
4 * 4 + 12 * 2 + 2 * 2);
const int LEN_DKL_PAD8 = DK_LABEL_SIZE - (LEN_DKL_ASCII + 136 + // sizeof(dk_vtoc8)
(NDKMAP * 8) + 14 * 2 + 2 * 2);
const int LEN_DKL_PAD16 = DK_LABEL_SIZE - (456 + // sizeof(dk_vtoc16)
4 * 4 + 12 * 2 + 2 * 2);
public enum SunTag : ushort
{
@@ -108,16 +106,15 @@ namespace DiscImageChef.PartPlugins
PluginUUID = new Guid("50F35CC4-8375-4445-8DCB-1BA550C931A3");
}
public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin, out List<CommonTypes.Partition> partitions, ulong sectorOffset)
public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin,
out List<CommonTypes.Partition> partitions, ulong sectorOffset)
{
partitions = new List<CommonTypes.Partition>();
if(imagePlugin.GetSectorSize() < 512)
return false;
if(imagePlugin.GetSectorSize() < 512) return false;
if(sectorOffset + 2 >= imagePlugin.GetSectors()) return false;
if(sectorOffset + 2 >= imagePlugin.GetSectors())
return false;
bool useDkl = false, useDkl8 = false, useDkl16 = false;
byte[] sunSector = imagePlugin.ReadSector(sectorOffset);
@@ -132,15 +129,11 @@ namespace DiscImageChef.PartPlugins
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_vtoc.v_sanity = 0x{0:X8}", dkl8.dkl_vtoc.v_sanity);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_vtoc.v_sanity = 0x{0:X8}", dkl16.dkl_vtoc.v_sanity);
if(dkl.dkl_magic == DKL_MAGIC || dkl.dkl_magic == DKL_CIGAM)
{
if(dkl16.dkl_vtoc.v_sanity == VTOC_SANE || dkl16.dkl_vtoc.v_sanity == VTOC_ENAS)
useDkl16 = true;
else if(dkl8.dkl_vtoc.v_sanity == VTOC_SANE || dkl8.dkl_vtoc.v_sanity == VTOC_ENAS)
useDkl8 = true;
else
useDkl = true;
if(dkl16.dkl_vtoc.v_sanity == VTOC_SANE || dkl16.dkl_vtoc.v_sanity == VTOC_ENAS) useDkl16 = true;
else if(dkl8.dkl_vtoc.v_sanity == VTOC_SANE || dkl8.dkl_vtoc.v_sanity == VTOC_ENAS) useDkl8 = true;
else useDkl = true;
}
if(!useDkl && !useDkl8 && !useDkl16)
@@ -155,30 +148,24 @@ namespace DiscImageChef.PartPlugins
if(dkl.dkl_magic == DKL_MAGIC || dkl.dkl_magic == DKL_CIGAM)
{
if(dkl16.dkl_vtoc.v_sanity == VTOC_SANE || dkl16.dkl_vtoc.v_sanity == VTOC_ENAS)
useDkl16 = true;
else if(dkl8.dkl_vtoc.v_sanity == VTOC_SANE || dkl8.dkl_vtoc.v_sanity == VTOC_ENAS)
useDkl8 = true;
else
useDkl = true;
if(dkl16.dkl_vtoc.v_sanity == VTOC_SANE || dkl16.dkl_vtoc.v_sanity == VTOC_ENAS) useDkl16 = true;
else if(dkl8.dkl_vtoc.v_sanity == VTOC_SANE || dkl8.dkl_vtoc.v_sanity == VTOC_ENAS) useDkl8 = true;
else useDkl = true;
}
}
if(!useDkl && !useDkl8 && !useDkl16)
return false;
if(!useDkl && !useDkl8 && !useDkl16) return false;
if(useDkl16 && dkl16.dkl_magic == DKL_CIGAM)
dkl16 = SwapDiskLabel(dkl16);
else if(useDkl8 && dkl8.dkl_magic == DKL_CIGAM)
dkl8 = SwapDiskLabel(dkl8);
else if(useDkl && dkl.dkl_magic == DKL_CIGAM)
dkl = SwapDiskLabel(dkl);
if(useDkl16 && dkl16.dkl_magic == DKL_CIGAM) dkl16 = SwapDiskLabel(dkl16);
else if(useDkl8 && dkl8.dkl_magic == DKL_CIGAM) dkl8 = SwapDiskLabel(dkl8);
else if(useDkl && dkl.dkl_magic == DKL_CIGAM) dkl = SwapDiskLabel(dkl);
if(useDkl)
{
ulong sectorsPerCylinder = (ulong)(dkl.dkl_nsect * dkl.dkl_nhead);
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_asciilabel = \"{0}\"", StringHandlers.CToString(dkl.dkl_asciilabel));
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_asciilabel = \"{0}\"",
StringHandlers.CToString(dkl.dkl_asciilabel));
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_rpm = {0}", dkl.dkl_rpm);
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_pcyl = {0}", dkl.dkl_pcyl);
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_apc = {0}", dkl.dkl_apc);
@@ -193,9 +180,12 @@ namespace DiscImageChef.PartPlugins
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_ppart = {0}", dkl.dkl_ppart);
for(int i = 0; i < NDKMAP; i++)
{
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_map[{0}].dkl_cylno = {1}", i, dkl.dkl_map[i].dkl_cylno);
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_map[{0}].dkl_nblk = {1}", i, dkl.dkl_map[i].dkl_nblk);
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_map[{0}].dkl_cylno = {1}", i,
dkl.dkl_map[i].dkl_cylno);
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_map[{0}].dkl_nblk = {1}", i,
dkl.dkl_map[i].dkl_nblk);
}
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_magic = 0x{0:X4}", dkl.dkl_magic);
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_cksum = 0x{0:X4}", dkl.dkl_cksum);
DicConsole.DebugWriteLine("Sun plugin", "sectorsPerCylinder = {0}", sectorsPerCylinder);
@@ -209,8 +199,10 @@ namespace DiscImageChef.PartPlugins
Size = (ulong)dkl.dkl_map[i].dkl_nblk * DK_LABEL_SIZE,
Length = (ulong)((dkl.dkl_map[i].dkl_nblk * DK_LABEL_SIZE) / imagePlugin.GetSectorSize()),
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.GetSectorSize(),
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.GetSectorSize(),
Type = "SunOS partition",
Scheme = Name
};
@@ -223,9 +215,11 @@ namespace DiscImageChef.PartPlugins
{
ulong sectorsPerCylinder = (ulong)(dkl8.dkl_nsect * dkl8.dkl_nhead);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_asciilabel = \"{0}\"", StringHandlers.CToString(dkl8.dkl_asciilabel));
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_asciilabel = \"{0}\"",
StringHandlers.CToString(dkl8.dkl_asciilabel));
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_vtoc.v_version = {0}", dkl8.dkl_vtoc.v_version);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_vtoc.v_volume = \"{0}\"", StringHandlers.CToString(dkl8.dkl_vtoc.v_volume));
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_vtoc.v_volume = \"{0}\"",
StringHandlers.CToString(dkl8.dkl_vtoc.v_volume));
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_vtoc.v_nparts = {0}", dkl8.dkl_vtoc.v_nparts);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_vtoc.v_sanity = 0x{0:X8}", dkl8.dkl_vtoc.v_sanity);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_write_reinstruct = {0}", dkl8.dkl_write_reinstruct);
@@ -244,23 +238,28 @@ namespace DiscImageChef.PartPlugins
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_obs4 = {0}", dkl8.dkl_obs4);
for(int i = 0; i < NDKMAP; i++)
{
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_map[{0}].dkl_cylno = {1}", i, dkl8.dkl_map[i].dkl_cylno);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_map[{0}].dkl_nblk = {1}", i, dkl8.dkl_map[i].dkl_nblk);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_vtoc.v_part[{0}].p_tag = {1} ({2})", i, dkl8.dkl_vtoc.v_part[i].p_tag, (ushort)dkl8.dkl_vtoc.v_part[i].p_tag);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_vtoc.v_part[{0}].p_flag = {1} ({2})", i, dkl8.dkl_vtoc.v_part[i].p_flag, (ushort)dkl8.dkl_vtoc.v_part[i].p_flag);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_vtoc.v_timestamp[{0}] = {1}", i, DateHandlers.UNIXToDateTime(dkl8.dkl_vtoc.v_timestamp[i]));
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_map[{0}].dkl_cylno = {1}", i,
dkl8.dkl_map[i].dkl_cylno);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_map[{0}].dkl_nblk = {1}", i,
dkl8.dkl_map[i].dkl_nblk);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_vtoc.v_part[{0}].p_tag = {1} ({2})", i,
dkl8.dkl_vtoc.v_part[i].p_tag, (ushort)dkl8.dkl_vtoc.v_part[i].p_tag);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_vtoc.v_part[{0}].p_flag = {1} ({2})", i,
dkl8.dkl_vtoc.v_part[i].p_flag, (ushort)dkl8.dkl_vtoc.v_part[i].p_flag);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_vtoc.v_timestamp[{0}] = {1}", i,
DateHandlers.UNIXToDateTime(dkl8.dkl_vtoc.v_timestamp[i]));
}
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_magic = 0x{0:X4}", dkl8.dkl_magic);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_cksum = 0x{0:X4}", dkl8.dkl_cksum);
DicConsole.DebugWriteLine("Sun plugin", "sectorsPerCylinder = {0}", sectorsPerCylinder);
if(dkl8.dkl_vtoc.v_nparts > NDKMAP)
return false;
if(dkl8.dkl_vtoc.v_nparts > NDKMAP) return false;
for(int i = 0; i < dkl8.dkl_vtoc.v_nparts; i++)
{
if(dkl8.dkl_map[i].dkl_nblk > 0 &&
dkl8.dkl_vtoc.v_part[i].p_tag != SunTag.SunEmpty && dkl8.dkl_vtoc.v_part[i].p_tag != SunTag.SunWholeDisk)
if(dkl8.dkl_map[i].dkl_nblk > 0 && dkl8.dkl_vtoc.v_part[i].p_tag != SunTag.SunEmpty &&
dkl8.dkl_vtoc.v_part[i].p_tag != SunTag.SunWholeDisk)
{
CommonTypes.Partition part = new CommonTypes.Partition
{
@@ -268,13 +267,18 @@ namespace DiscImageChef.PartPlugins
Size = (ulong)dkl8.dkl_map[i].dkl_nblk * DK_LABEL_SIZE,
Length = (ulong)((dkl8.dkl_map[i].dkl_nblk * DK_LABEL_SIZE) / imagePlugin.GetSectorSize()),
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.GetSectorSize(),
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.GetSectorSize(),
Type = SunIdToString(dkl8.dkl_vtoc.v_part[i].p_tag),
Scheme = Name
};
if(dkl8.dkl_vtoc.v_timestamp[i] != 0)
part.Description += string.Format("\nPartition timestamped on {0}", DateHandlers.UNIXToDateTime(dkl8.dkl_vtoc.v_timestamp[i]));
part.Description += string.Format("\nPartition timestamped on {0}",
DateHandlers
.UNIXToDateTime(dkl8.dkl_vtoc.v_timestamp[i]));
if(part.Start < imagePlugin.GetSectors() && part.End <= imagePlugin.GetSectors())
partitions.Add(part);
@@ -285,10 +289,12 @@ namespace DiscImageChef.PartPlugins
{
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_vtoc.v_sanity = 0x{0:X8}", dkl16.dkl_vtoc.v_sanity);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_vtoc.v_version = {0}", dkl16.dkl_vtoc.v_version);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_vtoc.v_volume = \"{0}\"", StringHandlers.CToString(dkl16.dkl_vtoc.v_volume));
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_vtoc.v_volume = \"{0}\"",
StringHandlers.CToString(dkl16.dkl_vtoc.v_volume));
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_vtoc.v_sectorsz = {0}", dkl16.dkl_vtoc.v_sectorsz);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_vtoc.v_nparts = {0}", dkl16.dkl_vtoc.v_nparts);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_vtoc.v_asciilabel = \"{0}\"", StringHandlers.CToString(dkl16.dkl_vtoc.v_asciilabel));
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_vtoc.v_asciilabel = \"{0}\"",
StringHandlers.CToString(dkl16.dkl_vtoc.v_asciilabel));
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_pcyl = {0}", dkl16.dkl_pcyl);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_ncyl = {0}", dkl16.dkl_ncyl);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_acyl = {0}", dkl16.dkl_acyl);
@@ -303,44 +309,55 @@ namespace DiscImageChef.PartPlugins
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_read_reinstruct = {0}", dkl16.dkl_read_reinstruct);
for(int i = 0; i < NDKMAP16; i++)
{
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_vtoc.v_part[{0}].p_start = {1}", i, dkl16.dkl_vtoc.v_part[i].p_start);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_vtoc.v_part[{0}].p_size = {1}", i, dkl16.dkl_vtoc.v_part[i].p_size);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_vtoc.v_part[{0}].p_tag = {1} ({2})", i, dkl16.dkl_vtoc.v_part[i].p_tag, (ushort)dkl16.dkl_vtoc.v_part[i].p_tag);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_vtoc.v_part[{0}].p_flag = {1} ({2})", i, dkl16.dkl_vtoc.v_part[i].p_flag, (ushort)dkl16.dkl_vtoc.v_part[i].p_flag);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_vtoc.v_timestamp[{0}] = {1}", i, DateHandlers.UNIXToDateTime(dkl16.dkl_vtoc.v_timestamp[i]));
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_vtoc.v_part[{0}].p_start = {1}", i,
dkl16.dkl_vtoc.v_part[i].p_start);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_vtoc.v_part[{0}].p_size = {1}", i,
dkl16.dkl_vtoc.v_part[i].p_size);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_vtoc.v_part[{0}].p_tag = {1} ({2})", i,
dkl16.dkl_vtoc.v_part[i].p_tag, (ushort)dkl16.dkl_vtoc.v_part[i].p_tag);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_vtoc.v_part[{0}].p_flag = {1} ({2})", i,
dkl16.dkl_vtoc.v_part[i].p_flag, (ushort)dkl16.dkl_vtoc.v_part[i].p_flag);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_vtoc.v_timestamp[{0}] = {1}", i,
DateHandlers.UNIXToDateTime(dkl16.dkl_vtoc.v_timestamp[i]));
}
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_magic = 0x{0:X4}", dkl16.dkl_magic);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_cksum = 0x{0:X4}", dkl16.dkl_cksum);
if(dkl16.dkl_vtoc.v_nparts > NDKMAP16)
return false;
if(dkl16.dkl_vtoc.v_nparts > NDKMAP16) return false;
for(int i = 0; i < dkl16.dkl_vtoc.v_nparts; i++)
{
if(dkl16.dkl_vtoc.v_part[i].p_size > 0 &&
dkl16.dkl_vtoc.v_part[i].p_tag != SunTag.SunEmpty && dkl16.dkl_vtoc.v_part[i].p_tag != SunTag.SunWholeDisk)
if(dkl16.dkl_vtoc.v_part[i].p_size > 0 && dkl16.dkl_vtoc.v_part[i].p_tag != SunTag.SunEmpty &&
dkl16.dkl_vtoc.v_part[i].p_tag != SunTag.SunWholeDisk)
{
CommonTypes.Partition part = new CommonTypes.Partition
{
Description = SunFlagsToString(dkl16.dkl_vtoc.v_part[i].p_flag),
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.GetSectorSize()),
Length =
(ulong)((dkl16.dkl_vtoc.v_part[i].p_size * dkl16.dkl_vtoc.v_sectorsz) /
imagePlugin.GetSectorSize()),
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.GetSectorSize(),
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.GetSectorSize(),
Type = SunIdToString(dkl16.dkl_vtoc.v_part[i].p_tag),
Scheme = Name
};
if(dkl16.dkl_vtoc.v_timestamp[i] != 0)
part.Description += string.Format("\nPartition timestamped on {0}", DateHandlers.UNIXToDateTime(dkl16.dkl_vtoc.v_timestamp[i]));
part.Description += string.Format("\nPartition timestamped on {0}",
DateHandlers
.UNIXToDateTime(dkl16.dkl_vtoc.v_timestamp[i]));
if(part.Start < imagePlugin.GetSectors() && part.End <= imagePlugin.GetSectors())
partitions.Add(part);
}
}
}
return
partitions.Count > 0;
return partitions.Count > 0;
}
static dk_label SwapDiskLabel(dk_label label)
@@ -400,10 +417,8 @@ namespace DiscImageChef.PartPlugins
public static string SunFlagsToString(SunFlags flags)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
if(flags.HasFlag(SunFlags.NoMount))
sb.AppendLine("Unmountable");
if(flags.HasFlag(SunFlags.ReadOnly))
sb.AppendLine("Read-only");
if(flags.HasFlag(SunFlags.NoMount)) sb.AppendLine("Unmountable");
if(flags.HasFlag(SunFlags.ReadOnly)) sb.AppendLine("Read-only");
return sb.ToString();
}
@@ -411,56 +426,31 @@ namespace DiscImageChef.PartPlugins
{
switch(id)
{
case SunTag.Linux:
return "Linux";
case SunTag.LinuxRaid:
return "Linux RAID";
case SunTag.LinuxSwap:
return "Linux swap";
case SunTag.LVM:
return "LVM";
case SunTag.SunBoot:
return "Sun boot";
case SunTag.SunEmpty:
return "Empty";
case SunTag.SunHome:
return "Sun /home";
case SunTag.SunRoot:
return "Sun /";
case SunTag.SunStand:
return "Sun /stand";
case SunTag.SunSwap:
return "Sun swap";
case SunTag.SunUsr:
return "Sun /usr";
case SunTag.SunVar:
return "Sun /var";
case SunTag.SunWholeDisk:
return "Whole disk";
case SunTag.SunAlt:
return "Replacement sectors";
case SunTag.SunCache:
return "Sun cachefs";
case SunTag.SunReserved:
return "Reserved for SMI";
case SunTag.VxVmPublic:
return "Veritas public";
case SunTag.VxVmPrivate:
return "Veritas private";
case SunTag.NetBSD:
return "NetBSD";
case SunTag.FreeBSD_Swap:
return "FreeBSD swap";
case SunTag.FreeBSD_UFS:
return "FreeBSD";
case SunTag.FreeBSD_Vinum:
return "Vinum";
case SunTag.FreeBSD_ZFS:
return "FreeBSD ZFS";
case SunTag.FreeBSD_NANDFS:
return "FreeBSD nandfs";
default:
return "Unknown";
case SunTag.Linux: return "Linux";
case SunTag.LinuxRaid: return "Linux RAID";
case SunTag.LinuxSwap: return "Linux swap";
case SunTag.LVM: return "LVM";
case SunTag.SunBoot: return "Sun boot";
case SunTag.SunEmpty: return "Empty";
case SunTag.SunHome: return "Sun /home";
case SunTag.SunRoot: return "Sun /";
case SunTag.SunStand: return "Sun /stand";
case SunTag.SunSwap: return "Sun swap";
case SunTag.SunUsr: return "Sun /usr";
case SunTag.SunVar: return "Sun /var";
case SunTag.SunWholeDisk: return "Whole disk";
case SunTag.SunAlt: return "Replacement sectors";
case SunTag.SunCache: return "Sun cachefs";
case SunTag.SunReserved: return "Reserved for SMI";
case SunTag.VxVmPublic: return "Veritas public";
case SunTag.VxVmPrivate: return "Veritas private";
case SunTag.NetBSD: return "NetBSD";
case SunTag.FreeBSD_Swap: return "FreeBSD swap";
case SunTag.FreeBSD_UFS: return "FreeBSD";
case SunTag.FreeBSD_Vinum: return "Vinum";
case SunTag.FreeBSD_ZFS: return "FreeBSD ZFS";
case SunTag.FreeBSD_NANDFS: return "FreeBSD nandfs";
default: return "Unknown";
}
}
@@ -479,11 +469,9 @@ namespace DiscImageChef.PartPlugins
struct dk_label
{
/// <summary>Informative string</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_ASCII)]
public byte[] dkl_asciilabel;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_ASCII)] public byte[] dkl_asciilabel;
/// <summary>Padding</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_PAD)]
public byte[] dkl_pad;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_PAD)] public byte[] dkl_pad;
/// <summary>rotations per minute</summary>
public ushort dkl_rpm;
/// <summary># physical cylinders</summary>
@@ -509,8 +497,7 @@ namespace DiscImageChef.PartPlugins
/// <summary>physical partition #</summary>
public ushort dkl_ppart;
/// <summary>Logical partitions</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NDKMAP)]
public dk_map[] dkl_map;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NDKMAP)] public dk_map[] dkl_map;
/// <summary>identifies this label format</summary>
public ushort dkl_magic;
/// <summary>xor checksum of sector</summary>
@@ -547,65 +534,53 @@ namespace DiscImageChef.PartPlugins
/// <summary> layout version</summary>
public uint v_version;
/// <summary> volume name</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_VVOL)]
public byte[] v_volume;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_VVOL)] public byte[] v_volume;
/// <summary> number of partitions </summary>
public ushort v_nparts;
/// <summary> partition hdrs, sec 2</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NDKMAP)]
public dk_map2[] v_part;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NDKMAP)] public dk_map2[] v_part;
/// <summary>Alignment</summary>
public ushort padding;
/// <summary> info needed by mboot</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public uint[] v_bootinfo;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public uint[] v_bootinfo;
/// <summary> to verify vtoc sanity</summary>
public uint v_sanity;
/// <summary> free space</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)]
public uint[] v_reserved;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] public uint[] v_reserved;
/// <summary> partition timestamp</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NDKMAP)]
public int[] v_timestamp;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NDKMAP)] public int[] v_timestamp;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct dk_vtoc16
{
/// <summary>info needed by mboot</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public uint[] v_bootinfo;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public uint[] v_bootinfo;
/// <summary>to verify vtoc sanity</summary>
public uint v_sanity;
/// <summary>layout version</summary>
public uint v_version;
/// <summary>volume name</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_VVOL)]
public byte[] v_volume;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_VVOL)] public byte[] v_volume;
/// <summary>sector size in bytes</summary>
public ushort v_sectorsz;
/// <summary>number of partitions</summary>
public ushort v_nparts;
/// <summary>free space</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)]
public uint[] v_reserved;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] public uint[] v_reserved;
/// <summary>partition headers</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NDKMAP16)]
public dkl_partition[] v_part;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NDKMAP16)] public dkl_partition[] v_part;
/// <summary>partition timestamp</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NDKMAP16)]
public int[] v_timestamp;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NDKMAP16)] public int[] v_timestamp;
/// <summary>for compatibility</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_ASCII)]
public byte[] v_asciilabel;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_ASCII)] public byte[] v_asciilabel;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct dk_label8
{
/// <summary>for compatibility</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_ASCII)]
public byte[] dkl_asciilabel;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_ASCII)] public byte[] dkl_asciilabel;
/// <summary>vtoc inclusions from AT&amp;T SVr4</summary>
public dk_vtoc8 dkl_vtoc;
/// <summary># sectors to skip, writes</summary>
@@ -613,8 +588,7 @@ namespace DiscImageChef.PartPlugins
/// <summary># sectors to skip, reads</summary>
public ushort dkl_read_reinstruct;
/// <summary>unused part of 512 bytes</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_PAD8)]
public byte[] dkl_pad;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_PAD8)] public byte[] dkl_pad;
/// <summary>rotations per minute</summary>
public ushort dkl_rpm;
/// <summary># physical cylinders</summary>
@@ -640,8 +614,7 @@ namespace DiscImageChef.PartPlugins
/// <summary>obsolete</summary>
public ushort dkl_obs4;
/// <summary>logical partition headers</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NDKMAP)]
public dk_map[] dkl_map;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NDKMAP)] public dk_map[] dkl_map;
/// <summary>identifies this label format</summary>
public ushort dkl_magic;
/// <summary>xor checksum of sector</summary>
@@ -678,11 +651,9 @@ namespace DiscImageChef.PartPlugins
/// <summary># sectors to skip, reads </summary>
public ushort dkl_read_reinstruct;
/// <summary>for compatible expansion</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public ushort[] dkl_extra;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public ushort[] dkl_extra;
/// <summary>unused part of 512 bytes</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_PAD16)]
public byte[] dkl_pad;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_PAD16)] public byte[] dkl_pad;
/// <summary>identifies this label format</summary>
public ushort dkl_magic;
/// <summary>xor checksum of sector</summary>

File diff suppressed because it is too large Load Diff

View File

@@ -46,7 +46,7 @@ namespace DiscImageChef.PartPlugins
const uint PD_CIGAM = 0x0D605ECA;
const uint VTOC_ENAS = 0xEEDE0D60;
const int V_NUMPAR = 16;
const uint XPDVERS = 3; /* 1st version of extended pdinfo */
const uint XPDVERS = 3; /* 1st version of extended pdinfo */
public VTOC()
{
@@ -66,12 +66,12 @@ namespace DiscImageChef.PartPlugins
foreach(ulong i in new ulong[] {0, 1, 8, 29})
{
if(i + sectorOffset >= imagePlugin.GetSectors())
break;
if(i + sectorOffset >= imagePlugin.GetSectors()) break;
pdsector = imagePlugin.ReadSector(i + sectorOffset);
magic = BitConverter.ToUInt32(pdsector, 4);
DicConsole.DebugWriteLine("VTOC plugin", "sanity at {0} is 0x{1:X8} (should be 0x{2:X8} or 0x{3:X8})", i + sectorOffset, magic, PD_MAGIC, PD_CIGAM);
DicConsole.DebugWriteLine("VTOC plugin", "sanity at {0} is 0x{1:X8} (should be 0x{2:X8} or 0x{3:X8})",
i + sectorOffset, magic, PD_MAGIC, PD_CIGAM);
if(magic == PD_MAGIC || magic == PD_CIGAM)
{
magic_found = true;
@@ -80,8 +80,7 @@ namespace DiscImageChef.PartPlugins
}
}
if(!magic_found)
return false;
if(!magic_found) return false;
PDInfo pd;
PDInfoOld pdold;
@@ -101,7 +100,8 @@ namespace DiscImageChef.PartPlugins
}
DicConsole.DebugWriteLine("VTOC plugin", "pdinfo.driveid = {0}", pd.driveid);
DicConsole.DebugWriteLine("VTOC plugin", "pdinfo.sanity = 0x{0:X8} (should be 0x{1:X8})", pd.sanity, PD_MAGIC);
DicConsole.DebugWriteLine("VTOC plugin", "pdinfo.sanity = 0x{0:X8} (should be 0x{1:X8})", pd.sanity,
PD_MAGIC);
DicConsole.DebugWriteLine("VTOC plugin", "pdinfo.version = {0}", pd.version);
DicConsole.DebugWriteLine("VTOC plugin", "pdinfo.serial = \"{0}\"", StringHandlers.CToString(pd.serial));
DicConsole.DebugWriteLine("VTOC plugin", "pdinfo.cyls = {0}", pd.cyls);
@@ -208,11 +208,12 @@ namespace DiscImageChef.PartPlugins
{
DicConsole.DebugWriteLine("VTOC plugin", "Searching for VTOC on relative byte {0}", pd.vtoc_ptr);
ulong rel_sec_ptr = pd.vtoc_ptr / imagePlugin.GetSectorSize();
uint rel_sec_off =pd.vtoc_ptr % imagePlugin.GetSectorSize();
uint rel_sec_off = pd.vtoc_ptr % imagePlugin.GetSectorSize();
uint sec_count = (rel_sec_off + pd.vtoc_len) / imagePlugin.GetSectorSize();
if((rel_sec_off + pd.vtoc_len) % imagePlugin.GetSectorSize() > 0)
sec_count++;
DicConsole.DebugWriteLine("VTOC plugin", "Going to read {0} sectors from sector {1}, getting VTOC from byte {2}", sec_count, rel_sec_ptr + sectorOffset, rel_sec_off);
if((rel_sec_off + pd.vtoc_len) % imagePlugin.GetSectorSize() > 0) sec_count++;
DicConsole.DebugWriteLine("VTOC plugin",
"Going to read {0} sectors from sector {1}, getting VTOC from byte {2}",
sec_count, rel_sec_ptr + sectorOffset, rel_sec_off);
if(rel_sec_ptr + sectorOffset + sec_count >= imagePlugin.GetSectors())
{
DicConsole.DebugWriteLine("VTOC plugin", "Going to read past device size, aborting...");
@@ -258,34 +259,47 @@ namespace DiscImageChef.PartPlugins
if(useOld)
{
DicConsole.DebugWriteLine("VTOC plugin", "vtocOld.v_sanity = 0x{0:X8} (should be 0x{1:X8})", vtocOld.v_sanity, VTOC_SANE);
DicConsole.DebugWriteLine("VTOC plugin", "vtocOld.v_sanity = 0x{0:X8} (should be 0x{1:X8})",
vtocOld.v_sanity, VTOC_SANE);
DicConsole.DebugWriteLine("VTOC plugin", "vtocOld.v_version = {0}", vtocOld.v_version);
DicConsole.DebugWriteLine("VTOC plugin", "vtocOld.v_volume = \"{0}\"", StringHandlers.CToString(vtocOld.v_volume));
DicConsole.DebugWriteLine("VTOC plugin", "vtocOld.v_volume = \"{0}\"",
StringHandlers.CToString(vtocOld.v_volume));
DicConsole.DebugWriteLine("VTOC plugin", "vtocOld.v_sectorsz = {0}", vtocOld.v_sectorsz);
DicConsole.DebugWriteLine("VTOC plugin", "vtocOld.v_nparts = {0}", vtocOld.v_nparts);
for(int i = 0; i < V_NUMPAR; i++)
{
DicConsole.DebugWriteLine("VTOC plugin", "vtocOld.v_part[{0}].p_tag = {1} ({2})", i, vtocOld.v_part[i].p_tag, (ushort)vtocOld.v_part[i].p_tag);
DicConsole.DebugWriteLine("VTOC plugin", "vtocOld.v_part[{0}].p_flag = {1} ({2})", i, vtocOld.v_part[i].p_flag, (ushort)vtocOld.v_part[i].p_flag);
DicConsole.DebugWriteLine("VTOC plugin", "vtocOld.v_part[{0}].p_start = {1}", i, vtocOld.v_part[i].p_start);
DicConsole.DebugWriteLine("VTOC plugin", "vtocOld.v_part[{0}].p_size = {1}", i, vtocOld.v_part[i].p_size);
DicConsole.DebugWriteLine("VTOC plugin", "vtocOld.timestamp[{0}] = {1}", i, DateHandlers.UNIXToDateTime(vtocOld.timestamp[i]));
DicConsole.DebugWriteLine("VTOC plugin", "vtocOld.v_part[{0}].p_tag = {1} ({2})", i,
vtocOld.v_part[i].p_tag, (ushort)vtocOld.v_part[i].p_tag);
DicConsole.DebugWriteLine("VTOC plugin", "vtocOld.v_part[{0}].p_flag = {1} ({2})", i,
vtocOld.v_part[i].p_flag, (ushort)vtocOld.v_part[i].p_flag);
DicConsole.DebugWriteLine("VTOC plugin", "vtocOld.v_part[{0}].p_start = {1}", i,
vtocOld.v_part[i].p_start);
DicConsole.DebugWriteLine("VTOC plugin", "vtocOld.v_part[{0}].p_size = {1}", i,
vtocOld.v_part[i].p_size);
DicConsole.DebugWriteLine("VTOC plugin", "vtocOld.timestamp[{0}] = {1}", i,
DateHandlers.UNIXToDateTime(vtocOld.timestamp[i]));
}
}
else
{
DicConsole.DebugWriteLine("VTOC plugin", "vtoc.v_sanity = 0x{0:X8} (should be 0x{1:X8})", vtoc.v_sanity, VTOC_SANE);
DicConsole.DebugWriteLine("VTOC plugin", "vtoc.v_sanity = 0x{0:X8} (should be 0x{1:X8})", vtoc.v_sanity,
VTOC_SANE);
DicConsole.DebugWriteLine("VTOC plugin", "vtoc.v_version = {0}", vtoc.v_version);
DicConsole.DebugWriteLine("VTOC plugin", "vtoc.v_volume = \"{0}\"", StringHandlers.CToString(vtoc.v_volume));
DicConsole.DebugWriteLine("VTOC plugin", "vtoc.v_volume = \"{0}\"",
StringHandlers.CToString(vtoc.v_volume));
DicConsole.DebugWriteLine("VTOC plugin", "vtoc.v_pad = {0}", vtoc.v_pad);
DicConsole.DebugWriteLine("VTOC plugin", "vtoc.v_nparts = {0}", vtoc.v_nparts);
for(int i = 0; i < V_NUMPAR; i++)
{
DicConsole.DebugWriteLine("VTOC plugin", "vtoc.v_part[{0}].p_tag = {1} ({2})", i, vtoc.v_part[i].p_tag, (ushort)vtoc.v_part[i].p_tag);
DicConsole.DebugWriteLine("VTOC plugin", "vtoc.v_part[{0}].p_flag = {1} ({2})", i, vtoc.v_part[i].p_flag, (ushort)vtoc.v_part[i].p_flag);
DicConsole.DebugWriteLine("VTOC plugin", "vtoc.v_part[{0}].p_start = {1}", i, vtoc.v_part[i].p_start);
DicConsole.DebugWriteLine("VTOC plugin", "vtoc.v_part[{0}].p_tag = {1} ({2})", i,
vtoc.v_part[i].p_tag, (ushort)vtoc.v_part[i].p_tag);
DicConsole.DebugWriteLine("VTOC plugin", "vtoc.v_part[{0}].p_flag = {1} ({2})", i,
vtoc.v_part[i].p_flag, (ushort)vtoc.v_part[i].p_flag);
DicConsole.DebugWriteLine("VTOC plugin", "vtoc.v_part[{0}].p_start = {1}", i,
vtoc.v_part[i].p_start);
DicConsole.DebugWriteLine("VTOC plugin", "vtoc.v_part[{0}].p_size = {1}", i, vtoc.v_part[i].p_size);
DicConsole.DebugWriteLine("VTOC plugin", "vtoc.timestamp[{0}] = {1}", i, DateHandlers.UNIXToDateTime(vtoc.timestamp[i]));
DicConsole.DebugWriteLine("VTOC plugin", "vtoc.timestamp[{0}] = {1}", i,
DateHandlers.UNIXToDateTime(vtoc.timestamp[i]));
}
}
@@ -340,23 +354,17 @@ namespace DiscImageChef.PartPlugins
part.Offset += sectorOffset * imagePlugin.GetSectorSize();
}
if(parts[i].p_flag.HasFlag(pFlag.V_VALID))
info += " (valid)";
if(parts[i].p_flag.HasFlag(pFlag.V_UNMNT))
info += " (unmountable)";
if(parts[i].p_flag.HasFlag(pFlag.V_OPEN))
info += " (open)";
if(parts[i].p_flag.HasFlag(pFlag.V_REMAP))
info += " (alternate sector mapping)";
if(parts[i].p_flag.HasFlag(pFlag.V_RONLY))
info += " (read-only)";
if(parts[i].p_flag.HasFlag(pFlag.V_VALID)) info += " (valid)";
if(parts[i].p_flag.HasFlag(pFlag.V_UNMNT)) info += " (unmountable)";
if(parts[i].p_flag.HasFlag(pFlag.V_OPEN)) info += " (open)";
if(parts[i].p_flag.HasFlag(pFlag.V_REMAP)) info += " (alternate sector mapping)";
if(parts[i].p_flag.HasFlag(pFlag.V_RONLY)) info += " (read-only)";
if(timestamps[i] != 0)
info += string.Format(" created on {0}", DateHandlers.UNIXToDateTime(timestamps[i]));
part.Description = "UNIX slice" + info + ".";
if(part.End < imagePlugin.GetSectors())
partitions.Add(part);
if(part.End < imagePlugin.GetSectors()) partitions.Add(part);
}
}
@@ -366,68 +374,65 @@ namespace DiscImageChef.PartPlugins
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct PDInfo
{
public uint driveid; /*identifies the device type*/
public uint sanity; /*verifies device sanity*/
public uint version; /*version number*/
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
public byte[] serial; /*serial number of the device*/
public uint cyls; /*number of cylinders per drive*/
public uint tracks; /*number tracks per cylinder*/
public uint sectors; /*number sectors per track*/
public uint bytes; /*number of bytes per sector*/
public uint logicalst; /*sector address of logical sector 0*/
public uint errlogst; /*sector address of error log area*/
public uint errlogsz; /*size in bytes of error log area*/
public uint mfgst; /*sector address of mfg. defect info*/
public uint mfgsz; /*size in bytes of mfg. defect info*/
public uint defectst; /*sector address of the defect map*/
public uint defectsz; /*size in bytes of defect map*/
public uint relno; /*number of relocation areas*/
public uint relst; /*sector address of relocation area*/
public uint relsz; /*size in sectors of relocation area*/
public uint relnext; /*address of next avail reloc sector*/
/* the previous items are left intact from AT&T's 3b2 pdinfo. Following
are added for the 80386 port */
public uint vtoc_ptr; /*byte offset of vtoc block*/
public ushort vtoc_len; /*byte length of vtoc block*/
public ushort vtoc_pad; /* pad for 16-bit machine alignment */
public uint alt_ptr; /*byte offset of alternates table*/
public ushort alt_len; /*byte length of alternates table*/
/* new in version 3 */
public uint pcyls; /*physical cylinders per drive*/
public uint ptracks; /*physical tracks per cylinder*/
public uint psectors; /*physical sectors per track*/
public uint pbytes; /*physical bytes per sector*/
public uint secovhd; /*sector overhead bytes per sector*/
public ushort interleave; /*interleave factor*/
public ushort skew; /*skew factor*/
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public uint[] pad; /*space for more stuff*/
public uint driveid; /*identifies the device type*/
public uint sanity; /*verifies device sanity*/
public uint version; /*version number*/
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] public byte[] serial; /*serial number of the device*/
public uint cyls; /*number of cylinders per drive*/
public uint tracks; /*number tracks per cylinder*/
public uint sectors; /*number sectors per track*/
public uint bytes; /*number of bytes per sector*/
public uint logicalst; /*sector address of logical sector 0*/
public uint errlogst; /*sector address of error log area*/
public uint errlogsz; /*size in bytes of error log area*/
public uint mfgst; /*sector address of mfg. defect info*/
public uint mfgsz; /*size in bytes of mfg. defect info*/
public uint defectst; /*sector address of the defect map*/
public uint defectsz; /*size in bytes of defect map*/
public uint relno; /*number of relocation areas*/
public uint relst; /*sector address of relocation area*/
public uint relsz; /*size in sectors of relocation area*/
public uint relnext; /*address of next avail reloc sector*/
/* the previous items are left intact from AT&T's 3b2 pdinfo. Following
are added for the 80386 port */
public uint vtoc_ptr; /*byte offset of vtoc block*/
public ushort vtoc_len; /*byte length of vtoc block*/
public ushort vtoc_pad; /* pad for 16-bit machine alignment */
public uint alt_ptr; /*byte offset of alternates table*/
public ushort alt_len; /*byte length of alternates table*/
/* new in version 3 */
public uint pcyls; /*physical cylinders per drive*/
public uint ptracks; /*physical tracks per cylinder*/
public uint psectors; /*physical sectors per track*/
public uint pbytes; /*physical bytes per sector*/
public uint secovhd; /*sector overhead bytes per sector*/
public ushort interleave; /*interleave factor*/
public ushort skew; /*skew factor*/
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public uint[] pad; /*space for more stuff*/
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct PDInfoOld
{
public uint driveid; /*identifies the device type*/
public uint sanity; /*verifies device sanity*/
public uint version; /*version number*/
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
public byte[] serial; /*serial number of the device*/
public uint cyls; /*number of cylinders per drive*/
public uint tracks; /*number tracks per cylinder*/
public uint sectors; /*number sectors per track*/
public uint bytes; /*number of bytes per sector*/
public uint logicalst; /*sector address of logical sector 0*/
public uint errlogst; /*sector address of error log area*/
public uint errlogsz; /*size in bytes of error log area*/
public uint mfgst; /*sector address of mfg. defect info*/
public uint mfgsz; /*size in bytes of mfg. defect info*/
public uint defectst; /*sector address of the defect map*/
public uint defectsz; /*size in bytes of defect map*/
public uint relno; /*number of relocation areas*/
public uint relst; /*sector address of relocation area*/
public uint relsz; /*size in sectors of relocation area*/
public uint relnext; /*address of next avail reloc sector*/
public uint driveid; /*identifies the device type*/
public uint sanity; /*verifies device sanity*/
public uint version; /*version number*/
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] public byte[] serial; /*serial number of the device*/
public uint cyls; /*number of cylinders per drive*/
public uint tracks; /*number tracks per cylinder*/
public uint sectors; /*number sectors per track*/
public uint bytes; /*number of bytes per sector*/
public uint logicalst; /*sector address of logical sector 0*/
public uint errlogst; /*sector address of error log area*/
public uint errlogsz; /*size in bytes of error log area*/
public uint mfgst; /*sector address of mfg. defect info*/
public uint mfgsz; /*size in bytes of mfg. defect info*/
public uint defectst; /*sector address of the defect map*/
public uint defectsz; /*size in bytes of defect map*/
public uint relno; /*number of relocation areas*/
public uint relst; /*sector address of relocation area*/
public uint relsz; /*size in sectors of relocation area*/
public uint relnext; /*address of next avail reloc sector*/
public uint allcstrt; /*start of the allocatable disk*/
public uint allcend; /*end of allocatable disk*/
}
@@ -435,46 +440,37 @@ namespace DiscImageChef.PartPlugins
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct vtocold
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public uint[] v_bootinfo; /*info needed by mboot*/
public uint v_sanity; /*to verify vtoc sanity*/
public uint v_version; /*layout version*/
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public byte[] v_volume; /*volume name*/
public ushort v_sectorsz; /*sector size in bytes*/
public ushort v_nparts; /*number of partitions*/
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)]
public uint[] v_reserved; /*free space*/
[MarshalAs(UnmanagedType.ByValArray, SizeConst = V_NUMPAR)]
public partition[] v_part; /*partition headers*/
[MarshalAs(UnmanagedType.ByValArray, SizeConst = V_NUMPAR)]
public int[] timestamp; /* SCSI time stamp */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public uint[] v_bootinfo; /*info needed by mboot*/
public uint v_sanity; /*to verify vtoc sanity*/
public uint v_version; /*layout version*/
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] v_volume; /*volume name*/
public ushort v_sectorsz; /*sector size in bytes*/
public ushort v_nparts; /*number of partitions*/
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] public uint[] v_reserved; /*free space*/
[MarshalAs(UnmanagedType.ByValArray, SizeConst = V_NUMPAR)] public partition[] v_part; /*partition headers*/
[MarshalAs(UnmanagedType.ByValArray, SizeConst = V_NUMPAR)] public int[] timestamp; /* SCSI time stamp */
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct vtoc
struct vtoc
{
public uint v_sanity; /*to verify vtoc sanity*/
public uint v_version; /*layout version*/
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public byte[] v_volume; /*volume name*/
public ushort v_nparts; /*number of partitions*/
public ushort v_pad; /*pad for 286 compiler*/
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)]
public uint[] v_reserved; /*free space*/
[MarshalAs(UnmanagedType.ByValArray, SizeConst = V_NUMPAR)]
public partition[] v_part; /*partition headers*/
[MarshalAs(UnmanagedType.ByValArray, SizeConst = V_NUMPAR)]
public int[] timestamp; /* SCSI time stamp */
public uint v_sanity; /*to verify vtoc sanity*/
public uint v_version; /*layout version*/
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] v_volume; /*volume name*/
public ushort v_nparts; /*number of partitions*/
public ushort v_pad; /*pad for 286 compiler*/
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] public uint[] v_reserved; /*free space*/
[MarshalAs(UnmanagedType.ByValArray, SizeConst = V_NUMPAR)] public partition[] v_part; /*partition headers*/
[MarshalAs(UnmanagedType.ByValArray, SizeConst = V_NUMPAR)] public int[] timestamp; /* SCSI time stamp */
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct partition
{
public pTag p_tag; /*ID tag of partition*/
public pFlag p_flag; /*permision flags*/
public int p_start; /*start sector no of partition*/
public int p_size; /*# of blocks in partition*/
public pTag p_tag; /*ID tag of partition*/
public pFlag p_flag; /*permision flags*/
public int p_start; /*start sector no of partition*/
public int p_size; /*# of blocks in partition*/
};
public enum pTag : ushort
@@ -529,54 +525,36 @@ struct vtoc
enum pFlag : ushort
{
/* Partition permission flags */
V_UNMNT = 0x01, /* Unmountable partition */
V_RONLY = 0x10, /* Read only */
V_REMAP = 0x20, /* do alternate sector mapping */
V_OPEN = 0x100, /* Partition open (for driver use) */
V_VALID = 0x200, /* Partition is valid to use */
V_VOMASK = 0x300 /* mask for open and valid */
V_UNMNT = 0x01, /* Unmountable partition */
V_RONLY = 0x10, /* Read only */
V_REMAP = 0x20, /* do alternate sector mapping */
V_OPEN = 0x100, /* Partition open (for driver use) */
V_VALID = 0x200, /* Partition is valid to use */
V_VOMASK = 0x300 /* mask for open and valid */
}
public static string decodeUNIXTAG(pTag type, bool isNew)
{
switch(type)
{
case pTag.V_UNUSED:
return "Unused";
case pTag.V_BOOT:
return "Boot";
case pTag.V_ROOT:
return "/";
case pTag.V_SWAP:
return "Swap";
case pTag.V_USER:
return "/usr";
case pTag.V_BACKUP:
return "Whole disk";
case pTag.V_STAND_OLD:
return isNew ? "Stand" : "Alternate sector space";
case pTag.V_VAR_OLD:
return isNew ? "/var" : "non UNIX";
case pTag.V_HOME_OLD:
return isNew ? "/home" : "Alternate track space";
case pTag.V_ALTSCTR_OLD:
return isNew ? "Alternate sector track" : "Stand";
case pTag.V_CACHE:
return isNew ? "Cache" : "/var";
case pTag.V_RESERVED:
return isNew ? "Reserved" : "/home";
case pTag.V_DUMP:
return "dump";
case pTag.V_ALTSCTR:
return "Alternate sector track";
case pTag.V_VMPUBLIC:
return "volume mgt public partition";
case pTag.V_VMPRIVATE:
return "volume mgt private partition";
default:
return string.Format("Unknown TAG: 0x{0:X4}", type);
case pTag.V_UNUSED: return "Unused";
case pTag.V_BOOT: return "Boot";
case pTag.V_ROOT: return "/";
case pTag.V_SWAP: return "Swap";
case pTag.V_USER: return "/usr";
case pTag.V_BACKUP: return "Whole disk";
case pTag.V_STAND_OLD: return isNew ? "Stand" : "Alternate sector space";
case pTag.V_VAR_OLD: return isNew ? "/var" : "non UNIX";
case pTag.V_HOME_OLD: return isNew ? "/home" : "Alternate track space";
case pTag.V_ALTSCTR_OLD: return isNew ? "Alternate sector track" : "Stand";
case pTag.V_CACHE: return isNew ? "Cache" : "/var";
case pTag.V_RESERVED: return isNew ? "Reserved" : "/home";
case pTag.V_DUMP: return "dump";
case pTag.V_ALTSCTR: return "Alternate sector track";
case pTag.V_VMPUBLIC: return "volume mgt public partition";
case pTag.V_VMPRIVATE: return "volume mgt private partition";
default: return string.Format("Unknown TAG: 0x{0:X4}", type);
}
}
}
}

View File

@@ -58,8 +58,7 @@ namespace DiscImageChef.PartPlugins
{
partitions = new List<Partition>();
if(42 + sectorOffset >= imagePlugin.GetSectors())
return false;
if(42 + sectorOffset >= imagePlugin.GetSectors()) return false;
byte[] tblsector = imagePlugin.ReadSector(42 + sectorOffset);
@@ -67,30 +66,33 @@ namespace DiscImageChef.PartPlugins
partable xnxtbl = (partable)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(partable));
handle.Free();
DicConsole.DebugWriteLine("XENIX plugin", "xnxtbl.p_magic = 0x{0:X4} (should be 0x{1:X4})", xnxtbl.p_magic, PAMAGIC);
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;
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)
if(xnxtbl.p[i].p_size > 0)
{
Partition part = new Partition
{
Start = ((ulong)((xnxtbl.p[i].p_off + XENIX_OFFSET) * XENIX_BSIZE) / imagePlugin.GetSectorSize()) + sectorOffset,
Start =
((ulong)((xnxtbl.p[i].p_off + XENIX_OFFSET) * XENIX_BSIZE) / imagePlugin.GetSectorSize()) +
sectorOffset,
Length = (ulong)(xnxtbl.p[i].p_size * XENIX_BSIZE) / imagePlugin.GetSectorSize(),
Offset = (ulong)((xnxtbl.p[i].p_off + XENIX_OFFSET) * XENIX_BSIZE) + (imagePlugin.GetSectorSize() * sectorOffset),
Offset =
(ulong)((xnxtbl.p[i].p_off + XENIX_OFFSET) * XENIX_BSIZE) +
(imagePlugin.GetSectorSize() * sectorOffset),
Size = (ulong)(xnxtbl.p[i].p_size * XENIX_BSIZE),
Sequence = (ulong)i,
Type = "XENIX",
Scheme = Name
};
if(part.End < imagePlugin.GetSectors())
partitions.Add(part);
if(part.End < imagePlugin.GetSectors()) partitions.Add(part);
}
}
@@ -100,16 +102,15 @@ namespace DiscImageChef.PartPlugins
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct partable
{
public ushort p_magic; /* magic number validity indicator */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MAXPARTS)]
public partition[] p; /*partition headers*/
public ushort p_magic; /* magic number validity indicator */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MAXPARTS)] public partition[] p; /*partition headers*/
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct partition
{
public int p_off; /*start 1K block no of partition*/
public int p_size; /*# of 1K blocks in partition*/
public int p_off; /*start 1K block no of partition*/
public int p_size; /*# of 1K blocks in partition*/
}
}
}

View File

@@ -82,16 +82,16 @@ namespace DiscImageChef.PartPlugins
partitions = new List<Partition>();
// Xbox partitions always start on 0
if(sectorOffset != 0)
return false;
if(sectorOffset != 0) return false;
byte[] sector = imagePlugin.ReadSector(0);
if(sector.Length < 512)
return false;
if(sector.Length < 512) return false;
Xbox360DevKitPartitionTable table = BigEndianMarshal.ByteArrayToStructureBigEndian<Xbox360DevKitPartitionTable>(sector);
Xbox360DevKitPartitionTable table =
BigEndianMarshal.ByteArrayToStructureBigEndian<Xbox360DevKitPartitionTable>(sector);
if(table.magic == Xbox360DevKitMagic && table.contentOff + table.contentLen <= imagePlugin.ImageInfo.sectors &&
if(table.magic == Xbox360DevKitMagic &&
table.contentOff + table.contentLen <= imagePlugin.ImageInfo.sectors &&
table.dashboardOff + table.dashboardLen <= imagePlugin.ImageInfo.sectors)
{
Partition contentPart = new Partition
@@ -145,7 +145,8 @@ namespace DiscImageChef.PartPlugins
Partition dataPart = new Partition
{
Description = "Data volume",
Size = (ulong)imagePlugin.ImageInfo.sectors * imagePlugin.ImageInfo.sectorSize - MemoryUnitDataOff,
Size =
(ulong)imagePlugin.ImageInfo.sectors * imagePlugin.ImageInfo.sectorSize - MemoryUnitDataOff,
Length = imagePlugin.ImageInfo.sectors - sysCachePart.Length,
Sequence = 2,
Offset = MemoryUnitDataOff,