mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
REFACTOR: All refactor in DiscImageChef.Partitions.
This commit is contained in:
@@ -72,10 +72,9 @@ namespace DiscImageChef.Partitions
|
||||
|
||||
if(sector.Length < 512) return false;
|
||||
|
||||
AcornBootBlock bootBlock;
|
||||
IntPtr bbPtr = Marshal.AllocHGlobal(512);
|
||||
Marshal.Copy(sector, 0, bbPtr, 512);
|
||||
bootBlock = (AcornBootBlock)Marshal.PtrToStructure(bbPtr, typeof(AcornBootBlock));
|
||||
AcornBootBlock bootBlock = (AcornBootBlock)Marshal.PtrToStructure(bbPtr, typeof(AcornBootBlock));
|
||||
Marshal.FreeHGlobal(bbPtr);
|
||||
|
||||
int checksum = 0;
|
||||
@@ -112,10 +111,9 @@ namespace DiscImageChef.Partitions
|
||||
switch(bootBlock.flags & TYPE_MASK) {
|
||||
case TYPE_LINUX:
|
||||
{
|
||||
LinuxTable table;
|
||||
IntPtr tablePtr = Marshal.AllocHGlobal(512);
|
||||
Marshal.Copy(map, 0, tablePtr, 512);
|
||||
table = (LinuxTable)Marshal.PtrToStructure(tablePtr, typeof(LinuxTable));
|
||||
LinuxTable table = (LinuxTable)Marshal.PtrToStructure(tablePtr, typeof(LinuxTable));
|
||||
Marshal.FreeHGlobal(tablePtr);
|
||||
|
||||
foreach(LinuxEntry entry in table.entries)
|
||||
@@ -140,10 +138,9 @@ namespace DiscImageChef.Partitions
|
||||
case TYPE_RISCIX_MFM:
|
||||
case TYPE_RISCIX_SCSI:
|
||||
{
|
||||
RiscIxTable table;
|
||||
IntPtr tablePtr = Marshal.AllocHGlobal(512);
|
||||
Marshal.Copy(map, 0, tablePtr, 512);
|
||||
table = (RiscIxTable)Marshal.PtrToStructure(tablePtr, typeof(RiscIxTable));
|
||||
RiscIxTable table = (RiscIxTable)Marshal.PtrToStructure(tablePtr, typeof(RiscIxTable));
|
||||
Marshal.FreeHGlobal(tablePtr);
|
||||
|
||||
if(table.magic == RISCIX_MAGIC)
|
||||
@@ -169,7 +166,7 @@ namespace DiscImageChef.Partitions
|
||||
}
|
||||
}
|
||||
|
||||
return !(partitions.Count == 0);
|
||||
return partitions.Count != 0;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
|
||||
@@ -62,30 +62,29 @@ namespace DiscImageChef.Partitions
|
||||
public override bool GetInformation(ImagePlugin imagePlugin,
|
||||
out List<Partition> partitions, ulong sectorOffset)
|
||||
{
|
||||
uint sector_size;
|
||||
uint sectorSize;
|
||||
|
||||
if(imagePlugin.GetSectorSize() == 2352 || imagePlugin.GetSectorSize() == 2448) sector_size = 2048;
|
||||
else sector_size = imagePlugin.GetSectorSize();
|
||||
if(imagePlugin.GetSectorSize() == 2352 || imagePlugin.GetSectorSize() == 2448) sectorSize = 2048;
|
||||
else sectorSize = imagePlugin.GetSectorSize();
|
||||
|
||||
partitions = new List<Partition>();
|
||||
|
||||
if(sectorOffset + 2 >= imagePlugin.GetSectors()) return false;
|
||||
|
||||
byte[] ddm_sector = imagePlugin.ReadSector(sectorOffset);
|
||||
AppleDriverDescriptorMap ddm;
|
||||
byte[] ddmSector = imagePlugin.ReadSector(sectorOffset);
|
||||
|
||||
ushort max_drivers = 61;
|
||||
ushort maxDrivers = 61;
|
||||
|
||||
if(sector_size == 256)
|
||||
if(sectorSize == 256)
|
||||
{
|
||||
byte[] tmp = new byte[512];
|
||||
Array.Copy(ddm_sector, 0, tmp, 0, 256);
|
||||
ddm_sector = tmp;
|
||||
max_drivers = 29;
|
||||
Array.Copy(ddmSector, 0, tmp, 0, 256);
|
||||
ddmSector = tmp;
|
||||
maxDrivers = 29;
|
||||
}
|
||||
else if(sector_size < 256) return false;
|
||||
else if(sectorSize < 256) return false;
|
||||
|
||||
ddm = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDriverDescriptorMap>(ddm_sector);
|
||||
AppleDriverDescriptorMap ddm = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleDriverDescriptorMap>(ddmSector);
|
||||
|
||||
DicConsole.DebugWriteLine("AppleMap Plugin", "ddm.sbSig = 0x{0:X4}", ddm.sbSig);
|
||||
DicConsole.DebugWriteLine("AppleMap Plugin", "ddm.sbBlockSize = {0}", ddm.sbBlockSize);
|
||||
@@ -98,13 +97,13 @@ namespace DiscImageChef.Partitions
|
||||
uint sequence = 0;
|
||||
|
||||
if(ddm.sbSig == DDM_MAGIC)
|
||||
if(ddm.sbDrvrCount < max_drivers)
|
||||
if(ddm.sbDrvrCount < maxDrivers)
|
||||
{
|
||||
ddm.sbMap = new AppleDriverEntry[ddm.sbDrvrCount];
|
||||
for(int i = 0; i < ddm.sbDrvrCount; i++)
|
||||
{
|
||||
byte[] tmp = new byte[8];
|
||||
Array.Copy(ddm_sector, 18 + i * 8, tmp, 0, 8);
|
||||
Array.Copy(ddmSector, 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);
|
||||
@@ -118,14 +117,14 @@ namespace DiscImageChef.Partitions
|
||||
Partition part = new Partition
|
||||
{
|
||||
Size = (ulong)(ddm.sbMap[i].ddSize * 512),
|
||||
Length = (ulong)(ddm.sbMap[i].ddSize * 512 / sector_size),
|
||||
Length = (ulong)(ddm.sbMap[i].ddSize * 512 / sectorSize),
|
||||
Sequence = sequence,
|
||||
Offset = ddm.sbMap[i].ddBlock * sector_size,
|
||||
Offset = ddm.sbMap[i].ddBlock * sectorSize,
|
||||
Start = ddm.sbMap[i].ddBlock + sectorOffset,
|
||||
Type = "Apple_Driver"
|
||||
};
|
||||
|
||||
if(ddm.sbMap[i].ddSize * 512 % sector_size > 0) part.Length++;
|
||||
if(ddm.sbMap[i].ddSize * 512 % sectorSize > 0) part.Length++;
|
||||
|
||||
partitions.Add(part);
|
||||
|
||||
@@ -133,45 +132,44 @@ namespace DiscImageChef.Partitions
|
||||
}
|
||||
}
|
||||
|
||||
byte[] part_sector = imagePlugin.ReadSector(1 + sectorOffset);
|
||||
AppleOldDevicePartitionMap old_map =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleOldDevicePartitionMap>(part_sector);
|
||||
byte[] partSector = imagePlugin.ReadSector(1 + sectorOffset);
|
||||
AppleOldDevicePartitionMap oldMap =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleOldDevicePartitionMap>(partSector);
|
||||
|
||||
// This is the easy one, no sector size mixing
|
||||
if(old_map.pdSig == APM_MAGIC_OLD)
|
||||
if(oldMap.pdSig == APM_MAGIC_OLD)
|
||||
{
|
||||
for(int i = 2; i < part_sector.Length; i += 12)
|
||||
for(int i = 2; i < partSector.Length; i += 12)
|
||||
{
|
||||
byte[] tmp = new byte[12];
|
||||
Array.Copy(part_sector, i, tmp, 0, 12);
|
||||
AppleMapOldPartitionEntry old_entry =
|
||||
Array.Copy(partSector, i, tmp, 0, 12);
|
||||
AppleMapOldPartitionEntry oldEntry =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<AppleMapOldPartitionEntry>(tmp);
|
||||
DicConsole.DebugWriteLine("AppleMap Plugin", "old_map.sbMap[{1}].pdStart = {0}", old_entry.pdStart,
|
||||
DicConsole.DebugWriteLine("AppleMap Plugin", "old_map.sbMap[{1}].pdStart = {0}", oldEntry.pdStart,
|
||||
(i - 2) / 12);
|
||||
DicConsole.DebugWriteLine("AppleMap Plugin", "old_map.sbMap[{1}].pdSize = {0}", old_entry.pdSize,
|
||||
DicConsole.DebugWriteLine("AppleMap Plugin", "old_map.sbMap[{1}].pdSize = {0}", oldEntry.pdSize,
|
||||
(i - 2) / 12);
|
||||
DicConsole.DebugWriteLine("AppleMap Plugin", "old_map.sbMap[{1}].pdFSID = 0x{0:X8}",
|
||||
old_entry.pdFSID, (i - 2) / 12);
|
||||
oldEntry.pdFSID, (i - 2) / 12);
|
||||
|
||||
if(old_entry.pdSize == 0 && old_entry.pdFSID == 0)
|
||||
if(oldEntry.pdSize == 0 && oldEntry.pdFSID == 0)
|
||||
{
|
||||
if(old_entry.pdStart == 0) break;
|
||||
if(oldEntry.pdStart == 0) break;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
Partition part = new Partition
|
||||
{
|
||||
Size = old_entry.pdStart * ddm.sbBlockSize,
|
||||
Length = old_entry.pdStart * ddm.sbBlockSize / sector_size,
|
||||
Size = oldEntry.pdStart * ddm.sbBlockSize,
|
||||
Length = oldEntry.pdStart * ddm.sbBlockSize / sectorSize,
|
||||
Sequence = sequence,
|
||||
Offset = old_entry.pdSize * ddm.sbBlockSize,
|
||||
Start = old_entry.pdSize * ddm.sbBlockSize / sector_size,
|
||||
Scheme = Name
|
||||
Offset = oldEntry.pdSize * ddm.sbBlockSize,
|
||||
Start = oldEntry.pdSize * ddm.sbBlockSize / sectorSize,
|
||||
Scheme = Name,
|
||||
Type = oldEntry.pdFSID == HFS_MAGIC_OLD ? "Apple_HFS" : $"0x{oldEntry.pdFSID:X8}"
|
||||
};
|
||||
|
||||
if(old_entry.pdFSID == HFS_MAGIC_OLD) part.Type = "Apple_HFS";
|
||||
else part.Type = $"0x{old_entry.pdFSID:X8}";
|
||||
|
||||
partitions.Add(part);
|
||||
|
||||
@@ -182,68 +180,68 @@ namespace DiscImageChef.Partitions
|
||||
}
|
||||
|
||||
AppleMapPartitionEntry entry;
|
||||
uint entry_size;
|
||||
uint entry_count;
|
||||
uint sectors_to_read;
|
||||
uint skip_ddm;
|
||||
uint entrySize;
|
||||
uint entryCount;
|
||||
uint sectorsToRead;
|
||||
uint skipDdm;
|
||||
|
||||
// If sector is bigger than 512
|
||||
if(sector_size > 512)
|
||||
if(sectorSize > 512)
|
||||
{
|
||||
byte[] tmp = new byte[512];
|
||||
Array.Copy(ddm_sector, 512, tmp, 0, 512);
|
||||
Array.Copy(ddmSector, 512, tmp, 0, 512);
|
||||
entry = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleMapPartitionEntry>(tmp);
|
||||
// Check for a partition entry that's 512-byte aligned
|
||||
if(entry.signature == APM_MAGIC)
|
||||
{
|
||||
DicConsole.DebugWriteLine("AppleMap Plugin", "Found misaligned entry.");
|
||||
entry_size = 512;
|
||||
entry_count = entry.entries;
|
||||
skip_ddm = 512;
|
||||
sectors_to_read = (entry_count + 1) * 512 / sector_size + 1;
|
||||
entrySize = 512;
|
||||
entryCount = entry.entries;
|
||||
skipDdm = 512;
|
||||
sectorsToRead = (entryCount + 1) * 512 / sectorSize + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
entry = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleMapPartitionEntry>(part_sector);
|
||||
entry = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleMapPartitionEntry>(partSector);
|
||||
if(entry.signature == APM_MAGIC)
|
||||
{
|
||||
DicConsole.DebugWriteLine("AppleMap Plugin", "Found aligned entry.");
|
||||
entry_size = sector_size;
|
||||
entry_count = entry.entries;
|
||||
skip_ddm = sector_size;
|
||||
sectors_to_read = entry_count + 2;
|
||||
entrySize = sectorSize;
|
||||
entryCount = entry.entries;
|
||||
skipDdm = sectorSize;
|
||||
sectorsToRead = entryCount + 2;
|
||||
}
|
||||
else return partitions.Count > 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
entry = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleMapPartitionEntry>(part_sector);
|
||||
entry = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleMapPartitionEntry>(partSector);
|
||||
if(entry.signature == APM_MAGIC)
|
||||
{
|
||||
DicConsole.DebugWriteLine("AppleMap Plugin", "Found aligned entry.");
|
||||
entry_size = sector_size;
|
||||
entry_count = entry.entries;
|
||||
skip_ddm = sector_size;
|
||||
sectors_to_read = entry_count + 2;
|
||||
entrySize = sectorSize;
|
||||
entryCount = entry.entries;
|
||||
skipDdm = sectorSize;
|
||||
sectorsToRead = entryCount + 2;
|
||||
}
|
||||
else return partitions.Count > 0;
|
||||
}
|
||||
|
||||
byte[] entries = imagePlugin.ReadSectors(sectorOffset, sectors_to_read);
|
||||
DicConsole.DebugWriteLine("AppleMap Plugin", "entry_size = {0}", entry_size);
|
||||
DicConsole.DebugWriteLine("AppleMap Plugin", "entry_count = {0}", entry_count);
|
||||
DicConsole.DebugWriteLine("AppleMap Plugin", "skip_ddm = {0}", skip_ddm);
|
||||
DicConsole.DebugWriteLine("AppleMap Plugin", "sectors_to_read = {0}", sectors_to_read);
|
||||
byte[] entries = imagePlugin.ReadSectors(sectorOffset, sectorsToRead);
|
||||
DicConsole.DebugWriteLine("AppleMap Plugin", "entry_size = {0}", entrySize);
|
||||
DicConsole.DebugWriteLine("AppleMap Plugin", "entry_count = {0}", entryCount);
|
||||
DicConsole.DebugWriteLine("AppleMap Plugin", "skip_ddm = {0}", skipDdm);
|
||||
DicConsole.DebugWriteLine("AppleMap Plugin", "sectors_to_read = {0}", sectorsToRead);
|
||||
|
||||
byte[] copy = new byte[entries.Length - skip_ddm];
|
||||
Array.Copy(entries, skip_ddm, copy, 0, copy.Length);
|
||||
byte[] copy = new byte[entries.Length - skipDdm];
|
||||
Array.Copy(entries, skipDdm, copy, 0, copy.Length);
|
||||
entries = copy;
|
||||
|
||||
for(int i = 0; i < entry_count; i++)
|
||||
for(int i = 0; i < entryCount; i++)
|
||||
{
|
||||
byte[] tmp = new byte[entry_size];
|
||||
Array.Copy(entries, i * entry_size, tmp, 0, entry_size);
|
||||
byte[] tmp = new byte[entrySize];
|
||||
Array.Copy(entries, i * entrySize, tmp, 0, entrySize);
|
||||
entry = BigEndianMarshal.ByteArrayToStructureBigEndian<AppleMapPartitionEntry>(tmp);
|
||||
if(entry.signature != APM_MAGIC) continue;
|
||||
|
||||
@@ -289,10 +287,10 @@ namespace DiscImageChef.Partitions
|
||||
Sequence = sequence,
|
||||
Type = StringHandlers.CToString(entry.type),
|
||||
Name = StringHandlers.CToString(entry.name),
|
||||
Offset = entry.start * entry_size,
|
||||
Size = entry.sectors * entry_size,
|
||||
Start = entry.start * entry_size / sector_size + sectorOffset,
|
||||
Length = entry.sectors * entry_size / sector_size,
|
||||
Offset = entry.start * entrySize,
|
||||
Size = entry.sectors * entrySize,
|
||||
Start = entry.start * entrySize / sectorSize + sectorOffset,
|
||||
Length = entry.sectors * entrySize / sectorSize,
|
||||
Scheme = Name
|
||||
};
|
||||
sb.AppendLine("Partition flags:");
|
||||
@@ -306,7 +304,7 @@ namespace DiscImageChef.Partitions
|
||||
if(flags.HasFlag(AppleMapFlags.Bootable))
|
||||
{
|
||||
sb.AppendFormat("First boot sector: {0}",
|
||||
entry.first_boot_block * entry_size / sector_size).AppendLine();
|
||||
entry.first_boot_block * entrySize / sectorSize).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();
|
||||
|
||||
@@ -73,10 +73,9 @@ namespace DiscImageChef.Partitions
|
||||
|
||||
if(sector.Length < 512) return false;
|
||||
|
||||
ApricotLabel label;
|
||||
IntPtr lblPtr = Marshal.AllocHGlobal(512);
|
||||
IntPtr lblPtr = Marshal.AllocHGlobal(512);
|
||||
Marshal.Copy(sector, 0, lblPtr, 512);
|
||||
label = (ApricotLabel)Marshal.PtrToStructure(lblPtr, typeof(ApricotLabel));
|
||||
ApricotLabel label = (ApricotLabel)Marshal.PtrToStructure(lblPtr, typeof(ApricotLabel));
|
||||
Marshal.FreeHGlobal(lblPtr);
|
||||
|
||||
// Not much to check but...
|
||||
|
||||
@@ -72,11 +72,13 @@ namespace DiscImageChef.Partitions
|
||||
|
||||
byte[] sector = imagePlugin.ReadSector(sectorOffset);
|
||||
|
||||
AtariTable table = new AtariTable();
|
||||
table.boot = new byte[342];
|
||||
table.icdEntries = new AtariEntry[8];
|
||||
table.unused = new byte[12];
|
||||
table.entries = new AtariEntry[4];
|
||||
AtariTable table = new AtariTable
|
||||
{
|
||||
boot = new byte[342],
|
||||
icdEntries = new AtariEntry[8],
|
||||
unused = new byte[12],
|
||||
entries = new AtariEntry[4]
|
||||
};
|
||||
|
||||
Array.Copy(sector, 0, table.boot, 0, 342);
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace DiscImageChef.Partitions
|
||||
/// <summary>Known byte offsets for BSD disklabel</summary>
|
||||
readonly uint[] labelOffsets = {0, 9, 64, 128, 516};
|
||||
/// <summary>Maximum size of a disklabel with 22 partitions</summary>
|
||||
const uint maxLabelSize = 500;
|
||||
const uint MAX_LABEL_SIZE = 500;
|
||||
|
||||
public BSD()
|
||||
{
|
||||
@@ -60,10 +60,9 @@ namespace DiscImageChef.Partitions
|
||||
public override bool GetInformation(ImagePlugin imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
{
|
||||
partitions = new List<Partition>();
|
||||
uint run = (maxLabelSize + labelOffsets.Last()) / imagePlugin.GetSectorSize();
|
||||
if((maxLabelSize + labelOffsets.Last()) % imagePlugin.GetSectorSize() > 0) run++;
|
||||
uint run = (MAX_LABEL_SIZE + labelOffsets.Last()) / imagePlugin.GetSectorSize();
|
||||
if((MAX_LABEL_SIZE + labelOffsets.Last()) % imagePlugin.GetSectorSize() > 0) run++;
|
||||
|
||||
byte[] sector;
|
||||
DiskLabel dl = new DiskLabel();
|
||||
bool found = false;
|
||||
|
||||
@@ -74,8 +73,8 @@ namespace DiscImageChef.Partitions
|
||||
byte[] tmp = imagePlugin.ReadSectors(location + sectorOffset, run);
|
||||
foreach(uint offset in labelOffsets)
|
||||
{
|
||||
sector = new byte[maxLabelSize];
|
||||
Array.Copy(tmp, offset, sector, 0, maxLabelSize);
|
||||
byte[] sector = new byte[MAX_LABEL_SIZE];
|
||||
Array.Copy(tmp, offset, sector, 0, MAX_LABEL_SIZE);
|
||||
dl = GetDiskLabel(sector);
|
||||
DicConsole.DebugWriteLine("BSD plugin",
|
||||
"dl.magic on sector {0} at offset {1} = 0x{2:X8} (expected 0x{3:X8})",
|
||||
|
||||
@@ -59,10 +59,9 @@ namespace DiscImageChef.Partitions
|
||||
byte[] sector = imagePlugin.ReadSector(31 + sectorOffset);
|
||||
if(sector.Length < 512) return false;
|
||||
|
||||
DECLabel table;
|
||||
IntPtr tablePtr = Marshal.AllocHGlobal(512);
|
||||
Marshal.Copy(sector, 0, tablePtr, 512);
|
||||
table = (DECLabel)Marshal.PtrToStructure(tablePtr, typeof(DECLabel));
|
||||
DECLabel table = (DECLabel)Marshal.PtrToStructure(tablePtr, typeof(DECLabel));
|
||||
Marshal.FreeHGlobal(tablePtr);
|
||||
|
||||
if(table.pt_magic != PT_MAGIC || table.pt_valid != PT_VALID) return false;
|
||||
|
||||
@@ -59,10 +59,9 @@ namespace DiscImageChef.Partitions
|
||||
byte[] sectors = imagePlugin.ReadSectors(sectorOffset, nSectors);
|
||||
if(sectors.Length < 2048) return false;
|
||||
|
||||
Disklabel64 disklabel;
|
||||
IntPtr labelPtr = Marshal.AllocHGlobal(2048);
|
||||
Marshal.Copy(sectors, 0, labelPtr, 2048);
|
||||
disklabel = (Disklabel64)Marshal.PtrToStructure(labelPtr, typeof(Disklabel64));
|
||||
Disklabel64 disklabel = (Disklabel64)Marshal.PtrToStructure(labelPtr, typeof(Disklabel64));
|
||||
Marshal.FreeHGlobal(labelPtr);
|
||||
|
||||
if(disklabel.d_magic != 0xC4464C59) return false;
|
||||
@@ -79,13 +78,14 @@ namespace DiscImageChef.Partitions
|
||||
Length = entry.p_bsize / imagePlugin.GetSectorSize(),
|
||||
Name = entry.p_stor_uuid.ToString(),
|
||||
Sequence = counter,
|
||||
Scheme = Name
|
||||
Scheme = Name,
|
||||
Type = (BSD.fsType) entry.p_fstype == BSD.fsType.Other
|
||||
? entry.p_type_uuid.ToString()
|
||||
: BSD.fsTypeToString((BSD.fsType) entry.p_fstype)
|
||||
};
|
||||
|
||||
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(entry.p_bsize <= 0 || entry.p_boffset <= 0) continue;
|
||||
|
||||
partitions.Add(part);
|
||||
|
||||
@@ -42,8 +42,8 @@ namespace DiscImageChef.Partitions
|
||||
{
|
||||
public class GuidPartitionTable : PartitionPlugin
|
||||
{
|
||||
const ulong GptMagic = 0x5452415020494645;
|
||||
const uint GptRevision1 = 0x00010000;
|
||||
const ulong GPT_MAGIC = 0x5452415020494645;
|
||||
const uint GPT_REVISION1 = 0x00010000;
|
||||
|
||||
public GuidPartitionTable()
|
||||
{
|
||||
@@ -66,13 +66,13 @@ namespace DiscImageChef.Partitions
|
||||
|
||||
DicConsole.DebugWriteLine("GPT Plugin", "hdr.signature = 0x{0:X16}", signature);
|
||||
|
||||
if(signature != GptMagic)
|
||||
if(signature != GPT_MAGIC)
|
||||
if(imagePlugin.ImageInfo.XmlMediaType == XmlMediaType.OpticalDisc)
|
||||
{
|
||||
hdrBytes = imagePlugin.ReadSector(sectorOffset);
|
||||
signature = BitConverter.ToUInt64(hdrBytes, 512);
|
||||
DicConsole.DebugWriteLine("GPT Plugin", "hdr.signature @ 0x200 = 0x{0:X16}", signature);
|
||||
if(signature == GptMagic)
|
||||
if(signature == GPT_MAGIC)
|
||||
{
|
||||
DicConsole.DebugWriteLine("GPT Plugin", "Found unaligned signature", signature);
|
||||
byte[] real = new byte[512];
|
||||
@@ -106,7 +106,7 @@ namespace DiscImageChef.Partitions
|
||||
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 != GPT_MAGIC) return false;
|
||||
|
||||
if(hdr.myLBA != 1 + sectorOffset) return false;
|
||||
|
||||
@@ -145,7 +145,8 @@ namespace DiscImageChef.Partitions
|
||||
entries.Add(entry);
|
||||
}
|
||||
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
|
||||
catch { }
|
||||
catch { // ignored
|
||||
}
|
||||
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
|
||||
}
|
||||
|
||||
@@ -183,7 +184,7 @@ namespace DiscImageChef.Partitions
|
||||
return true;
|
||||
}
|
||||
|
||||
public string GetGuidTypeName(Guid type)
|
||||
static string GetGuidTypeName(Guid type)
|
||||
{
|
||||
string strType = type.ToString().ToUpperInvariant();
|
||||
switch(strType)
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace DiscImageChef.Partitions
|
||||
{
|
||||
public class Human68K : PartitionPlugin
|
||||
{
|
||||
const uint X68kMagic = 0x5836384B;
|
||||
const uint X68K_MAGIC = 0x5836384B;
|
||||
|
||||
public Human68K()
|
||||
{
|
||||
@@ -82,7 +82,7 @@ namespace DiscImageChef.Partitions
|
||||
|
||||
DicConsole.DebugWriteLine("Human68k plugin", "table.magic = {0:X4}", table.magic);
|
||||
|
||||
if(table.magic != X68kMagic) return false;
|
||||
if(table.magic != X68K_MAGIC) return false;
|
||||
|
||||
for(int i = 0; i < table.entries.Length; i++)
|
||||
table.entries[i] = BigEndianMarshal.SwapStructureMembersEndian(table.entries[i]);
|
||||
|
||||
@@ -50,9 +50,9 @@ namespace DiscImageChef.Partitions
|
||||
// "dlV2"
|
||||
const uint NEXT_MAGIC3 = 0x646C5633;
|
||||
// "dlV3"
|
||||
const ushort disktabStart = 0xB4;
|
||||
const ushort DISKTAB_START = 0xB4;
|
||||
// 180
|
||||
const ushort disktabEntrySize = 0x2C;
|
||||
const ushort DISKTAB_ENTRY_SIZE = 0x2C;
|
||||
|
||||
// 44
|
||||
public NeXTDisklabel()
|
||||
@@ -61,45 +61,44 @@ namespace DiscImageChef.Partitions
|
||||
PluginUuid = new Guid("246A6D93-4F1A-1F8A-344D-50187A5513A9");
|
||||
}
|
||||
|
||||
public override bool GetInformation(ImagePlugin imagePlugin,
|
||||
out List<Partition> partitions, ulong sectorOffset)
|
||||
public override bool GetInformation(ImagePlugin imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
{
|
||||
bool magic_found = false;
|
||||
byte[] label_sector;
|
||||
bool magicFound = false;
|
||||
byte[] labelSector;
|
||||
|
||||
uint magic;
|
||||
uint sector_size;
|
||||
uint sectorSize;
|
||||
|
||||
if(imagePlugin.GetSectorSize() == 2352 || imagePlugin.GetSectorSize() == 2448) sector_size = 2048;
|
||||
else sector_size = imagePlugin.GetSectorSize();
|
||||
if(imagePlugin.GetSectorSize() == 2352 || imagePlugin.GetSectorSize() == 2448) sectorSize = 2048;
|
||||
else sectorSize = imagePlugin.GetSectorSize();
|
||||
|
||||
partitions = new List<Partition>();
|
||||
|
||||
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
||||
|
||||
ulong label_position = 0;
|
||||
ulong labelPosition = 0;
|
||||
|
||||
foreach(ulong i in new ulong[] {0, 4, 15, 16}.TakeWhile(i => i + sectorOffset < imagePlugin.GetSectors())) {
|
||||
label_sector = imagePlugin.ReadSector(i + sectorOffset);
|
||||
magic = BigEndianBitConverter.ToUInt32(label_sector, 0x00);
|
||||
foreach(ulong i in new ulong[] {0, 4, 15, 16}.TakeWhile(i => i + sectorOffset < imagePlugin.GetSectors()))
|
||||
{
|
||||
labelSector = imagePlugin.ReadSector(i + sectorOffset);
|
||||
uint magic = BigEndianBitConverter.ToUInt32(labelSector, 0x00);
|
||||
if(magic != NEXT_MAGIC1 && magic != NEXT_MAGIC2 && magic != NEXT_MAGIC3) continue;
|
||||
|
||||
magic_found = true;
|
||||
label_position = i + sectorOffset;
|
||||
magicFound = true;
|
||||
labelPosition = i + sectorOffset;
|
||||
break;
|
||||
}
|
||||
|
||||
if(!magic_found) return false;
|
||||
if(!magicFound) return false;
|
||||
|
||||
uint sectors_to_read = 7680 / imagePlugin.ImageInfo.SectorSize;
|
||||
if(7680 % imagePlugin.ImageInfo.SectorSize > 0) sectors_to_read++;
|
||||
uint sectorsToRead = 7680 / imagePlugin.ImageInfo.SectorSize;
|
||||
if(7680 % imagePlugin.ImageInfo.SectorSize > 0) sectorsToRead++;
|
||||
|
||||
label_sector = imagePlugin.ReadSectors(label_position, sectors_to_read);
|
||||
labelSector = imagePlugin.ReadSectors(labelPosition, sectorsToRead);
|
||||
|
||||
NeXTLabel label = BigEndianMarshal.ByteArrayToStructureBigEndian<NeXTLabel>(label_sector);
|
||||
byte[] disktab_b = new byte[498];
|
||||
Array.Copy(label_sector, 44, disktab_b, 0, 498);
|
||||
label.dl_dt = BigEndianMarshal.ByteArrayToStructureBigEndian<NeXTDiskTab>(disktab_b);
|
||||
NeXTLabel label = BigEndianMarshal.ByteArrayToStructureBigEndian<NeXTLabel>(labelSector);
|
||||
byte[] disktabB = new byte[498];
|
||||
Array.Copy(labelSector, 44, disktabB, 0, 498);
|
||||
label.dl_dt = BigEndianMarshal.ByteArrayToStructureBigEndian<NeXTDiskTab>(disktabB);
|
||||
label.dl_dt.d_partitions = new NeXTEntry[8];
|
||||
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_version = 0x{0:X8}", label.dl_version);
|
||||
@@ -137,9 +136,9 @@ namespace DiscImageChef.Partitions
|
||||
|
||||
for(int i = 0; i < 8; i++)
|
||||
{
|
||||
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);
|
||||
byte[] partB = new byte[44];
|
||||
Array.Copy(labelSector, 44 + 146 + 44 * i, partB, 0, 44);
|
||||
label.dl_dt.d_partitions[i] = BigEndianMarshal.ByteArrayToStructureBigEndian<NeXTEntry>(partB);
|
||||
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,
|
||||
@@ -178,9 +177,9 @@ namespace DiscImageChef.Partitions
|
||||
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),
|
||||
Length = (ulong)(label.dl_dt.d_partitions[i].p_size * label.dl_dt.d_secsize / sectorSize),
|
||||
Start = (ulong)((label.dl_dt.d_partitions[i].p_base + label.dl_dt.d_front) * label.dl_dt.d_secsize /
|
||||
sectorSize),
|
||||
Scheme = Name
|
||||
};
|
||||
|
||||
@@ -188,7 +187,7 @@ namespace DiscImageChef.Partitions
|
||||
{
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "Partition bigger than device, reducing...");
|
||||
part.Length = imagePlugin.ImageInfo.Sectors - part.Start;
|
||||
part.Size = part.Length * sector_size;
|
||||
part.Size = part.Length * sectorSize;
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_size = {1}", i,
|
||||
part.Length);
|
||||
}
|
||||
@@ -202,8 +201,7 @@ namespace DiscImageChef.Partitions
|
||||
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();
|
||||
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_newfs != 1) sb.AppendLine("Filesystem should be formatted at start");
|
||||
if(label.dl_dt.d_partitions[i].p_automnt == 1)
|
||||
sb.AppendLine("Filesystem should be automatically mounted");
|
||||
|
||||
@@ -216,7 +214,7 @@ namespace DiscImageChef.Partitions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// NeXT v3 disklabel, 544 bytes
|
||||
/// NeXT v3 disklabel, 544 bytes
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
struct NeXTLabel
|
||||
@@ -240,7 +238,7 @@ namespace DiscImageChef.Partitions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// NeXT v1 and v2 disklabel, 7224 bytes
|
||||
/// NeXT v1 and v2 disklabel, 7224 bytes
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
struct NeXTLabelOld
|
||||
@@ -266,7 +264,7 @@ namespace DiscImageChef.Partitions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// NeXT disktab and partitions, 498 bytes
|
||||
/// NeXT disktab and partitions, 498 bytes
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
struct NeXTDiskTab
|
||||
@@ -312,7 +310,7 @@ namespace DiscImageChef.Partitions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Partition entries, 44 bytes each
|
||||
/// Partition entries, 44 bytes each
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 2)]
|
||||
struct NeXTEntry
|
||||
|
||||
@@ -43,12 +43,10 @@ namespace DiscImageChef.Partitions
|
||||
{
|
||||
public class PC98 : PartitionPlugin
|
||||
{
|
||||
const ushort IntelMagic = 0xAA55;
|
||||
|
||||
public PC98()
|
||||
{
|
||||
Name = "NEC PC-9800 partition table";
|
||||
PluginUuid = new Guid("27333401-C7C2-447D-961C-22AD0641A09A\n");
|
||||
PluginUuid = new Guid("27333401-C7C2-447D-961C-22AD0641A09A");
|
||||
}
|
||||
|
||||
public override bool GetInformation(ImagePlugin imagePlugin, out List<Partition> partitions, ulong sectorOffset)
|
||||
@@ -61,10 +59,9 @@ namespace DiscImageChef.Partitions
|
||||
byte[] sector = imagePlugin.ReadSector(1);
|
||||
if(bootSector[bootSector.Length - 2] != 0x55 || bootSector[bootSector.Length - 1] != 0xAA) return false;
|
||||
|
||||
PC98Table table;
|
||||
IntPtr tablePtr = Marshal.AllocHGlobal(256);
|
||||
Marshal.Copy(sector, 0, tablePtr, 256);
|
||||
table = (PC98Table)Marshal.PtrToStructure(tablePtr, typeof(PC98Table));
|
||||
PC98Table table = (PC98Table)Marshal.PtrToStructure(tablePtr, typeof(PC98Table));
|
||||
Marshal.FreeHGlobal(tablePtr);
|
||||
|
||||
ulong counter = 0;
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace DiscImageChef.Partitions
|
||||
foreach(string[] tokens in really.TakeWhile(part => part.Length >= 5 && part.Substring(0, 5) == "part ").Select(part => part.Split(' ')).TakeWhile(tokens => tokens.Length == 4)) {
|
||||
if(!ulong.TryParse(tokens[2], out ulong start) || !ulong.TryParse(tokens[3], out ulong end)) break;
|
||||
|
||||
Partition _part = new Partition
|
||||
Partition part = new Partition
|
||||
{
|
||||
Length = end - start + 1,
|
||||
Offset = (start + sectorOffset) * imagePlugin.GetSectorSize(),
|
||||
@@ -76,7 +76,7 @@ namespace DiscImageChef.Partitions
|
||||
Type = tokens[1]
|
||||
};
|
||||
|
||||
partitions.Add(_part);
|
||||
partitions.Add(part);
|
||||
}
|
||||
|
||||
return partitions.Count > 0;
|
||||
|
||||
@@ -103,11 +103,11 @@ namespace DiscImageChef.Partitions
|
||||
/// <summary>
|
||||
/// Type ID for Amiga UNIX System V filesystem
|
||||
/// </summary>
|
||||
const uint TypeID_AMIXSysV = 0x554E4901;
|
||||
const uint TYPEID_AMIX_SYSV = 0x554E4901;
|
||||
/// <summary>
|
||||
/// Type ID for Amiga UNIX BSD filesystem
|
||||
/// </summary>
|
||||
const uint TYPEID_AMIXFFS = 0x554E4902;
|
||||
const uint TYPEID_AMIX_FFS = 0x554E4902;
|
||||
/// <summary>
|
||||
/// Type ID for Amiga UNIX Reserved partition (swap)
|
||||
/// </summary>
|
||||
@@ -928,12 +928,9 @@ namespace DiscImageChef.Partitions
|
||||
|
||||
rdbBlock += sectorOffset;
|
||||
|
||||
byte[] sector;
|
||||
byte[] tmpString;
|
||||
|
||||
RigidDiskBlock rdb = new RigidDiskBlock();
|
||||
|
||||
sector = imagePlugin.ReadSector(rdbBlock);
|
||||
byte[] sector = imagePlugin.ReadSector(rdbBlock);
|
||||
|
||||
rdb.Magic = BigEndianBitConverter.ToUInt32(sector, 0x00);
|
||||
rdb.Size = BigEndianBitConverter.ToUInt32(sector, 0x04);
|
||||
@@ -976,7 +973,7 @@ namespace DiscImageChef.Partitions
|
||||
rdb.HighCylinder = BigEndianBitConverter.ToUInt32(sector, 0x98);
|
||||
rdb.Reserved15 = BigEndianBitConverter.ToUInt32(sector, 0x9C);
|
||||
|
||||
tmpString = new byte[8];
|
||||
byte[] tmpString = new byte[8];
|
||||
Array.Copy(sector, 0xA0, tmpString, 0, 8);
|
||||
rdb.DiskVendor = StringHandlers.SpacePaddedToString(tmpString);
|
||||
tmpString = new byte[16];
|
||||
@@ -1340,12 +1337,14 @@ namespace DiscImageChef.Partitions
|
||||
DicConsole.DebugWriteLine("Amiga RDB plugin", "Found LoadSegment block");
|
||||
|
||||
thereAreLoadSegments = true;
|
||||
LoadSegment loadSeg = new LoadSegment();
|
||||
loadSeg.Magic = BigEndianBitConverter.ToUInt32(sector, 0x00);
|
||||
loadSeg.Size = BigEndianBitConverter.ToUInt32(sector, 0x04);
|
||||
loadSeg.Checksum = BigEndianBitConverter.ToInt32(sector, 0x08);
|
||||
loadSeg.TargetId = BigEndianBitConverter.ToUInt32(sector, 0x0C);
|
||||
loadSeg.NextPtr = BigEndianBitConverter.ToUInt32(sector, 0x10);
|
||||
LoadSegment loadSeg = new LoadSegment
|
||||
{
|
||||
Magic = BigEndianBitConverter.ToUInt32(sector, 0x00),
|
||||
Size = BigEndianBitConverter.ToUInt32(sector, 0x04),
|
||||
Checksum = BigEndianBitConverter.ToInt32(sector, 0x08),
|
||||
TargetId = BigEndianBitConverter.ToUInt32(sector, 0x0C),
|
||||
NextPtr = BigEndianBitConverter.ToUInt32(sector, 0x10)
|
||||
};
|
||||
loadSeg.LoadData = new byte[(loadSeg.Size - 5) * 4];
|
||||
Array.Copy(sector, 0x14, loadSeg.LoadData, 0, (loadSeg.Size - 5) * 4);
|
||||
|
||||
@@ -1410,9 +1409,9 @@ namespace DiscImageChef.Partitions
|
||||
case TYPEID_FFS_CACHE: return "Amiga Fast File System with directory cache";
|
||||
case TYPEID_OFS2: return "Amiga Original File System with long filenames";
|
||||
case TYPEID_FFS2: return "Amiga Fast File System with long filenames";
|
||||
case TypeID_AMIXSysV: return "Amiga UNIX System V filesystem";
|
||||
case TYPEID_AMIX_SYSV: return "Amiga UNIX System V filesystem";
|
||||
case TYPEID_AMIX_BOOT: return "Amiga UNIX boot filesystem";
|
||||
case TYPEID_AMIXFFS: return "Amiga UNIX BSD filesystem";
|
||||
case TYPEID_AMIX_FFS: return "Amiga UNIX BSD filesystem";
|
||||
case TYPEID_AMIX_RESERVED: return "Amiga UNIX Reserved partition (swap)";
|
||||
case TYPEID_PFS:
|
||||
case TYPEID_PFS2:
|
||||
@@ -1455,7 +1454,7 @@ namespace DiscImageChef.Partitions
|
||||
if((amigaDosType & TYPEID_OFS) == TYPEID_OFS)
|
||||
return $"Unknown Amiga DOS filesystem type {AmigaDosTypeToString(amigaDosType)}";
|
||||
|
||||
if((amigaDosType & TypeID_AMIXSysV) == TypeID_AMIXSysV)
|
||||
if((amigaDosType & TYPEID_AMIX_SYSV) == TYPEID_AMIX_SYSV)
|
||||
return $"Unknown Amiga UNIX filesystem type {AmigaDosTypeToString(amigaDosType)}";
|
||||
|
||||
if((amigaDosType & 0x50465300) == 0x50465300 || (amigaDosType & 0x41465300) == 0x41465300)
|
||||
@@ -1488,21 +1487,15 @@ namespace DiscImageChef.Partitions
|
||||
}
|
||||
}
|
||||
|
||||
static string AmigaDosTypeToString(uint amigaDosType)
|
||||
{
|
||||
return AmigaDosTypeToString(amigaDosType, true);
|
||||
}
|
||||
|
||||
static string AmigaDosTypeToString(uint amigaDosType, bool quoted)
|
||||
static string AmigaDosTypeToString(uint amigaDosType, bool quoted = true)
|
||||
{
|
||||
byte[] textPart = new byte[3];
|
||||
string textPartString;
|
||||
|
||||
textPart[0] = (byte)((amigaDosType & 0xFF000000) >> 24);
|
||||
textPart[1] = (byte)((amigaDosType & 0x00FF0000) >> 16);
|
||||
textPart[2] = (byte)((amigaDosType & 0x0000FF00) >> 8);
|
||||
|
||||
textPartString = Encoding.ASCII.GetString(textPart);
|
||||
string textPartString = Encoding.ASCII.GetString(textPart);
|
||||
|
||||
return quoted
|
||||
? $"\"{textPartString}\\{amigaDosType & 0xFF}\""
|
||||
|
||||
@@ -57,10 +57,9 @@ namespace DiscImageChef.Partitions
|
||||
byte[] sector = imagePlugin.ReadSector(sectorOffset);
|
||||
if(sector.Length < 512) return false;
|
||||
|
||||
RioKarmaTable table;
|
||||
IntPtr tablePtr = Marshal.AllocHGlobal(512);
|
||||
Marshal.Copy(sector, 0, tablePtr, 512);
|
||||
table = (RioKarmaTable)Marshal.PtrToStructure(tablePtr, typeof(RioKarmaTable));
|
||||
RioKarmaTable table = (RioKarmaTable)Marshal.PtrToStructure(tablePtr, typeof(RioKarmaTable));
|
||||
Marshal.FreeHGlobal(tablePtr);
|
||||
|
||||
if(table.magic != KARMA_MAGIC) return false;
|
||||
|
||||
@@ -32,13 +32,17 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.Console;
|
||||
using DiscImageChef.DiscImages;
|
||||
#pragma warning disable 169
|
||||
#pragma warning disable 649
|
||||
|
||||
namespace DiscImageChef.Partitions
|
||||
{
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class SGI : PartitionPlugin
|
||||
{
|
||||
const int SGI_MAGIC = 0x0BE5A941;
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using DiscImageChef.CommonTypes;
|
||||
@@ -40,6 +41,7 @@ using DiscImageChef.DiscImages;
|
||||
|
||||
namespace DiscImageChef.Partitions
|
||||
{
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class SunDisklabel : PartitionPlugin
|
||||
{
|
||||
/// <summary>Sun disklabel magic number</summary>
|
||||
@@ -68,7 +70,7 @@ namespace DiscImageChef.Partitions
|
||||
const int LEN_DKL_PAD16 = DK_LABEL_SIZE - (456 + // sizeof(dk_vtoc16)
|
||||
4 * 4 + 12 * 2 + 2 * 2);
|
||||
|
||||
public enum SunTag : ushort
|
||||
enum SunTag : ushort
|
||||
{
|
||||
SunEmpty = 0x0000,
|
||||
SunBoot = 0x0001,
|
||||
@@ -97,7 +99,7 @@ namespace DiscImageChef.Partitions
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum SunFlags : ushort
|
||||
enum SunFlags : ushort
|
||||
{
|
||||
NoMount = 0x0001,
|
||||
ReadOnly = 0x0010
|
||||
@@ -405,7 +407,7 @@ namespace DiscImageChef.Partitions
|
||||
return lebal;
|
||||
}
|
||||
|
||||
public static string SunFlagsToString(SunFlags flags)
|
||||
static string SunFlagsToString(SunFlags flags)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if(flags.HasFlag(SunFlags.NoMount)) sb.AppendLine("Unmountable");
|
||||
@@ -413,7 +415,7 @@ namespace DiscImageChef.Partitions
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static string SunIdToString(SunTag id)
|
||||
static string SunIdToString(SunTag id)
|
||||
{
|
||||
switch(id)
|
||||
{
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace DiscImageChef.Partitions
|
||||
uint magic = 0;
|
||||
ulong pdloc = 0;
|
||||
byte[] pdsector = null;
|
||||
bool magic_found = false;
|
||||
bool magicFound = false;
|
||||
bool absolute = false;
|
||||
|
||||
foreach(ulong i in new ulong[] {0, 1, 8, 29}.TakeWhile(i => i + sectorOffset < imagePlugin.GetSectors())) {
|
||||
@@ -72,12 +72,12 @@ namespace DiscImageChef.Partitions
|
||||
i + sectorOffset, magic, PD_MAGIC, PD_CIGAM);
|
||||
if(magic != PD_MAGIC && magic != PD_CIGAM) continue;
|
||||
|
||||
magic_found = true;
|
||||
magicFound = true;
|
||||
pdloc = i;
|
||||
break;
|
||||
}
|
||||
|
||||
if(!magic_found) return false;
|
||||
if(!magicFound) return false;
|
||||
|
||||
PDInfo pd;
|
||||
PDInfoOld pdold;
|
||||
@@ -139,7 +139,7 @@ namespace DiscImageChef.Partitions
|
||||
DicConsole.DebugWriteLine("VTOC plugin", "pdinfo.pad[6] = {0}", pd.pad[6]);
|
||||
DicConsole.DebugWriteLine("VTOC plugin", "pdinfo.pad[7] = {0}", pd.pad[7]);
|
||||
|
||||
magic_found = false;
|
||||
magicFound = false;
|
||||
bool useOld = false;
|
||||
byte[] vtocsector = imagePlugin.ReadSector(pdloc + sectorOffset + 1);
|
||||
vtoc vtoc = new vtoc();
|
||||
@@ -148,7 +148,7 @@ namespace DiscImageChef.Partitions
|
||||
|
||||
if(magic == VTOC_SANE || magic == VTOC_ENAS)
|
||||
{
|
||||
magic_found = true;
|
||||
magicFound = true;
|
||||
DicConsole.DebugWriteLine("VTOC plugin", "New VTOC found at {0}", pdloc + sectorOffset + 1);
|
||||
if(magic == VTOC_SANE)
|
||||
{
|
||||
@@ -170,13 +170,13 @@ namespace DiscImageChef.Partitions
|
||||
}
|
||||
}
|
||||
|
||||
if(!magic_found && pd.version < XPDVERS)
|
||||
if(!magicFound && pd.version < XPDVERS)
|
||||
{
|
||||
magic = BitConverter.ToUInt32(vtocsector, 12);
|
||||
|
||||
if(magic == VTOC_SANE || magic == VTOC_ENAS)
|
||||
{
|
||||
magic_found = true;
|
||||
magicFound = true;
|
||||
useOld = true;
|
||||
DicConsole.DebugWriteLine("VTOC plugin", "Old VTOC found at {0}", pdloc + sectorOffset + 1);
|
||||
if(magic == VTOC_SANE)
|
||||
@@ -200,30 +200,30 @@ namespace DiscImageChef.Partitions
|
||||
}
|
||||
}
|
||||
|
||||
if(!magic_found)
|
||||
if(!magicFound)
|
||||
{
|
||||
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 sec_count = (rel_sec_off + pd.vtoc_len) / imagePlugin.GetSectorSize();
|
||||
if((rel_sec_off + pd.vtoc_len) % imagePlugin.GetSectorSize() > 0) sec_count++;
|
||||
ulong relSecPtr = pd.vtoc_ptr / imagePlugin.GetSectorSize();
|
||||
uint relSecOff = pd.vtoc_ptr % imagePlugin.GetSectorSize();
|
||||
uint secCount = (relSecOff + pd.vtoc_len) / imagePlugin.GetSectorSize();
|
||||
if((relSecOff + pd.vtoc_len) % imagePlugin.GetSectorSize() > 0) secCount++;
|
||||
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())
|
||||
secCount, relSecPtr + sectorOffset, relSecOff);
|
||||
if(relSecPtr + sectorOffset + secCount >= imagePlugin.GetSectors())
|
||||
{
|
||||
DicConsole.DebugWriteLine("VTOC plugin", "Going to read past device size, aborting...");
|
||||
return false;
|
||||
}
|
||||
|
||||
byte[] tmp = imagePlugin.ReadSectors(rel_sec_ptr + sectorOffset, sec_count);
|
||||
byte[] tmp = imagePlugin.ReadSectors(relSecPtr + sectorOffset, secCount);
|
||||
vtocsector = new byte[pd.vtoc_len];
|
||||
Array.Copy(tmp, rel_sec_off, vtocsector, 0, pd.vtoc_len);
|
||||
Array.Copy(tmp, relSecOff, vtocsector, 0, pd.vtoc_len);
|
||||
magic = BitConverter.ToUInt32(vtocsector, 0);
|
||||
|
||||
if(magic == VTOC_SANE || magic == VTOC_ENAS)
|
||||
{
|
||||
magic_found = true;
|
||||
magicFound = true;
|
||||
DicConsole.DebugWriteLine("VTOC plugin", "New VTOC found.");
|
||||
if(magic == VTOC_SANE)
|
||||
{
|
||||
@@ -246,7 +246,7 @@ namespace DiscImageChef.Partitions
|
||||
}
|
||||
}
|
||||
|
||||
if(!magic_found)
|
||||
if(!magicFound)
|
||||
{
|
||||
DicConsole.DebugWriteLine("VTOC plugin", "Cannot find VTOC.");
|
||||
return false;
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace DiscImageChef.Partitions
|
||||
public uint dashboardLen;
|
||||
}
|
||||
|
||||
const uint Xbox360DevKitMagic = 0x00020000;
|
||||
const uint XBOX360_DEVKIT_MAGIC = 0x00020000;
|
||||
|
||||
public Xbox()
|
||||
{
|
||||
@@ -90,7 +90,7 @@ namespace DiscImageChef.Partitions
|
||||
Xbox360DevKitPartitionTable table =
|
||||
BigEndianMarshal.ByteArrayToStructureBigEndian<Xbox360DevKitPartitionTable>(sector);
|
||||
|
||||
if(table.magic == Xbox360DevKitMagic &&
|
||||
if(table.magic == XBOX360_DEVKIT_MAGIC &&
|
||||
table.contentOff + table.contentLen <= imagePlugin.ImageInfo.Sectors &&
|
||||
table.dashboardOff + table.dashboardLen <= imagePlugin.ImageInfo.Sectors)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user