mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Use new little endian marshaller on media images.
This commit is contained in:
@@ -30,11 +30,10 @@
|
|||||||
// Copyright © 2011-2019 Natalia Portillo
|
// Copyright © 2011-2019 Natalia Portillo
|
||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using DiscImageChef.CommonTypes.Interfaces;
|
using DiscImageChef.CommonTypes.Interfaces;
|
||||||
|
using DiscImageChef.Helpers;
|
||||||
|
|
||||||
namespace DiscImageChef.DiscImages
|
namespace DiscImageChef.DiscImages
|
||||||
{
|
{
|
||||||
@@ -48,10 +47,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
byte[] hdr = new byte[88];
|
byte[] hdr = new byte[88];
|
||||||
stream.Read(hdr, 0, 88);
|
stream.Read(hdr, 0, 88);
|
||||||
IntPtr hdrPtr = Marshal.AllocHGlobal(88);
|
AlcoholHeader header = Marshal.ByteArrayToStructureLittleEndian<AlcoholHeader>(hdr);
|
||||||
Marshal.Copy(hdr, 0, hdrPtr, 88);
|
|
||||||
AlcoholHeader header = (AlcoholHeader)Marshal.PtrToStructure(hdrPtr, typeof(AlcoholHeader));
|
|
||||||
Marshal.FreeHGlobal(hdrPtr);
|
|
||||||
|
|
||||||
return header.signature.SequenceEqual(alcoholSignature);
|
return header.signature.SequenceEqual(alcoholSignature);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using DiscImageChef.CommonTypes;
|
using DiscImageChef.CommonTypes;
|
||||||
using DiscImageChef.CommonTypes.Enums;
|
using DiscImageChef.CommonTypes.Enums;
|
||||||
@@ -44,6 +43,7 @@ using DiscImageChef.CommonTypes.Structs;
|
|||||||
using DiscImageChef.Console;
|
using DiscImageChef.Console;
|
||||||
using DiscImageChef.Decoders.CD;
|
using DiscImageChef.Decoders.CD;
|
||||||
using DiscImageChef.Decoders.DVD;
|
using DiscImageChef.Decoders.DVD;
|
||||||
|
using DiscImageChef.Helpers;
|
||||||
using DMI = DiscImageChef.Decoders.Xbox.DMI;
|
using DMI = DiscImageChef.Decoders.Xbox.DMI;
|
||||||
using Session = DiscImageChef.CommonTypes.Structs.Session;
|
using Session = DiscImageChef.CommonTypes.Structs.Session;
|
||||||
|
|
||||||
@@ -60,10 +60,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
isDvd = false;
|
isDvd = false;
|
||||||
byte[] hdr = new byte[88];
|
byte[] hdr = new byte[88];
|
||||||
stream.Read(hdr, 0, 88);
|
stream.Read(hdr, 0, 88);
|
||||||
IntPtr hdrPtr = Marshal.AllocHGlobal(88);
|
AlcoholHeader header = Marshal.ByteArrayToStructureLittleEndian<AlcoholHeader>(hdr);
|
||||||
Marshal.Copy(hdr, 0, hdrPtr, 88);
|
|
||||||
AlcoholHeader header = (AlcoholHeader)Marshal.PtrToStructure(hdrPtr, typeof(AlcoholHeader));
|
|
||||||
Marshal.FreeHGlobal(hdrPtr);
|
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("Alcohol 120% plugin", "header.signature = {0}",
|
DicConsole.DebugWriteLine("Alcohol 120% plugin", "header.signature = {0}",
|
||||||
Encoding.ASCII.GetString(header.signature));
|
Encoding.ASCII.GetString(header.signature));
|
||||||
@@ -99,10 +96,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
{
|
{
|
||||||
byte[] sesHdr = new byte[24];
|
byte[] sesHdr = new byte[24];
|
||||||
stream.Read(sesHdr, 0, 24);
|
stream.Read(sesHdr, 0, 24);
|
||||||
IntPtr sesPtr = Marshal.AllocHGlobal(24);
|
AlcoholSession session = Marshal.ByteArrayToStructureLittleEndian<AlcoholSession>(sesHdr);
|
||||||
Marshal.Copy(sesHdr, 0, sesPtr, 24);
|
|
||||||
AlcoholSession session = (AlcoholSession)Marshal.PtrToStructure(sesPtr, typeof(AlcoholSession));
|
|
||||||
Marshal.FreeHGlobal(sesPtr);
|
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("Alcohol 120% plugin", "session[{1}].sessionStart = {0}",
|
DicConsole.DebugWriteLine("Alcohol 120% plugin", "session[{1}].sessionStart = {0}",
|
||||||
session.sessionStart, i);
|
session.sessionStart, i);
|
||||||
@@ -138,10 +132,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
{
|
{
|
||||||
byte[] trkHdr = new byte[80];
|
byte[] trkHdr = new byte[80];
|
||||||
stream.Read(trkHdr, 0, 80);
|
stream.Read(trkHdr, 0, 80);
|
||||||
IntPtr trkPtr = Marshal.AllocHGlobal(80);
|
AlcoholTrack track = Marshal.ByteArrayToStructureLittleEndian<AlcoholTrack>(trkHdr);
|
||||||
Marshal.Copy(trkHdr, 0, trkPtr, 80);
|
|
||||||
AlcoholTrack track = (AlcoholTrack)Marshal.PtrToStructure(trkPtr, typeof(AlcoholTrack));
|
|
||||||
Marshal.FreeHGlobal(trkPtr);
|
|
||||||
|
|
||||||
if(track.mode == AlcoholTrackMode.Mode2F1Alt || track.mode == AlcoholTrackMode.Mode2F1Alt)
|
if(track.mode == AlcoholTrackMode.Mode2F1Alt || track.mode == AlcoholTrackMode.Mode2F1Alt)
|
||||||
oldIncorrectImage = true;
|
oldIncorrectImage = true;
|
||||||
@@ -216,11 +207,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
byte[] extHdr = new byte[8];
|
byte[] extHdr = new byte[8];
|
||||||
stream.Seek(track.extraOffset, SeekOrigin.Begin);
|
stream.Seek(track.extraOffset, SeekOrigin.Begin);
|
||||||
stream.Read(extHdr, 0, 8);
|
stream.Read(extHdr, 0, 8);
|
||||||
IntPtr extPtr = Marshal.AllocHGlobal(8);
|
AlcoholTrackExtra extra = Marshal.ByteArrayToStructureLittleEndian<AlcoholTrackExtra>(extHdr);
|
||||||
Marshal.Copy(extHdr, 0, extPtr, 8);
|
|
||||||
AlcoholTrackExtra extra =
|
|
||||||
(AlcoholTrackExtra)Marshal.PtrToStructure(extPtr, typeof(AlcoholTrackExtra));
|
|
||||||
Marshal.FreeHGlobal(extPtr);
|
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("Alcohol 120% plugin", "track[{1}].extra.pregap = {0}", extra.pregap,
|
DicConsole.DebugWriteLine("Alcohol 120% plugin", "track[{1}].extra.pregap = {0}", extra.pregap,
|
||||||
track.point);
|
track.point);
|
||||||
@@ -240,11 +227,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
byte[] footer = new byte[16];
|
byte[] footer = new byte[16];
|
||||||
stream.Seek(footerOff, SeekOrigin.Begin);
|
stream.Seek(footerOff, SeekOrigin.Begin);
|
||||||
stream.Read(footer, 0, 16);
|
stream.Read(footer, 0, 16);
|
||||||
alcFooter = new AlcoholFooter();
|
alcFooter = Marshal.ByteArrayToStructureLittleEndian<AlcoholFooter>(footer);
|
||||||
IntPtr footPtr = Marshal.AllocHGlobal(16);
|
|
||||||
Marshal.Copy(footer, 0, footPtr, 16);
|
|
||||||
alcFooter = (AlcoholFooter)Marshal.PtrToStructure(footPtr, typeof(AlcoholFooter));
|
|
||||||
Marshal.FreeHGlobal(footPtr);
|
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("Alcohol 120% plugin", "footer.filenameOffset = {0}",
|
DicConsole.DebugWriteLine("Alcohol 120% plugin", "footer.filenameOffset = {0}",
|
||||||
alcFooter.filenameOffset);
|
alcFooter.filenameOffset);
|
||||||
|
|||||||
@@ -51,9 +51,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
byte[] hdrB = new byte[Marshal.SizeOf(fdihdr)];
|
byte[] hdrB = new byte[Marshal.SizeOf(fdihdr)];
|
||||||
stream.Read(hdrB, 0, hdrB.Length);
|
stream.Read(hdrB, 0, hdrB.Length);
|
||||||
|
|
||||||
GCHandle handle = GCHandle.Alloc(hdrB, GCHandleType.Pinned);
|
fdihdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<Anex86Header>(hdrB);
|
||||||
fdihdr = (Anex86Header)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(Anex86Header));
|
|
||||||
handle.Free();
|
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("Anex86 plugin", "fdihdr.unknown = {0}", fdihdr.unknown);
|
DicConsole.DebugWriteLine("Anex86 plugin", "fdihdr.unknown = {0}", fdihdr.unknown);
|
||||||
DicConsole.DebugWriteLine("Anex86 plugin", "fdihdr.hddtype = {0}", fdihdr.hddtype);
|
DicConsole.DebugWriteLine("Anex86 plugin", "fdihdr.hddtype = {0}", fdihdr.hddtype);
|
||||||
|
|||||||
@@ -54,9 +54,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
byte[] hdrB = new byte[Marshal.SizeOf(fdihdr)];
|
byte[] hdrB = new byte[Marshal.SizeOf(fdihdr)];
|
||||||
stream.Read(hdrB, 0, hdrB.Length);
|
stream.Read(hdrB, 0, hdrB.Length);
|
||||||
|
|
||||||
GCHandle handle = GCHandle.Alloc(hdrB, GCHandleType.Pinned);
|
fdihdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<Anex86Header>(hdrB);
|
||||||
fdihdr = (Anex86Header)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(Anex86Header));
|
|
||||||
handle.Free();
|
|
||||||
|
|
||||||
imageInfo.MediaType = Geometry.GetMediaType(((ushort)fdihdr.cylinders, (byte)fdihdr.heads,
|
imageInfo.MediaType = Geometry.GetMediaType(((ushort)fdihdr.cylinders, (byte)fdihdr.heads,
|
||||||
(ushort)fdihdr.spt, (uint)fdihdr.bps, MediaEncoding.MFM,
|
(ushort)fdihdr.spt, (uint)fdihdr.bps, MediaEncoding.MFM,
|
||||||
|
|||||||
@@ -62,10 +62,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
byte[] recB = new byte[recordSize];
|
byte[] recB = new byte[recordSize];
|
||||||
stream.Read(recB, 0, recordSize);
|
stream.Read(recB, 0, recordSize);
|
||||||
|
|
||||||
GCHandle handle = GCHandle.Alloc(recB, GCHandleType.Pinned);
|
ApridiskRecord record = Helpers.Marshal.ByteArrayToStructureLittleEndian<ApridiskRecord>(recB);
|
||||||
ApridiskRecord record =
|
|
||||||
(ApridiskRecord)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(ApridiskRecord));
|
|
||||||
handle.Free();
|
|
||||||
|
|
||||||
switch(record.type)
|
switch(record.type)
|
||||||
{
|
{
|
||||||
@@ -152,10 +149,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
byte[] recB = new byte[recordSize];
|
byte[] recB = new byte[recordSize];
|
||||||
stream.Read(recB, 0, recordSize);
|
stream.Read(recB, 0, recordSize);
|
||||||
|
|
||||||
GCHandle handle = GCHandle.Alloc(recB, GCHandleType.Pinned);
|
ApridiskRecord record = Helpers.Marshal.ByteArrayToStructureLittleEndian<ApridiskRecord>(recB);
|
||||||
ApridiskRecord record =
|
|
||||||
(ApridiskRecord)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(ApridiskRecord));
|
|
||||||
handle.Free();
|
|
||||||
|
|
||||||
switch(record.type)
|
switch(record.type)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ using System.Collections.Generic;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using DiscImageChef.CommonTypes;
|
using DiscImageChef.CommonTypes;
|
||||||
using DiscImageChef.CommonTypes.Enums;
|
using DiscImageChef.CommonTypes.Enums;
|
||||||
@@ -47,6 +46,7 @@ using DiscImageChef.Decoders.CD;
|
|||||||
using DiscImageChef.Decoders.DVD;
|
using DiscImageChef.Decoders.DVD;
|
||||||
using DiscImageChef.Decoders.SCSI;
|
using DiscImageChef.Decoders.SCSI;
|
||||||
using DiscImageChef.Decoders.SCSI.MMC;
|
using DiscImageChef.Decoders.SCSI.MMC;
|
||||||
|
using DiscImageChef.Helpers;
|
||||||
using DMI = DiscImageChef.Decoders.Xbox.DMI;
|
using DMI = DiscImageChef.Decoders.Xbox.DMI;
|
||||||
using Session = DiscImageChef.CommonTypes.Structs.Session;
|
using Session = DiscImageChef.CommonTypes.Structs.Session;
|
||||||
|
|
||||||
@@ -62,11 +62,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
byte[] hdr = new byte[260];
|
byte[] hdr = new byte[260];
|
||||||
stream.Read(hdr, 0, 260);
|
stream.Read(hdr, 0, 260);
|
||||||
header = new Bw5Header();
|
header = Marshal.ByteArrayToStructureLittleEndian<Bw5Header>(hdr);
|
||||||
IntPtr hdrPtr = Marshal.AllocHGlobal(260);
|
|
||||||
Marshal.Copy(hdr, 0, hdrPtr, 260);
|
|
||||||
header = (Bw5Header)Marshal.PtrToStructure(hdrPtr, typeof(Bw5Header));
|
|
||||||
Marshal.FreeHGlobal(hdrPtr);
|
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("BlindWrite5 plugin", "header.signature = {0}",
|
DicConsole.DebugWriteLine("BlindWrite5 plugin", "header.signature = {0}",
|
||||||
StringHandlers.CToString(header.signature));
|
StringHandlers.CToString(header.signature));
|
||||||
@@ -328,12 +324,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
{
|
{
|
||||||
byte[] trk = new byte[72];
|
byte[] trk = new byte[72];
|
||||||
stream.Read(trk, 0, 72);
|
stream.Read(trk, 0, 72);
|
||||||
session.Tracks[tSeq] = new Bw5TrackDescriptor();
|
session.Tracks[tSeq] = Marshal.ByteArrayToStructureLittleEndian<Bw5TrackDescriptor>(trk);
|
||||||
IntPtr trkPtr = Marshal.AllocHGlobal(72);
|
|
||||||
Marshal.Copy(trk, 0, trkPtr, 72);
|
|
||||||
session.Tracks[tSeq] =
|
|
||||||
(Bw5TrackDescriptor)Marshal.PtrToStructure(trkPtr, typeof(Bw5TrackDescriptor));
|
|
||||||
Marshal.FreeHGlobal(trkPtr);
|
|
||||||
|
|
||||||
if(session.Tracks[tSeq].type == Bw5TrackType.Dvd ||
|
if(session.Tracks[tSeq].type == Bw5TrackType.Dvd ||
|
||||||
session.Tracks[tSeq].type == Bw5TrackType.NotData)
|
session.Tracks[tSeq].type == Bw5TrackType.NotData)
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using DiscImageChef.CommonTypes;
|
using DiscImageChef.CommonTypes;
|
||||||
@@ -44,7 +43,7 @@ using DiscImageChef.CommonTypes.Interfaces;
|
|||||||
using DiscImageChef.CommonTypes.Structs;
|
using DiscImageChef.CommonTypes.Structs;
|
||||||
using DiscImageChef.Console;
|
using DiscImageChef.Console;
|
||||||
using DiscImageChef.Decoders.ATA;
|
using DiscImageChef.Decoders.ATA;
|
||||||
using Marshal = DiscImageChef.Helpers.Marshal;
|
using DiscImageChef.Helpers;
|
||||||
|
|
||||||
namespace DiscImageChef.DiscImages
|
namespace DiscImageChef.DiscImages
|
||||||
{
|
{
|
||||||
@@ -111,12 +110,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
stream.Read(hunkSectorBytes, 0, 512);
|
stream.Read(hunkSectorBytes, 0, 512);
|
||||||
// This does the big-endian trick but reverses the order of elements also
|
// This does the big-endian trick but reverses the order of elements also
|
||||||
Array.Reverse(hunkSectorBytes);
|
Array.Reverse(hunkSectorBytes);
|
||||||
GCHandle handle = GCHandle.Alloc(hunkSectorBytes, GCHandleType.Pinned);
|
HunkSector hunkSector = Marshal.ByteArrayToStructureLittleEndian<HunkSector>(hunkSectorBytes);
|
||||||
HunkSector hunkSector =
|
|
||||||
(HunkSector)
|
|
||||||
System.Runtime.InteropServices.Marshal.PtrToStructure(handle.AddrOfPinnedObject(),
|
|
||||||
typeof(HunkSector));
|
|
||||||
handle.Free();
|
|
||||||
// This restores the order of elements
|
// This restores the order of elements
|
||||||
Array.Reverse(hunkSector.hunkEntry);
|
Array.Reverse(hunkSector.hunkEntry);
|
||||||
if(hunkTable.Length >= i * 512 / 8 + 512 / 8)
|
if(hunkTable.Length >= i * 512 / 8 + 512 / 8)
|
||||||
@@ -186,12 +180,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
stream.Read(hunkSectorBytes, 0, 512);
|
stream.Read(hunkSectorBytes, 0, 512);
|
||||||
// This does the big-endian trick but reverses the order of elements also
|
// This does the big-endian trick but reverses the order of elements also
|
||||||
Array.Reverse(hunkSectorBytes);
|
Array.Reverse(hunkSectorBytes);
|
||||||
GCHandle handle = GCHandle.Alloc(hunkSectorBytes, GCHandleType.Pinned);
|
HunkSector hunkSector = Marshal.ByteArrayToStructureLittleEndian<HunkSector>(hunkSectorBytes);
|
||||||
HunkSector hunkSector =
|
|
||||||
(HunkSector)
|
|
||||||
System.Runtime.InteropServices.Marshal.PtrToStructure(handle.AddrOfPinnedObject(),
|
|
||||||
typeof(HunkSector));
|
|
||||||
handle.Free();
|
|
||||||
// This restores the order of elements
|
// This restores the order of elements
|
||||||
Array.Reverse(hunkSector.hunkEntry);
|
Array.Reverse(hunkSector.hunkEntry);
|
||||||
if(hunkTable.Length >= i * 512 / 8 + 512 / 8)
|
if(hunkTable.Length >= i * 512 / 8 + 512 / 8)
|
||||||
@@ -369,12 +358,8 @@ namespace DiscImageChef.DiscImages
|
|||||||
stream.Read(hunkSectorBytes, 0, 512);
|
stream.Read(hunkSectorBytes, 0, 512);
|
||||||
// This does the big-endian trick but reverses the order of elements also
|
// This does the big-endian trick but reverses the order of elements also
|
||||||
Array.Reverse(hunkSectorBytes);
|
Array.Reverse(hunkSectorBytes);
|
||||||
GCHandle handle = GCHandle.Alloc(hunkSectorBytes, GCHandleType.Pinned);
|
|
||||||
HunkSectorSmall hunkSector =
|
HunkSectorSmall hunkSector =
|
||||||
(HunkSectorSmall)
|
Marshal.ByteArrayToStructureLittleEndian<HunkSectorSmall>(hunkSectorBytes);
|
||||||
System.Runtime.InteropServices.Marshal.PtrToStructure(handle.AddrOfPinnedObject(),
|
|
||||||
typeof(HunkSectorSmall));
|
|
||||||
handle.Free();
|
|
||||||
// This restores the order of elements
|
// This restores the order of elements
|
||||||
Array.Reverse(hunkSector.hunkEntry);
|
Array.Reverse(hunkSector.hunkEntry);
|
||||||
if(hunkTableSmall.Length >= i * 512 / 4 + 512 / 4)
|
if(hunkTableSmall.Length >= i * 512 / 4 + 512 / 4)
|
||||||
|
|||||||
@@ -30,12 +30,11 @@
|
|||||||
// Copyright © 2011-2019 Natalia Portillo
|
// Copyright © 2011-2019 Natalia Portillo
|
||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using DiscImageChef.CommonTypes.Interfaces;
|
using DiscImageChef.CommonTypes.Interfaces;
|
||||||
using DiscImageChef.Console;
|
using DiscImageChef.Console;
|
||||||
|
using DiscImageChef.Helpers;
|
||||||
|
|
||||||
namespace DiscImageChef.DiscImages
|
namespace DiscImageChef.DiscImages
|
||||||
{
|
{
|
||||||
@@ -50,10 +49,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
byte[] headerB = new byte[256];
|
byte[] headerB = new byte[256];
|
||||||
stream.Read(headerB, 0, 256);
|
stream.Read(headerB, 0, 256);
|
||||||
IntPtr headerPtr = Marshal.AllocHGlobal(256);
|
CpcDiskInfo header = Marshal.ByteArrayToStructureLittleEndian<CpcDiskInfo>(headerB);
|
||||||
Marshal.Copy(headerB, 0, headerPtr, 256);
|
|
||||||
CpcDiskInfo header = (CpcDiskInfo)Marshal.PtrToStructure(headerPtr, typeof(CpcDiskInfo));
|
|
||||||
Marshal.FreeHGlobal(headerPtr);
|
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("CPCDSK plugin", "header.magic = \"{0}\"",
|
DicConsole.DebugWriteLine("CPCDSK plugin", "header.magic = \"{0}\"",
|
||||||
StringHandlers.CToString(header.magic));
|
StringHandlers.CToString(header.magic));
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using DiscImageChef.Checksums;
|
using DiscImageChef.Checksums;
|
||||||
using DiscImageChef.CommonTypes;
|
using DiscImageChef.CommonTypes;
|
||||||
using DiscImageChef.CommonTypes.Enums;
|
using DiscImageChef.CommonTypes.Enums;
|
||||||
@@ -42,6 +41,7 @@ using DiscImageChef.CommonTypes.Exceptions;
|
|||||||
using DiscImageChef.CommonTypes.Interfaces;
|
using DiscImageChef.CommonTypes.Interfaces;
|
||||||
using DiscImageChef.Console;
|
using DiscImageChef.Console;
|
||||||
using DiscImageChef.Decoders.Floppy;
|
using DiscImageChef.Decoders.Floppy;
|
||||||
|
using DiscImageChef.Helpers;
|
||||||
|
|
||||||
namespace DiscImageChef.DiscImages
|
namespace DiscImageChef.DiscImages
|
||||||
{
|
{
|
||||||
@@ -56,10 +56,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
byte[] headerB = new byte[256];
|
byte[] headerB = new byte[256];
|
||||||
stream.Read(headerB, 0, 256);
|
stream.Read(headerB, 0, 256);
|
||||||
IntPtr headerPtr = Marshal.AllocHGlobal(256);
|
CpcDiskInfo header = Marshal.ByteArrayToStructureLittleEndian<CpcDiskInfo>(headerB);
|
||||||
Marshal.Copy(headerB, 0, headerPtr, 256);
|
|
||||||
CpcDiskInfo header = (CpcDiskInfo)Marshal.PtrToStructure(headerPtr, typeof(CpcDiskInfo));
|
|
||||||
Marshal.FreeHGlobal(headerPtr);
|
|
||||||
|
|
||||||
if(!cpcdskId.SequenceEqual(header.magic) && !edskId.SequenceEqual(header.magic) &&
|
if(!cpcdskId.SequenceEqual(header.magic) && !edskId.SequenceEqual(header.magic) &&
|
||||||
!du54Id.SequenceEqual(header.magic)) return false;
|
!du54Id.SequenceEqual(header.magic)) return false;
|
||||||
@@ -103,10 +100,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
byte[] trackB = new byte[256];
|
byte[] trackB = new byte[256];
|
||||||
stream.Read(trackB, 0, 256);
|
stream.Read(trackB, 0, 256);
|
||||||
IntPtr trackPtr = Marshal.AllocHGlobal(256);
|
CpcTrackInfo trackInfo = Marshal.ByteArrayToStructureLittleEndian<CpcTrackInfo>(trackB);
|
||||||
Marshal.Copy(trackB, 0, trackPtr, 256);
|
|
||||||
CpcTrackInfo trackInfo = (CpcTrackInfo)Marshal.PtrToStructure(trackPtr, typeof(CpcTrackInfo));
|
|
||||||
Marshal.FreeHGlobal(trackPtr);
|
|
||||||
|
|
||||||
if(!trackId.SequenceEqual(trackInfo.magic))
|
if(!trackId.SequenceEqual(trackInfo.magic))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,11 +32,11 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using DiscImageChef.CommonTypes;
|
using DiscImageChef.CommonTypes;
|
||||||
using DiscImageChef.CommonTypes.Enums;
|
using DiscImageChef.CommonTypes.Enums;
|
||||||
using DiscImageChef.CommonTypes.Interfaces;
|
using DiscImageChef.CommonTypes.Interfaces;
|
||||||
using DiscImageChef.Console;
|
using DiscImageChef.Console;
|
||||||
|
using DiscImageChef.Helpers;
|
||||||
|
|
||||||
namespace DiscImageChef.DiscImages
|
namespace DiscImageChef.DiscImages
|
||||||
{
|
{
|
||||||
@@ -50,11 +50,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
byte[] hdr = new byte[133];
|
byte[] hdr = new byte[133];
|
||||||
|
|
||||||
stream.Read(hdr, 0, 133);
|
stream.Read(hdr, 0, 133);
|
||||||
header = new CopyQmHeader();
|
header = Marshal.ByteArrayToStructureLittleEndian<CopyQmHeader>(hdr);
|
||||||
IntPtr hdrPtr = Marshal.AllocHGlobal(133);
|
|
||||||
Marshal.Copy(hdr, 0, hdrPtr, 133);
|
|
||||||
header = (CopyQmHeader)Marshal.PtrToStructure(hdrPtr, typeof(CopyQmHeader));
|
|
||||||
Marshal.FreeHGlobal(hdrPtr);
|
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("CopyQM plugin", "header.magic = 0x{0:X4}", header.magic);
|
DicConsole.DebugWriteLine("CopyQM plugin", "header.magic = 0x{0:X4}", header.magic);
|
||||||
DicConsole.DebugWriteLine("CopyQM plugin", "header.mark = 0x{0:X2}", header.mark);
|
DicConsole.DebugWriteLine("CopyQM plugin", "header.mark = 0x{0:X2}", header.mark);
|
||||||
@@ -187,8 +183,6 @@ namespace DiscImageChef.DiscImages
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool? VerifyMediaImage() => calculatedDataCrc == header.crc && headerChecksumOk;
|
|
||||||
|
|
||||||
public byte[] ReadSector(ulong sectorAddress) => ReadSectors(sectorAddress, 1);
|
public byte[] ReadSector(ulong sectorAddress) => ReadSectors(sectorAddress, 1);
|
||||||
|
|
||||||
public byte[] ReadSectors(ulong sectorAddress, uint length)
|
public byte[] ReadSectors(ulong sectorAddress, uint length)
|
||||||
@@ -206,5 +200,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool? VerifyMediaImage() => calculatedDataCrc == header.crc && headerChecksumOk;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -55,9 +55,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
byte[] hdrB = new byte[Marshal.SizeOf(d88Hdr)];
|
byte[] hdrB = new byte[Marshal.SizeOf(d88Hdr)];
|
||||||
stream.Read(hdrB, 0, hdrB.Length);
|
stream.Read(hdrB, 0, hdrB.Length);
|
||||||
|
|
||||||
GCHandle handle = GCHandle.Alloc(hdrB, GCHandleType.Pinned);
|
d88Hdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<D88Header>(hdrB);
|
||||||
d88Hdr = (D88Header)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(D88Header));
|
|
||||||
handle.Free();
|
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("D88 plugin", "d88hdr.name = \"{0}\"",
|
DicConsole.DebugWriteLine("D88 plugin", "d88hdr.name = \"{0}\"",
|
||||||
StringHandlers.CToString(d88Hdr.name, shiftjis));
|
StringHandlers.CToString(d88Hdr.name, shiftjis));
|
||||||
|
|||||||
@@ -59,10 +59,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
byte[] hdrB = new byte[Marshal.SizeOf(d88Hdr)];
|
byte[] hdrB = new byte[Marshal.SizeOf(d88Hdr)];
|
||||||
stream.Read(hdrB, 0, hdrB.Length);
|
stream.Read(hdrB, 0, hdrB.Length);
|
||||||
|
d88Hdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<D88Header>(hdrB);
|
||||||
GCHandle handle = GCHandle.Alloc(hdrB, GCHandleType.Pinned);
|
|
||||||
d88Hdr = (D88Header)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(D88Header));
|
|
||||||
handle.Free();
|
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("D88 plugin", "d88hdr.name = \"{0}\"",
|
DicConsole.DebugWriteLine("D88 plugin", "d88hdr.name = \"{0}\"",
|
||||||
StringHandlers.CToString(d88Hdr.name, shiftjis));
|
StringHandlers.CToString(d88Hdr.name, shiftjis));
|
||||||
@@ -97,9 +94,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
stream.Seek(d88Hdr.track_table[0], SeekOrigin.Begin);
|
stream.Seek(d88Hdr.track_table[0], SeekOrigin.Begin);
|
||||||
stream.Read(hdrB, 0, hdrB.Length);
|
stream.Read(hdrB, 0, hdrB.Length);
|
||||||
|
|
||||||
handle = GCHandle.Alloc(hdrB, GCHandleType.Pinned);
|
sechdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<SectorHeader>(hdrB);
|
||||||
sechdr = (SectorHeader)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(SectorHeader));
|
|
||||||
handle.Free();
|
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("D88 plugin", "sechdr.c = {0}", sechdr.c);
|
DicConsole.DebugWriteLine("D88 plugin", "sechdr.c = {0}", sechdr.c);
|
||||||
DicConsole.DebugWriteLine("D88 plugin", "sechdr.h = {0}", sechdr.h);
|
DicConsole.DebugWriteLine("D88 plugin", "sechdr.h = {0}", sechdr.h);
|
||||||
@@ -122,9 +117,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
stream.Read(hdrB, 0, hdrB.Length);
|
stream.Read(hdrB, 0, hdrB.Length);
|
||||||
SortedDictionary<byte, byte[]> sectors = new SortedDictionary<byte, byte[]>();
|
SortedDictionary<byte, byte[]> sectors = new SortedDictionary<byte, byte[]>();
|
||||||
|
|
||||||
handle = GCHandle.Alloc(hdrB, GCHandleType.Pinned);
|
sechdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<SectorHeader>(hdrB);
|
||||||
sechdr = (SectorHeader)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(SectorHeader));
|
|
||||||
handle.Free();
|
|
||||||
|
|
||||||
if(sechdr.spt != spt || sechdr.n != bps)
|
if(sechdr.spt != spt || sechdr.n != bps)
|
||||||
{
|
{
|
||||||
@@ -143,9 +136,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
sectors.Add(sechdr.r, secB);
|
sectors.Add(sechdr.r, secB);
|
||||||
stream.Read(hdrB, 0, hdrB.Length);
|
stream.Read(hdrB, 0, hdrB.Length);
|
||||||
|
|
||||||
handle = GCHandle.Alloc(hdrB, GCHandleType.Pinned);
|
sechdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<SectorHeader>(hdrB);
|
||||||
sechdr = (SectorHeader)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(SectorHeader));
|
|
||||||
handle.Free();
|
|
||||||
|
|
||||||
if(sechdr.spt == spt && sechdr.n == bps) continue;
|
if(sechdr.spt == spt && sechdr.n == bps) continue;
|
||||||
|
|
||||||
|
|||||||
@@ -48,10 +48,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
header = new DicHeader();
|
header = new DicHeader();
|
||||||
structureBytes = new byte[Marshal.SizeOf(header)];
|
structureBytes = new byte[Marshal.SizeOf(header)];
|
||||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(header));
|
header = Helpers.Marshal.ByteArrayToStructureLittleEndian<DicHeader>(structureBytes);
|
||||||
Marshal.Copy(structureBytes, 0, structurePointer, Marshal.SizeOf(header));
|
|
||||||
header = (DicHeader)Marshal.PtrToStructure(structurePointer, typeof(DicHeader));
|
|
||||||
Marshal.FreeHGlobal(structurePointer);
|
|
||||||
|
|
||||||
return header.identifier == DIC_MAGIC && header.imageMajorVersion <= DICF_VERSION;
|
return header.identifier == DIC_MAGIC && header.imageMajorVersion <= DICF_VERSION;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,10 +65,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
header = new DicHeader();
|
header = new DicHeader();
|
||||||
structureBytes = new byte[Marshal.SizeOf(header)];
|
structureBytes = new byte[Marshal.SizeOf(header)];
|
||||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(header));
|
header = Helpers.Marshal.ByteArrayToStructureLittleEndian<DicHeader>(structureBytes);
|
||||||
Marshal.Copy(structureBytes, 0, structurePointer, Marshal.SizeOf(header));
|
|
||||||
header = (DicHeader)Marshal.PtrToStructure(structurePointer, typeof(DicHeader));
|
|
||||||
Marshal.FreeHGlobal(structurePointer);
|
|
||||||
|
|
||||||
if(header.imageMajorVersion > DICF_VERSION)
|
if(header.imageMajorVersion > DICF_VERSION)
|
||||||
throw new FeatureUnsupportedImageException($"Image version {header.imageMajorVersion} not recognized.");
|
throw new FeatureUnsupportedImageException($"Image version {header.imageMajorVersion} not recognized.");
|
||||||
@@ -83,10 +80,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
IndexHeader idxHeader = new IndexHeader();
|
IndexHeader idxHeader = new IndexHeader();
|
||||||
structureBytes = new byte[Marshal.SizeOf(idxHeader)];
|
structureBytes = new byte[Marshal.SizeOf(idxHeader)];
|
||||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(idxHeader));
|
idxHeader = Helpers.Marshal.ByteArrayToStructureLittleEndian<IndexHeader>(structureBytes);
|
||||||
Marshal.Copy(structureBytes, 0, structurePointer, Marshal.SizeOf(idxHeader));
|
|
||||||
idxHeader = (IndexHeader)Marshal.PtrToStructure(structurePointer, typeof(IndexHeader));
|
|
||||||
Marshal.FreeHGlobal(structurePointer);
|
|
||||||
|
|
||||||
if(idxHeader.identifier != BlockType.Index) throw new FeatureUnsupportedImageException("Index not found!");
|
if(idxHeader.identifier != BlockType.Index) throw new FeatureUnsupportedImageException("Index not found!");
|
||||||
|
|
||||||
@@ -100,10 +94,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
IndexEntry entry = new IndexEntry();
|
IndexEntry entry = new IndexEntry();
|
||||||
structureBytes = new byte[Marshal.SizeOf(entry)];
|
structureBytes = new byte[Marshal.SizeOf(entry)];
|
||||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(entry));
|
entry = Helpers.Marshal.ByteArrayToStructureLittleEndian<IndexEntry>(structureBytes);
|
||||||
Marshal.Copy(structureBytes, 0, structurePointer, Marshal.SizeOf(entry));
|
|
||||||
entry = (IndexEntry)Marshal.PtrToStructure(structurePointer, typeof(IndexEntry));
|
|
||||||
Marshal.FreeHGlobal(structurePointer);
|
|
||||||
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
||||||
"Block type {0} with data type {1} is indexed to be at {2}", entry.blockType,
|
"Block type {0} with data type {1} is indexed to be at {2}", entry.blockType,
|
||||||
entry.dataType, entry.offset);
|
entry.dataType, entry.offset);
|
||||||
@@ -128,10 +119,8 @@ namespace DiscImageChef.DiscImages
|
|||||||
BlockHeader blockHeader = new BlockHeader();
|
BlockHeader blockHeader = new BlockHeader();
|
||||||
structureBytes = new byte[Marshal.SizeOf(blockHeader)];
|
structureBytes = new byte[Marshal.SizeOf(blockHeader)];
|
||||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(blockHeader));
|
blockHeader =
|
||||||
Marshal.Copy(structureBytes, 0, structurePointer, Marshal.SizeOf(blockHeader));
|
Helpers.Marshal.ByteArrayToStructureLittleEndian<BlockHeader>(structureBytes);
|
||||||
blockHeader = (BlockHeader)Marshal.PtrToStructure(structurePointer, typeof(BlockHeader));
|
|
||||||
Marshal.FreeHGlobal(structurePointer);
|
|
||||||
imageInfo.ImageSize += blockHeader.cmpLength;
|
imageInfo.ImageSize += blockHeader.cmpLength;
|
||||||
|
|
||||||
// Unused, skip
|
// Unused, skip
|
||||||
@@ -296,10 +285,8 @@ namespace DiscImageChef.DiscImages
|
|||||||
DdtHeader ddtHeader = new DdtHeader();
|
DdtHeader ddtHeader = new DdtHeader();
|
||||||
structureBytes = new byte[Marshal.SizeOf(ddtHeader)];
|
structureBytes = new byte[Marshal.SizeOf(ddtHeader)];
|
||||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(ddtHeader));
|
ddtHeader =
|
||||||
Marshal.Copy(structureBytes, 0, structurePointer, Marshal.SizeOf(ddtHeader));
|
Helpers.Marshal.ByteArrayToStructureLittleEndian<DdtHeader>(structureBytes);
|
||||||
ddtHeader = (DdtHeader)Marshal.PtrToStructure(structurePointer, typeof(DdtHeader));
|
|
||||||
Marshal.FreeHGlobal(structurePointer);
|
|
||||||
imageInfo.ImageSize += ddtHeader.cmpLength;
|
imageInfo.ImageSize += ddtHeader.cmpLength;
|
||||||
|
|
||||||
if(ddtHeader.identifier != BlockType.DeDuplicationTable) break;
|
if(ddtHeader.identifier != BlockType.DeDuplicationTable) break;
|
||||||
@@ -350,10 +337,8 @@ namespace DiscImageChef.DiscImages
|
|||||||
DdtHeader ddtHeader = new DdtHeader();
|
DdtHeader ddtHeader = new DdtHeader();
|
||||||
structureBytes = new byte[Marshal.SizeOf(ddtHeader)];
|
structureBytes = new byte[Marshal.SizeOf(ddtHeader)];
|
||||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(ddtHeader));
|
ddtHeader =
|
||||||
Marshal.Copy(structureBytes, 0, structurePointer, Marshal.SizeOf(ddtHeader));
|
Helpers.Marshal.ByteArrayToStructureLittleEndian<DdtHeader>(structureBytes);
|
||||||
ddtHeader = (DdtHeader)Marshal.PtrToStructure(structurePointer, typeof(DdtHeader));
|
|
||||||
Marshal.FreeHGlobal(structurePointer);
|
|
||||||
imageInfo.ImageSize += ddtHeader.cmpLength;
|
imageInfo.ImageSize += ddtHeader.cmpLength;
|
||||||
|
|
||||||
if(ddtHeader.identifier != BlockType.DeDuplicationTable) break;
|
if(ddtHeader.identifier != BlockType.DeDuplicationTable) break;
|
||||||
@@ -402,10 +387,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
geometryBlock = new GeometryBlock();
|
geometryBlock = new GeometryBlock();
|
||||||
structureBytes = new byte[Marshal.SizeOf(geometryBlock)];
|
structureBytes = new byte[Marshal.SizeOf(geometryBlock)];
|
||||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(geometryBlock));
|
geometryBlock = Helpers.Marshal.ByteArrayToStructureLittleEndian<GeometryBlock>(structureBytes);
|
||||||
Marshal.Copy(structureBytes, 0, structurePointer, Marshal.SizeOf(geometryBlock));
|
|
||||||
geometryBlock = (GeometryBlock)Marshal.PtrToStructure(structurePointer, typeof(GeometryBlock));
|
|
||||||
Marshal.FreeHGlobal(structurePointer);
|
|
||||||
if(geometryBlock.identifier == BlockType.GeometryBlock)
|
if(geometryBlock.identifier == BlockType.GeometryBlock)
|
||||||
{
|
{
|
||||||
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
||||||
@@ -423,10 +405,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
MetadataBlock metadataBlock = new MetadataBlock();
|
MetadataBlock metadataBlock = new MetadataBlock();
|
||||||
structureBytes = new byte[Marshal.SizeOf(metadataBlock)];
|
structureBytes = new byte[Marshal.SizeOf(metadataBlock)];
|
||||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(metadataBlock));
|
metadataBlock = Helpers.Marshal.ByteArrayToStructureLittleEndian<MetadataBlock>(structureBytes);
|
||||||
Marshal.Copy(structureBytes, 0, structurePointer, Marshal.SizeOf(metadataBlock));
|
|
||||||
metadataBlock = (MetadataBlock)Marshal.PtrToStructure(structurePointer, typeof(MetadataBlock));
|
|
||||||
Marshal.FreeHGlobal(structurePointer);
|
|
||||||
|
|
||||||
if(metadataBlock.identifier != entry.blockType)
|
if(metadataBlock.identifier != entry.blockType)
|
||||||
{
|
{
|
||||||
@@ -594,10 +573,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
TracksHeader tracksHeader = new TracksHeader();
|
TracksHeader tracksHeader = new TracksHeader();
|
||||||
structureBytes = new byte[Marshal.SizeOf(tracksHeader)];
|
structureBytes = new byte[Marshal.SizeOf(tracksHeader)];
|
||||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(tracksHeader));
|
tracksHeader = Helpers.Marshal.ByteArrayToStructureLittleEndian<TracksHeader>(structureBytes);
|
||||||
Marshal.Copy(structureBytes, 0, structurePointer, Marshal.SizeOf(tracksHeader));
|
|
||||||
tracksHeader = (TracksHeader)Marshal.PtrToStructure(structurePointer, typeof(TracksHeader));
|
|
||||||
Marshal.FreeHGlobal(structurePointer);
|
|
||||||
if(tracksHeader.identifier != BlockType.TracksBlock)
|
if(tracksHeader.identifier != BlockType.TracksBlock)
|
||||||
{
|
{
|
||||||
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
||||||
@@ -631,10 +607,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
TrackEntry trackEntry = new TrackEntry();
|
TrackEntry trackEntry = new TrackEntry();
|
||||||
structureBytes = new byte[Marshal.SizeOf(trackEntry)];
|
structureBytes = new byte[Marshal.SizeOf(trackEntry)];
|
||||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(trackEntry));
|
trackEntry = Helpers.Marshal.ByteArrayToStructureLittleEndian<TrackEntry>(structureBytes);
|
||||||
Marshal.Copy(structureBytes, 0, structurePointer, Marshal.SizeOf(trackEntry));
|
|
||||||
trackEntry = (TrackEntry)Marshal.PtrToStructure(structurePointer, typeof(TrackEntry));
|
|
||||||
Marshal.FreeHGlobal(structurePointer);
|
|
||||||
|
|
||||||
Tracks.Add(new Track
|
Tracks.Add(new Track
|
||||||
{
|
{
|
||||||
@@ -661,11 +634,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
CicmMetadataBlock cicmBlock = new CicmMetadataBlock();
|
CicmMetadataBlock cicmBlock = new CicmMetadataBlock();
|
||||||
structureBytes = new byte[Marshal.SizeOf(cicmBlock)];
|
structureBytes = new byte[Marshal.SizeOf(cicmBlock)];
|
||||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(cicmBlock));
|
cicmBlock = Helpers.Marshal.ByteArrayToStructureLittleEndian<CicmMetadataBlock>(structureBytes);
|
||||||
Marshal.Copy(structureBytes, 0, structurePointer, Marshal.SizeOf(cicmBlock));
|
|
||||||
cicmBlock = (CicmMetadataBlock)Marshal.PtrToStructure(structurePointer,
|
|
||||||
typeof(CicmMetadataBlock));
|
|
||||||
Marshal.FreeHGlobal(structurePointer);
|
|
||||||
if(cicmBlock.identifier != BlockType.CicmBlock) break;
|
if(cicmBlock.identifier != BlockType.CicmBlock) break;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
||||||
@@ -694,11 +663,8 @@ namespace DiscImageChef.DiscImages
|
|||||||
DumpHardwareHeader dumpBlock = new DumpHardwareHeader();
|
DumpHardwareHeader dumpBlock = new DumpHardwareHeader();
|
||||||
structureBytes = new byte[Marshal.SizeOf(dumpBlock)];
|
structureBytes = new byte[Marshal.SizeOf(dumpBlock)];
|
||||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(dumpBlock));
|
dumpBlock = Helpers
|
||||||
Marshal.Copy(structureBytes, 0, structurePointer, Marshal.SizeOf(dumpBlock));
|
.Marshal.ByteArrayToStructureLittleEndian<DumpHardwareHeader>(structureBytes);
|
||||||
dumpBlock = (DumpHardwareHeader)Marshal.PtrToStructure(structurePointer,
|
|
||||||
typeof(DumpHardwareHeader));
|
|
||||||
Marshal.FreeHGlobal(structurePointer);
|
|
||||||
if(dumpBlock.identifier != BlockType.DumpHardwareBlock) break;
|
if(dumpBlock.identifier != BlockType.DumpHardwareBlock) break;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
||||||
@@ -724,11 +690,8 @@ namespace DiscImageChef.DiscImages
|
|||||||
DumpHardwareEntry dumpEntry = new DumpHardwareEntry();
|
DumpHardwareEntry dumpEntry = new DumpHardwareEntry();
|
||||||
structureBytes = new byte[Marshal.SizeOf(dumpEntry)];
|
structureBytes = new byte[Marshal.SizeOf(dumpEntry)];
|
||||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(dumpEntry));
|
dumpEntry =
|
||||||
Marshal.Copy(structureBytes, 0, structurePointer, Marshal.SizeOf(dumpEntry));
|
Helpers.Marshal.ByteArrayToStructureLittleEndian<DumpHardwareEntry>(structureBytes);
|
||||||
dumpEntry = (DumpHardwareEntry)Marshal.PtrToStructure(structurePointer,
|
|
||||||
typeof(DumpHardwareEntry));
|
|
||||||
Marshal.FreeHGlobal(structurePointer);
|
|
||||||
|
|
||||||
DumpHardwareType dump = new DumpHardwareType
|
DumpHardwareType dump = new DumpHardwareType
|
||||||
{
|
{
|
||||||
@@ -973,10 +936,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
blockHeader = new BlockHeader();
|
blockHeader = new BlockHeader();
|
||||||
structureBytes = new byte[Marshal.SizeOf(blockHeader)];
|
structureBytes = new byte[Marshal.SizeOf(blockHeader)];
|
||||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(blockHeader));
|
blockHeader = Helpers.Marshal.ByteArrayToStructureLittleEndian<BlockHeader>(structureBytes);
|
||||||
Marshal.Copy(structureBytes, 0, structurePointer, Marshal.SizeOf(blockHeader));
|
|
||||||
blockHeader = (BlockHeader)Marshal.PtrToStructure(structurePointer, typeof(BlockHeader));
|
|
||||||
Marshal.FreeHGlobal(structurePointer);
|
|
||||||
|
|
||||||
// Decompress block
|
// Decompress block
|
||||||
switch(blockHeader.compression)
|
switch(blockHeader.compression)
|
||||||
|
|||||||
@@ -41,6 +41,170 @@ namespace DiscImageChef.DiscImages
|
|||||||
{
|
{
|
||||||
public partial class DiscImageChef
|
public partial class DiscImageChef
|
||||||
{
|
{
|
||||||
|
public bool? VerifyMediaImage()
|
||||||
|
{
|
||||||
|
// This will traverse all blocks and check their CRC64 without uncompressing them
|
||||||
|
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Checking index integrity at {0}",
|
||||||
|
header.indexOffset);
|
||||||
|
imageStream.Position = (long)header.indexOffset;
|
||||||
|
|
||||||
|
IndexHeader idxHeader = new IndexHeader();
|
||||||
|
structureBytes = new byte[Marshal.SizeOf(idxHeader)];
|
||||||
|
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||||
|
idxHeader = Helpers.Marshal.ByteArrayToStructureLittleEndian<IndexHeader>(structureBytes);
|
||||||
|
|
||||||
|
if(idxHeader.identifier != BlockType.Index)
|
||||||
|
{
|
||||||
|
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Incorrect index identifier");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Index at {0} contains {1} entries",
|
||||||
|
header.indexOffset, idxHeader.entries);
|
||||||
|
|
||||||
|
structureBytes = new byte[Marshal.SizeOf(typeof(IndexEntry)) * idxHeader.entries];
|
||||||
|
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||||
|
Crc64Context.Data(structureBytes, out byte[] verifyCrc);
|
||||||
|
|
||||||
|
if(BitConverter.ToUInt64(verifyCrc, 0) != idxHeader.crc64)
|
||||||
|
{
|
||||||
|
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Expected index CRC {0:X16} but got {1:X16}",
|
||||||
|
idxHeader.crc64, BitConverter.ToUInt64(verifyCrc, 0));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
imageStream.Position -= structureBytes.Length;
|
||||||
|
|
||||||
|
List<IndexEntry> vrIndex = new List<IndexEntry>();
|
||||||
|
for(ushort i = 0; i < idxHeader.entries; i++)
|
||||||
|
{
|
||||||
|
IndexEntry entry = new IndexEntry();
|
||||||
|
structureBytes = new byte[Marshal.SizeOf(entry)];
|
||||||
|
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||||
|
entry = Helpers.Marshal.ByteArrayToStructureLittleEndian<IndexEntry>(structureBytes);
|
||||||
|
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
||||||
|
"Block type {0} with data type {1} is indexed to be at {2}", entry.blockType,
|
||||||
|
entry.dataType, entry.offset);
|
||||||
|
vrIndex.Add(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read up to 1MiB at a time for verification
|
||||||
|
const int VERIFY_SIZE = 1024 * 1024;
|
||||||
|
|
||||||
|
foreach(IndexEntry entry in vrIndex)
|
||||||
|
{
|
||||||
|
imageStream.Position = (long)entry.offset;
|
||||||
|
Crc64Context crcVerify;
|
||||||
|
ulong readBytes;
|
||||||
|
byte[] verifyBytes;
|
||||||
|
|
||||||
|
switch(entry.blockType)
|
||||||
|
{
|
||||||
|
case BlockType.DataBlock:
|
||||||
|
BlockHeader blockHeader = new BlockHeader();
|
||||||
|
structureBytes = new byte[Marshal.SizeOf(blockHeader)];
|
||||||
|
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||||
|
blockHeader = Helpers.Marshal.ByteArrayToStructureLittleEndian<BlockHeader>(structureBytes);
|
||||||
|
|
||||||
|
crcVerify = new Crc64Context();
|
||||||
|
readBytes = 0;
|
||||||
|
|
||||||
|
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
||||||
|
"Verifying data block type {0} at position {1}", entry.dataType,
|
||||||
|
entry.offset);
|
||||||
|
|
||||||
|
while(readBytes + VERIFY_SIZE < blockHeader.cmpLength)
|
||||||
|
{
|
||||||
|
verifyBytes = new byte[VERIFY_SIZE];
|
||||||
|
imageStream.Read(verifyBytes, 0, verifyBytes.Length);
|
||||||
|
crcVerify.Update(verifyBytes);
|
||||||
|
readBytes += (ulong)verifyBytes.LongLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
verifyBytes = new byte[blockHeader.cmpLength - readBytes];
|
||||||
|
imageStream.Read(verifyBytes, 0, verifyBytes.Length);
|
||||||
|
crcVerify.Update(verifyBytes);
|
||||||
|
|
||||||
|
verifyCrc = crcVerify.Final();
|
||||||
|
|
||||||
|
if(BitConverter.ToUInt64(verifyCrc, 0) != blockHeader.cmpCrc64)
|
||||||
|
{
|
||||||
|
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
||||||
|
"Expected block CRC {0:X16} but got {1:X16}",
|
||||||
|
blockHeader.cmpCrc64, BitConverter.ToUInt64(verifyCrc, 0));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case BlockType.DeDuplicationTable:
|
||||||
|
DdtHeader ddtHeader = new DdtHeader();
|
||||||
|
structureBytes = new byte[Marshal.SizeOf(ddtHeader)];
|
||||||
|
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||||
|
ddtHeader = Helpers.Marshal.ByteArrayToStructureLittleEndian<DdtHeader>(structureBytes);
|
||||||
|
|
||||||
|
crcVerify = new Crc64Context();
|
||||||
|
readBytes = 0;
|
||||||
|
|
||||||
|
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
||||||
|
"Verifying deduplication table type {0} at position {1}",
|
||||||
|
entry.dataType, entry.offset);
|
||||||
|
|
||||||
|
while(readBytes + VERIFY_SIZE < ddtHeader.cmpLength)
|
||||||
|
{
|
||||||
|
verifyBytes = new byte[readBytes];
|
||||||
|
imageStream.Read(verifyBytes, 0, verifyBytes.Length);
|
||||||
|
crcVerify.Update(verifyBytes);
|
||||||
|
readBytes += (ulong)verifyBytes.LongLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
verifyBytes = new byte[ddtHeader.cmpLength - readBytes];
|
||||||
|
imageStream.Read(verifyBytes, 0, verifyBytes.Length);
|
||||||
|
crcVerify.Update(verifyBytes);
|
||||||
|
|
||||||
|
verifyCrc = crcVerify.Final();
|
||||||
|
|
||||||
|
if(BitConverter.ToUInt64(verifyCrc, 0) != ddtHeader.cmpCrc64)
|
||||||
|
{
|
||||||
|
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
||||||
|
"Expected DDT CRC {0:X16} but got {1:X16}", ddtHeader.cmpCrc64,
|
||||||
|
BitConverter.ToUInt64(verifyCrc, 0));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case BlockType.TracksBlock:
|
||||||
|
TracksHeader trkHeader = new TracksHeader();
|
||||||
|
structureBytes = new byte[Marshal.SizeOf(trkHeader)];
|
||||||
|
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||||
|
trkHeader = Helpers.Marshal.ByteArrayToStructureLittleEndian<TracksHeader>(structureBytes);
|
||||||
|
|
||||||
|
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
||||||
|
"Track block at {0} contains {1} entries", header.indexOffset,
|
||||||
|
trkHeader.entries);
|
||||||
|
|
||||||
|
structureBytes = new byte[Marshal.SizeOf(typeof(TrackEntry)) * trkHeader.entries];
|
||||||
|
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||||
|
Crc64Context.Data(structureBytes, out verifyCrc);
|
||||||
|
|
||||||
|
if(BitConverter.ToUInt64(verifyCrc, 0) != trkHeader.crc64)
|
||||||
|
{
|
||||||
|
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
||||||
|
"Expected index CRC {0:X16} but got {1:X16}", trkHeader.crc64,
|
||||||
|
BitConverter.ToUInt64(verifyCrc, 0));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Ignored field type {0}",
|
||||||
|
entry.blockType);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public bool? VerifySector(ulong sectorAddress)
|
public bool? VerifySector(ulong sectorAddress)
|
||||||
{
|
{
|
||||||
if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) return null;
|
if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) return null;
|
||||||
@@ -49,14 +213,6 @@ namespace DiscImageChef.DiscImages
|
|||||||
return CdChecksums.CheckCdSector(buffer);
|
return CdChecksums.CheckCdSector(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool? VerifySector(ulong sectorAddress, uint track)
|
|
||||||
{
|
|
||||||
if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) return null;
|
|
||||||
|
|
||||||
byte[] buffer = ReadSectorLong(sectorAddress, track);
|
|
||||||
return CdChecksums.CheckCdSector(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool? VerifySectors(ulong sectorAddress, uint length, out List<ulong> failingLbas,
|
public bool? VerifySectors(ulong sectorAddress, uint length, out List<ulong> failingLbas,
|
||||||
out List<ulong> unknownLbas)
|
out List<ulong> unknownLbas)
|
||||||
{
|
{
|
||||||
@@ -139,183 +295,12 @@ namespace DiscImageChef.DiscImages
|
|||||||
return failingLbas.Count <= 0;
|
return failingLbas.Count <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool? VerifyMediaImage()
|
public bool? VerifySector(ulong sectorAddress, uint track)
|
||||||
{
|
{
|
||||||
// This will traverse all blocks and check their CRC64 without uncompressing them
|
if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) return null;
|
||||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Checking index integrity at {0}",
|
|
||||||
header.indexOffset);
|
|
||||||
imageStream.Position = (long)header.indexOffset;
|
|
||||||
|
|
||||||
IndexHeader idxHeader = new IndexHeader();
|
byte[] buffer = ReadSectorLong(sectorAddress, track);
|
||||||
structureBytes = new byte[Marshal.SizeOf(idxHeader)];
|
return CdChecksums.CheckCdSector(buffer);
|
||||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
|
||||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(idxHeader));
|
|
||||||
Marshal.Copy(structureBytes, 0, structurePointer, Marshal.SizeOf(idxHeader));
|
|
||||||
idxHeader = (IndexHeader)Marshal.PtrToStructure(structurePointer, typeof(IndexHeader));
|
|
||||||
Marshal.FreeHGlobal(structurePointer);
|
|
||||||
|
|
||||||
if(idxHeader.identifier != BlockType.Index)
|
|
||||||
{
|
|
||||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Incorrect index identifier");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Index at {0} contains {1} entries",
|
|
||||||
header.indexOffset, idxHeader.entries);
|
|
||||||
|
|
||||||
structureBytes = new byte[Marshal.SizeOf(typeof(IndexEntry)) * idxHeader.entries];
|
|
||||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
|
||||||
Crc64Context.Data(structureBytes, out byte[] verifyCrc);
|
|
||||||
|
|
||||||
if(BitConverter.ToUInt64(verifyCrc, 0) != idxHeader.crc64)
|
|
||||||
{
|
|
||||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Expected index CRC {0:X16} but got {1:X16}",
|
|
||||||
idxHeader.crc64, BitConverter.ToUInt64(verifyCrc, 0));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
imageStream.Position -= structureBytes.Length;
|
|
||||||
|
|
||||||
List<IndexEntry> vrIndex = new List<IndexEntry>();
|
|
||||||
for(ushort i = 0; i < idxHeader.entries; i++)
|
|
||||||
{
|
|
||||||
IndexEntry entry = new IndexEntry();
|
|
||||||
structureBytes = new byte[Marshal.SizeOf(entry)];
|
|
||||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
|
||||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(entry));
|
|
||||||
Marshal.Copy(structureBytes, 0, structurePointer, Marshal.SizeOf(entry));
|
|
||||||
entry = (IndexEntry)Marshal.PtrToStructure(structurePointer, typeof(IndexEntry));
|
|
||||||
Marshal.FreeHGlobal(structurePointer);
|
|
||||||
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
|
||||||
"Block type {0} with data type {1} is indexed to be at {2}", entry.blockType,
|
|
||||||
entry.dataType, entry.offset);
|
|
||||||
vrIndex.Add(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read up to 1MiB at a time for verification
|
|
||||||
const int VERIFY_SIZE = 1024 * 1024;
|
|
||||||
|
|
||||||
foreach(IndexEntry entry in vrIndex)
|
|
||||||
{
|
|
||||||
imageStream.Position = (long)entry.offset;
|
|
||||||
Crc64Context crcVerify;
|
|
||||||
ulong readBytes;
|
|
||||||
byte[] verifyBytes;
|
|
||||||
|
|
||||||
switch(entry.blockType)
|
|
||||||
{
|
|
||||||
case BlockType.DataBlock:
|
|
||||||
BlockHeader blockHeader = new BlockHeader();
|
|
||||||
structureBytes = new byte[Marshal.SizeOf(blockHeader)];
|
|
||||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
|
||||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(blockHeader));
|
|
||||||
Marshal.Copy(structureBytes, 0, structurePointer, Marshal.SizeOf(blockHeader));
|
|
||||||
blockHeader = (BlockHeader)Marshal.PtrToStructure(structurePointer, typeof(BlockHeader));
|
|
||||||
Marshal.FreeHGlobal(structurePointer);
|
|
||||||
|
|
||||||
crcVerify = new Crc64Context();
|
|
||||||
readBytes = 0;
|
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
|
||||||
"Verifying data block type {0} at position {1}", entry.dataType,
|
|
||||||
entry.offset);
|
|
||||||
|
|
||||||
while(readBytes + VERIFY_SIZE < blockHeader.cmpLength)
|
|
||||||
{
|
|
||||||
verifyBytes = new byte[VERIFY_SIZE];
|
|
||||||
imageStream.Read(verifyBytes, 0, verifyBytes.Length);
|
|
||||||
crcVerify.Update(verifyBytes);
|
|
||||||
readBytes += (ulong)verifyBytes.LongLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
verifyBytes = new byte[blockHeader.cmpLength - readBytes];
|
|
||||||
imageStream.Read(verifyBytes, 0, verifyBytes.Length);
|
|
||||||
crcVerify.Update(verifyBytes);
|
|
||||||
|
|
||||||
verifyCrc = crcVerify.Final();
|
|
||||||
|
|
||||||
if(BitConverter.ToUInt64(verifyCrc, 0) != blockHeader.cmpCrc64)
|
|
||||||
{
|
|
||||||
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
|
||||||
"Expected block CRC {0:X16} but got {1:X16}",
|
|
||||||
blockHeader.cmpCrc64, BitConverter.ToUInt64(verifyCrc, 0));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case BlockType.DeDuplicationTable:
|
|
||||||
DdtHeader ddtHeader = new DdtHeader();
|
|
||||||
structureBytes = new byte[Marshal.SizeOf(ddtHeader)];
|
|
||||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
|
||||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(ddtHeader));
|
|
||||||
Marshal.Copy(structureBytes, 0, structurePointer, Marshal.SizeOf(ddtHeader));
|
|
||||||
ddtHeader = (DdtHeader)Marshal.PtrToStructure(structurePointer, typeof(DdtHeader));
|
|
||||||
Marshal.FreeHGlobal(structurePointer);
|
|
||||||
|
|
||||||
crcVerify = new Crc64Context();
|
|
||||||
readBytes = 0;
|
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
|
||||||
"Verifying deduplication table type {0} at position {1}",
|
|
||||||
entry.dataType, entry.offset);
|
|
||||||
|
|
||||||
while(readBytes + VERIFY_SIZE < ddtHeader.cmpLength)
|
|
||||||
{
|
|
||||||
verifyBytes = new byte[readBytes];
|
|
||||||
imageStream.Read(verifyBytes, 0, verifyBytes.Length);
|
|
||||||
crcVerify.Update(verifyBytes);
|
|
||||||
readBytes += (ulong)verifyBytes.LongLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
verifyBytes = new byte[ddtHeader.cmpLength - readBytes];
|
|
||||||
imageStream.Read(verifyBytes, 0, verifyBytes.Length);
|
|
||||||
crcVerify.Update(verifyBytes);
|
|
||||||
|
|
||||||
verifyCrc = crcVerify.Final();
|
|
||||||
|
|
||||||
if(BitConverter.ToUInt64(verifyCrc, 0) != ddtHeader.cmpCrc64)
|
|
||||||
{
|
|
||||||
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
|
||||||
"Expected DDT CRC {0:X16} but got {1:X16}", ddtHeader.cmpCrc64,
|
|
||||||
BitConverter.ToUInt64(verifyCrc, 0));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case BlockType.TracksBlock:
|
|
||||||
TracksHeader trkHeader = new TracksHeader();
|
|
||||||
structureBytes = new byte[Marshal.SizeOf(trkHeader)];
|
|
||||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
|
||||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(trkHeader));
|
|
||||||
Marshal.Copy(structureBytes, 0, structurePointer, Marshal.SizeOf(trkHeader));
|
|
||||||
trkHeader = (TracksHeader)Marshal.PtrToStructure(structurePointer, typeof(TracksHeader));
|
|
||||||
Marshal.FreeHGlobal(structurePointer);
|
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
|
||||||
"Track block at {0} contains {1} entries", header.indexOffset,
|
|
||||||
trkHeader.entries);
|
|
||||||
|
|
||||||
structureBytes = new byte[Marshal.SizeOf(typeof(TrackEntry)) * trkHeader.entries];
|
|
||||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
|
||||||
Crc64Context.Data(structureBytes, out verifyCrc);
|
|
||||||
|
|
||||||
if(BitConverter.ToUInt64(verifyCrc, 0) != trkHeader.crc64)
|
|
||||||
{
|
|
||||||
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
|
||||||
"Expected index CRC {0:X16} but got {1:X16}", trkHeader.crc64,
|
|
||||||
BitConverter.ToUInt64(verifyCrc, 0));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Ignored field type {0}",
|
|
||||||
entry.blockType);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -212,10 +212,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
header = new DicHeader();
|
header = new DicHeader();
|
||||||
structureBytes = new byte[Marshal.SizeOf(header)];
|
structureBytes = new byte[Marshal.SizeOf(header)];
|
||||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(header));
|
header = Helpers.Marshal.ByteArrayToStructureLittleEndian<DicHeader>(structureBytes);
|
||||||
Marshal.Copy(structureBytes, 0, structurePointer, Marshal.SizeOf(header));
|
|
||||||
header = (DicHeader)Marshal.PtrToStructure(structurePointer, typeof(DicHeader));
|
|
||||||
Marshal.FreeHGlobal(structurePointer);
|
|
||||||
|
|
||||||
if(header.identifier != DIC_MAGIC)
|
if(header.identifier != DIC_MAGIC)
|
||||||
{
|
{
|
||||||
@@ -267,10 +264,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
IndexHeader idxHeader = new IndexHeader();
|
IndexHeader idxHeader = new IndexHeader();
|
||||||
structureBytes = new byte[Marshal.SizeOf(idxHeader)];
|
structureBytes = new byte[Marshal.SizeOf(idxHeader)];
|
||||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(idxHeader));
|
idxHeader = Helpers.Marshal.ByteArrayToStructureLittleEndian<IndexHeader>(structureBytes);
|
||||||
Marshal.Copy(structureBytes, 0, structurePointer, Marshal.SizeOf(idxHeader));
|
|
||||||
idxHeader = (IndexHeader)Marshal.PtrToStructure(structurePointer, typeof(IndexHeader));
|
|
||||||
Marshal.FreeHGlobal(structurePointer);
|
|
||||||
|
|
||||||
if(idxHeader.identifier != BlockType.Index)
|
if(idxHeader.identifier != BlockType.Index)
|
||||||
{
|
{
|
||||||
@@ -286,10 +280,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
IndexEntry entry = new IndexEntry();
|
IndexEntry entry = new IndexEntry();
|
||||||
structureBytes = new byte[Marshal.SizeOf(entry)];
|
structureBytes = new byte[Marshal.SizeOf(entry)];
|
||||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(entry));
|
entry = Helpers.Marshal.ByteArrayToStructureLittleEndian<IndexEntry>(structureBytes);
|
||||||
Marshal.Copy(structureBytes, 0, structurePointer, Marshal.SizeOf(entry));
|
|
||||||
entry = (IndexEntry)Marshal.PtrToStructure(structurePointer, typeof(IndexEntry));
|
|
||||||
Marshal.FreeHGlobal(structurePointer);
|
|
||||||
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
||||||
"Block type {0} with data type {1} is indexed to be at {2}",
|
"Block type {0} with data type {1} is indexed to be at {2}",
|
||||||
entry.blockType, entry.dataType, entry.offset);
|
entry.blockType, entry.dataType, entry.offset);
|
||||||
@@ -322,10 +313,8 @@ namespace DiscImageChef.DiscImages
|
|||||||
BlockHeader blockHeader = new BlockHeader();
|
BlockHeader blockHeader = new BlockHeader();
|
||||||
structureBytes = new byte[Marshal.SizeOf(blockHeader)];
|
structureBytes = new byte[Marshal.SizeOf(blockHeader)];
|
||||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(blockHeader));
|
blockHeader =
|
||||||
Marshal.Copy(structureBytes, 0, structurePointer, Marshal.SizeOf(blockHeader));
|
Helpers.Marshal.ByteArrayToStructureLittleEndian<BlockHeader>(structureBytes);
|
||||||
blockHeader = (BlockHeader)Marshal.PtrToStructure(structurePointer, typeof(BlockHeader));
|
|
||||||
Marshal.FreeHGlobal(structurePointer);
|
|
||||||
imageInfo.ImageSize += blockHeader.cmpLength;
|
imageInfo.ImageSize += blockHeader.cmpLength;
|
||||||
|
|
||||||
if(blockHeader.identifier != entry.blockType)
|
if(blockHeader.identifier != entry.blockType)
|
||||||
@@ -418,10 +407,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
DdtHeader ddtHeader = new DdtHeader();
|
DdtHeader ddtHeader = new DdtHeader();
|
||||||
structureBytes = new byte[Marshal.SizeOf(ddtHeader)];
|
structureBytes = new byte[Marshal.SizeOf(ddtHeader)];
|
||||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(ddtHeader));
|
ddtHeader = Helpers.Marshal.ByteArrayToStructureLittleEndian<DdtHeader>(structureBytes);
|
||||||
Marshal.Copy(structureBytes, 0, structurePointer, Marshal.SizeOf(ddtHeader));
|
|
||||||
ddtHeader = (DdtHeader)Marshal.PtrToStructure(structurePointer, typeof(DdtHeader));
|
|
||||||
Marshal.FreeHGlobal(structurePointer);
|
|
||||||
|
|
||||||
if(ddtHeader.identifier != BlockType.DeDuplicationTable) break;
|
if(ddtHeader.identifier != BlockType.DeDuplicationTable) break;
|
||||||
|
|
||||||
@@ -478,10 +464,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
DdtHeader ddtHeader = new DdtHeader();
|
DdtHeader ddtHeader = new DdtHeader();
|
||||||
structureBytes = new byte[Marshal.SizeOf(ddtHeader)];
|
structureBytes = new byte[Marshal.SizeOf(ddtHeader)];
|
||||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(ddtHeader));
|
ddtHeader = Helpers.Marshal.ByteArrayToStructureLittleEndian<DdtHeader>(structureBytes);
|
||||||
Marshal.Copy(structureBytes, 0, structurePointer, Marshal.SizeOf(ddtHeader));
|
|
||||||
ddtHeader = (DdtHeader)Marshal.PtrToStructure(structurePointer, typeof(DdtHeader));
|
|
||||||
Marshal.FreeHGlobal(structurePointer);
|
|
||||||
|
|
||||||
if(ddtHeader.identifier != BlockType.DeDuplicationTable) break;
|
if(ddtHeader.identifier != BlockType.DeDuplicationTable) break;
|
||||||
|
|
||||||
@@ -544,11 +527,8 @@ namespace DiscImageChef.DiscImages
|
|||||||
CicmMetadataBlock cicmBlock = new CicmMetadataBlock();
|
CicmMetadataBlock cicmBlock = new CicmMetadataBlock();
|
||||||
structureBytes = new byte[Marshal.SizeOf(cicmBlock)];
|
structureBytes = new byte[Marshal.SizeOf(cicmBlock)];
|
||||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(cicmBlock));
|
cicmBlock =
|
||||||
Marshal.Copy(structureBytes, 0, structurePointer, Marshal.SizeOf(cicmBlock));
|
Helpers.Marshal.ByteArrayToStructureLittleEndian<CicmMetadataBlock>(structureBytes);
|
||||||
cicmBlock = (CicmMetadataBlock)Marshal.PtrToStructure(structurePointer,
|
|
||||||
typeof(CicmMetadataBlock));
|
|
||||||
Marshal.FreeHGlobal(structurePointer);
|
|
||||||
if(cicmBlock.identifier != BlockType.CicmBlock) break;
|
if(cicmBlock.identifier != BlockType.CicmBlock) break;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
||||||
@@ -578,11 +558,8 @@ namespace DiscImageChef.DiscImages
|
|||||||
DumpHardwareHeader dumpBlock = new DumpHardwareHeader();
|
DumpHardwareHeader dumpBlock = new DumpHardwareHeader();
|
||||||
structureBytes = new byte[Marshal.SizeOf(dumpBlock)];
|
structureBytes = new byte[Marshal.SizeOf(dumpBlock)];
|
||||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(dumpBlock));
|
dumpBlock =
|
||||||
Marshal.Copy(structureBytes, 0, structurePointer, Marshal.SizeOf(dumpBlock));
|
Helpers.Marshal.ByteArrayToStructureLittleEndian<DumpHardwareHeader>(structureBytes);
|
||||||
dumpBlock = (DumpHardwareHeader)Marshal.PtrToStructure(structurePointer,
|
|
||||||
typeof(DumpHardwareHeader));
|
|
||||||
Marshal.FreeHGlobal(structurePointer);
|
|
||||||
if(dumpBlock.identifier != BlockType.DumpHardwareBlock) break;
|
if(dumpBlock.identifier != BlockType.DumpHardwareBlock) break;
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
||||||
@@ -608,11 +585,8 @@ namespace DiscImageChef.DiscImages
|
|||||||
DumpHardwareEntry dumpEntry = new DumpHardwareEntry();
|
DumpHardwareEntry dumpEntry = new DumpHardwareEntry();
|
||||||
structureBytes = new byte[Marshal.SizeOf(dumpEntry)];
|
structureBytes = new byte[Marshal.SizeOf(dumpEntry)];
|
||||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(dumpEntry));
|
dumpEntry =
|
||||||
Marshal.Copy(structureBytes, 0, structurePointer, Marshal.SizeOf(dumpEntry));
|
Helpers.Marshal.ByteArrayToStructureLittleEndian<DumpHardwareEntry>(structureBytes);
|
||||||
dumpEntry = (DumpHardwareEntry)Marshal.PtrToStructure(structurePointer,
|
|
||||||
typeof(DumpHardwareEntry));
|
|
||||||
Marshal.FreeHGlobal(structurePointer);
|
|
||||||
|
|
||||||
DumpHardwareType dump = new DumpHardwareType
|
DumpHardwareType dump = new DumpHardwareType
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
// Copyright © 2011-2019 Natalia Portillo
|
// Copyright © 2011-2019 Natalia Portillo
|
||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
@@ -51,10 +50,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
stream.Seek(-buffer.Length, SeekOrigin.End);
|
stream.Seek(-buffer.Length, SeekOrigin.End);
|
||||||
stream.Read(buffer, 0, buffer.Length);
|
stream.Read(buffer, 0, buffer.Length);
|
||||||
|
|
||||||
IntPtr ftrPtr = Marshal.AllocHGlobal(buffer.Length);
|
DriFooter tmpFooter = Helpers.Marshal.ByteArrayToStructureLittleEndian<DriFooter>(buffer);
|
||||||
Marshal.Copy(buffer, 0, ftrPtr, buffer.Length);
|
|
||||||
DriFooter tmpFooter = (DriFooter)Marshal.PtrToStructure(ftrPtr, typeof(DriFooter));
|
|
||||||
Marshal.FreeHGlobal(ftrPtr);
|
|
||||||
|
|
||||||
string sig = StringHandlers.CToString(tmpFooter.signature);
|
string sig = StringHandlers.CToString(tmpFooter.signature);
|
||||||
|
|
||||||
|
|||||||
@@ -53,11 +53,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
stream.Seek(-buffer.Length, SeekOrigin.End);
|
stream.Seek(-buffer.Length, SeekOrigin.End);
|
||||||
stream.Read(buffer, 0, buffer.Length);
|
stream.Read(buffer, 0, buffer.Length);
|
||||||
|
|
||||||
footer = new DriFooter();
|
footer = Helpers.Marshal.ByteArrayToStructureLittleEndian<DriFooter>(buffer);
|
||||||
IntPtr ftrPtr = Marshal.AllocHGlobal(buffer.Length);
|
|
||||||
Marshal.Copy(buffer, 0, ftrPtr, buffer.Length);
|
|
||||||
footer = (DriFooter)Marshal.PtrToStructure(ftrPtr, typeof(DriFooter));
|
|
||||||
Marshal.FreeHGlobal(ftrPtr);
|
|
||||||
|
|
||||||
string sig = StringHandlers.CToString(footer.signature);
|
string sig = StringHandlers.CToString(footer.signature);
|
||||||
|
|
||||||
|
|||||||
@@ -31,10 +31,9 @@
|
|||||||
// Copyright © 2011-2019 Natalia Portillo
|
// Copyright © 2011-2019 Natalia Portillo
|
||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using DiscImageChef.CommonTypes.Interfaces;
|
using DiscImageChef.CommonTypes.Interfaces;
|
||||||
|
using DiscImageChef.Helpers;
|
||||||
|
|
||||||
namespace DiscImageChef.DiscImages
|
namespace DiscImageChef.DiscImages
|
||||||
{
|
{
|
||||||
@@ -50,10 +49,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
byte[] header = new byte[2 + 2 * 82];
|
byte[] header = new byte[2 + 2 * 82];
|
||||||
stream.Read(header, 0, 2 + 2 * 82);
|
stream.Read(header, 0, 2 + 2 * 82);
|
||||||
|
|
||||||
IntPtr hdrPtr = Marshal.AllocHGlobal(2 + 2 * 82);
|
HdcpFileHeader fheader = Marshal.ByteArrayToStructureLittleEndian<HdcpFileHeader>(header);
|
||||||
Marshal.Copy(header, 0, hdrPtr, 2 + 2 * 82);
|
|
||||||
HdcpFileHeader fheader = (HdcpFileHeader)Marshal.PtrToStructure(hdrPtr, typeof(HdcpFileHeader));
|
|
||||||
Marshal.FreeHGlobal(hdrPtr);
|
|
||||||
|
|
||||||
/* Some sanity checks on the values we just read.
|
/* Some sanity checks on the values we just read.
|
||||||
* We know the image is from a DOS floppy disk, so assume
|
* We know the image is from a DOS floppy disk, so assume
|
||||||
|
|||||||
@@ -33,11 +33,11 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using DiscImageChef.CommonTypes;
|
using DiscImageChef.CommonTypes;
|
||||||
using DiscImageChef.CommonTypes.Enums;
|
using DiscImageChef.CommonTypes.Enums;
|
||||||
using DiscImageChef.CommonTypes.Interfaces;
|
using DiscImageChef.CommonTypes.Interfaces;
|
||||||
using DiscImageChef.Console;
|
using DiscImageChef.Console;
|
||||||
|
using DiscImageChef.Helpers;
|
||||||
|
|
||||||
namespace DiscImageChef.DiscImages
|
namespace DiscImageChef.DiscImages
|
||||||
{
|
{
|
||||||
@@ -51,10 +51,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
byte[] header = new byte[2 + 2 * 82];
|
byte[] header = new byte[2 + 2 * 82];
|
||||||
stream.Read(header, 0, 2 + 2 * 82);
|
stream.Read(header, 0, 2 + 2 * 82);
|
||||||
|
|
||||||
IntPtr hdrPtr = Marshal.AllocHGlobal(2 + 2 * 82);
|
HdcpFileHeader fheader = Marshal.ByteArrayToStructureLittleEndian<HdcpFileHeader>(header);
|
||||||
Marshal.Copy(header, 0, hdrPtr, 2 + 2 * 82);
|
|
||||||
HdcpFileHeader fheader = (HdcpFileHeader)Marshal.PtrToStructure(hdrPtr, typeof(HdcpFileHeader));
|
|
||||||
Marshal.FreeHGlobal(hdrPtr);
|
|
||||||
DicConsole.DebugWriteLine("HDCP plugin",
|
DicConsole.DebugWriteLine("HDCP plugin",
|
||||||
"Detected HD-Copy image with {0} tracks and {1} sectors per track.",
|
"Detected HD-Copy image with {0} tracks and {1} sectors per track.",
|
||||||
fheader.lastCylinder + 1, fheader.sectorsPerTrack);
|
fheader.lastCylinder + 1, fheader.sectorsPerTrack);
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
// Copyright © 2011-2019 Natalia Portillo
|
// Copyright © 2011-2019 Natalia Portillo
|
||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using DiscImageChef.CommonTypes.Interfaces;
|
using DiscImageChef.CommonTypes.Interfaces;
|
||||||
@@ -49,10 +48,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
byte[] hdr = new byte[Marshal.SizeOf(header)];
|
byte[] hdr = new byte[Marshal.SizeOf(header)];
|
||||||
stream.Read(hdr, 0, Marshal.SizeOf(header));
|
stream.Read(hdr, 0, Marshal.SizeOf(header));
|
||||||
|
|
||||||
IntPtr hdrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(header));
|
header = Helpers.Marshal.ByteArrayToStructureLittleEndian<OobBlock>(hdr);
|
||||||
Marshal.Copy(hdr, 0, hdrPtr, Marshal.SizeOf(header));
|
|
||||||
header = (OobBlock)Marshal.PtrToStructure(hdrPtr, typeof(OobBlock));
|
|
||||||
Marshal.FreeHGlobal(hdrPtr);
|
|
||||||
|
|
||||||
OobBlock footer = new OobBlock();
|
OobBlock footer = new OobBlock();
|
||||||
stream.Seek(-Marshal.SizeOf(footer), SeekOrigin.End);
|
stream.Seek(-Marshal.SizeOf(footer), SeekOrigin.End);
|
||||||
@@ -60,10 +56,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
hdr = new byte[Marshal.SizeOf(footer)];
|
hdr = new byte[Marshal.SizeOf(footer)];
|
||||||
stream.Read(hdr, 0, Marshal.SizeOf(footer));
|
stream.Read(hdr, 0, Marshal.SizeOf(footer));
|
||||||
|
|
||||||
hdrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(footer));
|
footer = Helpers.Marshal.ByteArrayToStructureLittleEndian<OobBlock>(hdr);
|
||||||
Marshal.Copy(hdr, 0, hdrPtr, Marshal.SizeOf(footer));
|
|
||||||
footer = (OobBlock)Marshal.PtrToStructure(hdrPtr, typeof(OobBlock));
|
|
||||||
Marshal.FreeHGlobal(hdrPtr);
|
|
||||||
|
|
||||||
return header.blockId == BlockIds.Oob && header.blockType == OobTypes.KFInfo &&
|
return header.blockId == BlockIds.Oob && header.blockType == OobTypes.KFInfo &&
|
||||||
footer.blockId == BlockIds.Oob && footer.blockType == OobTypes.EOF && footer.length == 0x0D0D;
|
footer.blockId == BlockIds.Oob && footer.blockType == OobTypes.EOF && footer.length == 0x0D0D;
|
||||||
|
|||||||
@@ -55,10 +55,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
byte[] hdr = new byte[Marshal.SizeOf(header)];
|
byte[] hdr = new byte[Marshal.SizeOf(header)];
|
||||||
stream.Read(hdr, 0, Marshal.SizeOf(header));
|
stream.Read(hdr, 0, Marshal.SizeOf(header));
|
||||||
|
|
||||||
IntPtr hdrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(header));
|
header = Helpers.Marshal.ByteArrayToStructureLittleEndian<OobBlock>(hdr);
|
||||||
Marshal.Copy(hdr, 0, hdrPtr, Marshal.SizeOf(header));
|
|
||||||
header = (OobBlock)Marshal.PtrToStructure(hdrPtr, typeof(OobBlock));
|
|
||||||
Marshal.FreeHGlobal(hdrPtr);
|
|
||||||
|
|
||||||
OobBlock footer = new OobBlock();
|
OobBlock footer = new OobBlock();
|
||||||
stream.Seek(-Marshal.SizeOf(footer), SeekOrigin.End);
|
stream.Seek(-Marshal.SizeOf(footer), SeekOrigin.End);
|
||||||
@@ -66,10 +63,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
hdr = new byte[Marshal.SizeOf(footer)];
|
hdr = new byte[Marshal.SizeOf(footer)];
|
||||||
stream.Read(hdr, 0, Marshal.SizeOf(footer));
|
stream.Read(hdr, 0, Marshal.SizeOf(footer));
|
||||||
|
|
||||||
hdrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(footer));
|
footer = Helpers.Marshal.ByteArrayToStructureLittleEndian<OobBlock>(hdr);
|
||||||
Marshal.Copy(hdr, 0, hdrPtr, Marshal.SizeOf(footer));
|
|
||||||
footer = (OobBlock)Marshal.PtrToStructure(hdrPtr, typeof(OobBlock));
|
|
||||||
Marshal.FreeHGlobal(hdrPtr);
|
|
||||||
|
|
||||||
if(header.blockId != BlockIds.Oob || header.blockType != OobTypes.KFInfo ||
|
if(header.blockId != BlockIds.Oob || header.blockType != OobTypes.KFInfo ||
|
||||||
footer.blockId != BlockIds.Oob || footer.blockType != OobTypes.EOF ||
|
footer.blockId != BlockIds.Oob || footer.blockType != OobTypes.EOF ||
|
||||||
@@ -142,10 +136,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
byte[] oob = new byte[Marshal.SizeOf(oobBlk)];
|
byte[] oob = new byte[Marshal.SizeOf(oobBlk)];
|
||||||
trackStream.Read(oob, 0, Marshal.SizeOf(oobBlk));
|
trackStream.Read(oob, 0, Marshal.SizeOf(oobBlk));
|
||||||
|
|
||||||
IntPtr oobPtr = Marshal.AllocHGlobal(Marshal.SizeOf(oobBlk));
|
oobBlk = Helpers.Marshal.ByteArrayToStructureLittleEndian<OobBlock>(oob);
|
||||||
Marshal.Copy(oob, 0, oobPtr, Marshal.SizeOf(oobBlk));
|
|
||||||
oobBlk = (OobBlock)Marshal.PtrToStructure(oobPtr, typeof(OobBlock));
|
|
||||||
Marshal.FreeHGlobal(oobPtr);
|
|
||||||
|
|
||||||
if(oobBlk.blockType == OobTypes.EOF)
|
if(oobBlk.blockType == OobTypes.EOF)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,11 +30,10 @@
|
|||||||
// Copyright © 2011-2019 Natalia Portillo
|
// Copyright © 2011-2019 Natalia Portillo
|
||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using DiscImageChef.CommonTypes.Interfaces;
|
using DiscImageChef.CommonTypes.Interfaces;
|
||||||
using DiscImageChef.Console;
|
using DiscImageChef.Console;
|
||||||
|
using DiscImageChef.Helpers;
|
||||||
|
|
||||||
namespace DiscImageChef.DiscImages
|
namespace DiscImageChef.DiscImages
|
||||||
{
|
{
|
||||||
@@ -50,10 +49,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
stream.Seek(0, SeekOrigin.Begin);
|
stream.Seek(0, SeekOrigin.Begin);
|
||||||
stream.Read(buffer, 0, buffer.Length);
|
stream.Read(buffer, 0, buffer.Length);
|
||||||
|
|
||||||
IntPtr ftrPtr = Marshal.AllocHGlobal(buffer.Length);
|
HdkHeader tmpHeader = Marshal.ByteArrayToStructureLittleEndian<HdkHeader>(buffer);
|
||||||
Marshal.Copy(buffer, 0, ftrPtr, buffer.Length);
|
|
||||||
HdkHeader tmpHeader = (HdkHeader)Marshal.PtrToStructure(ftrPtr, typeof(HdkHeader));
|
|
||||||
Marshal.FreeHGlobal(ftrPtr);
|
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("MAXI Disk plugin", "tmp_header.unknown = {0}", tmpHeader.unknown);
|
DicConsole.DebugWriteLine("MAXI Disk plugin", "tmp_header.unknown = {0}", tmpHeader.unknown);
|
||||||
DicConsole.DebugWriteLine("MAXI Disk plugin", "tmp_header.diskType = {0}", tmpHeader.diskType);
|
DicConsole.DebugWriteLine("MAXI Disk plugin", "tmp_header.diskType = {0}", tmpHeader.diskType);
|
||||||
|
|||||||
@@ -32,10 +32,10 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using DiscImageChef.CommonTypes;
|
using DiscImageChef.CommonTypes;
|
||||||
using DiscImageChef.CommonTypes.Enums;
|
using DiscImageChef.CommonTypes.Enums;
|
||||||
using DiscImageChef.CommonTypes.Interfaces;
|
using DiscImageChef.CommonTypes.Interfaces;
|
||||||
|
using DiscImageChef.Helpers;
|
||||||
|
|
||||||
namespace DiscImageChef.DiscImages
|
namespace DiscImageChef.DiscImages
|
||||||
{
|
{
|
||||||
@@ -51,10 +51,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
stream.Seek(0, SeekOrigin.Begin);
|
stream.Seek(0, SeekOrigin.Begin);
|
||||||
stream.Read(buffer, 0, buffer.Length);
|
stream.Read(buffer, 0, buffer.Length);
|
||||||
|
|
||||||
IntPtr ftrPtr = Marshal.AllocHGlobal(buffer.Length);
|
HdkHeader tmpHeader = Marshal.ByteArrayToStructureLittleEndian<HdkHeader>(buffer);
|
||||||
Marshal.Copy(buffer, 0, ftrPtr, buffer.Length);
|
|
||||||
HdkHeader tmpHeader = (HdkHeader)Marshal.PtrToStructure(ftrPtr, typeof(HdkHeader));
|
|
||||||
Marshal.FreeHGlobal(ftrPtr);
|
|
||||||
|
|
||||||
// This is hardcoded
|
// This is hardcoded
|
||||||
// But its possible values are unknown...
|
// But its possible values are unknown...
|
||||||
|
|||||||
@@ -55,9 +55,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
byte[] hdrB = new byte[Marshal.SizeOf(nhdhdr)];
|
byte[] hdrB = new byte[Marshal.SizeOf(nhdhdr)];
|
||||||
stream.Read(hdrB, 0, hdrB.Length);
|
stream.Read(hdrB, 0, hdrB.Length);
|
||||||
|
|
||||||
GCHandle handle = GCHandle.Alloc(hdrB, GCHandleType.Pinned);
|
nhdhdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<Nhdr0Header>(hdrB);
|
||||||
nhdhdr = (Nhdr0Header)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(Nhdr0Header));
|
|
||||||
handle.Free();
|
|
||||||
|
|
||||||
if(!nhdhdr.szFileID.SequenceEqual(signature)) return false;
|
if(!nhdhdr.szFileID.SequenceEqual(signature)) return false;
|
||||||
|
|
||||||
|
|||||||
@@ -56,9 +56,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
byte[] hdrB = new byte[Marshal.SizeOf(nhdhdr)];
|
byte[] hdrB = new byte[Marshal.SizeOf(nhdhdr)];
|
||||||
stream.Read(hdrB, 0, hdrB.Length);
|
stream.Read(hdrB, 0, hdrB.Length);
|
||||||
|
|
||||||
GCHandle handle = GCHandle.Alloc(hdrB, GCHandleType.Pinned);
|
nhdhdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<Nhdr0Header>(hdrB);
|
||||||
nhdhdr = (Nhdr0Header)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(Nhdr0Header));
|
|
||||||
handle.Free();
|
|
||||||
|
|
||||||
imageInfo.MediaType = MediaType.GENERIC_HDD;
|
imageInfo.MediaType = MediaType.GENERIC_HDD;
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
// Copyright © 2011-2019 Natalia Portillo
|
// Copyright © 2011-2019 Natalia Portillo
|
||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
@@ -49,11 +48,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
byte[] pHdrB = new byte[Marshal.SizeOf(pHdr)];
|
byte[] pHdrB = new byte[Marshal.SizeOf(pHdr)];
|
||||||
stream.Read(pHdrB, 0, Marshal.SizeOf(pHdr));
|
stream.Read(pHdrB, 0, Marshal.SizeOf(pHdr));
|
||||||
pHdr = new ParallelsHeader();
|
pHdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<ParallelsHeader>(pHdrB);
|
||||||
IntPtr headerPtr = Marshal.AllocHGlobal(Marshal.SizeOf(pHdr));
|
|
||||||
Marshal.Copy(pHdrB, 0, headerPtr, Marshal.SizeOf(pHdr));
|
|
||||||
pHdr = (ParallelsHeader)Marshal.PtrToStructure(headerPtr, typeof(ParallelsHeader));
|
|
||||||
Marshal.FreeHGlobal(headerPtr);
|
|
||||||
|
|
||||||
return parallelsMagic.SequenceEqual(pHdr.magic) || parallelsExtMagic.SequenceEqual(pHdr.magic);
|
return parallelsMagic.SequenceEqual(pHdr.magic) || parallelsExtMagic.SequenceEqual(pHdr.magic);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,11 +53,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
byte[] pHdrB = new byte[Marshal.SizeOf(pHdr)];
|
byte[] pHdrB = new byte[Marshal.SizeOf(pHdr)];
|
||||||
stream.Read(pHdrB, 0, Marshal.SizeOf(pHdr));
|
stream.Read(pHdrB, 0, Marshal.SizeOf(pHdr));
|
||||||
pHdr = new ParallelsHeader();
|
pHdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<ParallelsHeader>(pHdrB);
|
||||||
IntPtr headerPtr = Marshal.AllocHGlobal(Marshal.SizeOf(pHdr));
|
|
||||||
Marshal.Copy(pHdrB, 0, headerPtr, Marshal.SizeOf(pHdr));
|
|
||||||
pHdr = (ParallelsHeader)Marshal.PtrToStructure(headerPtr, typeof(ParallelsHeader));
|
|
||||||
Marshal.FreeHGlobal(headerPtr);
|
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("Parallels plugin", "pHdr.magic = {0}",
|
DicConsole.DebugWriteLine("Parallels plugin", "pHdr.magic = {0}",
|
||||||
StringHandlers.CToString(pHdr.magic));
|
StringHandlers.CToString(pHdr.magic));
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
// Copyright © 2011-2019 Natalia Portillo
|
// Copyright © 2011-2019 Natalia Portillo
|
||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
@@ -49,11 +48,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
byte[] pHdrB = new byte[Marshal.SizeOf(pHdr)];
|
byte[] pHdrB = new byte[Marshal.SizeOf(pHdr)];
|
||||||
stream.Read(pHdrB, 0, Marshal.SizeOf(pHdr));
|
stream.Read(pHdrB, 0, Marshal.SizeOf(pHdr));
|
||||||
pHdr = new PartCloneHeader();
|
pHdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<PartCloneHeader>(pHdrB);
|
||||||
IntPtr headerPtr = Marshal.AllocHGlobal(Marshal.SizeOf(pHdr));
|
|
||||||
Marshal.Copy(pHdrB, 0, headerPtr, Marshal.SizeOf(pHdr));
|
|
||||||
pHdr = (PartCloneHeader)Marshal.PtrToStructure(headerPtr, typeof(PartCloneHeader));
|
|
||||||
Marshal.FreeHGlobal(headerPtr);
|
|
||||||
|
|
||||||
if(stream.Position + (long)pHdr.totalBlocks > stream.Length) return false;
|
if(stream.Position + (long)pHdr.totalBlocks > stream.Length) return false;
|
||||||
|
|
||||||
|
|||||||
@@ -55,11 +55,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
byte[] pHdrB = new byte[Marshal.SizeOf(pHdr)];
|
byte[] pHdrB = new byte[Marshal.SizeOf(pHdr)];
|
||||||
stream.Read(pHdrB, 0, Marshal.SizeOf(pHdr));
|
stream.Read(pHdrB, 0, Marshal.SizeOf(pHdr));
|
||||||
pHdr = new PartCloneHeader();
|
pHdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<PartCloneHeader>(pHdrB);
|
||||||
IntPtr headerPtr = Marshal.AllocHGlobal(Marshal.SizeOf(pHdr));
|
|
||||||
Marshal.Copy(pHdrB, 0, headerPtr, Marshal.SizeOf(pHdr));
|
|
||||||
pHdr = (PartCloneHeader)Marshal.PtrToStructure(headerPtr, typeof(PartCloneHeader));
|
|
||||||
Marshal.FreeHGlobal(headerPtr);
|
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("PartClone plugin", "pHdr.magic = {0}", StringHandlers.CToString(pHdr.magic));
|
DicConsole.DebugWriteLine("PartClone plugin", "pHdr.magic = {0}", StringHandlers.CToString(pHdr.magic));
|
||||||
DicConsole.DebugWriteLine("PartClone plugin", "pHdr.filesystem = {0}",
|
DicConsole.DebugWriteLine("PartClone plugin", "pHdr.filesystem = {0}",
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
// Copyright © 2011-2019 Natalia Portillo
|
// Copyright © 2011-2019 Natalia Portillo
|
||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
@@ -49,11 +48,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
byte[] pHdrB = new byte[Marshal.SizeOf(cVolumeHeader)];
|
byte[] pHdrB = new byte[Marshal.SizeOf(cVolumeHeader)];
|
||||||
stream.Read(pHdrB, 0, Marshal.SizeOf(cVolumeHeader));
|
stream.Read(pHdrB, 0, Marshal.SizeOf(cVolumeHeader));
|
||||||
cVolumeHeader = new PartimageHeader();
|
cVolumeHeader = Helpers.Marshal.ByteArrayToStructureLittleEndian<PartimageHeader>(pHdrB);
|
||||||
IntPtr headerPtr = Marshal.AllocHGlobal(Marshal.SizeOf(cVolumeHeader));
|
|
||||||
Marshal.Copy(pHdrB, 0, headerPtr, Marshal.SizeOf(cVolumeHeader));
|
|
||||||
cVolumeHeader = (PartimageHeader)Marshal.PtrToStructure(headerPtr, typeof(PartimageHeader));
|
|
||||||
Marshal.FreeHGlobal(headerPtr);
|
|
||||||
|
|
||||||
return partimageMagic.SequenceEqual(cVolumeHeader.magic);
|
return partimageMagic.SequenceEqual(cVolumeHeader.magic);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,11 +54,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
byte[] hdrB = new byte[Marshal.SizeOf(cVolumeHeader)];
|
byte[] hdrB = new byte[Marshal.SizeOf(cVolumeHeader)];
|
||||||
stream.Read(hdrB, 0, Marshal.SizeOf(cVolumeHeader));
|
stream.Read(hdrB, 0, Marshal.SizeOf(cVolumeHeader));
|
||||||
cVolumeHeader = new PartimageHeader();
|
cVolumeHeader = Helpers.Marshal.ByteArrayToStructureLittleEndian<PartimageHeader>(hdrB);
|
||||||
IntPtr headerPtr = Marshal.AllocHGlobal(Marshal.SizeOf(cVolumeHeader));
|
|
||||||
Marshal.Copy(hdrB, 0, headerPtr, Marshal.SizeOf(cVolumeHeader));
|
|
||||||
cVolumeHeader = (PartimageHeader)Marshal.PtrToStructure(headerPtr, typeof(PartimageHeader));
|
|
||||||
Marshal.FreeHGlobal(headerPtr);
|
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("Partimage plugin", "CVolumeHeader.magic = {0}",
|
DicConsole.DebugWriteLine("Partimage plugin", "CVolumeHeader.magic = {0}",
|
||||||
StringHandlers.CToString(cVolumeHeader.magic));
|
StringHandlers.CToString(cVolumeHeader.magic));
|
||||||
@@ -75,11 +71,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
hdrB = new byte[Marshal.SizeOf(cMainHeader)];
|
hdrB = new byte[Marshal.SizeOf(cMainHeader)];
|
||||||
stream.Read(hdrB, 0, Marshal.SizeOf(cMainHeader));
|
stream.Read(hdrB, 0, Marshal.SizeOf(cMainHeader));
|
||||||
cMainHeader = new PartimageMainHeader();
|
cMainHeader = Helpers.Marshal.ByteArrayToStructureLittleEndian<PartimageMainHeader>(hdrB);
|
||||||
headerPtr = Marshal.AllocHGlobal(Marshal.SizeOf(cMainHeader));
|
|
||||||
Marshal.Copy(hdrB, 0, headerPtr, Marshal.SizeOf(cMainHeader));
|
|
||||||
cMainHeader = (PartimageMainHeader)Marshal.PtrToStructure(headerPtr, typeof(PartimageMainHeader));
|
|
||||||
Marshal.FreeHGlobal(headerPtr);
|
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("Partimage plugin", "CMainHeader.szFileSystem = {0}",
|
DicConsole.DebugWriteLine("Partimage plugin", "CMainHeader.szFileSystem = {0}",
|
||||||
StringHandlers.CToString(cMainHeader.szFileSystem));
|
StringHandlers.CToString(cMainHeader.szFileSystem));
|
||||||
@@ -193,10 +185,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
hdrB = new byte[Marshal.SizeOf(typeof(CLocalHeader))];
|
hdrB = new byte[Marshal.SizeOf(typeof(CLocalHeader))];
|
||||||
stream.Read(hdrB, 0, Marshal.SizeOf(typeof(CLocalHeader)));
|
stream.Read(hdrB, 0, Marshal.SizeOf(typeof(CLocalHeader)));
|
||||||
headerPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(CLocalHeader)));
|
CLocalHeader localHeader = Helpers.Marshal.ByteArrayToStructureLittleEndian<CLocalHeader>(hdrB);
|
||||||
Marshal.Copy(hdrB, 0, headerPtr, Marshal.SizeOf(typeof(CLocalHeader)));
|
|
||||||
CLocalHeader localHeader = (CLocalHeader)Marshal.PtrToStructure(headerPtr, typeof(CLocalHeader));
|
|
||||||
Marshal.FreeHGlobal(headerPtr);
|
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("Partimage plugin", "CLocalHeader.qwBlockSize = {0}", localHeader.qwBlockSize);
|
DicConsole.DebugWriteLine("Partimage plugin", "CLocalHeader.qwBlockSize = {0}", localHeader.qwBlockSize);
|
||||||
DicConsole.DebugWriteLine("Partimage plugin", "CLocalHeader.qwUsedBlocks = {0}", localHeader.qwUsedBlocks);
|
DicConsole.DebugWriteLine("Partimage plugin", "CLocalHeader.qwUsedBlocks = {0}", localHeader.qwUsedBlocks);
|
||||||
|
|||||||
@@ -30,10 +30,9 @@
|
|||||||
// Copyright © 2011-2019 Natalia Portillo
|
// Copyright © 2011-2019 Natalia Portillo
|
||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using DiscImageChef.CommonTypes.Interfaces;
|
using DiscImageChef.CommonTypes.Interfaces;
|
||||||
|
using DiscImageChef.Helpers;
|
||||||
|
|
||||||
namespace DiscImageChef.DiscImages
|
namespace DiscImageChef.DiscImages
|
||||||
{
|
{
|
||||||
@@ -48,11 +47,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
byte[] qHdrB = new byte[64];
|
byte[] qHdrB = new byte[64];
|
||||||
stream.Read(qHdrB, 0, 64);
|
stream.Read(qHdrB, 0, 64);
|
||||||
qHdr = new QedHeader();
|
qHdr = Marshal.ByteArrayToStructureLittleEndian<QedHeader>(qHdrB);
|
||||||
IntPtr headerPtr = Marshal.AllocHGlobal(64);
|
|
||||||
Marshal.Copy(qHdrB, 0, headerPtr, 64);
|
|
||||||
qHdr = (QedHeader)Marshal.PtrToStructure(headerPtr, typeof(QedHeader));
|
|
||||||
Marshal.FreeHGlobal(headerPtr);
|
|
||||||
|
|
||||||
return qHdr.magic == QED_MAGIC;
|
return qHdr.magic == QED_MAGIC;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,11 +33,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using DiscImageChef.CommonTypes;
|
using DiscImageChef.CommonTypes;
|
||||||
using DiscImageChef.CommonTypes.Enums;
|
using DiscImageChef.CommonTypes.Enums;
|
||||||
using DiscImageChef.CommonTypes.Interfaces;
|
using DiscImageChef.CommonTypes.Interfaces;
|
||||||
using DiscImageChef.Console;
|
using DiscImageChef.Console;
|
||||||
|
using DiscImageChef.Helpers;
|
||||||
|
|
||||||
namespace DiscImageChef.DiscImages
|
namespace DiscImageChef.DiscImages
|
||||||
{
|
{
|
||||||
@@ -52,11 +52,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
byte[] qHdrB = new byte[64];
|
byte[] qHdrB = new byte[64];
|
||||||
stream.Read(qHdrB, 0, 64);
|
stream.Read(qHdrB, 0, 64);
|
||||||
qHdr = new QedHeader();
|
qHdr = Marshal.ByteArrayToStructureLittleEndian<QedHeader>(qHdrB);
|
||||||
IntPtr headerPtr = Marshal.AllocHGlobal(64);
|
|
||||||
Marshal.Copy(qHdrB, 0, headerPtr, 64);
|
|
||||||
qHdr = (QedHeader)Marshal.PtrToStructure(headerPtr, typeof(QedHeader));
|
|
||||||
Marshal.FreeHGlobal(headerPtr);
|
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("QED plugin", "qHdr.magic = 0x{0:X8}", qHdr.magic);
|
DicConsole.DebugWriteLine("QED plugin", "qHdr.magic = 0x{0:X8}", qHdr.magic);
|
||||||
DicConsole.DebugWriteLine("QED plugin", "qHdr.cluster_size = {0}", qHdr.cluster_size);
|
DicConsole.DebugWriteLine("QED plugin", "qHdr.cluster_size = {0}", qHdr.cluster_size);
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
// Copyright © 2011-2019 Natalia Portillo
|
// Copyright © 2011-2019 Natalia Portillo
|
||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
@@ -51,10 +50,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
stream.Seek(0, SeekOrigin.Begin);
|
stream.Seek(0, SeekOrigin.Begin);
|
||||||
stream.Read(buffer, 0, buffer.Length);
|
stream.Read(buffer, 0, buffer.Length);
|
||||||
|
|
||||||
IntPtr ftrPtr = Marshal.AllocHGlobal(buffer.Length);
|
RayHdr header = Helpers.Marshal.ByteArrayToStructureLittleEndian<RayHdr>(buffer);
|
||||||
Marshal.Copy(buffer, 0, ftrPtr, buffer.Length);
|
|
||||||
RayHdr header = (RayHdr)Marshal.PtrToStructure(ftrPtr, typeof(RayHdr));
|
|
||||||
Marshal.FreeHGlobal(ftrPtr);
|
|
||||||
|
|
||||||
string signature = StringHandlers.CToString(header.signature);
|
string signature = StringHandlers.CToString(header.signature);
|
||||||
|
|
||||||
|
|||||||
@@ -52,10 +52,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
stream.Seek(0, SeekOrigin.Begin);
|
stream.Seek(0, SeekOrigin.Begin);
|
||||||
stream.Read(buffer, 0, buffer.Length);
|
stream.Read(buffer, 0, buffer.Length);
|
||||||
|
|
||||||
IntPtr ftrPtr = Marshal.AllocHGlobal(buffer.Length);
|
RayHdr header = Helpers.Marshal.ByteArrayToStructureLittleEndian<RayHdr>(buffer);
|
||||||
Marshal.Copy(buffer, 0, ftrPtr, buffer.Length);
|
|
||||||
RayHdr header = (RayHdr)Marshal.PtrToStructure(ftrPtr, typeof(RayHdr));
|
|
||||||
Marshal.FreeHGlobal(ftrPtr);
|
|
||||||
|
|
||||||
string signature = StringHandlers.CToString(header.signature);
|
string signature = StringHandlers.CToString(header.signature);
|
||||||
|
|
||||||
|
|||||||
@@ -52,10 +52,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
byte[] hdrB = new byte[Marshal.SizeOf(typeof(RsIdeHeader))];
|
byte[] hdrB = new byte[Marshal.SizeOf(typeof(RsIdeHeader))];
|
||||||
stream.Read(hdrB, 0, hdrB.Length);
|
stream.Read(hdrB, 0, hdrB.Length);
|
||||||
|
|
||||||
IntPtr hdrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(RsIdeHeader)));
|
RsIdeHeader hdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<RsIdeHeader>(hdrB);
|
||||||
Marshal.Copy(hdrB, 0, hdrPtr, Marshal.SizeOf(typeof(RsIdeHeader)));
|
|
||||||
RsIdeHeader hdr = (RsIdeHeader)Marshal.PtrToStructure(hdrPtr, typeof(RsIdeHeader));
|
|
||||||
Marshal.FreeHGlobal(hdrPtr);
|
|
||||||
|
|
||||||
if(!hdr.magic.SequenceEqual(signature)) return false;
|
if(!hdr.magic.SequenceEqual(signature)) return false;
|
||||||
|
|
||||||
|
|||||||
@@ -30,10 +30,9 @@
|
|||||||
// Copyright © 2011-2019 Natalia Portillo
|
// Copyright © 2011-2019 Natalia Portillo
|
||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using DiscImageChef.CommonTypes.Interfaces;
|
using DiscImageChef.CommonTypes.Interfaces;
|
||||||
|
using DiscImageChef.Helpers;
|
||||||
|
|
||||||
namespace DiscImageChef.DiscImages
|
namespace DiscImageChef.DiscImages
|
||||||
{
|
{
|
||||||
@@ -48,11 +47,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
byte[] hdr = new byte[40];
|
byte[] hdr = new byte[40];
|
||||||
stream.Read(hdr, 0, 40);
|
stream.Read(hdr, 0, 40);
|
||||||
|
|
||||||
header = new SaveDskFHeader();
|
header = Marshal.ByteArrayToStructureLittleEndian<SaveDskFHeader>(hdr);
|
||||||
IntPtr hdrPtr = Marshal.AllocHGlobal(40);
|
|
||||||
Marshal.Copy(hdr, 0, hdrPtr, 40);
|
|
||||||
header = (SaveDskFHeader)Marshal.PtrToStructure(hdrPtr, typeof(SaveDskFHeader));
|
|
||||||
Marshal.FreeHGlobal(hdrPtr);
|
|
||||||
|
|
||||||
return (header.magic == SDF_MAGIC || header.magic == SDF_MAGIC_COMPRESSED ||
|
return (header.magic == SDF_MAGIC || header.magic == SDF_MAGIC_COMPRESSED ||
|
||||||
header.magic == SDF_MAGIC_OLD) && header.fatCopies <= 2 && header.padding == 0 &&
|
header.magic == SDF_MAGIC_OLD) && header.fatCopies <= 2 && header.padding == 0 &&
|
||||||
|
|||||||
@@ -32,13 +32,13 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using DiscImageChef.CommonTypes;
|
using DiscImageChef.CommonTypes;
|
||||||
using DiscImageChef.CommonTypes.Enums;
|
using DiscImageChef.CommonTypes.Enums;
|
||||||
using DiscImageChef.CommonTypes.Exceptions;
|
using DiscImageChef.CommonTypes.Exceptions;
|
||||||
using DiscImageChef.CommonTypes.Interfaces;
|
using DiscImageChef.CommonTypes.Interfaces;
|
||||||
using DiscImageChef.Console;
|
using DiscImageChef.Console;
|
||||||
|
using DiscImageChef.Helpers;
|
||||||
|
|
||||||
namespace DiscImageChef.DiscImages
|
namespace DiscImageChef.DiscImages
|
||||||
{
|
{
|
||||||
@@ -52,11 +52,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
byte[] hdr = new byte[40];
|
byte[] hdr = new byte[40];
|
||||||
|
|
||||||
stream.Read(hdr, 0, 40);
|
stream.Read(hdr, 0, 40);
|
||||||
header = new SaveDskFHeader();
|
header = Marshal.ByteArrayToStructureLittleEndian<SaveDskFHeader>(hdr);
|
||||||
IntPtr hdrPtr = Marshal.AllocHGlobal(40);
|
|
||||||
Marshal.Copy(hdr, 0, hdrPtr, 40);
|
|
||||||
header = (SaveDskFHeader)Marshal.PtrToStructure(hdrPtr, typeof(SaveDskFHeader));
|
|
||||||
Marshal.FreeHGlobal(hdrPtr);
|
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SaveDskF plugin", "header.magic = 0x{0:X4}", header.magic);
|
DicConsole.DebugWriteLine("SaveDskF plugin", "header.magic = 0x{0:X4}", header.magic);
|
||||||
DicConsole.DebugWriteLine("SaveDskF plugin", "header.mediaType = 0x{0:X2}", header.mediaType);
|
DicConsole.DebugWriteLine("SaveDskF plugin", "header.mediaType = 0x{0:X2}", header.mediaType);
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
// Copyright © 2011-2019 Natalia Portillo
|
// Copyright © 2011-2019 Natalia Portillo
|
||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
@@ -50,10 +49,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
byte[] hdr = new byte[Marshal.SizeOf(Header)];
|
byte[] hdr = new byte[Marshal.SizeOf(Header)];
|
||||||
stream.Read(hdr, 0, Marshal.SizeOf(Header));
|
stream.Read(hdr, 0, Marshal.SizeOf(Header));
|
||||||
|
|
||||||
IntPtr hdrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(Header));
|
Header = Helpers.Marshal.ByteArrayToStructureLittleEndian<ScpHeader>(hdr);
|
||||||
Marshal.Copy(hdr, 0, hdrPtr, Marshal.SizeOf(Header));
|
|
||||||
Header = (ScpHeader)Marshal.PtrToStructure(hdrPtr, typeof(ScpHeader));
|
|
||||||
Marshal.FreeHGlobal(hdrPtr);
|
|
||||||
|
|
||||||
return scpSignature.SequenceEqual(Header.signature);
|
return scpSignature.SequenceEqual(Header.signature);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,10 +53,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
byte[] hdr = new byte[Marshal.SizeOf(Header)];
|
byte[] hdr = new byte[Marshal.SizeOf(Header)];
|
||||||
scpStream.Read(hdr, 0, Marshal.SizeOf(Header));
|
scpStream.Read(hdr, 0, Marshal.SizeOf(Header));
|
||||||
|
|
||||||
IntPtr hdrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(Header));
|
Header = Helpers.Marshal.ByteArrayToStructureLittleEndian<ScpHeader>(hdr);
|
||||||
Marshal.Copy(hdr, 0, hdrPtr, Marshal.SizeOf(Header));
|
|
||||||
Header = (ScpHeader)Marshal.PtrToStructure(hdrPtr, typeof(ScpHeader));
|
|
||||||
Marshal.FreeHGlobal(hdrPtr);
|
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SuperCardPro plugin", "header.signature = \"{0}\"",
|
DicConsole.DebugWriteLine("SuperCardPro plugin", "header.signature = \"{0}\"",
|
||||||
StringHandlers.CToString(Header.signature));
|
StringHandlers.CToString(Header.signature));
|
||||||
@@ -107,10 +104,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
byte[] rev = new byte[Marshal.SizeOf(typeof(TrackEntry))];
|
byte[] rev = new byte[Marshal.SizeOf(typeof(TrackEntry))];
|
||||||
scpStream.Read(rev, 0, Marshal.SizeOf(typeof(TrackEntry)));
|
scpStream.Read(rev, 0, Marshal.SizeOf(typeof(TrackEntry)));
|
||||||
|
|
||||||
IntPtr revPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(TrackEntry)));
|
trk.Entries[r] = Helpers.Marshal.ByteArrayToStructureLittleEndian<TrackEntry>(rev);
|
||||||
Marshal.Copy(rev, 0, revPtr, Marshal.SizeOf(typeof(TrackEntry)));
|
|
||||||
trk.Entries[r] = (TrackEntry)Marshal.PtrToStructure(revPtr, typeof(TrackEntry));
|
|
||||||
Marshal.FreeHGlobal(revPtr);
|
|
||||||
// De-relative offsets
|
// De-relative offsets
|
||||||
trk.Entries[r].dataOffset += Header.offsets[t];
|
trk.Entries[r].dataOffset += Header.offsets[t];
|
||||||
}
|
}
|
||||||
@@ -138,10 +132,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
byte[] ftr = new byte[Marshal.SizeOf(typeof(ScpFooter))];
|
byte[] ftr = new byte[Marshal.SizeOf(typeof(ScpFooter))];
|
||||||
scpStream.Read(ftr, 0, Marshal.SizeOf(typeof(ScpFooter)));
|
scpStream.Read(ftr, 0, Marshal.SizeOf(typeof(ScpFooter)));
|
||||||
|
|
||||||
IntPtr ftrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(ScpFooter)));
|
ScpFooter footer = Helpers.Marshal.ByteArrayToStructureLittleEndian<ScpFooter>(ftr);
|
||||||
Marshal.Copy(ftr, 0, ftrPtr, Marshal.SizeOf(typeof(ScpFooter)));
|
|
||||||
ScpFooter footer = (ScpFooter)Marshal.PtrToStructure(ftrPtr, typeof(ScpFooter));
|
|
||||||
Marshal.FreeHGlobal(ftrPtr);
|
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("SuperCardPro plugin", "footer.manufacturerOffset = 0x{0:X8}",
|
DicConsole.DebugWriteLine("SuperCardPro plugin", "footer.manufacturerOffset = 0x{0:X8}",
|
||||||
footer.manufacturerOffset);
|
footer.manufacturerOffset);
|
||||||
|
|||||||
@@ -50,10 +50,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
byte[] hdrB = new byte[Marshal.SizeOf(hdr)];
|
byte[] hdrB = new byte[Marshal.SizeOf(hdr)];
|
||||||
stream.Read(hdrB, 0, hdrB.Length);
|
stream.Read(hdrB, 0, hdrB.Length);
|
||||||
|
hdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<FdiHeader>(hdrB);
|
||||||
GCHandle handle = GCHandle.Alloc(hdrB, GCHandleType.Pinned);
|
|
||||||
hdr = (FdiHeader)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(FdiHeader));
|
|
||||||
handle.Free();
|
|
||||||
|
|
||||||
return hdr.magic.SequenceEqual(signature);
|
return hdr.magic.SequenceEqual(signature);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,9 +54,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
byte[] hdrB = new byte[Marshal.SizeOf(hdr)];
|
byte[] hdrB = new byte[Marshal.SizeOf(hdr)];
|
||||||
stream.Read(hdrB, 0, hdrB.Length);
|
stream.Read(hdrB, 0, hdrB.Length);
|
||||||
|
|
||||||
GCHandle handle = GCHandle.Alloc(hdrB, GCHandleType.Pinned);
|
hdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<FdiHeader>(hdrB);
|
||||||
hdr = (FdiHeader)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(FdiHeader));
|
|
||||||
handle.Free();
|
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("UkvFdi plugin", "hdr.addInfoLen = {0}", hdr.addInfoLen);
|
DicConsole.DebugWriteLine("UkvFdi plugin", "hdr.addInfoLen = {0}", hdr.addInfoLen);
|
||||||
DicConsole.DebugWriteLine("UkvFdi plugin", "hdr.cylinders = {0}", hdr.cylinders);
|
DicConsole.DebugWriteLine("UkvFdi plugin", "hdr.cylinders = {0}", hdr.cylinders);
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
// Copyright © 2011-2019 Natalia Portillo
|
// Copyright © 2011-2019 Natalia Portillo
|
||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using DiscImageChef.CommonTypes.Interfaces;
|
using DiscImageChef.CommonTypes.Interfaces;
|
||||||
@@ -48,11 +47,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
byte[] vHdrB = new byte[Marshal.SizeOf(vHdr)];
|
byte[] vHdrB = new byte[Marshal.SizeOf(vHdr)];
|
||||||
stream.Read(vHdrB, 0, Marshal.SizeOf(vHdr));
|
stream.Read(vHdrB, 0, Marshal.SizeOf(vHdr));
|
||||||
vHdr = new VdiHeader();
|
vHdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<VdiHeader>(vHdrB);
|
||||||
IntPtr headerPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vHdr));
|
|
||||||
Marshal.Copy(vHdrB, 0, headerPtr, Marshal.SizeOf(vHdr));
|
|
||||||
vHdr = (VdiHeader)Marshal.PtrToStructure(headerPtr, typeof(VdiHeader));
|
|
||||||
Marshal.FreeHGlobal(headerPtr);
|
|
||||||
|
|
||||||
return vHdr.magic == VDI_MAGIC;
|
return vHdr.magic == VDI_MAGIC;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,11 +53,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
byte[] vHdrB = new byte[Marshal.SizeOf(vHdr)];
|
byte[] vHdrB = new byte[Marshal.SizeOf(vHdr)];
|
||||||
stream.Read(vHdrB, 0, Marshal.SizeOf(vHdr));
|
stream.Read(vHdrB, 0, Marshal.SizeOf(vHdr));
|
||||||
vHdr = new VdiHeader();
|
vHdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<VdiHeader>(vHdrB);
|
||||||
IntPtr headerPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vHdr));
|
|
||||||
Marshal.Copy(vHdrB, 0, headerPtr, Marshal.SizeOf(vHdr));
|
|
||||||
vHdr = (VdiHeader)Marshal.PtrToStructure(headerPtr, typeof(VdiHeader));
|
|
||||||
Marshal.FreeHGlobal(headerPtr);
|
|
||||||
|
|
||||||
DicConsole.DebugWriteLine("VirtualBox plugin", "vHdr.creator = {0}", vHdr.creator);
|
DicConsole.DebugWriteLine("VirtualBox plugin", "vHdr.creator = {0}", vHdr.creator);
|
||||||
DicConsole.DebugWriteLine("VirtualBox plugin", "vHdr.magic = {0}", vHdr.magic);
|
DicConsole.DebugWriteLine("VirtualBox plugin", "vHdr.magic = {0}", vHdr.magic);
|
||||||
|
|||||||
@@ -32,7 +32,6 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using DiscImageChef.Checksums;
|
using DiscImageChef.Checksums;
|
||||||
using DiscImageChef.CommonTypes;
|
using DiscImageChef.CommonTypes;
|
||||||
@@ -40,6 +39,7 @@ using DiscImageChef.CommonTypes.Enums;
|
|||||||
using DiscImageChef.CommonTypes.Exceptions;
|
using DiscImageChef.CommonTypes.Exceptions;
|
||||||
using DiscImageChef.CommonTypes.Interfaces;
|
using DiscImageChef.CommonTypes.Interfaces;
|
||||||
using DiscImageChef.Console;
|
using DiscImageChef.Console;
|
||||||
|
using DiscImageChef.Helpers;
|
||||||
|
|
||||||
namespace DiscImageChef.DiscImages
|
namespace DiscImageChef.DiscImages
|
||||||
{
|
{
|
||||||
@@ -423,10 +423,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
imageStream.Read(batSectorBytes, 0, 512);
|
imageStream.Read(batSectorBytes, 0, 512);
|
||||||
// This does the big-endian trick but reverses the order of elements also
|
// This does the big-endian trick but reverses the order of elements also
|
||||||
Array.Reverse(batSectorBytes);
|
Array.Reverse(batSectorBytes);
|
||||||
GCHandle handle = GCHandle.Alloc(batSectorBytes, GCHandleType.Pinned);
|
BatSector batSector = Marshal.ByteArrayToStructureLittleEndian<BatSector>(batSectorBytes);
|
||||||
BatSector batSector =
|
|
||||||
(BatSector)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(BatSector));
|
|
||||||
handle.Free();
|
|
||||||
// This restores the order of elements
|
// This restores the order of elements
|
||||||
Array.Reverse(batSector.blockPointer);
|
Array.Reverse(batSector.blockPointer);
|
||||||
if(blockAllocationTable.Length >= i * 512 / 4 + 512 / 4)
|
if(blockAllocationTable.Length >= i * 512 / 4 + 512 / 4)
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
// Copyright © 2011-2019 Natalia Portillo
|
// Copyright © 2011-2019 Natalia Portillo
|
||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using DiscImageChef.CommonTypes.Interfaces;
|
using DiscImageChef.CommonTypes.Interfaces;
|
||||||
@@ -48,11 +47,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
byte[] vhdxIdB = new byte[Marshal.SizeOf(vhdxId)];
|
byte[] vhdxIdB = new byte[Marshal.SizeOf(vhdxId)];
|
||||||
stream.Read(vhdxIdB, 0, Marshal.SizeOf(vhdxId));
|
stream.Read(vhdxIdB, 0, Marshal.SizeOf(vhdxId));
|
||||||
vhdxId = new VhdxIdentifier();
|
vhdxId = Helpers.Marshal.ByteArrayToStructureLittleEndian<VhdxIdentifier>(vhdxIdB);
|
||||||
IntPtr idPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vhdxId));
|
|
||||||
Marshal.Copy(vhdxIdB, 0, idPtr, Marshal.SizeOf(vhdxId));
|
|
||||||
vhdxId = (VhdxIdentifier)Marshal.PtrToStructure(idPtr, typeof(VhdxIdentifier));
|
|
||||||
Marshal.FreeHGlobal(idPtr);
|
|
||||||
|
|
||||||
return vhdxId.signature == VHDX_SIGNATURE;
|
return vhdxId.signature == VHDX_SIGNATURE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,11 +54,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
byte[] vhdxIdB = new byte[Marshal.SizeOf(vhdxId)];
|
byte[] vhdxIdB = new byte[Marshal.SizeOf(vhdxId)];
|
||||||
stream.Read(vhdxIdB, 0, Marshal.SizeOf(vhdxId));
|
stream.Read(vhdxIdB, 0, Marshal.SizeOf(vhdxId));
|
||||||
vhdxId = new VhdxIdentifier();
|
vhdxId = Helpers.Marshal.ByteArrayToStructureLittleEndian<VhdxIdentifier>(vhdxIdB);
|
||||||
IntPtr idPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vhdxId));
|
|
||||||
Marshal.Copy(vhdxIdB, 0, idPtr, Marshal.SizeOf(vhdxId));
|
|
||||||
vhdxId = (VhdxIdentifier)Marshal.PtrToStructure(idPtr, typeof(VhdxIdentifier));
|
|
||||||
Marshal.FreeHGlobal(idPtr);
|
|
||||||
|
|
||||||
if(vhdxId.signature != VHDX_SIGNATURE) return false;
|
if(vhdxId.signature != VHDX_SIGNATURE) return false;
|
||||||
|
|
||||||
@@ -67,22 +63,14 @@ namespace DiscImageChef.DiscImages
|
|||||||
stream.Seek(64 * 1024, SeekOrigin.Begin);
|
stream.Seek(64 * 1024, SeekOrigin.Begin);
|
||||||
byte[] vHdrB = new byte[Marshal.SizeOf(vHdr)];
|
byte[] vHdrB = new byte[Marshal.SizeOf(vHdr)];
|
||||||
stream.Read(vHdrB, 0, Marshal.SizeOf(vHdr));
|
stream.Read(vHdrB, 0, Marshal.SizeOf(vHdr));
|
||||||
vHdr = new VhdxHeader();
|
vHdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<VhdxHeader>(vHdrB);
|
||||||
IntPtr headerPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vHdr));
|
|
||||||
Marshal.Copy(vHdrB, 0, headerPtr, Marshal.SizeOf(vHdr));
|
|
||||||
vHdr = (VhdxHeader)Marshal.PtrToStructure(headerPtr, typeof(VhdxHeader));
|
|
||||||
Marshal.FreeHGlobal(headerPtr);
|
|
||||||
|
|
||||||
if(vHdr.Signature != VHDX_HEADER_SIG)
|
if(vHdr.Signature != VHDX_HEADER_SIG)
|
||||||
{
|
{
|
||||||
stream.Seek(128 * 1024, SeekOrigin.Begin);
|
stream.Seek(128 * 1024, SeekOrigin.Begin);
|
||||||
vHdrB = new byte[Marshal.SizeOf(vHdr)];
|
vHdrB = new byte[Marshal.SizeOf(vHdr)];
|
||||||
stream.Read(vHdrB, 0, Marshal.SizeOf(vHdr));
|
stream.Read(vHdrB, 0, Marshal.SizeOf(vHdr));
|
||||||
vHdr = new VhdxHeader();
|
vHdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<VhdxHeader>(vHdrB);
|
||||||
headerPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vHdr));
|
|
||||||
Marshal.Copy(vHdrB, 0, headerPtr, Marshal.SizeOf(vHdr));
|
|
||||||
vHdr = (VhdxHeader)Marshal.PtrToStructure(headerPtr, typeof(VhdxHeader));
|
|
||||||
Marshal.FreeHGlobal(headerPtr);
|
|
||||||
|
|
||||||
if(vHdr.Signature != VHDX_HEADER_SIG) throw new ImageNotSupportedException("VHDX header not found");
|
if(vHdr.Signature != VHDX_HEADER_SIG) throw new ImageNotSupportedException("VHDX header not found");
|
||||||
}
|
}
|
||||||
@@ -90,22 +78,14 @@ namespace DiscImageChef.DiscImages
|
|||||||
stream.Seek(192 * 1024, SeekOrigin.Begin);
|
stream.Seek(192 * 1024, SeekOrigin.Begin);
|
||||||
byte[] vRegTableB = new byte[Marshal.SizeOf(vRegHdr)];
|
byte[] vRegTableB = new byte[Marshal.SizeOf(vRegHdr)];
|
||||||
stream.Read(vRegTableB, 0, Marshal.SizeOf(vRegHdr));
|
stream.Read(vRegTableB, 0, Marshal.SizeOf(vRegHdr));
|
||||||
vRegHdr = new VhdxRegionTableHeader();
|
vRegHdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<VhdxRegionTableHeader>(vRegTableB);
|
||||||
IntPtr vRegTabPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vRegHdr));
|
|
||||||
Marshal.Copy(vRegTableB, 0, vRegTabPtr, Marshal.SizeOf(vRegHdr));
|
|
||||||
vRegHdr = (VhdxRegionTableHeader)Marshal.PtrToStructure(vRegTabPtr, typeof(VhdxRegionTableHeader));
|
|
||||||
Marshal.FreeHGlobal(vRegTabPtr);
|
|
||||||
|
|
||||||
if(vRegHdr.signature != VHDX_REGION_SIG)
|
if(vRegHdr.signature != VHDX_REGION_SIG)
|
||||||
{
|
{
|
||||||
stream.Seek(256 * 1024, SeekOrigin.Begin);
|
stream.Seek(256 * 1024, SeekOrigin.Begin);
|
||||||
vRegTableB = new byte[Marshal.SizeOf(vRegHdr)];
|
vRegTableB = new byte[Marshal.SizeOf(vRegHdr)];
|
||||||
stream.Read(vRegTableB, 0, Marshal.SizeOf(vRegHdr));
|
stream.Read(vRegTableB, 0, Marshal.SizeOf(vRegHdr));
|
||||||
vRegHdr = new VhdxRegionTableHeader();
|
vRegHdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<VhdxRegionTableHeader>(vRegTableB);
|
||||||
vRegTabPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vRegHdr));
|
|
||||||
Marshal.Copy(vRegTableB, 0, vRegTabPtr, Marshal.SizeOf(vRegHdr));
|
|
||||||
vRegHdr = (VhdxRegionTableHeader)Marshal.PtrToStructure(vRegTabPtr, typeof(VhdxRegionTableHeader));
|
|
||||||
Marshal.FreeHGlobal(vRegTabPtr);
|
|
||||||
|
|
||||||
if(vRegHdr.signature != VHDX_REGION_SIG)
|
if(vRegHdr.signature != VHDX_REGION_SIG)
|
||||||
throw new ImageNotSupportedException("VHDX region table not found");
|
throw new ImageNotSupportedException("VHDX region table not found");
|
||||||
@@ -116,11 +96,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
{
|
{
|
||||||
byte[] vRegB = new byte[Marshal.SizeOf(vRegs[i])];
|
byte[] vRegB = new byte[Marshal.SizeOf(vRegs[i])];
|
||||||
stream.Read(vRegB, 0, Marshal.SizeOf(vRegs[i]));
|
stream.Read(vRegB, 0, Marshal.SizeOf(vRegs[i]));
|
||||||
vRegs[i] = new VhdxRegionTableEntry();
|
vRegs[i] = Helpers.Marshal.ByteArrayToStructureLittleEndian<VhdxRegionTableEntry>(vRegB);
|
||||||
IntPtr vRegPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vRegs[i]));
|
|
||||||
Marshal.Copy(vRegB, 0, vRegPtr, Marshal.SizeOf(vRegs[i]));
|
|
||||||
vRegs[i] = (VhdxRegionTableEntry)Marshal.PtrToStructure(vRegPtr, typeof(VhdxRegionTableEntry));
|
|
||||||
Marshal.FreeHGlobal(vRegPtr);
|
|
||||||
|
|
||||||
if(vRegs[i].guid == batGuid)
|
if(vRegs[i].guid == batGuid)
|
||||||
batOffset = (long)vRegs[i].offset;
|
batOffset = (long)vRegs[i].offset;
|
||||||
@@ -140,22 +116,14 @@ namespace DiscImageChef.DiscImages
|
|||||||
stream.Seek(metadataOffset, SeekOrigin.Begin);
|
stream.Seek(metadataOffset, SeekOrigin.Begin);
|
||||||
byte[] metTableB = new byte[Marshal.SizeOf(vMetHdr)];
|
byte[] metTableB = new byte[Marshal.SizeOf(vMetHdr)];
|
||||||
stream.Read(metTableB, 0, Marshal.SizeOf(vMetHdr));
|
stream.Read(metTableB, 0, Marshal.SizeOf(vMetHdr));
|
||||||
vMetHdr = new VhdxMetadataTableHeader();
|
vMetHdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<VhdxMetadataTableHeader>(metTableB);
|
||||||
IntPtr metTablePtr = Marshal.AllocHGlobal(Marshal.SizeOf(vMetHdr));
|
|
||||||
Marshal.Copy(metTableB, 0, metTablePtr, Marshal.SizeOf(vMetHdr));
|
|
||||||
vMetHdr = (VhdxMetadataTableHeader)Marshal.PtrToStructure(metTablePtr, typeof(VhdxMetadataTableHeader));
|
|
||||||
Marshal.FreeHGlobal(metTablePtr);
|
|
||||||
|
|
||||||
vMets = new VhdxMetadataTableEntry[vMetHdr.entries];
|
vMets = new VhdxMetadataTableEntry[vMetHdr.entries];
|
||||||
for(int i = 0; i < vMets.Length; i++)
|
for(int i = 0; i < vMets.Length; i++)
|
||||||
{
|
{
|
||||||
byte[] vMetB = new byte[Marshal.SizeOf(vMets[i])];
|
byte[] vMetB = new byte[Marshal.SizeOf(vMets[i])];
|
||||||
stream.Read(vMetB, 0, Marshal.SizeOf(vMets[i]));
|
stream.Read(vMetB, 0, Marshal.SizeOf(vMets[i]));
|
||||||
vMets[i] = new VhdxMetadataTableEntry();
|
vMets[i] = Helpers.Marshal.ByteArrayToStructureLittleEndian<VhdxMetadataTableEntry>(vMetB);
|
||||||
IntPtr vMetPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vMets[i]));
|
|
||||||
Marshal.Copy(vMetB, 0, vMetPtr, Marshal.SizeOf(vMets[i]));
|
|
||||||
vMets[i] = (VhdxMetadataTableEntry)Marshal.PtrToStructure(vMetPtr, typeof(VhdxMetadataTableEntry));
|
|
||||||
Marshal.FreeHGlobal(vMetPtr);
|
|
||||||
|
|
||||||
if(vMets[i].itemId == fileParametersGuid)
|
if(vMets[i].itemId == fileParametersGuid)
|
||||||
fileParamsOff = vMets[i].offset;
|
fileParamsOff = vMets[i].offset;
|
||||||
@@ -228,11 +196,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
stream.Seek(parentOff + metadataOffset, SeekOrigin.Begin);
|
stream.Seek(parentOff + metadataOffset, SeekOrigin.Begin);
|
||||||
byte[] vParHdrB = new byte[Marshal.SizeOf(vMetHdr)];
|
byte[] vParHdrB = new byte[Marshal.SizeOf(vMetHdr)];
|
||||||
stream.Read(vParHdrB, 0, Marshal.SizeOf(vMetHdr));
|
stream.Read(vParHdrB, 0, Marshal.SizeOf(vMetHdr));
|
||||||
vParHdr = new VhdxParentLocatorHeader();
|
vParHdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<VhdxParentLocatorHeader>(vParHdrB);
|
||||||
IntPtr vParHdrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vMetHdr));
|
|
||||||
Marshal.Copy(vParHdrB, 0, vParHdrPtr, Marshal.SizeOf(vMetHdr));
|
|
||||||
vParHdr = (VhdxParentLocatorHeader)Marshal.PtrToStructure(vParHdrPtr, typeof(VhdxParentLocatorHeader));
|
|
||||||
Marshal.FreeHGlobal(vParHdrPtr);
|
|
||||||
|
|
||||||
if(vParHdr.locatorType != parentTypeVhdxGuid)
|
if(vParHdr.locatorType != parentTypeVhdxGuid)
|
||||||
throw new
|
throw new
|
||||||
@@ -243,11 +207,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
{
|
{
|
||||||
byte[] vParB = new byte[Marshal.SizeOf(vPars[i])];
|
byte[] vParB = new byte[Marshal.SizeOf(vPars[i])];
|
||||||
stream.Read(vParB, 0, Marshal.SizeOf(vPars[i]));
|
stream.Read(vParB, 0, Marshal.SizeOf(vPars[i]));
|
||||||
vPars[i] = new VhdxParentLocatorEntry();
|
vPars[i] = Helpers.Marshal.ByteArrayToStructureLittleEndian<VhdxParentLocatorEntry>(vParB);
|
||||||
IntPtr vParPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vPars[i]));
|
|
||||||
Marshal.Copy(vParB, 0, vParPtr, Marshal.SizeOf(vPars[i]));
|
|
||||||
vPars[i] = (VhdxParentLocatorEntry)Marshal.PtrToStructure(vParPtr, typeof(VhdxParentLocatorEntry));
|
|
||||||
Marshal.FreeHGlobal(vParPtr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if((vFileParms.flags & FILE_FLAGS_HAS_PARENT) == FILE_FLAGS_HAS_PARENT)
|
else if((vFileParms.flags & FILE_FLAGS_HAS_PARENT) == FILE_FLAGS_HAS_PARENT)
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
// Copyright © 2011-2019 Natalia Portillo
|
// Copyright © 2011-2019 Natalia Portillo
|
||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
@@ -51,11 +50,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
stream.Seek(0, SeekOrigin.Begin);
|
stream.Seek(0, SeekOrigin.Begin);
|
||||||
byte[] vmEHdrB = new byte[Marshal.SizeOf(vmEHdr)];
|
byte[] vmEHdrB = new byte[Marshal.SizeOf(vmEHdr)];
|
||||||
stream.Read(vmEHdrB, 0, Marshal.SizeOf(vmEHdr));
|
stream.Read(vmEHdrB, 0, Marshal.SizeOf(vmEHdr));
|
||||||
vmEHdr = new VMwareExtentHeader();
|
vmEHdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<VMwareExtentHeader>(vmEHdrB);
|
||||||
IntPtr headerPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vmEHdr));
|
|
||||||
Marshal.Copy(vmEHdrB, 0, headerPtr, Marshal.SizeOf(vmEHdr));
|
|
||||||
vmEHdr = (VMwareExtentHeader)Marshal.PtrToStructure(headerPtr, typeof(VMwareExtentHeader));
|
|
||||||
Marshal.FreeHGlobal(headerPtr);
|
|
||||||
|
|
||||||
stream.Seek(0, SeekOrigin.Begin);
|
stream.Seek(0, SeekOrigin.Begin);
|
||||||
stream.Read(ddfMagic, 0, 0x15);
|
stream.Read(ddfMagic, 0, 0x15);
|
||||||
@@ -68,10 +63,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
stream.Seek(0, SeekOrigin.Begin);
|
stream.Seek(0, SeekOrigin.Begin);
|
||||||
byte[] vmCHdrB = new byte[Marshal.SizeOf(vmCHdr)];
|
byte[] vmCHdrB = new byte[Marshal.SizeOf(vmCHdr)];
|
||||||
stream.Read(vmCHdrB, 0, Marshal.SizeOf(vmCHdr));
|
stream.Read(vmCHdrB, 0, Marshal.SizeOf(vmCHdr));
|
||||||
headerPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vmCHdr));
|
vmCHdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<VMwareCowHeader>(vmCHdrB);
|
||||||
Marshal.Copy(vmCHdrB, 0, headerPtr, Marshal.SizeOf(vmCHdr));
|
|
||||||
vmCHdr = (VMwareCowHeader)Marshal.PtrToStructure(headerPtr, typeof(VMwareCowHeader));
|
|
||||||
Marshal.FreeHGlobal(headerPtr);
|
|
||||||
|
|
||||||
return ddfMagicBytes.SequenceEqual(ddfMagic) || vmEHdr.magic == VMWARE_EXTENT_MAGIC ||
|
return ddfMagicBytes.SequenceEqual(ddfMagic) || vmEHdr.magic == VMWARE_EXTENT_MAGIC ||
|
||||||
vmCHdr.magic == VMWARE_COW_MAGIC;
|
vmCHdr.magic == VMWARE_COW_MAGIC;
|
||||||
|
|||||||
@@ -59,10 +59,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
stream.Seek(0, SeekOrigin.Begin);
|
stream.Seek(0, SeekOrigin.Begin);
|
||||||
byte[] vmEHdrB = new byte[Marshal.SizeOf(vmEHdr)];
|
byte[] vmEHdrB = new byte[Marshal.SizeOf(vmEHdr)];
|
||||||
stream.Read(vmEHdrB, 0, Marshal.SizeOf(vmEHdr));
|
stream.Read(vmEHdrB, 0, Marshal.SizeOf(vmEHdr));
|
||||||
IntPtr headerPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vmEHdr));
|
vmEHdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<VMwareExtentHeader>(vmEHdrB);
|
||||||
Marshal.Copy(vmEHdrB, 0, headerPtr, Marshal.SizeOf(vmEHdr));
|
|
||||||
vmEHdr = (VMwareExtentHeader)Marshal.PtrToStructure(headerPtr, typeof(VMwareExtentHeader));
|
|
||||||
Marshal.FreeHGlobal(headerPtr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(stream.Length > Marshal.SizeOf(vmCHdr))
|
if(stream.Length > Marshal.SizeOf(vmCHdr))
|
||||||
@@ -70,10 +67,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
stream.Seek(0, SeekOrigin.Begin);
|
stream.Seek(0, SeekOrigin.Begin);
|
||||||
byte[] vmCHdrB = new byte[Marshal.SizeOf(vmCHdr)];
|
byte[] vmCHdrB = new byte[Marshal.SizeOf(vmCHdr)];
|
||||||
stream.Read(vmCHdrB, 0, Marshal.SizeOf(vmCHdr));
|
stream.Read(vmCHdrB, 0, Marshal.SizeOf(vmCHdr));
|
||||||
IntPtr cowPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vmCHdr));
|
vmCHdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<VMwareCowHeader>(vmCHdrB);
|
||||||
Marshal.Copy(vmCHdrB, 0, cowPtr, Marshal.SizeOf(vmCHdr));
|
|
||||||
vmCHdr = (VMwareCowHeader)Marshal.PtrToStructure(cowPtr, typeof(VMwareCowHeader));
|
|
||||||
Marshal.FreeHGlobal(cowPtr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryStream ddfStream = new MemoryStream();
|
MemoryStream ddfStream = new MemoryStream();
|
||||||
@@ -142,10 +136,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
extentStream.Seek(0, SeekOrigin.Begin);
|
extentStream.Seek(0, SeekOrigin.Begin);
|
||||||
byte[] vmCHdrB = new byte[Marshal.SizeOf(extHdrCow)];
|
byte[] vmCHdrB = new byte[Marshal.SizeOf(extHdrCow)];
|
||||||
extentStream.Read(vmCHdrB, 0, Marshal.SizeOf(extHdrCow));
|
extentStream.Read(vmCHdrB, 0, Marshal.SizeOf(extHdrCow));
|
||||||
IntPtr cowPtr = Marshal.AllocHGlobal(Marshal.SizeOf(extHdrCow));
|
extHdrCow = Helpers.Marshal.ByteArrayToStructureLittleEndian<VMwareCowHeader>(vmCHdrB);
|
||||||
Marshal.Copy(vmCHdrB, 0, cowPtr, Marshal.SizeOf(extHdrCow));
|
|
||||||
extHdrCow = (VMwareCowHeader)Marshal.PtrToStructure(cowPtr, typeof(VMwareCowHeader));
|
|
||||||
Marshal.FreeHGlobal(cowPtr);
|
|
||||||
|
|
||||||
if(extHdrCow.magic != VMWARE_COW_MAGIC) break;
|
if(extHdrCow.magic != VMWARE_COW_MAGIC) break;
|
||||||
|
|
||||||
@@ -311,10 +302,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
VMwareExtentHeader extentHdr = new VMwareExtentHeader();
|
VMwareExtentHeader extentHdr = new VMwareExtentHeader();
|
||||||
byte[] extentHdrB = new byte[Marshal.SizeOf(extentHdr)];
|
byte[] extentHdrB = new byte[Marshal.SizeOf(extentHdr)];
|
||||||
extentStream.Read(extentHdrB, 0, Marshal.SizeOf(extentHdr));
|
extentStream.Read(extentHdrB, 0, Marshal.SizeOf(extentHdr));
|
||||||
IntPtr extentHdrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(extentHdr));
|
extentHdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<VMwareExtentHeader>(extentHdrB);
|
||||||
Marshal.Copy(extentHdrB, 0, extentHdrPtr, Marshal.SizeOf(extentHdr));
|
|
||||||
extentHdr = (VMwareExtentHeader)Marshal.PtrToStructure(extentHdrPtr, typeof(VMwareExtentHeader));
|
|
||||||
Marshal.FreeHGlobal(extentHdrPtr);
|
|
||||||
|
|
||||||
if(extentHdr.magic != VMWARE_EXTENT_MAGIC)
|
if(extentHdr.magic != VMWARE_EXTENT_MAGIC)
|
||||||
throw new Exception($"{extent.Filter} is not an VMware extent.");
|
throw new Exception($"{extent.Filter} is not an VMware extent.");
|
||||||
|
|||||||
@@ -55,9 +55,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
byte[] hdrB = new byte[Marshal.SizeOf(v98Hdr)];
|
byte[] hdrB = new byte[Marshal.SizeOf(v98Hdr)];
|
||||||
stream.Read(hdrB, 0, hdrB.Length);
|
stream.Read(hdrB, 0, hdrB.Length);
|
||||||
|
|
||||||
GCHandle handle = GCHandle.Alloc(hdrB, GCHandleType.Pinned);
|
v98Hdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<Virtual98Header>(hdrB);
|
||||||
v98Hdr = (Virtual98Header)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(Virtual98Header));
|
|
||||||
handle.Free();
|
|
||||||
|
|
||||||
if(!v98Hdr.signature.SequenceEqual(signature)) return false;
|
if(!v98Hdr.signature.SequenceEqual(signature)) return false;
|
||||||
|
|
||||||
|
|||||||
@@ -56,9 +56,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
byte[] hdrB = new byte[Marshal.SizeOf(v98Hdr)];
|
byte[] hdrB = new byte[Marshal.SizeOf(v98Hdr)];
|
||||||
stream.Read(hdrB, 0, hdrB.Length);
|
stream.Read(hdrB, 0, hdrB.Length);
|
||||||
|
|
||||||
GCHandle handle = GCHandle.Alloc(hdrB, GCHandleType.Pinned);
|
v98Hdr = Helpers.Marshal.ByteArrayToStructureLittleEndian<Virtual98Header>(hdrB);
|
||||||
v98Hdr = (Virtual98Header)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(Virtual98Header));
|
|
||||||
handle.Free();
|
|
||||||
|
|
||||||
imageInfo.MediaType = MediaType.GENERIC_HDD;
|
imageInfo.MediaType = MediaType.GENERIC_HDD;
|
||||||
|
|
||||||
|
|||||||
@@ -31,11 +31,10 @@
|
|||||||
// Copyright © 2011-2019 Natalia Portillo
|
// Copyright © 2011-2019 Natalia Portillo
|
||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using DiscImageChef.CommonTypes.Interfaces;
|
using DiscImageChef.CommonTypes.Interfaces;
|
||||||
|
using DiscImageChef.Helpers;
|
||||||
|
|
||||||
namespace DiscImageChef.DiscImages
|
namespace DiscImageChef.DiscImages
|
||||||
{
|
{
|
||||||
@@ -51,11 +50,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
byte[] header = new byte[32];
|
byte[] header = new byte[32];
|
||||||
stream.Read(header, 0, 32);
|
stream.Read(header, 0, 32);
|
||||||
|
|
||||||
IntPtr hdrPtr = Marshal.AllocHGlobal(32);
|
WCDiskImageFileHeader fheader = Marshal.ByteArrayToStructureLittleEndian<WCDiskImageFileHeader>(header);
|
||||||
Marshal.Copy(header, 0, hdrPtr, 32);
|
|
||||||
WCDiskImageFileHeader fheader =
|
|
||||||
(WCDiskImageFileHeader)Marshal.PtrToStructure(hdrPtr, typeof(WCDiskImageFileHeader));
|
|
||||||
Marshal.FreeHGlobal(hdrPtr);
|
|
||||||
|
|
||||||
/* check the signature */
|
/* check the signature */
|
||||||
if(Encoding.ASCII.GetString(fheader.signature).TrimEnd('\x00') != fileSignature) return false;
|
if(Encoding.ASCII.GetString(fheader.signature).TrimEnd('\x00') != fileSignature) return false;
|
||||||
|
|||||||
@@ -33,13 +33,13 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using DiscImageChef.Checksums;
|
using DiscImageChef.Checksums;
|
||||||
using DiscImageChef.CommonTypes;
|
using DiscImageChef.CommonTypes;
|
||||||
using DiscImageChef.CommonTypes.Enums;
|
using DiscImageChef.CommonTypes.Enums;
|
||||||
using DiscImageChef.CommonTypes.Interfaces;
|
using DiscImageChef.CommonTypes.Interfaces;
|
||||||
using DiscImageChef.Console;
|
using DiscImageChef.Console;
|
||||||
|
using DiscImageChef.Helpers;
|
||||||
|
|
||||||
namespace DiscImageChef.DiscImages
|
namespace DiscImageChef.DiscImages
|
||||||
{
|
{
|
||||||
@@ -54,11 +54,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
byte[] header = new byte[32];
|
byte[] header = new byte[32];
|
||||||
stream.Read(header, 0, 32);
|
stream.Read(header, 0, 32);
|
||||||
|
|
||||||
IntPtr hdrPtr = Marshal.AllocHGlobal(32);
|
WCDiskImageFileHeader fheader = Marshal.ByteArrayToStructureLittleEndian<WCDiskImageFileHeader>(header);
|
||||||
Marshal.Copy(header, 0, hdrPtr, 32);
|
|
||||||
WCDiskImageFileHeader fheader =
|
|
||||||
(WCDiskImageFileHeader)Marshal.PtrToStructure(hdrPtr, typeof(WCDiskImageFileHeader));
|
|
||||||
Marshal.FreeHGlobal(hdrPtr);
|
|
||||||
DicConsole.DebugWriteLine("d2f plugin",
|
DicConsole.DebugWriteLine("d2f plugin",
|
||||||
"Detected WC DISK IMAGE with {0} heads, {1} tracks and {2} sectors per track.",
|
"Detected WC DISK IMAGE with {0} heads, {1} tracks and {2} sectors per track.",
|
||||||
fheader.heads, fheader.cylinders, fheader.sectorsPerTrack);
|
fheader.heads, fheader.cylinders, fheader.sectorsPerTrack);
|
||||||
@@ -120,11 +116,8 @@ namespace DiscImageChef.DiscImages
|
|||||||
DicConsole.DebugWriteLine("d2f plugin", "Comment present, reading");
|
DicConsole.DebugWriteLine("d2f plugin", "Comment present, reading");
|
||||||
byte[] sheaderBuffer = new byte[6];
|
byte[] sheaderBuffer = new byte[6];
|
||||||
stream.Read(sheaderBuffer, 0, 6);
|
stream.Read(sheaderBuffer, 0, 6);
|
||||||
IntPtr sectPtr = Marshal.AllocHGlobal(6);
|
|
||||||
Marshal.Copy(sheaderBuffer, 0, sectPtr, 6);
|
|
||||||
WCDiskImageSectorHeader sheader =
|
WCDiskImageSectorHeader sheader =
|
||||||
(WCDiskImageSectorHeader)Marshal.PtrToStructure(sectPtr, typeof(WCDiskImageSectorHeader));
|
Marshal.ByteArrayToStructureLittleEndian<WCDiskImageSectorHeader>(sheaderBuffer);
|
||||||
Marshal.FreeHGlobal(sectPtr);
|
|
||||||
|
|
||||||
if(sheader.flag != SectorFlag.Comment)
|
if(sheader.flag != SectorFlag.Comment)
|
||||||
throw new InvalidDataException(string.Format("Invalid sector type '{0}' encountered",
|
throw new InvalidDataException(string.Format("Invalid sector type '{0}' encountered",
|
||||||
@@ -140,11 +133,8 @@ namespace DiscImageChef.DiscImages
|
|||||||
DicConsole.DebugWriteLine("d2f plugin", "Directory listing present, reading");
|
DicConsole.DebugWriteLine("d2f plugin", "Directory listing present, reading");
|
||||||
byte[] sheaderBuffer = new byte[6];
|
byte[] sheaderBuffer = new byte[6];
|
||||||
stream.Read(sheaderBuffer, 0, 6);
|
stream.Read(sheaderBuffer, 0, 6);
|
||||||
IntPtr sectPtr = Marshal.AllocHGlobal(6);
|
|
||||||
Marshal.Copy(sheaderBuffer, 0, sectPtr, 6);
|
|
||||||
WCDiskImageSectorHeader sheader =
|
WCDiskImageSectorHeader sheader =
|
||||||
(WCDiskImageSectorHeader)Marshal.PtrToStructure(sectPtr, typeof(WCDiskImageSectorHeader));
|
Marshal.ByteArrayToStructureLittleEndian<WCDiskImageSectorHeader>(sheaderBuffer);
|
||||||
Marshal.FreeHGlobal(sectPtr);
|
|
||||||
|
|
||||||
if(sheader.flag != SectorFlag.Directory)
|
if(sheader.flag != SectorFlag.Directory)
|
||||||
throw new InvalidDataException(string.Format("Invalid sector type '{0}' encountered",
|
throw new InvalidDataException(string.Format("Invalid sector type '{0}' encountered",
|
||||||
@@ -216,11 +206,8 @@ namespace DiscImageChef.DiscImages
|
|||||||
/* read the sector header */
|
/* read the sector header */
|
||||||
byte[] sheaderBuffer = new byte[6];
|
byte[] sheaderBuffer = new byte[6];
|
||||||
stream.Read(sheaderBuffer, 0, 6);
|
stream.Read(sheaderBuffer, 0, 6);
|
||||||
IntPtr sectPtr = Marshal.AllocHGlobal(6);
|
|
||||||
Marshal.Copy(sheaderBuffer, 0, sectPtr, 6);
|
|
||||||
WCDiskImageSectorHeader sheader =
|
WCDiskImageSectorHeader sheader =
|
||||||
(WCDiskImageSectorHeader)Marshal.PtrToStructure(sectPtr, typeof(WCDiskImageSectorHeader));
|
Marshal.ByteArrayToStructureLittleEndian<WCDiskImageSectorHeader>(sheaderBuffer);
|
||||||
Marshal.FreeHGlobal(sectPtr);
|
|
||||||
|
|
||||||
/* validate the sector header */
|
/* validate the sector header */
|
||||||
if(sheader.cylinder != cyl || sheader.head != head || sheader.sector != sect)
|
if(sheader.cylinder != cyl || sheader.head != head || sheader.sector != sect)
|
||||||
|
|||||||
Reference in New Issue
Block a user