diff --git a/.idea/.idea.DiscImageChef/.idea/contentModel.xml b/.idea/.idea.DiscImageChef/.idea/contentModel.xml
index 920404cb9..4e5dcf06c 100644
--- a/.idea/.idea.DiscImageChef/.idea/contentModel.xml
+++ b/.idea/.idea.DiscImageChef/.idea/contentModel.xml
@@ -2133,6 +2133,7 @@
+
diff --git a/DiscImageChef.Decoders/ATA/Identify.cs b/DiscImageChef.Decoders/ATA/Identify.cs
index c35e85e8b..72d34c418 100644
--- a/DiscImageChef.Decoders/ATA/Identify.cs
+++ b/DiscImageChef.Decoders/ATA/Identify.cs
@@ -37,6 +37,7 @@ using System.Runtime.InteropServices;
using System.Text;
using DiscImageChef.Console;
using DiscImageChef.Decoders.SCSI;
+using Marshal = DiscImageChef.Helpers.Marshal;
namespace DiscImageChef.Decoders.ATA
{
@@ -1863,10 +1864,7 @@ namespace DiscImageChef.Decoders.ATA
return null;
}
- IntPtr ptr = Marshal.AllocHGlobal(512);
- Marshal.Copy(IdentifyDeviceResponse, 0, ptr, 512);
- IdentifyDevice ATAID = (IdentifyDevice)Marshal.PtrToStructure(ptr, typeof(IdentifyDevice));
- Marshal.FreeHGlobal(ptr);
+ IdentifyDevice ATAID = Marshal.ByteArrayToStructureLittleEndian(IdentifyDeviceResponse);
ATAID.WWN = DescrambleWWN(ATAID.WWN);
ATAID.WWNExtension = DescrambleWWN(ATAID.WWNExtension);
@@ -1891,10 +1889,10 @@ namespace DiscImageChef.Decoders.ATA
ataId.WWNExtension = DescrambleWWN(ataId.WWNExtension);
byte[] buf = new byte[512];
- IntPtr ptr = Marshal.AllocHGlobal(512);
- Marshal.StructureToPtr(ataId, ptr, false);
- Marshal.Copy(ptr, buf, 0, 512);
- Marshal.FreeHGlobal(ptr);
+ IntPtr ptr = System.Runtime.InteropServices.Marshal.AllocHGlobal(512);
+ System.Runtime.InteropServices.Marshal.StructureToPtr(ataId, ptr, false);
+ System.Runtime.InteropServices.Marshal.Copy(ptr, buf, 0, 512);
+ System.Runtime.InteropServices.Marshal.FreeHGlobal(ptr);
byte[] str = ScrambleATAString(ataId.SerialNumber, 20);
Array.Copy(str, 0, buf, 10 * 2, 20);
diff --git a/DiscImageChef.Decoders/Sega/CD.cs b/DiscImageChef.Decoders/Sega/CD.cs
index da5425621..0755a67fc 100644
--- a/DiscImageChef.Decoders/Sega/CD.cs
+++ b/DiscImageChef.Decoders/Sega/CD.cs
@@ -36,6 +36,7 @@ using System.Globalization;
using System.Runtime.InteropServices;
using System.Text;
using DiscImageChef.Console;
+using Marshal = DiscImageChef.Helpers.Marshal;
namespace DiscImageChef.Decoders.Sega
{
@@ -134,10 +135,7 @@ namespace DiscImageChef.Decoders.Sega
if(ipbin_sector.Length < 512) return null;
- IntPtr ptr = Marshal.AllocHGlobal(512);
- Marshal.Copy(ipbin_sector, 0, ptr, 512);
- IPBin ipbin = (IPBin)Marshal.PtrToStructure(ptr, typeof(IPBin));
- Marshal.FreeHGlobal(ptr);
+ IPBin ipbin = Marshal.ByteArrayToStructureLittleEndian(ipbin_sector);
DicConsole.DebugWriteLine("SegaCD IP.BIN Decoder", "segacd_ipbin.volume_name = \"{0}\"",
Encoding.ASCII.GetString(ipbin.volume_name));
diff --git a/DiscImageChef.Decoders/Sega/Dreamcast.cs b/DiscImageChef.Decoders/Sega/Dreamcast.cs
index 53dc06607..16e0d09b0 100644
--- a/DiscImageChef.Decoders/Sega/Dreamcast.cs
+++ b/DiscImageChef.Decoders/Sega/Dreamcast.cs
@@ -36,6 +36,7 @@ using System.Globalization;
using System.Runtime.InteropServices;
using System.Text;
using DiscImageChef.Console;
+using Marshal = DiscImageChef.Helpers.Marshal;
namespace DiscImageChef.Decoders.Sega
{
@@ -109,10 +110,7 @@ namespace DiscImageChef.Decoders.Sega
if(ipbin_sector.Length < 512) return null;
- IntPtr ptr = Marshal.AllocHGlobal(512);
- Marshal.Copy(ipbin_sector, 0, ptr, 512);
- IPBin ipbin = (IPBin)Marshal.PtrToStructure(ptr, typeof(IPBin));
- Marshal.FreeHGlobal(ptr);
+ IPBin ipbin = Marshal.ByteArrayToStructureLittleEndian(ipbin_sector);
DicConsole.DebugWriteLine("Dreamcast IP.BIN Decoder", "dreamcast_ipbin.maker_id = \"{0}\"",
Encoding.ASCII.GetString(ipbin.maker_id));
diff --git a/DiscImageChef.Decoders/Sega/Saturn.cs b/DiscImageChef.Decoders/Sega/Saturn.cs
index 9352f5a68..b6a7625b1 100644
--- a/DiscImageChef.Decoders/Sega/Saturn.cs
+++ b/DiscImageChef.Decoders/Sega/Saturn.cs
@@ -36,6 +36,7 @@ using System.Globalization;
using System.Runtime.InteropServices;
using System.Text;
using DiscImageChef.Console;
+using Marshal = DiscImageChef.Helpers.Marshal;
namespace DiscImageChef.Decoders.Sega
{
@@ -91,10 +92,7 @@ namespace DiscImageChef.Decoders.Sega
if(ipbin_sector.Length < 512) return null;
- IntPtr ptr = Marshal.AllocHGlobal(512);
- Marshal.Copy(ipbin_sector, 0, ptr, 512);
- IPBin ipbin = (IPBin)Marshal.PtrToStructure(ptr, typeof(IPBin));
- Marshal.FreeHGlobal(ptr);
+ IPBin ipbin = Marshal.ByteArrayToStructureLittleEndian(ipbin_sector);
DicConsole.DebugWriteLine("Saturn IP.BIN Decoder", "saturn_ipbin.maker_id = \"{0}\"",
Encoding.ASCII.GetString(ipbin.maker_id));