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

@@ -34,10 +34,10 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using DiscImageChef.CommonTypes;
using DiscImageChef.CommonTypes.Enums;
using DiscImageChef.CommonTypes.Structs;
using DiscImageChef.Helpers;
using Schemas;
namespace DiscImageChef.DiscImages
@@ -88,7 +88,7 @@ namespace DiscImageChef.DiscImages
magic = VDI_MAGIC,
majorVersion = 1,
minorVersion = 1,
headerSize = Marshal.SizeOf(typeof(VdiHeader)) - 72,
headerSize = Marshal.SizeOf<VdiHeader>() - 72,
imageType = VdiImageType.Normal,
offsetBlocks = sectorSize,
offsetData = currentWritingPosition,
@@ -241,11 +241,11 @@ namespace DiscImageChef.DiscImages
}
}
byte[] hdr = new byte[Marshal.SizeOf(typeof(VdiHeader))];
IntPtr hdrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(VdiHeader)));
Marshal.StructureToPtr(vHdr, hdrPtr, true);
Marshal.Copy(hdrPtr, hdr, 0, hdr.Length);
Marshal.FreeHGlobal(hdrPtr);
byte[] hdr = new byte[Marshal.SizeOf<VdiHeader>()];
IntPtr hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<VdiHeader>());
System.Runtime.InteropServices.Marshal.StructureToPtr(vHdr, hdrPtr, true);
System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length);
System.Runtime.InteropServices.Marshal.FreeHGlobal(hdrPtr);
writingStream.Seek(0, SeekOrigin.Begin);
writingStream.Write(hdr, 0, hdr.Length);