mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Override Marshal.SizeOf in Helpers and use it instead of System's.
This commit is contained in:
@@ -31,9 +31,9 @@
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using DiscImageChef.Console;
|
||||
using DiscImageChef.Helpers;
|
||||
|
||||
namespace DiscImageChef.DiscImages
|
||||
{
|
||||
@@ -44,14 +44,12 @@ namespace DiscImageChef.DiscImages
|
||||
Stream stream = imageFilter.GetDataForkStream();
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
fdihdr = new Anex86Header();
|
||||
if(stream.Length < Marshal.SizeOf<Anex86Header>()) return false;
|
||||
|
||||
if(stream.Length < Marshal.SizeOf(fdihdr)) return false;
|
||||
|
||||
byte[] hdrB = new byte[Marshal.SizeOf(fdihdr)];
|
||||
byte[] hdrB = new byte[Marshal.SizeOf<Anex86Header>()];
|
||||
stream.Read(hdrB, 0, hdrB.Length);
|
||||
|
||||
fdihdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<Anex86Header>(hdrB);
|
||||
fdihdr = Marshal.ByteArrayToStructureLittleEndian<Anex86Header>(hdrB);
|
||||
|
||||
DicConsole.DebugWriteLine("Anex86 plugin", "fdihdr.unknown = {0}", fdihdr.unknown);
|
||||
DicConsole.DebugWriteLine("Anex86 plugin", "fdihdr.hddtype = {0}", fdihdr.hddtype);
|
||||
|
||||
@@ -32,11 +32,11 @@
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.CommonTypes.Enums;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using DiscImageChef.Console;
|
||||
using DiscImageChef.Helpers;
|
||||
|
||||
namespace DiscImageChef.DiscImages
|
||||
{
|
||||
@@ -47,14 +47,12 @@ namespace DiscImageChef.DiscImages
|
||||
Stream stream = imageFilter.GetDataForkStream();
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
fdihdr = new Anex86Header();
|
||||
if(stream.Length < Marshal.SizeOf<Anex86Header>()) return false;
|
||||
|
||||
if(stream.Length < Marshal.SizeOf(fdihdr)) return false;
|
||||
|
||||
byte[] hdrB = new byte[Marshal.SizeOf(fdihdr)];
|
||||
byte[] hdrB = new byte[Marshal.SizeOf<Anex86Header>()];
|
||||
stream.Read(hdrB, 0, hdrB.Length);
|
||||
|
||||
fdihdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<Anex86Header>(hdrB);
|
||||
fdihdr = Marshal.ByteArrayToStructureLittleEndian<Anex86Header>(hdrB);
|
||||
|
||||
imageInfo.MediaType = Geometry.GetMediaType(((ushort)fdihdr.cylinders, (byte)fdihdr.heads,
|
||||
(ushort)fdihdr.spt, (uint)fdihdr.bps, MediaEncoding.MFM,
|
||||
|
||||
@@ -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
|
||||
@@ -187,11 +187,11 @@ namespace DiscImageChef.DiscImages
|
||||
}
|
||||
}
|
||||
|
||||
byte[] hdr = new byte[Marshal.SizeOf(fdihdr)];
|
||||
IntPtr hdrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(fdihdr));
|
||||
Marshal.StructureToPtr(fdihdr, hdrPtr, true);
|
||||
Marshal.Copy(hdrPtr, hdr, 0, hdr.Length);
|
||||
Marshal.FreeHGlobal(hdrPtr);
|
||||
byte[] hdr = new byte[Marshal.SizeOf<Anex86Header>()];
|
||||
IntPtr hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<Anex86Header>());
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(fdihdr, 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);
|
||||
|
||||
Reference in New Issue
Block a user