Replace old bigendian marshaller with new one.

This commit is contained in:
2025-10-21 11:43:05 +01:00
parent 061669a255
commit 39f4ca2998
68 changed files with 188 additions and 336 deletions

View File

@@ -26,7 +26,7 @@ public sealed partial class Stfs
stream.ReadExactly(hdr, 0, hdr.Length);
RemotePackage header = Marshal.ByteArrayToStructureBigEndianGenerated<RemotePackage>(hdr);
RemotePackage header = Marshal.ByteArrayToStructureBigEndian<RemotePackage>(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<RemotePackage>(hdr);
RemotePackage header = Marshal.ByteArrayToStructureBigEndian<RemotePackage>(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<ConsolePackage>(hdr);
ConsolePackage consolePackage = Marshal.ByteArrayToStructureBigEndian<ConsolePackage>(hdr);
sb.AppendFormat(Localization.Certificate_owner_console_ID_0_1_2_3_4,
consolePackage.CertificateOwnerConsoleId[0],

View File

@@ -23,7 +23,7 @@ public sealed partial class Stfs
_stream.ReadExactly(hdr, 0, hdr.Length);
RemotePackage header = Marshal.ByteArrayToStructureBigEndianGenerated<RemotePackage>(hdr);
RemotePackage header = Marshal.ByteArrayToStructureBigEndian<RemotePackage>(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<FileTableEntry>(buffer, in_pos, entrySize);
FileTableEntry entry = Marshal.ByteArrayToStructureBigEndian<FileTableEntry>(buffer, in_pos, entrySize);
if(entry.FilenameLength == 0) break;

View File

@@ -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<RootBlock>(tmp);
RootBlock root = Marshal.ByteArrayToStructureBigEndian<RootBlock>(tmp);
root.hashTable = new uint[(block.Length - 224) / 4];
for(var i = 0; i < root.hashTable.Length; i++)

View File

@@ -60,7 +60,7 @@ public sealed partial class AmigaDOSPlugin
if(errno != ErrorNumber.NoError) return false;
BootBlock bblk = Marshal.ByteArrayToStructureBigEndianGenerated<BootBlock>(sector);
BootBlock bblk = Marshal.ByteArrayToStructureBigEndian<BootBlock>(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<BootBlock>(sector);
bblk = Marshal.ByteArrayToStructureBigEndian<BootBlock>(sector);
}
// Not FFS or MuFS?
@@ -166,7 +166,7 @@ public sealed partial class AmigaDOSPlugin
if(errno != ErrorNumber.NoError) return;
BootBlock bootBlk = Marshal.ByteArrayToStructureBigEndianGenerated<BootBlock>(bootBlockSectors);
BootBlock bootBlk = Marshal.ByteArrayToStructureBigEndian<BootBlock>(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;

View File

@@ -39,7 +39,7 @@ static partial class AppleCommon
{
if(bbSector is null || bbSector.Length < 0x100) return null;
BootBlock bb = Marshal.ByteArrayToStructureBigEndianGenerated<BootBlock>(bbSector);
BootBlock bb = Marshal.ByteArrayToStructureBigEndian<BootBlock>(bbSector);
if(bb.bbID != BB_MAGIC) return null;

View File

@@ -155,7 +155,7 @@ public sealed partial class AppleHFS
return;
}
MasterDirectoryBlock mdb = Marshal.ByteArrayToStructureBigEndianGenerated<MasterDirectoryBlock>(mdbSector);
MasterDirectoryBlock mdb = Marshal.ByteArrayToStructureBigEndian<MasterDirectoryBlock>(mdbSector);
sb.AppendLine(Localization.Name_Apple_Hierarchical_File_System);
sb.AppendLine();

View File

@@ -174,7 +174,7 @@ public sealed partial class AppleHFSPlus
Array.Copy(vhSector, 0x400, tmp, 0, 0x400);
vhSector = tmp;
vh = Marshal.ByteArrayToStructureBigEndianGenerated<VolumeHeader>(vhSector);
vh = Marshal.ByteArrayToStructureBigEndian<VolumeHeader>(vhSector);
if(vh.version is 4 or 5)
{

View File

@@ -59,7 +59,7 @@ public sealed partial class AppleMFS
entry.flTyp = _directoryBlocks[offset + 1];
entry.flUsrWds =
Marshal.ByteArrayToStructureBigEndianGenerated<AppleCommon.FInfo>(_directoryBlocks, offset + 2, 16);
Marshal.ByteArrayToStructureBigEndian<AppleCommon.FInfo>(_directoryBlocks, offset + 2, 16);
entry.flFlNum = BigEndianBitConverter.ToUInt32(_directoryBlocks, offset + 18);
entry.flStBlk = BigEndianBitConverter.ToUInt16(_directoryBlocks, offset + 22);

View File

@@ -132,7 +132,7 @@ public sealed partial class BeFS
besb = littleEndian
? Marshal.ByteArrayToStructureLittleEndian<SuperBlock>(sbSector)
: Marshal.ByteArrayToStructureBigEndianGenerated<SuperBlock>(sbSector);
: Marshal.ByteArrayToStructureBigEndian<SuperBlock>(sbSector);
sb.AppendLine(littleEndian ? Localization.Little_endian_BeFS : Localization.Big_endian_BeFS);

View File

@@ -88,7 +88,7 @@ public sealed partial class CBM
if(errno != ErrorNumber.NoError) return errno;
Header cbmHdr = Marshal.ByteArrayToStructureBigEndianGenerated<Header>(_diskHeader);
Header cbmHdr = Marshal.ByteArrayToStructureBigEndian<Header>(_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);
BAM cbmBam = Marshal.ByteArrayToStructureBigEndian<BAM>(_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<DirectoryEntry>(_root, offset, 32);
DirectoryEntry dirEntry = Marshal.ByteArrayToStructureBigEndian<DirectoryEntry>(_root, offset, 32);
if(dirEntry.fileType == 0)
{

View File

@@ -83,7 +83,7 @@ public sealed partial class Cram
break;
case CRAM_CIGAM:
crSb = Marshal.ByteArrayToStructureBigEndianGenerated<SuperBlock>(sector);
crSb = Marshal.ByteArrayToStructureBigEndian<SuperBlock>(sector);
littleEndian = false;
break;

View File

@@ -65,7 +65,7 @@ public sealed partial class EFS
Array.Copy(sector, 0x200, sbpiece, 0, Marshal.SizeOf<Superblock>());
Superblock sb = Marshal.ByteArrayToStructureBigEndianGenerated<Superblock>(sbpiece);
Superblock sb = Marshal.ByteArrayToStructureBigEndian<Superblock>(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<Superblock>()) return false;
Superblock sb = Marshal.ByteArrayToStructureBigEndianGenerated<Superblock>(sector);
Superblock sb = Marshal.ByteArrayToStructureBigEndian<Superblock>(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<Superblock>());
efsSb = Marshal.ByteArrayToStructureBigEndianGenerated<Superblock>(sbpiece);
efsSb = Marshal.ByteArrayToStructureBigEndian<Superblock>(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<Superblock>()) return;
efsSb = Marshal.ByteArrayToStructureBigEndianGenerated<Superblock>(sector);
efsSb = Marshal.ByteArrayToStructureBigEndian<Superblock>(sector);
AaruLogging.Debug(MODULE_NAME,
Localization.magic_at_0_equals_1_expected_2_or_3,

View File

@@ -49,7 +49,7 @@ public sealed partial class FAT
andosOemCorrect = false;
bootable = false;
humanBpb = Marshal.ByteArrayToStructureBigEndianGenerated<HumanParameterBlock>(bpbSector);
humanBpb = Marshal.ByteArrayToStructureBigEndian<HumanParameterBlock>(bpbSector);
atariBpb = Marshal.ByteArrayToStructureLittleEndian<AtariParameterBlock>(bpbSector);
ulong expectedClusters = humanBpb.bpc > 0 ? partition.Size / humanBpb.bpc : 0;

View File

@@ -82,7 +82,7 @@ public sealed partial class FAT
if(errno != ErrorNumber.NoError) return false;
HumanParameterBlock humanBpb = Marshal.ByteArrayToStructureBigEndianGenerated<HumanParameterBlock>(bpbSector);
HumanParameterBlock humanBpb = Marshal.ByteArrayToStructureBigEndian<HumanParameterBlock>(bpbSector);
ulong expectedClusters = humanBpb.bpc > 0 ? partition.Size / humanBpb.bpc : 0;

View File

@@ -130,7 +130,7 @@ public sealed partial class XboxFatPlugin
? Marshal.ByteArrayToStructureLittleEndian<DirectoryEntry>(directoryBuffer,
pos,
Marshal.SizeOf<DirectoryEntry>())
: Marshal.ByteArrayToStructureBigEndianGenerated<DirectoryEntry>(directoryBuffer,
: Marshal.ByteArrayToStructureBigEndian<DirectoryEntry>(directoryBuffer,
pos,
Marshal.SizeOf<DirectoryEntry>());

View File

@@ -48,7 +48,7 @@ public sealed partial class XboxFatPlugin
if(errno != ErrorNumber.NoError) return false;
Superblock sb = Marshal.ByteArrayToStructureBigEndianGenerated<Superblock>(sector);
Superblock sb = Marshal.ByteArrayToStructureBigEndian<Superblock>(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<Superblock>(sector);
Superblock fatxSb = Marshal.ByteArrayToStructureBigEndian<Superblock>(sector);
if(fatxSb.magic == FATX_CIGAM)
{

View File

@@ -69,7 +69,7 @@ public sealed partial class XboxFatPlugin
if(_superblock.magic == FATX_CIGAM)
{
_superblock = Marshal.ByteArrayToStructureBigEndianGenerated<Superblock>(sector);
_superblock = Marshal.ByteArrayToStructureBigEndian<Superblock>(sector);
_littleEndian = false;
}
@@ -233,7 +233,7 @@ public sealed partial class XboxFatPlugin
? Marshal.ByteArrayToStructureLittleEndian<DirectoryEntry>(rootDirectoryBuffer,
pos,
Marshal.SizeOf<DirectoryEntry>())
: Marshal.ByteArrayToStructureBigEndianGenerated<DirectoryEntry>(rootDirectoryBuffer,
: Marshal.ByteArrayToStructureBigEndian<DirectoryEntry>(rootDirectoryBuffer,
pos,
Marshal.SizeOf<DirectoryEntry>());

View File

@@ -220,7 +220,7 @@ public sealed partial class FFSPlugin
SuperBlock sb = Marshal.ByteArrayToStructureLittleEndian<SuperBlock>(ufs_sb_sectors);
SuperBlock bs_sfu = Marshal.ByteArrayToStructureBigEndianGenerated<SuperBlock>(ufs_sb_sectors);
SuperBlock bs_sfu = Marshal.ByteArrayToStructureBigEndian<SuperBlock>(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 ||

View File

@@ -53,7 +53,7 @@ public sealed partial class Fossil
if(errno != ErrorNumber.NoError) return false;
Header hdr = Marshal.ByteArrayToStructureBigEndianGenerated<Header>(sector);
Header hdr = Marshal.ByteArrayToStructureBigEndian<Header>(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<Header>(sector);
Header hdr = Marshal.ByteArrayToStructureBigEndian<Header>(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<SuperBlock>(sector);
SuperBlock fsb = Marshal.ByteArrayToStructureBigEndian<SuperBlock>(sector);
AaruLogging.Debug(MODULE_NAME, Localization.magic_0_expected_1, fsb.magic, FOSSIL_SB_MAGIC);

View File

@@ -84,7 +84,7 @@ public sealed partial class HAMMER
SuperBlock superBlock = magic == HAMMER_FSBUF_VOLUME
? Marshal.ByteArrayToStructureLittleEndian<SuperBlock>(sbSector)
: Marshal.ByteArrayToStructureBigEndianGenerated<SuperBlock>(sbSector);
: Marshal.ByteArrayToStructureBigEndian<SuperBlock>(sbSector);
sb.AppendLine(Localization.HAMMER_filesystem);

View File

@@ -93,10 +93,10 @@ public sealed partial class HPOFS
BiosParameterBlock bpb = Marshal.ByteArrayToStructureLittleEndian<BiosParameterBlock>(hpofsBpbSector);
MediaInformationBlock mib =
Marshal.ByteArrayToStructureBigEndianGenerated<MediaInformationBlock>(medInfoSector);
Marshal.ByteArrayToStructureBigEndian<MediaInformationBlock>(medInfoSector);
VolumeInformationBlock vib =
Marshal.ByteArrayToStructureBigEndianGenerated<VolumeInformationBlock>(volInfoSector);
Marshal.ByteArrayToStructureBigEndian<VolumeInformationBlock>(volInfoSector);
AaruLogging.Debug(MODULE_NAME, "bpb.oem_name = \"{0}\"", StringHandlers.CToString(bpb.oem_name));

View File

@@ -55,7 +55,7 @@ public sealed partial class ISO9660
while(entryOff + _cdiDirectoryRecordSize < data.Length)
{
CdiDirectoryRecord record =
Marshal.ByteArrayToStructureBigEndianGenerated<CdiDirectoryRecord>(data,
Marshal.ByteArrayToStructureBigEndian<CdiDirectoryRecord>(data,
entryOff,
_cdiDirectoryRecordSize);
@@ -107,7 +107,7 @@ public sealed partial class ISO9660
if(systemAreaStart % 2 != 0) systemAreaStart++;
entry.CdiSystemArea =
Marshal.ByteArrayToStructureBigEndianGenerated<CdiSystemArea>(data,
Marshal.ByteArrayToStructureBigEndian<CdiSystemArea>(data,
systemAreaStart,
_cdiSystemAreaSize);
@@ -459,7 +459,7 @@ public sealed partial class ISO9660
break;
case AppleId.HFS:
AppleHFSSystemUse appleHfsSystemUse =
Marshal.ByteArrayToStructureBigEndianGenerated<AppleHFSSystemUse>(data,
Marshal.ByteArrayToStructureBigEndian<AppleHFSSystemUse>(data,
systemAreaOff,
Marshal.SizeOf<AppleHFSSystemUse>());
@@ -500,7 +500,7 @@ public sealed partial class ISO9660
case AppleOldId.TypeCreator:
case AppleOldId.TypeCreatorBundle:
AppleHFSTypeCreatorSystemUse appleHfsTypeCreatorSystemUse =
Marshal.ByteArrayToStructureBigEndianGenerated<AppleHFSTypeCreatorSystemUse>(data,
Marshal.ByteArrayToStructureBigEndian<AppleHFSTypeCreatorSystemUse>(data,
systemAreaOff,
Marshal.SizeOf<AppleHFSTypeCreatorSystemUse>());
@@ -520,7 +520,7 @@ public sealed partial class ISO9660
case AppleOldId.TypeCreatorIcon:
case AppleOldId.TypeCreatorIconBundle:
AppleHFSIconSystemUse appleHfsIconSystemUse =
Marshal.ByteArrayToStructureBigEndianGenerated<AppleHFSIconSystemUse>(data,
Marshal.ByteArrayToStructureBigEndian<AppleHFSIconSystemUse>(data,
systemAreaOff,
Marshal.SizeOf<AppleHFSIconSystemUse>());
@@ -540,7 +540,7 @@ public sealed partial class ISO9660
break;
case AppleOldId.HFS:
AppleHFSOldSystemUse appleHfsSystemUse =
Marshal.ByteArrayToStructureBigEndianGenerated<AppleHFSOldSystemUse>(data,
Marshal.ByteArrayToStructureBigEndian<AppleHFSOldSystemUse>(data,
systemAreaOff,
Marshal.SizeOf<AppleHFSOldSystemUse>());
@@ -567,7 +567,7 @@ public sealed partial class ISO9660
break;
case XA_MAGIC:
entry.XA = Marshal.ByteArrayToStructureBigEndianGenerated<CdromXa>(data,
entry.XA = Marshal.ByteArrayToStructureBigEndian<CdromXa>(data,
systemAreaOff,
Marshal.SizeOf<CdromXa>());
@@ -579,7 +579,7 @@ public sealed partial class ISO9660
case AAIP_MAGIC:
case AMIGA_MAGIC:
AmigaEntry amiga =
Marshal.ByteArrayToStructureBigEndianGenerated<AmigaEntry>(data,
Marshal.ByteArrayToStructureBigEndian<AmigaEntry>(data,
systemAreaOff,
Marshal.SizeOf<AmigaEntry>());
@@ -588,7 +588,7 @@ public sealed partial class ISO9660
if(amiga.flags.HasFlag(AmigaFlags.Protection))
{
entry.AmigaProtection =
Marshal.ByteArrayToStructureBigEndianGenerated<AmigaProtection>(data,
Marshal.ByteArrayToStructureBigEndian<AmigaProtection>(data,
systemAreaOff + Marshal.SizeOf<AmigaEntry>(),
Marshal.SizeOf<AmigaProtection>());
@@ -995,7 +995,7 @@ public sealed partial class ISO9660
if(errno != ErrorNumber.NoError) continue;
CdiDirectoryRecord record =
Marshal.ByteArrayToStructureBigEndianGenerated<CdiDirectoryRecord>(sector,
Marshal.ByteArrayToStructureBigEndian<CdiDirectoryRecord>(sector,
tEntry.XattrLength,
_cdiDirectoryRecordSize);
@@ -1020,7 +1020,7 @@ public sealed partial class ISO9660
if(systemAreaStart % 2 != 0) systemAreaStart++;
entry.CdiSystemArea =
Marshal.ByteArrayToStructureBigEndianGenerated<CdiSystemArea>(sector,
Marshal.ByteArrayToStructureBigEndian<CdiSystemArea>(sector,
systemAreaStart,
_cdiSystemAreaSize);

View File

@@ -185,7 +185,7 @@ public sealed partial class ISO9660
if(highSierraInfo)
hsvd = Marshal.ByteArrayToStructureLittleEndian<HighSierraPrimaryVolumeDescriptor>(vdSector);
else if(cdiInfo)
fsvd = Marshal.ByteArrayToStructureBigEndianGenerated<FileStructureVolumeDescriptor>(vdSector);
fsvd = Marshal.ByteArrayToStructureBigEndian<FileStructureVolumeDescriptor>(vdSector);
else
pvd = Marshal.ByteArrayToStructureLittleEndian<PrimaryVolumeDescriptor>(vdSector);
@@ -319,7 +319,7 @@ public sealed partial class ISO9660
if(Marshal.SizeOf<CdromXa>() + saOff <= saLen)
{
CdromXa xa = Marshal.ByteArrayToStructureBigEndianGenerated<CdromXa>(sa);
CdromXa xa = Marshal.ByteArrayToStructureBigEndian<CdromXa>(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<ContinuationArea>(ce);
Marshal.ByteArrayToStructureBigEndian<ContinuationArea>(ce);
contareas.Add(ca);
@@ -515,7 +515,7 @@ public sealed partial class ISO9660
foreach(byte[] erb in refareas)
{
ReferenceArea er = Marshal.ByteArrayToStructureBigEndianGenerated<ReferenceArea>(erb);
ReferenceArea er = Marshal.ByteArrayToStructureBigEndian<ReferenceArea>(erb);
string extId = encoding.GetString(erb, Marshal.SizeOf<ReferenceArea>(), er.id_len);
string extDes = encoding.GetString(erb, Marshal.SizeOf<ReferenceArea>() + er.id_len, er.des_len);

View File

@@ -43,7 +43,7 @@ public sealed partial class ISO9660
var off = 0;
PathTableEntry entry =
Marshal.ByteArrayToStructureBigEndianGenerated<PathTableEntry>(data, off, Marshal.SizeOf<PathTableEntry>());
Marshal.ByteArrayToStructureBigEndian<PathTableEntry>(data, off, Marshal.SizeOf<PathTableEntry>());
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<PathTableEntry>(data,
entry = Marshal.ByteArrayToStructureBigEndian<PathTableEntry>(data,
off,
Marshal.SizeOf<PathTableEntry>());
@@ -90,7 +90,7 @@ public sealed partial class ISO9660
while(off < data.Length)
{
HighSierraPathTableEntry entry =
Marshal.ByteArrayToStructureBigEndianGenerated<HighSierraPathTableEntry>(data,
Marshal.ByteArrayToStructureBigEndian<HighSierraPathTableEntry>(data,
off,
Marshal.SizeOf<HighSierraPathTableEntry>());

View File

@@ -182,7 +182,7 @@ public sealed partial class ISO9660
if(_highSierra)
hsvd = Marshal.ByteArrayToStructureLittleEndian<HighSierraPrimaryVolumeDescriptor>(vdSector);
else if(_cdi)
fsvd = Marshal.ByteArrayToStructureBigEndianGenerated<FileStructureVolumeDescriptor>(vdSector);
fsvd = Marshal.ByteArrayToStructureBigEndian<FileStructureVolumeDescriptor>(vdSector);
else
pvd = Marshal.ByteArrayToStructureLittleEndian<PrimaryVolumeDescriptor>(vdSector);
@@ -423,7 +423,7 @@ public sealed partial class ISO9660
if(errno != ErrorNumber.NoError) return errno;
CdiDirectoryRecord rootEntry =
Marshal.ByteArrayToStructureBigEndianGenerated<CdiDirectoryRecord>(firstRootSector);
Marshal.ByteArrayToStructureBigEndian<CdiDirectoryRecord>(firstRootSector);
rootSize = rootEntry.size;

View File

@@ -52,7 +52,7 @@ public sealed partial class LIF
if(errno != ErrorNumber.NoError) return false;
SystemBlock lifSb = Marshal.ByteArrayToStructureBigEndianGenerated<SystemBlock>(sector);
SystemBlock lifSb = Marshal.ByteArrayToStructureBigEndian<SystemBlock>(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<SystemBlock>(sector);
SystemBlock lifSb = Marshal.ByteArrayToStructureBigEndian<SystemBlock>(sector);
if(lifSb.magic != LIF_MAGIC) return;

View File

@@ -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<Superblock>(sector);
locusSb = Marshal.ByteArrayToStructureBigEndian<Superblock>(sector);
locusSb.s_flags = (Flags)Swapping.Swap((ushort)locusSb.s_flags);
}

View File

@@ -224,7 +224,7 @@ public sealed partial class MinixFS
{
SuperBlock3 mnxSb = littleEndian
? Marshal.ByteArrayToStructureLittleEndian<SuperBlock3>(minixSbSector)
: Marshal.ByteArrayToStructureBigEndianGenerated<SuperBlock3>(minixSbSector);
: Marshal.ByteArrayToStructureBigEndian<SuperBlock3>(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<SuperBlock>(minixSbSector)
: Marshal.ByteArrayToStructureBigEndianGenerated<SuperBlock>(minixSbSector);
: Marshal.ByteArrayToStructureBigEndian<SuperBlock>(minixSbSector);
sb.AppendLine(minixVersion);
sb.AppendFormat(Localization._0_chars_in_filename, filenamesize).AppendLine();

View File

@@ -171,7 +171,7 @@ public sealed partial class OperaFS
if(errno != ErrorNumber.NoError) break;
header = Marshal.ByteArrayToStructureBigEndianGenerated<DirectoryHeader>(data);
header = Marshal.ByteArrayToStructureBigEndian<DirectoryHeader>(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<DirectoryEntry>(data, off, _directoryEntrySize);
entry = Marshal.ByteArrayToStructureBigEndian<DirectoryEntry>(data, off, _directoryEntrySize);
string name = StringHandlers.CToString(entry.name, _encoding);
var entryWithPointers = new DirectoryEntryWithPointers

View File

@@ -74,7 +74,7 @@ public sealed partial class OperaFS
if(errno != ErrorNumber.NoError) return;
SuperBlock sb = Marshal.ByteArrayToStructureBigEndianGenerated<SuperBlock>(sbSector);
SuperBlock sb = Marshal.ByteArrayToStructureBigEndian<SuperBlock>(sbSector);
if(sb.record_type != 1 || sb.record_version != 1) return;

View File

@@ -57,7 +57,7 @@ public sealed partial class OperaFS
if(errno != ErrorNumber.NoError) return errno;
SuperBlock sb = Marshal.ByteArrayToStructureBigEndianGenerated<SuperBlock>(sbSector);
SuperBlock sb = Marshal.ByteArrayToStructureBigEndian<SuperBlock>(sbSector);
if(sb.record_type != 1 || sb.record_version != 1) return ErrorNumber.InvalidArgument;

View File

@@ -68,7 +68,7 @@ public sealed partial class PFS
if(errno != ErrorNumber.NoError) return;
RootBlock rootBlock = Marshal.ByteArrayToStructureBigEndianGenerated<RootBlock>(rootBlockSector);
RootBlock rootBlock = Marshal.ByteArrayToStructureBigEndian<RootBlock>(rootBlockSector);
var sbInformation = new StringBuilder();
metadata = new FileSystem();

View File

@@ -69,8 +69,8 @@ public sealed partial class RBF
if(sector.Length < Marshal.SizeOf<IdSector>()) return false;
IdSector rbfSb = Marshal.ByteArrayToStructureBigEndianGenerated<IdSector>(sector);
NewIdSector rbf9000Sb = Marshal.ByteArrayToStructureBigEndianGenerated<NewIdSector>(sector);
IdSector rbfSb = Marshal.ByteArrayToStructureBigEndian<IdSector>(sector);
NewIdSector rbf9000Sb = Marshal.ByteArrayToStructureBigEndian<NewIdSector>(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<IdSector>()) return;
rbfSb = Marshal.ByteArrayToStructureBigEndianGenerated<IdSector>(sector);
rbf9000Sb = Marshal.ByteArrayToStructureBigEndianGenerated<NewIdSector>(sector);
rbfSb = Marshal.ByteArrayToStructureBigEndian<IdSector>(sector);
rbf9000Sb = Marshal.ByteArrayToStructureBigEndian<NewIdSector>(sector);
AaruLogging.Debug(MODULE_NAME,
Localization.magic_at_0_equals_1_or_2_expected_3_or_4,

View File

@@ -65,7 +65,7 @@ public sealed partial class SFS
if(errno != ErrorNumber.NoError) return;
RootBlock rootBlock = Marshal.ByteArrayToStructureBigEndianGenerated<RootBlock>(rootBlockSector);
RootBlock rootBlock = Marshal.ByteArrayToStructureBigEndian<RootBlock>(rootBlockSector);
var sbInformation = new StringBuilder();

View File

@@ -78,7 +78,7 @@ public sealed partial class Squash
break;
case SQUASH_CIGAM:
sqSb = Marshal.ByteArrayToStructureBigEndianGenerated<SuperBlock>(sector);
sqSb = Marshal.ByteArrayToStructureBigEndian<SuperBlock>(sector);
littleEndian = false;
break;

View File

@@ -61,7 +61,7 @@ public sealed partial class UNICOS
if(sector.Length < Marshal.SizeOf<Superblock>()) return false;
Superblock unicosSb = Marshal.ByteArrayToStructureBigEndianGenerated<Superblock>(sector);
Superblock unicosSb = Marshal.ByteArrayToStructureBigEndian<Superblock>(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<Superblock>()) return;
Superblock unicosSb = Marshal.ByteArrayToStructureBigEndianGenerated<Superblock>(sector);
Superblock unicosSb = Marshal.ByteArrayToStructureBigEndian<Superblock>(sector);
if(unicosSb.s_magic != UNICOS_MAGIC) return;

View File

@@ -70,7 +70,7 @@ public sealed partial class XFS
{
Array.Copy(sector, location, sbpiece, 0, Marshal.SizeOf<Superblock>());
Superblock xfsSb = Marshal.ByteArrayToStructureBigEndianGenerated<Superblock>(sbpiece);
Superblock xfsSb = Marshal.ByteArrayToStructureBigEndian<Superblock>(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<Superblock>()) return false;
Superblock xfsSb = Marshal.ByteArrayToStructureBigEndianGenerated<Superblock>(sector);
Superblock xfsSb = Marshal.ByteArrayToStructureBigEndian<Superblock>(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<Superblock>());
xfsSb = Marshal.ByteArrayToStructureBigEndianGenerated<Superblock>(sbpiece);
xfsSb = Marshal.ByteArrayToStructureBigEndian<Superblock>(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<Superblock>()) return;
xfsSb = Marshal.ByteArrayToStructureBigEndianGenerated<Superblock>(sector);
xfsSb = Marshal.ByteArrayToStructureBigEndian<Superblock>(sector);
AaruLogging.Debug(MODULE_NAME,
Localization.magic_at_0_equals_1_expected_2,

View File

@@ -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<s_spcl>(sector);
newHdr = Marshal.ByteArrayToStructureBigEndian<s_spcl>(sector);
}
else if(aixHdr.c_magic is XIX_MAGIC or XIX_CIGAM)
{
useAix = true;
if(aixHdr.c_magic == XIX_CIGAM) aixHdr = Marshal.ByteArrayToStructureBigEndianGenerated<spcl_aix>(sector);
if(aixHdr.c_magic == XIX_CIGAM) aixHdr = Marshal.ByteArrayToStructureBigEndian<spcl_aix>(sector);
}
else if(oldHdr.c_magic == OFS_MAGIC)
{

View File

@@ -172,7 +172,7 @@ public sealed partial class AppleDouble : IFilter
{
var prodosB = new byte[26];
prodosStream.EnsureRead(prodosB, 0, 26);
_header = Marshal.ByteArrayToStructureBigEndianGenerated<Header>(prodosB);
_header = Marshal.ByteArrayToStructureBigEndian<Header>(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<Header>(unixB);
_header = Marshal.ByteArrayToStructureBigEndian<Header>(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<Header>(dosB);
_header = Marshal.ByteArrayToStructureBigEndian<Header>(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<Header>(doslB);
_header = Marshal.ByteArrayToStructureBigEndian<Header>(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<Header>(netatalkB);
_header = Marshal.ByteArrayToStructureBigEndian<Header>(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<Header>(daveB);
_header = Marshal.ByteArrayToStructureBigEndian<Header>(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<Header>(osxB);
_header = Marshal.ByteArrayToStructureBigEndian<Header>(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<Header>(unarB);
_header = Marshal.ByteArrayToStructureBigEndian<Header>(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<Header>(prodosB);
_header = Marshal.ByteArrayToStructureBigEndian<Header>(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<Header>(unixB);
_header = Marshal.ByteArrayToStructureBigEndian<Header>(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<Header>(dosB);
_header = Marshal.ByteArrayToStructureBigEndian<Header>(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<Header>(doslB);
_header = Marshal.ByteArrayToStructureBigEndian<Header>(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<Header>(netatalkB);
_header = Marshal.ByteArrayToStructureBigEndian<Header>(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<Header>(daveB);
_header = Marshal.ByteArrayToStructureBigEndian<Header>(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<Header>(osxB);
_header = Marshal.ByteArrayToStructureBigEndian<Header>(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<Header>(unarB);
_header = Marshal.ByteArrayToStructureBigEndian<Header>(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<Header>(hdrB);
_header = Marshal.ByteArrayToStructureBigEndian<Header>(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>(entry);
entries[i] = Marshal.ByteArrayToStructureBigEndian<Entry>(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<FileDates>(datesB);
FileDates dates = Marshal.ByteArrayToStructureBigEndian<FileDates>(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<MacFileInfo>(finfo);
MacFileInfo macinfo = Marshal.ByteArrayToStructureBigEndian<MacFileInfo>(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<ProDOSFileInfo>(finfo);
Marshal.ByteArrayToStructureBigEndian<ProDOSFileInfo>(finfo);
CreationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate);
LastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate);
}
else if(_unixHome.SequenceEqual(_header.homeFilesystem))
{
UnixFileInfo unixinfo = Marshal.ByteArrayToStructureBigEndianGenerated<UnixFileInfo>(finfo);
UnixFileInfo unixinfo = Marshal.ByteArrayToStructureBigEndian<UnixFileInfo>(finfo);
CreationTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.creationDate);
LastWriteTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.modificationDate);
}
else if(_dosHome.SequenceEqual(_header.homeFilesystem))
{
DOSFileInfo dosinfo = Marshal.ByteArrayToStructureBigEndianGenerated<DOSFileInfo>(finfo);
DOSFileInfo dosinfo = Marshal.ByteArrayToStructureBigEndian<DOSFileInfo>(finfo);
LastWriteTime = DateHandlers.DosToDateTime(dosinfo.modificationDate, dosinfo.modificationTime);
}

View File

@@ -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<Header>(hdrB);
_header = Marshal.ByteArrayToStructureBigEndian<Header>(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<Header>(hdrB);
_header = Marshal.ByteArrayToStructureBigEndian<Header>(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<Header>(hdrB);
_header = Marshal.ByteArrayToStructureBigEndian<Header>(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<Header>(hdrB);
_header = Marshal.ByteArrayToStructureBigEndian<Header>(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>(entry);
entries[i] = Marshal.ByteArrayToStructureBigEndian<Entry>(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<FileDates>(datesB);
FileDates dates = Marshal.ByteArrayToStructureBigEndian<FileDates>(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<MacFileInfo>(finfo);
MacFileInfo macinfo = Marshal.ByteArrayToStructureBigEndian<MacFileInfo>(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<ProDOSFileInfo>(finfo);
Marshal.ByteArrayToStructureBigEndian<ProDOSFileInfo>(finfo);
CreationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate);
LastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate);
}
else if(_unixHome.SequenceEqual(_header.homeFilesystem))
{
UnixFileInfo unixinfo = Marshal.ByteArrayToStructureBigEndianGenerated<UnixFileInfo>(finfo);
UnixFileInfo unixinfo = Marshal.ByteArrayToStructureBigEndian<UnixFileInfo>(finfo);
CreationTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.creationDate);
LastWriteTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.modificationDate);
}
else if(_dosHome.SequenceEqual(_header.homeFilesystem))
{
DOSFileInfo dosinfo = Marshal.ByteArrayToStructureBigEndianGenerated<DOSFileInfo>(finfo);
DOSFileInfo dosinfo = Marshal.ByteArrayToStructureBigEndian<DOSFileInfo>(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<Header>(hdrB);
_header = Marshal.ByteArrayToStructureBigEndian<Header>(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>(entry);
entries[i] = Marshal.ByteArrayToStructureBigEndian<Entry>(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<FileDates>(datesB);
FileDates dates = Marshal.ByteArrayToStructureBigEndian<FileDates>(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<MacFileInfo>(finfo);
MacFileInfo macinfo = Marshal.ByteArrayToStructureBigEndian<MacFileInfo>(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<ProDOSFileInfo>(finfo);
Marshal.ByteArrayToStructureBigEndian<ProDOSFileInfo>(finfo);
CreationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate);
LastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate);
}
else if(_unixHome.SequenceEqual(_header.homeFilesystem))
{
UnixFileInfo unixinfo = Marshal.ByteArrayToStructureBigEndianGenerated<UnixFileInfo>(finfo);
UnixFileInfo unixinfo = Marshal.ByteArrayToStructureBigEndian<UnixFileInfo>(finfo);
CreationTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.creationDate);
LastWriteTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.modificationDate);
}
else if(_dosHome.SequenceEqual(_header.homeFilesystem))
{
DOSFileInfo dosinfo = Marshal.ByteArrayToStructureBigEndianGenerated<DOSFileInfo>(finfo);
DOSFileInfo dosinfo = Marshal.ByteArrayToStructureBigEndian<DOSFileInfo>(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<Header>(hdrB);
_header = Marshal.ByteArrayToStructureBigEndian<Header>(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>(entry);
entries[i] = Marshal.ByteArrayToStructureBigEndian<Entry>(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<FileDates>(datesB);
FileDates dates = Marshal.ByteArrayToStructureBigEndian<FileDates>(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<MacFileInfo>(finfo);
MacFileInfo macinfo = Marshal.ByteArrayToStructureBigEndian<MacFileInfo>(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<ProDOSFileInfo>(finfo);
Marshal.ByteArrayToStructureBigEndian<ProDOSFileInfo>(finfo);
CreationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate);
LastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate);
}
else if(_unixHome.SequenceEqual(_header.homeFilesystem))
{
UnixFileInfo unixinfo = Marshal.ByteArrayToStructureBigEndianGenerated<UnixFileInfo>(finfo);
UnixFileInfo unixinfo = Marshal.ByteArrayToStructureBigEndian<UnixFileInfo>(finfo);
CreationTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.creationDate);
LastWriteTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.modificationDate);
}
else if(_dosHome.SequenceEqual(_header.homeFilesystem))
{
DOSFileInfo dosinfo = Marshal.ByteArrayToStructureBigEndianGenerated<DOSFileInfo>(finfo);
DOSFileInfo dosinfo = Marshal.ByteArrayToStructureBigEndian<DOSFileInfo>(finfo);
LastWriteTime = DateHandlers.DosToDateTime(dosinfo.modificationDate, dosinfo.modificationTime);
}

View File

@@ -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<Header>(hdrB);
_header = Marshal.ByteArrayToStructureBigEndian<Header>(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<Header>(hdrB);
_header = Marshal.ByteArrayToStructureBigEndian<Header>(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<Header>(hdrB);
_header = Marshal.ByteArrayToStructureBigEndian<Header>(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<Header>(hdrB);
_header = Marshal.ByteArrayToStructureBigEndian<Header>(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<Header>(hdrB);
_header = Marshal.ByteArrayToStructureBigEndian<Header>(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<Header>(hdrB);
_header = Marshal.ByteArrayToStructureBigEndian<Header>(hdrB);
uint blocks = 1;
blocks += (uint)(_header.secondaryHeaderLength / 128);

View File

@@ -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<Entry>(datEntryB);
datEntry = Helpers.Marshal.ByteArrayToStructureBigEndian<Entry>(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<Entry>(datEntryB);
datEntry = Helpers.Marshal.ByteArrayToStructureBigEndian<Entry>(datEntryB);
string macName = StringHandlers.PascalToString(datEntry.macName, Encoding.GetEncoding("macintosh"));

View File

@@ -80,32 +80,14 @@ public static class Marshal
return ByteArrayToStructureLittleEndian<T>(span.Slice(start, length).ToArray());
}
/// <summary>Marshal big-endian binary data to a structure</summary>
/// <param name="bytes">Byte array containing the binary data</param>
/// <typeparam name="T">Type of the structure to marshal</typeparam>
/// <returns>The binary data marshalled in a structure with the specified type</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T ByteArrayToStructureBigEndian<T>(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);
}
/// <summary>
/// Marshal big-endian binary data to a structure using compile-time generated swap method.
/// This method is faster than <see cref="ByteArrayToStructureBigEndian{T}" /> as it avoids boxing and reflection.
/// </summary>
/// <param name="bytes">Byte array containing the binary data</param>
/// <typeparam name="T">Type of the structure to marshal (must be marked with [SwapEndian] attribute)</typeparam>
/// <returns>The binary data marshalled in a structure with the specified type</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T ByteArrayToStructureBigEndianGenerated<T>(byte[] bytes) where T : struct, ISwapEndian<T>
public static T ByteArrayToStructureBigEndian<T>(byte[] bytes) where T : struct, ISwapEndian<T>
{
T str = ByteArrayToStructureLittleEndian<T>(bytes);
@@ -114,8 +96,6 @@ public static class Marshal
/// <summary>
/// Marshal big-endian binary data to a structure using compile-time generated swap method.
/// This method is faster than <see cref="ByteArrayToStructureBigEndian{T}(byte[], int, int)" /> as it avoids boxing
/// and reflection.
/// </summary>
/// <param name="bytes">Byte array containing the binary data</param>
/// <param name="start">Start on the array where the structure begins</param>
@@ -123,25 +103,11 @@ public static class Marshal
/// <typeparam name="T">Type of the structure to marshal (must be marked with [SwapEndian] attribute)</typeparam>
/// <returns>The binary data marshalled in a structure with the specified type</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T ByteArrayToStructureBigEndianGenerated<T>(byte[] bytes, int start, int length)
public static T ByteArrayToStructureBigEndian<T>(byte[] bytes, int start, int length)
where T : struct, ISwapEndian<T>
{
Span<byte> span = bytes;
return ByteArrayToStructureBigEndianGenerated<T>(span.Slice(start, length).ToArray());
}
/// <summary>Marshal big-endian binary data to a structure</summary>
/// <param name="bytes">Byte array containing the binary data</param>
/// <param name="start">Start on the array where the structure begins</param>
/// <param name="length">Length of the structure in bytes</param>
/// <typeparam name="T">Type of the structure to marshal</typeparam>
/// <returns>The binary data marshalled in a structure with the specified type</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T ByteArrayToStructureBigEndian<T>(byte[] bytes, int start, int length) where T : struct
{
Span<byte> span = bytes;
return ByteArrayToStructureBigEndian<T>(span.Slice(start, length).ToArray());
}
@@ -203,32 +169,15 @@ public static class Marshal
public static T SpanToStructureLittleEndian<T>(ReadOnlySpan<byte> bytes, int start, int length) where T : struct =>
MemoryMarshal.Read<T>(bytes.Slice(start, length));
/// <summary>
/// Marshal big-endian binary data to a structure. If the structure type contains any non value type, this method
/// will crash.
/// </summary>
/// <param name="bytes">Byte array containing the binary data</param>
/// <typeparam name="T">Type of the structure to marshal</typeparam>
/// <returns>The binary data marshalled in a structure with the specified type</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T SpanToStructureBigEndian<T>(ReadOnlySpan<byte> bytes) where T : struct
{
T str = SpanToStructureLittleEndian<T>(bytes);
return (T)SwapStructureMembersEndian(str);
}
/// <summary>
/// Marshal big-endian binary data to a structure using compile-time generated swap method.
/// This method is faster than <see cref="SpanToStructureBigEndian{T}(ReadOnlySpan{byte})" /> as it avoids boxing and
/// reflection.
/// If the structure type contains any non value type, this method will crash.
/// </summary>
/// <param name="bytes">Byte array containing the binary data</param>
/// <typeparam name="T">Type of the structure to marshal (must be marked with [SwapEndian] attribute)</typeparam>
/// <returns>The binary data marshalled in a structure with the specified type</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T SpanToStructureBigEndianGenerated<T>(ReadOnlySpan<byte> bytes) where T : struct, ISwapEndian<T>
public static T SpanToStructureBigEndian<T>(ReadOnlySpan<byte> bytes) where T : struct, ISwapEndian<T>
{
T str = SpanToStructureLittleEndian<T>(bytes);
@@ -237,8 +186,6 @@ public static class Marshal
/// <summary>
/// Marshal big-endian binary data to a structure using compile-time generated swap method.
/// This method is faster than <see cref="SpanToStructureBigEndian{T}(ReadOnlySpan{byte}, int, int)" /> as it avoids
/// boxing and reflection.
/// If the structure type contains any non value type, this method will crash.
/// </summary>
/// <param name="bytes">Byte span containing the binary data</param>
@@ -247,7 +194,7 @@ public static class Marshal
/// <typeparam name="T">Type of the structure to marshal (must be marked with [SwapEndian] attribute)</typeparam>
/// <returns>The binary data marshalled in a structure with the specified type</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T SpanToStructureBigEndianGenerated<T>(ReadOnlySpan<byte> bytes, int start, int length)
public static T SpanToStructureBigEndian<T>(ReadOnlySpan<byte> bytes, int start, int length)
where T : struct, ISwapEndian<T>
{
T str = SpanToStructureLittleEndian<T>(bytes.Slice(start, length));
@@ -287,39 +234,6 @@ public static class Marshal
return (T)SwapStructureMembersEndianPdp(str);
}
/// <summary>
/// Marshal a structure depending on the decoration of <see cref="MarshallingPropertiesAttribute" />. If the
/// decoration is not present it will marshal as a reference type containing little endian structure.
/// </summary>
/// <param name="bytes">Byte array containing the binary data</param>
/// <typeparam name="T">Type of the structure to marshal</typeparam>
/// <returns>The binary data marshalled in a structure with the specified type</returns>
/// <exception cref="ArgumentOutOfRangeException">
/// The <see cref="MarshallingPropertiesAttribute" /> contains an unsupported
/// endian
/// </exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T MarshalStructure<T>(byte[] bytes) where T : struct
{
if(typeof(T).GetCustomAttribute(typeof(MarshallingPropertiesAttribute)) is not MarshallingPropertiesAttribute
properties)
return ByteArrayToStructureLittleEndian<T>(bytes);
return properties.Endian switch
{
BitEndian.Little => properties.HasReferences
? ByteArrayToStructureLittleEndian<T>(bytes)
: SpanToStructureLittleEndian<T>(bytes),
BitEndian.Big => properties.HasReferences
? ByteArrayToStructureBigEndian<T>(bytes)
: SpanToStructureBigEndian<T>(bytes),
BitEndian.Pdp => properties.HasReferences
? ByteArrayToStructurePdpEndian<T>(bytes)
: SpanToStructurePdpEndian<T>(bytes),
_ => throw new ArgumentOutOfRangeException()
};
}
/// <summary>Swaps all members of a structure</summary>
/// <param name="str"></param>
/// <returns></returns>

View File

@@ -1,62 +0,0 @@
// /***************************************************************************
// Aaru Data Preservation Suite
// ----------------------------------------------------------------------------
//
// Filename : MarshallingPropertiesAttribute.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// 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;
/// <inheritdoc />
/// <summary>Defines properties to help marshalling structs from binary data</summary>
[AttributeUsage(AttributeTargets.Struct)]
public sealed class MarshallingPropertiesAttribute : Attribute
{
/// <inheritdoc />
/// <summary>Defines properties to help marshalling structs from binary data</summary>
/// <param name="endian">Defines properties to help marshalling structs from binary data</param>
public MarshallingPropertiesAttribute(BitEndian endian)
{
Endian = endian;
HasReferences = true;
}
/// <summary>c</summary>
public BitEndian Endian { get; }
/// <summary>Tells if the structure, or any nested structure, has any non-value type (e.g. arrays, strings, etc).</summary>
public bool HasReferences { get; set; }
}

View File

@@ -103,7 +103,7 @@ public partial class AtariLynx : IByteAddressableImage
MetadataMediaType = MetadataMediaType.LinearMedia
};
HandyHeader header = Marshal.ByteArrayToStructureBigEndianGenerated<HandyHeader>(headerBytes, 0, 64);
HandyHeader header = Marshal.ByteArrayToStructureBigEndian<HandyHeader>(headerBytes, 0, 64);
if(header.Version != 256) return ErrorNumber.NotSupported;

View File

@@ -99,7 +99,7 @@ public partial class GameBoy : IByteAddressableImage
MetadataMediaType = MetadataMediaType.LinearMedia
};
Header header = Marshal.ByteArrayToStructureBigEndianGenerated<Header>(_data, 0x100, Marshal.SizeOf<Header>());
Header header = Marshal.ByteArrayToStructureBigEndian<Header>(_data, 0x100, Marshal.SizeOf<Header>());
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<Header>(_data, 0x100, Marshal.SizeOf<Header>());
Header header = Marshal.ByteArrayToStructureBigEndian<Header>(_data, 0x100, Marshal.SizeOf<Header>());
var hasMapper = false;
var hasSaveRam = false;

View File

@@ -98,7 +98,7 @@ public partial class GameBoyAdvance : IByteAddressableImage
MetadataMediaType = MetadataMediaType.LinearMedia
};
Header header = Marshal.ByteArrayToStructureBigEndianGenerated<Header>(_data, 0, Marshal.SizeOf<Header>());
Header header = Marshal.ByteArrayToStructureBigEndian<Header>(_data, 0, Marshal.SizeOf<Header>());
_imageInfo.MediaTitle = StringHandlers.CToString(header.Name);

View File

@@ -140,7 +140,7 @@ public partial class MasterSystem : IByteAddressableImage
};
Header header =
Marshal.ByteArrayToStructureBigEndianGenerated<Header>(_data, headerPosition, Marshal.SizeOf<Header>());
Marshal.ByteArrayToStructureBigEndian<Header>(_data, headerPosition, Marshal.SizeOf<Header>());
var sb = new StringBuilder();

View File

@@ -207,7 +207,7 @@ public partial class Nintendo64 : IByteAddressableImage
_data = tmp;
}
Header header = Marshal.ByteArrayToStructureBigEndianGenerated<Header>(_data, 0, Marshal.SizeOf<Header>());
Header header = Marshal.ByteArrayToStructureBigEndian<Header>(_data, 0, Marshal.SizeOf<Header>());
Encoding encoding;
try
@@ -306,7 +306,7 @@ public partial class Nintendo64 : IByteAddressableImage
LinearMemoryType saveType = LinearMemoryType.Unknown;
ulong saveLength = 0;
Header header = Marshal.ByteArrayToStructureBigEndianGenerated<Header>(_data, 0, Marshal.SizeOf<Header>());
Header header = Marshal.ByteArrayToStructureBigEndian<Header>(_data, 0, Marshal.SizeOf<Header>());
switch((char)header.CartridgeType)
{

View File

@@ -225,7 +225,7 @@ public partial class SegaMegaDrive : IByteAddressableImage
}
SegaHeader header =
Marshal.ByteArrayToStructureBigEndianGenerated<SegaHeader>(_data, 0x100, Marshal.SizeOf<SegaHeader>());
Marshal.ByteArrayToStructureBigEndian<SegaHeader>(_data, 0x100, Marshal.SizeOf<SegaHeader>());
Encoding encoding;
@@ -540,7 +540,7 @@ public partial class SegaMegaDrive : IByteAddressableImage
}
SegaHeader header =
Marshal.ByteArrayToStructureBigEndianGenerated<SegaHeader>(_data, 0x100, Marshal.SizeOf<SegaHeader>());
Marshal.ByteArrayToStructureBigEndian<SegaHeader>(_data, 0x100, Marshal.SizeOf<SegaHeader>());
bool extraRam = header.ExtraRamPresent[0] == 0x52 && header.ExtraRamPresent[1] == 0x41;

View File

@@ -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<MapEntryV3>(entryBytes);
MapEntryV3 entry = Marshal.ByteArrayToStructureBigEndian<MapEntryV3>(entryBytes);
switch((EntryFlagsV3)(entry.flags & 0x0F))
{

View File

@@ -84,7 +84,7 @@ public sealed partial class Chd
{
case 1:
{
HeaderV1 hdrV1 = Marshal.ByteArrayToStructureBigEndianGenerated<HeaderV1>(buffer);
HeaderV1 hdrV1 = Marshal.ByteArrayToStructureBigEndian<HeaderV1>(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<HeaderV2>(buffer);
HeaderV2 hdrV2 = Marshal.ByteArrayToStructureBigEndian<HeaderV2>(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<HeaderV3>(buffer);
HeaderV3 hdrV3 = Marshal.ByteArrayToStructureBigEndian<HeaderV3>(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<HeaderV4>(buffer);
HeaderV4 hdrV4 = Marshal.ByteArrayToStructureBigEndian<HeaderV4>(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<HeaderV5>(buffer);
HeaderV5 hdrV5 = Marshal.ByteArrayToStructureBigEndian<HeaderV5>(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<MetadataHeader>(hdrBytes);
MetadataHeader header = Marshal.ByteArrayToStructureBigEndian<MetadataHeader>(hdrBytes);
var meta = new byte[header.flagsAndLength & 0xFFFFFF];
stream.EnsureRead(meta, 0, meta.Length);

View File

@@ -51,7 +51,7 @@ public sealed partial class Dart
var headerB = new byte[Marshal.SizeOf<Header>()];
stream.EnsureRead(headerB, 0, Marshal.SizeOf<Header>());
Header header = Marshal.ByteArrayToStructureBigEndianGenerated<Header>(headerB);
Header header = Marshal.ByteArrayToStructureBigEndian<Header>(headerB);
if(header.srcCmp > COMPRESS_NONE) return false;

View File

@@ -61,7 +61,7 @@ public sealed partial class Dart
var headerB = new byte[Marshal.SizeOf<Header>()];
stream.EnsureRead(headerB, 0, Marshal.SizeOf<Header>());
Header header = Marshal.ByteArrayToStructureBigEndianGenerated<Header>(headerB);
Header header = Marshal.ByteArrayToStructureBigEndian<Header>(headerB);
if(header.srcCmp > COMPRESS_NONE) return ErrorNumber.NotSupported;

View File

@@ -66,7 +66,7 @@ public sealed partial class DiscFerret
var blk = new byte[Marshal.SizeOf<BlockHeader>()];
stream.EnsureRead(blk, 0, Marshal.SizeOf<BlockHeader>());
BlockHeader blockHeader = Marshal.ByteArrayToStructureBigEndianGenerated<BlockHeader>(blk);
BlockHeader blockHeader = Marshal.ByteArrayToStructureBigEndian<BlockHeader>(blk);
AaruLogging.Debug(MODULE_NAME, "block@{0}.cylinder = {1}", thisOffset, blockHeader.cylinder);

View File

@@ -85,7 +85,7 @@ public sealed partial class Ndif
{
if(bcem.Length < 128) return ErrorNumber.InvalidArgument;
_header = Marshal.ByteArrayToStructureBigEndianGenerated<ChunkHeader>(bcem);
_header = Marshal.ByteArrayToStructureBigEndian<ChunkHeader>(bcem);
AaruLogging.Debug(MODULE_NAME, "footer.type = {0}", _header.version);
AaruLogging.Debug(MODULE_NAME, "footer.driver = {0}", _header.driver);

View File

@@ -50,7 +50,7 @@ public sealed partial class Qcow
var qHdrB = new byte[48];
stream.EnsureRead(qHdrB, 0, 48);
_qHdr = Marshal.SpanToStructureBigEndianGenerated<Header>(qHdrB);
_qHdr = Marshal.SpanToStructureBigEndian<Header>(qHdrB);
return _qHdr is { magic: QCOW_MAGIC, version: QCOW_VERSION };
}

View File

@@ -59,7 +59,7 @@ public sealed partial class Qcow
var qHdrB = new byte[48];
stream.EnsureRead(qHdrB, 0, 48);
_qHdr = Marshal.SpanToStructureBigEndianGenerated<Header>(qHdrB);
_qHdr = Marshal.SpanToStructureBigEndian<Header>(qHdrB);
AaruLogging.Debug(MODULE_NAME, "qHdr.magic = 0x{0:X8}", _qHdr.magic);
AaruLogging.Debug(MODULE_NAME, "qHdr.version = {0}", _qHdr.version);

View File

@@ -51,7 +51,7 @@ public sealed partial class Qcow2
var qHdrB = new byte[Marshal.SizeOf<Header>()];
stream.EnsureRead(qHdrB, 0, Marshal.SizeOf<Header>());
_qHdr = Marshal.SpanToStructureBigEndianGenerated<Header>(qHdrB);
_qHdr = Marshal.SpanToStructureBigEndian<Header>(qHdrB);
AaruLogging.Debug(MODULE_NAME, "qHdr.magic = 0x{0:X8}", _qHdr.magic);
AaruLogging.Debug(MODULE_NAME, "qHdr.version = {0}", _qHdr.version);

View File

@@ -59,7 +59,7 @@ public sealed partial class Qcow2
var qHdrB = new byte[Marshal.SizeOf<Header>()];
stream.EnsureRead(qHdrB, 0, Marshal.SizeOf<Header>());
_qHdr = Marshal.SpanToStructureBigEndianGenerated<Header>(qHdrB);
_qHdr = Marshal.SpanToStructureBigEndian<Header>(qHdrB);
AaruLogging.Debug(MODULE_NAME, "qHdr.magic = 0x{0:X8}", _qHdr.magic);
AaruLogging.Debug(MODULE_NAME, "qHdr.version = {0}", _qHdr.version);

View File

@@ -51,7 +51,7 @@ public sealed partial class Udif
var footerB = new byte[Marshal.SizeOf<Footer>()];
stream.EnsureRead(footerB, 0, Marshal.SizeOf<Footer>());
_footer = Marshal.ByteArrayToStructureBigEndianGenerated<Footer>(footerB);
_footer = Marshal.ByteArrayToStructureBigEndian<Footer>(footerB);
if(_footer.signature == UDIF_SIGNATURE) return true;
@@ -60,7 +60,7 @@ public sealed partial class Udif
var headerB = new byte[Marshal.SizeOf<Footer>()];
stream.EnsureRead(headerB, 0, Marshal.SizeOf<Footer>());
_footer = Marshal.ByteArrayToStructureBigEndianGenerated<Footer>(headerB);
_footer = Marshal.ByteArrayToStructureBigEndian<Footer>(headerB);
return _footer.signature == UDIF_SIGNATURE;
}

View File

@@ -65,7 +65,7 @@ public sealed partial class Udif
var footerB = new byte[Marshal.SizeOf<Footer>()];
stream.EnsureRead(footerB, 0, Marshal.SizeOf<Footer>());
_footer = Marshal.ByteArrayToStructureBigEndianGenerated<Footer>(footerB);
_footer = Marshal.ByteArrayToStructureBigEndian<Footer>(footerB);
if(_footer.signature != UDIF_SIGNATURE)
{
@@ -73,7 +73,7 @@ public sealed partial class Udif
footerB = new byte[Marshal.SizeOf<Footer>()];
stream.EnsureRead(footerB, 0, Marshal.SizeOf<Footer>());
_footer = Marshal.ByteArrayToStructureBigEndianGenerated<Footer>(footerB);
_footer = Marshal.ByteArrayToStructureBigEndian<Footer>(footerB);
if(_footer.signature != UDIF_SIGNATURE)
{
@@ -335,7 +335,7 @@ public sealed partial class Udif
{
var bHdrB = new byte[Marshal.SizeOf<BlockHeader>()];
Array.Copy(blkxBytes, 0, bHdrB, 0, Marshal.SizeOf<BlockHeader>());
BlockHeader bHdr = Marshal.ByteArrayToStructureBigEndianGenerated<BlockHeader>(bHdrB);
BlockHeader bHdr = Marshal.ByteArrayToStructureBigEndian<BlockHeader>(bHdrB);
AaruLogging.Debug(MODULE_NAME, "bHdr.signature = 0x{0:X8}", bHdr.signature);
AaruLogging.Debug(MODULE_NAME, "bHdr.version = {0}", bHdr.version);
@@ -371,7 +371,7 @@ public sealed partial class Udif
0,
Marshal.SizeOf<BlockChunk>());
BlockChunk bChnk = Marshal.ByteArrayToStructureBigEndianGenerated<BlockChunk>(bChnkB);
BlockChunk bChnk = Marshal.ByteArrayToStructureBigEndian<BlockChunk>(bChnkB);
AaruLogging.Debug(MODULE_NAME, "bHdr.chunk[{0}].type = 0x{1:X8}", i, bChnk.type);
AaruLogging.Debug(MODULE_NAME, "bHdr.chunk[{0}].comment = {1}", i, bChnk.comment);

View File

@@ -104,7 +104,7 @@ public sealed partial class AppleMap : IPartition
}
AppleDriverDescriptorMap ddm =
Marshal.ByteArrayToStructureBigEndianGenerated<AppleDriverDescriptorMap>(ddmSector);
Marshal.ByteArrayToStructureBigEndian<AppleDriverDescriptorMap>(ddmSector);
AaruLogging.Debug(MODULE_NAME, "ddm.sbSig = 0x{0:X4}", ddm.sbSig);
AaruLogging.Debug(MODULE_NAME, "ddm.sbBlockSize = {0}", ddm.sbBlockSize);
@@ -126,7 +126,7 @@ public sealed partial class AppleMap : IPartition
{
var tmp = new byte[8];
Array.Copy(ddmSector, 18 + i * 8, tmp, 0, 8);
ddm.sbMap[i] = Marshal.ByteArrayToStructureBigEndianGenerated<AppleDriverEntry>(tmp);
ddm.sbMap[i] = Marshal.ByteArrayToStructureBigEndian<AppleDriverEntry>(tmp);
AaruLogging.Debug(MODULE_NAME, "ddm.sbMap[{1}].ddBlock = {0}", ddm.sbMap[i].ddBlock, i);
@@ -160,7 +160,7 @@ public sealed partial class AppleMap : IPartition
if(errno != ErrorNumber.NoError) return false;
AppleOldDevicePartitionMap oldMap =
Marshal.ByteArrayToStructureBigEndianGenerated<AppleOldDevicePartitionMap>(partSector);
Marshal.ByteArrayToStructureBigEndian<AppleOldDevicePartitionMap>(partSector);
// This is the easy one, no sector size mixing
if(oldMap.pdSig == APM_MAGIC_OLD)
@@ -171,7 +171,7 @@ public sealed partial class AppleMap : IPartition
Array.Copy(partSector, i, tmp, 0, 12);
AppleMapOldPartitionEntry oldEntry =
Marshal.ByteArrayToStructureBigEndianGenerated<AppleMapOldPartitionEntry>(tmp);
Marshal.ByteArrayToStructureBigEndian<AppleMapOldPartitionEntry>(tmp);
AaruLogging.Debug(MODULE_NAME, "old_map.sbMap[{1}].pdStart = {0}", oldEntry.pdStart, (i - 2) / 12);
@@ -216,7 +216,7 @@ public sealed partial class AppleMap : IPartition
{
var tmp = new byte[512];
Array.Copy(ddmSector, 512, tmp, 0, 512);
entry = Marshal.ByteArrayToStructureBigEndianGenerated<AppleMapPartitionEntry>(tmp);
entry = Marshal.ByteArrayToStructureBigEndian<AppleMapPartitionEntry>(tmp);
// Check for a partition entry that's 512-byte aligned
if(entry.signature == APM_MAGIC)
@@ -229,7 +229,7 @@ public sealed partial class AppleMap : IPartition
}
else
{
entry = Marshal.ByteArrayToStructureBigEndianGenerated<AppleMapPartitionEntry>(partSector);
entry = Marshal.ByteArrayToStructureBigEndian<AppleMapPartitionEntry>(partSector);
if(entry.signature == APM_MAGIC)
{
@@ -245,7 +245,7 @@ public sealed partial class AppleMap : IPartition
}
else
{
entry = Marshal.ByteArrayToStructureBigEndianGenerated<AppleMapPartitionEntry>(partSector);
entry = Marshal.ByteArrayToStructureBigEndian<AppleMapPartitionEntry>(partSector);
if(entry.signature == APM_MAGIC)
{
@@ -276,7 +276,7 @@ public sealed partial class AppleMap : IPartition
{
var tmp = new byte[entrySize];
Array.Copy(entries, i * entrySize, tmp, 0, entrySize);
entry = Marshal.ByteArrayToStructureBigEndianGenerated<AppleMapPartitionEntry>(tmp);
entry = Marshal.ByteArrayToStructureBigEndian<AppleMapPartitionEntry>(tmp);
if(entry.signature != APM_MAGIC) continue;

View File

@@ -99,7 +99,7 @@ public sealed partial class Human68K : IPartition
if(errno != ErrorNumber.NoError) return false;
Table table = Marshal.ByteArrayToStructureBigEndianGenerated<Table>(sector);
Table table = Marshal.ByteArrayToStructureBigEndian<Table>(sector);
AaruLogging.Debug(MODULE_NAME, "table.magic = {0:X4}", table.magic);

View File

@@ -119,10 +119,10 @@ public sealed partial class NeXTDisklabel : IPartition
if(errno != ErrorNumber.NoError) return false;
Label label = Marshal.ByteArrayToStructureBigEndianGenerated<Label>(labelSector);
Label label = Marshal.ByteArrayToStructureBigEndian<Label>(labelSector);
var disktabB = new byte[498];
Array.Copy(labelSector, 44, disktabB, 0, 498);
label.dl_dt = Marshal.ByteArrayToStructureBigEndianGenerated<DiskTab>(disktabB);
label.dl_dt = Marshal.ByteArrayToStructureBigEndian<DiskTab>(disktabB);
label.dl_dt.d_partitions = new Entry[8];
AaruLogging.Debug(MODULE_NAME, "label.dl_version = 0x{0:X8}", label.dl_version);
@@ -169,7 +169,7 @@ public sealed partial class NeXTDisklabel : IPartition
{
var partB = new byte[44];
Array.Copy(labelSector, 44 + 146 + 44 * i, partB, 0, 44);
label.dl_dt.d_partitions[i] = Marshal.ByteArrayToStructureBigEndianGenerated<Entry>(partB);
label.dl_dt.d_partitions[i] = Marshal.ByteArrayToStructureBigEndian<Entry>(partB);
AaruLogging.Debug(MODULE_NAME,
"label.dl_dt.d_partitions[{0}].p_base = {1}",

View File

@@ -74,7 +74,7 @@ public sealed partial class SGI : IPartition
if(errno != ErrorNumber.NoError || sector.Length < 512) return false;
Label dvh = Marshal.ByteArrayToStructureBigEndianGenerated<Label>(sector);
Label dvh = Marshal.ByteArrayToStructureBigEndian<Label>(sector);
for(var i = 0; i < dvh.volume.Length; i++)
dvh.volume[i] = (Volume)Marshal.SwapStructureMembersEndian(dvh.volume[i]);

View File

@@ -119,8 +119,8 @@ public sealed partial class VTOC : IPartition
}
else
{
pd = Marshal.ByteArrayToStructureBigEndianGenerated<PDInfo>(pdsector);
pdold = Marshal.ByteArrayToStructureBigEndianGenerated<PDInfoOld>(pdsector);
pd = Marshal.ByteArrayToStructureBigEndian<PDInfo>(pdsector);
pdold = Marshal.ByteArrayToStructureBigEndian<PDInfoOld>(pdsector);
}
AaruLogging.Debug(MODULE_NAME, "pdinfo.driveid = {0}", pd.driveid);
@@ -186,7 +186,7 @@ public sealed partial class VTOC : IPartition
vtoc = Marshal.ByteArrayToStructureLittleEndian<Vtoc>(vtocsector);
else
{
vtoc = Marshal.ByteArrayToStructureBigEndianGenerated<Vtoc>(vtocsector);
vtoc = Marshal.ByteArrayToStructureBigEndian<Vtoc>(vtocsector);
for(var i = 0; i < vtoc.v_part.Length; i++)
{
@@ -213,7 +213,7 @@ public sealed partial class VTOC : IPartition
vtocOld = Marshal.ByteArrayToStructureLittleEndian<VTocOld>(vtocsector);
else
{
vtocOld = Marshal.ByteArrayToStructureBigEndianGenerated<VTocOld>(vtocsector);
vtocOld = Marshal.ByteArrayToStructureBigEndian<VTocOld>(vtocsector);
for(var i = 0; i < vtocOld.v_part.Length; i++)
{
@@ -266,7 +266,7 @@ public sealed partial class VTOC : IPartition
vtoc = Marshal.ByteArrayToStructureLittleEndian<Vtoc>(vtocsector);
else
{
vtoc = Marshal.ByteArrayToStructureBigEndianGenerated<Vtoc>(vtocsector);
vtoc = Marshal.ByteArrayToStructureBigEndian<Vtoc>(vtocsector);
for(var i = 0; i < vtoc.v_part.Length; i++)
{

View File

@@ -89,7 +89,7 @@ public sealed partial class Xbox : IPartition
if(errno != ErrorNumber.NoError || sector.Length < 512) return false;
Xbox360DevKitPartitionTable table =
Marshal.ByteArrayToStructureBigEndianGenerated<Xbox360DevKitPartitionTable>(sector);
Marshal.ByteArrayToStructureBigEndian<Xbox360DevKitPartitionTable>(sector);
if(table.magic == XBOX360_DEVKIT_MAGIC &&
table.contentOff + table.contentLen <= imagePlugin.Info.Sectors &&