[SGI VH] Use new source generator based big endian marshaller

This commit is contained in:
2025-10-21 11:21:38 +01:00
parent 432c1663fb
commit d2cffa661d
3 changed files with 185 additions and 194 deletions

View File

@@ -34,6 +34,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using Aaru.CommonTypes.Attributes;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Interfaces;
using Aaru.Helpers;
@@ -48,7 +49,7 @@ namespace Aaru.Partitions;
/// <inheritdoc />
/// <summary>Implements decoding of the SGI Disk Volume Header</summary>
[SuppressMessage("ReSharper", "InconsistentNaming")]
public sealed class SGI : IPartition
public sealed partial class SGI : IPartition
{
const int SGI_MAGIC = 0x0BE5A941;
const string MODULE_NAME = "SGI Volume Header plugin";
@@ -73,18 +74,15 @@ public sealed class SGI : IPartition
if(errno != ErrorNumber.NoError || sector.Length < 512) return false;
Label dvh = Marshal.ByteArrayToStructureBigEndian<Label>(sector);
Label dvh = Marshal.ByteArrayToStructureBigEndianGenerated<Label>(sector);
for(int i = 0; i < dvh.volume.Length; i++)
for(var i = 0; i < dvh.volume.Length; i++)
dvh.volume[i] = (Volume)Marshal.SwapStructureMembersEndian(dvh.volume[i]);
for(int i = 0; i < dvh.partitions.Length; i++)
for(var i = 0; i < dvh.partitions.Length; i++)
dvh.partitions[i] = (Partition)Marshal.SwapStructureMembersEndian(dvh.partitions[i]);
AaruLogging.Debug(MODULE_NAME,
Localization.dvh_magic_equals_0_X8_should_be_1_X8,
dvh.magic,
SGI_MAGIC);
AaruLogging.Debug(MODULE_NAME, Localization.dvh_magic_equals_0_X8_should_be_1_X8, dvh.magic, SGI_MAGIC);
if(dvh.magic != SGI_MAGIC) return false;
@@ -97,9 +95,7 @@ public sealed class SGI : IPartition
AaruLogging.Debug(MODULE_NAME, "dvh.device_params.dp_gap1 = {0}", dvh.device_params.dp_gap1);
AaruLogging.Debug(MODULE_NAME, "dvh.device_params.dp_gap2 = {0}", dvh.device_params.dp_gap2);
AaruLogging.Debug(MODULE_NAME,
"dvh.device_params.dp_spares_cyl = {0}",
dvh.device_params.dp_spares_cyl);
AaruLogging.Debug(MODULE_NAME, "dvh.device_params.dp_spares_cyl = {0}", dvh.device_params.dp_spares_cyl);
AaruLogging.Debug(MODULE_NAME, "dvh.device_params.dp_cyls = {0}", dvh.device_params.dp_cyls);
AaruLogging.Debug(MODULE_NAME, "dvh.device_params.dp_shd0 = {0}", dvh.device_params.dp_shd0);
@@ -113,9 +109,7 @@ public sealed class SGI : IPartition
AaruLogging.Debug(MODULE_NAME, "dvh.device_params.dp_secbytes = {0}", dvh.device_params.dp_secbytes);
AaruLogging.Debug(MODULE_NAME,
"dvh.device_params.dp_interleave = {0}",
dvh.device_params.dp_interleave);
AaruLogging.Debug(MODULE_NAME, "dvh.device_params.dp_interleave = {0}", dvh.device_params.dp_interleave);
AaruLogging.Debug(MODULE_NAME, "dvh.device_params.dp_flags = {0}", dvh.device_params.dp_flags);
@@ -135,17 +129,11 @@ public sealed class SGI : IPartition
ulong counter = 0;
for(int i = 0; i < dvh.partitions.Length; i++)
for(var i = 0; i < dvh.partitions.Length; i++)
{
AaruLogging.Debug(MODULE_NAME,
"dvh.partitions[{0}].num_blocks = {1}",
i,
dvh.partitions[i].num_blocks);
AaruLogging.Debug(MODULE_NAME, "dvh.partitions[{0}].num_blocks = {1}", i, dvh.partitions[i].num_blocks);
AaruLogging.Debug(MODULE_NAME,
"dvh.partitions[{0}].first_block = {1}",
i,
dvh.partitions[i].first_block);
AaruLogging.Debug(MODULE_NAME, "dvh.partitions[{0}].first_block = {1}", i, dvh.partitions[i].first_block);
AaruLogging.Debug(MODULE_NAME, "dvh.partitions[{0}].type = {1}", i, dvh.partitions[i].type);
@@ -195,7 +183,9 @@ public sealed class SGI : IPartition
#region Nested type: DeviceParameters
struct DeviceParameters
[StructLayout(LayoutKind.Sequential, Pack = 1)]
[SwapEndian]
partial struct DeviceParameters
{
public byte dp_skew;
public byte dp_gap1;
@@ -227,20 +217,21 @@ public sealed class SGI : IPartition
#region Nested type: Label
[StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct Label
[SwapEndian]
partial struct Label
{
public readonly uint magic;
public readonly short root_part_num;
public readonly short swap_part_num;
public uint magic;
public short root_part_num;
public short swap_part_num;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public readonly byte[] boot_file;
public readonly DeviceParameters device_params;
public byte[] boot_file;
public DeviceParameters device_params;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 15)]
public readonly Volume[] volume;
public Volume[] volume;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public readonly Partition[] partitions;
public readonly uint csum;
public readonly uint padding;
public Partition[] partitions;
public uint csum;
public uint padding;
}
#endregion
@@ -248,11 +239,12 @@ public sealed class SGI : IPartition
#region Nested type: Partition
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct Partition
[SwapEndian]
partial struct Partition
{
public readonly uint num_blocks;
public readonly uint first_block;
public readonly SGIType type;
public uint num_blocks;
public uint first_block;
public SGIType type;
}
#endregion
@@ -285,12 +277,13 @@ public sealed class SGI : IPartition
#region Nested type: Volume
[StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct Volume
[SwapEndian]
partial struct Volume
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public readonly byte[] name;
public readonly uint block_num;
public readonly uint num_bytes;
public byte[] name;
public uint block_num;
public uint num_bytes;
}
#endregion

View File

@@ -36,6 +36,7 @@ using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.InteropServices;
using Aaru.CommonTypes;
using Aaru.CommonTypes.Attributes;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Interfaces;
using Aaru.Helpers;
@@ -47,7 +48,7 @@ namespace Aaru.Partitions;
/// <inheritdoc />
/// <summary>Implements decoding of UNIX VTOC partitions</summary>
[SuppressMessage("ReSharper", "UnusedMember.Local")]
public sealed class VTOC : IPartition
public sealed partial class VTOC : IPartition
{
const uint PD_MAGIC = 0xCA5E600D;
const uint VTOC_SANE = 0x600DDEEE;
@@ -76,8 +77,8 @@ public sealed class VTOC : IPartition
uint magic = 0;
ulong pdloc = 0;
byte[] pdsector = null;
bool magicFound = false;
bool absolute = false;
var magicFound = false;
var absolute = false;
ErrorNumber errno;
foreach(ulong i in new ulong[]
@@ -92,11 +93,11 @@ public sealed class VTOC : IPartition
magic = BitConverter.ToUInt32(pdsector, 4);
AaruLogging.Debug(MODULE_NAME,
Localization.sanity_at_0_is_1_X8_should_be_2_X8_or_3_X8,
i + sectorOffset,
magic,
PD_MAGIC,
PD_CIGAM);
Localization.sanity_at_0_is_1_X8_should_be_2_X8_or_3_X8,
i + sectorOffset,
magic,
PD_MAGIC,
PD_CIGAM);
if(magic != PD_MAGIC && magic != PD_CIGAM) continue;
@@ -118,8 +119,8 @@ public sealed class VTOC : IPartition
}
else
{
pd = Marshal.ByteArrayToStructureBigEndian<PDInfo>(pdsector);
pdold = Marshal.ByteArrayToStructureBigEndian<PDInfoOld>(pdsector);
pd = Marshal.ByteArrayToStructureBigEndianGenerated<PDInfo>(pdsector);
pdold = Marshal.ByteArrayToStructureBigEndianGenerated<PDInfoOld>(pdsector);
}
AaruLogging.Debug(MODULE_NAME, "pdinfo.driveid = {0}", pd.driveid);
@@ -167,7 +168,7 @@ public sealed class VTOC : IPartition
AaruLogging.Debug(MODULE_NAME, "pdinfo.pad[7] = {0}", pd.pad[7]);
magicFound = false;
bool useOld = false;
var useOld = false;
errno = imagePlugin.ReadSector(pdloc + sectorOffset + 1, out byte[] vtocsector);
if(errno != ErrorNumber.NoError) return false;
@@ -185,9 +186,9 @@ public sealed class VTOC : IPartition
vtoc = Marshal.ByteArrayToStructureLittleEndian<Vtoc>(vtocsector);
else
{
vtoc = Marshal.ByteArrayToStructureBigEndian<Vtoc>(vtocsector);
vtoc = Marshal.ByteArrayToStructureBigEndianGenerated<Vtoc>(vtocsector);
for(int i = 0; i < vtoc.v_part.Length; i++)
for(var i = 0; i < vtoc.v_part.Length; i++)
{
vtoc.v_part[i].p_tag = (pTag)Swapping.Swap((ushort)vtoc.v_part[i].p_tag);
vtoc.v_part[i].p_flag = (pFlag)Swapping.Swap((ushort)vtoc.v_part[i].p_flag);
@@ -212,9 +213,9 @@ public sealed class VTOC : IPartition
vtocOld = Marshal.ByteArrayToStructureLittleEndian<VTocOld>(vtocsector);
else
{
vtocOld = Marshal.ByteArrayToStructureBigEndian<VTocOld>(vtocsector);
vtocOld = Marshal.ByteArrayToStructureBigEndianGenerated<VTocOld>(vtocsector);
for(int i = 0; i < vtocOld.v_part.Length; i++)
for(var i = 0; i < vtocOld.v_part.Length; i++)
{
vtocOld.v_part[i].p_tag = (pTag)Swapping.Swap((ushort)vtocOld.v_part[i].p_tag);
vtocOld.v_part[i].p_flag = (pFlag)Swapping.Swap((ushort)vtocOld.v_part[i].p_flag);
@@ -236,10 +237,10 @@ public sealed class VTOC : IPartition
if((relSecOff + pd.vtoc_len) % imagePlugin.Info.SectorSize > 0) secCount++;
AaruLogging.Debug(MODULE_NAME,
Localization.Going_to_read_0_sectors_from_sector_1_getting_VTOC_from_byte_2,
secCount,
relSecPtr + sectorOffset,
relSecOff);
Localization.Going_to_read_0_sectors_from_sector_1_getting_VTOC_from_byte_2,
secCount,
relSecPtr + sectorOffset,
relSecOff);
if(relSecPtr + sectorOffset + secCount >= imagePlugin.Info.Sectors)
{
@@ -265,9 +266,9 @@ public sealed class VTOC : IPartition
vtoc = Marshal.ByteArrayToStructureLittleEndian<Vtoc>(vtocsector);
else
{
vtoc = Marshal.ByteArrayToStructureBigEndian<Vtoc>(vtocsector);
vtoc = Marshal.ByteArrayToStructureBigEndianGenerated<Vtoc>(vtocsector);
for(int i = 0; i < vtoc.v_part.Length; i++)
for(var i = 0; i < vtoc.v_part.Length; i++)
{
vtoc.v_part[i].p_tag = (pTag)Swapping.Swap((ushort)vtoc.v_part[i].p_tag);
vtoc.v_part[i].p_flag = (pFlag)Swapping.Swap((ushort)vtoc.v_part[i].p_flag);
@@ -289,55 +290,44 @@ public sealed class VTOC : IPartition
if(useOld)
{
AaruLogging.Debug(MODULE_NAME,
"vtocOld.v_sanity = 0x{0:X8} (should be 0x{1:X8})",
vtocOld.v_sanity,
VTOC_SANE);
"vtocOld.v_sanity = 0x{0:X8} (should be 0x{1:X8})",
vtocOld.v_sanity,
VTOC_SANE);
AaruLogging.Debug(MODULE_NAME, "vtocOld.v_version = {0}", vtocOld.v_version);
AaruLogging.Debug(MODULE_NAME,
"vtocOld.v_volume = \"{0}\"",
StringHandlers.CToString(vtocOld.v_volume));
AaruLogging.Debug(MODULE_NAME, "vtocOld.v_volume = \"{0}\"", StringHandlers.CToString(vtocOld.v_volume));
AaruLogging.Debug(MODULE_NAME, "vtocOld.v_sectorsz = {0}", vtocOld.v_sectorsz);
AaruLogging.Debug(MODULE_NAME, "vtocOld.v_nparts = {0}", vtocOld.v_nparts);
for(int i = 0; i < V_NUMPAR; i++)
for(var i = 0; i < V_NUMPAR; i++)
{
AaruLogging.Debug(MODULE_NAME,
"vtocOld.v_part[{0}].p_tag = {1} ({2})",
i,
vtocOld.v_part[i].p_tag,
(ushort)vtocOld.v_part[i].p_tag);
"vtocOld.v_part[{0}].p_tag = {1} ({2})",
i,
vtocOld.v_part[i].p_tag,
(ushort)vtocOld.v_part[i].p_tag);
AaruLogging.Debug(MODULE_NAME,
"vtocOld.v_part[{0}].p_flag = {1} ({2})",
i,
vtocOld.v_part[i].p_flag,
(ushort)vtocOld.v_part[i].p_flag);
"vtocOld.v_part[{0}].p_flag = {1} ({2})",
i,
vtocOld.v_part[i].p_flag,
(ushort)vtocOld.v_part[i].p_flag);
AaruLogging.Debug(MODULE_NAME, "vtocOld.v_part[{0}].p_start = {1}", i, vtocOld.v_part[i].p_start);
AaruLogging.Debug(MODULE_NAME, "vtocOld.v_part[{0}].p_size = {1}", i, vtocOld.v_part[i].p_size);
AaruLogging.Debug(MODULE_NAME,
"vtocOld.v_part[{0}].p_start = {1}",
i,
vtocOld.v_part[i].p_start);
AaruLogging.Debug(MODULE_NAME,
"vtocOld.v_part[{0}].p_size = {1}",
i,
vtocOld.v_part[i].p_size);
AaruLogging.Debug(MODULE_NAME,
"vtocOld.timestamp[{0}] = {1}",
i,
DateHandlers.UnixToDateTime(vtocOld.timestamp[i]));
"vtocOld.timestamp[{0}] = {1}",
i,
DateHandlers.UnixToDateTime(vtocOld.timestamp[i]));
}
}
else
{
AaruLogging.Debug(MODULE_NAME,
"vtoc.v_sanity = 0x{0:X8} (should be 0x{1:X8})",
vtoc.v_sanity,
VTOC_SANE);
AaruLogging.Debug(MODULE_NAME, "vtoc.v_sanity = 0x{0:X8} (should be 0x{1:X8})", vtoc.v_sanity, VTOC_SANE);
AaruLogging.Debug(MODULE_NAME, "vtoc.v_version = {0}", vtoc.v_version);
@@ -346,28 +336,28 @@ public sealed class VTOC : IPartition
AaruLogging.Debug(MODULE_NAME, "vtoc.v_pad = {0}", vtoc.v_pad);
AaruLogging.Debug(MODULE_NAME, "vtoc.v_nparts = {0}", vtoc.v_nparts);
for(int i = 0; i < V_NUMPAR; i++)
for(var i = 0; i < V_NUMPAR; i++)
{
AaruLogging.Debug(MODULE_NAME,
"vtoc.v_part[{0}].p_tag = {1} ({2})",
i,
vtoc.v_part[i].p_tag,
(ushort)vtoc.v_part[i].p_tag);
"vtoc.v_part[{0}].p_tag = {1} ({2})",
i,
vtoc.v_part[i].p_tag,
(ushort)vtoc.v_part[i].p_tag);
AaruLogging.Debug(MODULE_NAME,
"vtoc.v_part[{0}].p_flag = {1} ({2})",
i,
vtoc.v_part[i].p_flag,
(ushort)vtoc.v_part[i].p_flag);
"vtoc.v_part[{0}].p_flag = {1} ({2})",
i,
vtoc.v_part[i].p_flag,
(ushort)vtoc.v_part[i].p_flag);
AaruLogging.Debug(MODULE_NAME, "vtoc.v_part[{0}].p_start = {1}", i, vtoc.v_part[i].p_start);
AaruLogging.Debug(MODULE_NAME, "vtoc.v_part[{0}].p_size = {1}", i, vtoc.v_part[i].p_size);
AaruLogging.Debug(MODULE_NAME,
"vtoc.timestamp[{0}] = {1}",
i,
DateHandlers.UnixToDateTime(vtoc.timestamp[i]));
"vtoc.timestamp[{0}] = {1}",
i,
DateHandlers.UnixToDateTime(vtoc.timestamp[i]));
}
}
@@ -390,7 +380,7 @@ public sealed class VTOC : IPartition
// Check for a partition describing the VTOC whose start is the same as the start we know.
// This means partition starts are absolute, not relative, to the VTOC position
for(int i = 0; i < V_NUMPAR; i++)
for(var i = 0; i < V_NUMPAR; i++)
{
if(parts[i].p_tag != pTag.V_BACKUP || (ulong)parts[i].p_start != sectorOffset) continue;
@@ -399,7 +389,7 @@ public sealed class VTOC : IPartition
break;
}
for(int i = 0; i < V_NUMPAR; i++)
for(var i = 0; i < V_NUMPAR; i++)
{
if(parts[i].p_tag == pTag.V_UNUSED) continue;
@@ -414,7 +404,7 @@ public sealed class VTOC : IPartition
Scheme = Name
};
string info = "";
var info = "";
// Apparently old ones are absolute :?
if(!useOld && !absolute)
@@ -479,47 +469,48 @@ public sealed class VTOC : IPartition
#region Nested type: PDInfo
[StructLayout(LayoutKind.Sequential, Pack = 1)]
[SwapEndian]
// ReSharper disable once InconsistentNaming
struct PDInfo
partial struct PDInfo
{
public readonly uint driveid; /*identifies the device type*/
public readonly uint sanity; /*verifies device sanity*/
public readonly uint version; /*version number*/
public uint driveid; /*identifies the device type*/
public uint sanity; /*verifies device sanity*/
public uint version; /*version number*/
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
public readonly byte[] serial; /*serial number of the device*/
public readonly uint cyls; /*number of cylinders per drive*/
public readonly uint tracks; /*number tracks per cylinder*/
public readonly uint sectors; /*number sectors per track*/
public readonly uint bytes; /*number of bytes per sector*/
public readonly uint logicalst; /*sector address of logical sector 0*/
public readonly uint errlogst; /*sector address of error log area*/
public readonly uint errlogsz; /*size in bytes of error log area*/
public readonly uint mfgst; /*sector address of mfg. defect info*/
public readonly uint mfgsz; /*size in bytes of mfg. defect info*/
public readonly uint defectst; /*sector address of the defect map*/
public readonly uint defectsz; /*size in bytes of defect map*/
public readonly uint relno; /*number of relocation areas*/
public readonly uint relst; /*sector address of relocation area*/
public readonly uint relsz; /*size in sectors of relocation area*/
public readonly uint relnext; /*address of next avail reloc sector*/
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 readonly uint vtoc_ptr; /*byte offset of vtoc block*/
public readonly ushort vtoc_len; /*byte length of vtoc block*/
public readonly ushort vtoc_pad; /* pad for 16-bit machine alignment */
public readonly uint alt_ptr; /*byte offset of alternates table*/
public readonly ushort alt_len; /*byte length of alternates table*/
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 readonly uint pcyls; /*physical cylinders per drive*/
public readonly uint ptracks; /*physical tracks per cylinder*/
public readonly uint psectors; /*physical sectors per track*/
public readonly uint pbytes; /*physical bytes per sector*/
public readonly uint secovhd; /*sector overhead bytes per sector*/
public readonly ushort interleave; /*interleave factor*/
public readonly ushort skew; /*skew factor*/
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 readonly uint[] pad; /*space for more stuff*/
public uint[] pad; /*space for more stuff*/
}
#endregion
@@ -527,32 +518,33 @@ public sealed class VTOC : IPartition
#region Nested type: PDInfoOld
[StructLayout(LayoutKind.Sequential, Pack = 1)]
[SwapEndian]
// ReSharper disable once InconsistentNaming
struct PDInfoOld
partial struct PDInfoOld
{
public readonly uint driveid; /*identifies the device type*/
public readonly uint sanity; /*verifies device sanity*/
public readonly uint version; /*version number*/
public uint driveid; /*identifies the device type*/
public uint sanity; /*verifies device sanity*/
public uint version; /*version number*/
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
public readonly byte[] serial; /*serial number of the device*/
public readonly uint cyls; /*number of cylinders per drive*/
public readonly uint tracks; /*number tracks per cylinder*/
public readonly uint sectors; /*number sectors per track*/
public readonly uint bytes; /*number of bytes per sector*/
public readonly uint logicalst; /*sector address of logical sector 0*/
public readonly uint errlogst; /*sector address of error log area*/
public readonly uint errlogsz; /*size in bytes of error log area*/
public readonly uint mfgst; /*sector address of mfg. defect info*/
public readonly uint mfgsz; /*size in bytes of mfg. defect info*/
public readonly uint defectst; /*sector address of the defect map*/
public readonly uint defectsz; /*size in bytes of defect map*/
public readonly uint relno; /*number of relocation areas*/
public readonly uint relst; /*sector address of relocation area*/
public readonly uint relsz; /*size in sectors of relocation area*/
public readonly uint relnext; /*address of next avail reloc sector*/
public readonly uint allcstrt; /*start of the allocatable disk*/
public readonly uint allcend; /*end of allocatable disk*/
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*/
}
#endregion
@@ -630,22 +622,23 @@ public sealed class VTOC : IPartition
#region Nested type: Vtoc
[StructLayout(LayoutKind.Sequential, Pack = 1)]
[SwapEndian]
// ReSharper disable once InconsistentNaming
struct Vtoc
partial struct Vtoc
{
public readonly uint v_sanity; /*to verify vtoc sanity*/
public readonly uint v_version; /*layout version*/
public uint v_sanity; /*to verify vtoc sanity*/
public uint v_version; /*layout version*/
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public readonly byte[] v_volume; /*volume name*/
public readonly ushort v_nparts; /*number of partitions*/
public readonly ushort v_pad; /*pad for 286 compiler*/
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 readonly uint[] v_reserved; /*free space*/
public uint[] v_reserved; /*free space*/
[MarshalAs(UnmanagedType.ByValArray, SizeConst = V_NUMPAR)]
public readonly VtocPartition[] v_part; /*partition headers*/
public VtocPartition[] v_part; /*partition headers*/
[MarshalAs(UnmanagedType.ByValArray, SizeConst = V_NUMPAR)]
public readonly int[] timestamp; /* SCSI time stamp */
public int[] timestamp; /* SCSI time stamp */
}
#endregion
@@ -653,24 +646,25 @@ public sealed class VTOC : IPartition
#region Nested type: VTocOld
[StructLayout(LayoutKind.Sequential, Pack = 1)]
[SwapEndian]
// ReSharper disable once InconsistentNaming
struct VTocOld
partial struct VTocOld
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public readonly uint[] v_bootinfo; /*info needed by mboot*/
public readonly uint v_sanity; /*to verify vtoc sanity*/
public readonly uint v_version; /*layout version*/
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 readonly byte[] v_volume; /*volume name*/
public readonly ushort v_sectorsz; /*sector size in bytes*/
public readonly ushort v_nparts; /*number of partitions*/
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 readonly uint[] v_reserved; /*free space*/
public uint[] v_reserved; /*free space*/
[MarshalAs(UnmanagedType.ByValArray, SizeConst = V_NUMPAR)]
public readonly VtocPartition[] v_part; /*partition headers*/
public VtocPartition[] v_part; /*partition headers*/
[MarshalAs(UnmanagedType.ByValArray, SizeConst = V_NUMPAR)]
public readonly int[] timestamp; /* SCSI time stamp */
public int[] timestamp; /* SCSI time stamp */
}
#endregion
@@ -678,9 +672,10 @@ public sealed class VTOC : IPartition
#region Nested type: VtocPartition
[StructLayout(LayoutKind.Sequential, Pack = 1)]
[SwapEndian]
// ReSharper disable once InconsistentNaming
struct VtocPartition
partial struct VtocPartition
{
public pTag p_tag; /*ID tag of partition*/
public pFlag p_flag; /*permision flags*/

View File

@@ -35,6 +35,7 @@ using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using Aaru.CommonTypes;
using Aaru.CommonTypes.Attributes;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Interfaces;
using Marshal = Aaru.Helpers.Marshal;
@@ -44,7 +45,7 @@ namespace Aaru.Partitions;
/// <inheritdoc />
/// <summary>Implements decoding of Xbox partitions</summary>
[SuppressMessage("ReSharper", "UnusedMember.Local")]
public sealed class Xbox : IPartition
public sealed partial class Xbox : IPartition
{
const uint XBOX_CIGAM = 0x46415458;
const uint XBOX_MAGIC = 0x58544146;
@@ -87,7 +88,8 @@ public sealed class Xbox : IPartition
if(errno != ErrorNumber.NoError || sector.Length < 512) return false;
Xbox360DevKitPartitionTable table = Marshal.ByteArrayToStructureBigEndian<Xbox360DevKitPartitionTable>(sector);
Xbox360DevKitPartitionTable table =
Marshal.ByteArrayToStructureBigEndianGenerated<Xbox360DevKitPartitionTable>(sector);
if(table.magic == XBOX360_DEVKIT_MAGIC &&
table.contentOff + table.contentLen <= imagePlugin.Info.Sectors &&
@@ -269,14 +271,15 @@ public sealed class Xbox : IPartition
#region Nested type: Xbox360DevKitPartitionTable
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct Xbox360DevKitPartitionTable
[SwapEndian]
partial struct Xbox360DevKitPartitionTable
{
public readonly uint magic;
public readonly uint unknown;
public readonly uint contentOff;
public readonly uint contentLen;
public readonly uint dashboardOff;
public readonly uint dashboardLen;
public uint magic;
public uint unknown;
public uint contentOff;
public uint contentLen;
public uint dashboardOff;
public uint dashboardLen;
}
#endregion