2017-09-19 18:55:47 +01:00
|
|
|
|
// /***************************************************************************
|
|
|
|
|
|
// The Disc Image Chef
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : PartClone.cs
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Component : Disk image plugins.
|
2017-09-19 18:55:47 +01:00
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Manages partclone disk images.
|
2017-09-19 18:55:47 +01:00
|
|
|
|
//
|
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// This library is free software; you can redistribute it and/or modify
|
|
|
|
|
|
// it under the terms of the GNU Lesser General Public License as
|
|
|
|
|
|
// published by the Free Software Foundation; either version 2.1 of the
|
|
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
|
//
|
|
|
|
|
|
// This library is distributed in the hope that it will be useful, but
|
|
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
|
|
//
|
|
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
|
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Copyright © 2011-2018 Natalia Portillo
|
2017-09-19 18:55:47 +01:00
|
|
|
|
// ****************************************************************************/
|
2017-09-19 21:13:16 +01:00
|
|
|
|
|
2017-09-19 18:55:47 +01:00
|
|
|
|
using System;
|
2017-09-19 21:13:16 +01:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Linq;
|
2017-12-19 19:33:46 +00:00
|
|
|
|
using System.Runtime.InteropServices;
|
2017-09-19 21:13:16 +01:00
|
|
|
|
using DiscImageChef.CommonTypes;
|
|
|
|
|
|
using DiscImageChef.Console;
|
|
|
|
|
|
using DiscImageChef.Filters;
|
2017-09-21 19:09:27 +01:00
|
|
|
|
using Extents;
|
2018-01-28 20:29:46 +00:00
|
|
|
|
using Schemas;
|
2017-09-19 21:13:16 +01:00
|
|
|
|
|
2017-09-19 18:55:47 +01:00
|
|
|
|
namespace DiscImageChef.DiscImages
|
|
|
|
|
|
{
|
2017-12-26 06:05:12 +00:00
|
|
|
|
public class PartClone : IMediaImage
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
const int CRC_SIZE = 4;
|
|
|
|
|
|
|
2018-01-28 20:29:46 +00:00
|
|
|
|
const uint MAX_CACHE_SIZE = 16777216;
|
|
|
|
|
|
const uint MAX_CACHED_SECTORS = MAX_CACHE_SIZE / 512;
|
|
|
|
|
|
readonly byte[] biTmAgIc = {0x42, 0x69, 0x54, 0x6D, 0x41, 0x67, 0x49, 0x63};
|
|
|
|
|
|
readonly byte[] partCloneMagic =
|
2017-12-24 00:12:31 +00:00
|
|
|
|
{0x70, 0x61, 0x72, 0x74, 0x63, 0x6C, 0x6F, 0x6E, 0x65, 0x2D, 0x69, 0x6D, 0x61, 0x67, 0x65};
|
2017-12-19 20:33:03 +00:00
|
|
|
|
// The used block "bitmap" uses one byte per block
|
|
|
|
|
|
// TODO: Convert on-image bytemap to on-memory bitmap
|
|
|
|
|
|
byte[] byteMap;
|
2018-01-28 20:29:46 +00:00
|
|
|
|
long dataOff;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2018-01-28 20:29:46 +00:00
|
|
|
|
ExtentsULong extents;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
Dictionary<ulong, ulong> extentsOff;
|
2018-01-28 20:29:46 +00:00
|
|
|
|
ImageInfo imageInfo;
|
|
|
|
|
|
Stream imageStream;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
|
|
|
|
|
|
PartCloneHeader pHdr;
|
|
|
|
|
|
|
|
|
|
|
|
Dictionary<ulong, byte[]> sectorCache;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
|
|
public PartClone()
|
|
|
|
|
|
{
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo = new ImageInfo
|
2017-12-22 06:55:04 +00:00
|
|
|
|
{
|
2018-01-28 20:29:46 +00:00
|
|
|
|
ReadableSectorTags = new List<SectorTagType>(),
|
|
|
|
|
|
ReadableMediaTags = new List<MediaTagType>(),
|
|
|
|
|
|
HasPartitions = false,
|
|
|
|
|
|
HasSessions = false,
|
|
|
|
|
|
Application = "PartClone",
|
|
|
|
|
|
ApplicationVersion = null,
|
|
|
|
|
|
Creator = null,
|
|
|
|
|
|
Comments = null,
|
|
|
|
|
|
MediaManufacturer = null,
|
|
|
|
|
|
MediaModel = null,
|
|
|
|
|
|
MediaSerialNumber = null,
|
|
|
|
|
|
MediaBarcode = null,
|
|
|
|
|
|
MediaPartNumber = null,
|
|
|
|
|
|
MediaSequence = 0,
|
|
|
|
|
|
LastMediaSequence = 0,
|
|
|
|
|
|
DriveManufacturer = null,
|
|
|
|
|
|
DriveModel = null,
|
|
|
|
|
|
DriveSerialNumber = null,
|
2017-12-22 06:55:04 +00:00
|
|
|
|
DriveFirmwareRevision = null
|
|
|
|
|
|
};
|
2017-12-19 20:33:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-28 20:29:46 +00:00
|
|
|
|
public string Name => "PartClone disk image";
|
|
|
|
|
|
public Guid Id => new Guid("AB1D7518-B548-4099-A4E2-C29C53DDE0C3");
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public ImageInfo Info => imageInfo;
|
2017-12-26 02:51:10 +00:00
|
|
|
|
|
2017-12-28 19:56:36 +00:00
|
|
|
|
public string Format => "PartClone";
|
2017-12-26 06:05:12 +00:00
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public List<Partition> Partitions =>
|
2017-12-26 02:51:10 +00:00
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public List<Track> Tracks =>
|
2017-12-26 02:51:10 +00:00
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public List<Session> Sessions =>
|
2017-12-26 02:51:10 +00:00
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
|
2017-12-28 19:56:36 +00:00
|
|
|
|
public bool Identify(IFilter imageFilter)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
Stream stream = imageFilter.GetDataForkStream();
|
|
|
|
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
|
|
|
|
|
|
|
|
|
|
if(stream.Length < 512) return false;
|
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
|
byte[] pHdrB = new byte[Marshal.SizeOf(pHdr)];
|
|
|
|
|
|
stream.Read(pHdrB, 0, Marshal.SizeOf(pHdr));
|
2018-01-28 20:29:46 +00:00
|
|
|
|
pHdr = new PartCloneHeader();
|
2017-12-19 20:33:03 +00:00
|
|
|
|
IntPtr headerPtr = Marshal.AllocHGlobal(Marshal.SizeOf(pHdr));
|
2017-12-20 17:15:26 +00:00
|
|
|
|
Marshal.Copy(pHdrB, 0, headerPtr, Marshal.SizeOf(pHdr));
|
2017-12-19 20:33:03 +00:00
|
|
|
|
pHdr = (PartCloneHeader)Marshal.PtrToStructure(headerPtr, typeof(PartCloneHeader));
|
|
|
|
|
|
Marshal.FreeHGlobal(headerPtr);
|
|
|
|
|
|
|
|
|
|
|
|
if(stream.Position + (long)pHdr.totalBlocks > stream.Length) return false;
|
|
|
|
|
|
|
|
|
|
|
|
stream.Seek((long)pHdr.totalBlocks, SeekOrigin.Current);
|
|
|
|
|
|
|
|
|
|
|
|
byte[] bitmagic = new byte[8];
|
|
|
|
|
|
stream.Read(bitmagic, 0, 8);
|
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
|
return partCloneMagic.SequenceEqual(pHdr.magic) && biTmAgIc.SequenceEqual(bitmagic);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-28 19:56:36 +00:00
|
|
|
|
public bool Open(IFilter imageFilter)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
Stream stream = imageFilter.GetDataForkStream();
|
|
|
|
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
|
|
|
|
|
|
|
|
|
|
if(stream.Length < 512) return false;
|
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
|
byte[] pHdrB = new byte[Marshal.SizeOf(pHdr)];
|
|
|
|
|
|
stream.Read(pHdrB, 0, Marshal.SizeOf(pHdr));
|
2018-01-28 20:29:46 +00:00
|
|
|
|
pHdr = new PartCloneHeader();
|
2017-12-19 20:33:03 +00:00
|
|
|
|
IntPtr headerPtr = Marshal.AllocHGlobal(Marshal.SizeOf(pHdr));
|
2017-12-20 17:15:26 +00:00
|
|
|
|
Marshal.Copy(pHdrB, 0, headerPtr, Marshal.SizeOf(pHdr));
|
2017-12-19 20:33:03 +00:00
|
|
|
|
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.filesystem = {0}",
|
|
|
|
|
|
StringHandlers.CToString(pHdr.filesystem));
|
2018-01-28 20:29:46 +00:00
|
|
|
|
DicConsole.DebugWriteLine("PartClone plugin", "pHdr.version = {0}",
|
|
|
|
|
|
StringHandlers.CToString(pHdr.version));
|
|
|
|
|
|
DicConsole.DebugWriteLine("PartClone plugin", "pHdr.blockSize = {0}", pHdr.blockSize);
|
|
|
|
|
|
DicConsole.DebugWriteLine("PartClone plugin", "pHdr.deviceSize = {0}", pHdr.deviceSize);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
DicConsole.DebugWriteLine("PartClone plugin", "pHdr.totalBlocks = {0}", pHdr.totalBlocks);
|
2018-01-28 20:29:46 +00:00
|
|
|
|
DicConsole.DebugWriteLine("PartClone plugin", "pHdr.usedBlocks = {0}", pHdr.usedBlocks);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
|
|
byteMap = new byte[pHdr.totalBlocks];
|
|
|
|
|
|
DicConsole.DebugWriteLine("PartClone plugin", "Reading bytemap {0} bytes", byteMap.Length);
|
|
|
|
|
|
stream.Read(byteMap, 0, byteMap.Length);
|
|
|
|
|
|
|
|
|
|
|
|
byte[] bitmagic = new byte[8];
|
|
|
|
|
|
stream.Read(bitmagic, 0, 8);
|
|
|
|
|
|
|
|
|
|
|
|
DicConsole.DebugWriteLine("PartClone plugin", "pHdr.bitmagic = {0}", StringHandlers.CToString(bitmagic));
|
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
|
if(!biTmAgIc.SequenceEqual(bitmagic))
|
2017-12-19 20:33:03 +00:00
|
|
|
|
throw new ImageNotSupportedException("Could not find partclone BiTmAgIc, not continuing...");
|
|
|
|
|
|
|
|
|
|
|
|
dataOff = stream.Position;
|
|
|
|
|
|
DicConsole.DebugWriteLine("PartClone plugin", "pHdr.dataOff = {0}", dataOff);
|
|
|
|
|
|
|
|
|
|
|
|
DicConsole.DebugWriteLine("PartClone plugin", "Filling extents");
|
2018-01-28 20:29:46 +00:00
|
|
|
|
DateTime start = DateTime.Now;
|
|
|
|
|
|
extents = new ExtentsULong();
|
|
|
|
|
|
extentsOff = new Dictionary<ulong, ulong>();
|
|
|
|
|
|
bool current = byteMap[0] > 0;
|
|
|
|
|
|
ulong blockOff = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
ulong extentStart = 0;
|
|
|
|
|
|
|
|
|
|
|
|
for(ulong i = 1; i < pHdr.totalBlocks; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool next = byteMap[i] > 0;
|
|
|
|
|
|
|
|
|
|
|
|
// Flux
|
|
|
|
|
|
if(next != current)
|
|
|
|
|
|
if(next)
|
|
|
|
|
|
{
|
|
|
|
|
|
extentStart = i;
|
|
|
|
|
|
extentsOff.Add(i, ++blockOff);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
extents.Add(extentStart, i);
|
2017-12-22 06:55:04 +00:00
|
|
|
|
extentsOff.TryGetValue(extentStart, out _);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(next && current) blockOff++;
|
|
|
|
|
|
|
|
|
|
|
|
current = next;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DateTime end = DateTime.Now;
|
|
|
|
|
|
DicConsole.DebugWriteLine("PartClone plugin", "Took {0} seconds to fill extents",
|
|
|
|
|
|
(end - start).TotalSeconds);
|
|
|
|
|
|
|
|
|
|
|
|
sectorCache = new Dictionary<ulong, byte[]>();
|
|
|
|
|
|
|
2018-01-28 20:29:46 +00:00
|
|
|
|
imageInfo.CreationTime = imageFilter.GetCreationTime();
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.LastModificationTime = imageFilter.GetLastWriteTime();
|
2018-01-28 20:29:46 +00:00
|
|
|
|
imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename());
|
|
|
|
|
|
imageInfo.Sectors = pHdr.totalBlocks;
|
|
|
|
|
|
imageInfo.SectorSize = pHdr.blockSize;
|
|
|
|
|
|
imageInfo.XmlMediaType = XmlMediaType.BlockMedia;
|
|
|
|
|
|
imageInfo.MediaType = MediaType.GENERIC_HDD;
|
|
|
|
|
|
imageInfo.ImageSize = (ulong)(stream.Length - (4096 + 0x40 + (long)pHdr.totalBlocks));
|
|
|
|
|
|
imageStream = stream;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadSector(ulong sectorAddress)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
2017-12-26 06:05:12 +00:00
|
|
|
|
if(sectorAddress > imageInfo.Sectors - 1)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(sectorAddress),
|
2017-12-21 17:58:51 +00:00
|
|
|
|
$"Sector address {sectorAddress} not found");
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
|
|
if(byteMap[sectorAddress] == 0) return new byte[pHdr.blockSize];
|
|
|
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
|
if(sectorCache.TryGetValue(sectorAddress, out byte[] sector)) return sector;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
|
|
long imageOff = dataOff + (long)(BlockOffset(sectorAddress) * (pHdr.blockSize + CRC_SIZE));
|
|
|
|
|
|
|
|
|
|
|
|
sector = new byte[pHdr.blockSize];
|
|
|
|
|
|
imageStream.Seek(imageOff, SeekOrigin.Begin);
|
|
|
|
|
|
imageStream.Read(sector, 0, (int)pHdr.blockSize);
|
|
|
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
|
if(sectorCache.Count > MAX_CACHED_SECTORS) sectorCache.Clear();
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
|
|
sectorCache.Add(sectorAddress, sector);
|
|
|
|
|
|
|
|
|
|
|
|
return sector;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadSectors(ulong sectorAddress, uint length)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
2017-12-26 06:05:12 +00:00
|
|
|
|
if(sectorAddress > imageInfo.Sectors - 1)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(sectorAddress),
|
2017-12-21 17:58:51 +00:00
|
|
|
|
$"Sector address {sectorAddress} not found");
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
if(sectorAddress + length > imageInfo.Sectors)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available");
|
|
|
|
|
|
|
|
|
|
|
|
MemoryStream ms = new MemoryStream();
|
|
|
|
|
|
|
|
|
|
|
|
bool allEmpty = true;
|
2018-01-28 20:29:46 +00:00
|
|
|
|
for(uint i = 0; i < length; i++)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
if(byteMap[sectorAddress + i] != 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
allEmpty = false;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(allEmpty) return new byte[pHdr.blockSize * length];
|
|
|
|
|
|
|
|
|
|
|
|
for(uint i = 0; i < length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
byte[] sector = ReadSector(sectorAddress + i);
|
|
|
|
|
|
ms.Write(sector, 0, sector.Length);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return ms.ToArray();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadDiskTag(MediaTagType tag)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadSector(ulong sectorAddress, uint track)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadSectors(ulong sectorAddress, uint length, uint track)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadSectorLong(ulong sectorAddress)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadSectorLong(ulong sectorAddress, uint track)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadSectorsLong(ulong sectorAddress, uint length)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadSectorsLong(ulong sectorAddress, uint length, uint track)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public List<Track> GetSessionTracks(Session session)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public List<Track> GetSessionTracks(ushort session)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public bool? VerifySector(ulong sectorAddress)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public bool? VerifySector(ulong sectorAddress, uint track)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public bool? VerifySectors(ulong sectorAddress, uint length, out List<ulong> failingLbas,
|
2018-01-28 20:29:46 +00:00
|
|
|
|
out List<ulong> unknownLbas)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
|
failingLbas = new List<ulong>();
|
|
|
|
|
|
unknownLbas = new List<ulong>();
|
2017-12-26 06:05:12 +00:00
|
|
|
|
for(ulong i = 0; i < imageInfo.Sectors; i++) unknownLbas.Add(i);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List<ulong> failingLbas,
|
2018-01-28 20:29:46 +00:00
|
|
|
|
out List<ulong> unknownLbas)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: All blocks contain a CRC32 that's incompatible with current implementation. Need to check for compatibility.
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public bool? VerifyMediaImage()
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
2017-12-24 00:12:31 +00:00
|
|
|
|
|
2018-01-28 20:29:46 +00:00
|
|
|
|
public List<DumpHardwareType> DumpHardware => null;
|
|
|
|
|
|
public CICMMetadataType CicmMetadata => null;
|
|
|
|
|
|
|
|
|
|
|
|
ulong BlockOffset(ulong sectorAddress)
|
|
|
|
|
|
{
|
|
|
|
|
|
extents.GetStart(sectorAddress, out ulong extentStart);
|
|
|
|
|
|
extentsOff.TryGetValue(extentStart, out ulong extentStartingOffset);
|
|
|
|
|
|
return extentStartingOffset + (sectorAddress - extentStart);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// PartClone disk image header, little-endian
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
|
|
|
|
struct PartCloneHeader
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Magic, <see cref="PartClone.partCloneMagic" />
|
|
|
|
|
|
/// </summary>
|
2018-01-28 20:29:46 +00:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 15)]
|
|
|
|
|
|
public byte[] magic;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Source filesystem
|
|
|
|
|
|
/// </summary>
|
2018-01-28 20:29:46 +00:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 15)]
|
|
|
|
|
|
public byte[] filesystem;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Version
|
|
|
|
|
|
/// </summary>
|
2018-01-28 20:29:46 +00:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
|
|
|
|
|
public byte[] version;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Padding
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public ushort padding;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Block (sector) size
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public uint blockSize;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Size of device containing the cloned partition
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public ulong deviceSize;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Total blocks in cloned partition
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public ulong totalBlocks;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Used blocks in cloned partition
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public ulong usedBlocks;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Empty space
|
|
|
|
|
|
/// </summary>
|
2018-01-28 20:29:46 +00:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4096)]
|
|
|
|
|
|
public byte[] buffer;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|