2017-05-19 20:28:49 +01:00
|
|
|
// /***************************************************************************
|
2016-08-27 04:44:36 +01:00
|
|
|
// The Disc Image Chef
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Filename : VDI.cs
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
// Component : Disk image plugins.
|
2016-08-27 04:44:36 +01:00
|
|
|
//
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Manages VirtualBox disk images.
|
|
|
|
|
//
|
|
|
|
|
// --[ 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
|
2016-08-27 04:44:36 +01:00
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
2018-01-04 11:17:39 +00:00
|
|
|
using System.Linq;
|
2016-08-27 04:44:36 +01:00
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using DiscImageChef.CommonTypes;
|
|
|
|
|
using DiscImageChef.Console;
|
2016-09-05 17:37:31 +01:00
|
|
|
using DiscImageChef.Filters;
|
2018-01-28 20:29:46 +00:00
|
|
|
using Schemas;
|
2016-08-27 04:44:36 +01:00
|
|
|
|
|
|
|
|
namespace DiscImageChef.DiscImages
|
|
|
|
|
{
|
2018-01-04 11:16:00 +00:00
|
|
|
// TODO: Support version 0
|
|
|
|
|
// TODO: Support fixed images
|
|
|
|
|
// TODO: Support version 1.2 geometry
|
2018-01-04 11:17:39 +00:00
|
|
|
public class Vdi : IWritableImage
|
2016-08-27 04:44:36 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
const uint VDI_MAGIC = 0xBEDA107F;
|
|
|
|
|
const uint VDI_EMPTY = 0xFFFFFFFF;
|
2016-08-27 04:44:36 +01:00
|
|
|
|
2018-01-04 11:17:39 +00:00
|
|
|
const string ORACLE_VDI = "<<< Oracle VM VirtualBox Disk Image >>>\n";
|
|
|
|
|
const string QEMUVDI = "<<< QEMU VM Virtual Disk Image >>>\n";
|
|
|
|
|
const string SUN_OLD_VDI = "<<< Sun xVM VirtualBox Disk Image >>>\n";
|
|
|
|
|
const string SUN_VDI = "<<< Sun VirtualBox Disk Image >>>\n";
|
|
|
|
|
const string INNOTEK_VDI = "<<< innotek VirtualBox Disk Image >>>\n";
|
2017-12-20 17:15:26 +00:00
|
|
|
const string INNOTEK_OLD_VDI = "<<< InnoTek VirtualBox Disk Image >>>\n";
|
2018-01-04 11:17:39 +00:00
|
|
|
const string DIC_VDI = "<<< DiscImageChef VirtualBox Disk Image >>>\n";
|
2016-08-27 04:44:36 +01:00
|
|
|
|
2018-01-04 11:17:39 +00:00
|
|
|
const uint MAX_CACHE_SIZE = 16777216;
|
2017-12-24 00:12:31 +00:00
|
|
|
const uint MAX_CACHED_SECTORS = MAX_CACHE_SIZE / 512;
|
2018-01-04 11:17:39 +00:00
|
|
|
const uint DEFAULT_BLOCK_SIZE = 1048576;
|
|
|
|
|
uint currentWritingPosition;
|
|
|
|
|
uint[] ibm;
|
|
|
|
|
ImageInfo imageInfo;
|
|
|
|
|
Stream imageStream;
|
2016-08-27 04:44:36 +01:00
|
|
|
|
|
|
|
|
Dictionary<ulong, byte[]> sectorCache;
|
|
|
|
|
|
2018-01-04 11:17:39 +00:00
|
|
|
VdiHeader vHdr;
|
|
|
|
|
FileStream writingStream;
|
2016-08-27 04:44:36 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
public Vdi()
|
2016-08-27 04:44:36 +01:00
|
|
|
{
|
2017-12-26 06:05:12 +00:00
|
|
|
imageInfo = new ImageInfo
|
2017-12-22 06:55:04 +00:00
|
|
|
{
|
2018-01-04 11:17:39 +00:00
|
|
|
ReadableSectorTags = new List<SectorTagType>(),
|
|
|
|
|
ReadableMediaTags = new List<MediaTagType>(),
|
|
|
|
|
HasPartitions = false,
|
|
|
|
|
HasSessions = false,
|
|
|
|
|
Version = null,
|
|
|
|
|
Application = null,
|
|
|
|
|
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
|
|
|
|
|
};
|
2016-08-27 04:44:36 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public ImageInfo Info => imageInfo;
|
2017-12-26 02:51:10 +00:00
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public string Name => "VirtualBox Disk Image";
|
2018-01-04 11:17:39 +00:00
|
|
|
public Guid Id => new Guid("E314DE35-C103-48A3-AD36-990F68523C46");
|
2017-12-26 06:05:12 +00:00
|
|
|
|
2017-12-28 19:56:36 +00:00
|
|
|
public string Format => "VDI";
|
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)
|
2016-08-27 04:44:36 +01:00
|
|
|
{
|
2016-09-05 17:37:31 +01:00
|
|
|
Stream stream = imageFilter.GetDataForkStream();
|
2016-08-27 04:44:36 +01:00
|
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
if(stream.Length < 512) return false;
|
2016-08-27 04:44:36 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
byte[] vHdrB = new byte[Marshal.SizeOf(vHdr)];
|
|
|
|
|
stream.Read(vHdrB, 0, Marshal.SizeOf(vHdr));
|
2018-01-04 11:17:39 +00:00
|
|
|
vHdr = new VdiHeader();
|
2016-08-27 04:44:36 +01:00
|
|
|
IntPtr headerPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vHdr));
|
2017-12-20 17:15:26 +00:00
|
|
|
Marshal.Copy(vHdrB, 0, headerPtr, Marshal.SizeOf(vHdr));
|
|
|
|
|
vHdr = (VdiHeader)Marshal.PtrToStructure(headerPtr, typeof(VdiHeader));
|
2016-08-27 04:44:36 +01:00
|
|
|
Marshal.FreeHGlobal(headerPtr);
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
return vHdr.magic == VDI_MAGIC;
|
2016-08-27 04:44:36 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-28 19:56:36 +00:00
|
|
|
public bool Open(IFilter imageFilter)
|
2016-08-27 04:44:36 +01:00
|
|
|
{
|
2016-09-05 17:37:31 +01:00
|
|
|
Stream stream = imageFilter.GetDataForkStream();
|
2016-08-27 04:44:36 +01:00
|
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
if(stream.Length < 512) return false;
|
2016-08-27 04:44:36 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
byte[] vHdrB = new byte[Marshal.SizeOf(vHdr)];
|
|
|
|
|
stream.Read(vHdrB, 0, Marshal.SizeOf(vHdr));
|
2018-01-04 11:17:39 +00:00
|
|
|
vHdr = new VdiHeader();
|
2016-08-27 04:44:36 +01:00
|
|
|
IntPtr headerPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vHdr));
|
2017-12-20 17:15:26 +00:00
|
|
|
Marshal.Copy(vHdrB, 0, headerPtr, Marshal.SizeOf(vHdr));
|
|
|
|
|
vHdr = (VdiHeader)Marshal.PtrToStructure(headerPtr, typeof(VdiHeader));
|
2016-08-27 04:44:36 +01:00
|
|
|
Marshal.FreeHGlobal(headerPtr);
|
|
|
|
|
|
|
|
|
|
DicConsole.DebugWriteLine("VirtualBox plugin", "vHdr.creator = {0}", vHdr.creator);
|
2018-01-04 11:17:39 +00:00
|
|
|
DicConsole.DebugWriteLine("VirtualBox plugin", "vHdr.magic = {0}", vHdr.magic);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("VirtualBox plugin", "vHdr.version = {0}.{1}", vHdr.majorVersion,
|
|
|
|
|
vHdr.minorVersion);
|
2018-01-04 11:17:39 +00:00
|
|
|
DicConsole.DebugWriteLine("VirtualBox plugin", "vHdr.headerSize = {0}", vHdr.headerSize);
|
|
|
|
|
DicConsole.DebugWriteLine("VirtualBox plugin", "vHdr.imageType = {0}", vHdr.imageType);
|
|
|
|
|
DicConsole.DebugWriteLine("VirtualBox plugin", "vHdr.imageFlags = {0}", vHdr.imageFlags);
|
|
|
|
|
DicConsole.DebugWriteLine("VirtualBox plugin", "vHdr.description = {0}", vHdr.comments);
|
|
|
|
|
DicConsole.DebugWriteLine("VirtualBox plugin", "vHdr.offsetBlocks = {0}", vHdr.offsetBlocks);
|
|
|
|
|
DicConsole.DebugWriteLine("VirtualBox plugin", "vHdr.offsetData = {0}", vHdr.offsetData);
|
|
|
|
|
DicConsole.DebugWriteLine("VirtualBox plugin", "vHdr.cylinders = {0}", vHdr.cylinders);
|
|
|
|
|
DicConsole.DebugWriteLine("VirtualBox plugin", "vHdr.heads = {0}", vHdr.heads);
|
|
|
|
|
DicConsole.DebugWriteLine("VirtualBox plugin", "vHdr.spt = {0}", vHdr.spt);
|
|
|
|
|
DicConsole.DebugWriteLine("VirtualBox plugin", "vHdr.sectorSize = {0}", vHdr.sectorSize);
|
|
|
|
|
DicConsole.DebugWriteLine("VirtualBox plugin", "vHdr.size = {0}", vHdr.size);
|
|
|
|
|
DicConsole.DebugWriteLine("VirtualBox plugin", "vHdr.blockSize = {0}", vHdr.blockSize);
|
|
|
|
|
DicConsole.DebugWriteLine("VirtualBox plugin", "vHdr.blockExtraData = {0}", vHdr.blockExtraData);
|
|
|
|
|
DicConsole.DebugWriteLine("VirtualBox plugin", "vHdr.blocks = {0}", vHdr.blocks);
|
2016-08-27 04:44:36 +01:00
|
|
|
DicConsole.DebugWriteLine("VirtualBox plugin", "vHdr.allocatedBlocks = {0}", vHdr.allocatedBlocks);
|
2018-01-04 11:17:39 +00:00
|
|
|
DicConsole.DebugWriteLine("VirtualBox plugin", "vHdr.uuid = {0}", vHdr.uuid);
|
|
|
|
|
DicConsole.DebugWriteLine("VirtualBox plugin", "vHdr.snapshotUuid = {0}", vHdr.snapshotUuid);
|
|
|
|
|
DicConsole.DebugWriteLine("VirtualBox plugin", "vHdr.linkUuid = {0}", vHdr.linkUuid);
|
|
|
|
|
DicConsole.DebugWriteLine("VirtualBox plugin", "vHdr.parentUuid = {0}", vHdr.parentUuid);
|
2016-08-27 04:44:36 +01:00
|
|
|
|
2018-01-04 11:16:00 +00:00
|
|
|
if(vHdr.imageType != VdiImageType.Normal)
|
2018-01-04 11:17:39 +00:00
|
|
|
throw new
|
|
|
|
|
FeatureSupportedButNotImplementedImageException($"Support for image type {vHdr.imageType} not yet implemented");
|
|
|
|
|
|
2016-08-27 04:44:36 +01:00
|
|
|
DicConsole.DebugWriteLine("VirtualBox plugin", "Reading Image Block Map");
|
2017-12-19 20:33:03 +00:00
|
|
|
stream.Seek(vHdr.offsetBlocks, SeekOrigin.Begin);
|
2018-01-04 11:17:39 +00:00
|
|
|
ibm = new uint[vHdr.blocks];
|
2017-12-20 17:15:26 +00:00
|
|
|
byte[] ibmB = new byte[vHdr.blocks * 4];
|
|
|
|
|
stream.Read(ibmB, 0, ibmB.Length);
|
|
|
|
|
for(int i = 0; i < ibm.Length; i++) ibm[i] = BitConverter.ToUInt32(ibmB, i * 4);
|
2016-08-27 04:44:36 +01:00
|
|
|
|
|
|
|
|
sectorCache = new Dictionary<ulong, byte[]>();
|
|
|
|
|
|
2018-01-04 11:17:39 +00:00
|
|
|
imageInfo.CreationTime = imageFilter.GetCreationTime();
|
2017-12-26 06:05:12 +00:00
|
|
|
imageInfo.LastModificationTime = imageFilter.GetLastWriteTime();
|
2018-01-04 11:17:39 +00:00
|
|
|
imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename());
|
|
|
|
|
imageInfo.Sectors = vHdr.size / vHdr.sectorSize;
|
|
|
|
|
imageInfo.ImageSize = vHdr.size;
|
|
|
|
|
imageInfo.SectorSize = vHdr.sectorSize;
|
|
|
|
|
imageInfo.XmlMediaType = XmlMediaType.BlockMedia;
|
|
|
|
|
imageInfo.MediaType = MediaType.GENERIC_HDD;
|
|
|
|
|
imageInfo.Comments = vHdr.comments;
|
|
|
|
|
imageInfo.Version = $"{vHdr.majorVersion}.{vHdr.minorVersion}";
|
2016-08-27 04:44:36 +01:00
|
|
|
|
|
|
|
|
switch(vHdr.creator)
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case SUN_VDI:
|
2017-12-26 06:05:12 +00:00
|
|
|
imageInfo.Application = "Sun VirtualBox";
|
2016-08-27 04:44:36 +01:00
|
|
|
break;
|
2017-12-20 17:15:26 +00:00
|
|
|
case SUN_OLD_VDI:
|
2017-12-26 06:05:12 +00:00
|
|
|
imageInfo.Application = "Sun xVM";
|
2016-08-27 04:44:36 +01:00
|
|
|
break;
|
2017-12-20 17:15:26 +00:00
|
|
|
case ORACLE_VDI:
|
2017-12-26 06:05:12 +00:00
|
|
|
imageInfo.Application = "Oracle VirtualBox";
|
2016-08-27 04:44:36 +01:00
|
|
|
break;
|
|
|
|
|
case QEMUVDI:
|
2017-12-26 06:05:12 +00:00
|
|
|
imageInfo.Application = "QEMU";
|
2016-08-27 04:44:36 +01:00
|
|
|
break;
|
2017-12-20 17:15:26 +00:00
|
|
|
case INNOTEK_VDI:
|
|
|
|
|
case INNOTEK_OLD_VDI:
|
2017-12-26 06:05:12 +00:00
|
|
|
imageInfo.Application = "innotek VirtualBox";
|
2016-08-27 04:44:36 +01:00
|
|
|
break;
|
2018-01-04 11:16:00 +00:00
|
|
|
case DIC_VDI:
|
|
|
|
|
imageInfo.Application = "DiscImageChef";
|
|
|
|
|
break;
|
2016-08-27 04:44:36 +01:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2016-08-27 04:44:36 +01:00
|
|
|
imageStream = stream;
|
|
|
|
|
|
2018-01-04 11:17:39 +00:00
|
|
|
imageInfo.Cylinders = vHdr.cylinders;
|
|
|
|
|
imageInfo.Heads = vHdr.heads;
|
2017-12-26 06:05:12 +00:00
|
|
|
imageInfo.SectorsPerTrack = vHdr.spt;
|
2017-08-02 23:01:11 +01:00
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
return true;
|
2016-08-27 04:44:36 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public byte[] ReadSector(ulong sectorAddress)
|
2016-08-27 04:44:36 +01: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");
|
2016-08-27 04:44:36 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
if(sectorCache.TryGetValue(sectorAddress, out byte[] sector)) return sector;
|
2016-08-27 04:44:36 +01:00
|
|
|
|
2018-01-04 11:17:39 +00:00
|
|
|
ulong index = sectorAddress * vHdr.sectorSize / vHdr.blockSize;
|
2017-12-20 17:26:28 +00:00
|
|
|
ulong secOff = sectorAddress * vHdr.sectorSize % vHdr.blockSize;
|
2016-08-27 04:44:36 +01:00
|
|
|
|
2018-01-18 23:18:56 +00:00
|
|
|
uint ibmOff = ibm[index];
|
2016-08-27 04:44:36 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(ibmOff == VDI_EMPTY) return new byte[vHdr.sectorSize];
|
2016-08-27 04:44:36 +01:00
|
|
|
|
2018-01-04 11:17:39 +00:00
|
|
|
ulong imageOff = vHdr.offsetData + ibmOff * vHdr.blockSize;
|
2016-08-27 04:44:36 +01:00
|
|
|
|
|
|
|
|
byte[] cluster = new byte[vHdr.blockSize];
|
|
|
|
|
imageStream.Seek((long)imageOff, SeekOrigin.Begin);
|
|
|
|
|
imageStream.Read(cluster, 0, (int)vHdr.blockSize);
|
|
|
|
|
sector = new byte[vHdr.sectorSize];
|
|
|
|
|
Array.Copy(cluster, (int)secOff, sector, 0, vHdr.sectorSize);
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(sectorCache.Count > MAX_CACHED_SECTORS) sectorCache.Clear();
|
2016-08-27 04:44:36 +01:00
|
|
|
|
|
|
|
|
sectorCache.Add(sectorAddress, sector);
|
|
|
|
|
|
|
|
|
|
return sector;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public byte[] ReadSectors(ulong sectorAddress, uint length)
|
2016-08-27 04:44:36 +01: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");
|
2016-08-27 04:44:36 +01: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),
|
2017-12-26 06:05:12 +00:00
|
|
|
$"Requested more sectors ({sectorAddress} + {length}) than available ({imageInfo.Sectors})");
|
2016-08-27 04:44:36 +01:00
|
|
|
|
|
|
|
|
MemoryStream ms = new MemoryStream();
|
|
|
|
|
|
|
|
|
|
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)
|
2016-08-27 04:44:36 +01: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)
|
2016-08-27 04:44:36 +01:00
|
|
|
{
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public byte[] ReadDiskTag(MediaTagType tag)
|
2016-08-27 04:44:36 +01: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)
|
2016-08-27 04:44:36 +01: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)
|
2016-08-27 04:44:36 +01: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)
|
2016-08-27 04:44:36 +01: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)
|
2016-08-27 04:44:36 +01:00
|
|
|
{
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public byte[] ReadSectorLong(ulong sectorAddress)
|
2016-08-27 04:44:36 +01: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)
|
2016-08-27 04:44:36 +01: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)
|
2016-08-27 04:44:36 +01: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)
|
2016-08-27 04:44:36 +01:00
|
|
|
{
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public List<Track> GetSessionTracks(Session session)
|
2016-08-27 04:44:36 +01:00
|
|
|
{
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public List<Track> GetSessionTracks(ushort session)
|
2016-08-27 04:44:36 +01:00
|
|
|
{
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public bool? VerifySector(ulong sectorAddress)
|
2016-08-27 04:44:36 +01:00
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public bool? VerifySector(ulong sectorAddress, uint track)
|
2016-08-27 04:44:36 +01: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-04 11:17:39 +00:00
|
|
|
out List<ulong> unknownLbas)
|
2016-08-27 04:44:36 +01: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
|
|
|
|
2016-08-27 04:44:36 +01: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-04 11:17:39 +00:00
|
|
|
out List<ulong> unknownLbas)
|
2016-08-27 04:44:36 +01:00
|
|
|
{
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public bool? VerifyMediaImage()
|
2016-08-27 04:44:36 +01: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;
|
|
|
|
|
|
2018-01-04 11:17:39 +00:00
|
|
|
public IEnumerable<MediaTagType> SupportedMediaTags => new MediaTagType[] { };
|
|
|
|
|
public IEnumerable<SectorTagType> SupportedSectorTags => new SectorTagType[] { };
|
2018-01-18 23:18:56 +00:00
|
|
|
public IEnumerable<MediaType> SupportedMediaTypes =>
|
|
|
|
|
new[]
|
|
|
|
|
{
|
|
|
|
|
MediaType.Unknown, MediaType.GENERIC_HDD, MediaType.FlashDrive, MediaType.CompactFlash,
|
|
|
|
|
MediaType.CompactFlashType2, MediaType.PCCardTypeI, MediaType.PCCardTypeII, MediaType.PCCardTypeIII,
|
|
|
|
|
MediaType.PCCardTypeIV
|
|
|
|
|
};
|
2018-01-04 11:17:39 +00:00
|
|
|
// TODO: Add cluster size option
|
|
|
|
|
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
|
|
|
|
new (string name, Type type, string description)[] { };
|
|
|
|
|
public IEnumerable<string> KnownExtensions => new[] {".vdi"};
|
|
|
|
|
public bool IsWriting { get; private set; }
|
|
|
|
|
public string ErrorMessage { get; private set; }
|
|
|
|
|
|
|
|
|
|
public bool Create(string path, MediaType mediaType, Dictionary<string, string> options, ulong sectors,
|
|
|
|
|
uint sectorSize)
|
|
|
|
|
{
|
2018-01-17 14:59:05 +00:00
|
|
|
if(sectorSize != 512)
|
2018-01-04 11:17:39 +00:00
|
|
|
{
|
|
|
|
|
ErrorMessage = "Unsupported sector size";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!SupportedMediaTypes.Contains(mediaType))
|
|
|
|
|
{
|
|
|
|
|
ErrorMessage = $"Unsupport media format {mediaType}";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(sectors * sectorSize / DEFAULT_BLOCK_SIZE > uint.MaxValue)
|
|
|
|
|
{
|
|
|
|
|
ErrorMessage = "Too many sectors for selected cluster size";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
|
|
|
|
|
2018-01-18 23:18:56 +00:00
|
|
|
try { writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); }
|
2018-01-04 11:17:39 +00:00
|
|
|
catch(IOException e)
|
|
|
|
|
{
|
|
|
|
|
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint ibmEntries = (uint)(sectors * sectorSize / DEFAULT_BLOCK_SIZE);
|
|
|
|
|
if(sectors * sectorSize % DEFAULT_BLOCK_SIZE > 0) ibmEntries++;
|
|
|
|
|
|
|
|
|
|
uint headerSectors = 1 + ibmEntries * 4 / sectorSize;
|
|
|
|
|
if(ibmEntries * 4 % sectorSize != 0) headerSectors++;
|
|
|
|
|
ibm = new uint[ibmEntries];
|
|
|
|
|
currentWritingPosition = headerSectors * sectorSize;
|
|
|
|
|
|
|
|
|
|
vHdr = new VdiHeader
|
|
|
|
|
{
|
|
|
|
|
creator = DIC_VDI,
|
|
|
|
|
magic = VDI_MAGIC,
|
|
|
|
|
majorVersion = 1,
|
|
|
|
|
minorVersion = 1,
|
|
|
|
|
headerSize = Marshal.SizeOf(typeof(VdiHeader)) - 72,
|
|
|
|
|
imageType = VdiImageType.Normal,
|
|
|
|
|
offsetBlocks = sectorSize,
|
|
|
|
|
offsetData = currentWritingPosition,
|
|
|
|
|
sectorSize = sectorSize,
|
|
|
|
|
size = sectors * sectorSize,
|
|
|
|
|
blockSize = DEFAULT_BLOCK_SIZE,
|
|
|
|
|
blocks = ibmEntries,
|
|
|
|
|
uuid = Guid.NewGuid(),
|
|
|
|
|
snapshotUuid = Guid.NewGuid()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
for(uint i = 0; i < ibmEntries; i++) ibm[i] = VDI_EMPTY;
|
|
|
|
|
|
|
|
|
|
IsWriting = true;
|
|
|
|
|
ErrorMessage = null;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool WriteMediaTag(byte[] data, MediaTagType tag)
|
|
|
|
|
{
|
|
|
|
|
ErrorMessage = "Writing media tags is not supported.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool WriteSector(byte[] data, ulong sectorAddress)
|
|
|
|
|
{
|
|
|
|
|
if(!IsWriting)
|
|
|
|
|
{
|
|
|
|
|
ErrorMessage = "Tried to write on a non-writable image";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(data.Length != imageInfo.SectorSize)
|
|
|
|
|
{
|
|
|
|
|
ErrorMessage = "Incorrect data size";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(sectorAddress >= imageInfo.Sectors)
|
|
|
|
|
{
|
|
|
|
|
ErrorMessage = "Tried to write past image size";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Ignore empty sectors
|
|
|
|
|
if(ArrayHelpers.ArrayIsNullOrEmpty(data)) return true;
|
|
|
|
|
|
|
|
|
|
ulong index = sectorAddress * vHdr.sectorSize / vHdr.blockSize;
|
|
|
|
|
ulong secOff = sectorAddress * vHdr.sectorSize % vHdr.blockSize;
|
|
|
|
|
|
|
|
|
|
uint ibmOff = ibm[index];
|
|
|
|
|
|
|
|
|
|
if(ibmOff == VDI_EMPTY)
|
|
|
|
|
{
|
|
|
|
|
ibmOff = (currentWritingPosition - vHdr.offsetData) / vHdr.blockSize;
|
|
|
|
|
ibm[index] = ibmOff;
|
|
|
|
|
currentWritingPosition += vHdr.blockSize;
|
|
|
|
|
vHdr.allocatedBlocks++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ulong imageOff = vHdr.offsetData + ibmOff * vHdr.blockSize;
|
|
|
|
|
|
|
|
|
|
writingStream.Seek((long)imageOff, SeekOrigin.Begin);
|
|
|
|
|
writingStream.Seek((long)secOff, SeekOrigin.Current);
|
|
|
|
|
writingStream.Write(data, 0, data.Length);
|
|
|
|
|
|
|
|
|
|
ErrorMessage = "";
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO: This can be optimized
|
|
|
|
|
public bool WriteSectors(byte[] data, ulong sectorAddress, uint length)
|
|
|
|
|
{
|
|
|
|
|
if(!IsWriting)
|
|
|
|
|
{
|
|
|
|
|
ErrorMessage = "Tried to write on a non-writable image";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(data.Length % imageInfo.SectorSize != 0)
|
|
|
|
|
{
|
|
|
|
|
ErrorMessage = "Incorrect data size";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(sectorAddress + length > imageInfo.Sectors)
|
|
|
|
|
{
|
|
|
|
|
ErrorMessage = "Tried to write past image size";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Ignore empty sectors
|
|
|
|
|
if(ArrayHelpers.ArrayIsNullOrEmpty(data)) return true;
|
|
|
|
|
|
|
|
|
|
for(uint i = 0; i < length; i++)
|
|
|
|
|
{
|
|
|
|
|
byte[] tmp = new byte[imageInfo.SectorSize];
|
|
|
|
|
Array.Copy(data, i * imageInfo.SectorSize, tmp, 0, imageInfo.SectorSize);
|
|
|
|
|
if(!WriteSector(tmp, sectorAddress + i)) return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ErrorMessage = "";
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool WriteSectorLong(byte[] data, ulong sectorAddress)
|
|
|
|
|
{
|
|
|
|
|
ErrorMessage = "Writing sectors with tags is not supported.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length)
|
|
|
|
|
{
|
|
|
|
|
ErrorMessage = "Writing sectors with tags is not supported.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool SetTracks(List<Track> tracks)
|
|
|
|
|
{
|
|
|
|
|
ErrorMessage = "Unsupported feature";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Close()
|
|
|
|
|
{
|
|
|
|
|
if(!IsWriting)
|
|
|
|
|
{
|
|
|
|
|
ErrorMessage = "Image is not opened for writing";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!string.IsNullOrEmpty(imageInfo.Comments))
|
|
|
|
|
vHdr.comments = imageInfo.Comments.Length > 255
|
|
|
|
|
? imageInfo.Comments.Substring(0, 255)
|
|
|
|
|
: imageInfo.Comments;
|
|
|
|
|
|
2018-01-18 23:18:56 +00:00
|
|
|
if(vHdr.cylinders == 0)
|
|
|
|
|
{
|
|
|
|
|
vHdr.cylinders = (uint)(imageInfo.Sectors / 16 / 63);
|
|
|
|
|
vHdr.heads = 16;
|
|
|
|
|
vHdr.spt = 63;
|
|
|
|
|
|
|
|
|
|
while(vHdr.cylinders == 0)
|
|
|
|
|
{
|
|
|
|
|
vHdr.heads--;
|
|
|
|
|
|
|
|
|
|
if(vHdr.heads == 0)
|
|
|
|
|
{
|
|
|
|
|
vHdr.spt--;
|
|
|
|
|
vHdr.heads = 16;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vHdr.cylinders = (uint)(imageInfo.Sectors / vHdr.heads / vHdr.spt);
|
|
|
|
|
|
|
|
|
|
if(vHdr.cylinders == 0 && vHdr.heads == 0 && vHdr.spt == 0) break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-04 11:17:39 +00:00
|
|
|
byte[] hdr = new byte[Marshal.SizeOf(typeof(VdiHeader))];
|
|
|
|
|
IntPtr hdrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(VdiHeader)));
|
|
|
|
|
Marshal.StructureToPtr(vHdr, hdrPtr, true);
|
|
|
|
|
Marshal.Copy(hdrPtr, hdr, 0, hdr.Length);
|
|
|
|
|
Marshal.FreeHGlobal(hdrPtr);
|
|
|
|
|
|
|
|
|
|
writingStream.Seek(0, SeekOrigin.Begin);
|
|
|
|
|
writingStream.Write(hdr, 0, hdr.Length);
|
|
|
|
|
|
|
|
|
|
writingStream.Seek(vHdr.offsetBlocks, SeekOrigin.Begin);
|
|
|
|
|
for(long i = 0; i < ibm.LongLength; i++) writingStream.Write(BitConverter.GetBytes(ibm[i]), 0, 4);
|
|
|
|
|
|
2018-01-18 23:18:56 +00:00
|
|
|
writingStream.Flush();
|
|
|
|
|
writingStream.Close();
|
|
|
|
|
|
|
|
|
|
IsWriting = false;
|
|
|
|
|
ErrorMessage = "";
|
2018-01-04 11:17:39 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool SetMetadata(ImageInfo metadata)
|
|
|
|
|
{
|
|
|
|
|
imageInfo.Comments = metadata.Comments;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool SetGeometry(uint cylinders, uint heads, uint sectorsPerTrack)
|
|
|
|
|
{
|
|
|
|
|
vHdr.cylinders = cylinders;
|
|
|
|
|
vHdr.heads = heads;
|
|
|
|
|
vHdr.spt = sectorsPerTrack;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag)
|
|
|
|
|
{
|
|
|
|
|
ErrorMessage = "Writing sectors with tags is not supported.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag)
|
|
|
|
|
{
|
|
|
|
|
ErrorMessage = "Writing sectors with tags is not supported.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-28 20:29:46 +00:00
|
|
|
public bool SetDumpHardware(List<DumpHardwareType> dumpHardware)
|
|
|
|
|
{
|
|
|
|
|
// Not supported
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool SetCicmMetadata(CICMMetadataType metadata)
|
|
|
|
|
{
|
|
|
|
|
// Not supported
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
/// <summary>
|
|
|
|
|
/// VDI disk image header, little-endian
|
|
|
|
|
/// </summary>
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
|
|
|
struct VdiHeader
|
|
|
|
|
{
|
2018-01-04 11:17:39 +00:00
|
|
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
|
|
|
|
|
public string creator;
|
2017-12-24 00:12:31 +00:00
|
|
|
/// <summary>
|
|
|
|
|
/// Magic, <see cref="Vdi.VDI_MAGIC" />
|
|
|
|
|
/// </summary>
|
|
|
|
|
public uint magic;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Version
|
|
|
|
|
/// </summary>
|
2018-01-04 11:17:39 +00:00
|
|
|
public ushort majorVersion;
|
|
|
|
|
public ushort minorVersion;
|
|
|
|
|
public int headerSize;
|
|
|
|
|
public VdiImageType imageType;
|
2018-01-04 11:16:00 +00:00
|
|
|
public VdiImageFlags imageFlags;
|
2018-01-04 11:17:39 +00:00
|
|
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
|
|
|
|
public string comments;
|
|
|
|
|
public uint offsetBlocks;
|
|
|
|
|
public uint offsetData;
|
|
|
|
|
public uint cylinders;
|
|
|
|
|
public uint heads;
|
|
|
|
|
public uint spt;
|
|
|
|
|
public uint sectorSize;
|
|
|
|
|
public uint unused;
|
|
|
|
|
public ulong size;
|
|
|
|
|
public uint blockSize;
|
|
|
|
|
public uint blockExtraData;
|
|
|
|
|
public uint blocks;
|
|
|
|
|
public uint allocatedBlocks;
|
|
|
|
|
public Guid uuid;
|
|
|
|
|
public Guid snapshotUuid;
|
|
|
|
|
public Guid linkUuid;
|
|
|
|
|
public Guid parentUuid;
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-04 11:16:00 +00:00
|
|
|
enum VdiImageType : uint
|
|
|
|
|
{
|
2018-01-04 11:17:39 +00:00
|
|
|
/// <summary> Normal dynamically growing base image file.</summary>
|
2018-01-04 11:16:00 +00:00
|
|
|
Normal = 1,
|
2018-01-04 11:17:39 +00:00
|
|
|
/// <summary>Preallocated base image file of a fixed size.</summary>
|
2018-01-04 11:16:00 +00:00
|
|
|
Fixed,
|
2018-01-04 11:17:39 +00:00
|
|
|
/// <summary>Dynamically growing image file for undo/commit changes support.</summary>
|
2018-01-04 11:16:00 +00:00
|
|
|
Undo,
|
2018-01-04 11:17:39 +00:00
|
|
|
/// <summary>Dynamically growing image file for differencing support.</summary>
|
2018-01-04 11:16:00 +00:00
|
|
|
Differential,
|
|
|
|
|
|
2018-01-04 11:17:39 +00:00
|
|
|
/// <summary>First valid image type value.</summary>
|
2018-01-04 11:16:00 +00:00
|
|
|
First = Normal,
|
2018-01-04 11:17:39 +00:00
|
|
|
/// <summary>Last valid image type value.</summary>
|
2018-01-04 11:16:00 +00:00
|
|
|
Last = Differential
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enum VdiImageFlags : uint
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2018-01-04 11:17:39 +00:00
|
|
|
/// Fill new blocks with zeroes while expanding image file. Only valid for newly created images, never set
|
|
|
|
|
/// for opened existing images.
|
|
|
|
|
/// </summary>
|
2018-01-04 11:16:00 +00:00
|
|
|
ZeroExpand = 0x100
|
2017-12-24 00:12:31 +00:00
|
|
|
}
|
2016-08-27 04:44:36 +01:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
}
|