diff --git a/Aaru.Filesystems/FAT/BPB.cs b/Aaru.Filesystems/FAT/BPB.cs index 437b7f85f..40827ef99 100644 --- a/Aaru.Filesystems/FAT/BPB.cs +++ b/Aaru.Filesystems/FAT/BPB.cs @@ -49,7 +49,7 @@ public sealed partial class FAT andosOemCorrect = false; bootable = false; - humanBpb = Marshal.ByteArrayToStructureBigEndian(bpbSector); + humanBpb = Marshal.ByteArrayToStructureBigEndianGenerated(bpbSector); atariBpb = Marshal.ByteArrayToStructureLittleEndian(bpbSector); ulong expectedClusters = humanBpb.bpc > 0 ? partition.Size / humanBpb.bpc : 0; diff --git a/Aaru.Filesystems/FAT/Info.cs b/Aaru.Filesystems/FAT/Info.cs index be65cad27..319b915f3 100644 --- a/Aaru.Filesystems/FAT/Info.cs +++ b/Aaru.Filesystems/FAT/Info.cs @@ -82,7 +82,7 @@ public sealed partial class FAT if(errno != ErrorNumber.NoError) return false; - HumanParameterBlock humanBpb = Marshal.ByteArrayToStructureBigEndian(bpbSector); + HumanParameterBlock humanBpb = Marshal.ByteArrayToStructureBigEndianGenerated(bpbSector); ulong expectedClusters = humanBpb.bpc > 0 ? partition.Size / humanBpb.bpc : 0; diff --git a/Aaru.Filesystems/FAT/Structs.cs b/Aaru.Filesystems/FAT/Structs.cs index a132f5bd4..1fd3b5098 100644 --- a/Aaru.Filesystems/FAT/Structs.cs +++ b/Aaru.Filesystems/FAT/Structs.cs @@ -30,6 +30,7 @@ using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; +using Aaru.CommonTypes.Attributes; using Aaru.CommonTypes.Interfaces; namespace Aaru.Filesystems; @@ -942,35 +943,36 @@ public sealed partial class FAT /// Human68k Parameter Block, big endian, 512 bytes even on 256 bytes/sector. [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct HumanParameterBlock + [SwapEndian] + partial struct HumanParameterBlock { /// 68k bra.S [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] - public readonly byte[] jump; + public byte[] jump; /// OEM Name, 16 bytes, space-padded [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] - public readonly byte[] oem_name; + public byte[] oem_name; /// Bytes per cluster - public readonly ushort bpc; + public ushort bpc; /// Unknown, seen 1, 2 and 16 - public readonly byte unknown1; + public byte unknown1; /// Unknown, always 512? - public readonly ushort unknown2; + public ushort unknown2; /// Unknown, always 1? - public readonly byte unknown3; + public byte unknown3; /// Number of entries on root directory - public readonly ushort root_ent; + public ushort root_ent; /// Clusters, set to 0 if more than 65536 - public readonly ushort clusters; + public ushort clusters; /// Media descriptor - public readonly byte media; + public byte media; /// Clusters per FAT, set to 0 - public readonly byte cpfat; + public byte cpfat; /// Clustersin volume - public readonly uint big_clusters; + public uint big_clusters; /// Boot code. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 478)] - public readonly byte[] boot_code; + public byte[] boot_code; } #endregion