mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Override Marshal.SizeOf in Helpers and use it instead of System's.
This commit is contained in:
@@ -31,12 +31,12 @@
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.CommonTypes.Enums;
|
||||
using DiscImageChef.Decoders.ATA;
|
||||
using DiscImageChef.Decoders.SCSI;
|
||||
using DiscImageChef.Decoders.SecureDigital;
|
||||
using DiscImageChef.Helpers;
|
||||
using VendorString = DiscImageChef.Decoders.SecureDigital.VendorString;
|
||||
|
||||
namespace DiscImageChef.DiscImages
|
||||
@@ -231,7 +231,7 @@ namespace DiscImageChef.DiscImages
|
||||
if(ddtEntryCache.TryGetValue(sectorAddress, out ulong entry)) return entry;
|
||||
|
||||
long oldPosition = imageStream.Position;
|
||||
imageStream.Position = outMemoryDdtPosition + Marshal.SizeOf(typeof(DdtHeader));
|
||||
imageStream.Position = outMemoryDdtPosition + Marshal.SizeOf<DdtHeader>();
|
||||
imageStream.Position += (long)(sectorAddress * sizeof(ulong));
|
||||
byte[] temp = new byte[sizeof(ulong)];
|
||||
imageStream.Read(temp, 0, sizeof(ulong));
|
||||
@@ -254,7 +254,7 @@ namespace DiscImageChef.DiscImages
|
||||
}
|
||||
|
||||
long oldPosition = imageStream.Position;
|
||||
imageStream.Position = outMemoryDdtPosition + Marshal.SizeOf(typeof(DdtHeader));
|
||||
imageStream.Position = outMemoryDdtPosition + Marshal.SizeOf<DdtHeader>();
|
||||
imageStream.Position += (long)(sectorAddress * sizeof(ulong));
|
||||
imageStream.Write(BitConverter.GetBytes(pointer), 0, sizeof(ulong));
|
||||
imageStream.Position = oldPosition;
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using DiscImageChef.Helpers;
|
||||
|
||||
namespace DiscImageChef.DiscImages
|
||||
{
|
||||
@@ -43,12 +43,11 @@ namespace DiscImageChef.DiscImages
|
||||
imageStream = imageFilter.GetDataForkStream();
|
||||
imageStream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
if(imageStream.Length < Marshal.SizeOf(header)) return false;
|
||||
if(imageStream.Length < Marshal.SizeOf<DicHeader>()) return false;
|
||||
|
||||
header = new DicHeader();
|
||||
structureBytes = new byte[Marshal.SizeOf(header)];
|
||||
structureBytes = new byte[Marshal.SizeOf<DicHeader>()];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
header = Helpers.Marshal.ByteArrayToStructureLittleEndian<DicHeader>(structureBytes);
|
||||
header = Marshal.ByteArrayToStructureLittleEndian<DicHeader>(structureBytes);
|
||||
|
||||
return header.identifier == DIC_MAGIC && header.imageMajorVersion <= DICF_VERSION;
|
||||
}
|
||||
|
||||
@@ -61,20 +61,20 @@ namespace DiscImageChef.DiscImages
|
||||
new[]
|
||||
{
|
||||
("sectors_per_block", typeof(uint),
|
||||
"How many sectors to store per block (will be rounded to next power of two)", 4096U),
|
||||
"How many sectors to store per block (will be rounded to next power of two)", 4096U),
|
||||
("dictionary", typeof(uint), "Size, in bytes, of the LZMA dictionary", (uint)(1 << 25)),
|
||||
("max_ddt_size", typeof(uint),
|
||||
"Maximum size, in mebibytes, for in-memory DDT. If image needs a bigger one, it will be on-disk",
|
||||
256U),
|
||||
"Maximum size, in mebibytes, for in-memory DDT. If image needs a bigger one, it will be on-disk",
|
||||
256U),
|
||||
("md5", typeof(bool), "Calculate and store MD5 of image's user data", (object)false),
|
||||
("sha1", typeof(bool), "Calculate and store SHA1 of image's user data", (object)false),
|
||||
("sha256", typeof(bool), "Calculate and store SHA256 of image's user data", (object)false),
|
||||
("spamsum", typeof(bool), "Calculate and store SpamSum of image's user data", (object)false),
|
||||
("deduplicate", typeof(bool),
|
||||
"Store only unique sectors. This consumes more memory and is slower, but it's enabled by default",
|
||||
(object)true),
|
||||
"Store only unique sectors. This consumes more memory and is slower, but it's enabled by default",
|
||||
(object)true),
|
||||
("nocompress", typeof(bool),
|
||||
"Don't compress user data blocks. Other blocks will still be compressed", (object)false)
|
||||
"Don't compress user data blocks. Other blocks will still be compressed", (object)false)
|
||||
};
|
||||
public IEnumerable<string> KnownExtensions => new[] {".dicf"};
|
||||
public bool IsWriting { get; private set; }
|
||||
|
||||
@@ -34,7 +34,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
@@ -47,6 +46,7 @@ using DiscImageChef.CommonTypes.Exceptions;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using DiscImageChef.CommonTypes.Structs;
|
||||
using DiscImageChef.Console;
|
||||
using DiscImageChef.Helpers;
|
||||
using Schemas;
|
||||
using SharpCompress.Compressors.LZMA;
|
||||
using TrackType = DiscImageChef.CommonTypes.Enums.TrackType;
|
||||
@@ -60,12 +60,11 @@ namespace DiscImageChef.DiscImages
|
||||
imageStream = imageFilter.GetDataForkStream();
|
||||
imageStream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
if(imageStream.Length < Marshal.SizeOf(header)) return false;
|
||||
if(imageStream.Length < Marshal.SizeOf<DicHeader>()) return false;
|
||||
|
||||
header = new DicHeader();
|
||||
structureBytes = new byte[Marshal.SizeOf(header)];
|
||||
structureBytes = new byte[Marshal.SizeOf<DicHeader>()];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
header = Helpers.Marshal.ByteArrayToStructureLittleEndian<DicHeader>(structureBytes);
|
||||
header = Marshal.ByteArrayToStructureLittleEndian<DicHeader>(structureBytes);
|
||||
|
||||
if(header.imageMajorVersion > DICF_VERSION)
|
||||
throw new FeatureUnsupportedImageException($"Image version {header.imageMajorVersion} not recognized.");
|
||||
@@ -77,10 +76,9 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
// Read the index header
|
||||
imageStream.Position = (long)header.indexOffset;
|
||||
IndexHeader idxHeader = new IndexHeader();
|
||||
structureBytes = new byte[Marshal.SizeOf(idxHeader)];
|
||||
structureBytes = new byte[Marshal.SizeOf<IndexHeader>()];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
idxHeader = Helpers.Marshal.ByteArrayToStructureLittleEndian<IndexHeader>(structureBytes);
|
||||
IndexHeader idxHeader = Marshal.ByteArrayToStructureLittleEndian<IndexHeader>(structureBytes);
|
||||
|
||||
if(idxHeader.identifier != BlockType.Index) throw new FeatureUnsupportedImageException("Index not found!");
|
||||
|
||||
@@ -91,10 +89,9 @@ namespace DiscImageChef.DiscImages
|
||||
index = new List<IndexEntry>();
|
||||
for(ushort i = 0; i < idxHeader.entries; i++)
|
||||
{
|
||||
IndexEntry entry = new IndexEntry();
|
||||
structureBytes = new byte[Marshal.SizeOf(entry)];
|
||||
structureBytes = new byte[Marshal.SizeOf<IndexEntry>()];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
entry = Helpers.Marshal.ByteArrayToStructureLittleEndian<IndexEntry>(structureBytes);
|
||||
IndexEntry entry = 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);
|
||||
@@ -116,11 +113,9 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
imageStream.Position = (long)entry.offset;
|
||||
|
||||
BlockHeader blockHeader = new BlockHeader();
|
||||
structureBytes = new byte[Marshal.SizeOf(blockHeader)];
|
||||
structureBytes = new byte[Marshal.SizeOf<BlockHeader>()];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
blockHeader =
|
||||
Helpers.Marshal.ByteArrayToStructureLittleEndian<BlockHeader>(structureBytes);
|
||||
BlockHeader blockHeader = Marshal.ByteArrayToStructureLittleEndian<BlockHeader>(structureBytes);
|
||||
imageInfo.ImageSize += blockHeader.cmpLength;
|
||||
|
||||
// Unused, skip
|
||||
@@ -282,11 +277,9 @@ namespace DiscImageChef.DiscImages
|
||||
// Only user data deduplication tables are used right now
|
||||
if(entry.dataType == DataType.UserData)
|
||||
{
|
||||
DdtHeader ddtHeader = new DdtHeader();
|
||||
structureBytes = new byte[Marshal.SizeOf(ddtHeader)];
|
||||
structureBytes = new byte[Marshal.SizeOf<DdtHeader>()];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
ddtHeader =
|
||||
Helpers.Marshal.ByteArrayToStructureLittleEndian<DdtHeader>(structureBytes);
|
||||
DdtHeader ddtHeader = Marshal.ByteArrayToStructureLittleEndian<DdtHeader>(structureBytes);
|
||||
imageInfo.ImageSize += ddtHeader.cmpLength;
|
||||
|
||||
if(ddtHeader.identifier != BlockType.DeDuplicationTable) break;
|
||||
@@ -334,11 +327,9 @@ namespace DiscImageChef.DiscImages
|
||||
else if(entry.dataType == DataType.CdSectorPrefixCorrected ||
|
||||
entry.dataType == DataType.CdSectorSuffixCorrected)
|
||||
{
|
||||
DdtHeader ddtHeader = new DdtHeader();
|
||||
structureBytes = new byte[Marshal.SizeOf(ddtHeader)];
|
||||
structureBytes = new byte[Marshal.SizeOf<DdtHeader>()];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
ddtHeader =
|
||||
Helpers.Marshal.ByteArrayToStructureLittleEndian<DdtHeader>(structureBytes);
|
||||
DdtHeader ddtHeader = Marshal.ByteArrayToStructureLittleEndian<DdtHeader>(structureBytes);
|
||||
imageInfo.ImageSize += ddtHeader.cmpLength;
|
||||
|
||||
if(ddtHeader.identifier != BlockType.DeDuplicationTable) break;
|
||||
@@ -384,10 +375,9 @@ namespace DiscImageChef.DiscImages
|
||||
break;
|
||||
// Logical geometry block. It doesn't have a CRC coz, well, it's not so important
|
||||
case BlockType.GeometryBlock:
|
||||
geometryBlock = new GeometryBlock();
|
||||
structureBytes = new byte[Marshal.SizeOf(geometryBlock)];
|
||||
structureBytes = new byte[Marshal.SizeOf<GeometryBlock>()];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
geometryBlock = Helpers.Marshal.ByteArrayToStructureLittleEndian<GeometryBlock>(structureBytes);
|
||||
geometryBlock = Marshal.ByteArrayToStructureLittleEndian<GeometryBlock>(structureBytes);
|
||||
if(geometryBlock.identifier == BlockType.GeometryBlock)
|
||||
{
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
||||
@@ -402,10 +392,10 @@ namespace DiscImageChef.DiscImages
|
||||
break;
|
||||
// Metadata block
|
||||
case BlockType.MetadataBlock:
|
||||
MetadataBlock metadataBlock = new MetadataBlock();
|
||||
structureBytes = new byte[Marshal.SizeOf(metadataBlock)];
|
||||
structureBytes = new byte[Marshal.SizeOf<MetadataBlock>()];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
metadataBlock = Helpers.Marshal.ByteArrayToStructureLittleEndian<MetadataBlock>(structureBytes);
|
||||
MetadataBlock metadataBlock =
|
||||
Marshal.ByteArrayToStructureLittleEndian<MetadataBlock>(structureBytes);
|
||||
|
||||
if(metadataBlock.identifier != entry.blockType)
|
||||
{
|
||||
@@ -570,10 +560,10 @@ namespace DiscImageChef.DiscImages
|
||||
break;
|
||||
// Optical disc tracks block
|
||||
case BlockType.TracksBlock:
|
||||
TracksHeader tracksHeader = new TracksHeader();
|
||||
structureBytes = new byte[Marshal.SizeOf(tracksHeader)];
|
||||
structureBytes = new byte[Marshal.SizeOf<TracksHeader>()];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
tracksHeader = Helpers.Marshal.ByteArrayToStructureLittleEndian<TracksHeader>(structureBytes);
|
||||
TracksHeader tracksHeader =
|
||||
Marshal.ByteArrayToStructureLittleEndian<TracksHeader>(structureBytes);
|
||||
if(tracksHeader.identifier != BlockType.TracksBlock)
|
||||
{
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
||||
@@ -582,7 +572,7 @@ namespace DiscImageChef.DiscImages
|
||||
break;
|
||||
}
|
||||
|
||||
structureBytes = new byte[Marshal.SizeOf(typeof(TrackEntry)) * tracksHeader.entries];
|
||||
structureBytes = new byte[Marshal.SizeOf<TrackEntry>() * tracksHeader.entries];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
Crc64Context.Data(structureBytes, out byte[] trksCrc);
|
||||
if(BitConverter.ToUInt64(trksCrc, 0) != tracksHeader.crc64)
|
||||
@@ -604,10 +594,10 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
for(ushort i = 0; i < tracksHeader.entries; i++)
|
||||
{
|
||||
TrackEntry trackEntry = new TrackEntry();
|
||||
structureBytes = new byte[Marshal.SizeOf(trackEntry)];
|
||||
structureBytes = new byte[Marshal.SizeOf<TrackEntry>()];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
trackEntry = Helpers.Marshal.ByteArrayToStructureLittleEndian<TrackEntry>(structureBytes);
|
||||
TrackEntry trackEntry =
|
||||
Marshal.ByteArrayToStructureLittleEndian<TrackEntry>(structureBytes);
|
||||
|
||||
Tracks.Add(new Track
|
||||
{
|
||||
@@ -631,10 +621,10 @@ namespace DiscImageChef.DiscImages
|
||||
break;
|
||||
// CICM XML metadata block
|
||||
case BlockType.CicmBlock:
|
||||
CicmMetadataBlock cicmBlock = new CicmMetadataBlock();
|
||||
structureBytes = new byte[Marshal.SizeOf(cicmBlock)];
|
||||
structureBytes = new byte[Marshal.SizeOf<CicmMetadataBlock>()];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
cicmBlock = Helpers.Marshal.ByteArrayToStructureLittleEndian<CicmMetadataBlock>(structureBytes);
|
||||
CicmMetadataBlock cicmBlock =
|
||||
Marshal.ByteArrayToStructureLittleEndian<CicmMetadataBlock>(structureBytes);
|
||||
if(cicmBlock.identifier != BlockType.CicmBlock) break;
|
||||
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
||||
@@ -660,11 +650,10 @@ namespace DiscImageChef.DiscImages
|
||||
break;
|
||||
// Dump hardware block
|
||||
case BlockType.DumpHardwareBlock:
|
||||
DumpHardwareHeader dumpBlock = new DumpHardwareHeader();
|
||||
structureBytes = new byte[Marshal.SizeOf(dumpBlock)];
|
||||
structureBytes = new byte[Marshal.SizeOf<DumpHardwareHeader>()];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
dumpBlock = Helpers
|
||||
.Marshal.ByteArrayToStructureLittleEndian<DumpHardwareHeader>(structureBytes);
|
||||
DumpHardwareHeader dumpBlock =
|
||||
Marshal.ByteArrayToStructureLittleEndian<DumpHardwareHeader>(structureBytes);
|
||||
if(dumpBlock.identifier != BlockType.DumpHardwareBlock) break;
|
||||
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
||||
@@ -687,11 +676,10 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
for(ushort i = 0; i < dumpBlock.entries; i++)
|
||||
{
|
||||
DumpHardwareEntry dumpEntry = new DumpHardwareEntry();
|
||||
structureBytes = new byte[Marshal.SizeOf(dumpEntry)];
|
||||
structureBytes = new byte[Marshal.SizeOf<DumpHardwareEntry>()];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
dumpEntry =
|
||||
Helpers.Marshal.ByteArrayToStructureLittleEndian<DumpHardwareEntry>(structureBytes);
|
||||
DumpHardwareEntry dumpEntry =
|
||||
Marshal.ByteArrayToStructureLittleEndian<DumpHardwareEntry>(structureBytes);
|
||||
|
||||
DumpHardwareType dump = new DumpHardwareType
|
||||
{
|
||||
@@ -933,10 +921,9 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
// Read block header
|
||||
imageStream.Position = (long)blockOffset;
|
||||
blockHeader = new BlockHeader();
|
||||
structureBytes = new byte[Marshal.SizeOf(blockHeader)];
|
||||
structureBytes = new byte[Marshal.SizeOf<BlockHeader>()];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
blockHeader = Helpers.Marshal.ByteArrayToStructureLittleEndian<BlockHeader>(structureBytes);
|
||||
blockHeader = Marshal.ByteArrayToStructureLittleEndian<BlockHeader>(structureBytes);
|
||||
|
||||
// Decompress block
|
||||
switch(blockHeader.compression)
|
||||
|
||||
@@ -32,10 +32,10 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using DiscImageChef.Checksums;
|
||||
using DiscImageChef.CommonTypes.Enums;
|
||||
using DiscImageChef.Console;
|
||||
using DiscImageChef.Helpers;
|
||||
|
||||
namespace DiscImageChef.DiscImages
|
||||
{
|
||||
@@ -48,10 +48,9 @@ namespace DiscImageChef.DiscImages
|
||||
header.indexOffset);
|
||||
imageStream.Position = (long)header.indexOffset;
|
||||
|
||||
IndexHeader idxHeader = new IndexHeader();
|
||||
structureBytes = new byte[Marshal.SizeOf(idxHeader)];
|
||||
structureBytes = new byte[Marshal.SizeOf<IndexHeader>()];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
idxHeader = Helpers.Marshal.ByteArrayToStructureLittleEndian<IndexHeader>(structureBytes);
|
||||
IndexHeader idxHeader = Marshal.ByteArrayToStructureLittleEndian<IndexHeader>(structureBytes);
|
||||
|
||||
if(idxHeader.identifier != BlockType.Index)
|
||||
{
|
||||
@@ -62,7 +61,7 @@ namespace DiscImageChef.DiscImages
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Index at {0} contains {1} entries",
|
||||
header.indexOffset, idxHeader.entries);
|
||||
|
||||
structureBytes = new byte[Marshal.SizeOf(typeof(IndexEntry)) * idxHeader.entries];
|
||||
structureBytes = new byte[Marshal.SizeOf<IndexEntry>() * idxHeader.entries];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
Crc64Context.Data(structureBytes, out byte[] verifyCrc);
|
||||
|
||||
@@ -78,10 +77,9 @@ namespace DiscImageChef.DiscImages
|
||||
List<IndexEntry> vrIndex = new List<IndexEntry>();
|
||||
for(ushort i = 0; i < idxHeader.entries; i++)
|
||||
{
|
||||
IndexEntry entry = new IndexEntry();
|
||||
structureBytes = new byte[Marshal.SizeOf(entry)];
|
||||
structureBytes = new byte[Marshal.SizeOf<IndexEntry>()];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
entry = Helpers.Marshal.ByteArrayToStructureLittleEndian<IndexEntry>(structureBytes);
|
||||
IndexEntry entry = 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);
|
||||
@@ -101,10 +99,9 @@ namespace DiscImageChef.DiscImages
|
||||
switch(entry.blockType)
|
||||
{
|
||||
case BlockType.DataBlock:
|
||||
BlockHeader blockHeader = new BlockHeader();
|
||||
structureBytes = new byte[Marshal.SizeOf(blockHeader)];
|
||||
structureBytes = new byte[Marshal.SizeOf<BlockHeader>()];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
blockHeader = Helpers.Marshal.ByteArrayToStructureLittleEndian<BlockHeader>(structureBytes);
|
||||
BlockHeader blockHeader = Marshal.ByteArrayToStructureLittleEndian<BlockHeader>(structureBytes);
|
||||
|
||||
crcVerify = new Crc64Context();
|
||||
readBytes = 0;
|
||||
@@ -137,10 +134,9 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
break;
|
||||
case BlockType.DeDuplicationTable:
|
||||
DdtHeader ddtHeader = new DdtHeader();
|
||||
structureBytes = new byte[Marshal.SizeOf(ddtHeader)];
|
||||
structureBytes = new byte[Marshal.SizeOf<DdtHeader>()];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
ddtHeader = Helpers.Marshal.ByteArrayToStructureLittleEndian<DdtHeader>(structureBytes);
|
||||
DdtHeader ddtHeader = Marshal.ByteArrayToStructureLittleEndian<DdtHeader>(structureBytes);
|
||||
|
||||
crcVerify = new Crc64Context();
|
||||
readBytes = 0;
|
||||
@@ -173,16 +169,15 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
break;
|
||||
case BlockType.TracksBlock:
|
||||
TracksHeader trkHeader = new TracksHeader();
|
||||
structureBytes = new byte[Marshal.SizeOf(trkHeader)];
|
||||
structureBytes = new byte[Marshal.SizeOf<TracksHeader>()];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
trkHeader = Helpers.Marshal.ByteArrayToStructureLittleEndian<TracksHeader>(structureBytes);
|
||||
TracksHeader trkHeader = 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];
|
||||
structureBytes = new byte[Marshal.SizeOf<TrackEntry>() * trkHeader.entries];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
Crc64Context.Data(structureBytes, out verifyCrc);
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
@@ -48,6 +47,7 @@ using DiscImageChef.CommonTypes.Exceptions;
|
||||
using DiscImageChef.CommonTypes.Structs;
|
||||
using DiscImageChef.Console;
|
||||
using DiscImageChef.Decoders;
|
||||
using DiscImageChef.Helpers;
|
||||
using Schemas;
|
||||
using SharpCompress.Compressors.LZMA;
|
||||
using TrackType = DiscImageChef.CommonTypes.Enums.TrackType;
|
||||
@@ -207,12 +207,11 @@ namespace DiscImageChef.DiscImages
|
||||
}
|
||||
|
||||
// Check if appending to an existing image
|
||||
if(imageStream.Length > Marshal.SizeOf(typeof(DicHeader)))
|
||||
if(imageStream.Length > Marshal.SizeOf<DicHeader>())
|
||||
{
|
||||
header = new DicHeader();
|
||||
structureBytes = new byte[Marshal.SizeOf(header)];
|
||||
structureBytes = new byte[Marshal.SizeOf<DicHeader>()];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
header = Helpers.Marshal.ByteArrayToStructureLittleEndian<DicHeader>(structureBytes);
|
||||
header = Marshal.ByteArrayToStructureLittleEndian<DicHeader>(structureBytes);
|
||||
|
||||
if(header.identifier != DIC_MAGIC)
|
||||
{
|
||||
@@ -240,7 +239,7 @@ namespace DiscImageChef.DiscImages
|
||||
identifier = DIC_MAGIC, mediaType = mediaType, creationTime = DateTime.UtcNow.ToFileTimeUtc()
|
||||
};
|
||||
|
||||
imageStream.Write(new byte[Marshal.SizeOf(typeof(DicHeader))], 0, Marshal.SizeOf(typeof(DicHeader)));
|
||||
imageStream.Write(new byte[Marshal.SizeOf<DicHeader>()], 0, Marshal.SizeOf<DicHeader>());
|
||||
}
|
||||
|
||||
header.application = "DiscImageChef";
|
||||
@@ -261,10 +260,9 @@ namespace DiscImageChef.DiscImages
|
||||
spamsumProvider = null;
|
||||
|
||||
imageStream.Position = (long)header.indexOffset;
|
||||
IndexHeader idxHeader = new IndexHeader();
|
||||
structureBytes = new byte[Marshal.SizeOf(idxHeader)];
|
||||
structureBytes = new byte[Marshal.SizeOf<IndexHeader>()];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
idxHeader = Helpers.Marshal.ByteArrayToStructureLittleEndian<IndexHeader>(structureBytes);
|
||||
IndexHeader idxHeader = Marshal.ByteArrayToStructureLittleEndian<IndexHeader>(structureBytes);
|
||||
|
||||
if(idxHeader.identifier != BlockType.Index)
|
||||
{
|
||||
@@ -277,10 +275,9 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
for(ushort i = 0; i < idxHeader.entries; i++)
|
||||
{
|
||||
IndexEntry entry = new IndexEntry();
|
||||
structureBytes = new byte[Marshal.SizeOf(entry)];
|
||||
structureBytes = new byte[Marshal.SizeOf<IndexEntry>()];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
entry = Helpers.Marshal.ByteArrayToStructureLittleEndian<IndexEntry>(structureBytes);
|
||||
IndexEntry entry = 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);
|
||||
@@ -310,11 +307,10 @@ namespace DiscImageChef.DiscImages
|
||||
default: continue;
|
||||
}
|
||||
|
||||
BlockHeader blockHeader = new BlockHeader();
|
||||
structureBytes = new byte[Marshal.SizeOf(blockHeader)];
|
||||
structureBytes = new byte[Marshal.SizeOf<BlockHeader>()];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
blockHeader =
|
||||
Helpers.Marshal.ByteArrayToStructureLittleEndian<BlockHeader>(structureBytes);
|
||||
BlockHeader blockHeader =
|
||||
Marshal.ByteArrayToStructureLittleEndian<BlockHeader>(structureBytes);
|
||||
imageInfo.ImageSize += blockHeader.cmpLength;
|
||||
|
||||
if(blockHeader.identifier != entry.blockType)
|
||||
@@ -404,10 +400,10 @@ namespace DiscImageChef.DiscImages
|
||||
// Only user data deduplication tables are used right now
|
||||
if(entry.dataType == DataType.UserData)
|
||||
{
|
||||
DdtHeader ddtHeader = new DdtHeader();
|
||||
structureBytes = new byte[Marshal.SizeOf(ddtHeader)];
|
||||
structureBytes = new byte[Marshal.SizeOf<DdtHeader>()];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
ddtHeader = Helpers.Marshal.ByteArrayToStructureLittleEndian<DdtHeader>(structureBytes);
|
||||
DdtHeader ddtHeader =
|
||||
Marshal.ByteArrayToStructureLittleEndian<DdtHeader>(structureBytes);
|
||||
|
||||
if(ddtHeader.identifier != BlockType.DeDuplicationTable) break;
|
||||
|
||||
@@ -461,10 +457,10 @@ namespace DiscImageChef.DiscImages
|
||||
else if(entry.dataType == DataType.CdSectorPrefixCorrected ||
|
||||
entry.dataType == DataType.CdSectorSuffixCorrected)
|
||||
{
|
||||
DdtHeader ddtHeader = new DdtHeader();
|
||||
structureBytes = new byte[Marshal.SizeOf(ddtHeader)];
|
||||
structureBytes = new byte[Marshal.SizeOf<DdtHeader>()];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
ddtHeader = Helpers.Marshal.ByteArrayToStructureLittleEndian<DdtHeader>(structureBytes);
|
||||
DdtHeader ddtHeader =
|
||||
Marshal.ByteArrayToStructureLittleEndian<DdtHeader>(structureBytes);
|
||||
|
||||
if(ddtHeader.identifier != BlockType.DeDuplicationTable) break;
|
||||
|
||||
@@ -524,11 +520,10 @@ namespace DiscImageChef.DiscImages
|
||||
break;
|
||||
// CICM XML metadata block
|
||||
case BlockType.CicmBlock:
|
||||
CicmMetadataBlock cicmBlock = new CicmMetadataBlock();
|
||||
structureBytes = new byte[Marshal.SizeOf(cicmBlock)];
|
||||
structureBytes = new byte[Marshal.SizeOf<CicmMetadataBlock>()];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
cicmBlock =
|
||||
Helpers.Marshal.ByteArrayToStructureLittleEndian<CicmMetadataBlock>(structureBytes);
|
||||
CicmMetadataBlock cicmBlock =
|
||||
Marshal.ByteArrayToStructureLittleEndian<CicmMetadataBlock>(structureBytes);
|
||||
if(cicmBlock.identifier != BlockType.CicmBlock) break;
|
||||
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
||||
@@ -555,11 +550,10 @@ namespace DiscImageChef.DiscImages
|
||||
break;
|
||||
// Dump hardware block
|
||||
case BlockType.DumpHardwareBlock:
|
||||
DumpHardwareHeader dumpBlock = new DumpHardwareHeader();
|
||||
structureBytes = new byte[Marshal.SizeOf(dumpBlock)];
|
||||
structureBytes = new byte[Marshal.SizeOf<DumpHardwareHeader>()];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
dumpBlock =
|
||||
Helpers.Marshal.ByteArrayToStructureLittleEndian<DumpHardwareHeader>(structureBytes);
|
||||
DumpHardwareHeader dumpBlock =
|
||||
Marshal.ByteArrayToStructureLittleEndian<DumpHardwareHeader>(structureBytes);
|
||||
if(dumpBlock.identifier != BlockType.DumpHardwareBlock) break;
|
||||
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
||||
@@ -582,11 +576,10 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
for(ushort i = 0; i < dumpBlock.entries; i++)
|
||||
{
|
||||
DumpHardwareEntry dumpEntry = new DumpHardwareEntry();
|
||||
structureBytes = new byte[Marshal.SizeOf(dumpEntry)];
|
||||
structureBytes = new byte[Marshal.SizeOf<DumpHardwareEntry>()];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
dumpEntry =
|
||||
Helpers.Marshal.ByteArrayToStructureLittleEndian<DumpHardwareEntry>(structureBytes);
|
||||
DumpHardwareEntry dumpEntry =
|
||||
Marshal.ByteArrayToStructureLittleEndian<DumpHardwareEntry>(structureBytes);
|
||||
|
||||
DumpHardwareType dump = new DumpHardwareType
|
||||
{
|
||||
@@ -724,11 +717,12 @@ namespace DiscImageChef.DiscImages
|
||||
length = sectors * sizeof(ulong)
|
||||
};
|
||||
|
||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(ddtHeader));
|
||||
structureBytes = new byte[Marshal.SizeOf(ddtHeader)];
|
||||
Marshal.StructureToPtr(ddtHeader, structurePointer, true);
|
||||
Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
Marshal.FreeHGlobal(structurePointer);
|
||||
structurePointer = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<DdtHeader>());
|
||||
structureBytes = new byte[Marshal.SizeOf<DdtHeader>()];
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(ddtHeader, structurePointer, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0,
|
||||
structureBytes.Length);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer);
|
||||
imageStream.Write(structureBytes, 0, structureBytes.Length);
|
||||
structureBytes = null;
|
||||
|
||||
@@ -938,11 +932,11 @@ namespace DiscImageChef.DiscImages
|
||||
offset = (ulong)imageStream.Position
|
||||
});
|
||||
|
||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(currentBlockHeader));
|
||||
structureBytes = new byte[Marshal.SizeOf(currentBlockHeader)];
|
||||
Marshal.StructureToPtr(currentBlockHeader, structurePointer, true);
|
||||
Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
Marshal.FreeHGlobal(structurePointer);
|
||||
structurePointer = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<BlockHeader>());
|
||||
structureBytes = new byte[Marshal.SizeOf<BlockHeader>()];
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(currentBlockHeader, structurePointer, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer);
|
||||
imageStream.Write(structureBytes, 0, structureBytes.Length);
|
||||
structureBytes = null;
|
||||
if(currentBlockHeader.compression == CompressionType.Lzma)
|
||||
@@ -1530,11 +1524,11 @@ namespace DiscImageChef.DiscImages
|
||||
offset = (ulong)imageStream.Position
|
||||
});
|
||||
|
||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(currentBlockHeader));
|
||||
structureBytes = new byte[Marshal.SizeOf(currentBlockHeader)];
|
||||
Marshal.StructureToPtr(currentBlockHeader, structurePointer, true);
|
||||
Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
Marshal.FreeHGlobal(structurePointer);
|
||||
structurePointer = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<BlockHeader>());
|
||||
structureBytes = new byte[Marshal.SizeOf<BlockHeader>()];
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(currentBlockHeader, structurePointer, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer);
|
||||
imageStream.Write(structureBytes, 0, structureBytes.Length);
|
||||
structureBytes = null;
|
||||
if(currentBlockHeader.compression == CompressionType.Lzma)
|
||||
@@ -1602,11 +1596,11 @@ namespace DiscImageChef.DiscImages
|
||||
blockStream.Close();
|
||||
blockStream = null;
|
||||
|
||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(tagBlock));
|
||||
structureBytes = new byte[Marshal.SizeOf(tagBlock)];
|
||||
Marshal.StructureToPtr(tagBlock, structurePointer, true);
|
||||
Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
Marshal.FreeHGlobal(structurePointer);
|
||||
structurePointer = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<BlockHeader>());
|
||||
structureBytes = new byte[Marshal.SizeOf<BlockHeader>()];
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(tagBlock, structurePointer, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer);
|
||||
imageStream.Write(structureBytes, 0, structureBytes.Length);
|
||||
if(tagBlock.compression == CompressionType.Lzma)
|
||||
imageStream.Write(lzmaProperties, 0, lzmaProperties.Length);
|
||||
@@ -1630,11 +1624,11 @@ namespace DiscImageChef.DiscImages
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Writing geometry block to position {0}",
|
||||
idxEntry.offset);
|
||||
|
||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(geometryBlock));
|
||||
structureBytes = new byte[Marshal.SizeOf(geometryBlock)];
|
||||
Marshal.StructureToPtr(geometryBlock, structurePointer, true);
|
||||
Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
Marshal.FreeHGlobal(structurePointer);
|
||||
structurePointer = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<GeometryBlock>());
|
||||
structureBytes = new byte[Marshal.SizeOf<GeometryBlock>()];
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(geometryBlock, structurePointer, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer);
|
||||
imageStream.Write(structureBytes, 0, structureBytes.Length);
|
||||
|
||||
index.RemoveAll(t => t.blockType == BlockType.GeometryBlock && t.dataType == DataType.NoData);
|
||||
@@ -1686,11 +1680,13 @@ namespace DiscImageChef.DiscImages
|
||||
extents = (uint)dump.Extents.Length
|
||||
};
|
||||
|
||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(dumpEntry));
|
||||
structureBytes = new byte[Marshal.SizeOf(dumpEntry)];
|
||||
Marshal.StructureToPtr(dumpEntry, structurePointer, true);
|
||||
Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
Marshal.FreeHGlobal(structurePointer);
|
||||
structurePointer =
|
||||
System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<DumpHardwareEntry>());
|
||||
structureBytes = new byte[Marshal.SizeOf<DumpHardwareEntry>()];
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(dumpEntry, structurePointer, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0,
|
||||
structureBytes.Length);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer);
|
||||
dumpMs.Write(structureBytes, 0, structureBytes.Length);
|
||||
|
||||
if(dumpManufacturer != null)
|
||||
@@ -1767,11 +1763,12 @@ namespace DiscImageChef.DiscImages
|
||||
length = (uint)dumpMs.Length
|
||||
};
|
||||
|
||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(dumpBlock));
|
||||
structureBytes = new byte[Marshal.SizeOf(dumpBlock)];
|
||||
Marshal.StructureToPtr(dumpBlock, structurePointer, true);
|
||||
Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
Marshal.FreeHGlobal(structurePointer);
|
||||
structurePointer =
|
||||
System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<DumpHardwareHeader>());
|
||||
structureBytes = new byte[Marshal.SizeOf<DumpHardwareHeader>()];
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(dumpBlock, structurePointer, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer);
|
||||
imageStream.Write(structureBytes, 0, structureBytes.Length);
|
||||
imageStream.Write(dumpMs.ToArray(), 0, (int)dumpMs.Length);
|
||||
|
||||
@@ -1799,11 +1796,12 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
CicmMetadataBlock cicmBlock =
|
||||
new CicmMetadataBlock {identifier = BlockType.CicmBlock, length = (uint)cicmMs.Length};
|
||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(cicmBlock));
|
||||
structureBytes = new byte[Marshal.SizeOf(cicmBlock)];
|
||||
Marshal.StructureToPtr(cicmBlock, structurePointer, true);
|
||||
Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
Marshal.FreeHGlobal(structurePointer);
|
||||
structurePointer =
|
||||
System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<CicmMetadataBlock>());
|
||||
structureBytes = new byte[Marshal.SizeOf<CicmMetadataBlock>()];
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(cicmBlock, structurePointer, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer);
|
||||
imageStream.Write(structureBytes, 0, structureBytes.Length);
|
||||
imageStream.Write(cicmMs.ToArray(), 0, (int)cicmMs.Length);
|
||||
|
||||
@@ -1823,11 +1821,13 @@ namespace DiscImageChef.DiscImages
|
||||
byte[] md5 = md5Provider.Final();
|
||||
ChecksumEntry md5Entry =
|
||||
new ChecksumEntry {type = ChecksumAlgorithm.Md5, length = (uint)md5.Length};
|
||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(md5Entry));
|
||||
structureBytes = new byte[Marshal.SizeOf(md5Entry)];
|
||||
Marshal.StructureToPtr(md5Entry, structurePointer, true);
|
||||
Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
Marshal.FreeHGlobal(structurePointer);
|
||||
structurePointer =
|
||||
System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<ChecksumEntry>());
|
||||
structureBytes = new byte[Marshal.SizeOf<ChecksumEntry>()];
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(md5Entry, structurePointer, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0,
|
||||
structureBytes.Length);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer);
|
||||
chkMs.Write(structureBytes, 0, structureBytes.Length);
|
||||
chkMs.Write(md5, 0, md5.Length);
|
||||
chkHeader.entries++;
|
||||
@@ -1838,11 +1838,13 @@ namespace DiscImageChef.DiscImages
|
||||
byte[] sha1 = sha1Provider.Final();
|
||||
ChecksumEntry sha1Entry =
|
||||
new ChecksumEntry {type = ChecksumAlgorithm.Sha1, length = (uint)sha1.Length};
|
||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(sha1Entry));
|
||||
structureBytes = new byte[Marshal.SizeOf(sha1Entry)];
|
||||
Marshal.StructureToPtr(sha1Entry, structurePointer, true);
|
||||
Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
Marshal.FreeHGlobal(structurePointer);
|
||||
structurePointer =
|
||||
System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<ChecksumEntry>());
|
||||
structureBytes = new byte[Marshal.SizeOf<ChecksumEntry>()];
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(sha1Entry, structurePointer, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0,
|
||||
structureBytes.Length);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer);
|
||||
chkMs.Write(structureBytes, 0, structureBytes.Length);
|
||||
chkMs.Write(sha1, 0, sha1.Length);
|
||||
chkHeader.entries++;
|
||||
@@ -1853,11 +1855,13 @@ namespace DiscImageChef.DiscImages
|
||||
byte[] sha256 = sha256Provider.Final();
|
||||
ChecksumEntry sha256Entry =
|
||||
new ChecksumEntry {type = ChecksumAlgorithm.Sha256, length = (uint)sha256.Length};
|
||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(sha256Entry));
|
||||
structureBytes = new byte[Marshal.SizeOf(sha256Entry)];
|
||||
Marshal.StructureToPtr(sha256Entry, structurePointer, true);
|
||||
Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
Marshal.FreeHGlobal(structurePointer);
|
||||
structurePointer =
|
||||
System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<ChecksumEntry>());
|
||||
structureBytes = new byte[Marshal.SizeOf<ChecksumEntry>()];
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(sha256Entry, structurePointer, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0,
|
||||
structureBytes.Length);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer);
|
||||
chkMs.Write(structureBytes, 0, structureBytes.Length);
|
||||
chkMs.Write(sha256, 0, sha256.Length);
|
||||
chkHeader.entries++;
|
||||
@@ -1868,11 +1872,13 @@ namespace DiscImageChef.DiscImages
|
||||
byte[] spamsum = Encoding.ASCII.GetBytes(spamsumProvider.End());
|
||||
ChecksumEntry spamsumEntry =
|
||||
new ChecksumEntry {type = ChecksumAlgorithm.SpamSum, length = (uint)spamsum.Length};
|
||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(spamsumEntry));
|
||||
structureBytes = new byte[Marshal.SizeOf(spamsumEntry)];
|
||||
Marshal.StructureToPtr(spamsumEntry, structurePointer, true);
|
||||
Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
Marshal.FreeHGlobal(structurePointer);
|
||||
structurePointer =
|
||||
System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<ChecksumEntry>());
|
||||
structureBytes = new byte[Marshal.SizeOf<ChecksumEntry>()];
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(spamsumEntry, structurePointer, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0,
|
||||
structureBytes.Length);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer);
|
||||
chkMs.Write(structureBytes, 0, structureBytes.Length);
|
||||
chkMs.Write(spamsum, 0, spamsum.Length);
|
||||
chkHeader.entries++;
|
||||
@@ -1891,11 +1897,13 @@ namespace DiscImageChef.DiscImages
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Writing checksum block to position {0}",
|
||||
idxEntry.offset);
|
||||
|
||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(chkHeader));
|
||||
structureBytes = new byte[Marshal.SizeOf(chkHeader)];
|
||||
Marshal.StructureToPtr(chkHeader, structurePointer, true);
|
||||
Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
Marshal.FreeHGlobal(structurePointer);
|
||||
structurePointer =
|
||||
System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<ChecksumHeader>());
|
||||
structureBytes = new byte[Marshal.SizeOf<ChecksumHeader>()];
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(chkHeader, structurePointer, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0,
|
||||
structureBytes.Length);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer);
|
||||
imageStream.Write(structureBytes, 0, structureBytes.Length);
|
||||
imageStream.Write(chkMs.ToArray(), 0, (int)chkMs.Length);
|
||||
|
||||
@@ -1948,11 +1956,11 @@ namespace DiscImageChef.DiscImages
|
||||
cmpCrc64Context.Update(blockStream.ToArray());
|
||||
ddtHeader.cmpCrc64 = BitConverter.ToUInt64(cmpCrc64Context.Final(), 0);
|
||||
|
||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(ddtHeader));
|
||||
structureBytes = new byte[Marshal.SizeOf(ddtHeader)];
|
||||
Marshal.StructureToPtr(ddtHeader, structurePointer, true);
|
||||
Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
Marshal.FreeHGlobal(structurePointer);
|
||||
structurePointer = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<DdtHeader>());
|
||||
structureBytes = new byte[Marshal.SizeOf<DdtHeader>()];
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(ddtHeader, structurePointer, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer);
|
||||
imageStream.Write(structureBytes, 0, structureBytes.Length);
|
||||
structureBytes = null;
|
||||
imageStream.Write(lzmaProperties, 0, lzmaProperties.Length);
|
||||
@@ -2025,11 +2033,13 @@ namespace DiscImageChef.DiscImages
|
||||
(endCompress - startCompress).TotalSeconds);
|
||||
}
|
||||
|
||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(prefixBlock));
|
||||
structureBytes = new byte[Marshal.SizeOf(prefixBlock)];
|
||||
Marshal.StructureToPtr(prefixBlock, structurePointer, true);
|
||||
Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
Marshal.FreeHGlobal(structurePointer);
|
||||
structurePointer =
|
||||
System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<BlockHeader>());
|
||||
structureBytes = new byte[Marshal.SizeOf<BlockHeader>()];
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(prefixBlock, structurePointer, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0,
|
||||
structureBytes.Length);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer);
|
||||
imageStream.Write(structureBytes, 0, structureBytes.Length);
|
||||
if(prefixBlock.compression == CompressionType.Lzma)
|
||||
imageStream.Write(lzmaProperties, 0, lzmaProperties.Length);
|
||||
@@ -2091,11 +2101,13 @@ namespace DiscImageChef.DiscImages
|
||||
(endCompress - startCompress).TotalSeconds);
|
||||
}
|
||||
|
||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(prefixBlock));
|
||||
structureBytes = new byte[Marshal.SizeOf(prefixBlock)];
|
||||
Marshal.StructureToPtr(prefixBlock, structurePointer, true);
|
||||
Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
Marshal.FreeHGlobal(structurePointer);
|
||||
structurePointer =
|
||||
System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<BlockHeader>());
|
||||
structureBytes = new byte[Marshal.SizeOf<BlockHeader>()];
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(prefixBlock, structurePointer, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0,
|
||||
structureBytes.Length);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer);
|
||||
imageStream.Write(structureBytes, 0, structureBytes.Length);
|
||||
if(prefixBlock.compression == CompressionType.Lzma)
|
||||
imageStream.Write(lzmaProperties, 0, lzmaProperties.Length);
|
||||
@@ -2199,11 +2211,13 @@ namespace DiscImageChef.DiscImages
|
||||
cmpCrc64Context.Update(blockStream.ToArray());
|
||||
ddtHeader.cmpCrc64 = BitConverter.ToUInt64(cmpCrc64Context.Final(), 0);
|
||||
|
||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(ddtHeader));
|
||||
structureBytes = new byte[Marshal.SizeOf(ddtHeader)];
|
||||
Marshal.StructureToPtr(ddtHeader, structurePointer, true);
|
||||
Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
Marshal.FreeHGlobal(structurePointer);
|
||||
structurePointer =
|
||||
System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<DdtHeader>());
|
||||
structureBytes = new byte[Marshal.SizeOf<DdtHeader>()];
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(ddtHeader, structurePointer, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0,
|
||||
structureBytes.Length);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer);
|
||||
imageStream.Write(structureBytes, 0, structureBytes.Length);
|
||||
structureBytes = null;
|
||||
imageStream.Write(lzmaProperties, 0, lzmaProperties.Length);
|
||||
@@ -2255,11 +2269,13 @@ namespace DiscImageChef.DiscImages
|
||||
cmpCrc64Context.Update(blockStream.ToArray());
|
||||
ddtHeader.cmpCrc64 = BitConverter.ToUInt64(cmpCrc64Context.Final(), 0);
|
||||
|
||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(ddtHeader));
|
||||
structureBytes = new byte[Marshal.SizeOf(ddtHeader)];
|
||||
Marshal.StructureToPtr(ddtHeader, structurePointer, true);
|
||||
Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
Marshal.FreeHGlobal(structurePointer);
|
||||
structurePointer =
|
||||
System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<DdtHeader>());
|
||||
structureBytes = new byte[Marshal.SizeOf<DdtHeader>()];
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(ddtHeader, structurePointer, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0,
|
||||
structureBytes.Length);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer);
|
||||
imageStream.Write(structureBytes, 0, structureBytes.Length);
|
||||
structureBytes = null;
|
||||
imageStream.Write(lzmaProperties, 0, lzmaProperties.Length);
|
||||
@@ -2325,11 +2341,13 @@ namespace DiscImageChef.DiscImages
|
||||
(endCompress - startCompress).TotalSeconds);
|
||||
}
|
||||
|
||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(prefixBlock));
|
||||
structureBytes = new byte[Marshal.SizeOf(prefixBlock)];
|
||||
Marshal.StructureToPtr(prefixBlock, structurePointer, true);
|
||||
Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
Marshal.FreeHGlobal(structurePointer);
|
||||
structurePointer =
|
||||
System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<BlockHeader>());
|
||||
structureBytes = new byte[Marshal.SizeOf<BlockHeader>()];
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(prefixBlock, structurePointer, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0,
|
||||
structureBytes.Length);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer);
|
||||
imageStream.Write(structureBytes, 0, structureBytes.Length);
|
||||
if(prefixBlock.compression == CompressionType.Lzma)
|
||||
imageStream.Write(lzmaProperties, 0, lzmaProperties.Length);
|
||||
@@ -2395,11 +2413,13 @@ namespace DiscImageChef.DiscImages
|
||||
(endCompress - startCompress).TotalSeconds);
|
||||
}
|
||||
|
||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(suffixBlock));
|
||||
structureBytes = new byte[Marshal.SizeOf(suffixBlock)];
|
||||
Marshal.StructureToPtr(suffixBlock, structurePointer, true);
|
||||
Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
Marshal.FreeHGlobal(structurePointer);
|
||||
structurePointer =
|
||||
System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<BlockHeader>());
|
||||
structureBytes = new byte[Marshal.SizeOf<BlockHeader>()];
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(suffixBlock, structurePointer, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0,
|
||||
structureBytes.Length);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer);
|
||||
imageStream.Write(structureBytes, 0, structureBytes.Length);
|
||||
if(suffixBlock.compression == CompressionType.Lzma)
|
||||
imageStream.Write(lzmaProperties, 0, lzmaProperties.Length);
|
||||
@@ -2467,11 +2487,13 @@ namespace DiscImageChef.DiscImages
|
||||
(endCompress - startCompress).TotalSeconds);
|
||||
}
|
||||
|
||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(subheaderBlock));
|
||||
structureBytes = new byte[Marshal.SizeOf(subheaderBlock)];
|
||||
Marshal.StructureToPtr(subheaderBlock, structurePointer, true);
|
||||
Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
Marshal.FreeHGlobal(structurePointer);
|
||||
structurePointer =
|
||||
System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<BlockHeader>());
|
||||
structureBytes = new byte[Marshal.SizeOf<BlockHeader>()];
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(subheaderBlock, structurePointer, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0,
|
||||
structureBytes.Length);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer);
|
||||
imageStream.Write(structureBytes, 0, structureBytes.Length);
|
||||
if(subheaderBlock.compression == CompressionType.Lzma)
|
||||
imageStream.Write(lzmaProperties, 0, lzmaProperties.Length);
|
||||
@@ -2540,11 +2562,13 @@ namespace DiscImageChef.DiscImages
|
||||
(endCompress - startCompress).TotalSeconds);
|
||||
}
|
||||
|
||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(subchannelBlock));
|
||||
structureBytes = new byte[Marshal.SizeOf(subchannelBlock)];
|
||||
Marshal.StructureToPtr(subchannelBlock, structurePointer, true);
|
||||
Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
Marshal.FreeHGlobal(structurePointer);
|
||||
structurePointer =
|
||||
System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<BlockHeader>());
|
||||
structureBytes = new byte[Marshal.SizeOf<BlockHeader>()];
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(subchannelBlock, structurePointer, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0,
|
||||
structureBytes.Length);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer);
|
||||
imageStream.Write(structureBytes, 0, structureBytes.Length);
|
||||
if(subchannelBlock.compression == CompressionType.Lzma || subchannelBlock.compression ==
|
||||
CompressionType.LzmaClauniaSubchannelTransform)
|
||||
@@ -2588,11 +2612,13 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
foreach(TrackEntry entry in trackEntries)
|
||||
{
|
||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(entry));
|
||||
structureBytes = new byte[Marshal.SizeOf(entry)];
|
||||
Marshal.StructureToPtr(entry, structurePointer, true);
|
||||
Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
Marshal.FreeHGlobal(structurePointer);
|
||||
structurePointer =
|
||||
System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<TrackEntry>());
|
||||
structureBytes = new byte[Marshal.SizeOf<TrackEntry>()];
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(entry, structurePointer, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0,
|
||||
structureBytes.Length);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer);
|
||||
blockStream.Write(structureBytes, 0, structureBytes.Length);
|
||||
}
|
||||
|
||||
@@ -2616,11 +2642,13 @@ namespace DiscImageChef.DiscImages
|
||||
offset = (ulong)imageStream.Position
|
||||
});
|
||||
|
||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(trkHeader));
|
||||
structureBytes = new byte[Marshal.SizeOf(trkHeader)];
|
||||
Marshal.StructureToPtr(trkHeader, structurePointer, true);
|
||||
Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
Marshal.FreeHGlobal(structurePointer);
|
||||
structurePointer =
|
||||
System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<TracksHeader>());
|
||||
structureBytes = new byte[Marshal.SizeOf<TracksHeader>()];
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(trkHeader, structurePointer, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0,
|
||||
structureBytes.Length);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer);
|
||||
imageStream.Write(structureBytes, 0, structureBytes.Length);
|
||||
imageStream.Write(blockStream.ToArray(), 0, (int)blockStream.Length);
|
||||
blockStream.Close();
|
||||
@@ -2715,11 +2743,13 @@ namespace DiscImageChef.DiscImages
|
||||
subchannelBlock.compression = CompressionType.Lzma;
|
||||
}
|
||||
|
||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(subchannelBlock));
|
||||
structureBytes = new byte[Marshal.SizeOf(subchannelBlock)];
|
||||
Marshal.StructureToPtr(subchannelBlock, structurePointer, true);
|
||||
Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
Marshal.FreeHGlobal(structurePointer);
|
||||
structurePointer =
|
||||
System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<BlockHeader>());
|
||||
structureBytes = new byte[Marshal.SizeOf<BlockHeader>()];
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(subchannelBlock, structurePointer, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0,
|
||||
structureBytes.Length);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer);
|
||||
imageStream.Write(structureBytes, 0, structureBytes.Length);
|
||||
if(subchannelBlock.compression == CompressionType.Lzma)
|
||||
imageStream.Write(lzmaProperties, 0, lzmaProperties.Length);
|
||||
@@ -2739,7 +2769,7 @@ namespace DiscImageChef.DiscImages
|
||||
SetMetadataFromTags();
|
||||
MetadataBlock metadataBlock = new MetadataBlock();
|
||||
blockStream = new MemoryStream();
|
||||
blockStream.Write(new byte[Marshal.SizeOf(metadataBlock)], 0, Marshal.SizeOf(metadataBlock));
|
||||
blockStream.Write(new byte[Marshal.SizeOf<MetadataBlock>()], 0, Marshal.SizeOf<MetadataBlock>());
|
||||
byte[] tmpUtf16Le;
|
||||
|
||||
if(imageInfo.MediaSequence > 0 && imageInfo.LastMediaSequence > 0)
|
||||
@@ -2875,11 +2905,12 @@ namespace DiscImageChef.DiscImages
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Writing metadata to position {0}",
|
||||
imageStream.Position);
|
||||
metadataBlock.blockSize = (uint)blockStream.Length;
|
||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(metadataBlock));
|
||||
structureBytes = new byte[Marshal.SizeOf(metadataBlock)];
|
||||
Marshal.StructureToPtr(metadataBlock, structurePointer, true);
|
||||
Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
Marshal.FreeHGlobal(structurePointer);
|
||||
structurePointer =
|
||||
System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<MetadataBlock>());
|
||||
structureBytes = new byte[Marshal.SizeOf<MetadataBlock>()];
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(metadataBlock, structurePointer, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer);
|
||||
blockStream.Position = 0;
|
||||
blockStream.Write(structureBytes, 0, structureBytes.Length);
|
||||
index.RemoveAll(t => t.blockType == BlockType.MetadataBlock && t.dataType == DataType.NoData);
|
||||
@@ -2904,11 +2935,11 @@ namespace DiscImageChef.DiscImages
|
||||
// Write index to memory
|
||||
foreach(IndexEntry entry in index)
|
||||
{
|
||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(entry));
|
||||
structureBytes = new byte[Marshal.SizeOf(entry)];
|
||||
Marshal.StructureToPtr(entry, structurePointer, true);
|
||||
Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
Marshal.FreeHGlobal(structurePointer);
|
||||
structurePointer = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<IndexEntry>());
|
||||
structureBytes = new byte[Marshal.SizeOf<IndexEntry>()];
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(entry, structurePointer, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer);
|
||||
blockStream.Write(structureBytes, 0, structureBytes.Length);
|
||||
}
|
||||
|
||||
@@ -2922,11 +2953,11 @@ namespace DiscImageChef.DiscImages
|
||||
};
|
||||
|
||||
// Write index to disk
|
||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(idxHeader));
|
||||
structureBytes = new byte[Marshal.SizeOf(idxHeader)];
|
||||
Marshal.StructureToPtr(idxHeader, structurePointer, true);
|
||||
Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
Marshal.FreeHGlobal(structurePointer);
|
||||
structurePointer = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<IndexHeader>());
|
||||
structureBytes = new byte[Marshal.SizeOf<IndexHeader>()];
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(idxHeader, structurePointer, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer);
|
||||
imageStream.Write(structureBytes, 0, structureBytes.Length);
|
||||
imageStream.Write(blockStream.ToArray(), 0, (int)blockStream.Length);
|
||||
blockStream.Close();
|
||||
@@ -2935,11 +2966,11 @@ namespace DiscImageChef.DiscImages
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Writing header");
|
||||
header.lastWrittenTime = DateTime.UtcNow.ToFileTimeUtc();
|
||||
imageStream.Position = 0;
|
||||
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(header));
|
||||
structureBytes = new byte[Marshal.SizeOf(header)];
|
||||
Marshal.StructureToPtr(header, structurePointer, true);
|
||||
Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
Marshal.FreeHGlobal(structurePointer);
|
||||
structurePointer = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<DicHeader>());
|
||||
structureBytes = new byte[Marshal.SizeOf<DicHeader>()];
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(header, structurePointer, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length);
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer);
|
||||
imageStream.Write(structureBytes, 0, structureBytes.Length);
|
||||
|
||||
imageStream.Flush();
|
||||
|
||||
Reference in New Issue
Block a user