Override Marshal.SizeOf in Helpers and use it instead of System's.

This commit is contained in:
2019-03-01 07:35:22 +00:00
parent 0ec558da55
commit e14c19279a
116 changed files with 1138 additions and 1182 deletions

View File

@@ -31,8 +31,8 @@
// ****************************************************************************/
using System.IO;
using System.Runtime.InteropServices;
using DiscImageChef.CommonTypes.Interfaces;
using DiscImageChef.Helpers;
namespace DiscImageChef.DiscImages
{
@@ -44,20 +44,20 @@ namespace DiscImageChef.DiscImages
if(stream.Length < 512) return false;
stream.Seek(-Marshal.SizeOf(footer), SeekOrigin.End);
byte[] footerB = new byte[Marshal.SizeOf(footer)];
stream.Seek(-Marshal.SizeOf<UdifFooter>(), SeekOrigin.End);
byte[] footerB = new byte[Marshal.SizeOf<UdifFooter>()];
stream.Read(footerB, 0, Marshal.SizeOf(footer));
footer = Helpers.Marshal.ByteArrayToStructureBigEndian<UdifFooter>(footerB);
stream.Read(footerB, 0, Marshal.SizeOf<UdifFooter>());
footer = Marshal.ByteArrayToStructureBigEndian<UdifFooter>(footerB);
if(footer.signature == UDIF_SIGNATURE) return true;
// Old UDIF as created by DiskCopy 6.5 using "OBSOLETE" format. (DiskCopy 5 rumored format?)
stream.Seek(0, SeekOrigin.Begin);
byte[] headerB = new byte[Marshal.SizeOf(footer)];
byte[] headerB = new byte[Marshal.SizeOf<UdifFooter>()];
stream.Read(headerB, 0, Marshal.SizeOf(footer));
footer = Helpers.Marshal.ByteArrayToStructureBigEndian<UdifFooter>(headerB);
stream.Read(headerB, 0, Marshal.SizeOf<UdifFooter>());
footer = Marshal.ByteArrayToStructureBigEndian<UdifFooter>(headerB);
return footer.signature == UDIF_SIGNATURE;
}