2018-07-23 23:25:43 +01:00
|
|
|
|
// /***************************************************************************
|
2020-02-27 12:31:25 +00:00
|
|
|
|
// Aaru Data Preservation Suite
|
2018-07-23 23:25:43 +01:00
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : Write.cs
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
|
|
|
|
|
// Component : Disk image plugins.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Writes VMware 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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2022-12-03 16:07:10 +00:00
|
|
|
|
// Copyright © 2011-2023 Natalia Portillo
|
2018-07-23 23:25:43 +01:00
|
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Aaru.CommonTypes;
|
2022-12-15 22:21:07 +00:00
|
|
|
|
using Aaru.CommonTypes.AaruMetadata;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Aaru.CommonTypes.Enums;
|
|
|
|
|
|
using Aaru.CommonTypes.Structs;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2023-10-06 01:16:28 +01:00
|
|
|
|
namespace Aaru.Images;
|
2022-11-15 15:58:43 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
public sealed partial class VMware
|
2018-07-23 23:25:43 +01:00
|
|
|
|
{
|
2023-10-03 23:34:59 +01:00
|
|
|
|
#region IWritableImage Members
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public bool Create(string path, MediaType mediaType, Dictionary<string, string> options, ulong sectors,
|
2023-10-03 23:34:59 +01:00
|
|
|
|
uint sectorSize)
|
2018-07-23 23:25:43 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(options != null)
|
2018-07-23 23:25:43 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(options.TryGetValue("adapter", out _adapterType))
|
2023-10-03 23:34:59 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
switch(_adapterType.ToLowerInvariant())
|
2018-07-23 23:25:43 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
case "ide":
|
|
|
|
|
|
case "lsilogic":
|
|
|
|
|
|
case "buslogic":
|
|
|
|
|
|
_adapterType = _adapterType.ToLowerInvariant();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case "legacyesx":
|
|
|
|
|
|
_adapterType = "legacyESX";
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
break;
|
|
|
|
|
|
default:
|
2022-11-29 02:10:37 +00:00
|
|
|
|
ErrorMessage = string.Format(Localization.Invalid_adapter_type_0, _adapterType);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2018-07-23 23:25:43 +01:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2023-10-03 23:34:59 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
else
|
|
|
|
|
|
_adapterType = "ide";
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(options.TryGetValue("hwversion", out string tmpValue))
|
|
|
|
|
|
{
|
|
|
|
|
|
if(!uint.TryParse(tmpValue, out _hwversion))
|
2018-07-23 23:25:43 +01:00
|
|
|
|
{
|
2022-11-29 02:10:37 +00:00
|
|
|
|
ErrorMessage = Localization.Invalid_value_for_hwversion_option;
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return false;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
2022-03-06 13:29:38 +00:00
|
|
|
|
_hwversion = 4;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(options.TryGetValue("split", out tmpValue))
|
2018-07-23 23:25:43 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(!bool.TryParse(tmpValue, out bool tmpBool))
|
|
|
|
|
|
{
|
2022-11-29 02:10:37 +00:00
|
|
|
|
ErrorMessage = Localization.Invalid_value_for_split_option;
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(tmpBool)
|
|
|
|
|
|
{
|
2022-11-29 02:10:37 +00:00
|
|
|
|
ErrorMessage = Localization.Splitted_images_not_yet_implemented;
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2018-07-23 23:25:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(options.TryGetValue("sparse", out tmpValue))
|
2018-07-23 23:25:43 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(!bool.TryParse(tmpValue, out bool tmpBool))
|
|
|
|
|
|
{
|
2022-11-29 02:10:37 +00:00
|
|
|
|
ErrorMessage = Localization.Invalid_value_for_sparse_option;
|
2020-07-22 13:20:25 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(tmpBool)
|
|
|
|
|
|
{
|
2022-11-29 02:10:37 +00:00
|
|
|
|
ErrorMessage = Localization.Sparse_images_not_yet_implemented;
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2018-07-23 23:25:43 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
_adapterType = "ide";
|
|
|
|
|
|
_hwversion = 4;
|
|
|
|
|
|
}
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(sectorSize != 512)
|
|
|
|
|
|
{
|
2022-11-29 02:10:37 +00:00
|
|
|
|
ErrorMessage = Localization.Unsupported_sector_size;
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return false;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(!SupportedMediaTypes.Contains(mediaType))
|
2018-07-23 23:25:43 +01:00
|
|
|
|
{
|
2022-11-29 02:10:37 +00:00
|
|
|
|
ErrorMessage = string.Format(Localization.Unsupported_media_format_0, mediaType);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2018-07-23 23:25:43 +01:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
_imageInfo = new ImageInfo
|
2018-07-23 23:25:43 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
MediaType = mediaType,
|
|
|
|
|
|
SectorSize = sectorSize,
|
|
|
|
|
|
Sectors = sectors
|
|
|
|
|
|
};
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
try
|
|
|
|
|
|
{
|
2022-03-07 07:36:44 +00:00
|
|
|
|
_writingBaseName = Path.Combine(Path.GetDirectoryName(path) ?? "", Path.GetFileNameWithoutExtension(path));
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
_descriptorStream = new StreamWriter(path, false, Encoding.ASCII);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
// TODO: Support split
|
|
|
|
|
|
_writingStream = new FileStream(_writingBaseName + "-flat.vmdk", FileMode.OpenOrCreate,
|
|
|
|
|
|
FileAccess.ReadWrite, FileShare.None);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch(IOException e)
|
|
|
|
|
|
{
|
2022-11-29 02:10:37 +00:00
|
|
|
|
ErrorMessage = string.Format(Localization.Could_not_create_new_image_file_exception_0, e.Message);
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
IsWriting = true;
|
|
|
|
|
|
ErrorMessage = null;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return true;
|
|
|
|
|
|
}
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public bool WriteMediaTag(byte[] data, MediaTagType tag)
|
|
|
|
|
|
{
|
2022-11-29 02:10:37 +00:00
|
|
|
|
ErrorMessage = Localization.Writing_media_tags_is_not_supported;
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public bool WriteSector(byte[] data, ulong sectorAddress)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(!IsWriting)
|
|
|
|
|
|
{
|
2022-11-29 02:10:37 +00:00
|
|
|
|
ErrorMessage = Localization.Tried_to_write_on_a_non_writable_image;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
return false;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(data.Length != 512)
|
2018-07-23 23:25:43 +01:00
|
|
|
|
{
|
2022-11-29 02:10:37 +00:00
|
|
|
|
ErrorMessage = Localization.Incorrect_data_size;
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(sectorAddress >= _imageInfo.Sectors)
|
|
|
|
|
|
{
|
2022-11-29 02:10:37 +00:00
|
|
|
|
ErrorMessage = Localization.Tried_to_write_past_image_size;
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
_writingStream.Seek((long)(sectorAddress * 512), SeekOrigin.Begin);
|
|
|
|
|
|
_writingStream.Write(data, 0, data.Length);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
ErrorMessage = "";
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return true;
|
|
|
|
|
|
}
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
// TODO: Implement sparse and split
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public bool WriteSectors(byte[] data, ulong sectorAddress, uint length)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(!IsWriting)
|
|
|
|
|
|
{
|
2022-11-29 02:10:37 +00:00
|
|
|
|
ErrorMessage = Localization.Tried_to_write_on_a_non_writable_image;
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return false;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(data.Length % 512 != 0)
|
2018-07-23 23:25:43 +01:00
|
|
|
|
{
|
2022-11-29 02:10:37 +00:00
|
|
|
|
ErrorMessage = Localization.Incorrect_data_size;
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2018-07-23 23:25:43 +01:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(sectorAddress + length > _imageInfo.Sectors)
|
2018-07-23 23:25:43 +01:00
|
|
|
|
{
|
2022-11-29 02:10:37 +00:00
|
|
|
|
ErrorMessage = Localization.Tried_to_write_past_image_size;
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2018-07-23 23:25:43 +01:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
_writingStream.Seek((long)(sectorAddress * 512), SeekOrigin.Begin);
|
|
|
|
|
|
_writingStream.Write(data, 0, data.Length);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
ErrorMessage = "";
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return true;
|
|
|
|
|
|
}
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public bool WriteSectorLong(byte[] data, ulong sectorAddress)
|
|
|
|
|
|
{
|
2022-11-29 02:10:37 +00:00
|
|
|
|
ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length)
|
|
|
|
|
|
{
|
2022-11-29 02:10:37 +00:00
|
|
|
|
ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
// TODO: Implement sparse and split
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public bool Close()
|
|
|
|
|
|
{
|
|
|
|
|
|
if(!IsWriting)
|
|
|
|
|
|
{
|
2022-11-29 02:10:37 +00:00
|
|
|
|
ErrorMessage = Localization.Image_is_not_opened_for_writing;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return false;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
_writingStream.Flush();
|
|
|
|
|
|
_writingStream.Close();
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(_imageInfo.Cylinders == 0)
|
2018-07-23 23:25:43 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
_imageInfo.Cylinders = (uint)(_imageInfo.Sectors / 16 / 63);
|
|
|
|
|
|
_imageInfo.Heads = 16;
|
|
|
|
|
|
_imageInfo.SectorsPerTrack = 63;
|
|
|
|
|
|
|
|
|
|
|
|
while(_imageInfo.Cylinders == 0)
|
2018-07-23 23:25:43 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
_imageInfo.Heads--;
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(_imageInfo.Heads == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
_imageInfo.SectorsPerTrack--;
|
|
|
|
|
|
_imageInfo.Heads = 16;
|
|
|
|
|
|
}
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
_imageInfo.Cylinders = (uint)(_imageInfo.Sectors / _imageInfo.Heads / _imageInfo.SectorsPerTrack);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2023-10-04 17:34:40 +01:00
|
|
|
|
if(_imageInfo.Cylinders == 0 && _imageInfo is { Heads: 0, SectorsPerTrack: 0 })
|
2022-03-06 13:29:38 +00:00
|
|
|
|
break;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
_descriptorStream.WriteLine("# Disk DescriptorFile");
|
|
|
|
|
|
_descriptorStream.WriteLine("version=1");
|
|
|
|
|
|
_descriptorStream.WriteLine($"CID={new Random().Next(int.MinValue, int.MaxValue):x8}");
|
|
|
|
|
|
_descriptorStream.WriteLine("parentCID=ffffffff");
|
|
|
|
|
|
_descriptorStream.WriteLine("createType=\"monolithicFlat\"");
|
|
|
|
|
|
_descriptorStream.WriteLine();
|
|
|
|
|
|
_descriptorStream.WriteLine("# Extent description");
|
|
|
|
|
|
_descriptorStream.WriteLine($"RW {_imageInfo.Sectors} FLAT \"{_writingBaseName + "-flat.vmdk"}\" 0");
|
|
|
|
|
|
_descriptorStream.WriteLine();
|
|
|
|
|
|
_descriptorStream.WriteLine("# The Disk Data Base");
|
|
|
|
|
|
_descriptorStream.WriteLine("#DDB");
|
|
|
|
|
|
_descriptorStream.WriteLine();
|
|
|
|
|
|
_descriptorStream.WriteLine($"ddb.virtualHWVersion = \"{_hwversion}\"");
|
|
|
|
|
|
_descriptorStream.WriteLine($"ddb.geometry.cylinders = \"{_imageInfo.Cylinders}\"");
|
|
|
|
|
|
_descriptorStream.WriteLine($"ddb.geometry.heads = \"{_imageInfo.Heads}\"");
|
|
|
|
|
|
_descriptorStream.WriteLine($"ddb.geometry.sectors = \"{_imageInfo.SectorsPerTrack}\"");
|
|
|
|
|
|
_descriptorStream.WriteLine($"ddb.adapterType = \"{_adapterType}\"");
|
|
|
|
|
|
|
|
|
|
|
|
_descriptorStream.Flush();
|
|
|
|
|
|
_descriptorStream.Close();
|
|
|
|
|
|
|
|
|
|
|
|
IsWriting = false;
|
|
|
|
|
|
ErrorMessage = "";
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <inheritdoc />
|
2022-12-15 22:21:07 +00:00
|
|
|
|
public bool SetImageInfo(ImageInfo imageInfo) => true;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public bool SetGeometry(uint cylinders, uint heads, uint sectorsPerTrack)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(cylinders > ushort.MaxValue)
|
|
|
|
|
|
{
|
2022-11-29 02:10:37 +00:00
|
|
|
|
ErrorMessage = Localization.Too_many_cylinders;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return false;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(heads > byte.MaxValue)
|
2018-07-23 23:25:43 +01:00
|
|
|
|
{
|
2022-11-29 02:10:37 +00:00
|
|
|
|
ErrorMessage = Localization.Too_many_heads;
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2018-07-23 23:25:43 +01:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(sectorsPerTrack > byte.MaxValue)
|
2018-07-23 23:25:43 +01:00
|
|
|
|
{
|
2022-11-29 02:10:37 +00:00
|
|
|
|
ErrorMessage = Localization.Too_many_sectors_per_track;
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2018-07-23 23:25:43 +01:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
_imageInfo.SectorsPerTrack = sectorsPerTrack;
|
|
|
|
|
|
_imageInfo.Heads = heads;
|
|
|
|
|
|
_imageInfo.Cylinders = cylinders;
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag)
|
|
|
|
|
|
{
|
2022-11-29 02:10:37 +00:00
|
|
|
|
ErrorMessage = Localization.Unsupported_feature;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return false;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag)
|
|
|
|
|
|
{
|
2022-11-29 02:10:37 +00:00
|
|
|
|
ErrorMessage = Localization.Unsupported_feature;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2022-12-15 22:21:07 +00:00
|
|
|
|
public bool SetDumpHardware(List<DumpHardware> dumpHardware) => false;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2022-12-15 22:21:07 +00:00
|
|
|
|
public bool SetMetadata(Metadata metadata) => false;
|
2023-10-03 23:34:59 +01:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
2018-07-23 23:25:43 +01:00
|
|
|
|
}
|