diff --git a/Aaru.Archives/Stfs/Info.cs b/Aaru.Archives/Stfs/Info.cs index fa583271a..96a78e816 100644 --- a/Aaru.Archives/Stfs/Info.cs +++ b/Aaru.Archives/Stfs/Info.cs @@ -26,7 +26,7 @@ public sealed partial class Stfs stream.ReadExactly(hdr, 0, hdr.Length); - RemotePackage header = Marshal.ByteArrayToStructureBigEndianGenerated(hdr); + RemotePackage header = Marshal.ByteArrayToStructureBigEndian(hdr); if(header.Magic is not (PackageMagic.Console or PackageMagic.Live or PackageMagic.Microsoft)) return false; @@ -51,7 +51,7 @@ public sealed partial class Stfs // Reverse positions that hold UTF16-BE strings ReverseShorts(hdr, 0x0411, 0x1300); - RemotePackage header = Marshal.ByteArrayToStructureBigEndianGenerated(hdr); + RemotePackage header = Marshal.ByteArrayToStructureBigEndian(hdr); if(header.Magic is not (PackageMagic.Console or PackageMagic.Live or PackageMagic.Microsoft)) return; @@ -78,7 +78,7 @@ public sealed partial class Stfs if(header.Magic == PackageMagic.Console) { - ConsolePackage consolePackage = Marshal.ByteArrayToStructureBigEndianGenerated(hdr); + ConsolePackage consolePackage = Marshal.ByteArrayToStructureBigEndian(hdr); sb.AppendFormat(Localization.Certificate_owner_console_ID_0_1_2_3_4, consolePackage.CertificateOwnerConsoleId[0], diff --git a/Aaru.Archives/Stfs/Open.cs b/Aaru.Archives/Stfs/Open.cs index 63e596948..679850ed0 100644 --- a/Aaru.Archives/Stfs/Open.cs +++ b/Aaru.Archives/Stfs/Open.cs @@ -23,7 +23,7 @@ public sealed partial class Stfs _stream.ReadExactly(hdr, 0, hdr.Length); - RemotePackage header = Marshal.ByteArrayToStructureBigEndianGenerated(hdr); + RemotePackage header = Marshal.ByteArrayToStructureBigEndian(hdr); if(header.Magic is not (PackageMagic.Console or PackageMagic.Live or PackageMagic.Microsoft)) return ErrorNumber.InvalidArgument; @@ -56,7 +56,7 @@ public sealed partial class Stfs do { - FileTableEntry entry = Marshal.ByteArrayToStructureBigEndianGenerated(buffer, in_pos, entrySize); + FileTableEntry entry = Marshal.ByteArrayToStructureBigEndian(buffer, in_pos, entrySize); if(entry.FilenameLength == 0) break; diff --git a/Aaru.Filesystems/AmigaDOS/Helpers.cs b/Aaru.Filesystems/AmigaDOS/Helpers.cs index 38ec1daf5..afcb131e5 100644 --- a/Aaru.Filesystems/AmigaDOS/Helpers.cs +++ b/Aaru.Filesystems/AmigaDOS/Helpers.cs @@ -40,7 +40,7 @@ public sealed partial class AmigaDOSPlugin var tmp = new byte[228]; Array.Copy(block, 0, tmp, 0, 24); Array.Copy(block, block.Length - 200, tmp, 28, 200); - RootBlock root = Marshal.ByteArrayToStructureBigEndianGenerated(tmp); + RootBlock root = Marshal.ByteArrayToStructureBigEndian(tmp); root.hashTable = new uint[(block.Length - 224) / 4]; for(var i = 0; i < root.hashTable.Length; i++) diff --git a/Aaru.Filesystems/AmigaDOS/Info.cs b/Aaru.Filesystems/AmigaDOS/Info.cs index 5f65adb88..d7cb661fb 100644 --- a/Aaru.Filesystems/AmigaDOS/Info.cs +++ b/Aaru.Filesystems/AmigaDOS/Info.cs @@ -60,7 +60,7 @@ public sealed partial class AmigaDOSPlugin if(errno != ErrorNumber.NoError) return false; - BootBlock bblk = Marshal.ByteArrayToStructureBigEndianGenerated(sector); + BootBlock bblk = Marshal.ByteArrayToStructureBigEndian(sector); // AROS boot floppies... if(sector.Length >= 512 && @@ -73,7 +73,7 @@ public sealed partial class AmigaDOSPlugin if(errno != ErrorNumber.NoError) return false; - bblk = Marshal.ByteArrayToStructureBigEndianGenerated(sector); + bblk = Marshal.ByteArrayToStructureBigEndian(sector); } // Not FFS or MuFS? @@ -166,7 +166,7 @@ public sealed partial class AmigaDOSPlugin if(errno != ErrorNumber.NoError) return; - BootBlock bootBlk = Marshal.ByteArrayToStructureBigEndianGenerated(bootBlockSectors); + BootBlock bootBlk = Marshal.ByteArrayToStructureBigEndian(bootBlockSectors); bootBlk.bootCode = new byte[bootBlockSectors.Length - 12]; Array.Copy(bootBlockSectors, 12, bootBlk.bootCode, 0, bootBlk.bootCode.Length); bootBlockSectors[4] = bootBlockSectors[5] = bootBlockSectors[6] = bootBlockSectors[7] = 0; diff --git a/Aaru.Filesystems/AppleCommon/Info.cs b/Aaru.Filesystems/AppleCommon/Info.cs index 13433fbab..a2c0d1154 100644 --- a/Aaru.Filesystems/AppleCommon/Info.cs +++ b/Aaru.Filesystems/AppleCommon/Info.cs @@ -39,7 +39,7 @@ static partial class AppleCommon { if(bbSector is null || bbSector.Length < 0x100) return null; - BootBlock bb = Marshal.ByteArrayToStructureBigEndianGenerated(bbSector); + BootBlock bb = Marshal.ByteArrayToStructureBigEndian(bbSector); if(bb.bbID != BB_MAGIC) return null; diff --git a/Aaru.Filesystems/AppleHFS/Info.cs b/Aaru.Filesystems/AppleHFS/Info.cs index e693c1105..c3760d593 100644 --- a/Aaru.Filesystems/AppleHFS/Info.cs +++ b/Aaru.Filesystems/AppleHFS/Info.cs @@ -155,7 +155,7 @@ public sealed partial class AppleHFS return; } - MasterDirectoryBlock mdb = Marshal.ByteArrayToStructureBigEndianGenerated(mdbSector); + MasterDirectoryBlock mdb = Marshal.ByteArrayToStructureBigEndian(mdbSector); sb.AppendLine(Localization.Name_Apple_Hierarchical_File_System); sb.AppendLine(); diff --git a/Aaru.Filesystems/AppleHFSPlus/Info.cs b/Aaru.Filesystems/AppleHFSPlus/Info.cs index 14c7a7052..bdb862050 100644 --- a/Aaru.Filesystems/AppleHFSPlus/Info.cs +++ b/Aaru.Filesystems/AppleHFSPlus/Info.cs @@ -174,7 +174,7 @@ public sealed partial class AppleHFSPlus Array.Copy(vhSector, 0x400, tmp, 0, 0x400); vhSector = tmp; - vh = Marshal.ByteArrayToStructureBigEndianGenerated(vhSector); + vh = Marshal.ByteArrayToStructureBigEndian(vhSector); if(vh.version is 4 or 5) { diff --git a/Aaru.Filesystems/AppleMFS/Dir.cs b/Aaru.Filesystems/AppleMFS/Dir.cs index 4ddc6aee8..5e96ca456 100644 --- a/Aaru.Filesystems/AppleMFS/Dir.cs +++ b/Aaru.Filesystems/AppleMFS/Dir.cs @@ -59,7 +59,7 @@ public sealed partial class AppleMFS entry.flTyp = _directoryBlocks[offset + 1]; entry.flUsrWds = - Marshal.ByteArrayToStructureBigEndianGenerated(_directoryBlocks, offset + 2, 16); + Marshal.ByteArrayToStructureBigEndian(_directoryBlocks, offset + 2, 16); entry.flFlNum = BigEndianBitConverter.ToUInt32(_directoryBlocks, offset + 18); entry.flStBlk = BigEndianBitConverter.ToUInt16(_directoryBlocks, offset + 22); diff --git a/Aaru.Filesystems/BFS/Info.cs b/Aaru.Filesystems/BFS/Info.cs index a610830b2..d6cf0f258 100644 --- a/Aaru.Filesystems/BFS/Info.cs +++ b/Aaru.Filesystems/BFS/Info.cs @@ -132,7 +132,7 @@ public sealed partial class BeFS besb = littleEndian ? Marshal.ByteArrayToStructureLittleEndian(sbSector) - : Marshal.ByteArrayToStructureBigEndianGenerated(sbSector); + : Marshal.ByteArrayToStructureBigEndian(sbSector); sb.AppendLine(littleEndian ? Localization.Little_endian_BeFS : Localization.Big_endian_BeFS); diff --git a/Aaru.Filesystems/CBM/Super.cs b/Aaru.Filesystems/CBM/Super.cs index 1a2e57fb4..198d845ae 100644 --- a/Aaru.Filesystems/CBM/Super.cs +++ b/Aaru.Filesystems/CBM/Super.cs @@ -88,7 +88,7 @@ public sealed partial class CBM if(errno != ErrorNumber.NoError) return errno; - Header cbmHdr = Marshal.ByteArrayToStructureBigEndianGenerated
(_diskHeader); + Header cbmHdr = Marshal.ByteArrayToStructureBigEndian
(_diskHeader); if(cbmHdr.diskDosVersion != 0x44 || cbmHdr is not { dosVersion: 0x33, diskVersion: 0x44 }) return ErrorNumber.InvalidArgument; @@ -126,7 +126,7 @@ public sealed partial class CBM if(errno != ErrorNumber.NoError) return errno; - BAM cbmBam = Marshal.ByteArrayToStructureBigEndianGenerated(_bam); + BAM cbmBam = Marshal.ByteArrayToStructureBigEndian(_bam); if(cbmBam is not ({ dosVersion: 0x41, doubleSided : 0x00 or 0x80 } and { unused1 : 0x00, directoryTrack: 0x12 })) @@ -228,7 +228,7 @@ public sealed partial class CBM while(offset < _root.Length) { - DirectoryEntry dirEntry = Marshal.ByteArrayToStructureBigEndianGenerated(_root, offset, 32); + DirectoryEntry dirEntry = Marshal.ByteArrayToStructureBigEndian(_root, offset, 32); if(dirEntry.fileType == 0) { diff --git a/Aaru.Filesystems/Cram/Info.cs b/Aaru.Filesystems/Cram/Info.cs index 1ad8e2233..a965a98a2 100644 --- a/Aaru.Filesystems/Cram/Info.cs +++ b/Aaru.Filesystems/Cram/Info.cs @@ -83,7 +83,7 @@ public sealed partial class Cram break; case CRAM_CIGAM: - crSb = Marshal.ByteArrayToStructureBigEndianGenerated(sector); + crSb = Marshal.ByteArrayToStructureBigEndian(sector); littleEndian = false; break; diff --git a/Aaru.Filesystems/EFS/Info.cs b/Aaru.Filesystems/EFS/Info.cs index a101d7b77..7c1f7e86e 100644 --- a/Aaru.Filesystems/EFS/Info.cs +++ b/Aaru.Filesystems/EFS/Info.cs @@ -65,7 +65,7 @@ public sealed partial class EFS Array.Copy(sector, 0x200, sbpiece, 0, Marshal.SizeOf()); - Superblock sb = Marshal.ByteArrayToStructureBigEndianGenerated(sbpiece); + Superblock sb = Marshal.ByteArrayToStructureBigEndian(sbpiece); AaruLogging.Debug(MODULE_NAME, Localization.magic_at_0_equals_1_expected_2_or_3, @@ -88,7 +88,7 @@ public sealed partial class EFS if(sector.Length < Marshal.SizeOf()) return false; - Superblock sb = Marshal.ByteArrayToStructureBigEndianGenerated(sector); + Superblock sb = Marshal.ByteArrayToStructureBigEndian(sector); AaruLogging.Debug(MODULE_NAME, Localization.magic_at_0_equals_1_expected_2_or_3, @@ -132,7 +132,7 @@ public sealed partial class EFS Array.Copy(sector, 0x200, sbpiece, 0, Marshal.SizeOf()); - efsSb = Marshal.ByteArrayToStructureBigEndianGenerated(sbpiece); + efsSb = Marshal.ByteArrayToStructureBigEndian(sbpiece); AaruLogging.Debug(MODULE_NAME, Localization.magic_at_0_X3_equals_1_expected_2_or_3, @@ -153,7 +153,7 @@ public sealed partial class EFS if(sector.Length < Marshal.SizeOf()) return; - efsSb = Marshal.ByteArrayToStructureBigEndianGenerated(sector); + efsSb = Marshal.ByteArrayToStructureBigEndian(sector); AaruLogging.Debug(MODULE_NAME, Localization.magic_at_0_equals_1_expected_2_or_3, diff --git a/Aaru.Filesystems/FAT/BPB.cs b/Aaru.Filesystems/FAT/BPB.cs index 40827ef99..437b7f85f 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.ByteArrayToStructureBigEndianGenerated(bpbSector); + humanBpb = Marshal.ByteArrayToStructureBigEndian(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 319b915f3..be65cad27 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.ByteArrayToStructureBigEndianGenerated(bpbSector); + HumanParameterBlock humanBpb = Marshal.ByteArrayToStructureBigEndian(bpbSector); ulong expectedClusters = humanBpb.bpc > 0 ? partition.Size / humanBpb.bpc : 0; diff --git a/Aaru.Filesystems/FATX/Dir.cs b/Aaru.Filesystems/FATX/Dir.cs index a25868af4..890ac1d0c 100644 --- a/Aaru.Filesystems/FATX/Dir.cs +++ b/Aaru.Filesystems/FATX/Dir.cs @@ -130,7 +130,7 @@ public sealed partial class XboxFatPlugin ? Marshal.ByteArrayToStructureLittleEndian(directoryBuffer, pos, Marshal.SizeOf()) - : Marshal.ByteArrayToStructureBigEndianGenerated(directoryBuffer, + : Marshal.ByteArrayToStructureBigEndian(directoryBuffer, pos, Marshal.SizeOf()); diff --git a/Aaru.Filesystems/FATX/Info.cs b/Aaru.Filesystems/FATX/Info.cs index 7c1628ddf..b44c1c82e 100644 --- a/Aaru.Filesystems/FATX/Info.cs +++ b/Aaru.Filesystems/FATX/Info.cs @@ -48,7 +48,7 @@ public sealed partial class XboxFatPlugin if(errno != ErrorNumber.NoError) return false; - Superblock sb = Marshal.ByteArrayToStructureBigEndianGenerated(sector); + Superblock sb = Marshal.ByteArrayToStructureBigEndian(sector); return sb.magic is FATX_MAGIC or FATX_CIGAM; } @@ -68,7 +68,7 @@ public sealed partial class XboxFatPlugin if(errno != ErrorNumber.NoError) return; - Superblock fatxSb = Marshal.ByteArrayToStructureBigEndianGenerated(sector); + Superblock fatxSb = Marshal.ByteArrayToStructureBigEndian(sector); if(fatxSb.magic == FATX_CIGAM) { diff --git a/Aaru.Filesystems/FATX/Super.cs b/Aaru.Filesystems/FATX/Super.cs index 076ca1395..a20558b3a 100644 --- a/Aaru.Filesystems/FATX/Super.cs +++ b/Aaru.Filesystems/FATX/Super.cs @@ -69,7 +69,7 @@ public sealed partial class XboxFatPlugin if(_superblock.magic == FATX_CIGAM) { - _superblock = Marshal.ByteArrayToStructureBigEndianGenerated(sector); + _superblock = Marshal.ByteArrayToStructureBigEndian(sector); _littleEndian = false; } @@ -233,7 +233,7 @@ public sealed partial class XboxFatPlugin ? Marshal.ByteArrayToStructureLittleEndian(rootDirectoryBuffer, pos, Marshal.SizeOf()) - : Marshal.ByteArrayToStructureBigEndianGenerated(rootDirectoryBuffer, + : Marshal.ByteArrayToStructureBigEndian(rootDirectoryBuffer, pos, Marshal.SizeOf()); diff --git a/Aaru.Filesystems/FFS/Info.cs b/Aaru.Filesystems/FFS/Info.cs index 632eb3fb3..a2ba068cb 100644 --- a/Aaru.Filesystems/FFS/Info.cs +++ b/Aaru.Filesystems/FFS/Info.cs @@ -220,7 +220,7 @@ public sealed partial class FFSPlugin SuperBlock sb = Marshal.ByteArrayToStructureLittleEndian(ufs_sb_sectors); - SuperBlock bs_sfu = Marshal.ByteArrayToStructureBigEndianGenerated(ufs_sb_sectors); + SuperBlock bs_sfu = Marshal.ByteArrayToStructureBigEndian(ufs_sb_sectors); if(bs_sfu.fs_magic == UFS_MAGIC && sb.fs_magic == UFS_CIGAM || bs_sfu.fs_magic == UFS_MAGIC_BW && sb.fs_magic == UFS_CIGAM_BW || diff --git a/Aaru.Filesystems/Fossil/Info.cs b/Aaru.Filesystems/Fossil/Info.cs index 743239363..aa3c4f9c8 100644 --- a/Aaru.Filesystems/Fossil/Info.cs +++ b/Aaru.Filesystems/Fossil/Info.cs @@ -53,7 +53,7 @@ public sealed partial class Fossil if(errno != ErrorNumber.NoError) return false; - Header hdr = Marshal.ByteArrayToStructureBigEndianGenerated
(sector); + Header hdr = Marshal.ByteArrayToStructureBigEndian
(sector); AaruLogging.Debug(MODULE_NAME, Localization.magic_at_0_expected_1, hdr.magic, FOSSIL_HDR_MAGIC); @@ -77,7 +77,7 @@ public sealed partial class Fossil if(errno != ErrorNumber.NoError) return; - Header hdr = Marshal.ByteArrayToStructureBigEndianGenerated
(sector); + Header hdr = Marshal.ByteArrayToStructureBigEndian
(sector); AaruLogging.Debug(MODULE_NAME, Localization.magic_at_0_expected_1, hdr.magic, FOSSIL_HDR_MAGIC); @@ -103,7 +103,7 @@ public sealed partial class Fossil if(sbLocation <= partition.End) { imagePlugin.ReadSector(sbLocation, out sector); - SuperBlock fsb = Marshal.ByteArrayToStructureBigEndianGenerated(sector); + SuperBlock fsb = Marshal.ByteArrayToStructureBigEndian(sector); AaruLogging.Debug(MODULE_NAME, Localization.magic_0_expected_1, fsb.magic, FOSSIL_SB_MAGIC); diff --git a/Aaru.Filesystems/HAMMER/Info.cs b/Aaru.Filesystems/HAMMER/Info.cs index 7984d9c1d..70e7ff1b7 100644 --- a/Aaru.Filesystems/HAMMER/Info.cs +++ b/Aaru.Filesystems/HAMMER/Info.cs @@ -84,7 +84,7 @@ public sealed partial class HAMMER SuperBlock superBlock = magic == HAMMER_FSBUF_VOLUME ? Marshal.ByteArrayToStructureLittleEndian(sbSector) - : Marshal.ByteArrayToStructureBigEndianGenerated(sbSector); + : Marshal.ByteArrayToStructureBigEndian(sbSector); sb.AppendLine(Localization.HAMMER_filesystem); diff --git a/Aaru.Filesystems/HPOFS/Info.cs b/Aaru.Filesystems/HPOFS/Info.cs index 325ab2bd9..3168ba90e 100644 --- a/Aaru.Filesystems/HPOFS/Info.cs +++ b/Aaru.Filesystems/HPOFS/Info.cs @@ -93,10 +93,10 @@ public sealed partial class HPOFS BiosParameterBlock bpb = Marshal.ByteArrayToStructureLittleEndian(hpofsBpbSector); MediaInformationBlock mib = - Marshal.ByteArrayToStructureBigEndianGenerated(medInfoSector); + Marshal.ByteArrayToStructureBigEndian(medInfoSector); VolumeInformationBlock vib = - Marshal.ByteArrayToStructureBigEndianGenerated(volInfoSector); + Marshal.ByteArrayToStructureBigEndian(volInfoSector); AaruLogging.Debug(MODULE_NAME, "bpb.oem_name = \"{0}\"", StringHandlers.CToString(bpb.oem_name)); diff --git a/Aaru.Filesystems/ISO9660/Dir.cs b/Aaru.Filesystems/ISO9660/Dir.cs index df8ffdffd..719cb582f 100644 --- a/Aaru.Filesystems/ISO9660/Dir.cs +++ b/Aaru.Filesystems/ISO9660/Dir.cs @@ -55,7 +55,7 @@ public sealed partial class ISO9660 while(entryOff + _cdiDirectoryRecordSize < data.Length) { CdiDirectoryRecord record = - Marshal.ByteArrayToStructureBigEndianGenerated(data, + Marshal.ByteArrayToStructureBigEndian(data, entryOff, _cdiDirectoryRecordSize); @@ -107,7 +107,7 @@ public sealed partial class ISO9660 if(systemAreaStart % 2 != 0) systemAreaStart++; entry.CdiSystemArea = - Marshal.ByteArrayToStructureBigEndianGenerated(data, + Marshal.ByteArrayToStructureBigEndian(data, systemAreaStart, _cdiSystemAreaSize); @@ -459,7 +459,7 @@ public sealed partial class ISO9660 break; case AppleId.HFS: AppleHFSSystemUse appleHfsSystemUse = - Marshal.ByteArrayToStructureBigEndianGenerated(data, + Marshal.ByteArrayToStructureBigEndian(data, systemAreaOff, Marshal.SizeOf()); @@ -500,7 +500,7 @@ public sealed partial class ISO9660 case AppleOldId.TypeCreator: case AppleOldId.TypeCreatorBundle: AppleHFSTypeCreatorSystemUse appleHfsTypeCreatorSystemUse = - Marshal.ByteArrayToStructureBigEndianGenerated(data, + Marshal.ByteArrayToStructureBigEndian(data, systemAreaOff, Marshal.SizeOf()); @@ -520,7 +520,7 @@ public sealed partial class ISO9660 case AppleOldId.TypeCreatorIcon: case AppleOldId.TypeCreatorIconBundle: AppleHFSIconSystemUse appleHfsIconSystemUse = - Marshal.ByteArrayToStructureBigEndianGenerated(data, + Marshal.ByteArrayToStructureBigEndian(data, systemAreaOff, Marshal.SizeOf()); @@ -540,7 +540,7 @@ public sealed partial class ISO9660 break; case AppleOldId.HFS: AppleHFSOldSystemUse appleHfsSystemUse = - Marshal.ByteArrayToStructureBigEndianGenerated(data, + Marshal.ByteArrayToStructureBigEndian(data, systemAreaOff, Marshal.SizeOf()); @@ -567,7 +567,7 @@ public sealed partial class ISO9660 break; case XA_MAGIC: - entry.XA = Marshal.ByteArrayToStructureBigEndianGenerated(data, + entry.XA = Marshal.ByteArrayToStructureBigEndian(data, systemAreaOff, Marshal.SizeOf()); @@ -579,7 +579,7 @@ public sealed partial class ISO9660 case AAIP_MAGIC: case AMIGA_MAGIC: AmigaEntry amiga = - Marshal.ByteArrayToStructureBigEndianGenerated(data, + Marshal.ByteArrayToStructureBigEndian(data, systemAreaOff, Marshal.SizeOf()); @@ -588,7 +588,7 @@ public sealed partial class ISO9660 if(amiga.flags.HasFlag(AmigaFlags.Protection)) { entry.AmigaProtection = - Marshal.ByteArrayToStructureBigEndianGenerated(data, + Marshal.ByteArrayToStructureBigEndian(data, systemAreaOff + Marshal.SizeOf(), Marshal.SizeOf()); @@ -995,7 +995,7 @@ public sealed partial class ISO9660 if(errno != ErrorNumber.NoError) continue; CdiDirectoryRecord record = - Marshal.ByteArrayToStructureBigEndianGenerated(sector, + Marshal.ByteArrayToStructureBigEndian(sector, tEntry.XattrLength, _cdiDirectoryRecordSize); @@ -1020,7 +1020,7 @@ public sealed partial class ISO9660 if(systemAreaStart % 2 != 0) systemAreaStart++; entry.CdiSystemArea = - Marshal.ByteArrayToStructureBigEndianGenerated(sector, + Marshal.ByteArrayToStructureBigEndian(sector, systemAreaStart, _cdiSystemAreaSize); diff --git a/Aaru.Filesystems/ISO9660/Info.cs b/Aaru.Filesystems/ISO9660/Info.cs index d554b4a21..7847824e8 100644 --- a/Aaru.Filesystems/ISO9660/Info.cs +++ b/Aaru.Filesystems/ISO9660/Info.cs @@ -185,7 +185,7 @@ public sealed partial class ISO9660 if(highSierraInfo) hsvd = Marshal.ByteArrayToStructureLittleEndian(vdSector); else if(cdiInfo) - fsvd = Marshal.ByteArrayToStructureBigEndianGenerated(vdSector); + fsvd = Marshal.ByteArrayToStructureBigEndian(vdSector); else pvd = Marshal.ByteArrayToStructureLittleEndian(vdSector); @@ -319,7 +319,7 @@ public sealed partial class ISO9660 if(Marshal.SizeOf() + saOff <= saLen) { - CdromXa xa = Marshal.ByteArrayToStructureBigEndianGenerated(sa); + CdromXa xa = Marshal.ByteArrayToStructureBigEndian(sa); if(xa.signature == XA_MAGIC) { @@ -397,7 +397,7 @@ public sealed partial class ISO9660 Array.Copy(sa, saOff, ce, 0, ce.Length); ContinuationArea ca = - Marshal.ByteArrayToStructureBigEndianGenerated(ce); + Marshal.ByteArrayToStructureBigEndian(ce); contareas.Add(ca); @@ -515,7 +515,7 @@ public sealed partial class ISO9660 foreach(byte[] erb in refareas) { - ReferenceArea er = Marshal.ByteArrayToStructureBigEndianGenerated(erb); + ReferenceArea er = Marshal.ByteArrayToStructureBigEndian(erb); string extId = encoding.GetString(erb, Marshal.SizeOf(), er.id_len); string extDes = encoding.GetString(erb, Marshal.SizeOf() + er.id_len, er.des_len); diff --git a/Aaru.Filesystems/ISO9660/PathTable.cs b/Aaru.Filesystems/ISO9660/PathTable.cs index 70e305688..1a6dbbdbc 100644 --- a/Aaru.Filesystems/ISO9660/PathTable.cs +++ b/Aaru.Filesystems/ISO9660/PathTable.cs @@ -43,7 +43,7 @@ public sealed partial class ISO9660 var off = 0; PathTableEntry entry = - Marshal.ByteArrayToStructureBigEndianGenerated(data, off, Marshal.SizeOf()); + Marshal.ByteArrayToStructureBigEndian(data, off, Marshal.SizeOf()); if(entry.name_len != 1 || entry.parent_dirno != 1 || @@ -53,7 +53,7 @@ public sealed partial class ISO9660 while(off < data.Length) { - entry = Marshal.ByteArrayToStructureBigEndianGenerated(data, + entry = Marshal.ByteArrayToStructureBigEndian(data, off, Marshal.SizeOf()); @@ -90,7 +90,7 @@ public sealed partial class ISO9660 while(off < data.Length) { HighSierraPathTableEntry entry = - Marshal.ByteArrayToStructureBigEndianGenerated(data, + Marshal.ByteArrayToStructureBigEndian(data, off, Marshal.SizeOf()); diff --git a/Aaru.Filesystems/ISO9660/Super.cs b/Aaru.Filesystems/ISO9660/Super.cs index 6180d9ffb..5d5628632 100644 --- a/Aaru.Filesystems/ISO9660/Super.cs +++ b/Aaru.Filesystems/ISO9660/Super.cs @@ -182,7 +182,7 @@ public sealed partial class ISO9660 if(_highSierra) hsvd = Marshal.ByteArrayToStructureLittleEndian(vdSector); else if(_cdi) - fsvd = Marshal.ByteArrayToStructureBigEndianGenerated(vdSector); + fsvd = Marshal.ByteArrayToStructureBigEndian(vdSector); else pvd = Marshal.ByteArrayToStructureLittleEndian(vdSector); @@ -423,7 +423,7 @@ public sealed partial class ISO9660 if(errno != ErrorNumber.NoError) return errno; CdiDirectoryRecord rootEntry = - Marshal.ByteArrayToStructureBigEndianGenerated(firstRootSector); + Marshal.ByteArrayToStructureBigEndian(firstRootSector); rootSize = rootEntry.size; diff --git a/Aaru.Filesystems/LIF/Info.cs b/Aaru.Filesystems/LIF/Info.cs index e470da253..d9ef826d2 100644 --- a/Aaru.Filesystems/LIF/Info.cs +++ b/Aaru.Filesystems/LIF/Info.cs @@ -52,7 +52,7 @@ public sealed partial class LIF if(errno != ErrorNumber.NoError) return false; - SystemBlock lifSb = Marshal.ByteArrayToStructureBigEndianGenerated(sector); + SystemBlock lifSb = Marshal.ByteArrayToStructureBigEndian(sector); AaruLogging.Debug(MODULE_NAME, Localization.magic_0_expected_1, lifSb.magic, LIF_MAGIC); return lifSb.magic == LIF_MAGIC; @@ -72,7 +72,7 @@ public sealed partial class LIF if(errno != ErrorNumber.NoError) return; - SystemBlock lifSb = Marshal.ByteArrayToStructureBigEndianGenerated(sector); + SystemBlock lifSb = Marshal.ByteArrayToStructureBigEndian(sector); if(lifSb.magic != LIF_MAGIC) return; diff --git a/Aaru.Filesystems/Locus/Info.cs b/Aaru.Filesystems/Locus/Info.cs index 673b6fb40..ea95e2733 100644 --- a/Aaru.Filesystems/Locus/Info.cs +++ b/Aaru.Filesystems/Locus/Info.cs @@ -128,7 +128,7 @@ public sealed partial class Locus // Numerical arrays are not important for information so no need to swap them if(locusSb.s_magic is LOCUS_CIGAM or LOCUS_CIGAM_OLD) { - locusSb = Marshal.ByteArrayToStructureBigEndianGenerated(sector); + locusSb = Marshal.ByteArrayToStructureBigEndian(sector); locusSb.s_flags = (Flags)Swapping.Swap((ushort)locusSb.s_flags); } diff --git a/Aaru.Filesystems/MinixFS/Info.cs b/Aaru.Filesystems/MinixFS/Info.cs index ed545f342..b6221202b 100644 --- a/Aaru.Filesystems/MinixFS/Info.cs +++ b/Aaru.Filesystems/MinixFS/Info.cs @@ -224,7 +224,7 @@ public sealed partial class MinixFS { SuperBlock3 mnxSb = littleEndian ? Marshal.ByteArrayToStructureLittleEndian(minixSbSector) - : Marshal.ByteArrayToStructureBigEndianGenerated(minixSbSector); + : Marshal.ByteArrayToStructureBigEndian(minixSbSector); if(magic != MINIX3_MAGIC && magic != MINIX3_CIGAM) mnxSb.s_blocksize = 1024; @@ -268,7 +268,7 @@ public sealed partial class MinixFS { SuperBlock mnxSb = littleEndian ? Marshal.ByteArrayToStructureLittleEndian(minixSbSector) - : Marshal.ByteArrayToStructureBigEndianGenerated(minixSbSector); + : Marshal.ByteArrayToStructureBigEndian(minixSbSector); sb.AppendLine(minixVersion); sb.AppendFormat(Localization._0_chars_in_filename, filenamesize).AppendLine(); diff --git a/Aaru.Filesystems/Opera/Dir.cs b/Aaru.Filesystems/Opera/Dir.cs index 2fe9a01dd..19aa7666f 100644 --- a/Aaru.Filesystems/Opera/Dir.cs +++ b/Aaru.Filesystems/Opera/Dir.cs @@ -171,7 +171,7 @@ public sealed partial class OperaFS if(errno != ErrorNumber.NoError) break; - header = Marshal.ByteArrayToStructureBigEndianGenerated(data); + header = Marshal.ByteArrayToStructureBigEndian(data); nextBlock = header.next_block + firstBlock; var off = (int)header.first_used; @@ -180,7 +180,7 @@ public sealed partial class OperaFS while(off + _directoryEntrySize < data.Length) { - entry = Marshal.ByteArrayToStructureBigEndianGenerated(data, off, _directoryEntrySize); + entry = Marshal.ByteArrayToStructureBigEndian(data, off, _directoryEntrySize); string name = StringHandlers.CToString(entry.name, _encoding); var entryWithPointers = new DirectoryEntryWithPointers diff --git a/Aaru.Filesystems/Opera/Info.cs b/Aaru.Filesystems/Opera/Info.cs index b90a3d6b6..72a476e00 100644 --- a/Aaru.Filesystems/Opera/Info.cs +++ b/Aaru.Filesystems/Opera/Info.cs @@ -74,7 +74,7 @@ public sealed partial class OperaFS if(errno != ErrorNumber.NoError) return; - SuperBlock sb = Marshal.ByteArrayToStructureBigEndianGenerated(sbSector); + SuperBlock sb = Marshal.ByteArrayToStructureBigEndian(sbSector); if(sb.record_type != 1 || sb.record_version != 1) return; diff --git a/Aaru.Filesystems/Opera/Super.cs b/Aaru.Filesystems/Opera/Super.cs index 86e8993e9..54a216de0 100644 --- a/Aaru.Filesystems/Opera/Super.cs +++ b/Aaru.Filesystems/Opera/Super.cs @@ -57,7 +57,7 @@ public sealed partial class OperaFS if(errno != ErrorNumber.NoError) return errno; - SuperBlock sb = Marshal.ByteArrayToStructureBigEndianGenerated(sbSector); + SuperBlock sb = Marshal.ByteArrayToStructureBigEndian(sbSector); if(sb.record_type != 1 || sb.record_version != 1) return ErrorNumber.InvalidArgument; diff --git a/Aaru.Filesystems/PFS/Info.cs b/Aaru.Filesystems/PFS/Info.cs index 9f4f87040..d8d1550b3 100644 --- a/Aaru.Filesystems/PFS/Info.cs +++ b/Aaru.Filesystems/PFS/Info.cs @@ -68,7 +68,7 @@ public sealed partial class PFS if(errno != ErrorNumber.NoError) return; - RootBlock rootBlock = Marshal.ByteArrayToStructureBigEndianGenerated(rootBlockSector); + RootBlock rootBlock = Marshal.ByteArrayToStructureBigEndian(rootBlockSector); var sbInformation = new StringBuilder(); metadata = new FileSystem(); diff --git a/Aaru.Filesystems/RBF/Info.cs b/Aaru.Filesystems/RBF/Info.cs index 2ef9878b0..63f696a22 100644 --- a/Aaru.Filesystems/RBF/Info.cs +++ b/Aaru.Filesystems/RBF/Info.cs @@ -69,8 +69,8 @@ public sealed partial class RBF if(sector.Length < Marshal.SizeOf()) return false; - IdSector rbfSb = Marshal.ByteArrayToStructureBigEndianGenerated(sector); - NewIdSector rbf9000Sb = Marshal.ByteArrayToStructureBigEndianGenerated(sector); + IdSector rbfSb = Marshal.ByteArrayToStructureBigEndian(sector); + NewIdSector rbf9000Sb = Marshal.ByteArrayToStructureBigEndian(sector); AaruLogging.Debug(MODULE_NAME, Localization.magic_at_0_equals_1_or_2_expected_3_or_4, @@ -115,8 +115,8 @@ public sealed partial class RBF if(sector.Length < Marshal.SizeOf()) return; - rbfSb = Marshal.ByteArrayToStructureBigEndianGenerated(sector); - rbf9000Sb = Marshal.ByteArrayToStructureBigEndianGenerated(sector); + rbfSb = Marshal.ByteArrayToStructureBigEndian(sector); + rbf9000Sb = Marshal.ByteArrayToStructureBigEndian(sector); AaruLogging.Debug(MODULE_NAME, Localization.magic_at_0_equals_1_or_2_expected_3_or_4, diff --git a/Aaru.Filesystems/SFS/Info.cs b/Aaru.Filesystems/SFS/Info.cs index 0777499dd..e4a3efd01 100644 --- a/Aaru.Filesystems/SFS/Info.cs +++ b/Aaru.Filesystems/SFS/Info.cs @@ -65,7 +65,7 @@ public sealed partial class SFS if(errno != ErrorNumber.NoError) return; - RootBlock rootBlock = Marshal.ByteArrayToStructureBigEndianGenerated(rootBlockSector); + RootBlock rootBlock = Marshal.ByteArrayToStructureBigEndian(rootBlockSector); var sbInformation = new StringBuilder(); diff --git a/Aaru.Filesystems/Squash/Info.cs b/Aaru.Filesystems/Squash/Info.cs index 68b58c512..1b58d9ff4 100644 --- a/Aaru.Filesystems/Squash/Info.cs +++ b/Aaru.Filesystems/Squash/Info.cs @@ -78,7 +78,7 @@ public sealed partial class Squash break; case SQUASH_CIGAM: - sqSb = Marshal.ByteArrayToStructureBigEndianGenerated(sector); + sqSb = Marshal.ByteArrayToStructureBigEndian(sector); littleEndian = false; break; diff --git a/Aaru.Filesystems/UNICOS/Info.cs b/Aaru.Filesystems/UNICOS/Info.cs index e0bcfc0b3..5672263dc 100644 --- a/Aaru.Filesystems/UNICOS/Info.cs +++ b/Aaru.Filesystems/UNICOS/Info.cs @@ -61,7 +61,7 @@ public sealed partial class UNICOS if(sector.Length < Marshal.SizeOf()) return false; - Superblock unicosSb = Marshal.ByteArrayToStructureBigEndianGenerated(sector); + Superblock unicosSb = Marshal.ByteArrayToStructureBigEndian(sector); AaruLogging.Debug(MODULE_NAME, Localization.magic_equals_0_expected_1, unicosSb.s_magic, UNICOS_MAGIC); @@ -88,7 +88,7 @@ public sealed partial class UNICOS if(sector.Length < Marshal.SizeOf()) return; - Superblock unicosSb = Marshal.ByteArrayToStructureBigEndianGenerated(sector); + Superblock unicosSb = Marshal.ByteArrayToStructureBigEndian(sector); if(unicosSb.s_magic != UNICOS_MAGIC) return; diff --git a/Aaru.Filesystems/XFS/Info.cs b/Aaru.Filesystems/XFS/Info.cs index ff77eb6a9..55a752dd5 100644 --- a/Aaru.Filesystems/XFS/Info.cs +++ b/Aaru.Filesystems/XFS/Info.cs @@ -70,7 +70,7 @@ public sealed partial class XFS { Array.Copy(sector, location, sbpiece, 0, Marshal.SizeOf()); - Superblock xfsSb = Marshal.ByteArrayToStructureBigEndianGenerated(sbpiece); + Superblock xfsSb = Marshal.ByteArrayToStructureBigEndian(sbpiece); AaruLogging.Debug(MODULE_NAME, Localization.magic_at_0_X3_equals_1_expected_2, @@ -100,7 +100,7 @@ public sealed partial class XFS if(sector.Length < Marshal.SizeOf()) return false; - Superblock xfsSb = Marshal.ByteArrayToStructureBigEndianGenerated(sector); + Superblock xfsSb = Marshal.ByteArrayToStructureBigEndian(sector); AaruLogging.Debug(MODULE_NAME, Localization.magic_at_0_equals_1_expected_2, @@ -147,7 +147,7 @@ public sealed partial class XFS { Array.Copy(sector, location, sbpiece, 0, Marshal.SizeOf()); - xfsSb = Marshal.ByteArrayToStructureBigEndianGenerated(sbpiece); + xfsSb = Marshal.ByteArrayToStructureBigEndian(sbpiece); AaruLogging.Debug(MODULE_NAME, Localization.magic_at_0_X3_equals_1_expected_2, @@ -174,7 +174,7 @@ public sealed partial class XFS if(errno != ErrorNumber.NoError || sector.Length < Marshal.SizeOf()) return; - xfsSb = Marshal.ByteArrayToStructureBigEndianGenerated(sector); + xfsSb = Marshal.ByteArrayToStructureBigEndian(sector); AaruLogging.Debug(MODULE_NAME, Localization.magic_at_0_equals_1_expected_2, diff --git a/Aaru.Filesystems/dump/Info.cs b/Aaru.Filesystems/dump/Info.cs index 102227f2f..54a728d0a 100644 --- a/Aaru.Filesystems/dump/Info.cs +++ b/Aaru.Filesystems/dump/Info.cs @@ -121,13 +121,13 @@ public sealed partial class Dump newHdr.c_magic == UFS2_CIGAM) { if(newHdr.c_magic == OFS_CIGAM || newHdr.c_magic == NFS_CIGAM || newHdr.c_magic == UFS2_CIGAM) - newHdr = Marshal.ByteArrayToStructureBigEndianGenerated(sector); + newHdr = Marshal.ByteArrayToStructureBigEndian(sector); } else if(aixHdr.c_magic is XIX_MAGIC or XIX_CIGAM) { useAix = true; - if(aixHdr.c_magic == XIX_CIGAM) aixHdr = Marshal.ByteArrayToStructureBigEndianGenerated(sector); + if(aixHdr.c_magic == XIX_CIGAM) aixHdr = Marshal.ByteArrayToStructureBigEndian(sector); } else if(oldHdr.c_magic == OFS_MAGIC) { diff --git a/Aaru.Filters/AppleDouble.cs b/Aaru.Filters/AppleDouble.cs index 2b260dc2f..c422a9b20 100644 --- a/Aaru.Filters/AppleDouble.cs +++ b/Aaru.Filters/AppleDouble.cs @@ -172,7 +172,7 @@ public sealed partial class AppleDouble : IFilter { var prodosB = new byte[26]; prodosStream.EnsureRead(prodosB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndianGenerated
(prodosB); + _header = Marshal.ByteArrayToStructureBigEndian
(prodosB); prodosStream.Close(); if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) return true; @@ -188,7 +188,7 @@ public sealed partial class AppleDouble : IFilter { var unixB = new byte[26]; unixStream.EnsureRead(unixB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndianGenerated
(unixB); + _header = Marshal.ByteArrayToStructureBigEndian
(unixB); unixStream.Close(); if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) return true; @@ -204,7 +204,7 @@ public sealed partial class AppleDouble : IFilter { var dosB = new byte[26]; dosStream.EnsureRead(dosB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndianGenerated
(dosB); + _header = Marshal.ByteArrayToStructureBigEndian
(dosB); dosStream.Close(); if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) return true; @@ -220,7 +220,7 @@ public sealed partial class AppleDouble : IFilter { var doslB = new byte[26]; doslStream.EnsureRead(doslB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndianGenerated
(doslB); + _header = Marshal.ByteArrayToStructureBigEndian
(doslB); doslStream.Close(); if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) return true; @@ -236,7 +236,7 @@ public sealed partial class AppleDouble : IFilter { var netatalkB = new byte[26]; netatalkStream.EnsureRead(netatalkB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndianGenerated
(netatalkB); + _header = Marshal.ByteArrayToStructureBigEndian
(netatalkB); netatalkStream.Close(); if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) return true; @@ -252,7 +252,7 @@ public sealed partial class AppleDouble : IFilter { var daveB = new byte[26]; daveStream.EnsureRead(daveB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndianGenerated
(daveB); + _header = Marshal.ByteArrayToStructureBigEndian
(daveB); daveStream.Close(); if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) return true; @@ -268,7 +268,7 @@ public sealed partial class AppleDouble : IFilter { var osxB = new byte[26]; osxStream.EnsureRead(osxB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndianGenerated
(osxB); + _header = Marshal.ByteArrayToStructureBigEndian
(osxB); osxStream.Close(); if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) return true; @@ -284,7 +284,7 @@ public sealed partial class AppleDouble : IFilter var unarB = new byte[26]; unarStream.EnsureRead(unarB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndianGenerated
(unarB); + _header = Marshal.ByteArrayToStructureBigEndian
(unarB); unarStream.Close(); return _header is { magic: MAGIC, version: VERSION or VERSION2 }; @@ -342,7 +342,7 @@ public sealed partial class AppleDouble : IFilter { var prodosB = new byte[26]; prodosStream.EnsureRead(prodosB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndianGenerated
(prodosB); + _header = Marshal.ByteArrayToStructureBigEndian
(prodosB); prodosStream.Close(); if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) _headerPath = proDosAppleDouble; @@ -358,7 +358,7 @@ public sealed partial class AppleDouble : IFilter { var unixB = new byte[26]; unixStream.EnsureRead(unixB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndianGenerated
(unixB); + _header = Marshal.ByteArrayToStructureBigEndian
(unixB); unixStream.Close(); if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) _headerPath = unixAppleDouble; @@ -374,7 +374,7 @@ public sealed partial class AppleDouble : IFilter { var dosB = new byte[26]; dosStream.EnsureRead(dosB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndianGenerated
(dosB); + _header = Marshal.ByteArrayToStructureBigEndian
(dosB); dosStream.Close(); if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) _headerPath = dosAppleDouble; @@ -390,7 +390,7 @@ public sealed partial class AppleDouble : IFilter { var doslB = new byte[26]; doslStream.EnsureRead(doslB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndianGenerated
(doslB); + _header = Marshal.ByteArrayToStructureBigEndian
(doslB); doslStream.Close(); if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) _headerPath = dosAppleDoubleLower; @@ -406,7 +406,7 @@ public sealed partial class AppleDouble : IFilter { var netatalkB = new byte[26]; netatalkStream.EnsureRead(netatalkB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndianGenerated
(netatalkB); + _header = Marshal.ByteArrayToStructureBigEndian
(netatalkB); netatalkStream.Close(); if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) _headerPath = netatalkAppleDouble; @@ -422,7 +422,7 @@ public sealed partial class AppleDouble : IFilter { var daveB = new byte[26]; daveStream.EnsureRead(daveB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndianGenerated
(daveB); + _header = Marshal.ByteArrayToStructureBigEndian
(daveB); daveStream.Close(); if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) _headerPath = daveAppleDouble; @@ -438,7 +438,7 @@ public sealed partial class AppleDouble : IFilter { var osxB = new byte[26]; osxStream.EnsureRead(osxB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndianGenerated
(osxB); + _header = Marshal.ByteArrayToStructureBigEndian
(osxB); osxStream.Close(); if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) _headerPath = osxAppleDouble; @@ -454,7 +454,7 @@ public sealed partial class AppleDouble : IFilter { var unarB = new byte[26]; unarStream.EnsureRead(unarB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndianGenerated
(unarB); + _header = Marshal.ByteArrayToStructureBigEndian
(unarB); unarStream.Close(); if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) _headerPath = unArAppleDouble; @@ -469,7 +469,7 @@ public sealed partial class AppleDouble : IFilter var hdrB = new byte[26]; fs.EnsureRead(hdrB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndianGenerated
(hdrB); + _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); var entries = new Entry[_header.entries]; @@ -477,7 +477,7 @@ public sealed partial class AppleDouble : IFilter { var entry = new byte[12]; fs.EnsureRead(entry, 0, 12); - entries[i] = Marshal.ByteArrayToStructureBigEndianGenerated(entry); + entries[i] = Marshal.ByteArrayToStructureBigEndian(entry); } CreationTime = DateTime.UtcNow; @@ -495,7 +495,7 @@ public sealed partial class AppleDouble : IFilter var datesB = new byte[16]; fs.EnsureRead(datesB, 0, 16); - FileDates dates = Marshal.ByteArrayToStructureBigEndianGenerated(datesB); + FileDates dates = Marshal.ByteArrayToStructureBigEndian(datesB); CreationTime = DateHandlers.UnixUnsignedToDateTime(dates.creationDate); LastWriteTime = DateHandlers.UnixUnsignedToDateTime(dates.modificationDate); @@ -508,7 +508,7 @@ public sealed partial class AppleDouble : IFilter if(_macintoshHome.SequenceEqual(_header.homeFilesystem)) { - MacFileInfo macinfo = Marshal.ByteArrayToStructureBigEndianGenerated(finfo); + MacFileInfo macinfo = Marshal.ByteArrayToStructureBigEndian(finfo); CreationTime = DateHandlers.MacToDateTime(macinfo.creationDate); LastWriteTime = DateHandlers.MacToDateTime(macinfo.modificationDate); @@ -516,21 +516,21 @@ public sealed partial class AppleDouble : IFilter else if(_proDosHome.SequenceEqual(_header.homeFilesystem)) { ProDOSFileInfo prodosinfo = - Marshal.ByteArrayToStructureBigEndianGenerated(finfo); + Marshal.ByteArrayToStructureBigEndian(finfo); CreationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate); LastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate); } else if(_unixHome.SequenceEqual(_header.homeFilesystem)) { - UnixFileInfo unixinfo = Marshal.ByteArrayToStructureBigEndianGenerated(finfo); + UnixFileInfo unixinfo = Marshal.ByteArrayToStructureBigEndian(finfo); CreationTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.creationDate); LastWriteTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.modificationDate); } else if(_dosHome.SequenceEqual(_header.homeFilesystem)) { - DOSFileInfo dosinfo = Marshal.ByteArrayToStructureBigEndianGenerated(finfo); + DOSFileInfo dosinfo = Marshal.ByteArrayToStructureBigEndian(finfo); LastWriteTime = DateHandlers.DosToDateTime(dosinfo.modificationDate, dosinfo.modificationTime); } diff --git a/Aaru.Filters/AppleSingle.cs b/Aaru.Filters/AppleSingle.cs index 5245b94df..34d28ed28 100644 --- a/Aaru.Filters/AppleSingle.cs +++ b/Aaru.Filters/AppleSingle.cs @@ -165,7 +165,7 @@ public sealed partial class AppleSingle : IFilter var hdrB = new byte[26]; Array.Copy(buffer, 0, hdrB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndianGenerated
(hdrB); + _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); return _header is { magic: MAGIC, version: VERSION or VERSION2 }; } @@ -178,7 +178,7 @@ public sealed partial class AppleSingle : IFilter var hdrB = new byte[26]; stream.Seek(0, SeekOrigin.Begin); stream.EnsureRead(hdrB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndianGenerated
(hdrB); + _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); return _header is { magic: MAGIC, version: VERSION or VERSION2 }; } @@ -194,7 +194,7 @@ public sealed partial class AppleSingle : IFilter var hdrB = new byte[26]; fstream.EnsureRead(hdrB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndianGenerated
(hdrB); + _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); fstream.Close(); @@ -209,7 +209,7 @@ public sealed partial class AppleSingle : IFilter var hdrB = new byte[26]; ms.EnsureRead(hdrB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndianGenerated
(hdrB); + _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); var entries = new Entry[_header.entries]; @@ -217,7 +217,7 @@ public sealed partial class AppleSingle : IFilter { var entry = new byte[12]; ms.EnsureRead(entry, 0, 12); - entries[i] = Marshal.ByteArrayToStructureBigEndianGenerated(entry); + entries[i] = Marshal.ByteArrayToStructureBigEndian(entry); } CreationTime = DateTime.UtcNow; @@ -236,7 +236,7 @@ public sealed partial class AppleSingle : IFilter var datesB = new byte[16]; ms.EnsureRead(datesB, 0, 16); - FileDates dates = Marshal.ByteArrayToStructureBigEndianGenerated(datesB); + FileDates dates = Marshal.ByteArrayToStructureBigEndian(datesB); CreationTime = DateHandlers.UnixUnsignedToDateTime(dates.creationDate); LastWriteTime = DateHandlers.UnixUnsignedToDateTime(dates.modificationDate); @@ -249,7 +249,7 @@ public sealed partial class AppleSingle : IFilter if(_macintoshHome.SequenceEqual(_header.homeFilesystem)) { - MacFileInfo macinfo = Marshal.ByteArrayToStructureBigEndianGenerated(finfo); + MacFileInfo macinfo = Marshal.ByteArrayToStructureBigEndian(finfo); CreationTime = DateHandlers.MacToDateTime(macinfo.creationDate); LastWriteTime = DateHandlers.MacToDateTime(macinfo.modificationDate); @@ -257,21 +257,21 @@ public sealed partial class AppleSingle : IFilter else if(_proDosHome.SequenceEqual(_header.homeFilesystem)) { ProDOSFileInfo prodosinfo = - Marshal.ByteArrayToStructureBigEndianGenerated(finfo); + Marshal.ByteArrayToStructureBigEndian(finfo); CreationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate); LastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate); } else if(_unixHome.SequenceEqual(_header.homeFilesystem)) { - UnixFileInfo unixinfo = Marshal.ByteArrayToStructureBigEndianGenerated(finfo); + UnixFileInfo unixinfo = Marshal.ByteArrayToStructureBigEndian(finfo); CreationTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.creationDate); LastWriteTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.modificationDate); } else if(_dosHome.SequenceEqual(_header.homeFilesystem)) { - DOSFileInfo dosinfo = Marshal.ByteArrayToStructureBigEndianGenerated(finfo); + DOSFileInfo dosinfo = Marshal.ByteArrayToStructureBigEndian(finfo); LastWriteTime = DateHandlers.DosToDateTime(dosinfo.modificationDate, dosinfo.modificationTime); } @@ -298,7 +298,7 @@ public sealed partial class AppleSingle : IFilter var hdrB = new byte[26]; stream.EnsureRead(hdrB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndianGenerated
(hdrB); + _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); var entries = new Entry[_header.entries]; @@ -306,7 +306,7 @@ public sealed partial class AppleSingle : IFilter { var entry = new byte[12]; stream.EnsureRead(entry, 0, 12); - entries[i] = Marshal.ByteArrayToStructureBigEndianGenerated(entry); + entries[i] = Marshal.ByteArrayToStructureBigEndian(entry); } CreationTime = DateTime.UtcNow; @@ -325,7 +325,7 @@ public sealed partial class AppleSingle : IFilter var datesB = new byte[16]; stream.EnsureRead(datesB, 0, 16); - FileDates dates = Marshal.ByteArrayToStructureBigEndianGenerated(datesB); + FileDates dates = Marshal.ByteArrayToStructureBigEndian(datesB); CreationTime = DateHandlers.MacToDateTime(dates.creationDate); LastWriteTime = DateHandlers.MacToDateTime(dates.modificationDate); @@ -338,7 +338,7 @@ public sealed partial class AppleSingle : IFilter if(_macintoshHome.SequenceEqual(_header.homeFilesystem)) { - MacFileInfo macinfo = Marshal.ByteArrayToStructureBigEndianGenerated(finfo); + MacFileInfo macinfo = Marshal.ByteArrayToStructureBigEndian(finfo); CreationTime = DateHandlers.MacToDateTime(macinfo.creationDate); LastWriteTime = DateHandlers.MacToDateTime(macinfo.modificationDate); @@ -346,21 +346,21 @@ public sealed partial class AppleSingle : IFilter else if(_proDosHome.SequenceEqual(_header.homeFilesystem)) { ProDOSFileInfo prodosinfo = - Marshal.ByteArrayToStructureBigEndianGenerated(finfo); + Marshal.ByteArrayToStructureBigEndian(finfo); CreationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate); LastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate); } else if(_unixHome.SequenceEqual(_header.homeFilesystem)) { - UnixFileInfo unixinfo = Marshal.ByteArrayToStructureBigEndianGenerated(finfo); + UnixFileInfo unixinfo = Marshal.ByteArrayToStructureBigEndian(finfo); CreationTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.creationDate); LastWriteTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.modificationDate); } else if(_dosHome.SequenceEqual(_header.homeFilesystem)) { - DOSFileInfo dosinfo = Marshal.ByteArrayToStructureBigEndianGenerated(finfo); + DOSFileInfo dosinfo = Marshal.ByteArrayToStructureBigEndian(finfo); LastWriteTime = DateHandlers.DosToDateTime(dosinfo.modificationDate, dosinfo.modificationTime); } @@ -388,7 +388,7 @@ public sealed partial class AppleSingle : IFilter var hdrB = new byte[26]; fs.EnsureRead(hdrB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndianGenerated
(hdrB); + _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); var entries = new Entry[_header.entries]; @@ -396,7 +396,7 @@ public sealed partial class AppleSingle : IFilter { var entry = new byte[12]; fs.EnsureRead(entry, 0, 12); - entries[i] = Marshal.ByteArrayToStructureBigEndianGenerated(entry); + entries[i] = Marshal.ByteArrayToStructureBigEndian(entry); } CreationTime = DateTime.UtcNow; @@ -415,7 +415,7 @@ public sealed partial class AppleSingle : IFilter var datesB = new byte[16]; fs.EnsureRead(datesB, 0, 16); - FileDates dates = Marshal.ByteArrayToStructureBigEndianGenerated(datesB); + FileDates dates = Marshal.ByteArrayToStructureBigEndian(datesB); CreationTime = DateHandlers.MacToDateTime(dates.creationDate); LastWriteTime = DateHandlers.MacToDateTime(dates.modificationDate); @@ -428,7 +428,7 @@ public sealed partial class AppleSingle : IFilter if(_macintoshHome.SequenceEqual(_header.homeFilesystem)) { - MacFileInfo macinfo = Marshal.ByteArrayToStructureBigEndianGenerated(finfo); + MacFileInfo macinfo = Marshal.ByteArrayToStructureBigEndian(finfo); CreationTime = DateHandlers.MacToDateTime(macinfo.creationDate); LastWriteTime = DateHandlers.MacToDateTime(macinfo.modificationDate); @@ -436,21 +436,21 @@ public sealed partial class AppleSingle : IFilter else if(_proDosHome.SequenceEqual(_header.homeFilesystem)) { ProDOSFileInfo prodosinfo = - Marshal.ByteArrayToStructureBigEndianGenerated(finfo); + Marshal.ByteArrayToStructureBigEndian(finfo); CreationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate); LastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate); } else if(_unixHome.SequenceEqual(_header.homeFilesystem)) { - UnixFileInfo unixinfo = Marshal.ByteArrayToStructureBigEndianGenerated(finfo); + UnixFileInfo unixinfo = Marshal.ByteArrayToStructureBigEndian(finfo); CreationTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.creationDate); LastWriteTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.modificationDate); } else if(_dosHome.SequenceEqual(_header.homeFilesystem)) { - DOSFileInfo dosinfo = Marshal.ByteArrayToStructureBigEndianGenerated(finfo); + DOSFileInfo dosinfo = Marshal.ByteArrayToStructureBigEndian(finfo); LastWriteTime = DateHandlers.DosToDateTime(dosinfo.modificationDate, dosinfo.modificationTime); } diff --git a/Aaru.Filters/MacBinary.cs b/Aaru.Filters/MacBinary.cs index 6902a7f49..908511826 100644 --- a/Aaru.Filters/MacBinary.cs +++ b/Aaru.Filters/MacBinary.cs @@ -233,7 +233,7 @@ public sealed partial class MacBinary : IFilter var hdrB = new byte[128]; Array.Copy(buffer, 0, hdrB, 0, 128); - _header = Marshal.ByteArrayToStructureBigEndianGenerated
(hdrB); + _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); return _header.magic == MAGIC || _header.version == 0 && @@ -252,7 +252,7 @@ public sealed partial class MacBinary : IFilter var hdrB = new byte[128]; stream.Seek(0, SeekOrigin.Begin); stream.EnsureRead(hdrB, 0, 128); - _header = Marshal.ByteArrayToStructureBigEndianGenerated
(hdrB); + _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); return _header.magic == MAGIC || _header.version == 0 && @@ -274,7 +274,7 @@ public sealed partial class MacBinary : IFilter var hdrB = new byte[128]; fstream.EnsureRead(hdrB, 0, 128); - _header = Marshal.ByteArrayToStructureBigEndianGenerated
(hdrB); + _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); fstream.Close(); @@ -295,7 +295,7 @@ public sealed partial class MacBinary : IFilter var hdrB = new byte[128]; ms.EnsureRead(hdrB, 0, 128); - _header = Marshal.ByteArrayToStructureBigEndianGenerated
(hdrB); + _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); uint blocks = 1; blocks += (uint)(_header.secondaryHeaderLength / 128); @@ -327,7 +327,7 @@ public sealed partial class MacBinary : IFilter var hdrB = new byte[128]; stream.EnsureRead(hdrB, 0, 128); - _header = Marshal.ByteArrayToStructureBigEndianGenerated
(hdrB); + _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); uint blocks = 1; blocks += (uint)(_header.secondaryHeaderLength / 128); @@ -360,7 +360,7 @@ public sealed partial class MacBinary : IFilter var hdrB = new byte[128]; fs.EnsureRead(hdrB, 0, 128); - _header = Marshal.ByteArrayToStructureBigEndianGenerated
(hdrB); + _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); uint blocks = 1; blocks += (uint)(_header.secondaryHeaderLength / 128); diff --git a/Aaru.Filters/PCExchange.cs b/Aaru.Filters/PCExchange.cs index d50a0dd1e..b0636e8b4 100644 --- a/Aaru.Filters/PCExchange.cs +++ b/Aaru.Filters/PCExchange.cs @@ -137,7 +137,7 @@ public sealed partial class PcExchange : IFilter var datEntry = new Entry(); var datEntryB = new byte[Marshal.SizeOf(datEntry)]; finderDatStream.EnsureRead(datEntryB, 0, Marshal.SizeOf(datEntry)); - datEntry = Helpers.Marshal.ByteArrayToStructureBigEndianGenerated(datEntryB); + datEntry = Helpers.Marshal.ByteArrayToStructureBigEndian(datEntryB); // TODO: Add support for encoding on filters string macName = StringHandlers.PascalToString(datEntry.macName, Encoding.GetEncoding("macintosh")); @@ -194,7 +194,7 @@ public sealed partial class PcExchange : IFilter var datEntry = new Entry(); var datEntryB = new byte[Marshal.SizeOf(datEntry)]; finderDatStream.EnsureRead(datEntryB, 0, Marshal.SizeOf(datEntry)); - datEntry = Helpers.Marshal.ByteArrayToStructureBigEndianGenerated(datEntryB); + datEntry = Helpers.Marshal.ByteArrayToStructureBigEndian(datEntryB); string macName = StringHandlers.PascalToString(datEntry.macName, Encoding.GetEncoding("macintosh")); diff --git a/Aaru.Helpers/Marshal.cs b/Aaru.Helpers/Marshal.cs index 7585852a5..2081d55ae 100644 --- a/Aaru.Helpers/Marshal.cs +++ b/Aaru.Helpers/Marshal.cs @@ -80,32 +80,14 @@ public static class Marshal return ByteArrayToStructureLittleEndian(span.Slice(start, length).ToArray()); } - /// Marshal big-endian binary data to a structure - /// Byte array containing the binary data - /// Type of the structure to marshal - /// The binary data marshalled in a structure with the specified type - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static T ByteArrayToStructureBigEndian(byte[] bytes) where T : struct - { - var ptr = GCHandle.Alloc(bytes, GCHandleType.Pinned); - - object str = (T)(System.Runtime.InteropServices.Marshal.PtrToStructure(ptr.AddrOfPinnedObject(), typeof(T)) ?? - default(T)); - - ptr.Free(); - - return (T)SwapStructureMembersEndian(str); - } - /// /// Marshal big-endian binary data to a structure using compile-time generated swap method. - /// This method is faster than as it avoids boxing and reflection. /// /// Byte array containing the binary data /// Type of the structure to marshal (must be marked with [SwapEndian] attribute) /// The binary data marshalled in a structure with the specified type [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static T ByteArrayToStructureBigEndianGenerated(byte[] bytes) where T : struct, ISwapEndian + public static T ByteArrayToStructureBigEndian(byte[] bytes) where T : struct, ISwapEndian { T str = ByteArrayToStructureLittleEndian(bytes); @@ -114,8 +96,6 @@ public static class Marshal /// /// Marshal big-endian binary data to a structure using compile-time generated swap method. - /// This method is faster than as it avoids boxing - /// and reflection. /// /// Byte array containing the binary data /// Start on the array where the structure begins @@ -123,25 +103,11 @@ public static class Marshal /// Type of the structure to marshal (must be marked with [SwapEndian] attribute) /// The binary data marshalled in a structure with the specified type [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static T ByteArrayToStructureBigEndianGenerated(byte[] bytes, int start, int length) + public static T ByteArrayToStructureBigEndian(byte[] bytes, int start, int length) where T : struct, ISwapEndian { Span span = bytes; - return ByteArrayToStructureBigEndianGenerated(span.Slice(start, length).ToArray()); - } - - /// Marshal big-endian binary data to a structure - /// Byte array containing the binary data - /// Start on the array where the structure begins - /// Length of the structure in bytes - /// Type of the structure to marshal - /// The binary data marshalled in a structure with the specified type - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static T ByteArrayToStructureBigEndian(byte[] bytes, int start, int length) where T : struct - { - Span span = bytes; - return ByteArrayToStructureBigEndian(span.Slice(start, length).ToArray()); } @@ -203,32 +169,15 @@ public static class Marshal public static T SpanToStructureLittleEndian(ReadOnlySpan bytes, int start, int length) where T : struct => MemoryMarshal.Read(bytes.Slice(start, length)); - /// - /// Marshal big-endian binary data to a structure. If the structure type contains any non value type, this method - /// will crash. - /// - /// Byte array containing the binary data - /// Type of the structure to marshal - /// The binary data marshalled in a structure with the specified type - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static T SpanToStructureBigEndian(ReadOnlySpan bytes) where T : struct - { - T str = SpanToStructureLittleEndian(bytes); - - return (T)SwapStructureMembersEndian(str); - } - /// /// Marshal big-endian binary data to a structure using compile-time generated swap method. - /// This method is faster than as it avoids boxing and - /// reflection. /// If the structure type contains any non value type, this method will crash. /// /// Byte array containing the binary data /// Type of the structure to marshal (must be marked with [SwapEndian] attribute) /// The binary data marshalled in a structure with the specified type [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static T SpanToStructureBigEndianGenerated(ReadOnlySpan bytes) where T : struct, ISwapEndian + public static T SpanToStructureBigEndian(ReadOnlySpan bytes) where T : struct, ISwapEndian { T str = SpanToStructureLittleEndian(bytes); @@ -237,8 +186,6 @@ public static class Marshal /// /// Marshal big-endian binary data to a structure using compile-time generated swap method. - /// This method is faster than as it avoids - /// boxing and reflection. /// If the structure type contains any non value type, this method will crash. /// /// Byte span containing the binary data @@ -247,7 +194,7 @@ public static class Marshal /// Type of the structure to marshal (must be marked with [SwapEndian] attribute) /// The binary data marshalled in a structure with the specified type [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static T SpanToStructureBigEndianGenerated(ReadOnlySpan bytes, int start, int length) + public static T SpanToStructureBigEndian(ReadOnlySpan bytes, int start, int length) where T : struct, ISwapEndian { T str = SpanToStructureLittleEndian(bytes.Slice(start, length)); @@ -287,39 +234,6 @@ public static class Marshal return (T)SwapStructureMembersEndianPdp(str); } - /// - /// Marshal a structure depending on the decoration of . If the - /// decoration is not present it will marshal as a reference type containing little endian structure. - /// - /// Byte array containing the binary data - /// Type of the structure to marshal - /// The binary data marshalled in a structure with the specified type - /// - /// The contains an unsupported - /// endian - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static T MarshalStructure(byte[] bytes) where T : struct - { - if(typeof(T).GetCustomAttribute(typeof(MarshallingPropertiesAttribute)) is not MarshallingPropertiesAttribute - properties) - return ByteArrayToStructureLittleEndian(bytes); - - return properties.Endian switch - { - BitEndian.Little => properties.HasReferences - ? ByteArrayToStructureLittleEndian(bytes) - : SpanToStructureLittleEndian(bytes), - BitEndian.Big => properties.HasReferences - ? ByteArrayToStructureBigEndian(bytes) - : SpanToStructureBigEndian(bytes), - BitEndian.Pdp => properties.HasReferences - ? ByteArrayToStructurePdpEndian(bytes) - : SpanToStructurePdpEndian(bytes), - _ => throw new ArgumentOutOfRangeException() - }; - } - /// Swaps all members of a structure /// /// diff --git a/Aaru.Helpers/MarshallingPropertiesAttribute.cs b/Aaru.Helpers/MarshallingPropertiesAttribute.cs deleted file mode 100644 index 91353ed4d..000000000 --- a/Aaru.Helpers/MarshallingPropertiesAttribute.cs +++ /dev/null @@ -1,62 +0,0 @@ -// /*************************************************************************** -// Aaru Data Preservation Suite -// ---------------------------------------------------------------------------- -// -// Filename : MarshallingPropertiesAttribute.cs -// Author(s) : Natalia Portillo -// -// Component : Common types. -// -// --[ Description ] ---------------------------------------------------------- -// -// Declares properties of structs for marshalling. -// -// --[ License ] -------------------------------------------------------------- -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -// ---------------------------------------------------------------------------- -// Copyright © 2011-2025 Natalia Portillo -// ****************************************************************************/ - -using System; - -namespace Aaru.Helpers; - -/// -/// Defines properties to help marshalling structs from binary data -[AttributeUsage(AttributeTargets.Struct)] -public sealed class MarshallingPropertiesAttribute : Attribute -{ - /// - /// Defines properties to help marshalling structs from binary data - /// Defines properties to help marshalling structs from binary data - public MarshallingPropertiesAttribute(BitEndian endian) - { - Endian = endian; - HasReferences = true; - } - - /// c - public BitEndian Endian { get; } - - /// Tells if the structure, or any nested structure, has any non-value type (e.g. arrays, strings, etc). - public bool HasReferences { get; set; } -} \ No newline at end of file diff --git a/Aaru.Images/ByteAddressable/AtariLynx.cs b/Aaru.Images/ByteAddressable/AtariLynx.cs index 1b6d9a467..17051b207 100644 --- a/Aaru.Images/ByteAddressable/AtariLynx.cs +++ b/Aaru.Images/ByteAddressable/AtariLynx.cs @@ -103,7 +103,7 @@ public partial class AtariLynx : IByteAddressableImage MetadataMediaType = MetadataMediaType.LinearMedia }; - HandyHeader header = Marshal.ByteArrayToStructureBigEndianGenerated(headerBytes, 0, 64); + HandyHeader header = Marshal.ByteArrayToStructureBigEndian(headerBytes, 0, 64); if(header.Version != 256) return ErrorNumber.NotSupported; diff --git a/Aaru.Images/ByteAddressable/GameBoy.cs b/Aaru.Images/ByteAddressable/GameBoy.cs index f50646d25..3487cfc49 100644 --- a/Aaru.Images/ByteAddressable/GameBoy.cs +++ b/Aaru.Images/ByteAddressable/GameBoy.cs @@ -99,7 +99,7 @@ public partial class GameBoy : IByteAddressableImage MetadataMediaType = MetadataMediaType.LinearMedia }; - Header header = Marshal.ByteArrayToStructureBigEndianGenerated
(_data, 0x100, Marshal.SizeOf
()); + Header header = Marshal.ByteArrayToStructureBigEndian
(_data, 0x100, Marshal.SizeOf
()); var name = new byte[(header.Name[^1] & 0x80) == 0x80 ? 15 : 16]; Array.Copy(header.Name, 0, name, 0, name.Length); @@ -265,7 +265,7 @@ public partial class GameBoy : IByteAddressableImage return ErrorNumber.NotOpened; } - Header header = Marshal.ByteArrayToStructureBigEndianGenerated
(_data, 0x100, Marshal.SizeOf
()); + Header header = Marshal.ByteArrayToStructureBigEndian
(_data, 0x100, Marshal.SizeOf
()); var hasMapper = false; var hasSaveRam = false; diff --git a/Aaru.Images/ByteAddressable/GameBoyAdvance.cs b/Aaru.Images/ByteAddressable/GameBoyAdvance.cs index e36012db7..bff8dd7d9 100644 --- a/Aaru.Images/ByteAddressable/GameBoyAdvance.cs +++ b/Aaru.Images/ByteAddressable/GameBoyAdvance.cs @@ -98,7 +98,7 @@ public partial class GameBoyAdvance : IByteAddressableImage MetadataMediaType = MetadataMediaType.LinearMedia }; - Header header = Marshal.ByteArrayToStructureBigEndianGenerated
(_data, 0, Marshal.SizeOf
()); + Header header = Marshal.ByteArrayToStructureBigEndian
(_data, 0, Marshal.SizeOf
()); _imageInfo.MediaTitle = StringHandlers.CToString(header.Name); diff --git a/Aaru.Images/ByteAddressable/MasterSystem.cs b/Aaru.Images/ByteAddressable/MasterSystem.cs index 5e37afd93..a432f88d0 100644 --- a/Aaru.Images/ByteAddressable/MasterSystem.cs +++ b/Aaru.Images/ByteAddressable/MasterSystem.cs @@ -140,7 +140,7 @@ public partial class MasterSystem : IByteAddressableImage }; Header header = - Marshal.ByteArrayToStructureBigEndianGenerated
(_data, headerPosition, Marshal.SizeOf
()); + Marshal.ByteArrayToStructureBigEndian
(_data, headerPosition, Marshal.SizeOf
()); var sb = new StringBuilder(); diff --git a/Aaru.Images/ByteAddressable/Nintendo64.cs b/Aaru.Images/ByteAddressable/Nintendo64.cs index 89efe8994..6dce1d0c8 100644 --- a/Aaru.Images/ByteAddressable/Nintendo64.cs +++ b/Aaru.Images/ByteAddressable/Nintendo64.cs @@ -207,7 +207,7 @@ public partial class Nintendo64 : IByteAddressableImage _data = tmp; } - Header header = Marshal.ByteArrayToStructureBigEndianGenerated
(_data, 0, Marshal.SizeOf
()); + Header header = Marshal.ByteArrayToStructureBigEndian
(_data, 0, Marshal.SizeOf
()); Encoding encoding; try @@ -306,7 +306,7 @@ public partial class Nintendo64 : IByteAddressableImage LinearMemoryType saveType = LinearMemoryType.Unknown; ulong saveLength = 0; - Header header = Marshal.ByteArrayToStructureBigEndianGenerated
(_data, 0, Marshal.SizeOf
()); + Header header = Marshal.ByteArrayToStructureBigEndian
(_data, 0, Marshal.SizeOf
()); switch((char)header.CartridgeType) { diff --git a/Aaru.Images/ByteAddressable/SegaMegaDrive.cs b/Aaru.Images/ByteAddressable/SegaMegaDrive.cs index fad52d368..22420de00 100644 --- a/Aaru.Images/ByteAddressable/SegaMegaDrive.cs +++ b/Aaru.Images/ByteAddressable/SegaMegaDrive.cs @@ -225,7 +225,7 @@ public partial class SegaMegaDrive : IByteAddressableImage } SegaHeader header = - Marshal.ByteArrayToStructureBigEndianGenerated(_data, 0x100, Marshal.SizeOf()); + Marshal.ByteArrayToStructureBigEndian(_data, 0x100, Marshal.SizeOf()); Encoding encoding; @@ -540,7 +540,7 @@ public partial class SegaMegaDrive : IByteAddressableImage } SegaHeader header = - Marshal.ByteArrayToStructureBigEndianGenerated(_data, 0x100, Marshal.SizeOf()); + Marshal.ByteArrayToStructureBigEndian(_data, 0x100, Marshal.SizeOf()); bool extraRam = header.ExtraRamPresent[0] == 0x52 && header.ExtraRamPresent[1] == 0x41; diff --git a/Aaru.Images/CHD/Helpers.cs b/Aaru.Images/CHD/Helpers.cs index fab80d4f4..478480ad9 100644 --- a/Aaru.Images/CHD/Helpers.cs +++ b/Aaru.Images/CHD/Helpers.cs @@ -108,7 +108,7 @@ public sealed partial class Chd case 3: var entryBytes = new byte[16]; Array.Copy(_hunkMap, (int)(hunkNo * 16), entryBytes, 0, 16); - MapEntryV3 entry = Marshal.ByteArrayToStructureBigEndianGenerated(entryBytes); + MapEntryV3 entry = Marshal.ByteArrayToStructureBigEndian(entryBytes); switch((EntryFlagsV3)(entry.flags & 0x0F)) { diff --git a/Aaru.Images/CHD/Read.cs b/Aaru.Images/CHD/Read.cs index 250e77245..e9eb3f56a 100644 --- a/Aaru.Images/CHD/Read.cs +++ b/Aaru.Images/CHD/Read.cs @@ -84,7 +84,7 @@ public sealed partial class Chd { case 1: { - HeaderV1 hdrV1 = Marshal.ByteArrayToStructureBigEndianGenerated(buffer); + HeaderV1 hdrV1 = Marshal.ByteArrayToStructureBigEndian(buffer); AaruLogging.Debug(MODULE_NAME, "hdrV1.tag = \"{0}\"", Encoding.ASCII.GetString(hdrV1.tag)); @@ -159,7 +159,7 @@ public sealed partial class Chd case 2: { - HeaderV2 hdrV2 = Marshal.ByteArrayToStructureBigEndianGenerated(buffer); + HeaderV2 hdrV2 = Marshal.ByteArrayToStructureBigEndian(buffer); AaruLogging.Debug(MODULE_NAME, "hdrV2.tag = \"{0}\"", Encoding.ASCII.GetString(hdrV2.tag)); @@ -237,7 +237,7 @@ public sealed partial class Chd case 3: { - HeaderV3 hdrV3 = Marshal.ByteArrayToStructureBigEndianGenerated(buffer); + HeaderV3 hdrV3 = Marshal.ByteArrayToStructureBigEndian(buffer); AaruLogging.Debug(MODULE_NAME, "hdrV3.tag = \"{0}\"", Encoding.ASCII.GetString(hdrV3.tag)); @@ -293,7 +293,7 @@ public sealed partial class Chd case 4: { - HeaderV4 hdrV4 = Marshal.ByteArrayToStructureBigEndianGenerated(buffer); + HeaderV4 hdrV4 = Marshal.ByteArrayToStructureBigEndian(buffer); AaruLogging.Debug(MODULE_NAME, "hdrV4.tag = \"{0}\"", Encoding.ASCII.GetString(hdrV4.tag)); @@ -348,7 +348,7 @@ public sealed partial class Chd return ErrorNumber.NotImplemented; - HeaderV5 hdrV5 = Marshal.ByteArrayToStructureBigEndianGenerated(buffer); + HeaderV5 hdrV5 = Marshal.ByteArrayToStructureBigEndian(buffer); AaruLogging.Debug(MODULE_NAME, "hdrV5.tag = \"{0}\"", Encoding.ASCII.GetString(hdrV5.tag)); @@ -477,7 +477,7 @@ public sealed partial class Chd var hdrBytes = new byte[16]; stream.Seek((long)nextMetaOff, SeekOrigin.Begin); stream.EnsureRead(hdrBytes, 0, hdrBytes.Length); - MetadataHeader header = Marshal.ByteArrayToStructureBigEndianGenerated(hdrBytes); + MetadataHeader header = Marshal.ByteArrayToStructureBigEndian(hdrBytes); var meta = new byte[header.flagsAndLength & 0xFFFFFF]; stream.EnsureRead(meta, 0, meta.Length); diff --git a/Aaru.Images/DART/Identify.cs b/Aaru.Images/DART/Identify.cs index dcb9f6e44..e38312078 100644 --- a/Aaru.Images/DART/Identify.cs +++ b/Aaru.Images/DART/Identify.cs @@ -51,7 +51,7 @@ public sealed partial class Dart var headerB = new byte[Marshal.SizeOf
()]; stream.EnsureRead(headerB, 0, Marshal.SizeOf
()); - Header header = Marshal.ByteArrayToStructureBigEndianGenerated
(headerB); + Header header = Marshal.ByteArrayToStructureBigEndian
(headerB); if(header.srcCmp > COMPRESS_NONE) return false; diff --git a/Aaru.Images/DART/Read.cs b/Aaru.Images/DART/Read.cs index 86966f349..8be7369dd 100644 --- a/Aaru.Images/DART/Read.cs +++ b/Aaru.Images/DART/Read.cs @@ -61,7 +61,7 @@ public sealed partial class Dart var headerB = new byte[Marshal.SizeOf
()]; stream.EnsureRead(headerB, 0, Marshal.SizeOf
()); - Header header = Marshal.ByteArrayToStructureBigEndianGenerated
(headerB); + Header header = Marshal.ByteArrayToStructureBigEndian
(headerB); if(header.srcCmp > COMPRESS_NONE) return ErrorNumber.NotSupported; diff --git a/Aaru.Images/DiscFerret/Read.cs b/Aaru.Images/DiscFerret/Read.cs index e4501f6c7..9c8e9473c 100644 --- a/Aaru.Images/DiscFerret/Read.cs +++ b/Aaru.Images/DiscFerret/Read.cs @@ -66,7 +66,7 @@ public sealed partial class DiscFerret var blk = new byte[Marshal.SizeOf()]; stream.EnsureRead(blk, 0, Marshal.SizeOf()); - BlockHeader blockHeader = Marshal.ByteArrayToStructureBigEndianGenerated(blk); + BlockHeader blockHeader = Marshal.ByteArrayToStructureBigEndian(blk); AaruLogging.Debug(MODULE_NAME, "block@{0}.cylinder = {1}", thisOffset, blockHeader.cylinder); diff --git a/Aaru.Images/NDIF/Read.cs b/Aaru.Images/NDIF/Read.cs index 00e446830..926b44e21 100644 --- a/Aaru.Images/NDIF/Read.cs +++ b/Aaru.Images/NDIF/Read.cs @@ -85,7 +85,7 @@ public sealed partial class Ndif { if(bcem.Length < 128) return ErrorNumber.InvalidArgument; - _header = Marshal.ByteArrayToStructureBigEndianGenerated(bcem); + _header = Marshal.ByteArrayToStructureBigEndian(bcem); AaruLogging.Debug(MODULE_NAME, "footer.type = {0}", _header.version); AaruLogging.Debug(MODULE_NAME, "footer.driver = {0}", _header.driver); diff --git a/Aaru.Images/QCOW/Identify.cs b/Aaru.Images/QCOW/Identify.cs index ed3b3633a..95202a214 100644 --- a/Aaru.Images/QCOW/Identify.cs +++ b/Aaru.Images/QCOW/Identify.cs @@ -50,7 +50,7 @@ public sealed partial class Qcow var qHdrB = new byte[48]; stream.EnsureRead(qHdrB, 0, 48); - _qHdr = Marshal.SpanToStructureBigEndianGenerated
(qHdrB); + _qHdr = Marshal.SpanToStructureBigEndian
(qHdrB); return _qHdr is { magic: QCOW_MAGIC, version: QCOW_VERSION }; } diff --git a/Aaru.Images/QCOW/Read.cs b/Aaru.Images/QCOW/Read.cs index dc7e00f2c..2de3bb980 100644 --- a/Aaru.Images/QCOW/Read.cs +++ b/Aaru.Images/QCOW/Read.cs @@ -59,7 +59,7 @@ public sealed partial class Qcow var qHdrB = new byte[48]; stream.EnsureRead(qHdrB, 0, 48); - _qHdr = Marshal.SpanToStructureBigEndianGenerated
(qHdrB); + _qHdr = Marshal.SpanToStructureBigEndian
(qHdrB); AaruLogging.Debug(MODULE_NAME, "qHdr.magic = 0x{0:X8}", _qHdr.magic); AaruLogging.Debug(MODULE_NAME, "qHdr.version = {0}", _qHdr.version); diff --git a/Aaru.Images/QCOW2/Identify.cs b/Aaru.Images/QCOW2/Identify.cs index 88598e150..b02cf0d42 100644 --- a/Aaru.Images/QCOW2/Identify.cs +++ b/Aaru.Images/QCOW2/Identify.cs @@ -51,7 +51,7 @@ public sealed partial class Qcow2 var qHdrB = new byte[Marshal.SizeOf
()]; stream.EnsureRead(qHdrB, 0, Marshal.SizeOf
()); - _qHdr = Marshal.SpanToStructureBigEndianGenerated
(qHdrB); + _qHdr = Marshal.SpanToStructureBigEndian
(qHdrB); AaruLogging.Debug(MODULE_NAME, "qHdr.magic = 0x{0:X8}", _qHdr.magic); AaruLogging.Debug(MODULE_NAME, "qHdr.version = {0}", _qHdr.version); diff --git a/Aaru.Images/QCOW2/Read.cs b/Aaru.Images/QCOW2/Read.cs index d2a142532..c5b45d918 100644 --- a/Aaru.Images/QCOW2/Read.cs +++ b/Aaru.Images/QCOW2/Read.cs @@ -59,7 +59,7 @@ public sealed partial class Qcow2 var qHdrB = new byte[Marshal.SizeOf
()]; stream.EnsureRead(qHdrB, 0, Marshal.SizeOf
()); - _qHdr = Marshal.SpanToStructureBigEndianGenerated
(qHdrB); + _qHdr = Marshal.SpanToStructureBigEndian
(qHdrB); AaruLogging.Debug(MODULE_NAME, "qHdr.magic = 0x{0:X8}", _qHdr.magic); AaruLogging.Debug(MODULE_NAME, "qHdr.version = {0}", _qHdr.version); diff --git a/Aaru.Images/UDIF/Identify.cs b/Aaru.Images/UDIF/Identify.cs index e4f414578..31e9af1aa 100644 --- a/Aaru.Images/UDIF/Identify.cs +++ b/Aaru.Images/UDIF/Identify.cs @@ -51,7 +51,7 @@ public sealed partial class Udif var footerB = new byte[Marshal.SizeOf