Add support for negative sectors to read and write sector calls in images.

This commit is contained in:
2025-10-23 03:07:43 +01:00
parent 0c19fe1b11
commit 69738f5f1a
289 changed files with 2676 additions and 1352 deletions

View File

@@ -54,45 +54,53 @@ public interface IMediaImage : IBaseImage
/// <summary>Reads a sector's user data.</summary>
/// <returns>The sector's user data.</returns>
/// <param name="sectorAddress">Sector address (LBA).</param>
/// <param name="negative"></param>
/// <param name="buffer"></param>
/// <param name="sectorStatus"></param>
ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus);
ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus);
/// <summary>Reads a complete sector (user data + all tags).</summary>
/// <returns>The complete sector. Format depends on disk type.</returns>
/// <param name="sectorAddress">Sector address (LBA).</param>
/// <param name="negative"></param>
/// <param name="buffer"></param>
/// <param name="sectorStatus"></param>
ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus);
ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus);
/// <summary>Reads user data from several sectors.</summary>
/// <returns>The sectors user data.</returns>
/// <param name="sectorAddress">Starting sector address (LBA).</param>
/// <param name="negative"></param>
/// <param name="length">How many sectors to read.</param>
/// <param name="buffer"></param>
/// <param name="sectorStatus"></param>
ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus);
ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer,
out SectorStatus[] sectorStatus);
/// <summary>Reads several complete sector (user data + all tags).</summary>
/// <returns>The complete sectors. Format depends on disk type.</returns>
/// <param name="sectorAddress">Starting sector address (LBA).</param>
/// <param name="negative"></param>
/// <param name="length">How many sectors to read.</param>
/// <param name="buffer"></param>
/// <param name="sectorStatus"></param>
ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus);
ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer,
out SectorStatus[] sectorStatus);
/// <summary>Reads tag from several sectors.</summary>
/// <returns>The sectors tag.</returns>
/// <param name="sectorAddress">Starting sector address (LBA).</param>
/// <param name="negative"></param>
/// <param name="length">How many sectors to read.</param>
/// <param name="tag">Tag type.</param>
/// <param name="buffer"></param>
ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer);
ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, out byte[] buffer);
/// <summary>Reads a sector's tag.</summary>
/// <returns>The sector's tag.</returns>
/// <param name="sectorAddress">Sector address (LBA).</param>
/// <param name="negative"></param>
/// <param name="tag">Tag type.</param>
/// <param name="buffer"></param>
ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer);
ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer);
}

View File

@@ -65,45 +65,51 @@ public interface IWritableImage : IMediaImage, IBaseWritableImage
/// <summary>Writes a sector to the image</summary>
/// <param name="data">Sector data</param>
/// <param name="sectorAddress">Sector address</param>
/// <param name="negative"></param>
/// <param name="sectorStatus"></param>
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus);
bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus);
/// <summary>Writes a sector to the image with main channel tags attached</summary>
/// <param name="data">Sector data with its main channel tags attached</param>
/// <param name="sectorAddress">Sector address</param>
/// <param name="negative"></param>
/// <param name="sectorStatus"></param>
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus);
bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus);
/// <summary>Writes several sectors to the image</summary>
/// <param name="data">Sectors data</param>
/// <param name="sectorAddress">Sector starting address</param>
/// <param name="negative"></param>
/// <param name="length">How many sectors to write</param>
/// <param name="sectorStatus"></param>
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus);
bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus);
/// <summary>Writes several sectors to the image</summary>
/// <param name="data">Sector data with their main channel tags attached</param>
/// <param name="sectorAddress">Sector starting address</param>
/// <param name="negative"></param>
/// <param name="length">How many sectors to write</param>
/// <param name="sectorStatus"></param>
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus);
bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus);
/// <summary>Writes parallel or subchannel sector tag for several sector</summary>
/// <param name="data">Tag data to write</param>
/// <param name="sectorAddress">Starting sector address</param>
/// <param name="negative"></param>
/// <param name="length">How many sectors to write</param>
/// <param name="tag">Tag type</param>
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag);
bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag);
/// <summary>Writes parallel or subchannel sector tag for one sector</summary>
/// <param name="data">Tag data to write</param>
/// <param name="sectorAddress">Sector address</param>
/// <param name="negative"></param>
/// <param name="tag">Tag type</param>
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag);
bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag);
}