diff --git a/Aaru.CommonTypes/Interfaces/IMediaImage.cs b/Aaru.CommonTypes/Interfaces/IMediaImage.cs index beaf8b40f..5c1df2e91 100644 --- a/Aaru.CommonTypes/Interfaces/IMediaImage.cs +++ b/Aaru.CommonTypes/Interfaces/IMediaImage.cs @@ -54,45 +54,53 @@ public interface IMediaImage : IBaseImage /// Reads a sector's user data. /// The sector's user data. /// Sector address (LBA). + /// /// /// - ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus); + ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus); /// Reads a complete sector (user data + all tags). /// The complete sector. Format depends on disk type. /// Sector address (LBA). + /// /// /// - ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus); + ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus); /// Reads user data from several sectors. /// The sectors user data. /// Starting sector address (LBA). + /// /// How many sectors to read. /// /// - 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); /// Reads several complete sector (user data + all tags). /// The complete sectors. Format depends on disk type. /// Starting sector address (LBA). + /// /// How many sectors to read. /// /// - 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); /// Reads tag from several sectors. /// The sectors tag. /// Starting sector address (LBA). + /// /// How many sectors to read. /// Tag type. /// - ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer); + ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, out byte[] buffer); /// Reads a sector's tag. /// The sector's tag. /// Sector address (LBA). + /// /// Tag type. /// - ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer); + ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer); } \ No newline at end of file diff --git a/Aaru.CommonTypes/Interfaces/IWritableImage.cs b/Aaru.CommonTypes/Interfaces/IWritableImage.cs index 7314fa484..83cbde5e6 100644 --- a/Aaru.CommonTypes/Interfaces/IWritableImage.cs +++ b/Aaru.CommonTypes/Interfaces/IWritableImage.cs @@ -65,45 +65,51 @@ public interface IWritableImage : IMediaImage, IBaseWritableImage /// Writes a sector to the image /// Sector data /// Sector address + /// /// /// true if operating completed successfully, false otherwise - bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus); + bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus); /// Writes a sector to the image with main channel tags attached /// Sector data with its main channel tags attached /// Sector address + /// /// /// true if operating completed successfully, false otherwise - bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus); + bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus); /// Writes several sectors to the image /// Sectors data /// Sector starting address + /// /// How many sectors to write /// /// true if operating completed successfully, false otherwise - bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus); + bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus); /// Writes several sectors to the image /// Sector data with their main channel tags attached /// Sector starting address + /// /// How many sectors to write /// /// true if operating completed successfully, false otherwise - bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus); + bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus); /// Writes parallel or subchannel sector tag for several sector /// Tag data to write /// Starting sector address + /// /// How many sectors to write /// Tag type /// true if operating completed successfully, false otherwise - bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag); + bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag); /// Writes parallel or subchannel sector tag for one sector /// Tag data to write /// Sector address + /// /// Tag type /// true if operating completed successfully, false otherwise - bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag); + bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag); } \ No newline at end of file diff --git a/Aaru.Core/Devices/Dumping/ATA.cs b/Aaru.Core/Devices/Dumping/ATA.cs index 59ec8f409..6da7bf35b 100644 --- a/Aaru.Core/Devices/Dumping/ATA.cs +++ b/Aaru.Core/Devices/Dumping/ATA.cs @@ -339,6 +339,7 @@ public partial class Dump outputFormat.WriteSectors(cmdBuf, i, + false, blocksToRead, Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead) .ToArray()); @@ -359,6 +360,7 @@ public partial class Dump outputFormat.WriteSectors(new byte[blockSize * _skip], i, + false, _skip, Enumerable.Repeat(SectorStatus.NotDumped, (int)blocksToRead) .ToArray()); @@ -448,7 +450,7 @@ public partial class Dump _resume.BadBlocks.Remove(badSector); extents.Add(badSector); - outputFormat.WriteSector(cmdBuf, badSector, SectorStatus.Dumped); + outputFormat.WriteSector(cmdBuf, badSector, false, SectorStatus.Dumped); _mediaGraph?.PaintSectorGood(badSector); } @@ -516,7 +518,7 @@ public partial class Dump { _resume.BadBlocks.Remove(badSector); extents.Add(badSector); - outputFormat.WriteSector(cmdBuf, badSector, SectorStatus.Dumped); + outputFormat.WriteSector(cmdBuf, badSector, false, SectorStatus.Dumped); _mediaGraph?.PaintSectorGood(badSector); UpdateStatus?.Invoke(string.Format(Localization.Core @@ -524,7 +526,8 @@ public partial class Dump badSector, pass)); } - else if(_persistent) outputFormat.WriteSector(cmdBuf, badSector, SectorStatus.Errored); + else if(_persistent) + outputFormat.WriteSector(cmdBuf, badSector, false, SectorStatus.Errored); } if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0) @@ -627,6 +630,7 @@ public partial class Dump outputFormat.WriteSector(cmdBuf, (ulong)((cy * heads + hd) * sectors + (sc - 1)), + false, SectorStatus.Dumped); imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; @@ -642,6 +646,7 @@ public partial class Dump outputFormat.WriteSector(new byte[blockSize], (ulong)((cy * heads + hd) * sectors + (sc - 1)), + false, SectorStatus.Errored); imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/CdiReady.cs b/Aaru.Core/Devices/Dumping/CompactDisc/CdiReady.cs index c5d73b3e4..c081f850d 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/CdiReady.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/CdiReady.cs @@ -300,6 +300,7 @@ partial class Dump outputOptical.WriteSectorsLong(data, i + r, + false, 1, Enumerable.Repeat(SectorStatus.Dumped, 1).ToArray()); @@ -333,7 +334,7 @@ partial class Dump } } else - outputOptical.WriteSectorsLong(cmdBuf, i + r, 1, [SectorStatus.Dumped]); + outputOptical.WriteSectorsLong(cmdBuf, i + r, false, 1, [SectorStatus.Dumped]); imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; @@ -410,6 +411,7 @@ partial class Dump outputOptical.WriteSectorsLong(data, i, + false, blocksToRead, Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray()); @@ -466,16 +468,20 @@ partial class Dump outputOptical.WriteSectorsLong(data, i, + false, blocksToRead, Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead) .ToArray()); } else + { outputOptical.WriteSectorsLong(cmdBuf, i, + false, blocksToRead, Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead) .ToArray()); + } } imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Data.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Data.cs index 3613979a0..0c33a4979 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Data.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Data.cs @@ -776,11 +776,14 @@ partial class Dump Array.Copy(cmdBuf, sectorSize, sub, 0, subSize); if(supportsLongSectors) + { outputFormat.WriteSectorsLong(data, i + r, + false, 1, Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead) .ToArray()); + } else { var cooked = new MemoryStream(); @@ -795,6 +798,7 @@ partial class Dump outputFormat.WriteSectors(cooked.ToArray(), i, + false, blocksToRead, Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead) .ToArray()); @@ -844,7 +848,7 @@ partial class Dump else { if(supportsLongSectors) - outputFormat.WriteSectorsLong(cmdBuf, i + r, 1, [SectorStatus.Dumped]); + outputFormat.WriteSectorsLong(cmdBuf, i + r, false, 1, [SectorStatus.Dumped]); else { var cooked = new MemoryStream(); @@ -859,6 +863,7 @@ partial class Dump outputFormat.WriteSectors(cooked.ToArray(), i, + false, blocksToRead, Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead) .ToArray()); @@ -878,12 +883,17 @@ partial class Dump if(supportedSubchannel != MmcSubchannel.None) { - outputFormat.WriteSectorsLong(new byte[sectorSize], i + r, 1, [SectorStatus.Errored]); + outputFormat.WriteSectorsLong(new byte[sectorSize], + i + r, + false, + 1, + [SectorStatus.Errored]); if(desiredSubchannel != MmcSubchannel.None) { outputFormat.WriteSectorsTag(new byte[subSize], i + r, + false, 1, SectorTagType.CdSectorSubchannel); } @@ -891,16 +901,23 @@ partial class Dump else { if(supportsLongSectors) - outputFormat.WriteSectorsLong(new byte[blockSize], i + r, 1, [SectorStatus.Errored]); + outputFormat.WriteSectorsLong(new byte[blockSize], + i + r, + false, + 1, + [SectorStatus.Errored]); else { if(cmdBuf.Length % sectorSize == 0) - outputFormat.WriteSectors(new byte[2048], i + r, 1, [SectorStatus.Errored]); + outputFormat.WriteSectors(new byte[2048], i + r, false, 1, [SectorStatus.Errored]); else + { outputFormat.WriteSectorsLong(new byte[blockSize], i + r, + false, 1, [SectorStatus.Errored]); + } } } @@ -977,11 +994,14 @@ partial class Dump } if(supportsLongSectors) + { outputFormat.WriteSectorsLong(data, i, + false, blocksToRead, Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead) .ToArray()); + } else { var cooked = new MemoryStream(); @@ -996,6 +1016,7 @@ partial class Dump outputFormat.WriteSectors(cooked.ToArray(), i, + false, blocksToRead, Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray()); } @@ -1043,11 +1064,14 @@ partial class Dump else { if(supportsLongSectors) + { outputFormat.WriteSectorsLong(cmdBuf, i, + false, blocksToRead, Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead) .ToArray()); + } else { var cooked = new MemoryStream(); @@ -1062,6 +1086,7 @@ partial class Dump outputFormat.WriteSectors(cooked.ToArray(), i, + false, blocksToRead, Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray()); } @@ -1097,6 +1122,7 @@ partial class Dump { outputFormat.WriteSectorsLong(new byte[sectorSize * _skip], i, + false, _skip, Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray()); @@ -1104,6 +1130,7 @@ partial class Dump { outputFormat.WriteSectorsTag(new byte[subSize * _skip], i, + false, _skip, SectorTagType.CdSectorSubchannel); } @@ -1111,23 +1138,32 @@ partial class Dump else { if(supportsLongSectors) + { outputFormat.WriteSectorsLong(new byte[blockSize * _skip], i, + false, _skip, Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray()); + } else { if(cmdBuf.Length % sectorSize == 0) + { outputFormat.WriteSectors(new byte[2048 * _skip], i, + false, _skip, Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray()); + } else + { outputFormat.WriteSectorsLong(new byte[blockSize * _skip], i, + false, _skip, Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip) .ToArray()); + } } } diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs index d2570ab8f..1f46eed2c 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs @@ -87,21 +87,21 @@ sealed partial class Dump MhddLog mhddLog; // MHDD log double minSpeed = double.MaxValue; // Minimum speed bool newTrim; // Is trim a new one? - int offsetBytes = 0; // Read offset - bool read6 = false; // Device supports READ(6) - bool read10 = false; // Device supports READ(10) - bool read12 = false; // Device supports READ(12) - bool read16 = false; // Device supports READ(16) - bool readcd = true; // Device supports READ CD + var offsetBytes = 0; // Read offset + var read6 = false; // Device supports READ(6) + var read10 = false; // Device supports READ(10) + var read12 = false; // Device supports READ(12) + var read16 = false; // Device supports READ(16) + var readcd = true; // Device supports READ CD bool ret; // Image writing return status const uint sectorSize = 2352; // Full sector size - int sectorsForOffset = 0; // Sectors needed to fix offset - bool sense = true; // Sense indicator + var sectorsForOffset = 0; // Sectors needed to fix offset + var sense = true; // Sense indicator int sessions; // Number of sessions in disc SubchannelLog subLog = null; // Subchannel log uint subSize = 0; // Subchannel size in bytes TrackSubchannelType subType; // Track subchannel type - bool supportsLongSectors = true; // Supports reading EDC and ECC + var supportsLongSectors = true; // Supports reading EDC and ECC bool supportsPqSubchannel; // Supports reading PQ subchannel bool supportsRwSubchannel; // Supports reading RW subchannel byte[] tmpBuf; // Temporary buffer @@ -113,11 +113,11 @@ sealed partial class Dump bool hiddenTrack; // Disc has a hidden track before track 1 MmcSubchannel supportedSubchannel; // Drive's maximum supported subchannel MmcSubchannel desiredSubchannel; // User requested subchannel - bool bcdSubchannel = false; // Subchannel positioning is in BCD + var bcdSubchannel = false; // Subchannel positioning is in BCD Dictionary isrcs = new(); string mcn = null; HashSet subchannelExtents = []; - bool cdiReadyReadAsAudio = false; + var cdiReadyReadAsAudio = false; uint firstLba; var outputOptical = _outputPlugin as IWritableOpticalImage; @@ -541,7 +541,7 @@ sealed partial class Dump ErrorMessage?.Invoke(Localization.Core.Output_format_does_not_support_pregaps_continuing); } - for(int t = 1; t < tracks.Length; t++) tracks[t - 1].EndSector = tracks[t].StartSector - 1; + for(var t = 1; t < tracks.Length; t++) tracks[t - 1].EndSector = tracks[t].StartSector - 1; tracks[^1].EndSector = (ulong)lastSector; blocks = (ulong)(lastSector + 1); @@ -626,7 +626,7 @@ sealed partial class Dump Tuple[] dataExtentsArray = dataExtents.ToArray(); - for(int i = 0; i < dataExtentsArray.Length - 1; i++) + for(var i = 0; i < dataExtentsArray.Length - 1; i++) leadOutExtents.Add(dataExtentsArray[i].Item2 + 1, dataExtentsArray[i + 1].Item1 - 1); } @@ -715,7 +715,7 @@ sealed partial class Dump continue; } - int bufOffset = 0; + var bufOffset = 0; while(cmdBuf[0 + bufOffset] != 0x00 || cmdBuf[1 + bufOffset] != 0xFF || @@ -928,7 +928,7 @@ sealed partial class Dump _dev.LastError)); } - bool cdiWithHiddenTrack1 = false; + var cdiWithHiddenTrack1 = false; if(dskType is MediaType.CDIREADY && tracks.Min(t => t.Sequence) == 1) { @@ -978,7 +978,10 @@ sealed partial class Dump { foreach(Track imgTrack in outputOptical.Tracks) { - errno = outputOptical.ReadSectorTag(imgTrack.Sequence, SectorTagType.CdTrackIsrc, out byte[] isrcBytes); + errno = outputOptical.ReadSectorTag(imgTrack.Sequence, + false, + SectorTagType.CdTrackIsrc, + out byte[] isrcBytes); if(errno == ErrorNumber.NoError) isrcs[(byte)imgTrack.Sequence] = Encoding.ASCII.GetString(isrcBytes); @@ -1041,7 +1044,7 @@ sealed partial class Dump UpdateStatus?.Invoke(string.Format(Localization.Core.Setting_flags_for_track_0, track.Sequence)); - outputOptical.WriteSectorTag([kvp.Value], kvp.Key, SectorTagType.CdTrackFlags); + outputOptical.WriteSectorTag([kvp.Value], kvp.Key, false, SectorTagType.CdTrackFlags); } // Set MCN @@ -1079,8 +1082,9 @@ sealed partial class Dump foreach(int sub in _resume.BadSubchannels) subchannelExtents.Add(sub); if(_resume.NextBlock < blocks) - for(ulong i = _resume.NextBlock; i < blocks; i++) - subchannelExtents.Add((int)i); + { + for(ulong i = _resume.NextBlock; i < blocks; i++) subchannelExtents.Add((int)i); + } } if(_resume.NextBlock > 0) @@ -1495,8 +1499,9 @@ sealed partial class Dump supportsLongSectors); foreach(Tuple leadoutExtent in leadOutExtents.ToArray()) - for(ulong e = leadoutExtent.Item1; e <= leadoutExtent.Item2; e++) - subchannelExtents.Remove((int)e); + { + for(ulong e = leadoutExtent.Item1; e <= leadoutExtent.Item2; e++) subchannelExtents.Remove((int)e); + } if(subchannelExtents.Count > 0 && _retryPasses > 0 && _retrySubchannel) { @@ -1583,7 +1588,10 @@ sealed partial class Dump foreach(KeyValuePair isrc in isrcs) { // TODO: Track tags - if(!outputOptical.WriteSectorTag(Encoding.ASCII.GetBytes(isrc.Value), isrc.Key, SectorTagType.CdTrackIsrc)) + if(!outputOptical.WriteSectorTag(Encoding.ASCII.GetBytes(isrc.Value), + isrc.Key, + false, + SectorTagType.CdTrackIsrc)) continue; UpdateStatus?.Invoke(string.Format(Localization.Core.Setting_ISRC_for_track_0_to_1, isrc.Key, isrc.Value)); diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs index d0b830dc9..996c322a8 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs @@ -466,9 +466,8 @@ partial class Dump // MEDIUM ERROR, retry with ignore error below if(decSense is { ASC: 0x11 }) - { - if(!sectorsNotEvenPartial.Contains(badSector)) sectorsNotEvenPartial.Add(badSector); - } + if(!sectorsNotEvenPartial.Contains(badSector)) + sectorsNotEvenPartial.Add(badSector); } // Because one block has been partially used to fix the offset @@ -510,9 +509,9 @@ partial class Dump Array.Copy(cmdBuf, sectorSize, sub, 0, subSize); if(supportsLongSectors) - outputOptical.WriteSectorLong(data, badSector, SectorStatus.Dumped); + outputOptical.WriteSectorLong(data, badSector, false, SectorStatus.Dumped); else - outputOptical.WriteSector(Sector.GetUserData(data), badSector, SectorStatus.Dumped); + outputOptical.WriteSector(Sector.GetUserData(data), badSector, false, SectorStatus.Dumped); bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel, desiredSubchannel, @@ -543,9 +542,9 @@ partial class Dump else { if(supportsLongSectors) - outputOptical.WriteSectorLong(cmdBuf, badSector, SectorStatus.Dumped); + outputOptical.WriteSectorLong(cmdBuf, badSector, false, SectorStatus.Dumped); else - outputOptical.WriteSector(Sector.GetUserData(cmdBuf), badSector, SectorStatus.Dumped); + outputOptical.WriteSector(Sector.GetUserData(cmdBuf), badSector, false, SectorStatus.Dumped); } } @@ -663,9 +662,9 @@ partial class Dump Array.Copy(cmdBuf, sectorSize, sub, 0, subSize); if(supportsLongSectors) - outputOptical.WriteSectorLong(data, badSector, SectorStatus.Errored); + outputOptical.WriteSectorLong(data, badSector, false, SectorStatus.Errored); else - outputOptical.WriteSector(Sector.GetUserData(data), badSector, SectorStatus.Errored); + outputOptical.WriteSector(Sector.GetUserData(data), badSector, false, SectorStatus.Errored); bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel, desiredSubchannel, @@ -696,9 +695,12 @@ partial class Dump else { if(supportsLongSectors) - outputOptical.WriteSectorLong(cmdBuf, badSector, SectorStatus.Errored); + outputOptical.WriteSectorLong(cmdBuf, badSector, false, SectorStatus.Errored); else - outputOptical.WriteSector(Sector.GetUserData(cmdBuf), badSector, SectorStatus.Errored); + outputOptical.WriteSector(Sector.GetUserData(cmdBuf), + badSector, + false, + SectorStatus.Errored); } } diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/LeadOuts.cs b/Aaru.Core/Devices/Dumping/CompactDisc/LeadOuts.cs index 6df702f36..6dfcea5fc 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/LeadOuts.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/LeadOuts.cs @@ -217,6 +217,7 @@ partial class Dump outputOptical.WriteSectorsLong(data, i, + false, _maximumReadable, Enumerable.Repeat(SectorStatus.Dumped, (int)_maximumReadable) .ToArray()); @@ -251,11 +252,14 @@ partial class Dump } } else + { outputOptical.WriteSectors(cmdBuf, i, + false, _maximumReadable, Enumerable.Repeat(SectorStatus.Dumped, (int)_maximumReadable) .ToArray()); + } imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; } @@ -271,15 +275,16 @@ partial class Dump if(supportedSubchannel != MmcSubchannel.None) { - outputOptical.WriteSectorsLong(new byte[sectorSize * _skip], i, 1, new SectorStatus[1]); + outputOptical.WriteSectorsLong(new byte[sectorSize * _skip], i, false, 1, new SectorStatus[1]); outputOptical.WriteSectorsTag(new byte[subSize * _skip], i, + false, 1, SectorTagType.CdSectorSubchannel); } else - outputOptical.WriteSectors(new byte[blockSize * _skip], i, 1, new SectorStatus[1]); + outputOptical.WriteSectors(new byte[blockSize * _skip], i, false, 1, new SectorStatus[1]); imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; @@ -464,6 +469,7 @@ partial class Dump outputOptical.WriteSectorsLong(data, i, + false, _maximumReadable, Enumerable.Repeat(SectorStatus.Dumped, (int)_maximumReadable) .ToArray()); @@ -498,11 +504,14 @@ partial class Dump } } else + { outputOptical.WriteSectors(cmdBuf, i, + false, _maximumReadable, Enumerable.Repeat(SectorStatus.Dumped, (int)_maximumReadable) .ToArray()); + } imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; } @@ -518,18 +527,19 @@ partial class Dump if(supportedSubchannel != MmcSubchannel.None) { - outputOptical.WriteSectorsLong(new byte[sectorSize * _skip], i, 1, new SectorStatus[1]); + outputOptical.WriteSectorsLong(new byte[sectorSize * _skip], i, false, 1, new SectorStatus[1]); if(desiredSubchannel != MmcSubchannel.None) { outputOptical.WriteSectorsTag(new byte[subSize * _skip], i, + false, 1, SectorTagType.CdSectorSubchannel); } } else - outputOptical.WriteSectors(new byte[blockSize * _skip], i, 1, new SectorStatus[1]); + outputOptical.WriteSectors(new byte[blockSize * _skip], i, false, 1, new SectorStatus[1]); imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Recordable.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Recordable.cs index 2cee811be..c9efc6de4 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Recordable.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Recordable.cs @@ -102,9 +102,9 @@ partial class Dump } if(supportsLongSectors) - outputOptical.WriteSectorLong(sector, s, SectorStatus.Dumped); + outputOptical.WriteSectorLong(sector, s, false, SectorStatus.Dumped); else - outputOptical.WriteSector(Sector.GetUserData(sector), s, SectorStatus.Dumped); + outputOptical.WriteSector(Sector.GetUserData(sector), s, false, SectorStatus.Dumped); _resume.BadBlocks.Remove(s); extents.Add(s); @@ -145,7 +145,7 @@ partial class Dump byte[] sub = Subchannel.Generate((int)s, track?.Sequence ?? 0, (int)pregap, (int)trackStart, flags, index); - outputOptical.WriteSectorsTag(sub, s, 1, SectorTagType.CdSectorSubchannel); + outputOptical.WriteSectorsTag(sub, s, false, 1, SectorTagType.CdSectorSubchannel); subLog?.WriteEntry(sub, true, (long)s, 1, true, false); subchannelExtents.Remove((int)s); diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Trim.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Trim.cs index c68f44133..5914803e9 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Trim.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Trim.cs @@ -424,9 +424,9 @@ partial class Dump Array.Copy(cmdBuf, sectorSize, sub, 0, subSize); if(supportsLongSectors) - outputOptical.WriteSectorLong(data, badSector, SectorStatus.Dumped); + outputOptical.WriteSectorLong(data, badSector, false, SectorStatus.Dumped); else - outputOptical.WriteSector(Sector.GetUserData(data), badSector, SectorStatus.Dumped); + outputOptical.WriteSector(Sector.GetUserData(data), badSector, false, SectorStatus.Dumped); ulong trkStartBefore = track.StartSector; @@ -468,9 +468,9 @@ partial class Dump } if(supportsLongSectors) - outputOptical.WriteSectorLong(cmdBuf, badSector, SectorStatus.Dumped); + outputOptical.WriteSectorLong(cmdBuf, badSector, false, SectorStatus.Dumped); else - outputOptical.WriteSector(Sector.GetUserData(cmdBuf), badSector, SectorStatus.Dumped); + outputOptical.WriteSector(Sector.GetUserData(cmdBuf), badSector, false, SectorStatus.Dumped); } _trimStopwatch.Stop(); diff --git a/Aaru.Core/Devices/Dumping/MiniDisc.cs b/Aaru.Core/Devices/Dumping/MiniDisc.cs index 4c0473fe6..cac8cfb11 100644 --- a/Aaru.Core/Devices/Dumping/MiniDisc.cs +++ b/Aaru.Core/Devices/Dumping/MiniDisc.cs @@ -377,6 +377,7 @@ partial class Dump outputFormat.WriteSectors(readBuffer, i, + false, blocksToRead, Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray()); @@ -396,6 +397,7 @@ partial class Dump outputFormat.WriteSectors(new byte[blockSize * _skip], i, + false, _skip, Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray()); @@ -480,7 +482,7 @@ partial class Dump _resume.BadBlocks.Remove(badSector); extents.Add(badSector); - outputFormat.WriteSector(readBuffer, badSector, SectorStatus.Dumped); + outputFormat.WriteSector(readBuffer, badSector, false, SectorStatus.Dumped); _mediaGraph?.PaintSectorGood(badSector); } @@ -647,14 +649,14 @@ partial class Dump { _resume.BadBlocks.Remove(badSector); extents.Add(badSector); - outputFormat.WriteSector(readBuffer, badSector, SectorStatus.Dumped); + outputFormat.WriteSector(readBuffer, badSector, false, SectorStatus.Dumped); _mediaGraph?.PaintSectorGood(badSector); UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1, badSector, pass)); } - else if(runningPersistent) outputFormat.WriteSector(readBuffer, badSector, SectorStatus.Errored); + else if(runningPersistent) outputFormat.WriteSector(readBuffer, badSector, false, SectorStatus.Errored); } if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0) diff --git a/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs b/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs index 96e811ee8..40e5e1d38 100644 --- a/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs +++ b/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs @@ -249,6 +249,7 @@ public partial class Dump outputFormat.WriteSectors(readBuffer, i, + false, blocksToRead, Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray()); @@ -270,6 +271,7 @@ public partial class Dump outputFormat.WriteSectors(new byte[blockSize * _skip], i, + false, _skip, Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray()); @@ -373,7 +375,7 @@ public partial class Dump _resume.BadBlocks.Remove(badSector); extents.Add(badSector); - outputFormat.WriteSector(readBuffer, badSector, SectorStatus.Dumped); + outputFormat.WriteSector(readBuffer, badSector, false, SectorStatus.Dumped); _mediaGraph?.PaintSectorGood(badSector); } @@ -572,14 +574,14 @@ public partial class Dump { _resume.BadBlocks.Remove(badSector); extents.Add(badSector); - outputFormat.WriteSector(readBuffer, badSector, SectorStatus.Dumped); + outputFormat.WriteSector(readBuffer, badSector, false, SectorStatus.Dumped); _mediaGraph?.PaintSectorGood(badSector); UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1, badSector, pass)); } - else if(runningPersistent) outputFormat.WriteSector(readBuffer, badSector, SectorStatus.Errored); + else if(runningPersistent) outputFormat.WriteSector(readBuffer, badSector, false, SectorStatus.Errored); } if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0) diff --git a/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs b/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs index 9521d4370..285f85ca0 100644 --- a/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs +++ b/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs @@ -288,6 +288,7 @@ public partial class Dump outputOptical.WriteSectors(readBuffer, i, + false, blocksToRead, Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray()); @@ -307,6 +308,7 @@ public partial class Dump // Write empty data outputOptical.WriteSectors(new byte[blockSize * _skip], i, + false, _skip, Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray()); @@ -409,7 +411,7 @@ public partial class Dump _resume.BadBlocks.Remove(badSector); extents.Add(badSector); - outputOptical.WriteSector(readBuffer, badSector, SectorStatus.Dumped); + outputOptical.WriteSector(readBuffer, badSector, false, SectorStatus.Dumped); _mediaGraph?.PaintSectorGood(badSector); } @@ -585,14 +587,15 @@ public partial class Dump { _resume.BadBlocks.Remove(badSector); extents.Add(badSector); - outputOptical.WriteSector(readBuffer, badSector, SectorStatus.Dumped); + outputOptical.WriteSector(readBuffer, badSector, false, SectorStatus.Dumped); _mediaGraph?.PaintSectorGood(badSector); UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1, badSector, pass)); } - else if(runningPersistent) outputOptical.WriteSector(readBuffer, badSector, SectorStatus.Errored); + else if(runningPersistent) + outputOptical.WriteSector(readBuffer, badSector, false, SectorStatus.Errored); } if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0) diff --git a/Aaru.Core/Devices/Dumping/SSC.cs b/Aaru.Core/Devices/Dumping/SSC.cs index a083697b2..d624d2267 100644 --- a/Aaru.Core/Devices/Dumping/SSC.cs +++ b/Aaru.Core/Devices/Dumping/SSC.cs @@ -285,8 +285,9 @@ partial class Dump Modes.DecodedMode? decMode = null; if(!sense && !_dev.Error) - if(Modes.DecodeMode10(cmdBuf, _dev.ScsiType).HasValue) - decMode = Modes.DecodeMode10(cmdBuf, _dev.ScsiType); + { + if(Modes.DecodeMode10(cmdBuf, _dev.ScsiType).HasValue) decMode = Modes.DecodeMode10(cmdBuf, _dev.ScsiType); + } UpdateStatus?.Invoke(Localization.Core.Requesting_MODE_SENSE_6); @@ -314,8 +315,9 @@ partial class Dump if(sense || _dev.Error) sense = _dev.ModeSense(out cmdBuf, out senseBuf, 5, out duration); if(!sense && !_dev.Error) - if(Modes.DecodeMode6(cmdBuf, _dev.ScsiType).HasValue) - decMode = Modes.DecodeMode6(cmdBuf, _dev.ScsiType); + { + if(Modes.DecodeMode6(cmdBuf, _dev.ScsiType).HasValue) decMode = Modes.DecodeMode6(cmdBuf, _dev.ScsiType); + } // TODO: Check partitions page if(decMode.HasValue) @@ -1090,7 +1092,7 @@ partial class Dump // Write empty data _writeStopwatch.Restart(); - outputTape.WriteSector(new byte[blockSize], currentBlock, SectorStatus.NotDumped); + outputTape.WriteSector(new byte[blockSize], currentBlock, false, SectorStatus.NotDumped); imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; mhddLog.Write(currentBlock, duration < 500 ? 65535 : duration); @@ -1102,7 +1104,7 @@ partial class Dump mhddLog.Write(currentBlock, duration); ibgLog.Write(currentBlock, currentSpeed * 1024); _writeStopwatch.Restart(); - outputTape.WriteSector(cmdBuf, currentBlock, SectorStatus.Dumped); + outputTape.WriteSector(cmdBuf, currentBlock, false, SectorStatus.Dumped); imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; extents.Add(currentBlock, 1, true); } @@ -1297,13 +1299,13 @@ partial class Dump { _resume.BadBlocks.Remove(badBlock); extents.Add(badBlock); - outputTape.WriteSector(cmdBuf, badBlock, SectorStatus.Dumped); + outputTape.WriteSector(cmdBuf, badBlock, false, SectorStatus.Dumped); UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1, badBlock, pass)); } - else if(runningPersistent) outputTape.WriteSector(cmdBuf, badBlock, SectorStatus.Errored); + else if(runningPersistent) outputTape.WriteSector(cmdBuf, badBlock, false, SectorStatus.Errored); } if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0) diff --git a/Aaru.Core/Devices/Dumping/Sbc/Cache.cs b/Aaru.Core/Devices/Dumping/Sbc/Cache.cs index 30c41cc54..966d1bd28 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Cache.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Cache.cs @@ -126,7 +126,7 @@ partial class Dump if(key.All(static k => k == 0)) { - outputFormat.WriteSectorTag([0, 0, 0, 0, 0], i + j, SectorTagType.DvdTitleKeyDecrypted); + outputFormat.WriteSectorTag([0, 0, 0, 0, 0], i + j, false, SectorTagType.DvdTitleKeyDecrypted); _resume.MissingTitleKeys?.Remove(i + j); @@ -134,7 +134,7 @@ partial class Dump } CSS.DecryptTitleKey(discKey, key, out tmpBuf); - outputFormat.WriteSectorTag(tmpBuf, i + j, SectorTagType.DvdTitleKeyDecrypted); + outputFormat.WriteSectorTag(tmpBuf, i + j, false, SectorTagType.DvdTitleKeyDecrypted); _resume.MissingTitleKeys?.Remove(i + j); if(_storeEncrypted) continue; @@ -147,6 +147,7 @@ partial class Dump { ErrorNumber errno = outputFormat.ReadSectorsTag(i, + false, blocksToRead, SectorTagType.DvdTitleKeyDecrypted, out byte[] titleKey); @@ -162,6 +163,7 @@ partial class Dump outputFormat.WriteSectorsLong(buffer, i, + false, blocksToRead, Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray()); @@ -181,6 +183,7 @@ partial class Dump outputFormat.WriteSectorsLong(new byte[blockSize * _skip], i, + false, _skip, Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray()); diff --git a/Aaru.Core/Devices/Dumping/Sbc/Data.cs b/Aaru.Core/Devices/Dumping/Sbc/Data.cs index a20fd402c..9a7250dd5 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Data.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Data.cs @@ -134,7 +134,7 @@ partial class Dump CSS_CPRM.TitleKey? titleKey = CSS.DecodeTitleKey(tmpBuf, dvdDecrypt.BusKey); if(titleKey.HasValue) - outputFormat.WriteSectorTag([titleKey.Value.CMI], i + j, SectorTagType.DvdSectorCmi); + outputFormat.WriteSectorTag([titleKey.Value.CMI], i + j, false, SectorTagType.DvdSectorCmi); else continue; @@ -142,20 +142,23 @@ partial class Dump // not encrypted even if the CMI says it is. if(titleKey.Value.Key.All(static k => k == 0)) { - outputFormat.WriteSectorTag([0, 0, 0, 0, 0], i + j, SectorTagType.DvdSectorTitleKey); + outputFormat.WriteSectorTag([0, 0, 0, 0, 0], i + j, false, SectorTagType.DvdSectorTitleKey); - outputFormat.WriteSectorTag([0, 0, 0, 0, 0], i + j, SectorTagType.DvdTitleKeyDecrypted); + outputFormat.WriteSectorTag([0, 0, 0, 0, 0], + i + j, + false, + SectorTagType.DvdTitleKeyDecrypted); _resume.MissingTitleKeys.Remove(i + j); continue; } - outputFormat.WriteSectorTag(titleKey.Value.Key, i + j, SectorTagType.DvdSectorTitleKey); + outputFormat.WriteSectorTag(titleKey.Value.Key, i + j, false, SectorTagType.DvdSectorTitleKey); _resume.MissingTitleKeys.Remove(i + j); CSS.DecryptTitleKey(discKey, titleKey.Value.Key, out tmpBuf); - outputFormat.WriteSectorTag(tmpBuf, i + j, SectorTagType.DvdTitleKeyDecrypted); + outputFormat.WriteSectorTag(tmpBuf, i + j, false, SectorTagType.DvdTitleKeyDecrypted); } if(!_storeEncrypted) @@ -163,13 +166,18 @@ partial class Dump // Todo: Flag in the outputFormat that a sector has been decrypted { ErrorNumber errno = - outputFormat.ReadSectorsTag(i, blocksToRead, SectorTagType.DvdSectorCmi, out byte[] cmi); + outputFormat.ReadSectorsTag(i, + false, + blocksToRead, + SectorTagType.DvdSectorCmi, + out byte[] cmi); if(errno != ErrorNumber.NoError) ErrorMessage?.Invoke(string.Format(Localization.Core.Error_retrieving_CMI_for_sector_0, i)); else { errno = outputFormat.ReadSectorsTag(i, + false, blocksToRead, SectorTagType.DvdTitleKeyDecrypted, out byte[] titleKey); @@ -192,6 +200,7 @@ partial class Dump outputFormat.WriteSectors(buffer, i, + false, blocksToRead, Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray()); @@ -225,6 +234,7 @@ partial class Dump outputFormat.WriteSectors(new byte[blockSize * _skip], i, + false, _skip, Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray()); diff --git a/Aaru.Core/Devices/Dumping/Sbc/Error.cs b/Aaru.Core/Devices/Dumping/Sbc/Error.cs index c222f26a0..84a0c9fe9 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Error.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Error.cs @@ -316,14 +316,17 @@ partial class Dump if(key.All(static k => k == 0)) { - outputFormat.WriteSectorTag([0, 0, 0, 0, 0], badSector, SectorTagType.DvdTitleKeyDecrypted); + outputFormat.WriteSectorTag([0, 0, 0, 0, 0], + badSector, + false, + SectorTagType.DvdTitleKeyDecrypted); _resume.MissingTitleKeys?.Remove(badSector); } else { CSS.DecryptTitleKey(discKey, key, out byte[] tmpBuf); - outputFormat.WriteSectorTag(tmpBuf, badSector, SectorTagType.DvdTitleKeyDecrypted); + outputFormat.WriteSectorTag(tmpBuf, badSector, false, SectorTagType.DvdTitleKeyDecrypted); _resume.MissingTitleKeys?.Remove(badSector); cmi[0] = buffer[6]; @@ -333,6 +336,7 @@ partial class Dump { ErrorNumber errno = outputFormat.ReadSectorsTag(badSector, + false, 1, SectorTagType.DvdTitleKeyDecrypted, out byte[] titleKey); @@ -348,10 +352,10 @@ partial class Dump } _resume.BadBlocks.Remove(badSector); - outputFormat.WriteSectorLong(buffer, badSector, SectorStatus.Dumped); + outputFormat.WriteSectorLong(buffer, badSector, false, SectorStatus.Dumped); } else - outputFormat.WriteSector(buffer, badSector, SectorStatus.Dumped); + outputFormat.WriteSector(buffer, badSector, false, SectorStatus.Dumped); _mediaGraph?.PaintSectorGood(badSector); @@ -359,7 +363,7 @@ partial class Dump badSector, pass)); } - else if(runningPersistent) outputFormat.WriteSector(buffer, badSector, SectorStatus.Errored); + else if(runningPersistent) outputFormat.WriteSector(buffer, badSector, false, SectorStatus.Errored); } if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0) @@ -441,15 +445,15 @@ partial class Dump if(!titleKey.HasValue) continue; - outputFormat.WriteSectorTag([titleKey.Value.CMI], missingKey, SectorTagType.DvdSectorCmi); + outputFormat.WriteSectorTag([titleKey.Value.CMI], missingKey, false, SectorTagType.DvdSectorCmi); // If the CMI bit is 1, the sector is using copy protection, else it is not // If the decoded title key is zeroed, there should be no copy protection if((titleKey.Value.CMI & 0x80) >> 7 == 0 || titleKey.Value.Key.All(k => k == 0)) { - outputFormat.WriteSectorTag([0, 0, 0, 0, 0], missingKey, SectorTagType.DvdSectorTitleKey); + outputFormat.WriteSectorTag([0, 0, 0, 0, 0], missingKey, false, SectorTagType.DvdSectorTitleKey); - outputFormat.WriteSectorTag([0, 0, 0, 0, 0], missingKey, SectorTagType.DvdTitleKeyDecrypted); + outputFormat.WriteSectorTag([0, 0, 0, 0, 0], missingKey, false, SectorTagType.DvdTitleKeyDecrypted); _resume.MissingTitleKeys.Remove(missingKey); @@ -459,13 +463,13 @@ partial class Dump } else { - outputFormat.WriteSectorTag(titleKey.Value.Key, missingKey, SectorTagType.DvdSectorTitleKey); + outputFormat.WriteSectorTag(titleKey.Value.Key, missingKey, false, SectorTagType.DvdSectorTitleKey); _resume.MissingTitleKeys.Remove(missingKey); if(discKey != null) { CSS.DecryptTitleKey(discKey, titleKey.Value.Key, out buffer); - outputFormat.WriteSectorTag(buffer, missingKey, SectorTagType.DvdTitleKeyDecrypted); + outputFormat.WriteSectorTag(buffer, missingKey, false, SectorTagType.DvdTitleKeyDecrypted); } UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_title_key_0_in_pass_1, diff --git a/Aaru.Core/Devices/Dumping/Sbc/Optical.cs b/Aaru.Core/Devices/Dumping/Sbc/Optical.cs index 427b14bea..447190871 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Optical.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Optical.cs @@ -180,8 +180,9 @@ partial class Dump writtenExtents.Add(0, blocks - 1); foreach(Tuple blank in blankExtents.ToArray()) - for(ulong b = blank.Item1; b <= blank.Item2; b++) - writtenExtents.Remove(b); + { + for(ulong b = blank.Item1; b <= blank.Item2; b++) writtenExtents.Remove(b); + } } if(writtenExtents.Count == 0) @@ -239,6 +240,7 @@ partial class Dump outputFormat.WriteSectors(buffer, i, + false, blocksToRead, Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray()); @@ -257,6 +259,7 @@ partial class Dump outputFormat.WriteSectors(new byte[blockSize * _skip], i, + false, _skip, Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray()); diff --git a/Aaru.Core/Devices/Dumping/Sbc/Trim.cs b/Aaru.Core/Devices/Dumping/Sbc/Trim.cs index 6b2c5c8eb..0cfb2985e 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Trim.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Trim.cs @@ -107,14 +107,14 @@ partial class Dump if(key.All(static k => k == 0)) { - outputFormat.WriteSectorTag([0, 0, 0, 0, 0], badSector, SectorTagType.DvdTitleKeyDecrypted); + outputFormat.WriteSectorTag([0, 0, 0, 0, 0], badSector, false, SectorTagType.DvdTitleKeyDecrypted); _resume.MissingTitleKeys?.Remove(badSector); } else { CSS.DecryptTitleKey(discKey, key, out byte[] tmpBuf); - outputFormat.WriteSectorTag(tmpBuf, badSector, SectorTagType.DvdTitleKeyDecrypted); + outputFormat.WriteSectorTag(tmpBuf, badSector, false, SectorTagType.DvdTitleKeyDecrypted); _resume.MissingTitleKeys?.Remove(badSector); cmi[0] = buffer[6]; @@ -124,6 +124,7 @@ partial class Dump { ErrorNumber errno = outputFormat.ReadSectorsTag(badSector, + false, 1, SectorTagType.DvdTitleKeyDecrypted, out byte[] titleKey); @@ -138,10 +139,10 @@ partial class Dump } _resume.BadBlocks.Remove(badSector); - outputFormat.WriteSectorLong(buffer, badSector, SectorStatus.Dumped); + outputFormat.WriteSectorLong(buffer, badSector, false, SectorStatus.Dumped); } else - outputFormat.WriteSector(buffer, badSector, SectorStatus.Dumped); + outputFormat.WriteSector(buffer, badSector, false, SectorStatus.Dumped); _mediaGraph?.PaintSectorGood(badSector); } diff --git a/Aaru.Core/Devices/Dumping/SecureDigital.cs b/Aaru.Core/Devices/Dumping/SecureDigital.cs index 5499543e5..fe4c2e3d0 100644 --- a/Aaru.Core/Devices/Dumping/SecureDigital.cs +++ b/Aaru.Core/Devices/Dumping/SecureDigital.cs @@ -667,6 +667,7 @@ public partial class Dump outputFormat.WriteSectors(cmdBuf, i, + false, blocksToRead, Enumerable.Repeat(SectorStatus.Dumped, blocksToRead).ToArray()); @@ -689,6 +690,7 @@ public partial class Dump outputFormat.WriteSectors(new byte[blockSize * _skip], i, + false, _skip, Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray()); @@ -781,7 +783,7 @@ public partial class Dump _resume.BadBlocks.Remove(badSector); extents.Add(badSector); - outputFormat.WriteSector(cmdBuf, badSector, SectorStatus.Dumped); + outputFormat.WriteSector(cmdBuf, badSector, false, SectorStatus.Dumped); _mediaGraph?.PaintSectorGood(badSector); } @@ -842,7 +844,7 @@ public partial class Dump _resume.BadBlocks.Remove(badSector); extents.Add(badSector); - outputFormat.WriteSector(cmdBuf, badSector, SectorStatus.Dumped); + outputFormat.WriteSector(cmdBuf, badSector, false, SectorStatus.Dumped); _mediaGraph?.PaintSectorGood(badSector); UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1, diff --git a/Aaru.Core/Devices/Dumping/XGD.cs b/Aaru.Core/Devices/Dumping/XGD.cs index bcc77dec4..4213ef2dd 100644 --- a/Aaru.Core/Devices/Dumping/XGD.cs +++ b/Aaru.Core/Devices/Dumping/XGD.cs @@ -686,6 +686,7 @@ partial class Dump outputFormat.WriteSectors(readBuffer, i, + false, blocksToRead, Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray()); @@ -707,6 +708,7 @@ partial class Dump outputFormat.WriteSectors(new byte[blockSize * _skip], i, + false, _skip, Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray()); @@ -770,6 +772,7 @@ partial class Dump outputFormat.WriteSectors(new byte[blockSize * blocksToRead], i, + false, blocksToRead, Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray()); @@ -820,6 +823,7 @@ partial class Dump outputFormat.WriteSectors(new byte[blockSize * blocksToRead], middle + currentSector, + false, blocksToRead, Enumerable.Repeat(SectorStatus.NotDumped, (int)blocksToRead).ToArray()); @@ -910,6 +914,7 @@ partial class Dump outputFormat.WriteSectors(readBuffer, currentSector, + false, blocksToRead, Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray()); @@ -929,6 +934,7 @@ partial class Dump outputFormat.WriteSectors(new byte[blockSize * _skip], currentSector, + false, _skip, Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray()); @@ -1060,7 +1066,7 @@ partial class Dump _resume.BadBlocks.Remove(badSector); extents.Add(badSector); - outputFormat.WriteSector(readBuffer, badSector, SectorStatus.Dumped); + outputFormat.WriteSector(readBuffer, badSector, false, SectorStatus.Dumped); _mediaGraph?.PaintSectorGood(badSector); } @@ -1080,9 +1086,8 @@ partial class Dump List tmpList = []; foreach(ulong ur in _resume.BadBlocks) - { - for(ulong i = ur; i < ur + blocksToRead; i++) tmpList.Add(i); - } + for(ulong i = ur; i < ur + blocksToRead; i++) + tmpList.Add(i); tmpList.Sort(); @@ -1261,14 +1266,14 @@ partial class Dump { _resume.BadBlocks.Remove(badSector); extents.Add(badSector); - outputFormat.WriteSector(readBuffer, badSector, SectorStatus.Dumped); + outputFormat.WriteSector(readBuffer, badSector, false, SectorStatus.Dumped); _mediaGraph?.PaintSectorGood(badSector); UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1, badSector, pass)); } - else if(runningPersistent) outputFormat.WriteSector(readBuffer, badSector, SectorStatus.Errored); + else if(runningPersistent) outputFormat.WriteSector(readBuffer, badSector, false, SectorStatus.Errored); } if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0) diff --git a/Aaru.Core/Entropy.cs b/Aaru.Core/Entropy.cs index a6a7fff09..97e3d2494 100644 --- a/Aaru.Core/Entropy.cs +++ b/Aaru.Core/Entropy.cs @@ -174,9 +174,7 @@ public sealed class Entropy AaruLogging.Exception(ex, Localization.Core.Could_not_get_tracks_because_0, ex.Message); } else - { AaruLogging.Error(Localization.Core.Unable_to_get_separate_tracks_not_calculating_their_entropy); - } } return entropyResults.ToArray(); @@ -208,7 +206,7 @@ public sealed class Entropy (long)(i + 1), (long)entropy.Sectors); - ErrorNumber errno = mediaImage.ReadSector(i, out byte[] sector, out _); + ErrorNumber errno = mediaImage.ReadSector(i, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) { diff --git a/Aaru.Core/Media/CompactDisc.cs b/Aaru.Core/Media/CompactDisc.cs index 83868b463..610d196da 100644 --- a/Aaru.Core/Media/CompactDisc.cs +++ b/Aaru.Core/Media/CompactDisc.cs @@ -84,7 +84,7 @@ public static class CompactDisc // If not desired to fix, or to save, the subchannel, just save as is (or none) if(!fixSubchannelPosition && desiredSubchannel != MmcSubchannel.None) - outputPlugin.WriteSectorsTag(sub, sectorAddress, length, SectorTagType.CdSectorSubchannel); + outputPlugin.WriteSectorsTag(sub, sectorAddress, false, length, SectorTagType.CdSectorSubchannel); subLog?.WriteEntry(sub, supportedSubchannel == MmcSubchannel.Raw, (long)sectorAddress, length, false, false); @@ -106,15 +106,15 @@ public static class CompactDisc int prePos = int.MinValue; // Check subchannel - for(int subPos = 0; subPos < deSub.Length; subPos += 96) + for(var subPos = 0; subPos < deSub.Length; subPos += 96) { // Expected LBA long lba = (long)sectorAddress + subPos / 96; // We fixed the subchannel - bool @fixed = false; + var @fixed = false; - byte[] q = new byte[12]; + var q = new byte[12]; Array.Copy(deSub, subPos + 12, q, 0, 12); // Check Q CRC @@ -122,18 +122,17 @@ public static class CompactDisc bool crcOk = crc[0] == q[10] && crc[1] == q[11]; // Start considering P to be OK - bool pOk = true; - int pWeight = 0; + var pOk = true; + var pWeight = 0; // Check P and weight for(int p = subPos; p < subPos + 12; p++) { if(deSub[p] != 0 && deSub[p] != 255) pOk = false; - for(int w = 0; w < 8; w++) - { - if((deSub[p] >> w & 1) > 0) pWeight++; - } + for(var w = 0; w < 8; w++) + if((deSub[p] >> w & 1) > 0) + pWeight++; } // This seems to be a somewhat common pattern @@ -156,13 +155,13 @@ public static class CompactDisc deSub.Skip(subPos + 84).Take(12).All(w => w == 0xFF); bool rwOk = rOk && sOk && tOk && uOk && vOk && wOk; - bool rwPacket = false; - bool cdtextPacket = false; + var rwPacket = false; + var cdtextPacket = false; // Check RW contents if(!rwOk) { - byte[] sectorSub = new byte[96]; + var sectorSub = new byte[96]; Array.Copy(sub, subPos, sectorSub, 0, 96); DetectRwPackets(sectorSub, out _, out rwPacket, out cdtextPacket); @@ -177,13 +176,11 @@ public static class CompactDisc if(!pOk && fixSubchannel) { if(pWeight >= 48) - { - for(int p = subPos; p < subPos + 12; p++) deSub[p] = 255; - } + for(int p = subPos; p < subPos + 12; p++) + deSub[p] = 255; else - { - for(int p = subPos; p < subPos + 12; p++) deSub[p] = 0; - } + for(int p = subPos; p < subPos + 12; p++) + deSub[p] = 0; pOk = true; @fixed = true; @@ -255,20 +252,20 @@ public static class CompactDisc if(!pOk || !crcOk || !rwOk) continue; - byte aframe = (byte)(q[9] / 16 * 10 + (q[9] & 0x0F)); + var aframe = (byte)(q[9] / 16 * 10 + (q[9] & 0x0F)); if((q[0] & 0x3) == 1) { - byte amin = (byte)(q[7] / 16 * 10 + (q[7] & 0x0F)); - byte asec = (byte)(q[8] / 16 * 10 + (q[8] & 0x0F)); + var amin = (byte)(q[7] / 16 * 10 + (q[7] & 0x0F)); + var asec = (byte)(q[8] / 16 * 10 + (q[8] & 0x0F)); aPos = amin * 60 * 75 + asec * 75 + aframe - 150; } else { ulong expectedSectorAddress = sectorAddress + (ulong)(subPos / 96) + 150; - byte smin = (byte)(expectedSectorAddress / 60 / 75); + var smin = (byte)(expectedSectorAddress / 60 / 75); expectedSectorAddress -= (ulong)(smin * 60 * 75); - byte ssec = (byte)(expectedSectorAddress / 75); + var ssec = (byte)(expectedSectorAddress / 75); aPos = smin * 60 * 75 + ssec * 75 + aframe - 150; @@ -281,10 +278,10 @@ public static class CompactDisc prePos = aPos; - byte[] posSub = new byte[96]; + var posSub = new byte[96]; Array.Copy(deSub, subPos, posSub, 0, 96); posSub = Subchannel.Interleave(posSub); - outputPlugin.WriteSectorTag(posSub, (ulong)aPos, SectorTagType.CdSectorSubchannel); + outputPlugin.WriteSectorTag(posSub, (ulong)aPos, false, SectorTagType.CdSectorSubchannel); subchannelExtents.Remove(aPos); @@ -315,13 +312,13 @@ public static class CompactDisc Dictionary smallestPregapLbaPerTrack, bool dumping, out List newPregapSectors, ulong sectorAddress) { - bool status = false; + var status = false; newPregapSectors = []; // Check subchannel - for(int subPos = 0; subPos < deSub.Length; subPos += 96) + for(var subPos = 0; subPos < deSub.Length; subPos += 96) { - byte[] q = new byte[12]; + var q = new byte[12]; Array.Copy(deSub, subPos + 12, q, 0, 12); CRC16CcittContext.Data(q, 10, out byte[] crc); @@ -389,19 +386,19 @@ public static class CompactDisc continue; case 1: { - byte trackNo = (byte)(q[1] / 16 * 10 + (q[1] & 0x0F)); + var trackNo = (byte)(q[1] / 16 * 10 + (q[1] & 0x0F)); - for(int i = 0; i < tracks.Length; i++) + for(var i = 0; i < tracks.Length; i++) { if(tracks[i].Sequence != trackNo) continue; // Pregap if(q[2] == 0 && trackNo > 1) { - byte pmin = (byte)(q[3] / 16 * 10 + (q[3] & 0x0F)); - byte psec = (byte)(q[4] / 16 * 10 + (q[4] & 0x0F)); - byte pframe = (byte)(q[5] / 16 * 10 + (q[5] & 0x0F)); - int qPos = pmin * 60 * 75 + psec * 75 + pframe; + var pmin = (byte)(q[3] / 16 * 10 + (q[3] & 0x0F)); + var psec = (byte)(q[4] / 16 * 10 + (q[4] & 0x0F)); + var pframe = (byte)(q[5] / 16 * 10 + (q[5] & 0x0F)); + int qPos = pmin * 60 * 75 + psec * 75 + pframe; // When we are dumping we calculate the pregap in reverse from index 1 back. // When we are not, we go from index 0. @@ -427,7 +424,7 @@ public static class CompactDisc trackNo, tracks[i].Pregap)); - for(int p = 0; p < dif; p++) newPregapSectors.Add(tracks[i].StartSector + (ulong)p); + for(var p = 0; p < dif; p++) newPregapSectors.Add(tracks[i].StartSector + (ulong)p); status = true; } @@ -446,7 +443,7 @@ public static class CompactDisc trackNo, tracks[i].Pregap)); - for(int p = 0; p < (int)(tracks[i].Pregap - oldPregap); p++) + for(var p = 0; p < (int)(tracks[i].Pregap - oldPregap); p++) newPregapSectors.Add(tracks[i].StartSector + (ulong)p); status = true; @@ -456,10 +453,10 @@ public static class CompactDisc if(q[2] == 0) continue; - byte amin = (byte)(q[7] / 16 * 10 + (q[7] & 0x0F)); - byte asec = (byte)(q[8] / 16 * 10 + (q[8] & 0x0F)); - byte aframe = (byte)(q[9] / 16 * 10 + (q[9] & 0x0F)); - int aPos = amin * 60 * 75 + asec * 75 + aframe - 150; + var amin = (byte)(q[7] / 16 * 10 + (q[7] & 0x0F)); + var asec = (byte)(q[8] / 16 * 10 + (q[8] & 0x0F)); + var aframe = (byte)(q[9] / 16 * 10 + (q[9] & 0x0F)); + int aPos = amin * 60 * 75 + asec * 75 + aframe - 150; // Do not set INDEX 1 to a value higher than what the TOC already said. if(q[2] == 1 && aPos > (int)tracks[i].StartSector) continue; @@ -495,18 +492,18 @@ public static class CompactDisc rwPacket = false; cdtextPacket = false; - byte[] cdTextPack1 = new byte[18]; - byte[] cdTextPack2 = new byte[18]; - byte[] cdTextPack3 = new byte[18]; - byte[] cdTextPack4 = new byte[18]; - byte[] cdSubRwPack1 = new byte[24]; - byte[] cdSubRwPack2 = new byte[24]; - byte[] cdSubRwPack3 = new byte[24]; - byte[] cdSubRwPack4 = new byte[24]; + var cdTextPack1 = new byte[18]; + var cdTextPack2 = new byte[18]; + var cdTextPack3 = new byte[18]; + var cdTextPack4 = new byte[18]; + var cdSubRwPack1 = new byte[24]; + var cdSubRwPack2 = new byte[24]; + var cdSubRwPack3 = new byte[24]; + var cdSubRwPack4 = new byte[24]; - int i = 0; + var i = 0; - for(int j = 0; j < 18; j++) + for(var j = 0; j < 18; j++) { cdTextPack1[j] = (byte)(cdTextPack1[j] | (subchannel[i++] & 0x3F) << 2); @@ -521,7 +518,7 @@ public static class CompactDisc if(j < 18) cdTextPack1[j] = (byte)(cdTextPack1[j] | subchannel[i++] & 0x3F); } - for(int j = 0; j < 18; j++) + for(var j = 0; j < 18; j++) { cdTextPack2[j] = (byte)(cdTextPack2[j] | (subchannel[i++] & 0x3F) << 2); @@ -536,7 +533,7 @@ public static class CompactDisc if(j < 18) cdTextPack2[j] = (byte)(cdTextPack2[j] | subchannel[i++] & 0x3F); } - for(int j = 0; j < 18; j++) + for(var j = 0; j < 18; j++) { cdTextPack3[j] = (byte)(cdTextPack3[j] | (subchannel[i++] & 0x3F) << 2); @@ -551,7 +548,7 @@ public static class CompactDisc if(j < 18) cdTextPack3[j] = (byte)(cdTextPack3[j] | subchannel[i++] & 0x3F); } - for(int j = 0; j < 18; j++) + for(var j = 0; j < 18; j++) { cdTextPack4[j] = (byte)(cdTextPack4[j] | (subchannel[i++] & 0x3F) << 2); @@ -568,13 +565,13 @@ public static class CompactDisc i = 0; - for(int j = 0; j < 24; j++) cdSubRwPack1[j] = (byte)(subchannel[i++] & 0x3F); + for(var j = 0; j < 24; j++) cdSubRwPack1[j] = (byte)(subchannel[i++] & 0x3F); - for(int j = 0; j < 24; j++) cdSubRwPack2[j] = (byte)(subchannel[i++] & 0x3F); + for(var j = 0; j < 24; j++) cdSubRwPack2[j] = (byte)(subchannel[i++] & 0x3F); - for(int j = 0; j < 24; j++) cdSubRwPack3[j] = (byte)(subchannel[i++] & 0x3F); + for(var j = 0; j < 24; j++) cdSubRwPack3[j] = (byte)(subchannel[i++] & 0x3F); - for(int j = 0; j < 24; j++) cdSubRwPack4[j] = (byte)(subchannel[i++] & 0x3F); + for(var j = 0; j < 24; j++) cdSubRwPack4[j] = (byte)(subchannel[i++] & 0x3F); switch(cdSubRwPack1[0]) { @@ -670,14 +667,14 @@ public static class CompactDisc /// true if subchannel contains a TEXT packet, false otherwise static bool CheckCdTextPackets(byte[] subchannel) { - byte[] cdTextPack1 = new byte[18]; - byte[] cdTextPack2 = new byte[18]; - byte[] cdTextPack3 = new byte[18]; - byte[] cdTextPack4 = new byte[18]; + var cdTextPack1 = new byte[18]; + var cdTextPack2 = new byte[18]; + var cdTextPack3 = new byte[18]; + var cdTextPack4 = new byte[18]; - int i = 0; + var i = 0; - for(int j = 0; j < 18; j++) + for(var j = 0; j < 18; j++) { cdTextPack1[j] = (byte)(cdTextPack1[j] | (subchannel[i++] & 0x3F) << 2); @@ -692,7 +689,7 @@ public static class CompactDisc if(j < 18) cdTextPack1[j] = (byte)(cdTextPack1[j] | subchannel[i++] & 0x3F); } - for(int j = 0; j < 18; j++) + for(var j = 0; j < 18; j++) { cdTextPack2[j] = (byte)(cdTextPack2[j] | (subchannel[i++] & 0x3F) << 2); @@ -707,7 +704,7 @@ public static class CompactDisc if(j < 18) cdTextPack2[j] = (byte)(cdTextPack2[j] | subchannel[i++] & 0x3F); } - for(int j = 0; j < 18; j++) + for(var j = 0; j < 18; j++) { cdTextPack3[j] = (byte)(cdTextPack3[j] | (subchannel[i++] & 0x3F) << 2); @@ -722,7 +719,7 @@ public static class CompactDisc if(j < 18) cdTextPack3[j] = (byte)(cdTextPack3[j] | subchannel[i++] & 0x3F); } - for(int j = 0; j < 18; j++) + for(var j = 0; j < 18; j++) { cdTextPack4[j] = (byte)(cdTextPack4[j] | (subchannel[i++] & 0x3F) << 2); @@ -737,12 +734,12 @@ public static class CompactDisc if(j < 18) cdTextPack4[j] = (byte)(cdTextPack4[j] | subchannel[i++] & 0x3F); } - bool status = true; + var status = true; if((cdTextPack1[0] & 0x80) == 0x80) { - ushort cdTextPack1Crc = BigEndianBitConverter.ToUInt16(cdTextPack1, 16); - byte[] cdTextPack1ForCrc = new byte[16]; + var cdTextPack1Crc = BigEndianBitConverter.ToUInt16(cdTextPack1, 16); + var cdTextPack1ForCrc = new byte[16]; Array.Copy(cdTextPack1, 0, cdTextPack1ForCrc, 0, 16); ushort calculatedCdtp1Crc = CRC16CcittContext.Calculate(cdTextPack1ForCrc); @@ -751,8 +748,8 @@ public static class CompactDisc if((cdTextPack2[0] & 0x80) == 0x80) { - ushort cdTextPack2Crc = BigEndianBitConverter.ToUInt16(cdTextPack2, 16); - byte[] cdTextPack2ForCrc = new byte[16]; + var cdTextPack2Crc = BigEndianBitConverter.ToUInt16(cdTextPack2, 16); + var cdTextPack2ForCrc = new byte[16]; Array.Copy(cdTextPack2, 0, cdTextPack2ForCrc, 0, 16); ushort calculatedCdtp2Crc = CRC16CcittContext.Calculate(cdTextPack2ForCrc); @@ -761,8 +758,8 @@ public static class CompactDisc if((cdTextPack3[0] & 0x80) == 0x80) { - ushort cdTextPack3Crc = BigEndianBitConverter.ToUInt16(cdTextPack3, 16); - byte[] cdTextPack3ForCrc = new byte[16]; + var cdTextPack3Crc = BigEndianBitConverter.ToUInt16(cdTextPack3, 16); + var cdTextPack3ForCrc = new byte[16]; Array.Copy(cdTextPack3, 0, cdTextPack3ForCrc, 0, 16); ushort calculatedCdtp3Crc = CRC16CcittContext.Calculate(cdTextPack3ForCrc); @@ -771,8 +768,8 @@ public static class CompactDisc if((cdTextPack4[0] & 0x80) != 0x80) return status; - ushort cdTextPack4Crc = BigEndianBitConverter.ToUInt16(cdTextPack4, 16); - byte[] cdTextPack4ForCrc = new byte[16]; + var cdTextPack4Crc = BigEndianBitConverter.ToUInt16(cdTextPack4, 16); + var cdTextPack4ForCrc = new byte[16]; Array.Copy(cdTextPack4, 0, cdTextPack4ForCrc, 0, 16); ushort calculatedCdtp4Crc = CRC16CcittContext.Calculate(cdTextPack4ForCrc); @@ -816,8 +813,8 @@ public static class CompactDisc fixedMcn = false; fixedIsrc = false; - byte[] preQ = new byte[12]; - byte[] nextQ = new byte[12]; + var preQ = new byte[12]; + var nextQ = new byte[12]; Array.Copy(deSub, subPos + 12 - 96, preQ, 0, 12); Array.Copy(deSub, subPos + 12 + 96, nextQ, 0, 12); @@ -971,15 +968,15 @@ public static class CompactDisc } } - byte amin = (byte)(q[7] / 16 * 10 + (q[7] & 0x0F)); - byte asec = (byte)(q[8] / 16 * 10 + (q[8] & 0x0F)); + var amin = (byte)(q[7] / 16 * 10 + (q[7] & 0x0F)); + var asec = (byte)(q[8] / 16 * 10 + (q[8] & 0x0F)); aframe = (byte)(q[9] / 16 * 10 + (q[9] & 0x0F)); int aPos = amin * 60 * 75 + asec * 75 + aframe - 150; - byte pmin = (byte)(q[3] / 16 * 10 + (q[3] & 0x0F)); - byte psec = (byte)(q[4] / 16 * 10 + (q[4] & 0x0F)); - byte pframe = (byte)(q[5] / 16 * 10 + (q[5] & 0x0F)); - int pPos = pmin * 60 * 75 + psec * 75 + pframe; + var pmin = (byte)(q[3] / 16 * 10 + (q[3] & 0x0F)); + var psec = (byte)(q[4] / 16 * 10 + (q[4] & 0x0F)); + var pframe = (byte)(q[5] / 16 * 10 + (q[5] & 0x0F)); + int pPos = pmin * 60 * 75 + psec * 75 + pframe; // TODO: pregap // Not pregap @@ -1536,7 +1533,7 @@ public static class CompactDisc byte[] sub = Subchannel.Generate(sector, track?.Sequence ?? 0, (int)pregap, (int)trackStart, flags, index); - outputPlugin.WriteSectorsTag(sub, (ulong)sector, 1, SectorTagType.CdSectorSubchannel); + outputPlugin.WriteSectorsTag(sub, (ulong)sector, false, 1, SectorTagType.CdSectorSubchannel); subLog?.WriteEntry(sub, true, sector, 1, true, false); } diff --git a/Aaru.Core/Sidecar/BlockMedia.cs b/Aaru.Core/Sidecar/BlockMedia.cs index e48672f0c..0b74df048 100644 --- a/Aaru.Core/Sidecar/BlockMedia.cs +++ b/Aaru.Core/Sidecar/BlockMedia.cs @@ -401,7 +401,7 @@ public sealed partial class Sidecar if(sectors - doneSectors >= sectorsToRead) { - errno = image.ReadSectors(doneSectors, sectorsToRead, out sector, out _); + errno = image.ReadSectors(doneSectors, false, sectorsToRead, out sector, out _); if(errno != ErrorNumber.NoError) { @@ -416,7 +416,7 @@ public sealed partial class Sidecar } else { - errno = image.ReadSectors(doneSectors, (uint)(sectors - doneSectors), out sector, out _); + errno = image.ReadSectors(doneSectors, false, (uint)(sectors - doneSectors), out sector, out _); if(errno != ErrorNumber.NoError) { @@ -501,6 +501,7 @@ public sealed partial class Sidecar if(sectors - doneSectors >= sectorsToRead) { errno = image.ReadSectors(tapePartition.FirstBlock + doneSectors, + false, sectorsToRead, out sector, out _); @@ -522,6 +523,7 @@ public sealed partial class Sidecar else { errno = image.ReadSectors(tapePartition.FirstBlock + doneSectors, + false, (uint)(sectors - doneSectors), out sector, out _); @@ -605,6 +607,7 @@ public sealed partial class Sidecar if(sectors - doneSectors >= sectorsToRead) { errno = image.ReadSectors(tapeFile.FirstBlock + doneSectors, + false, sectorsToRead, out sector, out _); @@ -629,6 +632,7 @@ public sealed partial class Sidecar else { errno = image.ReadSectors(tapeFile.FirstBlock + doneSectors, + false, (uint)(sectors - doneSectors), out sector, out _); diff --git a/Aaru.Core/Sidecar/OpticalDisc.cs b/Aaru.Core/Sidecar/OpticalDisc.cs index bbe32de8a..853568741 100644 --- a/Aaru.Core/Sidecar/OpticalDisc.cs +++ b/Aaru.Core/Sidecar/OpticalDisc.cs @@ -663,11 +663,11 @@ public sealed partial class Sidecar xmlTrk.FileSystemInformation.Add(metadataPartition); } - errno = image.ReadSectorTag(trk.Sequence, SectorTagType.CdTrackIsrc, out byte[] isrcData); + errno = image.ReadSectorTag(trk.Sequence, false, SectorTagType.CdTrackIsrc, out byte[] isrcData); if(errno == ErrorNumber.NoError) xmlTrk.ISRC = Encoding.UTF8.GetString(isrcData); - errno = image.ReadSectorTag(trk.Sequence, SectorTagType.CdTrackFlags, out byte[] flagsData); + errno = image.ReadSectorTag(trk.Sequence, false, SectorTagType.CdTrackFlags, out byte[] flagsData); if(errno == ErrorNumber.NoError) { diff --git a/Aaru.Decryption/DVD/CSS.cs b/Aaru.Decryption/DVD/CSS.cs index 4a6e9e57c..c5a174f59 100644 --- a/Aaru.Decryption/DVD/CSS.cs +++ b/Aaru.Decryption/DVD/CSS.cs @@ -964,7 +964,7 @@ public class CSS for(ulong i = 0; i < sectorsToSearch; i++) { - input.ReadSector(startSector + i, out byte[] sector, out _); + input.ReadSector(startSector + i, false, out byte[] sector, out _); if(!IsEncrypted(null, null, sector)) continue; diff --git a/Aaru.Filesystems/AODOS/Info.cs b/Aaru.Filesystems/AODOS/Info.cs index 778efd3be..f533249d4 100644 --- a/Aaru.Filesystems/AODOS/Info.cs +++ b/Aaru.Filesystems/AODOS/Info.cs @@ -60,7 +60,7 @@ public sealed partial class AODOS // Does AO-DOS support any other kind of disk? if(imagePlugin.Info.Sectors != 800 && imagePlugin.Info.Sectors != 1600) return false; - ErrorNumber errno = imagePlugin.ReadSector(0, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(0, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -75,7 +75,7 @@ public sealed partial class AODOS { information = ""; encoding = Encoding.GetEncoding("koi8-r"); - ErrorNumber errno = imagePlugin.ReadSector(0, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(0, false, out byte[] sector, out _); metadata = new FileSystem(); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/APFS/Info.cs b/Aaru.Filesystems/APFS/Info.cs index 0d63a6afd..875213442 100644 --- a/Aaru.Filesystems/APFS/Info.cs +++ b/Aaru.Filesystems/APFS/Info.cs @@ -50,7 +50,7 @@ public sealed partial class APFS { if(partition.Start >= partition.End) return false; - ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(partition.Start, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -80,7 +80,7 @@ public sealed partial class APFS if(partition.Start >= partition.End) return; - ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(partition.Start, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/Acorn/Info.cs b/Aaru.Filesystems/Acorn/Info.cs index 99c205462..492d28766 100644 --- a/Aaru.Filesystems/Acorn/Info.cs +++ b/Aaru.Filesystems/Acorn/Info.cs @@ -60,14 +60,14 @@ public sealed partial class AcornADFS // ADFS-S, ADFS-M, ADFS-L, ADFS-D without partitions if(partition.Start == 0) { - errno = imagePlugin.ReadSector(0, out sector, out _); + errno = imagePlugin.ReadSector(0, false, out sector, out _); if(errno != ErrorNumber.NoError) return false; byte oldChk0 = AcornMapChecksum(sector, 255); OldMapSector0 oldMap0 = Marshal.ByteArrayToStructureLittleEndian(sector); - errno = imagePlugin.ReadSector(1, out sector, out _); + errno = imagePlugin.ReadSector(1, false, out sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -80,7 +80,7 @@ public sealed partial class AcornADFS // According to documentation map1 MUST start on sector 1. On ADFS-D it starts at 0x100, not on sector 1 (0x400) if(oldMap0.checksum == oldChk0 && oldMap1.checksum != oldChk1 && sector.Length >= 512) { - errno = imagePlugin.ReadSector(0, out sector, out _); + errno = imagePlugin.ReadSector(0, false, out sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -103,7 +103,7 @@ public sealed partial class AcornADFS if(OLD_DIRECTORY_SIZE % imagePlugin.Info.SectorSize > 0) sectorsToRead++; - errno = imagePlugin.ReadSectors(sbSector, sectorsToRead, out sector, out _); + errno = imagePlugin.ReadSectors(sbSector, false, sectorsToRead, out sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -136,7 +136,7 @@ public sealed partial class AcornADFS if(NEW_DIRECTORY_SIZE % imagePlugin.Info.SectorSize > 0) sectorsToRead++; - errno = imagePlugin.ReadSectors(sbSector, sectorsToRead, out sector, out _); + errno = imagePlugin.ReadSectors(sbSector, false, sectorsToRead, out sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -168,7 +168,7 @@ public sealed partial class AcornADFS // Partitioning or not, new formats follow: DiscRecord drSb; - errno = imagePlugin.ReadSector(partition.Start, out sector, out _); + errno = imagePlugin.ReadSector(partition.Start, false, out sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -183,7 +183,7 @@ public sealed partial class AcornADFS if(sbSector + partition.Start + sectorsToRead >= partition.End) return false; - errno = imagePlugin.ReadSectors(sbSector + partition.Start, sectorsToRead, out byte[] bootSector, out _); + errno = imagePlugin.ReadSectors(sbSector + partition.Start, false, sectorsToRead, out byte[] bootSector, out _); if(errno != ErrorNumber.NoError) return false; @@ -254,14 +254,14 @@ public sealed partial class AcornADFS // ADFS-S, ADFS-M, ADFS-L, ADFS-D without partitions if(partition.Start == 0) { - errno = imagePlugin.ReadSector(0, out sector, out _); + errno = imagePlugin.ReadSector(0, false, out sector, out _); if(errno != ErrorNumber.NoError) return; byte oldChk0 = AcornMapChecksum(sector, 255); OldMapSector0 oldMap0 = Marshal.ByteArrayToStructureLittleEndian(sector); - errno = imagePlugin.ReadSector(1, out sector, out _); + errno = imagePlugin.ReadSector(1, false, out sector, out _); if(errno != ErrorNumber.NoError) return; @@ -271,7 +271,7 @@ public sealed partial class AcornADFS // According to documentation map1 MUST start on sector 1. On ADFS-D it starts at 0x100, not on sector 1 (0x400) if(oldMap0.checksum == oldChk0 && oldMap1.checksum != oldChk1 && sector.Length >= 512) { - errno = imagePlugin.ReadSector(0, out sector, out _); + errno = imagePlugin.ReadSector(0, false, out sector, out _); if(errno != ErrorNumber.NoError) return; @@ -310,7 +310,7 @@ public sealed partial class AcornADFS if(OLD_DIRECTORY_SIZE % imagePlugin.Info.SectorSize > 0) sectorsToRead++; - errno = imagePlugin.ReadSectors(sbSector, sectorsToRead, out sector, out _); + errno = imagePlugin.ReadSectors(sbSector, false, sectorsToRead, out sector, out _); if(errno != ErrorNumber.NoError) return; @@ -334,7 +334,7 @@ public sealed partial class AcornADFS if(NEW_DIRECTORY_SIZE % imagePlugin.Info.SectorSize > 0) sectorsToRead++; - errno = imagePlugin.ReadSectors(sbSector, sectorsToRead, out sector, out _); + errno = imagePlugin.ReadSectors(sbSector, false, sectorsToRead, out sector, out _); if(errno != ErrorNumber.NoError) return; @@ -354,7 +354,7 @@ public sealed partial class AcornADFS namebytes = oldRoot.tail.name; else { - errno = imagePlugin.ReadSectors(sbSector, sectorsToRead, out sector, out _); + errno = imagePlugin.ReadSectors(sbSector, false, sectorsToRead, out sector, out _); if(errno != ErrorNumber.NoError) return; @@ -402,7 +402,7 @@ public sealed partial class AcornADFS // Partitioning or not, new formats follow: DiscRecord drSb; - errno = imagePlugin.ReadSector(partition.Start, out sector, out _); + errno = imagePlugin.ReadSector(partition.Start, false, out sector, out _); if(errno != ErrorNumber.NoError) return; @@ -415,7 +415,7 @@ public sealed partial class AcornADFS if(BOOT_BLOCK_SIZE % imagePlugin.Info.SectorSize > 0) sectorsToRead++; - errno = imagePlugin.ReadSectors(sbSector + partition.Start, sectorsToRead, out byte[] bootSector, out _); + errno = imagePlugin.ReadSectors(sbSector + partition.Start, false, sectorsToRead, out byte[] bootSector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/AmigaDOS/Info.cs b/Aaru.Filesystems/AmigaDOS/Info.cs index 85f4e36ba..f10a58568 100644 --- a/Aaru.Filesystems/AmigaDOS/Info.cs +++ b/Aaru.Filesystems/AmigaDOS/Info.cs @@ -56,7 +56,7 @@ public sealed partial class AmigaDOSPlugin // However while you can set a block size different from the sector size on formatting, the bootblock block // size for floppies is the sector size, and for RDB is usually is the hard disk sector size, // so this is not entirely wrong... - ErrorNumber errno = imagePlugin.ReadSectors(0 + partition.Start, 2, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(0 + partition.Start, false, 2, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -69,7 +69,7 @@ public sealed partial class AmigaDOSPlugin (bblk.diskType & FFS_MASK) != FFS_MASK && (bblk.diskType & MUFS_MASK) != MUFS_MASK) { - errno = imagePlugin.ReadSectors(1 + partition.Start, 2, out sector, out _); + errno = imagePlugin.ReadSectors(1 + partition.Start, false, 2, out sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -110,7 +110,7 @@ public sealed partial class AmigaDOSPlugin { AaruLogging.Debug(MODULE_NAME, Localization.Searching_for_Rootblock_in_sector_0, rootPtr); - errno = imagePlugin.ReadSector(rootPtr, out sector, out _); + errno = imagePlugin.ReadSector(rootPtr, false, out sector, out _); if(errno != ErrorNumber.NoError) continue; @@ -133,7 +133,7 @@ public sealed partial class AmigaDOSPlugin if(rootPtr + sectorsPerBlock >= partition.End) continue; - errno = imagePlugin.ReadSectors(rootPtr, sectorsPerBlock, out sector, out _); + errno = imagePlugin.ReadSectors(rootPtr, false, sectorsPerBlock, out sector, out _); if(errno != ErrorNumber.NoError) continue; @@ -162,7 +162,7 @@ public sealed partial class AmigaDOSPlugin var sbInformation = new StringBuilder(); metadata = new FileSystem(); information = null; - ErrorNumber errno = imagePlugin.ReadSectors(0 + partition.Start, 2, out byte[] bootBlockSectors, out _); + ErrorNumber errno = imagePlugin.ReadSectors(0 + partition.Start, false, 2, out byte[] bootBlockSectors, out _); if(errno != ErrorNumber.NoError) return; @@ -200,7 +200,7 @@ public sealed partial class AmigaDOSPlugin { AaruLogging.Debug(MODULE_NAME, Localization.Searching_for_Rootblock_in_sector_0, rootPtr); - errno = imagePlugin.ReadSector(rootPtr, out rootBlockSector, out _); + errno = imagePlugin.ReadSector(rootPtr, false, out rootBlockSector, out _); if(errno != ErrorNumber.NoError) continue; @@ -223,7 +223,7 @@ public sealed partial class AmigaDOSPlugin if(rootPtr + sectorsPerBlock >= partition.End) continue; - errno = imagePlugin.ReadSectors(rootPtr, sectorsPerBlock, out rootBlockSector, out _); + errno = imagePlugin.ReadSectors(rootPtr, false, sectorsPerBlock, out rootBlockSector, out _); if(errno != ErrorNumber.NoError) continue; @@ -240,7 +240,7 @@ public sealed partial class AmigaDOSPlugin if(rootBlk.sec_type != SUBTYPE_ROOT || rootBlk.checksum != rsum) continue; - errno = imagePlugin.ReadSectors(rootPtr, sectorsPerBlock, out rootBlockSector, out _); + errno = imagePlugin.ReadSectors(rootPtr, false, sectorsPerBlock, out rootBlockSector, out _); if(errno != ErrorNumber.NoError) continue; diff --git a/Aaru.Filesystems/AppleDOS/Dir.cs b/Aaru.Filesystems/AppleDOS/Dir.cs index a2dcd3459..fe11d8bd4 100644 --- a/Aaru.Filesystems/AppleDOS/Dir.cs +++ b/Aaru.Filesystems/AppleDOS/Dir.cs @@ -56,7 +56,7 @@ public sealed partial class AppleDOS while(lba != 0) { _usedSectors++; - ErrorNumber errno = _device.ReadSector(lba, out byte[] catSectorB, out _); + ErrorNumber errno = _device.ReadSector(lba, false, out byte[] catSectorB, out _); if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Filesystems/AppleDOS/File.cs b/Aaru.Filesystems/AppleDOS/File.cs index b83e49175..3d3dfe307 100644 --- a/Aaru.Filesystems/AppleDOS/File.cs +++ b/Aaru.Filesystems/AppleDOS/File.cs @@ -64,7 +64,7 @@ public sealed partial class AppleDOS while(lba != 0) { _usedSectors++; - ErrorNumber errno = _device.ReadSector(lba, out byte[] tsSectorB, out _); + ErrorNumber errno = _device.ReadSector(lba, false, out byte[] tsSectorB, out _); if(errno != ErrorNumber.NoError) return errno; @@ -90,7 +90,7 @@ public sealed partial class AppleDOS if(blockLba == 0) break; - errno = _device.ReadSector(blockLba, out byte[] fileBlock, out _); + errno = _device.ReadSector(blockLba, false, out byte[] fileBlock, out _); if(errno != ErrorNumber.NoError) return errno; @@ -128,7 +128,8 @@ public sealed partial class AppleDOS if(!_track2UsedByFiles) tracksOnBoot++; - ErrorNumber errno = _device.ReadSectors(0, (uint)(tracksOnBoot * _sectorsPerTrack), out _bootBlocks, out _); + ErrorNumber errno = + _device.ReadSectors(0, false, (uint)(tracksOnBoot * _sectorsPerTrack), out _bootBlocks, out _); if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Filesystems/AppleDOS/Info.cs b/Aaru.Filesystems/AppleDOS/Info.cs index 4cccda9c3..5b145ae58 100644 --- a/Aaru.Filesystems/AppleDOS/Info.cs +++ b/Aaru.Filesystems/AppleDOS/Info.cs @@ -48,7 +48,7 @@ public sealed partial class AppleDOS int spt = imagePlugin.Info.Sectors == 455 ? 13 : 16; - ErrorNumber errno = imagePlugin.ReadSector((ulong)(17 * spt), out byte[] vtocB, out _); + ErrorNumber errno = imagePlugin.ReadSector((ulong)(17 * spt), false, out byte[] vtocB, out _); if(errno != ErrorNumber.NoError) return false; @@ -70,7 +70,7 @@ public sealed partial class AppleDOS int spt = imagePlugin.Info.Sectors == 455 ? 13 : 16; - ErrorNumber errno = imagePlugin.ReadSector((ulong)(17 * spt), out byte[] vtocB, out _); + ErrorNumber errno = imagePlugin.ReadSector((ulong)(17 * spt), false, out byte[] vtocB, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/AppleDOS/Super.cs b/Aaru.Filesystems/AppleDOS/Super.cs index 924738009..920b94493 100644 --- a/Aaru.Filesystems/AppleDOS/Super.cs +++ b/Aaru.Filesystems/AppleDOS/Super.cs @@ -75,7 +75,7 @@ public sealed partial class AppleDOS _sectorsPerTrack = _device.Info.Sectors == 455 ? 13 : 16; // Read the VTOC - ErrorNumber error = _device.ReadSector((ulong)(17 * _sectorsPerTrack), out _vtocBlocks, out _); + ErrorNumber error = _device.ReadSector((ulong)(17 * _sectorsPerTrack), false, out _vtocBlocks, out _); if(error != ErrorNumber.NoError) return error; diff --git a/Aaru.Filesystems/AppleHFS/Info.cs b/Aaru.Filesystems/AppleHFS/Info.cs index b2c55c167..2d7d3962c 100644 --- a/Aaru.Filesystems/AppleHFS/Info.cs +++ b/Aaru.Filesystems/AppleHFS/Info.cs @@ -54,7 +54,7 @@ public sealed partial class AppleHFS if(imagePlugin.Info.SectorSize is 2352 or 2448 or 2048) { - errno = imagePlugin.ReadSectors(partition.Start, 2, out mdbSector, out _); + errno = imagePlugin.ReadSectors(partition.Start, false, 2, out mdbSector, out _); if(errno != ErrorNumber.NoError) return false; @@ -74,7 +74,7 @@ public sealed partial class AppleHFS } else { - errno = imagePlugin.ReadSector(2 + partition.Start, out mdbSector, out _); + errno = imagePlugin.ReadSector(2 + partition.Start, false, out mdbSector, out _); if(errno != ErrorNumber.NoError) return false; @@ -111,7 +111,7 @@ public sealed partial class AppleHFS if(imagePlugin.Info.SectorSize is 2352 or 2448 or 2048) { - errno = imagePlugin.ReadSectors(partition.Start, 2, out byte[] tmpSector, out _); + errno = imagePlugin.ReadSectors(partition.Start, false, 2, out byte[] tmpSector, out _); if(errno != ErrorNumber.NoError) return; @@ -139,7 +139,7 @@ public sealed partial class AppleHFS } else { - errno = imagePlugin.ReadSector(2 + partition.Start, out mdbSector, out _); + errno = imagePlugin.ReadSector(2 + partition.Start, false, out mdbSector, out _); if(errno != ErrorNumber.NoError) return; @@ -147,7 +147,7 @@ public sealed partial class AppleHFS if(drSigWord == AppleCommon.HFS_MAGIC) { - errno = imagePlugin.ReadSector(partition.Start, out bbSector, out _); + errno = imagePlugin.ReadSector(partition.Start, false, out bbSector, out _); if(errno != ErrorNumber.NoError) return; } diff --git a/Aaru.Filesystems/AppleHFSPlus/Info.cs b/Aaru.Filesystems/AppleHFSPlus/Info.cs index 70bdee154..d0a303c8d 100644 --- a/Aaru.Filesystems/AppleHFSPlus/Info.cs +++ b/Aaru.Filesystems/AppleHFSPlus/Info.cs @@ -54,7 +54,7 @@ public sealed partial class AppleHFSPlus if(0x800 % imagePlugin.Info.SectorSize > 0) sectorsToRead++; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sectorsToRead, out byte[] vhSector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, false, sectorsToRead, out byte[] vhSector, out _); if(errno != ErrorNumber.NoError) return false; @@ -84,6 +84,7 @@ public sealed partial class AppleHFSPlus hfspOffset = 0; errno = imagePlugin.ReadSectors(partition.Start + hfspOffset, + false, sectorsToRead, out vhSector, out _); // Read volume header @@ -111,7 +112,7 @@ public sealed partial class AppleHFSPlus if(0x800 % imagePlugin.Info.SectorSize > 0) sectorsToRead++; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sectorsToRead, out byte[] vhSector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, false, sectorsToRead, out byte[] vhSector, out _); if(errno != ErrorNumber.NoError) return; @@ -146,6 +147,7 @@ public sealed partial class AppleHFSPlus } errno = imagePlugin.ReadSectors(partition.Start + hfspOffset, + false, sectorsToRead, out vhSector, out _); // Read volume header diff --git a/Aaru.Filesystems/AppleMFS/File.cs b/Aaru.Filesystems/AppleMFS/File.cs index 6c805161d..f688e3789 100644 --- a/Aaru.Filesystems/AppleMFS/File.cs +++ b/Aaru.Filesystems/AppleMFS/File.cs @@ -93,12 +93,14 @@ public sealed partial class AppleMFS ? _device.ReadSectorsTag((ulong)((nextBlock - 2) * _sectorsPerBlock) + _volMdb.drAlBlSt + _partitionStart, + false, (uint)_sectorsPerBlock, SectorTagType.AppleSonyTag, out byte[] sectors) : _device.ReadSectors((ulong)((nextBlock - 2) * _sectorsPerBlock) + _volMdb.drAlBlSt + _partitionStart, + false, (uint)_sectorsPerBlock, out sectors, out _); diff --git a/Aaru.Filesystems/AppleMFS/Info.cs b/Aaru.Filesystems/AppleMFS/Info.cs index 4b8e6aad7..f9b0ff116 100644 --- a/Aaru.Filesystems/AppleMFS/Info.cs +++ b/Aaru.Filesystems/AppleMFS/Info.cs @@ -48,7 +48,7 @@ public sealed partial class AppleMFS { if(2 + partition.Start >= partition.End) return false; - ErrorNumber errno = imagePlugin.ReadSector(2 + partition.Start, out byte[] mdbSector, out _); + ErrorNumber errno = imagePlugin.ReadSector(2 + partition.Start, false, out byte[] mdbSector, out _); if(errno != ErrorNumber.NoError) return false; @@ -69,11 +69,11 @@ public sealed partial class AppleMFS var mdb = new MasterDirectoryBlock(); - ErrorNumber errno = imagePlugin.ReadSector(2 + partition.Start, out byte[] mdbSector, out _); + ErrorNumber errno = imagePlugin.ReadSector(2 + partition.Start, false, out byte[] mdbSector, out _); if(errno != ErrorNumber.NoError) return; - errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bbSector, out _); + errno = imagePlugin.ReadSector(0 + partition.Start, false, out byte[] bbSector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/AppleMFS/Super.cs b/Aaru.Filesystems/AppleMFS/Super.cs index 06f5dbf1c..dfb43b6c2 100644 --- a/Aaru.Filesystems/AppleMFS/Super.cs +++ b/Aaru.Filesystems/AppleMFS/Super.cs @@ -59,11 +59,11 @@ public sealed partial class AppleMFS _volMdb = new MasterDirectoryBlock(); - ErrorNumber errno = _device.ReadSector(2 + _partitionStart, out _mdbBlocks, out _); + ErrorNumber errno = _device.ReadSector(2 + _partitionStart, false, out _mdbBlocks, out _); if(errno != ErrorNumber.NoError) return errno; - errno = _device.ReadSector(0 + _partitionStart, out _bootBlocks, out _); + errno = _device.ReadSector(0 + _partitionStart, false, out _bootBlocks, out _); if(errno != ErrorNumber.NoError) return errno; @@ -88,7 +88,11 @@ public sealed partial class AppleMFS Array.Copy(_mdbBlocks, 0x024, variableSize, 0, _volMdb.drVNSiz + 1); _volMdb.drVN = StringHandlers.PascalToString(variableSize, _encoding); - errno = _device.ReadSectors(_volMdb.drDirSt + _partitionStart, _volMdb.drBlLen, out _directoryBlocks, out _); + errno = _device.ReadSectors(_volMdb.drDirSt + _partitionStart, + false, + _volMdb.drBlLen, + out _directoryBlocks, + out _); if(errno != ErrorNumber.NoError) return errno; @@ -98,7 +102,7 @@ public sealed partial class AppleMFS int sectorsInWholeMdb = bytesInWholeMdb / (int)_device.Info.SectorSize + bytesInWholeMdb % (int)_device.Info.SectorSize; - errno = _device.ReadSectors(_partitionStart + 2, (uint)sectorsInWholeMdb, out byte[] wholeMdb, out _); + errno = _device.ReadSectors(_partitionStart + 2, false, (uint)sectorsInWholeMdb, out byte[] wholeMdb, out _); if(errno != ErrorNumber.NoError) return errno; @@ -143,15 +147,17 @@ public sealed partial class AppleMFS if(_device.Info.ReadableSectorTags.Contains(SectorTagType.AppleSonyTag)) { - _device.ReadSectorTag(2 + _partitionStart, SectorTagType.AppleSonyTag, out _mdbTags); - _device.ReadSectorTag(0 + _partitionStart, SectorTagType.AppleSonyTag, out _bootTags); + _device.ReadSectorTag(2 + _partitionStart, false, SectorTagType.AppleSonyTag, out _mdbTags); + _device.ReadSectorTag(0 + _partitionStart, false, SectorTagType.AppleSonyTag, out _bootTags); _device.ReadSectorsTag(_volMdb.drDirSt + _partitionStart, + false, _volMdb.drBlLen, SectorTagType.AppleSonyTag, out _directoryTags); _device.ReadSectorsTag(_partitionStart + 2, + false, (uint)sectorsInWholeMdb, SectorTagType.AppleSonyTag, out _bitmapTags); diff --git a/Aaru.Filesystems/AtheOS/Info.cs b/Aaru.Filesystems/AtheOS/Info.cs index f160cd7f1..02c425187 100644 --- a/Aaru.Filesystems/AtheOS/Info.cs +++ b/Aaru.Filesystems/AtheOS/Info.cs @@ -55,7 +55,7 @@ public sealed partial class AtheOS if(sector + partition.Start >= partition.End) return false; - ErrorNumber errno = imagePlugin.ReadSectors(sector + partition.Start, run, out byte[] tmp, out _); + ErrorNumber errno = imagePlugin.ReadSectors(sector + partition.Start, false, run, out byte[] tmp, out _); if(errno != ErrorNumber.NoError) return false; @@ -86,7 +86,7 @@ public sealed partial class AtheOS if(imagePlugin.Info.SectorSize < AFS_SUPERBLOCK_SIZE) run = AFS_SUPERBLOCK_SIZE / imagePlugin.Info.SectorSize; - ErrorNumber errno = imagePlugin.ReadSectors(sector + partition.Start, run, out byte[] tmp, out _); + ErrorNumber errno = imagePlugin.ReadSectors(sector + partition.Start, false, run, out byte[] tmp, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/BFS/Info.cs b/Aaru.Filesystems/BFS/Info.cs index acbc4ea3f..2511a8f89 100644 --- a/Aaru.Filesystems/BFS/Info.cs +++ b/Aaru.Filesystems/BFS/Info.cs @@ -50,7 +50,7 @@ public sealed partial class BeFS { if(2 + partition.Start >= partition.End) return false; - ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] sbSector, out _); + ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, false, out byte[] sbSector, out _); if(errno != ErrorNumber.NoError) return false; @@ -67,7 +67,7 @@ public sealed partial class BeFS if(magic == BEFS_MAGIC1 || magicBe == BEFS_MAGIC1) return true; - errno = imagePlugin.ReadSector(1 + partition.Start, out sbSector, out _); + errno = imagePlugin.ReadSector(1 + partition.Start, false, out sbSector, out _); if(errno != ErrorNumber.NoError) return false; @@ -89,7 +89,7 @@ public sealed partial class BeFS var besb = new SuperBlock(); - ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] sbSector, out _); + ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, false, out byte[] sbSector, out _); if(errno != ErrorNumber.NoError) return; @@ -101,7 +101,7 @@ public sealed partial class BeFS littleEndian = besb.magic1 == BEFS_CIGAM1; else { - errno = imagePlugin.ReadSector(1 + partition.Start, out sbSector, out _); + errno = imagePlugin.ReadSector(1 + partition.Start, false, out sbSector, out _); if(errno != ErrorNumber.NoError) return; @@ -111,7 +111,7 @@ public sealed partial class BeFS littleEndian = besb.magic1 == BEFS_CIGAM1; else if(sbSector.Length >= 0x400) { - errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] temp, out _); + errno = imagePlugin.ReadSector(0 + partition.Start, false, out byte[] temp, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/BTRFS/Info.cs b/Aaru.Filesystems/BTRFS/Info.cs index 33956ed43..19f737127 100644 --- a/Aaru.Filesystems/BTRFS/Info.cs +++ b/Aaru.Filesystems/BTRFS/Info.cs @@ -59,7 +59,7 @@ public sealed partial class BTRFS if(sbSectorOff + partition.Start >= partition.End) return false; ErrorNumber errno = - imagePlugin.ReadSectors(sbSectorOff + partition.Start, sbSectorSize, out byte[] sector, out _); + imagePlugin.ReadSectors(sbSectorOff + partition.Start, false, sbSectorSize, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -96,7 +96,7 @@ public sealed partial class BTRFS uint sbSectorSize = 0x1000 / imagePlugin.Info.SectorSize; ErrorNumber errno = - imagePlugin.ReadSectors(sbSectorOff + partition.Start, sbSectorSize, out byte[] sector, out _); + imagePlugin.ReadSectors(sbSectorOff + partition.Start, false, sbSectorSize, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/CBM/Info.cs b/Aaru.Filesystems/CBM/Info.cs index 4663e9c12..50f655980 100644 --- a/Aaru.Filesystems/CBM/Info.cs +++ b/Aaru.Filesystems/CBM/Info.cs @@ -61,7 +61,7 @@ public sealed partial class CBM if(imagePlugin.Info.Sectors == 3200) { - ErrorNumber errno = imagePlugin.ReadSector(1560, out sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(1560, false, out sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -71,7 +71,7 @@ public sealed partial class CBM } else { - ErrorNumber errno = imagePlugin.ReadSector(357, out sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(357, false, out sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -105,7 +105,7 @@ public sealed partial class CBM if(imagePlugin.Info.Sectors == 3200) { - ErrorNumber errno = imagePlugin.ReadSector(1560, out sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(1560, false, out sector, out _); if(errno != ErrorNumber.NoError) return; @@ -147,7 +147,7 @@ public sealed partial class CBM } else { - ErrorNumber errno = imagePlugin.ReadSector(357, out sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(357, false, out sector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/CBM/Super.cs b/Aaru.Filesystems/CBM/Super.cs index a73d0ea31..80edaf437 100644 --- a/Aaru.Filesystems/CBM/Super.cs +++ b/Aaru.Filesystems/CBM/Super.cs @@ -84,7 +84,7 @@ public sealed partial class CBM // Commodore 1581 if(imagePlugin.Info.Sectors == 3200) { - ErrorNumber errno = imagePlugin.ReadSector(1560, out _diskHeader, out _); + ErrorNumber errno = imagePlugin.ReadSector(1560, false, out _diskHeader, out _); if(errno != ErrorNumber.NoError) return errno; @@ -96,7 +96,7 @@ public sealed partial class CBM _bam = new byte[512]; // Got to first BAM sector - errno = imagePlugin.ReadSector(1561, out sector, out _); + errno = imagePlugin.ReadSector(1561, false, out sector, out _); if(errno != ErrorNumber.NoError) return errno; @@ -105,7 +105,7 @@ public sealed partial class CBM if(_bam[0] > 0) { // Got to next (and last) BAM sector - errno = imagePlugin.ReadSector((ulong)((_bam[0] - 1) * 40), out sector, out _); + errno = imagePlugin.ReadSector((ulong)((_bam[0] - 1) * 40), false, out sector, out _); if(errno != ErrorNumber.NoError) return errno; @@ -122,7 +122,7 @@ public sealed partial class CBM } else { - ErrorNumber errno = imagePlugin.ReadSector(357, out _bam, out _); + ErrorNumber errno = imagePlugin.ReadSector(357, false, out _bam, out _); if(errno != ErrorNumber.NoError) return errno; @@ -147,7 +147,7 @@ public sealed partial class CBM do { - ErrorNumber errno = imagePlugin.ReadSector(nextLba, out sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(nextLba, false, out sector, out _); if(errno != ErrorNumber.NoError) return errno; @@ -241,9 +241,8 @@ public sealed partial class CBM _statfs.FreeFiles--; for(var i = 0; i < dirEntry.name.Length; i++) - { - if(dirEntry.name[i] == 0xA0) dirEntry.name[i] = 0; - } + if(dirEntry.name[i] == 0xA0) + dirEntry.name[i] = 0; string name = StringHandlers.CToString(dirEntry.name, encoding); @@ -263,7 +262,7 @@ public sealed partial class CBM { if(dirEntry.firstFileBlockTrack == 0) break; - ErrorNumber errno = imagePlugin.ReadSector(nextLba, out sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(nextLba, false, out sector, out _); if(errno != ErrorNumber.NoError) break; diff --git a/Aaru.Filesystems/CPM/Info.cs b/Aaru.Filesystems/CPM/Info.cs index 122ac7011..53deba2b5 100644 --- a/Aaru.Filesystems/CPM/Info.cs +++ b/Aaru.Filesystems/CPM/Info.cs @@ -181,7 +181,7 @@ public sealed partial class CPM if(!_cpmFound) { // Read CHS = {0,0,1} - errno = imagePlugin.ReadSector(0 + partition.Start, out sector, out _); + errno = imagePlugin.ReadSector(0 + partition.Start, false, out sector, out _); if(errno == ErrorNumber.NoError) { @@ -246,6 +246,7 @@ public sealed partial class CPM var directoryLength = (uint)(((ulong)_dpb.drm + 1) * 32 / sectorSize); imagePlugin.ReadSectors(firstDirectorySector + partition.Start, + false, directoryLength, out directory, out _); @@ -311,7 +312,7 @@ public sealed partial class CPM if(!_cpmFound) { // Read CHS = {0,0,4} - errno = imagePlugin.ReadSector(3 + partition.Start, out sector, out _); + errno = imagePlugin.ReadSector(3 + partition.Start, false, out sector, out _); if(errno == ErrorNumber.NoError) { @@ -366,6 +367,7 @@ public sealed partial class CPM var directoryLength = (uint)(((ulong)_dpb.drm + 1) * 32 / sectorSize); imagePlugin.ReadSectors(firstDirectorySector + partition.Start, + false, directoryLength, out directory, out _); @@ -419,7 +421,7 @@ public sealed partial class CPM if(!_cpmFound) { // Read CHS = {0,0,1} - errno = imagePlugin.ReadSector(0 + partition.Start, out sector, out _); + errno = imagePlugin.ReadSector(0 + partition.Start, false, out sector, out _); if(errno == ErrorNumber.NoError) { @@ -874,6 +876,7 @@ public sealed partial class CPM var directoryLength = (uint)(((ulong)_dpb.drm + 1) * 32 / imagePlugin.Info.SectorSize); imagePlugin.ReadSectors(firstDirectorySector86 + partition.Start, + false, directoryLength, out directory, out _); @@ -1010,6 +1013,7 @@ public sealed partial class CPM (int)partition.Start + p / _sectorMask.Length * _sectorMask.Length + _sectorMask[p % _sectorMask.Length]), + false, out byte[] dirSector, out _); @@ -1029,8 +1033,9 @@ public sealed partial class CPM // Complement of the directory bytes if needed if(def.complement) - for(var b = 0; b < directory.Length; b++) - directory[b] = (byte)(~directory[b] & 0xFF); + { + for(var b = 0; b < directory.Length; b++) directory[b] = (byte)(~directory[b] & 0xFF); + } // Check the directory if(CheckDir(directory)) diff --git a/Aaru.Filesystems/CPM/Super.cs b/Aaru.Filesystems/CPM/Super.cs index 81b0f8f9f..592ca52d9 100644 --- a/Aaru.Filesystems/CPM/Super.cs +++ b/Aaru.Filesystems/CPM/Super.cs @@ -162,15 +162,15 @@ public sealed partial class CPM _device.ReadSector((ulong)((int)partition.Start + p / _sectorMask.Length * _sectorMask.Length + _sectorMask[p % _sectorMask.Length]), + false, out byte[] readSector, out _); if(errno != ErrorNumber.NoError) return errno; if(_workingDefinition.complement) - { - for(var b = 0; b < readSector.Length; b++) readSector[b] = (byte)(~readSector[b] & 0xFF); - } + for(var b = 0; b < readSector.Length; b++) + readSector[b] = (byte)(~readSector[b] & 0xFF); deinterleavedSectors.Add((ulong)p, readSector); } diff --git a/Aaru.Filesystems/Cram/Info.cs b/Aaru.Filesystems/Cram/Info.cs index a49115f98..0d754f35b 100644 --- a/Aaru.Filesystems/Cram/Info.cs +++ b/Aaru.Filesystems/Cram/Info.cs @@ -51,7 +51,7 @@ public sealed partial class Cram { if(partition.Start >= partition.End) return false; - ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(partition.Start, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -66,7 +66,7 @@ public sealed partial class Cram { encoding ??= Encoding.GetEncoding("iso-8859-15"); information = ""; - ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(partition.Start, false, out byte[] sector, out _); metadata = new FileSystem(); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/ECMA67/Info.cs b/Aaru.Filesystems/ECMA67/Info.cs index 0f5044084..56379e829 100644 --- a/Aaru.Filesystems/ECMA67/Info.cs +++ b/Aaru.Filesystems/ECMA67/Info.cs @@ -53,7 +53,7 @@ public sealed partial class ECMA67 if(partition.End < 8) return false; - ErrorNumber errno = imagePlugin.ReadSector(6, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(6, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -70,7 +70,7 @@ public sealed partial class ECMA67 { information = ""; metadata = new FileSystem(); - ErrorNumber errno = imagePlugin.ReadSector(6, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(6, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/EFS/Info.cs b/Aaru.Filesystems/EFS/Info.cs index 99f0636b3..97d22c242 100644 --- a/Aaru.Filesystems/EFS/Info.cs +++ b/Aaru.Filesystems/EFS/Info.cs @@ -55,7 +55,7 @@ public sealed partial class EFS if((Marshal.SizeOf() + 0x200) % imagePlugin.Info.SectorSize != 0) sbSize++; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, false, sbSize, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -82,7 +82,7 @@ public sealed partial class EFS if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + 1, sbSize, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + 1, false, sbSize, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -122,7 +122,7 @@ public sealed partial class EFS if((Marshal.SizeOf() + 0x400) % imagePlugin.Info.SectorSize != 0) sbSize++; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, false, sbSize, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return; @@ -147,7 +147,7 @@ public sealed partial class EFS if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + 1, sbSize, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + 1, false, sbSize, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/F2FS/Info.cs b/Aaru.Filesystems/F2FS/Info.cs index a4563a6ce..41ea38b0e 100644 --- a/Aaru.Filesystems/F2FS/Info.cs +++ b/Aaru.Filesystems/F2FS/Info.cs @@ -58,7 +58,7 @@ public sealed partial class F2FS if(partition.Start + sbAddr + sbSize >= partition.End) return false; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, false, sbSize, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -86,7 +86,7 @@ public sealed partial class F2FS if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, false, sbSize, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/FAT/BPB.cs b/Aaru.Filesystems/FAT/BPB.cs index 636677670..f4142fdf6 100644 --- a/Aaru.Filesystems/FAT/BPB.cs +++ b/Aaru.Filesystems/FAT/BPB.cs @@ -374,10 +374,10 @@ public sealed partial class FAT byte z80Di = bpbSector[0]; // First FAT1 sector resides at LBA 0x14 - imagePlugin.ReadSector(0x14, out byte[] fat1Sector0, out _); + imagePlugin.ReadSector(0x14, false, out byte[] fat1Sector0, out _); // First FAT2 sector resides at LBA 0x1A - imagePlugin.ReadSector(0x1A, out byte[] fat2Sector0, out _); + imagePlugin.ReadSector(0x1A, false, out byte[] fat2Sector0, out _); bool equalFatIds = fat1Sector0[0] == fat2Sector0[0] && fat1Sector0[1] == fat2Sector0[1]; // Volume is software interleaved 2:1 @@ -388,7 +388,7 @@ public sealed partial class FAT 0x17, 0x19, 0x1B, 0x1D, 0x1E, 0x20 }) { - imagePlugin.ReadSector(rootSector, out byte[] tmp, out _); + imagePlugin.ReadSector(rootSector, false, out byte[] tmp, out _); rootMs.Write(tmp, 0, tmp.Length); } @@ -449,7 +449,7 @@ public sealed partial class FAT !useExtendedBpb && !useApricotBpb) { - imagePlugin.ReadSector(1 + partition.Start, out byte[] fatSector, out _); + imagePlugin.ReadSector(1 + partition.Start, false, out byte[] fatSector, out _); switch(fatSector[0]) { @@ -807,6 +807,7 @@ public sealed partial class FAT if(apricotBpb.bootLocation > 0 && apricotBpb.bootLocation + apricotBpb.bootSize < imagePlugin.Info.Sectors) { imagePlugin.ReadSectors(apricotBpb.bootLocation, + false, (uint)(apricotBpb.sectorSize * apricotBpb.bootSize) / imagePlugin.Info.SectorSize, out fakeBpb.boot_code, out _); diff --git a/Aaru.Filesystems/FAT/Dir.cs b/Aaru.Filesystems/FAT/Dir.cs index 27e542ba1..f0b2a4b9c 100644 --- a/Aaru.Filesystems/FAT/Dir.cs +++ b/Aaru.Filesystems/FAT/Dir.cs @@ -144,6 +144,7 @@ public sealed partial class FAT for(var i = 0; i < clusters.Length; i++) { ErrorNumber errno = _image.ReadSectors(_firstClusterSector + clusters[i] * _sectorsPerCluster, + false, _sectorsPerCluster, out byte[] buffer, out _); diff --git a/Aaru.Filesystems/FAT/File.cs b/Aaru.Filesystems/FAT/File.cs index 50753b1d9..6e9ecad6e 100644 --- a/Aaru.Filesystems/FAT/File.cs +++ b/Aaru.Filesystems/FAT/File.cs @@ -55,7 +55,7 @@ public sealed partial class FAT var nextEntry = (int)(nextCluster % _fatEntriesPerSector); ulong currentSector = nextSector; - ErrorNumber errno = _image.ReadSector(currentSector, out byte[] fatData, out _); + ErrorNumber errno = _image.ReadSector(currentSector, false, out byte[] fatData, out _); if(errno != ErrorNumber.NoError) return null; @@ -67,7 +67,7 @@ public sealed partial class FAT if(currentSector != nextSector) { - errno = _image.ReadSector(nextSector, out fatData, out _); + errno = _image.ReadSector(nextSector, false, out fatData, out _); if(errno != ErrorNumber.NoError) return null; @@ -244,6 +244,7 @@ public sealed partial class FAT ErrorNumber errno = _image.ReadSectors(_firstClusterSector + mynode.Clusters[i + firstCluster] * _sectorsPerCluster, + false, _sectorsPerCluster, out byte[] buf, out _); diff --git a/Aaru.Filesystems/FAT/Info.cs b/Aaru.Filesystems/FAT/Info.cs index a3730349e..ae9d177e8 100644 --- a/Aaru.Filesystems/FAT/Info.cs +++ b/Aaru.Filesystems/FAT/Info.cs @@ -74,11 +74,12 @@ public sealed partial class FAT uint sectorsPerBpb = imagePlugin.Info.SectorSize < 512 ? 512 / imagePlugin.Info.SectorSize : 1; - ErrorNumber errno = imagePlugin.ReadSectors(0 + partition.Start, sectorsPerBpb, out byte[] bpbSector, out _); + ErrorNumber errno = + imagePlugin.ReadSectors(0 + partition.Start, false, sectorsPerBpb, out byte[] bpbSector, out _); if(errno != ErrorNumber.NoError) return false; - errno = imagePlugin.ReadSector(sectorsPerBpb + partition.Start, out byte[] fatSector, out _); + errno = imagePlugin.ReadSector(sectorsPerBpb + partition.Start, false, out byte[] fatSector, out _); if(errno != ErrorNumber.NoError) return false; @@ -238,6 +239,7 @@ public sealed partial class FAT if(16 + partition.Start <= partition.End) { errno = imagePlugin.ReadSector(16 + partition.Start, + false, out byte[] hpfsSbSector, out _); // Seek to superblock, on logical sector 16 @@ -318,12 +320,12 @@ public sealed partial class FAT byte z80Di = bpbSector[0]; // First FAT1 sector resides at LBA 0x14 - errno = imagePlugin.ReadSector(0x14, out byte[] fat1Sector0, out _); + errno = imagePlugin.ReadSector(0x14, false, out byte[] fat1Sector0, out _); if(errno != ErrorNumber.NoError) return false; // First FAT2 sector resides at LBA 0x1A - errno = imagePlugin.ReadSector(0x1A, out byte[] fat2Sector0, out _); + errno = imagePlugin.ReadSector(0x1A, false, out byte[] fat2Sector0, out _); if(errno != ErrorNumber.NoError) return false; @@ -337,7 +339,7 @@ public sealed partial class FAT 0x17, 0x19, 0x1B, 0x1D, 0x1E, 0x20 }) { - errno = imagePlugin.ReadSector(rootSector, out byte[] tmp, out _); + errno = imagePlugin.ReadSector(rootSector, false, out byte[] tmp, out _); if(errno != ErrorNumber.NoError) return false; @@ -429,7 +431,7 @@ public sealed partial class FAT AaruLogging.Debug(MODULE_NAME, Localization.Second_fat_starts_at_0, fat2SectorNo); - errno = imagePlugin.ReadSector(fat2SectorNo, out byte[] fat2Sector, out _); + errno = imagePlugin.ReadSector(fat2SectorNo, false, out byte[] fat2Sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -454,7 +456,8 @@ public sealed partial class FAT uint sectorsPerBpb = imagePlugin.Info.SectorSize < 512 ? 512 / imagePlugin.Info.SectorSize : 1; - ErrorNumber errno = imagePlugin.ReadSectors(0 + partition.Start, sectorsPerBpb, out byte[] bpbSector, out _); + ErrorNumber errno = + imagePlugin.ReadSectors(0 + partition.Start, false, sectorsPerBpb, out byte[] bpbSector, out _); if(errno != ErrorNumber.NoError) return; @@ -643,6 +646,7 @@ public sealed partial class FAT if(fat32Bpb.fsinfo_sector + partition.Start <= partition.End) { errno = imagePlugin.ReadSector(fat32Bpb.fsinfo_sector + partition.Start, + false, out byte[] fsinfoSector, out _); @@ -781,7 +785,7 @@ public sealed partial class FAT sectorsPerRealSector = fakeBpb.bps / imagePlugin.Info.SectorSize; _fatFirstSector = partition.Start + _reservedSectors * sectorsPerRealSector; - errno = imagePlugin.ReadSectors(_fatFirstSector, fakeBpb.spfat, out byte[] fatBytes, out _); + errno = imagePlugin.ReadSectors(_fatFirstSector, false, fakeBpb.spfat, out byte[] fatBytes, out _); if(errno != ErrorNumber.NoError) return; @@ -1033,6 +1037,7 @@ public sealed partial class FAT imagePlugin.Info.MetadataMediaType != MetadataMediaType.OpticalDisc) { errno = imagePlugin.ReadSectors(rootDirectorySector + partition.Start, + false, sectorsForRootDirectory, out byte[] rootDirectory, out _); @@ -1048,7 +1053,7 @@ public sealed partial class FAT 0x17, 0x19, 0x1B, 0x1D, 0x1E, 0x20 }) { - errno = imagePlugin.ReadSector(rootSector, out byte[] tmp, out _); + errno = imagePlugin.ReadSector(rootSector, false, out byte[] tmp, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/FAT/Super.cs b/Aaru.Filesystems/FAT/Super.cs index 72b92f580..d28ed8a6c 100644 --- a/Aaru.Filesystems/FAT/Super.cs +++ b/Aaru.Filesystems/FAT/Super.cs @@ -96,7 +96,8 @@ public sealed partial class FAT uint sectorsPerBpb = imagePlugin.Info.SectorSize < 512 ? 512 / imagePlugin.Info.SectorSize : 1; - ErrorNumber errno = imagePlugin.ReadSectors(0 + partition.Start, sectorsPerBpb, out byte[] bpbSector, out _); + ErrorNumber errno = + imagePlugin.ReadSectors(0 + partition.Start, false, sectorsPerBpb, out byte[] bpbSector, out _); if(errno != ErrorNumber.NoError) return errno; @@ -193,8 +194,9 @@ public sealed partial class FAT }; if((fat32Bpb.flags & 0xF8) == 0x00) - if((fat32Bpb.flags & 0x01) == 0x01) - Metadata.Dirty = true; + { + if((fat32Bpb.flags & 0x01) == 0x01) Metadata.Dirty = true; + } if((fat32Bpb.mirror_flags & 0x80) == 0x80) _useFirstFat = (fat32Bpb.mirror_flags & 0xF) != 1; @@ -224,6 +226,7 @@ public sealed partial class FAT if(fat32Bpb.fsinfo_sector + partition.Start <= partition.End) { errno = imagePlugin.ReadSector(fat32Bpb.fsinfo_sector + partition.Start, + false, out byte[] fsinfoSector, out _); @@ -325,7 +328,7 @@ public sealed partial class FAT sectorsPerRealSector = fakeBpb.bps / imagePlugin.Info.SectorSize; _fatFirstSector = partition.Start + _reservedSectors * sectorsPerRealSector; - errno = imagePlugin.ReadSectors(_fatFirstSector, fakeBpb.spfat, out byte[] fatBytes, out _); + errno = imagePlugin.ReadSectors(_fatFirstSector, false, fakeBpb.spfat, out byte[] fatBytes, out _); if(errno != ErrorNumber.NoError) return errno; @@ -458,8 +461,9 @@ public sealed partial class FAT if(fakeBpb.signature is 0x28 or 0x29 || andosOemCorrect) { if((fakeBpb.flags & 0xF8) == 0x00) - if((fakeBpb.flags & 0x01) == 0x01) - Metadata.Dirty = true; + { + if((fakeBpb.flags & 0x01) == 0x01) Metadata.Dirty = true; + } if(fakeBpb.signature == 0x29 || andosOemCorrect) { @@ -512,7 +516,7 @@ public sealed partial class FAT if(!_fat32) { _firstClusterSector = firstRootSector + sectorsForRootDirectory - _sectorsPerCluster * 2; - errno = imagePlugin.ReadSectors(firstRootSector, sectorsForRootDirectory, out rootDirectory, out _); + errno = imagePlugin.ReadSectors(firstRootSector, false, sectorsForRootDirectory, out rootDirectory, out _); if(errno != ErrorNumber.NoError) return errno; @@ -525,7 +529,7 @@ public sealed partial class FAT 0x17, 0x19, 0x1B, 0x1D, 0x1E, 0x20 }) { - errno = imagePlugin.ReadSector(rootSector, out byte[] tmp, out _); + errno = imagePlugin.ReadSector(rootSector, false, out byte[] tmp, out _); if(errno != ErrorNumber.NoError) return errno; @@ -545,6 +549,7 @@ public sealed partial class FAT foreach(uint cluster in rootDirectoryClusters) { errno = imagePlugin.ReadSectors(_firstClusterSector + cluster * _sectorsPerCluster, + false, _sectorsPerCluster, out byte[] buffer, out _); @@ -771,7 +776,7 @@ public sealed partial class FAT { AaruLogging.Debug(MODULE_NAME, Localization.Reading_FAT12); - errno = imagePlugin.ReadSectors(_fatFirstSector, _sectorsPerFat, out byte[] fatBytes, out _); + errno = imagePlugin.ReadSectors(_fatFirstSector, false, _sectorsPerFat, out byte[] fatBytes, out _); if(errno != ErrorNumber.NoError) return errno; @@ -786,7 +791,11 @@ public sealed partial class FAT firstFatEntries[pos++] = (ushort)(((fatBytes[i + 1] & 0xF0) >> 4) + (fatBytes[i + 2] << 4)); } - errno = imagePlugin.ReadSectors(_fatFirstSector + _sectorsPerFat, _sectorsPerFat, out fatBytes, out _); + errno = imagePlugin.ReadSectors(_fatFirstSector + _sectorsPerFat, + false, + _sectorsPerFat, + out fatBytes, + out _); if(errno != ErrorNumber.NoError) return errno; @@ -820,14 +829,18 @@ public sealed partial class FAT { AaruLogging.Debug(MODULE_NAME, Localization.Reading_FAT16); - errno = imagePlugin.ReadSectors(_fatFirstSector, _sectorsPerFat, out byte[] fatBytes, out _); + errno = imagePlugin.ReadSectors(_fatFirstSector, false, _sectorsPerFat, out byte[] fatBytes, out _); if(errno != ErrorNumber.NoError) return errno; AaruLogging.Debug(MODULE_NAME, Localization.Casting_FAT); firstFatEntries = MemoryMarshal.Cast(fatBytes).ToArray(); - errno = imagePlugin.ReadSectors(_fatFirstSector + _sectorsPerFat, _sectorsPerFat, out fatBytes, out _); + errno = imagePlugin.ReadSectors(_fatFirstSector + _sectorsPerFat, + false, + _sectorsPerFat, + out fatBytes, + out _); if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Filesystems/FAT/Xattr.cs b/Aaru.Filesystems/FAT/Xattr.cs index ad72ec8e4..46e146af2 100644 --- a/Aaru.Filesystems/FAT/Xattr.cs +++ b/Aaru.Filesystems/FAT/Xattr.cs @@ -48,6 +48,7 @@ public sealed partial class FAT foreach(uint cluster in rootDirectoryClusters) { ErrorNumber errno = _image.ReadSectors(_firstClusterSector + cluster * _sectorsPerCluster, + false, _sectorsPerCluster, out byte[] buffer, out _); @@ -147,6 +148,7 @@ public sealed partial class FAT foreach(uint cluster in GetClusters(_eaDirEntry.start_cluster)) { ErrorNumber errno = _image.ReadSectors(_firstClusterSector + cluster * _sectorsPerCluster, + false, _sectorsPerCluster, out byte[] buffer, out _); diff --git a/Aaru.Filesystems/FATX/Dir.cs b/Aaru.Filesystems/FATX/Dir.cs index 057413b47..ed94008df 100644 --- a/Aaru.Filesystems/FATX/Dir.cs +++ b/Aaru.Filesystems/FATX/Dir.cs @@ -112,6 +112,7 @@ public sealed partial class XboxFatPlugin { ErrorNumber errno = _imagePlugin.ReadSectors(_firstClusterSector + (clusters[i] - 1) * _sectorsPerCluster, + false, _sectorsPerCluster, out byte[] buffer, out _); diff --git a/Aaru.Filesystems/FATX/File.cs b/Aaru.Filesystems/FATX/File.cs index 1283298f0..7164aac86 100644 --- a/Aaru.Filesystems/FATX/File.cs +++ b/Aaru.Filesystems/FATX/File.cs @@ -198,6 +198,7 @@ public sealed partial class XboxFatPlugin ErrorNumber errno = _imagePlugin.ReadSectors(_firstClusterSector + (mynode.Clusters[i + firstCluster] - 1) * _sectorsPerCluster, + false, _sectorsPerCluster, out byte[] buf, out _); diff --git a/Aaru.Filesystems/FATX/Info.cs b/Aaru.Filesystems/FATX/Info.cs index 7c4af1058..dd3708df2 100644 --- a/Aaru.Filesystems/FATX/Info.cs +++ b/Aaru.Filesystems/FATX/Info.cs @@ -44,7 +44,7 @@ public sealed partial class XboxFatPlugin { if(imagePlugin.Info.SectorSize < 512) return false; - ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(partition.Start, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -64,7 +64,7 @@ public sealed partial class XboxFatPlugin var bigEndian = true; - ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(partition.Start, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/FATX/Super.cs b/Aaru.Filesystems/FATX/Super.cs index 7277646ce..c8f9ff33d 100644 --- a/Aaru.Filesystems/FATX/Super.cs +++ b/Aaru.Filesystems/FATX/Super.cs @@ -61,7 +61,7 @@ public sealed partial class XboxFatPlugin AaruLogging.Debug(MODULE_NAME, Localization.Reading_superblock); - ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(partition.Start, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return errno; @@ -146,7 +146,7 @@ public sealed partial class XboxFatPlugin AaruLogging.Debug(MODULE_NAME, Localization.FAT_is_0_sectors, fatSize); - errno = imagePlugin.ReadSectors(_fatStartSector, fatSize, out buffer, out _); + errno = imagePlugin.ReadSectors(_fatStartSector, false, fatSize, out buffer, out _); if(errno != ErrorNumber.NoError) return errno; @@ -154,9 +154,8 @@ public sealed partial class XboxFatPlugin _fat32 = MemoryMarshal.Cast(buffer).ToArray(); if(!_littleEndian) - { - for(var i = 0; i < _fat32.Length; i++) _fat32[i] = Swapping.Swap(_fat32[i]); - } + for(var i = 0; i < _fat32.Length; i++) + _fat32[i] = Swapping.Swap(_fat32[i]); AaruLogging.Debug(MODULE_NAME, "fat32[0] == FATX32_ID = {0}", _fat32[0] == FATX32_ID); @@ -178,7 +177,7 @@ public sealed partial class XboxFatPlugin AaruLogging.Debug(MODULE_NAME, Localization.FAT_is_0_sectors, fatSize); - errno = imagePlugin.ReadSectors(_fatStartSector, fatSize, out buffer, out _); + errno = imagePlugin.ReadSectors(_fatStartSector, false, fatSize, out buffer, out _); if(errno != ErrorNumber.NoError) return errno; @@ -186,9 +185,8 @@ public sealed partial class XboxFatPlugin _fat16 = MemoryMarshal.Cast(buffer).ToArray(); if(!_littleEndian) - { - for(var i = 0; i < _fat16.Length; i++) _fat16[i] = Swapping.Swap(_fat16[i]); - } + for(var i = 0; i < _fat16.Length; i++) + _fat16[i] = Swapping.Swap(_fat16[i]); AaruLogging.Debug(MODULE_NAME, "fat16[0] == FATX16_ID = {0}", _fat16[0] == FATX16_ID); @@ -215,6 +213,7 @@ public sealed partial class XboxFatPlugin for(var i = 0; i < rootDirectoryClusters.Length; i++) { errno = imagePlugin.ReadSectors(_firstClusterSector + (rootDirectoryClusters[i] - 1) * _sectorsPerCluster, + false, _sectorsPerCluster, out buffer, out _); diff --git a/Aaru.Filesystems/FFS/Info.cs b/Aaru.Filesystems/FFS/Info.cs index 40e6a458b..e02a7da06 100644 --- a/Aaru.Filesystems/FFS/Info.cs +++ b/Aaru.Filesystems/FFS/Info.cs @@ -72,7 +72,11 @@ public sealed partial class FFSPlugin foreach(ulong loc in locations.Where(loc => partition.End > partition.Start + loc + sbSizeInSectors)) { ErrorNumber errno = - imagePlugin.ReadSectors(partition.Start + loc, sbSizeInSectors, out byte[] ufsSbSectors, out _); + imagePlugin.ReadSectors(partition.Start + loc, + false, + sbSizeInSectors, + out byte[] ufsSbSectors, + out _); if(errno != ErrorNumber.NoError) continue; @@ -135,7 +139,11 @@ public sealed partial class FFSPlugin foreach(ulong loc in locations.Where(loc => partition.End > partition.Start + loc + sb_size_in_sectors)) { - errno = imagePlugin.ReadSectors(partition.Start + loc, sb_size_in_sectors, out ufs_sb_sectors, out _); + errno = imagePlugin.ReadSectors(partition.Start + loc, + false, + sb_size_in_sectors, + out ufs_sb_sectors, + out _); if(errno != ErrorNumber.NoError) continue; @@ -214,7 +222,7 @@ public sealed partial class FFSPlugin } // Fun with seeking follows on superblock reading! - errno = imagePlugin.ReadSectors(sb_offset, sb_size_in_sectors, out ufs_sb_sectors, out _); + errno = imagePlugin.ReadSectors(sb_offset, false, sb_size_in_sectors, out ufs_sb_sectors, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/Fossil/Info.cs b/Aaru.Filesystems/Fossil/Info.cs index 49772dfd1..de0b34111 100644 --- a/Aaru.Filesystems/Fossil/Info.cs +++ b/Aaru.Filesystems/Fossil/Info.cs @@ -49,7 +49,7 @@ public sealed partial class Fossil if(partition.Start + hdrSector > imagePlugin.Info.Sectors) return false; - ErrorNumber errno = imagePlugin.ReadSector(partition.Start + hdrSector, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(partition.Start + hdrSector, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -73,7 +73,7 @@ public sealed partial class Fossil ulong hdrSector = HEADER_POS / imagePlugin.Info.SectorSize; - ErrorNumber errno = imagePlugin.ReadSector(partition.Start + hdrSector, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(partition.Start + hdrSector, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return; @@ -102,7 +102,7 @@ public sealed partial class Fossil if(sbLocation <= partition.End) { - imagePlugin.ReadSector(sbLocation, out sector, out _); + imagePlugin.ReadSector(sbLocation, false, out sector, out _); SuperBlock fsb = Marshal.ByteArrayToStructureBigEndian(sector); AaruLogging.Debug(MODULE_NAME, Localization.magic_0_expected_1, fsb.magic, FOSSIL_SB_MAGIC); diff --git a/Aaru.Filesystems/HAMMER/Info.cs b/Aaru.Filesystems/HAMMER/Info.cs index 2f9501464..dc329d397 100644 --- a/Aaru.Filesystems/HAMMER/Info.cs +++ b/Aaru.Filesystems/HAMMER/Info.cs @@ -53,7 +53,7 @@ public sealed partial class HAMMER if(run + partition.Start >= partition.End) return false; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, run, out byte[] sbSector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, false, run, out byte[] sbSector, out _); if(errno != ErrorNumber.NoError) return false; @@ -76,7 +76,7 @@ public sealed partial class HAMMER if(HAMMER_VOLHDR_SIZE % imagePlugin.Info.SectorSize > 0) run++; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, run, out byte[] sbSector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, false, run, out byte[] sbSector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/HPFS/Info.cs b/Aaru.Filesystems/HPFS/Info.cs index d34694a90..e2137287b 100644 --- a/Aaru.Filesystems/HPFS/Info.cs +++ b/Aaru.Filesystems/HPFS/Info.cs @@ -55,6 +55,7 @@ public sealed partial class HPFS ErrorNumber errno = imagePlugin.ReadSector(16 + partition.Start, + false, out byte[] hpfsSbSector, out _); // Seek to superblock, on logical sector 16 @@ -78,18 +79,21 @@ public sealed partial class HPFS ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, + false, out byte[] hpfsBpbSector, out _); // Seek to BIOS parameter block, on logical sector 0 if(errno != ErrorNumber.NoError) return; errno = imagePlugin.ReadSector(16 + partition.Start, + false, out byte[] hpfsSbSector, out _); // Seek to superblock, on logical sector 16 if(errno != ErrorNumber.NoError) return; errno = imagePlugin.ReadSector(17 + partition.Start, + false, out byte[] hpfsSpSector, out _); // Seek to spareblock, on logical sector 17 diff --git a/Aaru.Filesystems/HPOFS/Info.cs b/Aaru.Filesystems/HPOFS/Info.cs index c4d54c613..34e6bbed3 100644 --- a/Aaru.Filesystems/HPOFS/Info.cs +++ b/Aaru.Filesystems/HPOFS/Info.cs @@ -53,6 +53,7 @@ public sealed partial class HPOFS ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, + false, out byte[] hpofsBpbSector, out _); // Seek to BIOS parameter block, on logical sector 0 @@ -77,18 +78,21 @@ public sealed partial class HPOFS ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, + false, out byte[] hpofsBpbSector, out _); // Seek to BIOS parameter block, on logical sector 0 if(errno != ErrorNumber.NoError) return; errno = imagePlugin.ReadSector(13 + partition.Start, + false, out byte[] medInfoSector, out _); // Seek to media information block, on logical sector 13 if(errno != ErrorNumber.NoError) return; errno = imagePlugin.ReadSector(14 + partition.Start, + false, out byte[] volInfoSector, out _); // Seek to volume information block, on logical sector 14 diff --git a/Aaru.Filesystems/ISO9660/File.cs b/Aaru.Filesystems/ISO9660/File.cs index 40c4c8a33..e2aefbcea 100644 --- a/Aaru.Filesystems/ISO9660/File.cs +++ b/Aaru.Filesystems/ISO9660/File.cs @@ -201,6 +201,7 @@ public sealed partial class ISO9660 while(leftExtentSize > 0) { ErrorNumber errno = _image.ReadSectorTag((extents[i].extent + currentExtentSector) * _blockSize / 2048, + false, SectorTagType.CdSectorSubHeader, out byte[] fullSector); @@ -324,6 +325,7 @@ public sealed partial class ISO9660 if((read + offsetInSector) % 2352 > 0) sizeInSectors++; ErrorNumber errno = _image.ReadSectorsLong((ulong)(mynode.Dentry.Extents[0].extent + firstSector), + false, (uint)sizeInSectors, out byte[] buf, out _); diff --git a/Aaru.Filesystems/ISO9660/Info.cs b/Aaru.Filesystems/ISO9660/Info.cs index 6c089b32f..b1df0949a 100644 --- a/Aaru.Filesystems/ISO9660/Info.cs +++ b/Aaru.Filesystems/ISO9660/Info.cs @@ -55,7 +55,7 @@ public sealed partial class ISO9660 if(partition.End <= 16 + partition.Start) return false; // Read to Volume Descriptor - ErrorNumber errno = imagePlugin.ReadSector(16 + partition.Start, out byte[] vdSector, out _); + ErrorNumber errno = imagePlugin.ReadSector(16 + partition.Start, false, out byte[] vdSector, out _); if(errno != ErrorNumber.NoError) return false; @@ -109,7 +109,7 @@ public sealed partial class ISO9660 ulong counter = 0; - ErrorNumber errno = imagePlugin.ReadSector(16 + partition.Start, out byte[] vdSector, out _); + ErrorNumber errno = imagePlugin.ReadSector(16 + partition.Start, false, out byte[] vdSector, out _); if(errno != ErrorNumber.NoError) return; @@ -130,7 +130,7 @@ public sealed partial class ISO9660 // Seek to Volume Descriptor AaruLogging.Debug(MODULE_NAME, Localization.Reading_sector_0, 16 + counter + partition.Start); - errno = imagePlugin.ReadSector(16 + counter + partition.Start, out byte[] vdSectorTmp, out _); + errno = imagePlugin.ReadSector(16 + counter + partition.Start, false, out byte[] vdSectorTmp, out _); if(errno != ErrorNumber.NoError) return; @@ -290,7 +290,7 @@ public sealed partial class ISO9660 if(rootLocation + rootSize < imagePlugin.Info.Sectors) { - errno = imagePlugin.ReadSectors(rootLocation, rootSize, out rootDir, out _); + errno = imagePlugin.ReadSectors(rootLocation, false, rootSize, out rootDir, out _); if(errno != ErrorNumber.NoError) return; } @@ -454,7 +454,7 @@ public sealed partial class ISO9660 0) caLen++; - errno = imagePlugin.ReadSectors(ca.block_be, caLen, out byte[] caSectors, out _); + errno = imagePlugin.ReadSectors(ca.block_be, false, caLen, out byte[] caSectors, out _); if(errno != ErrorNumber.NoError) return; @@ -531,7 +531,7 @@ public sealed partial class ISO9660 } } - errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] ipbinSector, out _); + errno = imagePlugin.ReadSector(0 + partition.Start, false, out byte[] ipbinSector, out _); if(errno != ErrorNumber.NoError) return; @@ -680,7 +680,7 @@ public sealed partial class ISO9660 if(torito != null) { - errno = imagePlugin.ReadSector(torito.Value.catalog_sector + partition.Start, out vdSector, out _); + errno = imagePlugin.ReadSector(torito.Value.catalog_sector + partition.Start, false, out vdSector, out _); if(errno != ErrorNumber.NoError) return; @@ -713,6 +713,7 @@ public sealed partial class ISO9660 if(initialEntry.load_rba + partition.Start + initialEntry.sector_count - 1 <= partition.End) { imagePlugin.ReadSectors(initialEntry.load_rba + partition.Start, + false, initialEntry.sector_count, out bootImage, out _); @@ -827,6 +828,7 @@ public sealed partial class ISO9660 if(sectionEntry.load_rba + partition.Start + sectionEntry.sector_count - 1 <= partition.End) { imagePlugin.ReadSectors(sectionEntry.load_rba + partition.Start, + false, sectionEntry.sector_count, out bootImage, out _); diff --git a/Aaru.Filesystems/ISO9660/Mode2.cs b/Aaru.Filesystems/ISO9660/Mode2.cs index e172afd07..d78f84640 100644 --- a/Aaru.Filesystems/ISO9660/Mode2.cs +++ b/Aaru.Filesystems/ISO9660/Mode2.cs @@ -58,9 +58,9 @@ public sealed partial class ISO9660 if(sectorCount == 1) { - errno = _image.ReadSectorLong(realSector, out data, out _); + errno = _image.ReadSectorLong(realSector, false, out data, out _); - if(errno != ErrorNumber.NoError) errno = _image.ReadSector(realSector, out data, out _); + if(errno != ErrorNumber.NoError) errno = _image.ReadSector(realSector, false, out data, out _); if(errno != ErrorNumber.NoError) return errno; @@ -155,9 +155,9 @@ public sealed partial class ISO9660 { ulong dstSector = realSector + 1; - errno = _image.ReadSectorLong(dstSector, out data, out _); + errno = _image.ReadSectorLong(dstSector, false, out data, out _); - if(errno != ErrorNumber.NoError) errno = _image.ReadSector(dstSector, out data, out _); + if(errno != ErrorNumber.NoError) errno = _image.ReadSector(dstSector, false, out data, out _); if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Filesystems/ISO9660/Super.cs b/Aaru.Filesystems/ISO9660/Super.cs index 89a82181e..b40266fbb 100644 --- a/Aaru.Filesystems/ISO9660/Super.cs +++ b/Aaru.Filesystems/ISO9660/Super.cs @@ -113,7 +113,7 @@ public sealed partial class ISO9660 ulong counter = 0; - ErrorNumber errno = imagePlugin.ReadSector(16 + partition.Start, out byte[] vdSector, out _); + ErrorNumber errno = imagePlugin.ReadSector(16 + partition.Start, false, out byte[] vdSector, out _); if(errno != ErrorNumber.NoError) return errno; @@ -137,7 +137,7 @@ public sealed partial class ISO9660 // Seek to Volume Descriptor AaruLogging.Debug(MODULE_NAME, Localization.Reading_sector_0, 16 + counter + partition.Start); - errno = imagePlugin.ReadSector(16 + counter + partition.Start, out byte[] vdSectorTmp, out _); + errno = imagePlugin.ReadSector(16 + counter + partition.Start, false, out byte[] vdSectorTmp, out _); if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Filesystems/ISO9660/Xattr.cs b/Aaru.Filesystems/ISO9660/Xattr.cs index 52da7d9b1..7617619cb 100644 --- a/Aaru.Filesystems/ISO9660/Xattr.cs +++ b/Aaru.Filesystems/ISO9660/Xattr.cs @@ -75,6 +75,7 @@ public sealed partial class ISO9660 return ErrorNumber.NoError; ErrorNumber errno = _image.ReadSectorTag(entry.Extents[0].extent * _blockSize / 2048, + false, SectorTagType.CdSectorSubHeader, out _); diff --git a/Aaru.Filesystems/JFS/Info.cs b/Aaru.Filesystems/JFS/Info.cs index ea13d7e6f..38cb6d703 100644 --- a/Aaru.Filesystems/JFS/Info.cs +++ b/Aaru.Filesystems/JFS/Info.cs @@ -50,7 +50,7 @@ public sealed partial class JFS if(partition.Start + bootSectors >= partition.End) return false; - ErrorNumber errno = imagePlugin.ReadSector(partition.Start + bootSectors, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(partition.Start + bootSectors, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -65,12 +65,12 @@ public sealed partial class JFS public void GetInformation(IMediaImage imagePlugin, Partition partition, Encoding encoding, out string information, out FileSystem metadata) { - encoding ??= Encoding.GetEncoding("iso-8859-15"); - information = ""; - metadata = new FileSystem(); - var sb = new StringBuilder(); + encoding ??= Encoding.GetEncoding("iso-8859-15"); + information = ""; + metadata = new FileSystem(); + var sb = new StringBuilder(); uint bootSectors = JFS_BOOT_BLOCKS_SIZE / imagePlugin.Info.SectorSize; - ErrorNumber errno = imagePlugin.ReadSector(partition.Start + bootSectors, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(partition.Start + bootSectors, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/LIF/Info.cs b/Aaru.Filesystems/LIF/Info.cs index caeb43f9e..fac13c650 100644 --- a/Aaru.Filesystems/LIF/Info.cs +++ b/Aaru.Filesystems/LIF/Info.cs @@ -48,7 +48,7 @@ public sealed partial class LIF { if(imagePlugin.Info.SectorSize < 256) return false; - ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(partition.Start, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -68,7 +68,7 @@ public sealed partial class LIF if(imagePlugin.Info.SectorSize < 256) return; - ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(partition.Start, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/LisaFS/Dir.cs b/Aaru.Filesystems/LisaFS/Dir.cs index 2925c9a6a..d7d74f61e 100644 --- a/Aaru.Filesystems/LisaFS/Dir.cs +++ b/Aaru.Filesystems/LisaFS/Dir.cs @@ -127,7 +127,7 @@ public sealed partial class LisaFS // If root catalog is not pointed in MDDF (unchecked) maybe it's always following S-Records File? for(ulong i = 0; i < _device.Info.Sectors; i++) { - errno = _device.ReadSectorTag(i, SectorTagType.AppleSonyTag, out byte[] tag); + errno = _device.ReadSectorTag(i, false, SectorTagType.AppleSonyTag, out byte[] tag); if(errno != ErrorNumber.NoError) continue; @@ -135,7 +135,7 @@ public sealed partial class LisaFS if(catTag.FileId != FILEID_CATALOG || catTag.RelPage != 0) continue; - errno = _device.ReadSectors(i, 4, out firstCatalogBlock, out _); + errno = _device.ReadSectors(i, false, 4, out firstCatalogBlock, out _); if(errno != ErrorNumber.NoError) return errno; @@ -151,6 +151,7 @@ public sealed partial class LisaFS while(prevCatalogPointer != 0xFFFFFFFF) { errno = _device.ReadSectorTag(prevCatalogPointer + _mddf.mddf_block + _volumePrefix, + false, SectorTagType.AppleSonyTag, out byte[] tag); @@ -161,6 +162,7 @@ public sealed partial class LisaFS if(prevTag.FileId != FILEID_CATALOG) return ErrorNumber.InvalidArgument; errno = _device.ReadSectors(prevCatalogPointer + _mddf.mddf_block + _volumePrefix, + false, 4, out firstCatalogBlock, out _); @@ -178,6 +180,7 @@ public sealed partial class LisaFS while(nextCatalogPointer != 0xFFFFFFFF) { errno = _device.ReadSectorTag(nextCatalogPointer + _mddf.mddf_block + _volumePrefix, + false, SectorTagType.AppleSonyTag, out byte[] tag); @@ -188,6 +191,7 @@ public sealed partial class LisaFS if(nextTag.FileId != FILEID_CATALOG) return ErrorNumber.InvalidArgument; errno = _device.ReadSectors(nextCatalogPointer + _mddf.mddf_block + _volumePrefix, + false, 4, out byte[] nextCatalogBlock, out _); diff --git a/Aaru.Filesystems/LisaFS/Extent.cs b/Aaru.Filesystems/LisaFS/Extent.cs index 23be7f9df..5b020fe7a 100644 --- a/Aaru.Filesystems/LisaFS/Extent.cs +++ b/Aaru.Filesystems/LisaFS/Extent.cs @@ -75,7 +75,7 @@ public sealed partial class LisaFS for(ulong i = 0; i < _device.Info.Sectors; i++) { - errno = _device.ReadSectorTag(i, SectorTagType.AppleSonyTag, out tag); + errno = _device.ReadSectorTag(i, false, SectorTagType.AppleSonyTag, out tag); if(errno != ErrorNumber.NoError) continue; @@ -93,7 +93,7 @@ public sealed partial class LisaFS } // Checks that the sector tag indicates its the Extents File we are searching for - errno = _device.ReadSectorTag(ptr, SectorTagType.AppleSonyTag, out tag); + errno = _device.ReadSectorTag(ptr, false, SectorTagType.AppleSonyTag, out tag); if(errno != ErrorNumber.NoError) return errno; @@ -102,8 +102,8 @@ public sealed partial class LisaFS if(extTag.FileId != (short)(-1 * fileId)) return ErrorNumber.NoSuchFile; errno = _mddf.fsversion == LISA_V1 - ? _device.ReadSectors(ptr, 2, out byte[] sector, out _) - : _device.ReadSector(ptr, out sector, out _); + ? _device.ReadSectors(ptr, false, 2, out byte[] sector, out _) + : _device.ReadSector(ptr, false, out sector, out _); if(errno != ErrorNumber.NoError) return errno; @@ -307,6 +307,7 @@ public sealed partial class LisaFS // Searches the S-Records place using MDDF pointers ErrorNumber errno = _device.ReadSectors(_mddf.srec_ptr + _mddf.mddf_block + _volumePrefix, + false, _mddf.srec_len, out byte[] sectors, out _); diff --git a/Aaru.Filesystems/LisaFS/File.cs b/Aaru.Filesystems/LisaFS/File.cs index 01d398be6..35542eb09 100644 --- a/Aaru.Filesystems/LisaFS/File.cs +++ b/Aaru.Filesystems/LisaFS/File.cs @@ -105,8 +105,9 @@ public sealed partial class LisaFS if(!_mounted || !_debug) return ErrorNumber.AccessDenied; if(fileId is > 4 or <= 0) - if(fileId != FILEID_BOOT_SIGNED && fileId != FILEID_LOADER_SIGNED) - return ErrorNumber.InvalidArgument; + { + if(fileId != FILEID_BOOT_SIGNED && fileId != FILEID_LOADER_SIGNED) return ErrorNumber.InvalidArgument; + } if(_systemFileCache.TryGetValue(fileId, out buf) && !tags) return ErrorNumber.NoError; @@ -117,6 +118,7 @@ public sealed partial class LisaFS if(!tags) { errno = _device.ReadSectors(_mddf.mddf_block + _volumePrefix + _mddf.srec_ptr, + false, _mddf.srec_len, out buf, out _); @@ -129,6 +131,7 @@ public sealed partial class LisaFS } errno = _device.ReadSectorsTag(_mddf.mddf_block + _volumePrefix + _mddf.srec_ptr, + false, _mddf.srec_len, SectorTagType.AppleSonyTag, out buf); @@ -141,7 +144,7 @@ public sealed partial class LisaFS // Should be enough to check 100 sectors? for(ulong i = 0; i < 100; i++) { - errno = _device.ReadSectorTag(i, SectorTagType.AppleSonyTag, out byte[] tag); + errno = _device.ReadSectorTag(i, false, SectorTagType.AppleSonyTag, out byte[] tag); if(errno != ErrorNumber.NoError) continue; @@ -157,7 +160,7 @@ public sealed partial class LisaFS // Should be enough to check 100 sectors? for(ulong i = 0; i < 100; i++) { - errno = _device.ReadSectorTag(i, SectorTagType.AppleSonyTag, out byte[] tag); + errno = _device.ReadSectorTag(i, false, SectorTagType.AppleSonyTag, out byte[] tag); if(errno != ErrorNumber.NoError) continue; @@ -166,8 +169,8 @@ public sealed partial class LisaFS if(sysTag.FileId != fileId) continue; errno = !tags - ? _device.ReadSector(i, out byte[] sector, out _) - : _device.ReadSectorTag(i, SectorTagType.AppleSonyTag, out sector); + ? _device.ReadSector(i, false, out byte[] sector, out _) + : _device.ReadSectorTag(i, false, SectorTagType.AppleSonyTag, out sector); if(errno != ErrorNumber.NoError) continue; @@ -306,12 +309,14 @@ public sealed partial class LisaFS ? _device.ReadSectors((ulong)file.extents[i].start + _mddf.mddf_block + _volumePrefix, + false, (uint)file.extents[i].length, out byte[] sector, out _) : _device.ReadSectorsTag((ulong)file.extents[i].start + _mddf.mddf_block + _volumePrefix, + false, (uint)file.extents[i].length, SectorTagType.AppleSonyTag, out sector); @@ -325,8 +330,9 @@ public sealed partial class LisaFS if(!tags) { if(_fileSizeCache.TryGetValue(fileId, out int realSize)) - if(realSize > temp.Length) - AaruLogging.Error(Localization.File_0_gets_truncated, fileId); + { + if(realSize > temp.Length) AaruLogging.Error(Localization.File_0_gets_truncated, fileId); + } buf = temp; diff --git a/Aaru.Filesystems/LisaFS/Info.cs b/Aaru.Filesystems/LisaFS/Info.cs index ac22ccc7d..21a979274 100644 --- a/Aaru.Filesystems/LisaFS/Info.cs +++ b/Aaru.Filesystems/LisaFS/Info.cs @@ -57,7 +57,7 @@ public sealed partial class LisaFS // LisaOS searches sectors until tag tells MDDF resides there, so we'll search 100 sectors for(var i = 0; i < 100; i++) { - ErrorNumber errno = imagePlugin.ReadSectorTag((ulong)i, SectorTagType.AppleSonyTag, out byte[] tag); + ErrorNumber errno = imagePlugin.ReadSectorTag((ulong)i, false, SectorTagType.AppleSonyTag, out byte[] tag); if(errno != ErrorNumber.NoError) continue; @@ -69,7 +69,7 @@ public sealed partial class LisaFS if(searchTag.FileId != FILEID_MDDF) continue; - errno = imagePlugin.ReadSector((ulong)i, out byte[] sector, out _); + errno = imagePlugin.ReadSector((ulong)i, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) continue; @@ -134,7 +134,7 @@ public sealed partial class LisaFS // LisaOS searches sectors until tag tells MDDF resides there, so we'll search 100 sectors for(var i = 0; i < 100; i++) { - ErrorNumber errno = imagePlugin.ReadSectorTag((ulong)i, SectorTagType.AppleSonyTag, out byte[] tag); + ErrorNumber errno = imagePlugin.ReadSectorTag((ulong)i, false, SectorTagType.AppleSonyTag, out byte[] tag); if(errno != ErrorNumber.NoError) continue; @@ -146,7 +146,7 @@ public sealed partial class LisaFS if(searchTag.FileId != FILEID_MDDF) continue; - errno = imagePlugin.ReadSector((ulong)i, out byte[] sector, out _); + errno = imagePlugin.ReadSector((ulong)i, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) continue; diff --git a/Aaru.Filesystems/LisaFS/Super.cs b/Aaru.Filesystems/LisaFS/Super.cs index 450ddb8df..a65c5fc7a 100644 --- a/Aaru.Filesystems/LisaFS/Super.cs +++ b/Aaru.Filesystems/LisaFS/Super.cs @@ -78,7 +78,7 @@ public sealed partial class LisaFS // LisaOS searches sectors until tag tells MDDF resides there, so we'll search 100 sectors for(ulong i = 0; i < 100; i++) { - ErrorNumber errno = _device.ReadSectorTag(i, SectorTagType.AppleSonyTag, out byte[] tag); + ErrorNumber errno = _device.ReadSectorTag(i, false, SectorTagType.AppleSonyTag, out byte[] tag); if(errno != ErrorNumber.NoError) continue; @@ -92,7 +92,7 @@ public sealed partial class LisaFS if(searchTag.FileId != FILEID_MDDF) continue; _devTagSize = tag.Length; - errno = _device.ReadSector(i, out byte[] sector, out _); + errno = _device.ReadSector(i, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Filesystems/Locus/Info.cs b/Aaru.Filesystems/Locus/Info.cs index d4c8c4930..f75d755e7 100644 --- a/Aaru.Filesystems/Locus/Info.cs +++ b/Aaru.Filesystems/Locus/Info.cs @@ -72,7 +72,8 @@ public sealed partial class Locus if(partition.Start + location + sbSize >= imagePlugin.Info.Sectors) break; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + location, sbSize, out byte[] sector, out _); + ErrorNumber errno = + imagePlugin.ReadSectors(partition.Start + location, false, sbSize, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -107,7 +108,7 @@ public sealed partial class Locus if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + location, sbSize, out sector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + location, false, sbSize, out sector, out _); if(errno != ErrorNumber.NoError) continue; diff --git a/Aaru.Filesystems/MicroDOS/Info.cs b/Aaru.Filesystems/MicroDOS/Info.cs index 133fe3df9..faca7b731 100644 --- a/Aaru.Filesystems/MicroDOS/Info.cs +++ b/Aaru.Filesystems/MicroDOS/Info.cs @@ -54,7 +54,7 @@ public sealed partial class MicroDOS if(imagePlugin.Info.SectorSize < 512) return false; - ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bk0, out _); + ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, false, out byte[] bk0, out _); if(errno != ErrorNumber.NoError) return false; @@ -72,7 +72,7 @@ public sealed partial class MicroDOS var sb = new StringBuilder(); - ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bk0, out _); + ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, false, out byte[] bk0, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/MinixFS/Info.cs b/Aaru.Filesystems/MinixFS/Info.cs index 53d5be88d..856ee94ee 100644 --- a/Aaru.Filesystems/MinixFS/Info.cs +++ b/Aaru.Filesystems/MinixFS/Info.cs @@ -57,7 +57,7 @@ public sealed partial class MinixFS if(sector + partition.Start >= partition.End) return false; - ErrorNumber errno = imagePlugin.ReadSector(sector + partition.Start, out byte[] minixSbSector, out _); + ErrorNumber errno = imagePlugin.ReadSector(sector + partition.Start, false, out byte[] minixSbSector, out _); if(errno != ErrorNumber.NoError) return false; @@ -107,7 +107,7 @@ public sealed partial class MinixFS var minix3 = false; int filenamesize; string minixVersion; - ErrorNumber errno = imagePlugin.ReadSector(sector + partition.Start, out byte[] minixSbSector, out _); + ErrorNumber errno = imagePlugin.ReadSector(sector + partition.Start, false, out byte[] minixSbSector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/NILFS2/Info.cs b/Aaru.Filesystems/NILFS2/Info.cs index d3a4acb42..c8dbf932a 100644 --- a/Aaru.Filesystems/NILFS2/Info.cs +++ b/Aaru.Filesystems/NILFS2/Info.cs @@ -58,7 +58,7 @@ public sealed partial class NILFS2 if(partition.Start + sbAddr + sbSize >= partition.End) return false; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, false, sbSize, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -87,7 +87,7 @@ public sealed partial class NILFS2 if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, false, sbSize, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/NTFS/Info.cs b/Aaru.Filesystems/NTFS/Info.cs index f332c8c8d..de6f3465d 100644 --- a/Aaru.Filesystems/NTFS/Info.cs +++ b/Aaru.Filesystems/NTFS/Info.cs @@ -51,7 +51,7 @@ public sealed partial class NTFS var eigthBytes = new byte[8]; - ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] ntfsBpb, out _); + ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, false, out byte[] ntfsBpb, out _); if(errno != ErrorNumber.NoError) return false; @@ -80,7 +80,7 @@ public sealed partial class NTFS var sb = new StringBuilder(); - ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] ntfsBpb, out _); + ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, false, out byte[] ntfsBpb, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/Nintendo/Info.cs b/Aaru.Filesystems/Nintendo/Info.cs index eb97171c0..a3402aa2d 100644 --- a/Aaru.Filesystems/Nintendo/Info.cs +++ b/Aaru.Filesystems/Nintendo/Info.cs @@ -50,7 +50,8 @@ public sealed partial class NintendoPlugin if(imagePlugin.Info.Sectors * imagePlugin.Info.SectorSize < 0x50000) return false; - ErrorNumber errno = imagePlugin.ReadSectors(0, 0x50000 / imagePlugin.Info.SectorSize, out byte[] header, out _); + ErrorNumber errno = + imagePlugin.ReadSectors(0, false, 0x50000 / imagePlugin.Info.SectorSize, out byte[] header, out _); if(errno != ErrorNumber.NoError) return false; @@ -71,7 +72,8 @@ public sealed partial class NintendoPlugin var fields = new NintendoFields(); - ErrorNumber errno = imagePlugin.ReadSectors(0, 0x50000 / imagePlugin.Info.SectorSize, out byte[] header, out _); + ErrorNumber errno = + imagePlugin.ReadSectors(0, false, 0x50000 / imagePlugin.Info.SectorSize, out byte[] header, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/ODS/Info.cs b/Aaru.Filesystems/ODS/Info.cs index 6917fd2ed..cb40beccb 100644 --- a/Aaru.Filesystems/ODS/Info.cs +++ b/Aaru.Filesystems/ODS/Info.cs @@ -64,7 +64,7 @@ public sealed partial class ODS if(imagePlugin.Info.SectorSize < 512) return false; var magicB = new byte[12]; - ErrorNumber errno = imagePlugin.ReadSector(1 + partition.Start, out byte[] hbSector, out _); + ErrorNumber errno = imagePlugin.ReadSector(1 + partition.Start, false, out byte[] hbSector, out _); if(errno != ErrorNumber.NoError) return false; @@ -80,7 +80,7 @@ public sealed partial class ODS if(hbSector.Length < 0x400) return false; - errno = imagePlugin.ReadSector(partition.Start, out hbSector, out _); + errno = imagePlugin.ReadSector(partition.Start, false, out hbSector, out _); if(errno != ErrorNumber.NoError) return false; @@ -102,7 +102,7 @@ public sealed partial class ODS var sb = new StringBuilder(); - ErrorNumber errno = imagePlugin.ReadSector(1 + partition.Start, out byte[] hbSector, out _); + ErrorNumber errno = imagePlugin.ReadSector(1 + partition.Start, false, out byte[] hbSector, out _); if(errno != ErrorNumber.NoError) return; @@ -115,7 +115,7 @@ public sealed partial class ODS { if(hbSector.Length < 0x400) return; - errno = imagePlugin.ReadSector(partition.Start, out byte[] tmp, out _); + errno = imagePlugin.ReadSector(partition.Start, false, out byte[] tmp, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/Opera/Dir.cs b/Aaru.Filesystems/Opera/Dir.cs index 460682a85..245a91688 100644 --- a/Aaru.Filesystems/Opera/Dir.cs +++ b/Aaru.Filesystems/Opera/Dir.cs @@ -49,6 +49,7 @@ public sealed partial class OperaFS do { ErrorNumber errno = _image.ReadSectors((ulong)(nextBlock * _volumeBlockSizeRatio), + false, _volumeBlockSizeRatio, out byte[] data, out _); diff --git a/Aaru.Filesystems/Opera/File.cs b/Aaru.Filesystems/Opera/File.cs index 4260c04cd..0db88d433 100644 --- a/Aaru.Filesystems/Opera/File.cs +++ b/Aaru.Filesystems/Opera/File.cs @@ -163,6 +163,7 @@ public sealed partial class OperaFS fileBlockSizeRatio = mynode.Dentry.Entry.block_size / _image.Info.SectorSize; ErrorNumber errno = _image.ReadSectors((ulong)(mynode.Dentry.Pointers[0] + firstBlock * fileBlockSizeRatio), + false, (uint)(sizeInBlocks * fileBlockSizeRatio), out byte[] buf, out _); diff --git a/Aaru.Filesystems/Opera/Info.cs b/Aaru.Filesystems/Opera/Info.cs index c12914b6e..f91bb7f4c 100644 --- a/Aaru.Filesystems/Opera/Info.cs +++ b/Aaru.Filesystems/Opera/Info.cs @@ -45,7 +45,7 @@ public sealed partial class OperaFS { if(2 + partition.Start >= partition.End) return false; - ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] sbSector, out _); + ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, false, out byte[] sbSector, out _); if(errno != ErrorNumber.NoError) return false; @@ -70,7 +70,7 @@ public sealed partial class OperaFS metadata = new FileSystem(); var superBlockmetadata = new StringBuilder(); - ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] sbSector, out _); + ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, false, out byte[] sbSector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/Opera/Super.cs b/Aaru.Filesystems/Opera/Super.cs index 561abff57..3afad8c25 100644 --- a/Aaru.Filesystems/Opera/Super.cs +++ b/Aaru.Filesystems/Opera/Super.cs @@ -53,7 +53,7 @@ public sealed partial class OperaFS if(options.TryGetValue("debug", out string debugString)) bool.TryParse(debugString, out _debug); - ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] sbSector, out _); + ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, false, out byte[] sbSector, out _); if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Filesystems/PCEngine/Info.cs b/Aaru.Filesystems/PCEngine/Info.cs index e1e3c0af7..c662bb6f9 100644 --- a/Aaru.Filesystems/PCEngine/Info.cs +++ b/Aaru.Filesystems/PCEngine/Info.cs @@ -51,7 +51,7 @@ public sealed partial class PCEnginePlugin if(2 + partition.Start >= partition.End) return false; var systemDescriptor = new byte[23]; - ErrorNumber errno = imagePlugin.ReadSector(1 + partition.Start, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(1 + partition.Start, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; diff --git a/Aaru.Filesystems/PCFX/Info.cs b/Aaru.Filesystems/PCFX/Info.cs index 1395c8eb4..9044554b1 100644 --- a/Aaru.Filesystems/PCFX/Info.cs +++ b/Aaru.Filesystems/PCFX/Info.cs @@ -54,7 +54,7 @@ public sealed partial class PCFX if(2 + partition.Start >= partition.End || imagePlugin.Info.MetadataMediaType != MetadataMediaType.OpticalDisc) return false; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, 2, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, false, 2, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -72,7 +72,7 @@ public sealed partial class PCFX information = ""; metadata = new FileSystem(); - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, 2, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, false, 2, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/PFS/Info.cs b/Aaru.Filesystems/PFS/Info.cs index d3411b0d1..c10ca3e97 100644 --- a/Aaru.Filesystems/PFS/Info.cs +++ b/Aaru.Filesystems/PFS/Info.cs @@ -48,7 +48,7 @@ public sealed partial class PFS { if(partition.Length < 3) return false; - ErrorNumber errno = imagePlugin.ReadSector(2 + partition.Start, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(2 + partition.Start, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -64,7 +64,7 @@ public sealed partial class PFS information = ""; encoding ??= Encoding.GetEncoding("iso-8859-1"); metadata = new FileSystem(); - ErrorNumber errno = imagePlugin.ReadSector(2 + partition.Start, out byte[] rootBlockSector, out _); + ErrorNumber errno = imagePlugin.ReadSector(2 + partition.Start, false, out byte[] rootBlockSector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/ProDOS/Info.cs b/Aaru.Filesystems/ProDOS/Info.cs index 35d965fb2..4e2f87066 100644 --- a/Aaru.Filesystems/ProDOS/Info.cs +++ b/Aaru.Filesystems/ProDOS/Info.cs @@ -60,6 +60,7 @@ public sealed partial class ProDOSPlugin // Blocks 0 and 1 are boot code ErrorNumber errno = imagePlugin.ReadSectors(2 * multiplier + partition.Start, + false, multiplier, out byte[] rootDirectoryKeyBlock, out _); @@ -70,7 +71,7 @@ public sealed partial class ProDOSPlugin if(imagePlugin.Info.SectorSize is 2352 or 2448 or 2048) { - errno = imagePlugin.ReadSectors(partition.Start, 2, out byte[] tmp, out _); + errno = imagePlugin.ReadSectors(partition.Start, false, 2, out byte[] tmp, out _); if(errno != ErrorNumber.NoError) return false; @@ -141,6 +142,7 @@ public sealed partial class ProDOSPlugin // Blocks 0 and 1 are boot code ErrorNumber errno = imagePlugin.ReadSectors(2 * multiplier + partition.Start, + false, multiplier, out byte[] rootDirectoryKeyBlockBytes, out _); @@ -151,7 +153,7 @@ public sealed partial class ProDOSPlugin if(imagePlugin.Info.SectorSize is 2352 or 2448 or 2048) { - errno = imagePlugin.ReadSectors(partition.Start, 2, out byte[] tmp, out _); + errno = imagePlugin.ReadSectors(partition.Start, false, 2, out byte[] tmp, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/QNX4/Info.cs b/Aaru.Filesystems/QNX4/Info.cs index 5b617ebde..cae8d05fa 100644 --- a/Aaru.Filesystems/QNX4/Info.cs +++ b/Aaru.Filesystems/QNX4/Info.cs @@ -49,7 +49,7 @@ public sealed partial class QNX4 { if(partition.Start + 1 >= imagePlugin.Info.Sectors) return false; - ErrorNumber errno = imagePlugin.ReadSector(partition.Start + 1, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(partition.Start + 1, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -88,7 +88,7 @@ public sealed partial class QNX4 { information = ""; metadata = new FileSystem(); - ErrorNumber errno = imagePlugin.ReadSector(partition.Start + 1, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(partition.Start + 1, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/QNX6/Info.cs b/Aaru.Filesystems/QNX6/Info.cs index 37253bf7e..f13a9a42b 100644 --- a/Aaru.Filesystems/QNX6/Info.cs +++ b/Aaru.Filesystems/QNX6/Info.cs @@ -49,11 +49,11 @@ public sealed partial class QNX6 if(partition.Start + bootSectors + sectors >= partition.End) return false; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sectors, out byte[] audiSector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, false, sectors, out byte[] audiSector, out _); if(errno != ErrorNumber.NoError) return false; - errno = imagePlugin.ReadSectors(partition.Start + bootSectors, sectors, out byte[] sector, out _); + errno = imagePlugin.ReadSectors(partition.Start + bootSectors, false, sectors, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -76,11 +76,11 @@ public sealed partial class QNX6 uint sectors = QNX6_SUPER_BLOCK_SIZE / imagePlugin.Info.SectorSize; uint bootSectors = QNX6_BOOT_BLOCKS_SIZE / imagePlugin.Info.SectorSize; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sectors, out byte[] audiSector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, false, sectors, out byte[] audiSector, out _); if(errno != ErrorNumber.NoError) return; - errno = imagePlugin.ReadSectors(partition.Start + bootSectors, sectors, out byte[] sector, out _); + errno = imagePlugin.ReadSectors(partition.Start + bootSectors, false, sectors, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/RBF/Info.cs b/Aaru.Filesystems/RBF/Info.cs index bf6dcf441..77c06a693 100644 --- a/Aaru.Filesystems/RBF/Info.cs +++ b/Aaru.Filesystems/RBF/Info.cs @@ -63,7 +63,8 @@ public sealed partial class RBF if(partition.Start + location + sbSize >= imagePlugin.Info.Sectors) break; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + location, sbSize, out byte[] sector, out _); + ErrorNumber errno = + imagePlugin.ReadSectors(partition.Start + location, false, sbSize, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -109,7 +110,8 @@ public sealed partial class RBF if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + location, sbSize, out byte[] sector, out _); + ErrorNumber errno = + imagePlugin.ReadSectors(partition.Start + location, false, sbSize, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/RT11/Info.cs b/Aaru.Filesystems/RT11/Info.cs index f67f302ec..33d1787d4 100644 --- a/Aaru.Filesystems/RT11/Info.cs +++ b/Aaru.Filesystems/RT11/Info.cs @@ -55,7 +55,7 @@ public sealed partial class RT11 if(1 + partition.Start >= partition.End) return false; var magicB = new byte[12]; - ErrorNumber errno = imagePlugin.ReadSector(1 + partition.Start, out byte[] hbSector, out _); + ErrorNumber errno = imagePlugin.ReadSector(1 + partition.Start, false, out byte[] hbSector, out _); if(errno != ErrorNumber.NoError) return false; @@ -77,7 +77,7 @@ public sealed partial class RT11 var sb = new StringBuilder(); - ErrorNumber errno = imagePlugin.ReadSector(1 + partition.Start, out byte[] hbSector, out _); + ErrorNumber errno = imagePlugin.ReadSector(1 + partition.Start, false, out byte[] hbSector, out _); if(errno != ErrorNumber.NoError) return; @@ -108,7 +108,7 @@ public sealed partial class RT11 sb.AppendFormat(Localization.Volume_label_0, encoding.GetString(homeblock.volname).TrimEnd()).AppendLine(); sb.AppendFormat(Localization.Checksum_0_calculated_1, homeblock.checksum, check).AppendLine(); - imagePlugin.ReadSector(0, out byte[] bootBlock, out _); + imagePlugin.ReadSector(0, false, out byte[] bootBlock, out _); metadata = new FileSystem { diff --git a/Aaru.Filesystems/ReFS/Info.cs b/Aaru.Filesystems/ReFS/Info.cs index d224a5c1d..2e1f35bfc 100644 --- a/Aaru.Filesystems/ReFS/Info.cs +++ b/Aaru.Filesystems/ReFS/Info.cs @@ -53,7 +53,7 @@ public sealed partial class ReFS if(partition.Start + sbSize >= partition.End) return false; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, false, sbSize, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -79,7 +79,7 @@ public sealed partial class ReFS if(partition.Start + sbSize >= partition.End) return; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, false, sbSize, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/Reiser/Info.cs b/Aaru.Filesystems/Reiser/Info.cs index e5d2a7577..a652fc075 100644 --- a/Aaru.Filesystems/Reiser/Info.cs +++ b/Aaru.Filesystems/Reiser/Info.cs @@ -57,7 +57,7 @@ public sealed partial class Reiser if(partition.Start + sbAddr + sbSize >= partition.End) return false; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, false, sbSize, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -88,7 +88,7 @@ public sealed partial class Reiser if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, false, sbSize, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/Reiser4/Info.cs b/Aaru.Filesystems/Reiser4/Info.cs index 89d8c8d84..4a4c63037 100644 --- a/Aaru.Filesystems/Reiser4/Info.cs +++ b/Aaru.Filesystems/Reiser4/Info.cs @@ -57,7 +57,7 @@ public sealed partial class Reiser4 if(partition.Start + sbAddr + sbSize >= partition.End) return false; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, false, sbSize, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -86,7 +86,7 @@ public sealed partial class Reiser4 if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, false, sbSize, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/SFS/Info.cs b/Aaru.Filesystems/SFS/Info.cs index 522397816..0febbe5e4 100644 --- a/Aaru.Filesystems/SFS/Info.cs +++ b/Aaru.Filesystems/SFS/Info.cs @@ -46,7 +46,7 @@ public sealed partial class SFS { if(partition.Start >= partition.End) return false; - ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(partition.Start, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -61,7 +61,7 @@ public sealed partial class SFS { information = ""; metadata = new FileSystem(); - ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] rootBlockSector, out _); + ErrorNumber errno = imagePlugin.ReadSector(partition.Start, false, out byte[] rootBlockSector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/SolarFS/Info.cs b/Aaru.Filesystems/SolarFS/Info.cs index f6dc3f09b..b6f168d8e 100644 --- a/Aaru.Filesystems/SolarFS/Info.cs +++ b/Aaru.Filesystems/SolarFS/Info.cs @@ -49,7 +49,7 @@ public sealed partial class SolarFS { if(2 + partition.Start >= partition.End) return false; - ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bpb, out _); + ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, false, out byte[] bpb, out _); if(errno != ErrorNumber.NoError) return false; @@ -71,7 +71,7 @@ public sealed partial class SolarFS metadata = new FileSystem(); var sb = new StringBuilder(); - ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bpbSector, out _); + ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, false, out byte[] bpbSector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/Squash/Info.cs b/Aaru.Filesystems/Squash/Info.cs index ead7e9a20..04c922cef 100644 --- a/Aaru.Filesystems/Squash/Info.cs +++ b/Aaru.Filesystems/Squash/Info.cs @@ -47,7 +47,7 @@ public sealed partial class Squash { if(partition.Start >= partition.End) return false; - ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(partition.Start, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -62,7 +62,7 @@ public sealed partial class Squash { information = ""; metadata = new FileSystem(); - ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(partition.Start, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/SysV/Info.cs b/Aaru.Filesystems/SysV/Info.cs index 9ab3af9b3..26387def2 100644 --- a/Aaru.Filesystems/SysV/Info.cs +++ b/Aaru.Filesystems/SysV/Info.cs @@ -84,8 +84,11 @@ public sealed partial class SysVfs foreach(int i in locations.TakeWhile(i => (ulong)i + partition.Start + sb_size_in_sectors < imagePlugin.Info.Sectors)) { - ErrorNumber errno = - imagePlugin.ReadSectors((ulong)i + partition.Start, sb_size_in_sectors, out byte[] sb_sector, out _); + ErrorNumber errno = imagePlugin.ReadSectors((ulong)i + partition.Start, + false, + sb_size_in_sectors, + out byte[] sb_sector, + out _); if(errno != ErrorNumber.NoError || sb_sector.Length < 0x400) continue; @@ -186,7 +189,11 @@ public sealed partial class SysVfs foreach(int i in locations) { - errno = imagePlugin.ReadSectors((ulong)i + partition.Start, sb_size_in_sectors, out sb_sector, out _); + errno = imagePlugin.ReadSectors((ulong)i + partition.Start, + false, + sb_size_in_sectors, + out sb_sector, + out _); if(errno != ErrorNumber.NoError) continue; @@ -320,7 +327,12 @@ public sealed partial class SysVfs { var xenix_strings = new byte[6]; var xnx_sb = new XenixSuperBlock(); - errno = imagePlugin.ReadSectors((ulong)start + partition.Start, sb_size_in_sectors, out sb_sector, out _); + + errno = imagePlugin.ReadSectors((ulong)start + partition.Start, + false, + sb_size_in_sectors, + out sb_sector, + out _); if(errno != ErrorNumber.NoError) return; @@ -490,7 +502,11 @@ public sealed partial class SysVfs if(sysv) { - errno = imagePlugin.ReadSectors((ulong)start + partition.Start, sb_size_in_sectors, out sb_sector, out _); + errno = imagePlugin.ReadSectors((ulong)start + partition.Start, + false, + sb_size_in_sectors, + out sb_sector, + out _); if(errno != ErrorNumber.NoError) return; @@ -655,7 +671,11 @@ public sealed partial class SysVfs if(coherent) { - errno = imagePlugin.ReadSectors((ulong)start + partition.Start, sb_size_in_sectors, out sb_sector, out _); + errno = imagePlugin.ReadSectors((ulong)start + partition.Start, + false, + sb_size_in_sectors, + out sb_sector, + out _); if(errno != ErrorNumber.NoError) return; @@ -728,7 +748,11 @@ public sealed partial class SysVfs if(sys7th) { - errno = imagePlugin.ReadSectors((ulong)start + partition.Start, sb_size_in_sectors, out sb_sector, out _); + errno = imagePlugin.ReadSectors((ulong)start + partition.Start, + false, + sb_size_in_sectors, + out sb_sector, + out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/UCSDPascal/File.cs b/Aaru.Filesystems/UCSDPascal/File.cs index 41e83e094..eb10358fb 100644 --- a/Aaru.Filesystems/UCSDPascal/File.cs +++ b/Aaru.Filesystems/UCSDPascal/File.cs @@ -112,7 +112,8 @@ public sealed partial class PascalPlugin if(error != ErrorNumber.NoError) return error; - error = _device.ReadSectors((ulong)entry.FirstBlock * _multiplier, + error = _device.ReadSectors((ulong)entry.FirstBlock * _multiplier, + false, (uint)(entry.LastBlock - entry.FirstBlock) * _multiplier, out byte[] tmp, out _); diff --git a/Aaru.Filesystems/UCSDPascal/Info.cs b/Aaru.Filesystems/UCSDPascal/Info.cs index b1440b25d..2655b6e15 100644 --- a/Aaru.Filesystems/UCSDPascal/Info.cs +++ b/Aaru.Filesystems/UCSDPascal/Info.cs @@ -56,8 +56,11 @@ public sealed partial class PascalPlugin _multiplier = (uint)(imagePlugin.Info.SectorSize == 256 ? 2 : 1); // Blocks 0 and 1 are boot code - ErrorNumber errno = - imagePlugin.ReadSectors(_multiplier * 2 + partition.Start, _multiplier, out byte[] volBlock, out _); + ErrorNumber errno = imagePlugin.ReadSectors(_multiplier * 2 + partition.Start, + false, + _multiplier, + out byte[] volBlock, + out _); if(errno != ErrorNumber.NoError) return false; @@ -126,8 +129,11 @@ public sealed partial class PascalPlugin if(imagePlugin.Info.Sectors < 3) return; // Blocks 0 and 1 are boot code - ErrorNumber errno = - imagePlugin.ReadSectors(_multiplier * 2 + partition.Start, _multiplier, out byte[] volBlock, out _); + ErrorNumber errno = imagePlugin.ReadSectors(_multiplier * 2 + partition.Start, + false, + _multiplier, + out byte[] volBlock, + out _); if(errno != ErrorNumber.NoError) return; @@ -189,7 +195,7 @@ public sealed partial class PascalPlugin information = sbInformation.ToString(); - imagePlugin.ReadSectors(partition.Start, _multiplier * 2, out byte[] boot, out _); + imagePlugin.ReadSectors(partition.Start, false, _multiplier * 2, out byte[] boot, out _); metadata = new FileSystem { diff --git a/Aaru.Filesystems/UCSDPascal/Super.cs b/Aaru.Filesystems/UCSDPascal/Super.cs index a26c5858d..f618162e5 100644 --- a/Aaru.Filesystems/UCSDPascal/Super.cs +++ b/Aaru.Filesystems/UCSDPascal/Super.cs @@ -64,7 +64,7 @@ public sealed partial class PascalPlugin _multiplier = (uint)(imagePlugin.Info.SectorSize == 256 ? 2 : 1); // Blocks 0 and 1 are boot code - ErrorNumber errno = _device.ReadSectors(_multiplier * 2, _multiplier, out _catalogBlocks, out _); + ErrorNumber errno = _device.ReadSectors(_multiplier * 2, false, _multiplier, out _catalogBlocks, out _); if(errno != ErrorNumber.NoError) return errno; @@ -94,7 +94,8 @@ public sealed partial class PascalPlugin _mountedVolEntry.Files < 0) return ErrorNumber.InvalidArgument; - errno = _device.ReadSectors(_multiplier * 2, + errno = _device.ReadSectors(_multiplier * 2, + false, (uint)(_mountedVolEntry.LastBlock - _mountedVolEntry.FirstBlock - 2) * _multiplier, out _catalogBlocks, out _); @@ -124,7 +125,7 @@ public sealed partial class PascalPlugin offset += 26; } - errno = _device.ReadSectors(0, 2 * _multiplier, out _bootBlocks, out _); + errno = _device.ReadSectors(0, false, 2 * _multiplier, out _bootBlocks, out _); if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Filesystems/UDF/Info.cs b/Aaru.Filesystems/UDF/Info.cs index 4d82b9663..a0d4fbc80 100644 --- a/Aaru.Filesystems/UDF/Info.cs +++ b/Aaru.Filesystems/UDF/Info.cs @@ -75,7 +75,11 @@ public sealed partial class UDF partition.End && position[0] < partition.End) let errno = - imagePlugin.ReadSectors(position[0], (uint)position[1], out sector, out _) + imagePlugin.ReadSectors(position[0], + false, + (uint)position[1], + out sector, + out _) where errno == ErrorNumber.NoError select position) { @@ -133,6 +137,7 @@ public sealed partial class UDF imagePlugin.ReadSectors(partition.Start + anchor.mainVolumeDescriptorSequenceExtent.location * ratio + count * ratio, + false, ratio, out sector, out _); @@ -197,7 +202,7 @@ public sealed partial class UDF foreach(ulong[] position in positions) { - errno = imagePlugin.ReadSectors(position[0], (uint)position[1], out sector, out _); + errno = imagePlugin.ReadSectors(position[0], false, (uint)position[1], out sector, out _); if(errno != ErrorNumber.NoError) continue; @@ -224,6 +229,7 @@ public sealed partial class UDF errno = imagePlugin.ReadSectors(partition.Start + anchor.mainVolumeDescriptorSequenceExtent.location * ratio + count * ratio, + false, ratio, out sector, out _); @@ -255,7 +261,7 @@ public sealed partial class UDF count++; } - errno = imagePlugin.ReadSectors(lvd.integritySequenceExtent.location * ratio, ratio, out sector, out _); + errno = imagePlugin.ReadSectors(lvd.integritySequenceExtent.location * ratio, false, ratio, out sector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/UNICOS/Info.cs b/Aaru.Filesystems/UNICOS/Info.cs index 21f87c135..e725226a2 100644 --- a/Aaru.Filesystems/UNICOS/Info.cs +++ b/Aaru.Filesystems/UNICOS/Info.cs @@ -55,7 +55,7 @@ public sealed partial class UNICOS if(partition.Start + sbSize >= partition.End) return false; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, false, sbSize, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -82,7 +82,7 @@ public sealed partial class UNICOS if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, false, sbSize, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/UNIXBFS/Info.cs b/Aaru.Filesystems/UNIXBFS/Info.cs index aedc2b1be..50867dab8 100644 --- a/Aaru.Filesystems/UNIXBFS/Info.cs +++ b/Aaru.Filesystems/UNIXBFS/Info.cs @@ -49,7 +49,7 @@ public sealed partial class BFS { if(2 + partition.Start >= partition.End) return false; - ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] tmp, out _); + ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, false, out byte[] tmp, out _); if(errno != ErrorNumber.NoError) return false; @@ -67,7 +67,7 @@ public sealed partial class BFS metadata = new FileSystem(); var sb = new StringBuilder(); - ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bfsSbSector, out _); + ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, false, out byte[] bfsSbSector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/VMfs/Info.cs b/Aaru.Filesystems/VMfs/Info.cs index 0bf91cab3..63c342b18 100644 --- a/Aaru.Filesystems/VMfs/Info.cs +++ b/Aaru.Filesystems/VMfs/Info.cs @@ -57,7 +57,7 @@ public sealed partial class VMfs if(partition.Start + vmfsSuperOff > partition.End) return false; - ErrorNumber errno = imagePlugin.ReadSector(partition.Start + vmfsSuperOff, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(partition.Start + vmfsSuperOff, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -70,11 +70,11 @@ public sealed partial class VMfs public void GetInformation(IMediaImage imagePlugin, Partition partition, Encoding encoding, out string information, out FileSystem metadata) { - encoding ??= Encoding.UTF8; - information = ""; - metadata = new FileSystem(); + encoding ??= Encoding.UTF8; + information = ""; + metadata = new FileSystem(); ulong vmfsSuperOff = VMFS_BASE / imagePlugin.Info.SectorSize; - ErrorNumber errno = imagePlugin.ReadSector(partition.Start + vmfsSuperOff, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(partition.Start + vmfsSuperOff, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/VxFS/Info.cs b/Aaru.Filesystems/VxFS/Info.cs index c34f68f64..d9673c014 100644 --- a/Aaru.Filesystems/VxFS/Info.cs +++ b/Aaru.Filesystems/VxFS/Info.cs @@ -49,7 +49,7 @@ public sealed partial class VxFS if(partition.Start + vmfsSuperOff >= partition.End) return false; - ErrorNumber errno = imagePlugin.ReadSector(partition.Start + vmfsSuperOff, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(partition.Start + vmfsSuperOff, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -62,11 +62,11 @@ public sealed partial class VxFS public void GetInformation(IMediaImage imagePlugin, Partition partition, Encoding encoding, out string information, out FileSystem metadata) { - encoding ??= Encoding.UTF8; - information = ""; - metadata = new FileSystem(); + encoding ??= Encoding.UTF8; + information = ""; + metadata = new FileSystem(); ulong vmfsSuperOff = VXFS_BASE / imagePlugin.Info.SectorSize; - ErrorNumber errno = imagePlugin.ReadSector(partition.Start + vmfsSuperOff, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(partition.Start + vmfsSuperOff, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/XFS/Info.cs b/Aaru.Filesystems/XFS/Info.cs index 731ccd5e9..f19068b1b 100644 --- a/Aaru.Filesystems/XFS/Info.cs +++ b/Aaru.Filesystems/XFS/Info.cs @@ -55,7 +55,7 @@ public sealed partial class XFS if((Marshal.SizeOf() + 0x400) % imagePlugin.Info.SectorSize != 0) sbSize++; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, false, sbSize, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -95,7 +95,7 @@ public sealed partial class XFS if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; ErrorNumber errno = - imagePlugin.ReadSectors(partition.Start + location, sbSize, out byte[] sector, out _); + imagePlugin.ReadSectors(partition.Start + location, false, sbSize, out byte[] sector, out _); if(errno != ErrorNumber.NoError) continue; @@ -135,7 +135,7 @@ public sealed partial class XFS if((Marshal.SizeOf() + 0x400) % imagePlugin.Info.SectorSize != 0) sbSize++; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, false, sbSize, out byte[] sector, out _); if(errno != ErrorNumber.NoError || sector.Length < Marshal.SizeOf()) return; @@ -172,7 +172,7 @@ public sealed partial class XFS if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; ErrorNumber errno = - imagePlugin.ReadSectors(partition.Start + location, sbSize, out byte[] sector, out _); + imagePlugin.ReadSectors(partition.Start + location, false, sbSize, out byte[] sector, out _); if(errno != ErrorNumber.NoError || sector.Length < Marshal.SizeOf()) return; diff --git a/Aaru.Filesystems/Xia/Info.cs b/Aaru.Filesystems/Xia/Info.cs index df39eb6f5..d537e96ed 100644 --- a/Aaru.Filesystems/Xia/Info.cs +++ b/Aaru.Filesystems/Xia/Info.cs @@ -57,7 +57,8 @@ public sealed partial class Xia if(sbSizeInSectors + partition.Start >= partition.End) return false; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSizeInSectors, out byte[] sbSector, out _); + ErrorNumber errno = + imagePlugin.ReadSectors(partition.Start, false, sbSizeInSectors, out byte[] sbSector, out _); if(errno != ErrorNumber.NoError) return false; @@ -80,7 +81,8 @@ public sealed partial class Xia if(sbSizeInBytes % imagePlugin.Info.SectorSize > 0) sbSizeInSectors++; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSizeInSectors, out byte[] sbSector, out _); + ErrorNumber errno = + imagePlugin.ReadSectors(partition.Start, false, sbSizeInSectors, out byte[] sbSector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/ZFS/Info.cs b/Aaru.Filesystems/ZFS/Info.cs index 7e1e939a2..a8a4c944a 100644 --- a/Aaru.Filesystems/ZFS/Info.cs +++ b/Aaru.Filesystems/ZFS/Info.cs @@ -77,7 +77,7 @@ public sealed partial class ZFS if(partition.Start + 31 < partition.End) { - errno = imagePlugin.ReadSector(partition.Start + 31, out sector, out _); + errno = imagePlugin.ReadSector(partition.Start + 31, false, out sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -88,7 +88,7 @@ public sealed partial class ZFS if(partition.Start + 16 >= partition.End) return false; - errno = imagePlugin.ReadSector(partition.Start + 16, out sector, out _); + errno = imagePlugin.ReadSector(partition.Start + 16, false, out sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -116,7 +116,7 @@ public sealed partial class ZFS if(partition.Start + 31 < partition.End) { - errno = imagePlugin.ReadSector(partition.Start + 31, out sector, out _); + errno = imagePlugin.ReadSector(partition.Start + 31, false, out sector, out _); if(errno != ErrorNumber.NoError) return; @@ -127,7 +127,7 @@ public sealed partial class ZFS if(partition.Start + 16 < partition.End) { - errno = imagePlugin.ReadSector(partition.Start + 16, out sector, out _); + errno = imagePlugin.ReadSector(partition.Start + 16, false, out sector, out _); if(errno != ErrorNumber.NoError) return; @@ -139,7 +139,7 @@ public sealed partial class ZFS var sb = new StringBuilder(); sb.AppendLine(Localization.ZFS_filesystem); - errno = imagePlugin.ReadSectors(partition.Start + nvlistOff, nvlistLen, out byte[] nvlist, out _); + errno = imagePlugin.ReadSectors(partition.Start + nvlistOff, false, nvlistLen, out byte[] nvlist, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/dump/Info.cs b/Aaru.Filesystems/dump/Info.cs index 782d0bd25..474e4f81f 100644 --- a/Aaru.Filesystems/dump/Info.cs +++ b/Aaru.Filesystems/dump/Info.cs @@ -61,7 +61,7 @@ public sealed partial class Dump if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, false, sbSize, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -100,7 +100,7 @@ public sealed partial class Dump if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, false, sbSize, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/exFAT/Info.cs b/Aaru.Filesystems/exFAT/Info.cs index 4c0d92907..1db92f0b5 100644 --- a/Aaru.Filesystems/exFAT/Info.cs +++ b/Aaru.Filesystems/exFAT/Info.cs @@ -53,7 +53,7 @@ public sealed partial class exFAT { if(12 + partition.Start >= partition.End) return false; - ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] vbrSector, out _); + ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, false, out byte[] vbrSector, out _); if(errno != ErrorNumber.NoError) return false; @@ -73,20 +73,20 @@ public sealed partial class exFAT var sb = new StringBuilder(); metadata = new FileSystem(); - ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] vbrSector, out _); + ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, false, out byte[] vbrSector, out _); if(errno != ErrorNumber.NoError) return; VolumeBootRecord vbr = Marshal.ByteArrayToStructureLittleEndian(vbrSector); - errno = imagePlugin.ReadSector(9 + partition.Start, out byte[] parametersSector, out _); + errno = imagePlugin.ReadSector(9 + partition.Start, false, out byte[] parametersSector, out _); if(errno != ErrorNumber.NoError) return; OemParameterTable parametersTable = Marshal.ByteArrayToStructureLittleEndian(parametersSector); - errno = imagePlugin.ReadSector(11 + partition.Start, out byte[] chkSector, out _); + errno = imagePlugin.ReadSector(11 + partition.Start, false, out byte[] chkSector, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/ext2FS/Info.cs b/Aaru.Filesystems/ext2FS/Info.cs index 5fc03afc1..ada3d1e69 100644 --- a/Aaru.Filesystems/ext2FS/Info.cs +++ b/Aaru.Filesystems/ext2FS/Info.cs @@ -64,8 +64,11 @@ public sealed partial class ext2FS if(sbSizeInBytes % imagePlugin.Info.SectorSize > 0) sbSizeInSectors++; - ErrorNumber errno = - imagePlugin.ReadSectors(sbSectorOff + partition.Start, sbSizeInSectors, out byte[] sbSector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(sbSectorOff + partition.Start, + false, + sbSizeInSectors, + out byte[] sbSector, + out _); if(errno != ErrorNumber.NoError) return false; @@ -102,8 +105,11 @@ public sealed partial class ext2FS ulong sbSectorOff = SB_POS / imagePlugin.Info.SectorSize; uint sbOff = SB_POS % imagePlugin.Info.SectorSize; - ErrorNumber errno = - imagePlugin.ReadSectors(sbSectorOff + partition.Start, sbSizeInSectors, out byte[] sbSector, out _); + ErrorNumber errno = imagePlugin.ReadSectors(sbSectorOff + partition.Start, + false, + sbSizeInSectors, + out byte[] sbSector, + out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Filesystems/extFS/Info.cs b/Aaru.Filesystems/extFS/Info.cs index 0c3d02106..0155caa80 100644 --- a/Aaru.Filesystems/extFS/Info.cs +++ b/Aaru.Filesystems/extFS/Info.cs @@ -54,7 +54,7 @@ public sealed partial class extFS if(sbSectorOff + partition.Start >= partition.End) return false; - ErrorNumber errno = imagePlugin.ReadSector(sbSectorOff + partition.Start, out byte[] sbSector, out _); + ErrorNumber errno = imagePlugin.ReadSector(sbSectorOff + partition.Start, false, out byte[] sbSector, out _); if(errno != ErrorNumber.NoError) return false; @@ -85,7 +85,7 @@ public sealed partial class extFS if(sbSectorOff + partition.Start >= partition.End) return; - ErrorNumber errno = imagePlugin.ReadSector(sbSectorOff + partition.Start, out byte[] sblock, out _); + ErrorNumber errno = imagePlugin.ReadSector(sbSectorOff + partition.Start, false, out byte[] sblock, out _); if(errno != ErrorNumber.NoError) return; diff --git a/Aaru.Gui/ViewModels/Windows/ImageChecksumViewModel.cs b/Aaru.Gui/ViewModels/Windows/ImageChecksumViewModel.cs index 353f6115b..b32746c39 100644 --- a/Aaru.Gui/ViewModels/Windows/ImageChecksumViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/ImageChecksumViewModel.cs @@ -321,7 +321,7 @@ public sealed partial class ImageChecksumViewModel : ViewModelBase Progress2Text = $"Hashing track-less sector {sector}"; }); - errno = opticalMediaImage.ReadSector(i, out byte[] hiddenSector, out _); + errno = opticalMediaImage.ReadSector(i, false, out byte[] hiddenSector, out _); if(errno != ErrorNumber.NoError) { @@ -464,7 +464,7 @@ public sealed partial class ImageChecksumViewModel : ViewModelBase Progress2Text = $"Hashing track-less sector {sector}"; }); - errno = opticalMediaImage.ReadSector(i, out byte[] hiddenSector, out _); + errno = opticalMediaImage.ReadSector(i, false, out byte[] hiddenSector, out _); if(errno != ErrorNumber.NoError) { @@ -526,7 +526,7 @@ public sealed partial class ImageChecksumViewModel : ViewModelBase if(_inputFormat.Info.Sectors - doneSectors >= SECTORS_TO_READ) { - errno = _inputFormat.ReadSectors(doneSectors, SECTORS_TO_READ, out sector, out _); + errno = _inputFormat.ReadSectors(doneSectors, false, SECTORS_TO_READ, out sector, out _); if(errno != ErrorNumber.NoError) { @@ -555,6 +555,7 @@ public sealed partial class ImageChecksumViewModel : ViewModelBase else { errno = _inputFormat.ReadSectors(doneSectors, + false, (uint)(_inputFormat.Info.Sectors - doneSectors), out sector, out _); diff --git a/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs b/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs index 1fba5acb2..1720812b6 100644 --- a/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs @@ -748,8 +748,9 @@ public sealed partial class ImageConvertViewModel : ViewModelBase if(useLong) { errno = sectorsToDo == 1 - ? _inputFormat.ReadSectorLong(doneSectors, out sector, out sectorStatus) + ? _inputFormat.ReadSectorLong(doneSectors, false, out sector, out sectorStatus) : _inputFormat.ReadSectorsLong(doneSectors, + false, sectorsToDo, out sector, out sectorStatusArray); @@ -757,9 +758,10 @@ public sealed partial class ImageConvertViewModel : ViewModelBase if(errno == ErrorNumber.NoError) { result = sectorsToDo == 1 - ? outputFormat.WriteSectorLong(sector, doneSectors, sectorStatus) + ? outputFormat.WriteSectorLong(sector, doneSectors, false, sectorStatus) : outputFormat.WriteSectorsLong(sector, doneSectors, + false, sectorsToDo, sectorStatusArray); } @@ -794,14 +796,22 @@ public sealed partial class ImageConvertViewModel : ViewModelBase else { errno = sectorsToDo == 1 - ? _inputFormat.ReadSector(doneSectors, out sector, out sectorStatus) - : _inputFormat.ReadSectors(doneSectors, sectorsToDo, out sector, out sectorStatusArray); + ? _inputFormat.ReadSector(doneSectors, false, out sector, out sectorStatus) + : _inputFormat.ReadSectors(doneSectors, + false, + sectorsToDo, + out sector, + out sectorStatusArray); if(errno == ErrorNumber.NoError) { result = sectorsToDo == 1 - ? outputFormat.WriteSector(sector, doneSectors, sectorStatus) - : outputFormat.WriteSectors(sector, doneSectors, sectorsToDo, sectorStatusArray); + ? outputFormat.WriteSector(sector, doneSectors, false, sectorStatus) + : outputFormat.WriteSectors(sector, + doneSectors, + false, + sectorsToDo, + sectorStatusArray); } else { @@ -887,7 +897,7 @@ public sealed partial class ImageConvertViewModel : ViewModelBase { foreach(Track track in inputOptical.Tracks) { - errno = _inputFormat.ReadSectorTag(track.Sequence, tag, out byte[] isrc); + errno = _inputFormat.ReadSectorTag(track.Sequence, false, tag, out byte[] isrc); if(errno != ErrorNumber.NoError) continue; @@ -901,7 +911,7 @@ public sealed partial class ImageConvertViewModel : ViewModelBase { foreach(Track track in inputOptical.Tracks) { - errno = _inputFormat.ReadSectorTag(track.Sequence, tag, out byte[] flags); + errno = _inputFormat.ReadSectorTag(track.Sequence, false, tag, out byte[] flags); if(errno != ErrorNumber.NoError) continue; @@ -977,7 +987,7 @@ public sealed partial class ImageConvertViewModel : ViewModelBase if(sectorsToDo == 1) { - errno = _inputFormat.ReadSectorTag(doneSectors, tag, out sector); + errno = _inputFormat.ReadSectorTag(doneSectors, false, tag, out sector); if(errno == ErrorNumber.NoError) { @@ -1010,7 +1020,7 @@ public sealed partial class ImageConvertViewModel : ViewModelBase result = true; } else - result = outputFormat.WriteSectorTag(sector, doneSectors, tag); + result = outputFormat.WriteSectorTag(sector, doneSectors, false, tag); } else { @@ -1042,7 +1052,7 @@ public sealed partial class ImageConvertViewModel : ViewModelBase } else { - errno = _inputFormat.ReadSectorsTag(doneSectors, sectorsToDo, tag, out sector); + errno = _inputFormat.ReadSectorsTag(doneSectors, false, sectorsToDo, tag, out sector); if(errno == ErrorNumber.NoError) { @@ -1076,7 +1086,7 @@ public sealed partial class ImageConvertViewModel : ViewModelBase result = true; } else - result = outputFormat.WriteSectorsTag(sector, doneSectors, sectorsToDo, tag); + result = outputFormat.WriteSectorsTag(sector, doneSectors, false, sectorsToDo, tag); } else { @@ -1156,11 +1166,12 @@ public sealed partial class ImageConvertViewModel : ViewModelBase { outputOptical.WriteSectorTag(Encoding.UTF8.GetBytes(isrc.Value), isrc.Key, + false, SectorTagType.CdTrackIsrc); } foreach(KeyValuePair flags in trackFlags) - outputOptical.WriteSectorTag([flags.Value], flags.Key, SectorTagType.CdTrackFlags); + outputOptical.WriteSectorTag([flags.Value], flags.Key, false, SectorTagType.CdTrackFlags); if(mcn != null) outputOptical.WriteMediaTag(Encoding.UTF8.GetBytes(mcn), MediaTagType.CD_MCN); } @@ -1216,9 +1227,11 @@ public sealed partial class ImageConvertViewModel : ViewModelBase { errno = sectorsToDo == 1 ? _inputFormat.ReadSectorLong(doneSectors + track.StartSector, + false, out sector, out sectorStatus) : _inputFormat.ReadSectorsLong(doneSectors + track.StartSector, + false, sectorsToDo, out sector, out sectorStatusArray); @@ -1228,9 +1241,11 @@ public sealed partial class ImageConvertViewModel : ViewModelBase result = sectorsToDo == 1 ? outputFormat.WriteSectorLong(sector, doneSectors + track.StartSector, + false, sectorStatus) : outputFormat.WriteSectorsLong(sector, doneSectors + track.StartSector, + false, sectorsToDo, sectorStatusArray); } @@ -1264,9 +1279,11 @@ public sealed partial class ImageConvertViewModel : ViewModelBase { errno = sectorsToDo == 1 ? _inputFormat.ReadSector(doneSectors + track.StartSector, + false, out sector, out sectorStatus) : _inputFormat.ReadSectors(doneSectors + track.StartSector, + false, sectorsToDo, out sector, out sectorStatusArray); @@ -1276,9 +1293,11 @@ public sealed partial class ImageConvertViewModel : ViewModelBase result = sectorsToDo == 1 ? outputFormat.WriteSector(sector, doneSectors + track.StartSector, + false, sectorStatus) : outputFormat.WriteSectors(sector, doneSectors + track.StartSector, + false, sectorsToDo, sectorStatusArray); } @@ -1393,10 +1412,10 @@ public sealed partial class ImageConvertViewModel : ViewModelBase case SectorTagType.CdTrackFlags: case SectorTagType.CdTrackIsrc: - errno = _inputFormat.ReadSectorTag(track.Sequence, tag, out sector); + errno = _inputFormat.ReadSectorTag(track.Sequence, false, tag, out sector); if(errno == ErrorNumber.NoError) - result = outputFormat.WriteSectorTag(sector, track.Sequence, tag); + result = outputFormat.WriteSectorTag(sector, track.Sequence, false, tag); else { if(ForceChecked) @@ -1476,8 +1495,12 @@ public sealed partial class ImageConvertViewModel : ViewModelBase }); errno = sectorsToDo == 1 - ? _inputFormat.ReadSectorTag(doneSectors + track.StartSector, tag, out sector) + ? _inputFormat.ReadSectorTag(doneSectors + track.StartSector, + false, + tag, + out sector) : _inputFormat.ReadSectorsTag(doneSectors + track.StartSector, + false, sectorsToDo, tag, out sector); @@ -1485,9 +1508,13 @@ public sealed partial class ImageConvertViewModel : ViewModelBase if(errno == ErrorNumber.NoError) { result = sectorsToDo == 1 - ? outputFormat.WriteSectorTag(sector, doneSectors + track.StartSector, tag) + ? outputFormat.WriteSectorTag(sector, + doneSectors + track.StartSector, + false, + tag) : outputFormat.WriteSectorsTag(sector, doneSectors + track.StartSector, + false, sectorsToDo, tag); } diff --git a/Aaru.Gui/ViewModels/Windows/ViewSectorViewModel.cs b/Aaru.Gui/ViewModels/Windows/ViewSectorViewModel.cs index c583e5f6c..0b1c00abc 100644 --- a/Aaru.Gui/ViewModels/Windows/ViewSectorViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/ViewSectorViewModel.cs @@ -60,7 +60,7 @@ public sealed partial class ViewSectorViewModel : ViewModelBase { _inputFormat = inputFormat; - ErrorNumber errno = inputFormat.ReadSectorLong(0, out _, out _); + ErrorNumber errno = inputFormat.ReadSectorLong(0, false, out _, out _); if(errno == ErrorNumber.NoError) LongSectorChecked = true; @@ -83,8 +83,8 @@ public sealed partial class ViewSectorViewModel : ViewModelBase SetProperty(ref _sectorNumber, value); ErrorNumber errno = LongSectorChecked - ? _inputFormat.ReadSectorLong((ulong)SectorNumber, out byte[] sector, out _) - : _inputFormat.ReadSector((ulong)SectorNumber, out sector, out _); + ? _inputFormat.ReadSectorLong((ulong)SectorNumber, false, out byte[] sector, out _) + : _inputFormat.ReadSector((ulong)SectorNumber, false, out sector, out _); if(errno == ErrorNumber.NoError) PrintHexText = PrintHex.ByteArrayToHexArrayString(sector, HEX_COLUMNS); } diff --git a/Aaru.Images/A2R/Read.cs b/Aaru.Images/A2R/Read.cs index 0d5dc171a..689bc37b2 100644 --- a/Aaru.Images/A2R/Read.cs +++ b/Aaru.Images/A2R/Read.cs @@ -472,29 +472,29 @@ public sealed partial class A2R /// public ErrorNumber ReadMediaTag(MediaTagType tag, out byte[] buffer) => throw new NotImplementedException(); - /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) => - throw new NotImplementedException(); - - /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) => - throw new NotImplementedException(); - /// public ErrorNumber - ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) => + ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) => throw new NotImplementedException(); /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) => throw new NotImplementedException(); + + /// + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) => throw new NotImplementedException(); + + /// + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) => throw new NotImplementedException(); /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) => - throw new NotImplementedException(); + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) => throw new NotImplementedException(); /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) => + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) => throw new NotImplementedException(); #endregion diff --git a/Aaru.Images/A2R/Write.cs b/Aaru.Images/A2R/Write.cs index 9b3f7e2b7..2d4d47b5a 100644 --- a/Aaru.Images/A2R/Write.cs +++ b/Aaru.Images/A2R/Write.cs @@ -226,10 +226,11 @@ public sealed partial class A2R public bool SetGeometry(uint cylinders, uint heads, uint sectorsPerTrack) => true; /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) => false; + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) => false; /// - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) => false; + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) => + false; /// public bool SetDumpHardware(List dumpHardware) => false; @@ -241,20 +242,20 @@ public sealed partial class A2R public bool WriteMediaTag(byte[] data, MediaTagType tag) => false; /// - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) => + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) => throw new NotImplementedException(); /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) => + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) => throw new NotImplementedException(); /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) => - throw new NotImplementedException(); + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) => throw new NotImplementedException(); /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) => - throw new NotImplementedException(); + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) => throw new NotImplementedException(); #endregion diff --git a/Aaru.Images/AaruFormat/Optical.cs b/Aaru.Images/AaruFormat/Optical.cs index 3a11e88d1..46fb39c9d 100644 --- a/Aaru.Images/AaruFormat/Optical.cs +++ b/Aaru.Images/AaruFormat/Optical.cs @@ -144,10 +144,10 @@ public sealed partial class AaruFormat foreach(Track trk in tracks) { - ReadSector(trk.StartSector, out byte[] sector, out _); + ReadSector(trk.StartSector, false, out byte[] sector, out _); trk.BytesPerSector = sector?.Length ?? (trk.Type == TrackType.Audio ? 2352 : 2048); - ErrorNumber errno = ReadSectorLong(trk.StartSector, out byte[] longSector, out _); + ErrorNumber errno = ReadSectorLong(trk.StartSector, false, out byte[] longSector, out _); if(errno == ErrorNumber.NoError) trk.RawBytesPerSector = longSector.Length; diff --git a/Aaru.Images/AaruFormat/Read.cs b/Aaru.Images/AaruFormat/Read.cs index a2be79d93..32787e429 100644 --- a/Aaru.Images/AaruFormat/Read.cs +++ b/Aaru.Images/AaruFormat/Read.cs @@ -69,19 +69,19 @@ public sealed partial class AaruFormat } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { buffer = null; uint length = 0; sectorStatus = SectorStatus.NotDumped; - Status res = aaruf_read_sector(_context, sectorAddress, false, buffer, ref length, out _); + Status res = aaruf_read_sector(_context, sectorAddress, negative, buffer, ref length, out _); if(res != Status.BufferTooSmall) return StatusToErrorNumber(res); buffer = new byte[length]; - res = aaruf_read_sector(_context, sectorAddress, false, buffer, ref length, out byte libSectorStatus); + res = aaruf_read_sector(_context, sectorAddress, negative, buffer, ref length, out byte libSectorStatus); sectorStatus = (SectorStatus)libSectorStatus; @@ -124,19 +124,20 @@ public sealed partial class AaruFormat } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; uint length = 0; sectorStatus = SectorStatus.NotDumped; - Status res = aaruf_read_sector_long(_context, sectorAddress, false, buffer, ref length, out _); + Status res = aaruf_read_sector_long(_context, sectorAddress, negative, buffer, ref length, out _); if(res != Status.BufferTooSmall) return StatusToErrorNumber(res); buffer = new byte[length]; - res = aaruf_read_sector_long(_context, sectorAddress, false, buffer, ref length, out byte libSectorStatus); + res = aaruf_read_sector_long(_context, sectorAddress, negative, buffer, ref length, out byte libSectorStatus); sectorStatus = (SectorStatus)libSectorStatus; @@ -149,7 +150,7 @@ public sealed partial class AaruFormat } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -187,19 +188,20 @@ public sealed partial class AaruFormat uint length = 0; - Status res = aaruf_read_sector_tag(_context, sectorAddress, false, buffer, ref length, tag); + Status res = aaruf_read_sector_tag(_context, sectorAddress, negative, buffer, ref length, tag); if(res != Status.BufferTooSmall && res != Status.IncorrectDataSize) return StatusToErrorNumber(res); buffer = new byte[length]; - res = aaruf_read_sector_tag(_context, sectorAddress, false, buffer, ref length, tag); + res = aaruf_read_sector_tag(_context, sectorAddress, negative, buffer, ref length, tag); return StatusToErrorNumber(res); } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { MemoryStream ms = new(); sectorStatus = new SectorStatus[length]; @@ -207,6 +209,7 @@ public sealed partial class AaruFormat for(uint i = 0; i < length; i++) { ErrorNumber res = ReadSector(sectorAddress + i, + negative, out byte[] sectorBuffer, out SectorStatus singleSectorStatus); @@ -227,7 +230,7 @@ public sealed partial class AaruFormat } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { MemoryStream ms = new(); @@ -236,6 +239,7 @@ public sealed partial class AaruFormat for(uint i = 0; i < length; i++) { ErrorNumber res = ReadSectorLong(sectorAddress + i, + negative, out byte[] sectorBuffer, out SectorStatus singleSectorStatus); @@ -256,13 +260,14 @@ public sealed partial class AaruFormat } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { MemoryStream ms = new(); for(uint i = 0; i < length; i++) { - ErrorNumber res = ReadSectorTag(sectorAddress + i, tag, out byte[] sectorBuffer); + ErrorNumber res = ReadSectorTag(sectorAddress + i, negative, tag, out byte[] sectorBuffer); if(res != ErrorNumber.NoError) { @@ -292,7 +297,7 @@ public sealed partial class AaruFormat return trk?.Sequence != track ? ErrorNumber.SectorNotFound - : ReadSectorTag(trk.StartSector + sectorAddress, tag, out buffer); + : ReadSectorTag(trk.StartSector + sectorAddress, false, tag, out buffer); } /// @@ -312,7 +317,7 @@ public sealed partial class AaruFormat return trk.StartSector + sectorAddress + length > trk.EndSector + 1 ? ErrorNumber.OutOfRange - : ReadSectors(trk.StartSector + sectorAddress, length, out buffer, out sectorStatus); + : ReadSectors(trk.StartSector + sectorAddress, false, length, out buffer, out sectorStatus); } /// @@ -331,7 +336,7 @@ public sealed partial class AaruFormat ? ErrorNumber.SectorNotFound : trk.StartSector + sectorAddress + length > trk.EndSector + 1 ? ErrorNumber.OutOfRange - : ReadSectorsTag(trk.StartSector + sectorAddress, length, tag, out buffer); + : ReadSectorsTag(trk.StartSector + sectorAddress, false, length, tag, out buffer); } /// @@ -348,7 +353,7 @@ public sealed partial class AaruFormat return trk?.Sequence != track ? ErrorNumber.SectorNotFound - : ReadSectorLong(trk.StartSector + sectorAddress, out buffer, out sectorStatus); + : ReadSectorLong(trk.StartSector + sectorAddress, false, out buffer, out sectorStatus); } /// @@ -368,7 +373,7 @@ public sealed partial class AaruFormat ? ErrorNumber.SectorNotFound : trk.StartSector + sectorAddress + length > trk.EndSector + 1 ? ErrorNumber.OutOfRange - : ReadSectorsLong(trk.StartSector + sectorAddress, length, out buffer, out sectorStatus); + : ReadSectorsLong(trk.StartSector + sectorAddress, false, length, out buffer, out sectorStatus); } #endregion diff --git a/Aaru.Images/AaruFormat/Verify.cs b/Aaru.Images/AaruFormat/Verify.cs index fbb7deef1..4a9f3532c 100644 --- a/Aaru.Images/AaruFormat/Verify.cs +++ b/Aaru.Images/AaruFormat/Verify.cs @@ -35,7 +35,7 @@ public sealed partial class AaruFormat { if(_imageInfo.MetadataMediaType != MetadataMediaType.OpticalDisc) return null; - ErrorNumber errno = ReadSectorLong(sectorAddress, out byte[] buffer, out _); + ErrorNumber errno = ReadSectorLong(sectorAddress, false, out byte[] buffer, out _); return errno != ErrorNumber.NoError ? null : CdChecksums.CheckCdSector(buffer); } @@ -55,7 +55,7 @@ public sealed partial class AaruFormat return null; } - ErrorNumber errno = ReadSectorsLong(sectorAddress, length, out byte[] buffer, out _); + ErrorNumber errno = ReadSectorsLong(sectorAddress, false, length, out byte[] buffer, out _); if(errno != ErrorNumber.NoError) return null; diff --git a/Aaru.Images/AaruFormat/Write.cs b/Aaru.Images/AaruFormat/Write.cs index 2ce63feff..670376508 100644 --- a/Aaru.Images/AaruFormat/Write.cs +++ b/Aaru.Images/AaruFormat/Write.cs @@ -66,9 +66,9 @@ public sealed partial class AaruFormat #region IWritableOpticalImage Members /// - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { - Status res = aaruf_write_sector(_context, sectorAddress, false, data, sectorStatus, (uint)data.Length); + Status res = aaruf_write_sector(_context, sectorAddress, negative, data, sectorStatus, (uint)data.Length); if(res == Status.Ok) return true; @@ -78,9 +78,9 @@ public sealed partial class AaruFormat } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { - Status res = aaruf_write_sector_long(_context, sectorAddress, false, data, sectorStatus, (uint)data.Length); + Status res = aaruf_write_sector_long(_context, sectorAddress, negative, data, sectorStatus, (uint)data.Length); if(res == Status.Ok) return true; @@ -102,7 +102,7 @@ public sealed partial class AaruFormat } /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) { switch(tag) { @@ -126,7 +126,7 @@ public sealed partial class AaruFormat } } - Status res = aaruf_write_sector_tag(_context, sectorAddress, false, data, (nuint)data.Length, tag); + Status res = aaruf_write_sector_tag(_context, sectorAddress, negative, data, (nuint)data.Length, tag); if(res == Status.Ok) return true; @@ -136,7 +136,7 @@ public sealed partial class AaruFormat } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus) { var sectorSize = (uint)(data.Length / length); @@ -145,14 +145,15 @@ public sealed partial class AaruFormat var sectorData = new byte[sectorSize]; Array.Copy(data, i * sectorSize, sectorData, 0, sectorSize); - if(!WriteSector(sectorData, sectorAddress + i, sectorStatus[i])) return false; + if(!WriteSector(sectorData, sectorAddress + i, negative, sectorStatus[i])) return false; } return true; } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) { var sectorSize = (uint)(data.Length / length); @@ -161,14 +162,14 @@ public sealed partial class AaruFormat var sectorData = new byte[sectorSize]; Array.Copy(data, i * sectorSize, sectorData, 0, sectorSize); - if(!WriteSectorLong(sectorData, sectorAddress + i, sectorStatus[i])) return false; + if(!WriteSectorLong(sectorData, sectorAddress + i, negative, sectorStatus[i])) return false; } return true; } /// - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) { var sectorSize = (uint)(data.Length / length); @@ -177,7 +178,7 @@ public sealed partial class AaruFormat var sectorData = new byte[sectorSize]; Array.Copy(data, i * sectorSize, sectorData, 0, sectorSize); - if(!WriteSectorTag(sectorData, sectorAddress + i, tag)) return false; + if(!WriteSectorTag(sectorData, sectorAddress + i, negative, tag)) return false; } return true; @@ -287,8 +288,9 @@ public sealed partial class AaruFormat // Convert array of booleans to List of enums for(nuint i = 0; i < sizet_length; i++) - if(sectorTagsBuffer[i] != 0) - _imageInfo.ReadableSectorTags.Add((SectorTagType)i); + { + if(sectorTagsBuffer[i] != 0) _imageInfo.ReadableSectorTags.Add((SectorTagType)i); + } sizet_length = 0; ret = aaruf_get_readable_media_tags(_context, null, ref sizet_length); @@ -312,8 +314,9 @@ public sealed partial class AaruFormat // Convert array of booleans to List of enums for(nuint i = 0; i < sizet_length; i++) - if(mediaTagsBuffer[i] != 0) - _imageInfo.ReadableMediaTags.Add((MediaTagType)i); + { + if(mediaTagsBuffer[i] != 0) _imageInfo.ReadableMediaTags.Add((MediaTagType)i); + } ret = aaruf_get_media_sequence(_context, out int sequence, out int lastSequence); diff --git a/Aaru.Images/Alcohol120/Read.cs b/Aaru.Images/Alcohol120/Read.cs index 269389c0e..f112d344d 100644 --- a/Aaru.Images/Alcohol120/Read.cs +++ b/Aaru.Images/Alcohol120/Read.cs @@ -757,16 +757,16 @@ public sealed partial class Alcohol120 } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, false, 1, out buffer, out _); } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) => - ReadSectorsTag(sectorAddress, 1, tag, out buffer); + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) => + ReadSectorsTag(sectorAddress, negative, 1, tag, out buffer); /// public ErrorNumber ReadSector(ulong sectorAddress, uint track, out byte[] buffer, out SectorStatus sectorStatus) @@ -781,11 +781,14 @@ public sealed partial class Alcohol120 ReadSectorsTag(sectorAddress, 1, track, tag, out buffer); /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + foreach(KeyValuePair kvp in _offsetMap) { if(sectorAddress < kvp.Value) continue; @@ -804,10 +807,13 @@ public sealed partial class Alcohol120 } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; + if(negative) return ErrorNumber.NotSupported; + foreach(KeyValuePair kvp in _offsetMap) { if(sectorAddress < kvp.Value) continue; @@ -1376,11 +1382,12 @@ public sealed partial class Alcohol120 } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectorsLong(sectorAddress, 1, out buffer, out _); + return ReadSectorsLong(sectorAddress, false, 1, out buffer, out _); } /// @@ -1392,12 +1399,14 @@ public sealed partial class Alcohol120 } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + foreach(KeyValuePair kvp in _offsetMap) { if(sectorAddress < kvp.Value) continue; diff --git a/Aaru.Images/Alcohol120/Verify.cs b/Aaru.Images/Alcohol120/Verify.cs index 1445dd45a..d13cc7fd4 100644 --- a/Aaru.Images/Alcohol120/Verify.cs +++ b/Aaru.Images/Alcohol120/Verify.cs @@ -44,7 +44,7 @@ public sealed partial class Alcohol120 /// public bool? VerifySector(ulong sectorAddress) { - ErrorNumber errno = ReadSectorLong(sectorAddress, out byte[] buffer, out _); + ErrorNumber errno = ReadSectorLong(sectorAddress, false, out byte[] buffer, out _); return errno != ErrorNumber.NoError ? null : CdChecksums.CheckCdSector(buffer); } @@ -55,7 +55,7 @@ public sealed partial class Alcohol120 { failingLbas = []; unknownLbas = []; - ErrorNumber errno = ReadSectorsLong(sectorAddress, length, out byte[] buffer, out _); + ErrorNumber errno = ReadSectorsLong(sectorAddress, false, length, out byte[] buffer, out _); if(errno != ErrorNumber.NoError) return null; diff --git a/Aaru.Images/Alcohol120/Write.cs b/Aaru.Images/Alcohol120/Write.cs index ad12fe4a9..9c33e59f9 100644 --- a/Aaru.Images/Alcohol120/Write.cs +++ b/Aaru.Images/Alcohol120/Write.cs @@ -211,7 +211,7 @@ public sealed partial class Alcohol120 } /// - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { if(!IsWriting) { @@ -220,6 +220,13 @@ public sealed partial class Alcohol120 return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + CommonTypes.Structs.Track track = _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); @@ -261,7 +268,7 @@ public sealed partial class Alcohol120 } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -270,6 +277,13 @@ public sealed partial class Alcohol120 return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(!_isDvd) { ErrorMessage = Localization.Cannot_write_non_long_sectors_to_CD_images; @@ -343,7 +357,7 @@ public sealed partial class Alcohol120 } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { if(!IsWriting) { @@ -352,6 +366,13 @@ public sealed partial class Alcohol120 return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + CommonTypes.Structs.Track track = _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); @@ -382,7 +403,8 @@ public sealed partial class Alcohol120 } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -391,6 +413,13 @@ public sealed partial class Alcohol120 return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + CommonTypes.Structs.Track track = _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); @@ -1052,7 +1081,7 @@ public sealed partial class Alcohol120 } /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) { if(!IsWriting) { @@ -1061,6 +1090,13 @@ public sealed partial class Alcohol120 return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + CommonTypes.Structs.Track track = _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); @@ -1121,7 +1157,7 @@ public sealed partial class Alcohol120 } /// - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) { if(!IsWriting) { @@ -1130,6 +1166,13 @@ public sealed partial class Alcohol120 return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + CommonTypes.Structs.Track track = _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); @@ -1143,7 +1186,7 @@ public sealed partial class Alcohol120 switch(tag) { case SectorTagType.CdTrackFlags: - return WriteSectorTag(data, sectorAddress, tag); + return WriteSectorTag(data, sectorAddress, false, tag); case SectorTagType.CdSectorSubchannel: { if(track.SubchannelType == 0) diff --git a/Aaru.Images/Anex86/Read.cs b/Aaru.Images/Anex86/Read.cs index 0028eea8f..4c6e239fc 100644 --- a/Aaru.Images/Anex86/Read.cs +++ b/Aaru.Images/Anex86/Read.cs @@ -81,19 +81,22 @@ public sealed partial class Anex86 } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, false, 1, out buffer, out _); } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1 || sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; diff --git a/Aaru.Images/Anex86/Unsupported.cs b/Aaru.Images/Anex86/Unsupported.cs index 651bebb07..d15a3f620 100644 --- a/Aaru.Images/Anex86/Unsupported.cs +++ b/Aaru.Images/Anex86/Unsupported.cs @@ -47,7 +47,7 @@ public sealed partial class Anex86 } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -55,7 +55,8 @@ public sealed partial class Anex86 } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -63,7 +64,8 @@ public sealed partial class Anex86 } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -72,7 +74,7 @@ public sealed partial class Anex86 } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/Anex86/Write.cs b/Aaru.Images/Anex86/Write.cs index 32ace3a07..aefd3f965 100644 --- a/Aaru.Images/Anex86/Write.cs +++ b/Aaru.Images/Anex86/Write.cs @@ -113,7 +113,7 @@ public sealed partial class Anex86 } /// - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { if(!IsWriting) { @@ -122,6 +122,13 @@ public sealed partial class Anex86 return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length != _imageInfo.SectorSize) { ErrorMessage = Localization.Incorrect_data_size; @@ -145,7 +152,7 @@ public sealed partial class Anex86 } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -154,6 +161,13 @@ public sealed partial class Anex86 return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length % _imageInfo.SectorSize != 0) { ErrorMessage = Localization.Incorrect_data_size; @@ -177,7 +191,7 @@ public sealed partial class Anex86 } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -185,7 +199,8 @@ public sealed partial class Anex86 } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -283,7 +298,7 @@ public sealed partial class Anex86 } /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; @@ -291,7 +306,7 @@ public sealed partial class Anex86 } /// - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; diff --git a/Aaru.Images/Apple2MG/Read.cs b/Aaru.Images/Apple2MG/Read.cs index eafba09ac..8d0df98ed 100644 --- a/Aaru.Images/Apple2MG/Read.cs +++ b/Aaru.Images/Apple2MG/Read.cs @@ -114,7 +114,9 @@ public sealed partial class Apple2Mg var noFilter = new ZZZNoFilter(); noFilter.Open(tmp); nibPlugin.Open(noFilter); - ErrorNumber errno = nibPlugin.ReadSectors(0, (uint)nibPlugin.Info.Sectors, out _decodedImage, out _); + + ErrorNumber errno = + nibPlugin.ReadSectors(0, false, (uint)nibPlugin.Info.Sectors, out _decodedImage, out _); if(errno != ErrorNumber.NoError) return errno; @@ -275,19 +277,22 @@ public sealed partial class Apple2Mg } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, false, 1, out buffer, out _); } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1 || sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; diff --git a/Aaru.Images/Apple2MG/Unsupported.cs b/Aaru.Images/Apple2MG/Unsupported.cs index f660fa776..4eed67d9a 100644 --- a/Aaru.Images/Apple2MG/Unsupported.cs +++ b/Aaru.Images/Apple2MG/Unsupported.cs @@ -47,7 +47,7 @@ public sealed partial class Apple2Mg } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -55,7 +55,8 @@ public sealed partial class Apple2Mg } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -63,7 +64,8 @@ public sealed partial class Apple2Mg } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -72,7 +74,7 @@ public sealed partial class Apple2Mg } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/Apple2MG/Write.cs b/Aaru.Images/Apple2MG/Write.cs index 066b5c593..03702b79a 100644 --- a/Aaru.Images/Apple2MG/Write.cs +++ b/Aaru.Images/Apple2MG/Write.cs @@ -109,7 +109,7 @@ public sealed partial class Apple2Mg } /// - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { if(!IsWriting) { @@ -118,6 +118,13 @@ public sealed partial class Apple2Mg return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length != _imageInfo.SectorSize) { ErrorMessage = Localization.Incorrect_data_size; @@ -141,7 +148,7 @@ public sealed partial class Apple2Mg } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -150,6 +157,13 @@ public sealed partial class Apple2Mg return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length % _imageInfo.SectorSize != 0) { ErrorMessage = Localization.Incorrect_data_size; @@ -173,7 +187,7 @@ public sealed partial class Apple2Mg } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -181,7 +195,8 @@ public sealed partial class Apple2Mg } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -267,7 +282,7 @@ public sealed partial class Apple2Mg public bool SetGeometry(uint cylinders, uint heads, uint sectorsPerTrack) => true; /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -275,7 +290,7 @@ public sealed partial class Apple2Mg } /// - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; diff --git a/Aaru.Images/AppleDOS/Read.cs b/Aaru.Images/AppleDOS/Read.cs index f9c403300..ce8c69216 100644 --- a/Aaru.Images/AppleDOS/Read.cs +++ b/Aaru.Images/AppleDOS/Read.cs @@ -100,19 +100,22 @@ public sealed partial class AppleDos } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, false, 1, out buffer, out _); } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; diff --git a/Aaru.Images/AppleDOS/Unsupported.cs b/Aaru.Images/AppleDOS/Unsupported.cs index 73d8bbc85..40d3013d7 100644 --- a/Aaru.Images/AppleDOS/Unsupported.cs +++ b/Aaru.Images/AppleDOS/Unsupported.cs @@ -39,7 +39,7 @@ public sealed partial class AppleDos #region IWritableImage Members /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -47,7 +47,8 @@ public sealed partial class AppleDos } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -55,7 +56,8 @@ public sealed partial class AppleDos } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -64,7 +66,7 @@ public sealed partial class AppleDos } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/AppleDOS/Write.cs b/Aaru.Images/AppleDOS/Write.cs index ed9b7cb88..cded671d8 100644 --- a/Aaru.Images/AppleDOS/Write.cs +++ b/Aaru.Images/AppleDOS/Write.cs @@ -114,11 +114,11 @@ public sealed partial class AppleDos } /// - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) => - WriteSectors(data, sectorAddress, 1, [SectorStatus.Dumped]); + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) => + WriteSectors(data, sectorAddress, negative, 1, [SectorStatus.Dumped]); /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -127,6 +127,13 @@ public sealed partial class AppleDos return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length % _imageInfo.SectorSize != 0) { ErrorMessage = Localization.Incorrect_data_size; @@ -149,7 +156,7 @@ public sealed partial class AppleDos } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -157,7 +164,8 @@ public sealed partial class AppleDos } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -222,7 +230,7 @@ public sealed partial class AppleDos public bool SetGeometry(uint cylinders, uint heads, uint sectorsPerTrack) => true; /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -230,7 +238,7 @@ public sealed partial class AppleDos } /// - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; diff --git a/Aaru.Images/AppleNIB/Read.cs b/Aaru.Images/AppleNIB/Read.cs index 93c639006..5e05a251a 100644 --- a/Aaru.Images/AppleNIB/Read.cs +++ b/Aaru.Images/AppleNIB/Read.cs @@ -183,7 +183,7 @@ public sealed partial class AppleNib } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.Dumped; @@ -203,11 +203,14 @@ public sealed partial class AppleNib } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; @@ -217,7 +220,11 @@ public sealed partial class AppleNib for(uint i = 0; i < length; i++) { - ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] sector, out SectorStatus singleSectorStatus); + ErrorNumber errno = ReadSector(sectorAddress + i, + false, + out byte[] sector, + out SectorStatus singleSectorStatus); + sectorStatus[i] = singleSectorStatus; if(errno != ErrorNumber.NoError) return errno; @@ -231,10 +238,12 @@ public sealed partial class AppleNib } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(tag != SectorTagType.FloppyAddressMark) return ErrorNumber.NotSupported; @@ -243,10 +252,13 @@ public sealed partial class AppleNib } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; @@ -257,7 +269,7 @@ public sealed partial class AppleNib for(uint i = 0; i < length; i++) { - ErrorNumber errno = ReadSectorTag(sectorAddress + i, tag, out byte[] sector); + ErrorNumber errno = ReadSectorTag(sectorAddress + i, false, tag, out byte[] sector); if(errno != ErrorNumber.NoError) return errno; @@ -270,11 +282,14 @@ public sealed partial class AppleNib } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(_longSectors.TryGetValue(sectorAddress, out buffer)) @@ -290,12 +305,14 @@ public sealed partial class AppleNib } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; @@ -305,8 +322,10 @@ public sealed partial class AppleNib for(uint i = 0; i < length; i++) { - ErrorNumber errno = - ReadSectorLong(sectorAddress + i, out byte[] sector, out SectorStatus singleSectorStatus); + ErrorNumber errno = ReadSectorLong(sectorAddress + i, + false, + out byte[] sector, + out SectorStatus singleSectorStatus); sectorStatus[i] = singleSectorStatus; diff --git a/Aaru.Images/Apridisk/Read.cs b/Aaru.Images/Apridisk/Read.cs index 679afb289..41b4ed595 100644 --- a/Aaru.Images/Apridisk/Read.cs +++ b/Aaru.Images/Apridisk/Read.cs @@ -205,8 +205,9 @@ public sealed partial class Apridisk for(ushort cyl = 0; cyl < _imageInfo.Cylinders; cyl++) { for(ushort head = 0; head < _imageInfo.Heads; head++) - if(spts[cyl][head] < spt) - spt = spts[cyl][head]; + { + if(spts[cyl][head] < spt) spt = spts[cyl][head]; + } } _imageInfo.SectorsPerTrack = spt; @@ -228,12 +229,14 @@ public sealed partial class Apridisk } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { buffer = null; (ushort cylinder, byte head, byte sector) = LbaToChs(sectorAddress); sectorStatus = SectorStatus.NotDumped; + if(negative) return ErrorNumber.NotSupported; + if(cylinder >= _sectorsData.Length || head >= _sectorsData[cylinder].Length || sector > _sectorsData[cylinder][head].Length) @@ -246,11 +249,14 @@ public sealed partial class Apridisk } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; @@ -260,7 +266,11 @@ public sealed partial class Apridisk for(uint i = 0; i < length; i++) { - ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] sector, out SectorStatus singleSectorStatus); + ErrorNumber errno = ReadSector(sectorAddress + i, + false, + out byte[] sector, + out SectorStatus singleSectorStatus); + sectorStatus[i] = singleSectorStatus; if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Images/Apridisk/Unsupported.cs b/Aaru.Images/Apridisk/Unsupported.cs index 2299e54ad..71a35424d 100644 --- a/Aaru.Images/Apridisk/Unsupported.cs +++ b/Aaru.Images/Apridisk/Unsupported.cs @@ -47,7 +47,7 @@ public sealed partial class Apridisk } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -55,7 +55,8 @@ public sealed partial class Apridisk } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -63,7 +64,8 @@ public sealed partial class Apridisk } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -72,7 +74,7 @@ public sealed partial class Apridisk } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/Apridisk/Write.cs b/Aaru.Images/Apridisk/Write.cs index f53f15f14..83be7895d 100644 --- a/Aaru.Images/Apridisk/Write.cs +++ b/Aaru.Images/Apridisk/Write.cs @@ -93,10 +93,17 @@ public sealed partial class Apridisk } /// - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { (ushort cylinder, byte head, byte sector) = LbaToChs(sectorAddress); + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(cylinder >= _sectorsData.Length) { ErrorMessage = Localization.Sector_address_not_found; @@ -124,8 +131,15 @@ public sealed partial class Apridisk } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus) { + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + for(uint i = 0; i < length; i++) { (ushort cylinder, byte head, byte sector) = LbaToChs(sectorAddress); @@ -158,7 +172,7 @@ public sealed partial class Apridisk } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -166,7 +180,8 @@ public sealed partial class Apridisk } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -312,7 +327,7 @@ public sealed partial class Apridisk } /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; @@ -320,7 +335,7 @@ public sealed partial class Apridisk } /// - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; diff --git a/Aaru.Images/BLU/Read.cs b/Aaru.Images/BLU/Read.cs index d1fd33dec..7d88d8cde 100644 --- a/Aaru.Images/BLU/Read.cs +++ b/Aaru.Images/BLU/Read.cs @@ -73,9 +73,8 @@ public sealed partial class Blu AaruLogging.Debug(MODULE_NAME, "ImageHeader.bytesPerBlock = {0}", _imageHeader.BytesPerBlock); for(var i = 0; i < 0xD; i++) - { - if(_imageHeader.DeviceName[i] < 0x20) return ErrorNumber.InvalidArgument; - } + if(_imageHeader.DeviceName[i] < 0x20) + return ErrorNumber.InvalidArgument; if((_imageHeader.BytesPerBlock & 0xFE00) != 0x200) return ErrorNumber.InvalidArgument; @@ -155,23 +154,26 @@ public sealed partial class Blu } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) => - ReadSectorsTag(sectorAddress, 1, tag, out buffer); + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) => + ReadSectorsTag(sectorAddress, negative, 1, tag, out buffer); /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; @@ -200,10 +202,13 @@ public sealed partial class Blu } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; + if(negative) return ErrorNumber.NotSupported; + if(tag != SectorTagType.AppleSonyTag) return ErrorNumber.NotSupported; if(_bptag == 0) return ErrorNumber.NoData; @@ -233,20 +238,23 @@ public sealed partial class Blu } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectorsLong(sectorAddress, 1, out buffer, out _); + return ReadSectorsLong(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; diff --git a/Aaru.Images/BLU/Write.cs b/Aaru.Images/BLU/Write.cs index e38c8d760..c14184def 100644 --- a/Aaru.Images/BLU/Write.cs +++ b/Aaru.Images/BLU/Write.cs @@ -111,7 +111,7 @@ public sealed partial class Blu } /// - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { int longSectorSize = _imageInfo.MediaType == MediaType.PriamDataTower ? 536 : 532; @@ -122,6 +122,13 @@ public sealed partial class Blu return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length != 512) { ErrorMessage = Localization.Incorrect_data_size; @@ -145,7 +152,7 @@ public sealed partial class Blu } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus) { int longSectorSize = _imageInfo.MediaType == MediaType.PriamDataTower ? 536 : 532; @@ -156,6 +163,13 @@ public sealed partial class Blu return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length % 512 != 0) { ErrorMessage = Localization.Incorrect_data_size; @@ -179,7 +193,7 @@ public sealed partial class Blu } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { if(!IsWriting) { @@ -188,6 +202,13 @@ public sealed partial class Blu return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(sectorAddress >= _imageInfo.Sectors) { ErrorMessage = Localization.Tried_to_write_past_image_size; @@ -269,7 +290,8 @@ public sealed partial class Blu } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -278,6 +300,13 @@ public sealed partial class Blu return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(sectorAddress + length > _imageInfo.Sectors) { ErrorMessage = Localization.Tried_to_write_past_image_size; @@ -444,7 +473,7 @@ public sealed partial class Blu public bool SetGeometry(uint cylinders, uint heads, uint sectorsPerTrack) => true; /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; @@ -452,7 +481,7 @@ public sealed partial class Blu } /// - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; diff --git a/Aaru.Images/BlindWrite4/Read.cs b/Aaru.Images/BlindWrite4/Read.cs index 53abd6718..5548ebce4 100644 --- a/Aaru.Images/BlindWrite4/Read.cs +++ b/Aaru.Images/BlindWrite4/Read.cs @@ -745,9 +745,8 @@ public sealed partial class BlindWrite4 // As long as subchannel is written for any track, it is present for all tracks if(Tracks.Any(t => t.SubchannelType == TrackSubchannelType.Packed)) - { - foreach(Track track in Tracks) track.SubchannelType = TrackSubchannelType.Packed; - } + foreach(Track track in Tracks) + track.SubchannelType = TrackSubchannelType.Packed; _imageInfo.MediaType = MediaType.CD; @@ -829,16 +828,16 @@ public sealed partial class BlindWrite4 } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, false, 1, out buffer, out _); } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) => - ReadSectorsTag(sectorAddress, 1, tag, out buffer); + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) => + ReadSectorsTag(sectorAddress, false, 1, tag, out buffer); /// public ErrorNumber ReadSector(ulong sectorAddress, uint track, out byte[] buffer, out SectorStatus sectorStatus) @@ -853,11 +852,14 @@ public sealed partial class BlindWrite4 ReadSectorsTag(sectorAddress, 1, track, tag, out buffer); /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + foreach(KeyValuePair kvp in from kvp in _offsetMap where sectorAddress >= kvp.Value from track in Tracks @@ -871,10 +873,13 @@ public sealed partial class BlindWrite4 } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; + if(negative) return ErrorNumber.NotSupported; + foreach(KeyValuePair kvp in from kvp in _offsetMap where sectorAddress >= kvp.Value from track in Tracks @@ -1186,11 +1191,15 @@ public sealed partial class BlindWrite4 } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { + buffer = null; sectorStatus = SectorStatus.Dumped; - return ReadSectorsLong(sectorAddress, 1, out buffer, out _); + if(negative) return ErrorNumber.NotSupported; + + return ReadSectorsLong(sectorAddress, false, 1, out buffer, out _); } /// @@ -1202,12 +1211,14 @@ public sealed partial class BlindWrite4 } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + foreach(KeyValuePair kvp in from kvp in _offsetMap where sectorAddress >= kvp.Value from track in Tracks diff --git a/Aaru.Images/BlindWrite4/Verify.cs b/Aaru.Images/BlindWrite4/Verify.cs index 958fdc24f..23ea8fdc0 100644 --- a/Aaru.Images/BlindWrite4/Verify.cs +++ b/Aaru.Images/BlindWrite4/Verify.cs @@ -44,7 +44,7 @@ public sealed partial class BlindWrite4 /// public bool? VerifySector(ulong sectorAddress) { - ErrorNumber errno = ReadSectorLong(sectorAddress, out byte[] buffer, out _); + ErrorNumber errno = ReadSectorLong(sectorAddress, false, out byte[] buffer, out _); return errno != ErrorNumber.NoError ? null : CdChecksums.CheckCdSector(buffer); } @@ -55,7 +55,7 @@ public sealed partial class BlindWrite4 { failingLbas = []; unknownLbas = []; - ErrorNumber errno = ReadSectorsLong(sectorAddress, length, out byte[] buffer, out _); + ErrorNumber errno = ReadSectorsLong(sectorAddress, false, length, out byte[] buffer, out _); if(errno != ErrorNumber.NoError) return null; diff --git a/Aaru.Images/BlindWrite5/Read.cs b/Aaru.Images/BlindWrite5/Read.cs index a2b6d6ac5..b200b1906 100644 --- a/Aaru.Images/BlindWrite5/Read.cs +++ b/Aaru.Images/BlindWrite5/Read.cs @@ -1456,16 +1456,19 @@ public sealed partial class BlindWrite5 } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { + buffer = null; sectorStatus = SectorStatus.Dumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + if(negative) return ErrorNumber.NotSupported; + + return ReadSectors(sectorAddress, false, 1, out buffer, out _); } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) => - ReadSectorsTag(sectorAddress, 1, tag, out buffer); + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) => + ReadSectorsTag(sectorAddress, false, 1, tag, out buffer); /// public ErrorNumber ReadSector(ulong sectorAddress, uint track, out byte[] buffer, out SectorStatus sectorStatus) @@ -1480,11 +1483,14 @@ public sealed partial class BlindWrite5 ReadSectorsTag(sectorAddress, 1, track, tag, out buffer); /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + foreach(KeyValuePair kvp in from kvp in _offsetMap where sectorAddress >= kvp.Value from track in Tracks @@ -1498,10 +1504,13 @@ public sealed partial class BlindWrite5 } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; + if(negative) return ErrorNumber.NotSupported; + foreach(KeyValuePair kvp in from kvp in _offsetMap where sectorAddress >= kvp.Value from track in Tracks @@ -2144,11 +2153,12 @@ public sealed partial class BlindWrite5 } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectorsLong(sectorAddress, 1, out buffer, out _); + return ReadSectorsLong(sectorAddress, false, 1, out buffer, out _); } /// @@ -2160,7 +2170,7 @@ public sealed partial class BlindWrite5 } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/BlindWrite5/Verify.cs b/Aaru.Images/BlindWrite5/Verify.cs index 8e57dde6d..f442d9f74 100644 --- a/Aaru.Images/BlindWrite5/Verify.cs +++ b/Aaru.Images/BlindWrite5/Verify.cs @@ -44,7 +44,7 @@ public sealed partial class BlindWrite5 /// public bool? VerifySector(ulong sectorAddress) { - ErrorNumber errno = ReadSectorLong(sectorAddress, out byte[] buffer, out _); + ErrorNumber errno = ReadSectorLong(sectorAddress, false, out byte[] buffer, out _); return errno != ErrorNumber.NoError ? null : CdChecksums.CheckCdSector(buffer); } @@ -55,7 +55,7 @@ public sealed partial class BlindWrite5 { failingLbas = []; unknownLbas = []; - ErrorNumber errno = ReadSectorsLong(sectorAddress, length, out byte[] buffer, out _); + ErrorNumber errno = ReadSectorsLong(sectorAddress, false, length, out byte[] buffer, out _); if(errno != ErrorNumber.NoError) return null; diff --git a/Aaru.Images/CDRDAO/Read.cs b/Aaru.Images/CDRDAO/Read.cs index f7c5bb792..c44f22b04 100644 --- a/Aaru.Images/CDRDAO/Read.cs +++ b/Aaru.Images/CDRDAO/Read.cs @@ -724,30 +724,22 @@ public sealed partial class Cdrdao if(_discimage.Tracks[i].Arranger == null) AaruLogging.Debug(MODULE_NAME, "\t\t" + Localization.Arranger_is_not_set); else - { AaruLogging.Debug(MODULE_NAME, "\t\t" + Localization.Arranger_0, _discimage.Tracks[i].Arranger); - } if(_discimage.Tracks[i].Composer == null) AaruLogging.Debug(MODULE_NAME, "\t\t" + Localization.Composer_is_not_set); else - { AaruLogging.Debug(MODULE_NAME, "\t\t" + Localization.Composer_0, _discimage.Tracks[i].Composer); - } if(_discimage.Tracks[i].Performer == null) AaruLogging.Debug(MODULE_NAME, "\t\t" + Localization.Performer_is_not_set); else - { AaruLogging.Debug(MODULE_NAME, "\t\t" + Localization.Performer_0, _discimage.Tracks[i].Performer); - } if(_discimage.Tracks[i].Songwriter == null) AaruLogging.Debug(MODULE_NAME, "\t\t" + Localization.Songwriter_is_not_set); else - { AaruLogging.Debug(MODULE_NAME, "\t\t" + Localization.Songwriter_0, _discimage.Tracks[i].Songwriter); - } if(_discimage.Tracks[i].Title == null) AaruLogging.Debug(MODULE_NAME, "\t\t" + Localization.Title_is_not_set); @@ -969,16 +961,16 @@ public sealed partial class Cdrdao } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) => - ReadSectorsTag(sectorAddress, 1, tag, out buffer); + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) => + ReadSectorsTag(sectorAddress, negative, 1, tag, out buffer); /// public ErrorNumber ReadSector(ulong sectorAddress, uint track, out byte[] buffer, out SectorStatus sectorStatus) @@ -993,11 +985,14 @@ public sealed partial class Cdrdao ReadSectorsTag(sectorAddress, 1, track, tag, out buffer); /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + foreach(KeyValuePair kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value from cdrdaoTrack in _discimage.Tracks @@ -1010,10 +1005,13 @@ public sealed partial class Cdrdao } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; + if(negative) return ErrorNumber.NotSupported; + foreach(KeyValuePair kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value from cdrdaoTrack in _discimage.Tracks @@ -1364,11 +1362,12 @@ public sealed partial class Cdrdao } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectorsLong(sectorAddress, 1, out buffer, out _); + return ReadSectorsLong(sectorAddress, negative, 1, out buffer, out _); } /// @@ -1380,12 +1379,14 @@ public sealed partial class Cdrdao } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + foreach(KeyValuePair kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value from cdrdaoTrack in _discimage.Tracks diff --git a/Aaru.Images/CDRDAO/Verify.cs b/Aaru.Images/CDRDAO/Verify.cs index 58ab7ce48..d64c76999 100644 --- a/Aaru.Images/CDRDAO/Verify.cs +++ b/Aaru.Images/CDRDAO/Verify.cs @@ -44,7 +44,7 @@ public sealed partial class Cdrdao /// public bool? VerifySector(ulong sectorAddress) { - ErrorNumber errno = ReadSectorLong(sectorAddress, out byte[] buffer, out _); + ErrorNumber errno = ReadSectorLong(sectorAddress, false, out byte[] buffer, out _); return errno != ErrorNumber.NoError ? null : CdChecksums.CheckCdSector(buffer); } @@ -55,7 +55,7 @@ public sealed partial class Cdrdao { failingLbas = []; unknownLbas = []; - ErrorNumber errno = ReadSectorsLong(sectorAddress, length, out byte[] buffer, out _); + ErrorNumber errno = ReadSectorsLong(sectorAddress, false, length, out byte[] buffer, out _); if(errno != ErrorNumber.NoError) return null; diff --git a/Aaru.Images/CDRDAO/Write.cs b/Aaru.Images/CDRDAO/Write.cs index 2c7668350..88a54f212 100644 --- a/Aaru.Images/CDRDAO/Write.cs +++ b/Aaru.Images/CDRDAO/Write.cs @@ -143,7 +143,7 @@ public sealed partial class Cdrdao } /// - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { if(!IsWriting) { @@ -152,6 +152,13 @@ public sealed partial class Cdrdao return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + Track track = _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); @@ -209,7 +216,7 @@ public sealed partial class Cdrdao } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -218,6 +225,13 @@ public sealed partial class Cdrdao return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + Track track = _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); @@ -307,7 +321,7 @@ public sealed partial class Cdrdao } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { if(!IsWriting) { @@ -316,6 +330,13 @@ public sealed partial class Cdrdao return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + Track track = _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); @@ -369,7 +390,8 @@ public sealed partial class Cdrdao } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -378,6 +400,13 @@ public sealed partial class Cdrdao return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + Track track = _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); @@ -458,8 +487,9 @@ public sealed partial class Cdrdao } if(_writingTracks != null && _writingStreams != null) - foreach(FileStream oldTrack in _writingStreams.Select(t => t.Value).Distinct()) - oldTrack.Close(); + { + foreach(FileStream oldTrack in _writingStreams.Select(t => t.Value).Distinct()) oldTrack.Close(); + } ulong currentOffset = 0; _writingTracks = []; @@ -647,7 +677,7 @@ public sealed partial class Cdrdao } /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) { if(!IsWriting) { @@ -656,6 +686,13 @@ public sealed partial class Cdrdao return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + Track track = _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); @@ -731,7 +768,7 @@ public sealed partial class Cdrdao } /// - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) { if(!IsWriting) { @@ -740,6 +777,13 @@ public sealed partial class Cdrdao return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + Track track = _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); @@ -754,7 +798,7 @@ public sealed partial class Cdrdao { case SectorTagType.CdTrackFlags: case SectorTagType.CdTrackIsrc: - return WriteSectorTag(data, sectorAddress, tag); + return WriteSectorTag(data, sectorAddress, false, tag); case SectorTagType.CdSectorSubchannel: { if(track.SubchannelType == 0) diff --git a/Aaru.Images/CDRWin/Read.cs b/Aaru.Images/CDRWin/Read.cs index f5ed0d338..9a9da812d 100644 --- a/Aaru.Images/CDRWin/Read.cs +++ b/Aaru.Images/CDRWin/Read.cs @@ -1208,18 +1208,14 @@ public sealed partial class CdrWin if(_discImage.CdTextFile == null) AaruLogging.Debug(MODULE_NAME, "\t" + Localization.CD_TEXT_binary_file_not_set); else - { AaruLogging.Debug(MODULE_NAME, "\t" + Localization.CD_TEXT_binary_file_0, _discImage.CdTextFile); - } AaruLogging.Debug(MODULE_NAME, Localization.Disc_information); if(_discImage.OriginalMediaType == null) AaruLogging.Debug(MODULE_NAME, "\t" + Localization.ISOBuster_disc_type_not_set); else - { AaruLogging.Debug(MODULE_NAME, "\t" + Localization.ISOBuster_disc_type_0, _discImage.OriginalMediaType); - } AaruLogging.Debug(MODULE_NAME, "\t" + Localization.Guessed_disk_type_0, _discImage.MediaType); @@ -1688,16 +1684,16 @@ public sealed partial class CdrWin } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) => - ReadSectorsTag(sectorAddress, 1, tag, out buffer); + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) => + ReadSectorsTag(sectorAddress, negative, 1, tag, out buffer); /// public ErrorNumber ReadSector(ulong sectorAddress, uint track, out byte[] buffer, out SectorStatus sectorStatus) @@ -1712,11 +1708,14 @@ public sealed partial class CdrWin ReadSectorsTag(sectorAddress, 1, track, tag, out buffer); /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + foreach(KeyValuePair kvp in from kvp in _offsetMap where sectorAddress >= kvp.Value from cdrwinTrack in _discImage.Tracks @@ -1729,10 +1728,13 @@ public sealed partial class CdrWin } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; + if(negative) return ErrorNumber.NotSupported; + if(tag is SectorTagType.CdTrackFlags or SectorTagType.CdTrackIsrc) return ReadSectorsTag(sectorAddress, length, 0, tag, out buffer); @@ -2180,11 +2182,12 @@ public sealed partial class CdrWin } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectorsLong(sectorAddress, 1, out buffer, out _); + return ReadSectorsLong(sectorAddress, negative, 1, out buffer, out _); } /// @@ -2196,12 +2199,14 @@ public sealed partial class CdrWin } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + foreach(KeyValuePair kvp in from kvp in _offsetMap where sectorAddress >= kvp.Value from cdrwinTrack in _discImage.Tracks diff --git a/Aaru.Images/CDRWin/Verify.cs b/Aaru.Images/CDRWin/Verify.cs index d4d0f282b..fe09c97aa 100644 --- a/Aaru.Images/CDRWin/Verify.cs +++ b/Aaru.Images/CDRWin/Verify.cs @@ -158,7 +158,7 @@ public sealed partial class CdrWin /// public bool? VerifySector(ulong sectorAddress) { - ErrorNumber errno = ReadSectorLong(sectorAddress, out byte[] buffer, out _); + ErrorNumber errno = ReadSectorLong(sectorAddress, false, out byte[] buffer, out _); return errno != ErrorNumber.NoError ? null : CdChecksums.CheckCdSector(buffer); } @@ -169,7 +169,7 @@ public sealed partial class CdrWin { failingLbas = []; unknownLbas = []; - ErrorNumber errno = ReadSectorsLong(sectorAddress, length, out byte[] buffer, out _); + ErrorNumber errno = ReadSectorsLong(sectorAddress, false, length, out byte[] buffer, out _); if(errno != ErrorNumber.NoError) return null; diff --git a/Aaru.Images/CDRWin/Write.cs b/Aaru.Images/CDRWin/Write.cs index 5cfee870d..1cac4b2a2 100644 --- a/Aaru.Images/CDRWin/Write.cs +++ b/Aaru.Images/CDRWin/Write.cs @@ -168,7 +168,7 @@ public sealed partial class CdrWin } /// - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { if(!IsWriting) { @@ -177,6 +177,13 @@ public sealed partial class CdrWin return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + Track track = _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); @@ -220,7 +227,7 @@ public sealed partial class CdrWin } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -229,6 +236,13 @@ public sealed partial class CdrWin return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + Track track = _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); @@ -279,7 +293,7 @@ public sealed partial class CdrWin } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { if(!IsWriting) { @@ -288,6 +302,13 @@ public sealed partial class CdrWin return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + Track track = _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); @@ -324,7 +345,8 @@ public sealed partial class CdrWin } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -333,6 +355,13 @@ public sealed partial class CdrWin return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + Track track = _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); @@ -393,8 +422,9 @@ public sealed partial class CdrWin } if(_writingTracks != null && _writingStreams != null) - foreach(FileStream oldTrack in _writingStreams.Select(t => t.Value).Distinct()) - oldTrack.Close(); + { + foreach(FileStream oldTrack in _writingStreams.Select(t => t.Value).Distinct()) oldTrack.Close(); + } _writingTracks = []; @@ -634,7 +664,7 @@ public sealed partial class CdrWin } /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) { if(!IsWriting) { @@ -643,6 +673,13 @@ public sealed partial class CdrWin return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + Track track = _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); @@ -682,8 +719,8 @@ public sealed partial class CdrWin } /// - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) => - WriteSectorTag(data, sectorAddress, tag); + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) => + WriteSectorTag(data, sectorAddress, negative, tag); /// public bool SetDumpHardware(List dumpHardware) diff --git a/Aaru.Images/CHD/Read.cs b/Aaru.Images/CHD/Read.cs index aeec63fd3..481e2a4db 100644 --- a/Aaru.Images/CHD/Read.cs +++ b/Aaru.Images/CHD/Read.cs @@ -1349,11 +1349,13 @@ public sealed partial class Chd } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; var track = new Track(); @@ -1488,10 +1490,12 @@ public sealed partial class Chd } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; + if(negative) return ErrorNumber.NotSupported; + if(_isHdd) return ErrorNumber.NotSupported; if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; @@ -1764,11 +1768,14 @@ public sealed partial class Chd } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; @@ -1778,7 +1785,7 @@ public sealed partial class Chd for(uint i = 0; i < length; i++) { - ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] sector, out SectorStatus status); + ErrorNumber errno = ReadSector(sectorAddress + i, false, out byte[] sector, out SectorStatus status); sectorStatus[i] = status; if(errno != ErrorNumber.NoError) return errno; @@ -1792,10 +1799,13 @@ public sealed partial class Chd } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; @@ -1804,7 +1814,7 @@ public sealed partial class Chd for(uint i = 0; i < length; i++) { - ErrorNumber errno = ReadSectorTag(sectorAddress + i, tag, out byte[] sector); + ErrorNumber errno = ReadSectorTag(sectorAddress + i, false, tag, out byte[] sector); if(errno != ErrorNumber.NoError) return errno; @@ -1817,12 +1827,15 @@ public sealed partial class Chd } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; - if(_isHdd) return ReadSector(sectorAddress, out buffer, out sectorStatus); + if(negative) return ErrorNumber.NotSupported; + + if(_isHdd) return ReadSector(sectorAddress, false, out buffer, out sectorStatus); if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; @@ -1918,12 +1931,14 @@ public sealed partial class Chd } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; @@ -1933,7 +1948,7 @@ public sealed partial class Chd for(uint i = 0; i < length; i++) { - ErrorNumber errno = ReadSectorLong(sectorAddress + i, out byte[] sector, out SectorStatus status); + ErrorNumber errno = ReadSectorLong(sectorAddress + i, false, out byte[] sector, out SectorStatus status); sectorStatus[i] = status; if(errno != ErrorNumber.NoError) return errno; @@ -1982,7 +1997,7 @@ public sealed partial class Chd return _isHdd ? ErrorNumber.NotSupported - : ReadSector(GetAbsoluteSector(sectorAddress, track), out buffer, out sectorStatus); + : ReadSector(GetAbsoluteSector(sectorAddress, track), false, out buffer, out sectorStatus); } /// @@ -1992,7 +2007,7 @@ public sealed partial class Chd return _isHdd ? ErrorNumber.NotSupported - : ReadSectorTag(GetAbsoluteSector(sectorAddress, track), tag, out buffer); + : ReadSectorTag(GetAbsoluteSector(sectorAddress, track), false, tag, out buffer); } /// @@ -2004,7 +2019,7 @@ public sealed partial class Chd return _isHdd ? ErrorNumber.NotSupported - : ReadSectors(GetAbsoluteSector(sectorAddress, track), length, out buffer, out sectorStatus); + : ReadSectors(GetAbsoluteSector(sectorAddress, track), false, length, out buffer, out sectorStatus); } /// @@ -2015,7 +2030,7 @@ public sealed partial class Chd return _isHdd ? ErrorNumber.NotSupported - : ReadSectorsTag(GetAbsoluteSector(sectorAddress, track), length, tag, out buffer); + : ReadSectorsTag(GetAbsoluteSector(sectorAddress, track), false, length, tag, out buffer); } /// @@ -2026,7 +2041,7 @@ public sealed partial class Chd return _isHdd ? ErrorNumber.NotSupported - : ReadSectorLong(GetAbsoluteSector(sectorAddress, track), out buffer, out sectorStatus); + : ReadSectorLong(GetAbsoluteSector(sectorAddress, track), false, out buffer, out sectorStatus); } /// @@ -2038,7 +2053,11 @@ public sealed partial class Chd return _isHdd ? ErrorNumber.NotSupported - : ReadSectorsLong(GetAbsoluteSector(sectorAddress, track), length, out buffer, out sectorStatus); + : ReadSectorsLong(GetAbsoluteSector(sectorAddress, track), + false, + length, + out buffer, + out sectorStatus); } #endregion diff --git a/Aaru.Images/CHD/Verify.cs b/Aaru.Images/CHD/Verify.cs index f11047dd8..37b0d55ca 100644 --- a/Aaru.Images/CHD/Verify.cs +++ b/Aaru.Images/CHD/Verify.cs @@ -90,7 +90,7 @@ public sealed partial class Chd { if(_isHdd) return null; - ErrorNumber errno = ReadSectorLong(sectorAddress, out byte[] buffer, out _); + ErrorNumber errno = ReadSectorLong(sectorAddress, false, out byte[] buffer, out _); return errno != ErrorNumber.NoError ? null : CdChecksums.CheckCdSector(buffer); } @@ -104,7 +104,7 @@ public sealed partial class Chd if(_isHdd) return null; - ErrorNumber errno = ReadSectorsLong(sectorAddress, length, out byte[] buffer, out _); + ErrorNumber errno = ReadSectorsLong(sectorAddress, false, length, out byte[] buffer, out _); if(errno != ErrorNumber.NoError) return null; diff --git a/Aaru.Images/CPCDSK/Read.cs b/Aaru.Images/CPCDSK/Read.cs index aaeb9ebb1..924065e30 100644 --- a/Aaru.Images/CPCDSK/Read.cs +++ b/Aaru.Images/CPCDSK/Read.cs @@ -63,8 +63,9 @@ public sealed partial class Cpcdsk int pos; for(pos = 0; pos < 254; pos++) - if(headerB[pos] == 0x0D && headerB[pos + 1] == 0x0A) - break; + { + if(headerB[pos] == 0x0D && headerB[pos + 1] == 0x0A) break; + } if(pos >= 254) return ErrorNumber.InvalidArgument; @@ -316,8 +317,13 @@ public sealed partial class Cpcdsk } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { + buffer = null; + sectorStatus = SectorStatus.NotDumped; + + if(negative) return ErrorNumber.NotSupported; + if(_sectors.TryGetValue(sectorAddress, out buffer)) { sectorStatus = SectorStatus.Dumped; @@ -331,11 +337,14 @@ public sealed partial class Cpcdsk } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; @@ -345,7 +354,7 @@ public sealed partial class Cpcdsk for(uint i = 0; i < length; i++) { - ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] sector, out SectorStatus status); + ErrorNumber errno = ReadSector(sectorAddress + i, false, out byte[] sector, out SectorStatus status); sectorStatus[i] = status; if(errno != ErrorNumber.NoError) return errno; @@ -359,20 +368,25 @@ public sealed partial class Cpcdsk } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; + if(negative) return ErrorNumber.NotSupported; + if(tag != SectorTagType.FloppyAddressMark) return ErrorNumber.NotSupported; return _addressMarks.TryGetValue(sectorAddress, out buffer) ? ErrorNumber.NoError : ErrorNumber.SectorNotFound; } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; + if(negative) return ErrorNumber.NotSupported; + if(tag != SectorTagType.FloppyAddressMark) return ErrorNumber.NotSupported; if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; @@ -383,7 +397,7 @@ public sealed partial class Cpcdsk for(uint i = 0; i < length; i++) { - ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] addressMark, out _); + ErrorNumber errno = ReadSector(sectorAddress + i, false, out byte[] addressMark, out _); if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Images/CPCDSK/Unsupported.cs b/Aaru.Images/CPCDSK/Unsupported.cs index 4febe5a9e..0b33dce35 100644 --- a/Aaru.Images/CPCDSK/Unsupported.cs +++ b/Aaru.Images/CPCDSK/Unsupported.cs @@ -47,7 +47,8 @@ public sealed partial class Cpcdsk } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -56,7 +57,7 @@ public sealed partial class Cpcdsk } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/CisCopy/Read.cs b/Aaru.Images/CisCopy/Read.cs index 0d2a0d9b8..13589c8de 100644 --- a/Aaru.Images/CisCopy/Read.cs +++ b/Aaru.Images/CisCopy/Read.cs @@ -190,19 +190,22 @@ public sealed partial class CisCopy } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; diff --git a/Aaru.Images/CisCopy/Unsupported.cs b/Aaru.Images/CisCopy/Unsupported.cs index 084bb63e9..17e05b53c 100644 --- a/Aaru.Images/CisCopy/Unsupported.cs +++ b/Aaru.Images/CisCopy/Unsupported.cs @@ -39,7 +39,7 @@ public sealed partial class CisCopy #region IWritableImage Members /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -47,7 +47,8 @@ public sealed partial class CisCopy } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -55,7 +56,8 @@ public sealed partial class CisCopy } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -64,7 +66,7 @@ public sealed partial class CisCopy } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/CisCopy/Write.cs b/Aaru.Images/CisCopy/Write.cs index 509da93ee..40ba744e4 100644 --- a/Aaru.Images/CisCopy/Write.cs +++ b/Aaru.Images/CisCopy/Write.cs @@ -157,7 +157,7 @@ public sealed partial class CisCopy } /// - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { if(!IsWriting) { @@ -166,6 +166,13 @@ public sealed partial class CisCopy return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length != 512) { ErrorMessage = Localization.Incorrect_data_size; @@ -189,7 +196,7 @@ public sealed partial class CisCopy } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -198,6 +205,13 @@ public sealed partial class CisCopy return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length % 512 != 0) { ErrorMessage = Localization.Incorrect_data_size; @@ -221,7 +235,7 @@ public sealed partial class CisCopy } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -229,7 +243,8 @@ public sealed partial class CisCopy } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -262,7 +277,7 @@ public sealed partial class CisCopy public bool SetGeometry(uint cylinders, uint heads, uint sectorsPerTrack) => true; /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; @@ -270,7 +285,7 @@ public sealed partial class CisCopy } /// - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; diff --git a/Aaru.Images/CloneCD/Read.cs b/Aaru.Images/CloneCD/Read.cs index a31843368..3dd736cb2 100644 --- a/Aaru.Images/CloneCD/Read.cs +++ b/Aaru.Images/CloneCD/Read.cs @@ -902,16 +902,16 @@ public sealed partial class CloneCd } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) => - ReadSectorsTag(sectorAddress, 1, tag, out buffer); + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) => + ReadSectorsTag(sectorAddress, negative, 1, tag, out buffer); /// public ErrorNumber ReadSector(ulong sectorAddress, uint track, out byte[] buffer, out SectorStatus sectorStatus) @@ -926,11 +926,14 @@ public sealed partial class CloneCd ReadSectorsTag(sectorAddress, 1, track, tag, out buffer); /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + foreach(KeyValuePair kvp in from kvp in _offsetMap where sectorAddress >= kvp.Value from track in Tracks @@ -944,10 +947,13 @@ public sealed partial class CloneCd } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; + if(negative) return ErrorNumber.NotSupported; + foreach(KeyValuePair kvp in _offsetMap.Where(kvp => sectorAddress >= kvp.Value) .SelectMany(_ => Tracks, (kvp, track) => new @@ -1322,11 +1328,12 @@ public sealed partial class CloneCd } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectorsLong(sectorAddress, 1, out buffer, out _); + return ReadSectorsLong(sectorAddress, negative, 1, out buffer, out _); } /// @@ -1338,12 +1345,14 @@ public sealed partial class CloneCd } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + foreach(KeyValuePair kvp in from kvp in _offsetMap where sectorAddress >= kvp.Value from track in Tracks diff --git a/Aaru.Images/CloneCD/Verify.cs b/Aaru.Images/CloneCD/Verify.cs index b46165283..9fc68c3c9 100644 --- a/Aaru.Images/CloneCD/Verify.cs +++ b/Aaru.Images/CloneCD/Verify.cs @@ -44,7 +44,7 @@ public sealed partial class CloneCd /// public bool? VerifySector(ulong sectorAddress) { - ErrorNumber errno = ReadSectorLong(sectorAddress, out byte[] buffer, out _); + ErrorNumber errno = ReadSectorLong(sectorAddress, false, out byte[] buffer, out _); return errno != ErrorNumber.NoError ? null : CdChecksums.CheckCdSector(buffer); } @@ -55,7 +55,7 @@ public sealed partial class CloneCd { failingLbas = []; unknownLbas = []; - ErrorNumber errno = ReadSectorsLong(sectorAddress, length, out byte[] buffer, out _); + ErrorNumber errno = ReadSectorsLong(sectorAddress, false, length, out byte[] buffer, out _); if(errno != ErrorNumber.NoError) return null; diff --git a/Aaru.Images/CloneCD/Write.cs b/Aaru.Images/CloneCD/Write.cs index 2677b9fae..cdd510c85 100644 --- a/Aaru.Images/CloneCD/Write.cs +++ b/Aaru.Images/CloneCD/Write.cs @@ -126,7 +126,7 @@ public sealed partial class CloneCd } /// - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { if(!IsWriting) { @@ -135,6 +135,13 @@ public sealed partial class CloneCd return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + // TODO: Implement ECC generation ErrorMessage = Localization.This_format_requires_sectors_to_be_raw_Generating_ECC_is_not_yet_implemented; @@ -142,7 +149,7 @@ public sealed partial class CloneCd } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -151,6 +158,13 @@ public sealed partial class CloneCd return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + // TODO: Implement ECC generation ErrorMessage = Localization.This_format_requires_sectors_to_be_raw_Generating_ECC_is_not_yet_implemented; @@ -158,7 +172,7 @@ public sealed partial class CloneCd } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { if(!IsWriting) { @@ -167,6 +181,13 @@ public sealed partial class CloneCd return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + Track track = Tracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); if(track is null) @@ -193,7 +214,8 @@ public sealed partial class CloneCd } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -202,6 +224,13 @@ public sealed partial class CloneCd return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + Track track = Tracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); if(track is null) @@ -419,7 +448,7 @@ public sealed partial class CloneCd } /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) { if(!IsWriting) { @@ -428,6 +457,13 @@ public sealed partial class CloneCd return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + Track track = Tracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); if(track is null) @@ -507,7 +543,7 @@ public sealed partial class CloneCd } /// - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) { if(!IsWriting) { @@ -516,6 +552,13 @@ public sealed partial class CloneCd return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + Track track = Tracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); if(track is null) @@ -529,7 +572,7 @@ public sealed partial class CloneCd { case SectorTagType.CdTrackFlags: case SectorTagType.CdTrackIsrc: - return WriteSectorTag(data, sectorAddress, tag); + return WriteSectorTag(data, sectorAddress, false, tag); case SectorTagType.CdSectorSubchannel: { if(track.SubchannelType == 0) diff --git a/Aaru.Images/CopyQM/Read.cs b/Aaru.Images/CopyQM/Read.cs index 4311037ad..e9b0b1711 100644 --- a/Aaru.Images/CopyQM/Read.cs +++ b/Aaru.Images/CopyQM/Read.cs @@ -213,19 +213,22 @@ public sealed partial class CopyQm } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; diff --git a/Aaru.Images/CopyQM/Unsupported.cs b/Aaru.Images/CopyQM/Unsupported.cs index 705000174..b491470bb 100644 --- a/Aaru.Images/CopyQM/Unsupported.cs +++ b/Aaru.Images/CopyQM/Unsupported.cs @@ -39,7 +39,7 @@ public sealed partial class CopyQm #region IMediaImage Members /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -47,7 +47,8 @@ public sealed partial class CopyQm } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -55,7 +56,8 @@ public sealed partial class CopyQm } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -64,7 +66,7 @@ public sealed partial class CopyQm } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/CopyTape/Read.cs b/Aaru.Images/CopyTape/Read.cs index f80413a26..e4399d889 100644 --- a/Aaru.Images/CopyTape/Read.cs +++ b/Aaru.Images/CopyTape/Read.cs @@ -188,11 +188,13 @@ public sealed partial class CopyTape } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress >= (ulong)_blockPositionCache.LongLength) return ErrorNumber.OutOfRange; _imageStream.Position = _blockPositionCache[sectorAddress]; @@ -226,17 +228,20 @@ public sealed partial class CopyTape } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + var ms = new MemoryStream(); sectorStatus = new SectorStatus[length]; for(uint i = 0; i < length; i++) { - ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] sector, out SectorStatus status); + ErrorNumber errno = ReadSector(sectorAddress + i, false, out byte[] sector, out SectorStatus status); if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Images/CopyTape/Unsupported.cs b/Aaru.Images/CopyTape/Unsupported.cs index 917613b54..994df4cae 100644 --- a/Aaru.Images/CopyTape/Unsupported.cs +++ b/Aaru.Images/CopyTape/Unsupported.cs @@ -47,7 +47,7 @@ public sealed partial class CopyTape } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -55,7 +55,8 @@ public sealed partial class CopyTape } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -63,7 +64,8 @@ public sealed partial class CopyTape } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -72,7 +74,7 @@ public sealed partial class CopyTape } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/CopyTape/Write.cs b/Aaru.Images/CopyTape/Write.cs index aacc7c899..2b4ed9725 100644 --- a/Aaru.Images/CopyTape/Write.cs +++ b/Aaru.Images/CopyTape/Write.cs @@ -102,8 +102,15 @@ public sealed partial class CopyTape } /// - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(!_writtenBlockPositions.TryGetValue(sectorAddress, out ulong position)) { if(_dataStream.Length != 0 && _lastWrittenBlock >= sectorAddress) @@ -138,11 +145,18 @@ public sealed partial class CopyTape } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus) { + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + for(uint i = 0; i < length; i++) { - bool ret = WriteSector(data, sectorAddress + i, sectorStatus[i]); + bool ret = WriteSector(data, sectorAddress + i, false, sectorStatus[i]); if(!ret) return false; } @@ -151,7 +165,7 @@ public sealed partial class CopyTape } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { ErrorMessage = Localization.Unsupported_feature; @@ -159,7 +173,8 @@ public sealed partial class CopyTape } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) { ErrorMessage = Localization.Unsupported_feature; @@ -199,7 +214,7 @@ public sealed partial class CopyTape } /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; @@ -207,7 +222,7 @@ public sealed partial class CopyTape } /// - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; diff --git a/Aaru.Images/D88/Read.cs b/Aaru.Images/D88/Read.cs index 0b48c26aa..03317bfb2 100644 --- a/Aaru.Images/D88/Read.cs +++ b/Aaru.Images/D88/Read.cs @@ -348,19 +348,22 @@ public sealed partial class D88 } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; diff --git a/Aaru.Images/D88/Unsupported.cs b/Aaru.Images/D88/Unsupported.cs index 3e25502f5..a1271836c 100644 --- a/Aaru.Images/D88/Unsupported.cs +++ b/Aaru.Images/D88/Unsupported.cs @@ -47,7 +47,7 @@ public sealed partial class D88 } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -55,7 +55,8 @@ public sealed partial class D88 } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -63,7 +64,8 @@ public sealed partial class D88 } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -72,7 +74,7 @@ public sealed partial class D88 } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/DART/Read.cs b/Aaru.Images/DART/Read.cs index 8e0d1f188..4b4a7c573 100644 --- a/Aaru.Images/DART/Read.cs +++ b/Aaru.Images/DART/Read.cs @@ -303,23 +303,26 @@ public sealed partial class Dart } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) => - ReadSectorsTag(sectorAddress, 1, tag, out buffer); + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) => + ReadSectorsTag(sectorAddress, negative, 1, tag, out buffer); /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; @@ -334,10 +337,13 @@ public sealed partial class Dart } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; + if(negative) return ErrorNumber.NotSupported; + if(tag != SectorTagType.AppleSonyTag) return ErrorNumber.NotSupported; if(_tagCache == null || _tagCache.Length == 0) return ErrorNumber.NoData; @@ -354,29 +360,32 @@ public sealed partial class Dart } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectorsLong(sectorAddress, 1, out buffer, out _); + return ReadSectorsLong(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; - ErrorNumber errno = ReadSectors(sectorAddress, length, out byte[] data, out sectorStatus); + ErrorNumber errno = ReadSectors(sectorAddress, false, length, out byte[] data, out sectorStatus); if(errno != ErrorNumber.NoError) return errno; - errno = ReadSectorsTag(sectorAddress, length, SectorTagType.AppleSonyTag, out byte[] tags); + errno = ReadSectorsTag(sectorAddress, false, length, SectorTagType.AppleSonyTag, out byte[] tags); if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Images/DIM/Read.cs b/Aaru.Images/DIM/Read.cs index 9f0a26f2e..8e572ec52 100644 --- a/Aaru.Images/DIM/Read.cs +++ b/Aaru.Images/DIM/Read.cs @@ -233,19 +233,22 @@ public sealed partial class Dim } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; diff --git a/Aaru.Images/DIM/Unsupported.cs b/Aaru.Images/DIM/Unsupported.cs index 0de17363e..2c0e64a84 100644 --- a/Aaru.Images/DIM/Unsupported.cs +++ b/Aaru.Images/DIM/Unsupported.cs @@ -49,7 +49,7 @@ public sealed partial class Dim } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -57,7 +57,8 @@ public sealed partial class Dim } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -65,7 +66,8 @@ public sealed partial class Dim } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -74,7 +76,7 @@ public sealed partial class Dim } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/DiscFerret/Read.cs b/Aaru.Images/DiscFerret/Read.cs index 7f916d933..540b32ffd 100644 --- a/Aaru.Images/DiscFerret/Read.cs +++ b/Aaru.Images/DiscFerret/Read.cs @@ -128,15 +128,15 @@ public sealed partial class DiscFerret } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.NotDumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -144,7 +144,8 @@ public sealed partial class DiscFerret } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; @@ -153,7 +154,8 @@ public sealed partial class DiscFerret } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -161,15 +163,16 @@ public sealed partial class DiscFerret } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { sectorStatus = SectorStatus.NotDumped; - return ReadSectorsLong(sectorAddress, 1, out buffer, out _); + return ReadSectorsLong(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/DiscJuggler/Read.cs b/Aaru.Images/DiscJuggler/Read.cs index 51c6c8327..4c5e46f65 100644 --- a/Aaru.Images/DiscJuggler/Read.cs +++ b/Aaru.Images/DiscJuggler/Read.cs @@ -793,16 +793,16 @@ public sealed partial class DiscJuggler } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) => - ReadSectorsTag(sectorAddress, 1, tag, out buffer); + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) => + ReadSectorsTag(sectorAddress, negative, 1, tag, out buffer); /// public ErrorNumber ReadSector(ulong sectorAddress, uint track, out byte[] buffer, out SectorStatus sectorStatus) @@ -817,11 +817,14 @@ public sealed partial class DiscJuggler ReadSectorsTag(sectorAddress, 1, track, tag, out buffer); /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + foreach(KeyValuePair kvp in from kvp in _offsetMap where sectorAddress >= kvp.Value from track in Tracks @@ -835,10 +838,13 @@ public sealed partial class DiscJuggler } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; + if(negative) return ErrorNumber.NotSupported; + foreach(KeyValuePair kvp in from kvp in _offsetMap where sectorAddress >= kvp.Value from track in Tracks @@ -1225,11 +1231,12 @@ public sealed partial class DiscJuggler } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectorsLong(sectorAddress, 1, out buffer, out _); + return ReadSectorsLong(sectorAddress, negative, 1, out buffer, out _); } /// @@ -1241,12 +1248,14 @@ public sealed partial class DiscJuggler } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + foreach(KeyValuePair kvp in from kvp in _offsetMap where sectorAddress >= kvp.Value from track in Tracks diff --git a/Aaru.Images/DiscJuggler/Verify.cs b/Aaru.Images/DiscJuggler/Verify.cs index 06d5a24fb..75f5ffd74 100644 --- a/Aaru.Images/DiscJuggler/Verify.cs +++ b/Aaru.Images/DiscJuggler/Verify.cs @@ -44,7 +44,7 @@ public sealed partial class DiscJuggler /// public bool? VerifySector(ulong sectorAddress) { - ErrorNumber errno = ReadSectorLong(sectorAddress, out byte[] buffer, out _); + ErrorNumber errno = ReadSectorLong(sectorAddress, false, out byte[] buffer, out _); return errno != ErrorNumber.NoError ? null : CdChecksums.CheckCdSector(buffer); } @@ -55,7 +55,7 @@ public sealed partial class DiscJuggler { failingLbas = []; unknownLbas = []; - ErrorNumber errno = ReadSectorsLong(sectorAddress, length, out byte[] buffer, out _); + ErrorNumber errno = ReadSectorsLong(sectorAddress, false, length, out byte[] buffer, out _); if(errno != ErrorNumber.NoError) return null; diff --git a/Aaru.Images/DiskCopy42/Read.cs b/Aaru.Images/DiskCopy42/Read.cs index 5905b7486..367aed760 100644 --- a/Aaru.Images/DiskCopy42/Read.cs +++ b/Aaru.Images/DiskCopy42/Read.cs @@ -398,23 +398,26 @@ public sealed partial class DiskCopy42 } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) => - ReadSectorsTag(sectorAddress, 1, tag, out buffer); + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) => + ReadSectorsTag(sectorAddress, negative, 1, tag, out buffer); /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > imageInfo.Sectors - 1) return ErrorNumber.SectorNotFound; if(sectorAddress + length > imageInfo.Sectors) return ErrorNumber.OutOfRange; @@ -441,10 +444,13 @@ public sealed partial class DiskCopy42 } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; + if(negative) return ErrorNumber.NotSupported; + if(tag != SectorTagType.AppleSonyTag) return ErrorNumber.NotSupported; if(header.TagSize == 0) return ErrorNumber.NoData; @@ -468,29 +474,32 @@ public sealed partial class DiskCopy42 } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectorsLong(sectorAddress, 1, out buffer, out _); + return ReadSectorsLong(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > imageInfo.Sectors) return ErrorNumber.OutOfRange; - ErrorNumber errno = ReadSectors(sectorAddress, length, out byte[] data, out sectorStatus); + ErrorNumber errno = ReadSectors(sectorAddress, false, length, out byte[] data, out sectorStatus); if(errno != ErrorNumber.NoError) return errno; - errno = ReadSectorsTag(sectorAddress, length, SectorTagType.AppleSonyTag, out byte[] tags); + errno = ReadSectorsTag(sectorAddress, false, length, SectorTagType.AppleSonyTag, out byte[] tags); if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Images/DiskCopy42/Write.cs b/Aaru.Images/DiskCopy42/Write.cs index 923da274d..7e9ccdd88 100644 --- a/Aaru.Images/DiskCopy42/Write.cs +++ b/Aaru.Images/DiskCopy42/Write.cs @@ -223,7 +223,7 @@ public sealed partial class DiskCopy42 } /// - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { if(!IsWriting) { @@ -232,6 +232,13 @@ public sealed partial class DiskCopy42 return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length != 512) { ErrorMessage = Localization.Incorrect_data_size; @@ -255,7 +262,7 @@ public sealed partial class DiskCopy42 } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -264,6 +271,13 @@ public sealed partial class DiskCopy42 return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length % 512 != 0) { ErrorMessage = Localization.Incorrect_data_size; @@ -287,7 +301,7 @@ public sealed partial class DiskCopy42 } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { if(!IsWriting) { @@ -328,7 +342,8 @@ public sealed partial class DiskCopy42 } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -434,7 +449,7 @@ public sealed partial class DiskCopy42 public bool SetGeometry(uint cylinders, uint heads, uint sectorsPerTrack) => true; /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; @@ -442,7 +457,7 @@ public sealed partial class DiskCopy42 } /// - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; diff --git a/Aaru.Images/DiskDupe/Read.cs b/Aaru.Images/DiskDupe/Read.cs index 39671f9d7..3f36e170a 100644 --- a/Aaru.Images/DiskDupe/Read.cs +++ b/Aaru.Images/DiskDupe/Read.cs @@ -86,10 +86,12 @@ public sealed partial class DiskDupe return ErrorNumber.NoError; } - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; + + if(negative) return ErrorNumber.NotSupported; var trackNum = (int)(sectorAddress / _imageInfo.SectorsPerTrack); var sectorOffset = (int)(sectorAddress % _imageInfo.SectorsPerTrack); @@ -115,11 +117,14 @@ public sealed partial class DiskDupe return ErrorNumber.NoError; } - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; @@ -129,7 +134,7 @@ public sealed partial class DiskDupe for(uint i = 0; i < length; i++) { - ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] sector, out SectorStatus status); + ErrorNumber errno = ReadSector(sectorAddress + i, false, out byte[] sector, out SectorStatus status); if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Images/DiskDupe/Unsupported.cs b/Aaru.Images/DiskDupe/Unsupported.cs index d15ad35c2..ad2e63238 100644 --- a/Aaru.Images/DiskDupe/Unsupported.cs +++ b/Aaru.Images/DiskDupe/Unsupported.cs @@ -48,7 +48,7 @@ public sealed partial class DiskDupe } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -56,7 +56,8 @@ public sealed partial class DiskDupe } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -64,7 +65,8 @@ public sealed partial class DiskDupe } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -73,7 +75,7 @@ public sealed partial class DiskDupe } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/DriDiskCopy/Read.cs b/Aaru.Images/DriDiskCopy/Read.cs index 23c02ca23..62fe95e87 100644 --- a/Aaru.Images/DriDiskCopy/Read.cs +++ b/Aaru.Images/DriDiskCopy/Read.cs @@ -126,19 +126,22 @@ public sealed partial class DriDiskCopy } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; diff --git a/Aaru.Images/DriDiskCopy/Unsupported.cs b/Aaru.Images/DriDiskCopy/Unsupported.cs index 6fcbad6fc..35f89eece 100644 --- a/Aaru.Images/DriDiskCopy/Unsupported.cs +++ b/Aaru.Images/DriDiskCopy/Unsupported.cs @@ -39,7 +39,7 @@ public sealed partial class DriDiskCopy #region IWritableImage Members /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -47,7 +47,8 @@ public sealed partial class DriDiskCopy } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -55,7 +56,8 @@ public sealed partial class DriDiskCopy } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -64,7 +66,7 @@ public sealed partial class DriDiskCopy } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/DriDiskCopy/Write.cs b/Aaru.Images/DriDiskCopy/Write.cs index cec08432f..bf5a7dcb7 100644 --- a/Aaru.Images/DriDiskCopy/Write.cs +++ b/Aaru.Images/DriDiskCopy/Write.cs @@ -131,7 +131,7 @@ public sealed partial class DriDiskCopy } /// - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { if(!IsWriting) { @@ -140,6 +140,13 @@ public sealed partial class DriDiskCopy return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length != _imageInfo.SectorSize) { ErrorMessage = Localization.Incorrect_data_size; @@ -163,7 +170,7 @@ public sealed partial class DriDiskCopy } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -172,6 +179,13 @@ public sealed partial class DriDiskCopy return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length % _imageInfo.SectorSize != 0) { ErrorMessage = Localization.Incorrect_data_size; @@ -195,7 +209,7 @@ public sealed partial class DriDiskCopy } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -203,7 +217,8 @@ public sealed partial class DriDiskCopy } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -245,7 +260,7 @@ public sealed partial class DriDiskCopy public bool SetGeometry(uint cylinders, uint heads, uint sectorsPerTrack) => true; /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; @@ -253,7 +268,7 @@ public sealed partial class DriDiskCopy } /// - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; diff --git a/Aaru.Images/GDI/Read.cs b/Aaru.Images/GDI/Read.cs index c538e0049..94c866cd6 100644 --- a/Aaru.Images/GDI/Read.cs +++ b/Aaru.Images/GDI/Read.cs @@ -342,16 +342,16 @@ public sealed partial class Gdi } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) => - ReadSectorsTag(sectorAddress, 1, tag, out buffer); + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) => + ReadSectorsTag(sectorAddress, negative, 1, tag, out buffer); /// public ErrorNumber ReadSector(ulong sectorAddress, uint track, out byte[] buffer, out SectorStatus sectorStatus) @@ -366,20 +366,21 @@ public sealed partial class Gdi ReadSectorsTag(sectorAddress, 1, track, tag, out buffer); /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + foreach(KeyValuePair kvp in from kvp in _offsetMap where sectorAddress >= kvp.Value from gdiTrack in _discImage.Tracks where gdiTrack.Sequence == kvp.Key where sectorAddress - kvp.Value < gdiTrack.Sectors select kvp) - { return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key, out buffer, out sectorStatus); - } _offsetMap.TryGetValue(0, out ulong transitionStart); @@ -390,10 +391,13 @@ public sealed partial class Gdi } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; + if(negative) return ErrorNumber.NotSupported; + foreach(KeyValuePair kvp in from kvp in _offsetMap where sectorAddress >= kvp.Value from gdiTrack in _discImage.Tracks @@ -719,11 +723,12 @@ public sealed partial class Gdi } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectorsLong(sectorAddress, 1, out buffer, out _); + return ReadSectorsLong(sectorAddress, negative, 1, out buffer, out _); } /// @@ -735,12 +740,14 @@ public sealed partial class Gdi } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + foreach(KeyValuePair kvp in from kvp in _offsetMap where sectorAddress >= kvp.Value from gdiTrack in _discImage.Tracks diff --git a/Aaru.Images/GDI/Verify.cs b/Aaru.Images/GDI/Verify.cs index d53f08414..931323331 100644 --- a/Aaru.Images/GDI/Verify.cs +++ b/Aaru.Images/GDI/Verify.cs @@ -46,7 +46,7 @@ public sealed partial class Gdi /// public bool? VerifySector(ulong sectorAddress) { - ErrorNumber errno = ReadSectorLong(sectorAddress, out byte[] buffer, out _); + ErrorNumber errno = ReadSectorLong(sectorAddress, false, out byte[] buffer, out _); return errno != ErrorNumber.NoError ? null : CdChecksums.CheckCdSector(buffer); } @@ -57,7 +57,7 @@ public sealed partial class Gdi { failingLbas = []; unknownLbas = []; - ErrorNumber errno = ReadSectorsLong(sectorAddress, length, out byte[] buffer, out _); + ErrorNumber errno = ReadSectorsLong(sectorAddress, false, length, out byte[] buffer, out _); if(errno != ErrorNumber.NoError) return null; diff --git a/Aaru.Images/HDCopy/Read.cs b/Aaru.Images/HDCopy/Read.cs index 3c196ee96..f82ff683c 100644 --- a/Aaru.Images/HDCopy/Read.cs +++ b/Aaru.Images/HDCopy/Read.cs @@ -122,10 +122,12 @@ public sealed partial class HdCopy } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; + + if(negative) return ErrorNumber.NotSupported; var trackNum = (int)(sectorAddress / _imageInfo.SectorsPerTrack); var sectorOffset = (int)(sectorAddress % _imageInfo.SectorsPerTrack); @@ -156,11 +158,14 @@ public sealed partial class HdCopy } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; @@ -170,7 +175,7 @@ public sealed partial class HdCopy for(uint i = 0; i < length; i++) { - ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] sector, out SectorStatus status); + ErrorNumber errno = ReadSector(sectorAddress + i, false, out byte[] sector, out SectorStatus status); if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Images/HDCopy/Unsupported.cs b/Aaru.Images/HDCopy/Unsupported.cs index 371ceb820..9b6a5ed9d 100644 --- a/Aaru.Images/HDCopy/Unsupported.cs +++ b/Aaru.Images/HDCopy/Unsupported.cs @@ -48,7 +48,7 @@ public sealed partial class HdCopy } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -56,7 +56,8 @@ public sealed partial class HdCopy } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -64,7 +65,8 @@ public sealed partial class HdCopy } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -73,7 +75,7 @@ public sealed partial class HdCopy } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/IMD/Read.cs b/Aaru.Images/IMD/Read.cs index f74ea6198..ab9bf7b96 100644 --- a/Aaru.Images/IMD/Read.cs +++ b/Aaru.Images/IMD/Read.cs @@ -109,8 +109,9 @@ public sealed partial class Imd for(var i = 0; i < spt; i++) bps[i] = BitConverter.ToUInt16(bpsbytes, i * 2); } else - for(var i = 0; i < spt; i++) - bps[i] = (ushort)(128 << n); + { + for(var i = 0; i < spt; i++) bps[i] = (ushort)(128 << n); + } if(spt > _imageInfo.SectorsPerTrack) _imageInfo.SectorsPerTrack = spt; @@ -212,19 +213,22 @@ public sealed partial class Imd } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; diff --git a/Aaru.Images/IMD/Unsupported.cs b/Aaru.Images/IMD/Unsupported.cs index a58b048b2..e8bad38cc 100644 --- a/Aaru.Images/IMD/Unsupported.cs +++ b/Aaru.Images/IMD/Unsupported.cs @@ -39,7 +39,7 @@ public sealed partial class Imd #region IMediaImage Members /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -47,7 +47,8 @@ public sealed partial class Imd } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -55,7 +56,8 @@ public sealed partial class Imd } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -64,7 +66,7 @@ public sealed partial class Imd } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/KryoFlux/Read.cs b/Aaru.Images/KryoFlux/Read.cs index 78dc21674..99316dc53 100644 --- a/Aaru.Images/KryoFlux/Read.cs +++ b/Aaru.Images/KryoFlux/Read.cs @@ -273,19 +273,20 @@ public sealed partial class KryoFlux } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.NotDumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) => - ReadSectorsTag(sectorAddress, 1, tag, out buffer); + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) => + ReadSectorsTag(sectorAddress, negative, 1, tag, out buffer); /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; @@ -294,7 +295,8 @@ public sealed partial class KryoFlux } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -302,15 +304,16 @@ public sealed partial class KryoFlux } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { sectorStatus = SectorStatus.NotDumped; - return ReadSectorsLong(sectorAddress, 1, out buffer, out _); + return ReadSectorsLong(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/MaxiDisk/Read.cs b/Aaru.Images/MaxiDisk/Read.cs index 82d7c4ab1..22428e0d0 100644 --- a/Aaru.Images/MaxiDisk/Read.cs +++ b/Aaru.Images/MaxiDisk/Read.cs @@ -100,19 +100,22 @@ public sealed partial class MaxiDisk } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; diff --git a/Aaru.Images/MaxiDisk/Unsupported.cs b/Aaru.Images/MaxiDisk/Unsupported.cs index bbb333cc4..6c6c5bba8 100644 --- a/Aaru.Images/MaxiDisk/Unsupported.cs +++ b/Aaru.Images/MaxiDisk/Unsupported.cs @@ -39,7 +39,7 @@ public sealed partial class MaxiDisk #region IWritableImage Members /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -47,7 +47,8 @@ public sealed partial class MaxiDisk } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -55,7 +56,8 @@ public sealed partial class MaxiDisk } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -64,7 +66,7 @@ public sealed partial class MaxiDisk } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/MaxiDisk/Write.cs b/Aaru.Images/MaxiDisk/Write.cs index 0d6c1dd00..1a00d0c28 100644 --- a/Aaru.Images/MaxiDisk/Write.cs +++ b/Aaru.Images/MaxiDisk/Write.cs @@ -125,7 +125,7 @@ public sealed partial class MaxiDisk } /// - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { if(!IsWriting) { @@ -134,6 +134,13 @@ public sealed partial class MaxiDisk return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length != 512) { ErrorMessage = Localization.Incorrect_data_size; @@ -159,7 +166,7 @@ public sealed partial class MaxiDisk } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -168,6 +175,13 @@ public sealed partial class MaxiDisk return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length % 512 != 0) { ErrorMessage = Localization.Incorrect_data_size; @@ -193,7 +207,7 @@ public sealed partial class MaxiDisk } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -201,7 +215,8 @@ public sealed partial class MaxiDisk } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -285,7 +300,7 @@ public sealed partial class MaxiDisk } /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; @@ -293,7 +308,7 @@ public sealed partial class MaxiDisk } /// - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; diff --git a/Aaru.Images/NDIF/Read.cs b/Aaru.Images/NDIF/Read.cs index 7c5667bd4..9ba707b4c 100644 --- a/Aaru.Images/NDIF/Read.cs +++ b/Aaru.Images/NDIF/Read.cs @@ -298,11 +298,13 @@ public sealed partial class Ndif } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(_sectorCache.TryGetValue(sectorAddress, out buffer)) return ErrorNumber.NoError; @@ -411,11 +413,14 @@ public sealed partial class Ndif } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; @@ -425,7 +430,7 @@ public sealed partial class Ndif for(uint i = 0; i < length; i++) { - ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] sector, out SectorStatus status); + ErrorNumber errno = ReadSector(sectorAddress + i, false, out byte[] sector, out SectorStatus status); if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Images/NDIF/Unsupported.cs b/Aaru.Images/NDIF/Unsupported.cs index 3b5bd6ff6..74aad58b5 100644 --- a/Aaru.Images/NDIF/Unsupported.cs +++ b/Aaru.Images/NDIF/Unsupported.cs @@ -39,7 +39,7 @@ public sealed partial class Ndif #region IMediaImage Members /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -47,7 +47,8 @@ public sealed partial class Ndif } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -63,7 +64,8 @@ public sealed partial class Ndif } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -72,7 +74,7 @@ public sealed partial class Ndif } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/NHDr0/Read.cs b/Aaru.Images/NHDr0/Read.cs index 8c6ba32e8..cea17c8b9 100644 --- a/Aaru.Images/NHDr0/Read.cs +++ b/Aaru.Images/NHDr0/Read.cs @@ -80,19 +80,22 @@ public sealed partial class Nhdr0 } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; diff --git a/Aaru.Images/NHDr0/Unsupported.cs b/Aaru.Images/NHDr0/Unsupported.cs index 2cc58736d..b7baadab8 100644 --- a/Aaru.Images/NHDr0/Unsupported.cs +++ b/Aaru.Images/NHDr0/Unsupported.cs @@ -47,7 +47,7 @@ public sealed partial class Nhdr0 } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -55,7 +55,8 @@ public sealed partial class Nhdr0 } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -63,7 +64,8 @@ public sealed partial class Nhdr0 } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -72,7 +74,7 @@ public sealed partial class Nhdr0 } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/NHDr0/Write.cs b/Aaru.Images/NHDr0/Write.cs index 1120fab05..980af351e 100644 --- a/Aaru.Images/NHDr0/Write.cs +++ b/Aaru.Images/NHDr0/Write.cs @@ -100,7 +100,7 @@ public sealed partial class Nhdr0 } /// - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { if(!IsWriting) { @@ -109,6 +109,13 @@ public sealed partial class Nhdr0 return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length != _imageInfo.SectorSize) { ErrorMessage = Localization.Incorrect_data_size; @@ -134,7 +141,7 @@ public sealed partial class Nhdr0 } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -143,6 +150,13 @@ public sealed partial class Nhdr0 return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length % 512 != 0) { ErrorMessage = Localization.Incorrect_data_size; @@ -168,7 +182,7 @@ public sealed partial class Nhdr0 } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -176,7 +190,8 @@ public sealed partial class Nhdr0 } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -295,7 +310,7 @@ public sealed partial class Nhdr0 } /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; @@ -303,7 +318,7 @@ public sealed partial class Nhdr0 } /// - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; diff --git a/Aaru.Images/Nero/Read.cs b/Aaru.Images/Nero/Read.cs index 39633740a..352c5662e 100644 --- a/Aaru.Images/Nero/Read.cs +++ b/Aaru.Images/Nero/Read.cs @@ -1600,16 +1600,16 @@ public sealed partial class Nero } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) => - ReadSectorsTag(sectorAddress, 1, tag, out buffer); + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) => + ReadSectorsTag(sectorAddress, negative, 1, tag, out buffer); /// public ErrorNumber ReadSector(ulong sectorAddress, uint track, out byte[] buffer, out SectorStatus sectorStatus) @@ -1624,11 +1624,14 @@ public sealed partial class Nero ReadSectorsTag(sectorAddress, 1, track, tag, out buffer); /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + foreach(KeyValuePair kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value from track in Tracks @@ -1641,10 +1644,13 @@ public sealed partial class Nero } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; + if(negative) return ErrorNumber.NotSupported; + foreach(KeyValuePair kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value from track in Tracks @@ -2112,11 +2118,12 @@ public sealed partial class Nero } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectorsLong(sectorAddress, 1, out buffer, out _); + return ReadSectorsLong(sectorAddress, negative, 1, out buffer, out _); } /// @@ -2128,12 +2135,14 @@ public sealed partial class Nero } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + foreach(KeyValuePair kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value from track in Tracks diff --git a/Aaru.Images/Nero/Verify.cs b/Aaru.Images/Nero/Verify.cs index 54cd1ac77..a241aecbd 100644 --- a/Aaru.Images/Nero/Verify.cs +++ b/Aaru.Images/Nero/Verify.cs @@ -44,7 +44,7 @@ public sealed partial class Nero /// public bool? VerifySector(ulong sectorAddress) { - ErrorNumber errno = ReadSectorLong(sectorAddress, out byte[] buffer, out _); + ErrorNumber errno = ReadSectorLong(sectorAddress, false, out byte[] buffer, out _); return errno != ErrorNumber.NoError ? null : CdChecksums.CheckCdSector(buffer); } @@ -55,7 +55,7 @@ public sealed partial class Nero { failingLbas = []; unknownLbas = []; - ErrorNumber errno = ReadSectorsLong(sectorAddress, length, out byte[] buffer, out _); + ErrorNumber errno = ReadSectorsLong(sectorAddress, false, length, out byte[] buffer, out _); if(errno != ErrorNumber.NoError) return null; diff --git a/Aaru.Images/Parallels/Read.cs b/Aaru.Images/Parallels/Read.cs index 762d0661e..937f213d3 100644 --- a/Aaru.Images/Parallels/Read.cs +++ b/Aaru.Images/Parallels/Read.cs @@ -108,11 +108,13 @@ public sealed partial class Parallels } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; sectorStatus = SectorStatus.Dumped; @@ -158,11 +160,14 @@ public sealed partial class Parallels } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; @@ -172,7 +177,7 @@ public sealed partial class Parallels for(uint i = 0; i < length; i++) { - ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] sector, out SectorStatus status); + ErrorNumber errno = ReadSector(sectorAddress + i, false, out byte[] sector, out SectorStatus status); if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Images/Parallels/Unsupported.cs b/Aaru.Images/Parallels/Unsupported.cs index 23f30991c..875e51688 100644 --- a/Aaru.Images/Parallels/Unsupported.cs +++ b/Aaru.Images/Parallels/Unsupported.cs @@ -39,7 +39,7 @@ public sealed partial class Parallels #region IWritableImage Members /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -47,7 +47,8 @@ public sealed partial class Parallels } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -63,7 +64,8 @@ public sealed partial class Parallels } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -72,7 +74,7 @@ public sealed partial class Parallels } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/Parallels/Write.cs b/Aaru.Images/Parallels/Write.cs index 619b2f484..551bb27a5 100644 --- a/Aaru.Images/Parallels/Write.cs +++ b/Aaru.Images/Parallels/Write.cs @@ -129,7 +129,7 @@ public sealed partial class Parallels } /// - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { if(!IsWriting) { @@ -138,6 +138,13 @@ public sealed partial class Parallels return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length != 512) { ErrorMessage = Localization.Incorrect_data_size; @@ -180,7 +187,7 @@ public sealed partial class Parallels // TODO: This can be optimized /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -189,6 +196,13 @@ public sealed partial class Parallels return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length % 512 != 0) { ErrorMessage = Localization.Incorrect_data_size; @@ -211,7 +225,7 @@ public sealed partial class Parallels var tmp = new byte[512]; Array.Copy(data, i * 512, tmp, 0, 512); - if(!WriteSector(tmp, sectorAddress + i, sectorStatus[i])) return false; + if(!WriteSector(tmp, sectorAddress + i, false, sectorStatus[i])) return false; } ErrorMessage = ""; @@ -220,7 +234,7 @@ public sealed partial class Parallels } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -228,7 +242,8 @@ public sealed partial class Parallels } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -300,7 +315,7 @@ public sealed partial class Parallels } /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -308,7 +323,7 @@ public sealed partial class Parallels } /// - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; diff --git a/Aaru.Images/PartClone/Read.cs b/Aaru.Images/PartClone/Read.cs index 42fe06c1e..0cc6e9b17 100644 --- a/Aaru.Images/PartClone/Read.cs +++ b/Aaru.Images/PartClone/Read.cs @@ -144,11 +144,13 @@ public sealed partial class PartClone } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; sectorStatus = SectorStatus.Dumped; @@ -176,11 +178,14 @@ public sealed partial class PartClone } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; @@ -208,7 +213,7 @@ public sealed partial class PartClone for(uint i = 0; i < length; i++) { - ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] sector, out SectorStatus status); + ErrorNumber errno = ReadSector(sectorAddress + i, false, out byte[] sector, out SectorStatus status); if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Images/PartClone/Unsupported.cs b/Aaru.Images/PartClone/Unsupported.cs index 4c8abaf01..e992e74dd 100644 --- a/Aaru.Images/PartClone/Unsupported.cs +++ b/Aaru.Images/PartClone/Unsupported.cs @@ -39,7 +39,7 @@ public sealed partial class PartClone #region IMediaImage Members /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -47,7 +47,8 @@ public sealed partial class PartClone } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -63,7 +64,8 @@ public sealed partial class PartClone } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -72,7 +74,7 @@ public sealed partial class PartClone } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/Partimage/Read.cs b/Aaru.Images/Partimage/Read.cs index 208969317..0b4b1d5f3 100644 --- a/Aaru.Images/Partimage/Read.cs +++ b/Aaru.Images/Partimage/Read.cs @@ -381,11 +381,13 @@ public sealed partial class Partimage } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; sectorStatus = SectorStatus.Dumped; @@ -423,11 +425,14 @@ public sealed partial class Partimage } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; @@ -455,7 +460,7 @@ public sealed partial class Partimage for(uint i = 0; i < length; i++) { - ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] sector, out SectorStatus status); + ErrorNumber errno = ReadSector(sectorAddress + i, false, out byte[] sector, out SectorStatus status); if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Images/Partimage/Unsupported.cs b/Aaru.Images/Partimage/Unsupported.cs index 94ed9d484..34d778cd7 100644 --- a/Aaru.Images/Partimage/Unsupported.cs +++ b/Aaru.Images/Partimage/Unsupported.cs @@ -41,7 +41,7 @@ public sealed partial class Partimage #region IMediaImage Members /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -49,7 +49,8 @@ public sealed partial class Partimage } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -65,7 +66,8 @@ public sealed partial class Partimage } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -74,7 +76,7 @@ public sealed partial class Partimage } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/QCOW/Read.cs b/Aaru.Images/QCOW/Read.cs index 2ecac372b..d87fcd861 100644 --- a/Aaru.Images/QCOW/Read.cs +++ b/Aaru.Images/QCOW/Read.cs @@ -200,11 +200,13 @@ public sealed partial class Qcow } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; sectorStatus = SectorStatus.Dumped; @@ -301,11 +303,14 @@ public sealed partial class Qcow } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; @@ -315,7 +320,7 @@ public sealed partial class Qcow for(uint i = 0; i < length; i++) { - ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] sector, out SectorStatus status); + ErrorNumber errno = ReadSector(sectorAddress + i, false, out byte[] sector, out SectorStatus status); if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Images/QCOW/Unsupported.cs b/Aaru.Images/QCOW/Unsupported.cs index 8153ba45e..09c09bc35 100644 --- a/Aaru.Images/QCOW/Unsupported.cs +++ b/Aaru.Images/QCOW/Unsupported.cs @@ -39,7 +39,7 @@ public sealed partial class Qcow #region IWritableImage Members /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -47,7 +47,8 @@ public sealed partial class Qcow } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -63,7 +64,8 @@ public sealed partial class Qcow } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -72,7 +74,7 @@ public sealed partial class Qcow } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/QCOW/Write.cs b/Aaru.Images/QCOW/Write.cs index 3da877b11..f40fca4c6 100644 --- a/Aaru.Images/QCOW/Write.cs +++ b/Aaru.Images/QCOW/Write.cs @@ -154,7 +154,7 @@ public sealed partial class Qcow } /// - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { if(!IsWriting) { @@ -163,6 +163,13 @@ public sealed partial class Qcow return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length != _imageInfo.SectorSize) { ErrorMessage = Localization.Incorrect_data_size; @@ -233,7 +240,7 @@ public sealed partial class Qcow // TODO: This can be optimized /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -242,6 +249,13 @@ public sealed partial class Qcow return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length % _imageInfo.SectorSize != 0) { ErrorMessage = Localization.Incorrect_data_size; @@ -264,7 +278,7 @@ public sealed partial class Qcow var tmp = new byte[_imageInfo.SectorSize]; Array.Copy(data, i * _imageInfo.SectorSize, tmp, 0, _imageInfo.SectorSize); - if(!WriteSector(tmp, sectorAddress + i, sectorStatus[i])) return false; + if(!WriteSector(tmp, sectorAddress + i, false, sectorStatus[i])) return false; } ErrorMessage = ""; @@ -273,7 +287,7 @@ public sealed partial class Qcow } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -281,7 +295,8 @@ public sealed partial class Qcow } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -336,7 +351,7 @@ public sealed partial class Qcow public bool SetGeometry(uint cylinders, uint heads, uint sectorsPerTrack) => true; /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -344,7 +359,7 @@ public sealed partial class Qcow } /// - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; diff --git a/Aaru.Images/QCOW2/Read.cs b/Aaru.Images/QCOW2/Read.cs index 0b4dde7fb..8302e4180 100644 --- a/Aaru.Images/QCOW2/Read.cs +++ b/Aaru.Images/QCOW2/Read.cs @@ -202,7 +202,7 @@ public sealed partial class Qcow2 } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -304,7 +304,8 @@ public sealed partial class Qcow2 } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; @@ -318,7 +319,7 @@ public sealed partial class Qcow2 for(uint i = 0; i < length; i++) { - ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] sector, out SectorStatus status); + ErrorNumber errno = ReadSector(sectorAddress + i, false, out byte[] sector, out SectorStatus status); if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Images/QCOW2/Unsupported.cs b/Aaru.Images/QCOW2/Unsupported.cs index fb9d28f11..bf2200f14 100644 --- a/Aaru.Images/QCOW2/Unsupported.cs +++ b/Aaru.Images/QCOW2/Unsupported.cs @@ -39,7 +39,7 @@ public sealed partial class Qcow2 #region IWritableImage Members /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -47,7 +47,8 @@ public sealed partial class Qcow2 } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -63,7 +64,8 @@ public sealed partial class Qcow2 } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -72,7 +74,7 @@ public sealed partial class Qcow2 } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/QCOW2/Write.cs b/Aaru.Images/QCOW2/Write.cs index 6c8333de3..31281d5a6 100644 --- a/Aaru.Images/QCOW2/Write.cs +++ b/Aaru.Images/QCOW2/Write.cs @@ -177,7 +177,7 @@ public sealed partial class Qcow2 } /// - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { if(!IsWriting) { @@ -186,6 +186,13 @@ public sealed partial class Qcow2 return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length != _imageInfo.SectorSize) { ErrorMessage = Localization.Incorrect_data_size; @@ -275,7 +282,7 @@ public sealed partial class Qcow2 // TODO: This can be optimized /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -284,6 +291,13 @@ public sealed partial class Qcow2 return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length % _imageInfo.SectorSize != 0) { ErrorMessage = Localization.Incorrect_data_size; @@ -306,7 +320,7 @@ public sealed partial class Qcow2 var tmp = new byte[_imageInfo.SectorSize]; Array.Copy(data, i * _imageInfo.SectorSize, tmp, 0, _imageInfo.SectorSize); - if(!WriteSector(tmp, sectorAddress + i, sectorStatus[i])) return false; + if(!WriteSector(tmp, sectorAddress + i, false, sectorStatus[i])) return false; } ErrorMessage = ""; @@ -315,7 +329,7 @@ public sealed partial class Qcow2 } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -323,7 +337,8 @@ public sealed partial class Qcow2 } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -392,7 +407,7 @@ public sealed partial class Qcow2 public bool SetGeometry(uint cylinders, uint heads, uint sectorsPerTrack) => true; /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -400,7 +415,7 @@ public sealed partial class Qcow2 } /// - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; diff --git a/Aaru.Images/QED/Read.cs b/Aaru.Images/QED/Read.cs index 50d1350cd..c69f3183d 100644 --- a/Aaru.Images/QED/Read.cs +++ b/Aaru.Images/QED/Read.cs @@ -185,11 +185,13 @@ public sealed partial class Qed } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; sectorStatus = SectorStatus.Dumped; @@ -262,11 +264,14 @@ public sealed partial class Qed } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; @@ -276,7 +281,7 @@ public sealed partial class Qed for(uint i = 0; i < length; i++) { - ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] sector, out SectorStatus status); + ErrorNumber errno = ReadSector(sectorAddress + i, false, out byte[] sector, out SectorStatus status); if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Images/QED/Unsupported.cs b/Aaru.Images/QED/Unsupported.cs index fe7c8edd7..6cda03506 100644 --- a/Aaru.Images/QED/Unsupported.cs +++ b/Aaru.Images/QED/Unsupported.cs @@ -39,7 +39,7 @@ public sealed partial class Qed #region IWritableImage Members /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -47,7 +47,8 @@ public sealed partial class Qed } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -63,7 +64,8 @@ public sealed partial class Qed } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -72,7 +74,7 @@ public sealed partial class Qed } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/QED/Write.cs b/Aaru.Images/QED/Write.cs index 0e2f32916..84198a5b3 100644 --- a/Aaru.Images/QED/Write.cs +++ b/Aaru.Images/QED/Write.cs @@ -146,7 +146,7 @@ public sealed partial class Qed } /// - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { if(!IsWriting) { @@ -155,6 +155,13 @@ public sealed partial class Qed return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length != _imageInfo.SectorSize) { ErrorMessage = Localization.Incorrect_data_size; @@ -225,7 +232,7 @@ public sealed partial class Qed // TODO: This can be optimized /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -234,6 +241,13 @@ public sealed partial class Qed return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length % _imageInfo.SectorSize != 0) { ErrorMessage = Localization.Incorrect_data_size; @@ -256,7 +270,7 @@ public sealed partial class Qed var tmp = new byte[_imageInfo.SectorSize]; Array.Copy(data, i * _imageInfo.SectorSize, tmp, 0, _imageInfo.SectorSize); - if(!WriteSector(tmp, sectorAddress + i, sectorStatus[i])) return false; + if(!WriteSector(tmp, sectorAddress + i, false, sectorStatus[i])) return false; } ErrorMessage = ""; @@ -265,7 +279,7 @@ public sealed partial class Qed } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -273,7 +287,8 @@ public sealed partial class Qed } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -316,7 +331,7 @@ public sealed partial class Qed public bool SetGeometry(uint cylinders, uint heads, uint sectorsPerTrack) => true; /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -324,7 +339,7 @@ public sealed partial class Qed } /// - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; diff --git a/Aaru.Images/RayDIM/Read.cs b/Aaru.Images/RayDIM/Read.cs index ca0e53236..735bbd10e 100644 --- a/Aaru.Images/RayDIM/Read.cs +++ b/Aaru.Images/RayDIM/Read.cs @@ -108,19 +108,22 @@ public sealed partial class RayDim } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; diff --git a/Aaru.Images/RayDIM/Unsupported.cs b/Aaru.Images/RayDIM/Unsupported.cs index 649e820e9..44e9c61eb 100644 --- a/Aaru.Images/RayDIM/Unsupported.cs +++ b/Aaru.Images/RayDIM/Unsupported.cs @@ -39,7 +39,7 @@ public sealed partial class RayDim #region IWritableImage Members /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -47,7 +47,8 @@ public sealed partial class RayDim } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -55,7 +56,8 @@ public sealed partial class RayDim } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -64,7 +66,7 @@ public sealed partial class RayDim } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/RayDIM/Write.cs b/Aaru.Images/RayDIM/Write.cs index 1f2955086..5e3773bb2 100644 --- a/Aaru.Images/RayDIM/Write.cs +++ b/Aaru.Images/RayDIM/Write.cs @@ -113,7 +113,7 @@ public sealed partial class RayDim } /// - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { if(!IsWriting) { @@ -122,6 +122,13 @@ public sealed partial class RayDim return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length != 512) { ErrorMessage = Localization.Incorrect_data_size; @@ -147,7 +154,7 @@ public sealed partial class RayDim } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -156,6 +163,13 @@ public sealed partial class RayDim return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length % 512 != 0) { ErrorMessage = Localization.Incorrect_data_size; @@ -181,7 +195,7 @@ public sealed partial class RayDim } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -189,7 +203,8 @@ public sealed partial class RayDim } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -200,7 +215,7 @@ public sealed partial class RayDim public bool SetGeometry(uint cylinders, uint heads, uint sectorsPerTrack) => true; /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; @@ -208,7 +223,7 @@ public sealed partial class RayDim } /// - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; diff --git a/Aaru.Images/RsIde/Read.cs b/Aaru.Images/RsIde/Read.cs index 53d662d91..c10c658ab 100644 --- a/Aaru.Images/RsIde/Read.cs +++ b/Aaru.Images/RsIde/Read.cs @@ -103,19 +103,22 @@ public sealed partial class RsIde } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; diff --git a/Aaru.Images/RsIde/Unsupported.cs b/Aaru.Images/RsIde/Unsupported.cs index 773ad1ae7..0f76ddc03 100644 --- a/Aaru.Images/RsIde/Unsupported.cs +++ b/Aaru.Images/RsIde/Unsupported.cs @@ -39,7 +39,7 @@ public sealed partial class RsIde #region IWritableImage Members /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -47,7 +47,8 @@ public sealed partial class RsIde } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -55,7 +56,8 @@ public sealed partial class RsIde } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -64,7 +66,7 @@ public sealed partial class RsIde } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/RsIde/Write.cs b/Aaru.Images/RsIde/Write.cs index 722055fb7..fa074e4f3 100644 --- a/Aaru.Images/RsIde/Write.cs +++ b/Aaru.Images/RsIde/Write.cs @@ -123,7 +123,7 @@ public sealed partial class RsIde } /// - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { if(!IsWriting) { @@ -132,6 +132,13 @@ public sealed partial class RsIde return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length != _imageInfo.SectorSize) { ErrorMessage = Localization.Incorrect_data_size; @@ -157,7 +164,7 @@ public sealed partial class RsIde } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -166,6 +173,13 @@ public sealed partial class RsIde return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length % _imageInfo.SectorSize != 0) { ErrorMessage = Localization.Incorrect_data_size; @@ -191,7 +205,7 @@ public sealed partial class RsIde } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -199,7 +213,8 @@ public sealed partial class RsIde } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -367,7 +382,7 @@ public sealed partial class RsIde } /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; @@ -375,7 +390,7 @@ public sealed partial class RsIde } /// - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; diff --git a/Aaru.Images/SaveDskF/Read.cs b/Aaru.Images/SaveDskF/Read.cs index b3d42b9d2..eade7f33f 100644 --- a/Aaru.Images/SaveDskF/Read.cs +++ b/Aaru.Images/SaveDskF/Read.cs @@ -141,19 +141,22 @@ public sealed partial class SaveDskF } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; diff --git a/Aaru.Images/SaveDskF/Unsupported.cs b/Aaru.Images/SaveDskF/Unsupported.cs index 9c041a594..884624ef9 100644 --- a/Aaru.Images/SaveDskF/Unsupported.cs +++ b/Aaru.Images/SaveDskF/Unsupported.cs @@ -39,7 +39,7 @@ public sealed partial class SaveDskF #region IWritableImage Members /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -47,7 +47,8 @@ public sealed partial class SaveDskF } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -55,7 +56,8 @@ public sealed partial class SaveDskF } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -64,7 +66,7 @@ public sealed partial class SaveDskF } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/SaveDskF/Write.cs b/Aaru.Images/SaveDskF/Write.cs index 839d8269e..538eacda4 100644 --- a/Aaru.Images/SaveDskF/Write.cs +++ b/Aaru.Images/SaveDskF/Write.cs @@ -56,7 +56,7 @@ public sealed partial class SaveDskF } /// - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { if(!IsWriting) { @@ -65,6 +65,13 @@ public sealed partial class SaveDskF return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length != _imageInfo.SectorSize) { ErrorMessage = Localization.Incorrect_data_size; @@ -88,7 +95,7 @@ public sealed partial class SaveDskF } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -97,6 +104,13 @@ public sealed partial class SaveDskF return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length % _imageInfo.SectorSize != 0) { ErrorMessage = Localization.Incorrect_data_size; @@ -120,7 +134,7 @@ public sealed partial class SaveDskF } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -128,7 +142,8 @@ public sealed partial class SaveDskF } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -273,7 +288,7 @@ public sealed partial class SaveDskF public bool SetGeometry(uint cylinders, uint heads, uint sectorsPerTrack) => true; /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; @@ -281,7 +296,7 @@ public sealed partial class SaveDskF } /// - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; diff --git a/Aaru.Images/SuperCardPro/Read.cs b/Aaru.Images/SuperCardPro/Read.cs index 0bb6f2b43..62c2ea711 100644 --- a/Aaru.Images/SuperCardPro/Read.cs +++ b/Aaru.Images/SuperCardPro/Read.cs @@ -564,19 +564,20 @@ public sealed partial class SuperCardPro } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.NotDumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) => - ReadSectorsTag(sectorAddress, 1, tag, out buffer); + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) => + ReadSectorsTag(sectorAddress, negative, 1, tag, out buffer); /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; @@ -585,7 +586,8 @@ public sealed partial class SuperCardPro } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -593,15 +595,16 @@ public sealed partial class SuperCardPro } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { sectorStatus = SectorStatus.NotDumped; - return ReadSectorsLong(sectorAddress, 1, out buffer, out _); + return ReadSectorsLong(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/SuperCardPro/Write.cs b/Aaru.Images/SuperCardPro/Write.cs index 2566a78c5..52ba39741 100644 --- a/Aaru.Images/SuperCardPro/Write.cs +++ b/Aaru.Images/SuperCardPro/Write.cs @@ -197,9 +197,10 @@ public sealed partial class SuperCardPro public bool SetGeometry(uint cylinders, uint heads, uint sectorsPerTrack) => true; - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) => false; + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) => false; - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) => false; + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) => + false; public bool SetDumpHardware(List dumpHardware) => false; @@ -207,14 +208,14 @@ public sealed partial class SuperCardPro public bool WriteMediaTag(byte[] data, MediaTagType tag) => false; - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { ErrorMessage = Localization.Flux_decoding_is_not_yet_implemented; return false; } - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus) { ErrorMessage = Localization.Flux_decoding_is_not_yet_implemented; @@ -222,7 +223,7 @@ public sealed partial class SuperCardPro } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { ErrorMessage = Localization.Flux_decoding_is_not_yet_implemented; @@ -230,7 +231,8 @@ public sealed partial class SuperCardPro } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) { ErrorMessage = Localization.Flux_decoding_is_not_yet_implemented; diff --git a/Aaru.Images/T98/Read.cs b/Aaru.Images/T98/Read.cs index c045c824a..3ef4ad24f 100644 --- a/Aaru.Images/T98/Read.cs +++ b/Aaru.Images/T98/Read.cs @@ -58,9 +58,8 @@ public sealed partial class T98 stream.EnsureRead(hdrB, 0, hdrB.Length); for(var i = 4; i < 256; i++) - { - if(hdrB[i] != 0) return ErrorNumber.InvalidArgument; - } + if(hdrB[i] != 0) + return ErrorNumber.InvalidArgument; var cylinders = BitConverter.ToInt32(hdrB, 0); @@ -83,19 +82,22 @@ public sealed partial class T98 } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; diff --git a/Aaru.Images/T98/Unsupported.cs b/Aaru.Images/T98/Unsupported.cs index 2b7ed2008..891704e6d 100644 --- a/Aaru.Images/T98/Unsupported.cs +++ b/Aaru.Images/T98/Unsupported.cs @@ -49,7 +49,7 @@ public sealed partial class T98 } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -57,7 +57,8 @@ public sealed partial class T98 } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -65,7 +66,8 @@ public sealed partial class T98 } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -74,7 +76,7 @@ public sealed partial class T98 } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/T98/Write.cs b/Aaru.Images/T98/Write.cs index 729f0191c..72feafafa 100644 --- a/Aaru.Images/T98/Write.cs +++ b/Aaru.Images/T98/Write.cs @@ -100,7 +100,7 @@ public sealed partial class T98 } /// - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { if(!IsWriting) { @@ -109,6 +109,13 @@ public sealed partial class T98 return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length != _imageInfo.SectorSize) { ErrorMessage = Localization.Incorrect_data_size; @@ -132,7 +139,7 @@ public sealed partial class T98 } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -141,6 +148,13 @@ public sealed partial class T98 return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length % _imageInfo.SectorSize != 0) { ErrorMessage = Localization.Incorrect_data_size; @@ -164,7 +178,7 @@ public sealed partial class T98 } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -172,7 +186,8 @@ public sealed partial class T98 } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -206,7 +221,7 @@ public sealed partial class T98 public bool SetGeometry(uint cylinders, uint heads, uint sectorsPerTrack) => true; /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; @@ -214,7 +229,7 @@ public sealed partial class T98 } /// - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; diff --git a/Aaru.Images/TeleDisk/Read.cs b/Aaru.Images/TeleDisk/Read.cs index 593d0de47..95e56f82b 100644 --- a/Aaru.Images/TeleDisk/Read.cs +++ b/Aaru.Images/TeleDisk/Read.cs @@ -188,8 +188,9 @@ public sealed partial class TeleDisk for(var i = 0; i < _commentBlock.Length; i++) // Replace NULLs, used by TeleDisk as newline markers, with UNIX newline marker - if(_commentBlock[i] == 0x00) - _commentBlock[i] = 0x0A; + { + if(_commentBlock[i] == 0x00) _commentBlock[i] = 0x0A; + } _imageInfo.Comments = Encoding.ASCII.GetString(_commentBlock); @@ -563,12 +564,14 @@ public sealed partial class TeleDisk } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; (ushort cylinder, byte head, byte sector) = LbaToChs(sectorAddress); + if(negative) return ErrorNumber.NotSupported; + if(cylinder >= _sectorsData.Length) return ErrorNumber.SectorNotFound; if(head >= _sectorsData[cylinder].Length) return ErrorNumber.SectorNotFound; @@ -582,11 +585,14 @@ public sealed partial class TeleDisk } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; @@ -596,7 +602,7 @@ public sealed partial class TeleDisk for(uint i = 0; i < length; i++) { - ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] sector, out SectorStatus status); + ErrorNumber errno = ReadSector(sectorAddress + i, false, out byte[] sector, out SectorStatus status); if(errno != ErrorNumber.NoError) return errno; @@ -618,17 +624,18 @@ public sealed partial class TeleDisk } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) => - ReadSectors(sectorAddress, length, out buffer, out sectorStatus); + ReadSectors(sectorAddress, negative, length, out buffer, out sectorStatus); /// public ErrorNumber ReadMediaTag(MediaTagType tag, out byte[] buffer) diff --git a/Aaru.Images/TeleDisk/Unsupported.cs b/Aaru.Images/TeleDisk/Unsupported.cs index 127099a4e..a996f6097 100644 --- a/Aaru.Images/TeleDisk/Unsupported.cs +++ b/Aaru.Images/TeleDisk/Unsupported.cs @@ -39,7 +39,7 @@ public sealed partial class TeleDisk #region IMediaImage Members /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -47,7 +47,8 @@ public sealed partial class TeleDisk } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; diff --git a/Aaru.Images/UDIF/Read.cs b/Aaru.Images/UDIF/Read.cs index b8c80f60a..df707547e 100644 --- a/Aaru.Images/UDIF/Read.cs +++ b/Aaru.Images/UDIF/Read.cs @@ -442,11 +442,13 @@ public sealed partial class Udif } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; sectorStatus = SectorStatus.Dumped; @@ -608,11 +610,14 @@ public sealed partial class Udif } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; @@ -622,7 +627,7 @@ public sealed partial class Udif for(uint i = 0; i < length; i++) { - ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] sector, out SectorStatus status); + ErrorNumber errno = ReadSector(sectorAddress + i, false, out byte[] sector, out SectorStatus status); if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Images/UDIF/Unsupported.cs b/Aaru.Images/UDIF/Unsupported.cs index dd74273c6..8a450ff47 100644 --- a/Aaru.Images/UDIF/Unsupported.cs +++ b/Aaru.Images/UDIF/Unsupported.cs @@ -39,7 +39,7 @@ public sealed partial class Udif #region IWritableImage Members /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -47,7 +47,8 @@ public sealed partial class Udif } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -63,7 +64,8 @@ public sealed partial class Udif } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -72,7 +74,7 @@ public sealed partial class Udif } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/UDIF/Write.cs b/Aaru.Images/UDIF/Write.cs index 0966c54fe..b82330e56 100644 --- a/Aaru.Images/UDIF/Write.cs +++ b/Aaru.Images/UDIF/Write.cs @@ -108,7 +108,7 @@ public sealed partial class Udif } /// - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { if(!IsWriting) { @@ -117,6 +117,13 @@ public sealed partial class Udif return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length != _imageInfo.SectorSize) { ErrorMessage = Localization.Incorrect_data_size; @@ -179,7 +186,7 @@ public sealed partial class Udif // TODO: This can be optimized /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -188,6 +195,13 @@ public sealed partial class Udif return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length % _imageInfo.SectorSize != 0) { ErrorMessage = Localization.Incorrect_data_size; @@ -230,7 +244,7 @@ public sealed partial class Udif var tmp = new byte[_imageInfo.SectorSize]; Array.Copy(data, i * _imageInfo.SectorSize, tmp, 0, _imageInfo.SectorSize); - if(!WriteSector(tmp, sectorAddress + i, sectorStatus[i])) return false; + if(!WriteSector(tmp, sectorAddress + i, false, sectorStatus[i])) return false; } ErrorMessage = ""; @@ -239,7 +253,7 @@ public sealed partial class Udif } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -247,7 +261,8 @@ public sealed partial class Udif } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -418,7 +433,7 @@ public sealed partial class Udif public bool SetGeometry(uint cylinders, uint heads, uint sectorsPerTrack) => true; /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -426,7 +441,7 @@ public sealed partial class Udif } /// - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; diff --git a/Aaru.Images/UkvFdi/Read.cs b/Aaru.Images/UkvFdi/Read.cs index d604fa794..d0cbe04a4 100644 --- a/Aaru.Images/UkvFdi/Read.cs +++ b/Aaru.Images/UkvFdi/Read.cs @@ -182,12 +182,14 @@ public sealed partial class UkvFdi } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; (ushort cylinder, byte head, byte sector) = LbaToChs(sectorAddress); + if(negative) return ErrorNumber.NotSupported; + if(cylinder >= _sectorsData.Length) return ErrorNumber.SectorNotFound; if(head >= _sectorsData[cylinder].Length) return ErrorNumber.SectorNotFound; @@ -201,11 +203,14 @@ public sealed partial class UkvFdi } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; @@ -215,7 +220,7 @@ public sealed partial class UkvFdi for(uint i = 0; i < length; i++) { - ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] sector, out SectorStatus status); + ErrorNumber errno = ReadSector(sectorAddress + i, false, out byte[] sector, out SectorStatus status); sectorStatus[i] = status; if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Images/UkvFdi/Unsupported.cs b/Aaru.Images/UkvFdi/Unsupported.cs index 69886011e..04733f8e3 100644 --- a/Aaru.Images/UkvFdi/Unsupported.cs +++ b/Aaru.Images/UkvFdi/Unsupported.cs @@ -49,7 +49,7 @@ public sealed partial class UkvFdi } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -57,7 +57,8 @@ public sealed partial class UkvFdi } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -65,7 +66,8 @@ public sealed partial class UkvFdi } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -74,7 +76,7 @@ public sealed partial class UkvFdi } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/VDI/Read.cs b/Aaru.Images/VDI/Read.cs index a8a6cb8b6..23289a153 100644 --- a/Aaru.Images/VDI/Read.cs +++ b/Aaru.Images/VDI/Read.cs @@ -176,11 +176,13 @@ public sealed partial class Vdi } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(_sectorCache.TryGetValue(sectorAddress, out buffer)) return ErrorNumber.NoError; @@ -215,11 +217,14 @@ public sealed partial class Vdi } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; @@ -229,7 +234,7 @@ public sealed partial class Vdi for(uint i = 0; i < length; i++) { - ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] sector, out SectorStatus status); + ErrorNumber errno = ReadSector(sectorAddress + i, false, out byte[] sector, out SectorStatus status); if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Images/VDI/Unsupported.cs b/Aaru.Images/VDI/Unsupported.cs index 22a71427b..c77de589a 100644 --- a/Aaru.Images/VDI/Unsupported.cs +++ b/Aaru.Images/VDI/Unsupported.cs @@ -39,7 +39,7 @@ public sealed partial class Vdi #region IWritableImage Members /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -47,7 +47,8 @@ public sealed partial class Vdi } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -63,7 +64,8 @@ public sealed partial class Vdi } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -72,7 +74,7 @@ public sealed partial class Vdi } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/VDI/Write.cs b/Aaru.Images/VDI/Write.cs index 3c4581f31..9752d81ff 100644 --- a/Aaru.Images/VDI/Write.cs +++ b/Aaru.Images/VDI/Write.cs @@ -139,7 +139,7 @@ public sealed partial class Vdi } /// - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { if(!IsWriting) { @@ -148,6 +148,13 @@ public sealed partial class Vdi return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length != _imageInfo.SectorSize) { ErrorMessage = Localization.Incorrect_data_size; @@ -191,7 +198,7 @@ public sealed partial class Vdi // TODO: This can be optimized /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -200,6 +207,13 @@ public sealed partial class Vdi return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length % _imageInfo.SectorSize != 0) { ErrorMessage = Localization.Incorrect_data_size; @@ -222,7 +236,7 @@ public sealed partial class Vdi var tmp = new byte[_imageInfo.SectorSize]; Array.Copy(data, i * _imageInfo.SectorSize, tmp, 0, _imageInfo.SectorSize); - if(!WriteSector(tmp, sectorAddress + i, sectorStatus[i])) return false; + if(!WriteSector(tmp, sectorAddress + i, false, sectorStatus[i])) return false; } ErrorMessage = ""; @@ -231,7 +245,7 @@ public sealed partial class Vdi } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -239,7 +253,8 @@ public sealed partial class Vdi } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -321,7 +336,7 @@ public sealed partial class Vdi } /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -329,7 +344,7 @@ public sealed partial class Vdi } /// - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; diff --git a/Aaru.Images/VHD/Read.cs b/Aaru.Images/VHD/Read.cs index 4fb723456..0d7db24d7 100644 --- a/Aaru.Images/VHD/Read.cs +++ b/Aaru.Images/VHD/Read.cs @@ -702,9 +702,12 @@ public sealed partial class Vhd } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.NotDumped; + buffer = null; + + if(negative) return ErrorNumber.NotSupported; switch(_thisFooter.DiskType) { @@ -755,7 +758,7 @@ public sealed partial class Vhd */ // Sector has been written, read from child image - if(!dirty) return _parentImage.ReadSector(sectorAddress, out buffer, out sectorStatus); + if(!dirty) return _parentImage.ReadSector(sectorAddress, false, out buffer, out sectorStatus); /* Too noisy AaruLogging.DebugWriteLine(MODULE_NAME, "Sector {0} is dirty", sectorAddress); */ @@ -781,16 +784,19 @@ public sealed partial class Vhd default: sectorStatus = SectorStatus.Dumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, false, 1, out buffer, out _); } } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = Enumerable.Repeat(SectorStatus.Dumped, (int)length).ToArray(); + if(negative) return ErrorNumber.NotSupported; + switch(_thisFooter.DiskType) { @@ -830,7 +836,8 @@ public sealed partial class Vhd if(length > remainingInBlock) { ErrorNumber errno = ReadSectors(sectorAddress + remainingInBlock, - length - remainingInBlock, + false, + length - remainingInBlock, out suffix, out sectorStatus); @@ -885,7 +892,7 @@ public sealed partial class Vhd for(ulong i = 0; i < length; i++) { - ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] oneSector, out _); + ErrorNumber errno = ReadSector(sectorAddress + i, false, out byte[] oneSector, out _); if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Images/VHD/Unsupported.cs b/Aaru.Images/VHD/Unsupported.cs index 8e371edde..ab4b0f019 100644 --- a/Aaru.Images/VHD/Unsupported.cs +++ b/Aaru.Images/VHD/Unsupported.cs @@ -47,7 +47,7 @@ public sealed partial class Vhd } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -55,7 +55,8 @@ public sealed partial class Vhd } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -63,7 +64,8 @@ public sealed partial class Vhd } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -72,7 +74,7 @@ public sealed partial class Vhd } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/VHD/Write.cs b/Aaru.Images/VHD/Write.cs index 8369450cb..c56a42ff7 100644 --- a/Aaru.Images/VHD/Write.cs +++ b/Aaru.Images/VHD/Write.cs @@ -322,7 +322,7 @@ public sealed partial class Vhd } /// - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { if(!IsWriting) { @@ -331,6 +331,13 @@ public sealed partial class Vhd return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length != 512) { ErrorMessage = Localization.Incorrect_data_size; @@ -424,8 +431,15 @@ public sealed partial class Vhd } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus) { + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(_dynamic) { if(ArrayHelpers.ArrayIsNullOrEmpty(data)) @@ -472,8 +486,10 @@ public sealed partial class Vhd } for(var i = 0; i < length; i++) - if(!WriteSector(data[(i * 512)..(i * 512 + 512)], sectorAddress + (ulong)i, sectorStatus[i])) + { + if(!WriteSector(data[(i * 512)..(i * 512 + 512)], sectorAddress + (ulong)i, false, sectorStatus[i])) return false; + } return true; } @@ -508,7 +524,7 @@ public sealed partial class Vhd } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -516,7 +532,8 @@ public sealed partial class Vhd } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -581,7 +598,7 @@ public sealed partial class Vhd } /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; @@ -589,7 +606,7 @@ public sealed partial class Vhd } /// - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; diff --git a/Aaru.Images/VHDX/Read.cs b/Aaru.Images/VHDX/Read.cs index d127ed39e..0460a36f1 100644 --- a/Aaru.Images/VHDX/Read.cs +++ b/Aaru.Images/VHDX/Read.cs @@ -489,11 +489,13 @@ public sealed partial class Vhdx } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(_sectorCache.TryGetValue(sectorAddress, out buffer)) return ErrorNumber.NoError; @@ -516,7 +518,7 @@ public sealed partial class Vhdx switch(blkFlags & BAT_FLAGS_MASK) { case PAYLOAD_BLOCK_NOT_PRESENT: - if(_hasParent) return _parentImage.ReadSector(sectorAddress, out buffer, out sectorStatus); + if(_hasParent) return _parentImage.ReadSector(sectorAddress, false, out buffer, out sectorStatus); buffer = new byte[_logicalSectorSize]; @@ -532,7 +534,7 @@ public sealed partial class Vhdx bool partialBlock = (blkFlags & BAT_FLAGS_MASK) == PAYLOAD_BLOCK_PARTIALLY_PRESENT; if(partialBlock && _hasParent && !CheckBitmap(sectorAddress)) - return _parentImage.ReadSector(sectorAddress, out buffer, out sectorStatus); + return _parentImage.ReadSector(sectorAddress, false, out buffer, out sectorStatus); if(!_blockCache.TryGetValue(blkPtr & BAT_FILE_OFFSET_MASK, out byte[] block)) { @@ -556,11 +558,14 @@ public sealed partial class Vhdx } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; @@ -570,7 +575,7 @@ public sealed partial class Vhdx for(uint i = 0; i < length; i++) { - ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] sector, out SectorStatus status); + ErrorNumber errno = ReadSector(sectorAddress + i, false, out byte[] sector, out SectorStatus status); if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Images/VHDX/Unsupported.cs b/Aaru.Images/VHDX/Unsupported.cs index 190aa769e..42479440a 100644 --- a/Aaru.Images/VHDX/Unsupported.cs +++ b/Aaru.Images/VHDX/Unsupported.cs @@ -47,7 +47,7 @@ public sealed partial class Vhdx } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -55,7 +55,8 @@ public sealed partial class Vhdx } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -63,7 +64,8 @@ public sealed partial class Vhdx } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -72,7 +74,7 @@ public sealed partial class Vhdx } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/VMware/Read.cs b/Aaru.Images/VMware/Read.cs index e2d5b2788..5ff2ea76f 100644 --- a/Aaru.Images/VMware/Read.cs +++ b/Aaru.Images/VMware/Read.cs @@ -589,11 +589,13 @@ public sealed partial class VMware } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(_sectorCache.TryGetValue(sectorAddress, out buffer)) return ErrorNumber.NoError; @@ -650,7 +652,7 @@ public sealed partial class VMware switch(grainOff) { case 0 when _hasParent: - return _parentImage.ReadSector(sectorAddress, out buffer, out sectorStatus); + return _parentImage.ReadSector(sectorAddress, false, out buffer, out sectorStatus); case 0 or 1: { buffer = new byte[SECTOR_SIZE]; @@ -686,11 +688,14 @@ public sealed partial class VMware } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; @@ -700,7 +705,7 @@ public sealed partial class VMware for(uint i = 0; i < length; i++) { - ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] sector, out SectorStatus status); + ErrorNumber errno = ReadSector(sectorAddress + i, false, out byte[] sector, out SectorStatus status); if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Images/VMware/Unsupported.cs b/Aaru.Images/VMware/Unsupported.cs index a053d36b0..27b7b027f 100644 --- a/Aaru.Images/VMware/Unsupported.cs +++ b/Aaru.Images/VMware/Unsupported.cs @@ -39,7 +39,7 @@ public sealed partial class VMware #region IWritableImage Members /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -47,7 +47,8 @@ public sealed partial class VMware } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -63,7 +64,8 @@ public sealed partial class VMware } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -72,7 +74,7 @@ public sealed partial class VMware } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/VMware/Write.cs b/Aaru.Images/VMware/Write.cs index 5503df6b7..f2beaf9b3 100644 --- a/Aaru.Images/VMware/Write.cs +++ b/Aaru.Images/VMware/Write.cs @@ -184,7 +184,7 @@ public sealed partial class VMware } /// - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { if(!IsWriting) { @@ -193,6 +193,13 @@ public sealed partial class VMware return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length != 512) { ErrorMessage = Localization.Incorrect_data_size; @@ -217,7 +224,7 @@ public sealed partial class VMware // TODO: Implement sparse and split /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -226,6 +233,13 @@ public sealed partial class VMware return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length % 512 != 0) { ErrorMessage = Localization.Incorrect_data_size; @@ -249,7 +263,7 @@ public sealed partial class VMware } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -257,7 +271,8 @@ public sealed partial class VMware } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -362,7 +377,7 @@ public sealed partial class VMware } /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; @@ -370,7 +385,7 @@ public sealed partial class VMware } /// - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; diff --git a/Aaru.Images/Virtual98/Read.cs b/Aaru.Images/Virtual98/Read.cs index 37c479040..1272b0f6a 100644 --- a/Aaru.Images/Virtual98/Read.cs +++ b/Aaru.Images/Virtual98/Read.cs @@ -80,19 +80,22 @@ public sealed partial class Virtual98 } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = new SectorStatus[length]; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; diff --git a/Aaru.Images/Virtual98/Unsupported.cs b/Aaru.Images/Virtual98/Unsupported.cs index df4a2a00e..7fb98964b 100644 --- a/Aaru.Images/Virtual98/Unsupported.cs +++ b/Aaru.Images/Virtual98/Unsupported.cs @@ -47,7 +47,7 @@ public sealed partial class Virtual98 } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -55,7 +55,8 @@ public sealed partial class Virtual98 } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -63,7 +64,8 @@ public sealed partial class Virtual98 } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -72,7 +74,7 @@ public sealed partial class Virtual98 } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/Virtual98/Write.cs b/Aaru.Images/Virtual98/Write.cs index b2758ebbc..068c0c6f3 100644 --- a/Aaru.Images/Virtual98/Write.cs +++ b/Aaru.Images/Virtual98/Write.cs @@ -107,7 +107,7 @@ public sealed partial class Virtual98 } /// - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { if(!IsWriting) { @@ -116,6 +116,13 @@ public sealed partial class Virtual98 return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length != 512) { ErrorMessage = Localization.Incorrect_data_size; @@ -139,7 +146,7 @@ public sealed partial class Virtual98 } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -148,6 +155,13 @@ public sealed partial class Virtual98 return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length % 512 != 0) { ErrorMessage = Localization.Incorrect_data_size; @@ -171,7 +185,7 @@ public sealed partial class Virtual98 } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -179,7 +193,8 @@ public sealed partial class Virtual98 } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -296,7 +311,7 @@ public sealed partial class Virtual98 } /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; @@ -304,7 +319,7 @@ public sealed partial class Virtual98 } /// - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; diff --git a/Aaru.Images/WCDiskImage/Read.cs b/Aaru.Images/WCDiskImage/Read.cs index 611859add..17559638b 100644 --- a/Aaru.Images/WCDiskImage/Read.cs +++ b/Aaru.Images/WCDiskImage/Read.cs @@ -178,8 +178,13 @@ public sealed partial class WCDiskImage } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { + sectorStatus = SectorStatus.NotDumped; + buffer = null; + + if(negative) return ErrorNumber.NotSupported; + int sectorNumber = (int)(sectorAddress % _imageInfo.SectorsPerTrack) + 1; var trackNumber = (int)(sectorAddress / _imageInfo.SectorsPerTrack); int headNumber = _imageInfo.Heads > 1 ? trackNumber % 2 : 0; @@ -219,11 +224,14 @@ public sealed partial class WCDiskImage } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; @@ -233,7 +241,7 @@ public sealed partial class WCDiskImage for(uint i = 0; i < length; i++) { - ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] sector, out SectorStatus status); + ErrorNumber errno = ReadSector(sectorAddress + i, false, out byte[] sector, out SectorStatus status); if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Images/WCDiskImage/Unsupported.cs b/Aaru.Images/WCDiskImage/Unsupported.cs index 513ac4dcf..0672a16d6 100644 --- a/Aaru.Images/WCDiskImage/Unsupported.cs +++ b/Aaru.Images/WCDiskImage/Unsupported.cs @@ -49,7 +49,7 @@ public sealed partial class WCDiskImage } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -57,7 +57,8 @@ public sealed partial class WCDiskImage } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; @@ -65,7 +66,8 @@ public sealed partial class WCDiskImage } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { buffer = null; sectorStatus = SectorStatus.NotDumped; @@ -74,7 +76,7 @@ public sealed partial class WCDiskImage } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; diff --git a/Aaru.Images/ZZZRawImage/Read.cs b/Aaru.Images/ZZZRawImage/Read.cs index 7f284db70..93a61bb67 100644 --- a/Aaru.Images/ZZZRawImage/Read.cs +++ b/Aaru.Images/ZZZRawImage/Read.cs @@ -1286,19 +1286,22 @@ public sealed partial class ZZZRawImage } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectors(sectorAddress, 1, out buffer, out _); + return ReadSectors(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) + public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer, + out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(_differentTrackZeroSize) return ErrorNumber.NotImplemented; if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; @@ -1450,7 +1453,7 @@ public sealed partial class ZZZRawImage if(_imageInfo.MetadataMediaType != MetadataMediaType.OpticalDisc) return ErrorNumber.NotSupported; - return track != 1 ? ErrorNumber.OutOfRange : ReadSector(sectorAddress, out buffer, out sectorStatus); + return track != 1 ? ErrorNumber.OutOfRange : ReadSector(sectorAddress, false, out buffer, out sectorStatus); } /// @@ -1462,7 +1465,9 @@ public sealed partial class ZZZRawImage if(_imageInfo.MetadataMediaType != MetadataMediaType.OpticalDisc) return ErrorNumber.NotSupported; - return track != 1 ? ErrorNumber.OutOfRange : ReadSectors(sectorAddress, length, out buffer, out sectorStatus); + return track != 1 + ? ErrorNumber.OutOfRange + : ReadSectors(sectorAddress, false, length, out buffer, out sectorStatus); } /// @@ -1473,7 +1478,7 @@ public sealed partial class ZZZRawImage if(_imageInfo.MetadataMediaType != MetadataMediaType.OpticalDisc) return ErrorNumber.NotSupported; - return track != 1 ? ErrorNumber.OutOfRange : ReadSectorsLong(sectorAddress, 1, out buffer, out _); + return track != 1 ? ErrorNumber.OutOfRange : ReadSectorsLong(sectorAddress, false, 1, out buffer, out _); } /// @@ -1487,11 +1492,11 @@ public sealed partial class ZZZRawImage return track != 1 ? ErrorNumber.OutOfRange - : ReadSectorsLong(sectorAddress, length, out buffer, out sectorStatus); + : ReadSectorsLong(sectorAddress, false, length, out buffer, out sectorStatus); } /// - public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) { buffer = null; @@ -1499,14 +1504,17 @@ public sealed partial class ZZZRawImage !_rawCompactDisc && !_toastXa && tag != SectorTagType.CdTrackFlags) return ErrorNumber.NotSupported; - return ReadSectorsTag(sectorAddress, 1, tag, out buffer); + return ReadSectorsTag(sectorAddress, negative, 1, tag, out buffer); } /// - public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer) + public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag, + out byte[] buffer) { buffer = null; + if(negative) return ErrorNumber.NotSupported; + if(_imageInfo.MetadataMediaType != MetadataMediaType.OpticalDisc || !_rawCompactDisc && !_toastXa && !_rawDvd && tag != SectorTagType.CdTrackFlags) return ErrorNumber.NotSupported; @@ -1701,20 +1709,23 @@ public sealed partial class ZZZRawImage } /// - public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus) + public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer, + out SectorStatus sectorStatus) { sectorStatus = SectorStatus.Dumped; - return ReadSectorsLong(sectorAddress, 1, out buffer, out _); + return ReadSectorsLong(sectorAddress, negative, 1, out buffer, out _); } /// - public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer, + public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer, out SectorStatus[] sectorStatus) { buffer = null; sectorStatus = null; + if(negative) return ErrorNumber.NotSupported; + if(_imageInfo.MetadataMediaType != MetadataMediaType.OpticalDisc || !_rawCompactDisc && !_toastXa && !_rawDvd) return ErrorNumber.NotSupported; @@ -1817,7 +1828,7 @@ public sealed partial class ZZZRawImage ? ErrorNumber.NotSupported : track != 1 ? ErrorNumber.OutOfRange - : ReadSectorsTag(sectorAddress, length, tag, out buffer); + : ReadSectorsTag(sectorAddress, false, length, tag, out buffer); } #endregion diff --git a/Aaru.Images/ZZZRawImage/Verify.cs b/Aaru.Images/ZZZRawImage/Verify.cs index 637c78ed8..dccffd2aa 100644 --- a/Aaru.Images/ZZZRawImage/Verify.cs +++ b/Aaru.Images/ZZZRawImage/Verify.cs @@ -46,7 +46,7 @@ public sealed partial class ZZZRawImage { if(!_rawCompactDisc) return null; - ErrorNumber errno = ReadSectorLong(sectorAddress, out byte[] buffer, out _); + ErrorNumber errno = ReadSectorLong(sectorAddress, false, out byte[] buffer, out _); return errno != ErrorNumber.NoError ? null : CdChecksums.CheckCdSector(buffer); } @@ -67,7 +67,7 @@ public sealed partial class ZZZRawImage failingLbas = []; unknownLbas = []; - ErrorNumber errno = ReadSectorsLong(sectorAddress, length, out byte[] buffer, out _); + ErrorNumber errno = ReadSectorsLong(sectorAddress, false, length, out byte[] buffer, out _); if(errno != ErrorNumber.NoError) return null; diff --git a/Aaru.Images/ZZZRawImage/Write.cs b/Aaru.Images/ZZZRawImage/Write.cs index 7441dc35c..471459d5a 100644 --- a/Aaru.Images/ZZZRawImage/Write.cs +++ b/Aaru.Images/ZZZRawImage/Write.cs @@ -118,7 +118,7 @@ public sealed partial class ZZZRawImage public bool SetGeometry(uint cylinders, uint heads, uint sectorsPerTrack) => true; /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) + public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; @@ -126,7 +126,7 @@ public sealed partial class ZZZRawImage } /// - public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) + public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag) { ErrorMessage = Localization.Unsupported_feature; @@ -157,7 +157,7 @@ public sealed partial class ZZZRawImage } /// - public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { if(!IsWriting) { @@ -166,6 +166,13 @@ public sealed partial class ZZZRawImage return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length != _imageInfo.SectorSize) { ErrorMessage = Localization.Incorrect_data_size; @@ -189,7 +196,7 @@ public sealed partial class ZZZRawImage } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -198,6 +205,13 @@ public sealed partial class ZZZRawImage return false; } + if(negative) + { + ErrorMessage = Localization.Unsupported_feature; + + return false; + } + if(data.Length % _imageInfo.SectorSize != 0) { ErrorMessage = Localization.Incorrect_data_size; @@ -221,7 +235,7 @@ public sealed partial class ZZZRawImage } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -229,7 +243,8 @@ public sealed partial class ZZZRawImage } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length, + SectorStatus[] sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; diff --git a/Aaru.Partitions/Acorn.cs b/Aaru.Partitions/Acorn.cs index dd4bd1eee..b4c911898 100644 --- a/Aaru.Partitions/Acorn.cs +++ b/Aaru.Partitions/Acorn.cs @@ -70,7 +70,7 @@ public sealed class Acorn : IPartition else sbSector = ADFS_SB_POS / imagePlugin.Info.SectorSize; - ErrorNumber errno = imagePlugin.ReadSector(sbSector, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(sbSector, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError || sector.Length < 512) return; @@ -86,7 +86,7 @@ public sealed class Acorn : IPartition if((ulong)mapSector >= imagePlugin.Info.Sectors) return; - errno = imagePlugin.ReadSector((ulong)mapSector, out byte[] map, out _); + errno = imagePlugin.ReadSector((ulong)mapSector, false, out byte[] map, out _); if(errno != ErrorNumber.NoError) return; @@ -180,7 +180,7 @@ public sealed class Acorn : IPartition // RISC OS always checks for the partition on 0. Afaik no emulator chains it. if(sectorOffset != 0) return; - ErrorNumber errno = imagePlugin.ReadSector(0, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(0, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError || sector.Length < 512) return; @@ -220,7 +220,7 @@ public sealed class Acorn : IPartition } // Negative size means Linux partition, first sector needs to be read - errno = imagePlugin.ReadSector(entry.start, out sector, out _); + errno = imagePlugin.ReadSector(entry.start, false, out sector, out _); if(errno != ErrorNumber.NoError) continue; diff --git a/Aaru.Partitions/AppleMap.cs b/Aaru.Partitions/AppleMap.cs index 748c8a44d..e3e6eddb8 100644 --- a/Aaru.Partitions/AppleMap.cs +++ b/Aaru.Partitions/AppleMap.cs @@ -82,7 +82,7 @@ public sealed partial class AppleMap : IPartition if(sectorOffset + 2 >= imagePlugin.Info.Sectors) return false; - ErrorNumber errno = imagePlugin.ReadSector(sectorOffset, out byte[] ddmSector, out _); + ErrorNumber errno = imagePlugin.ReadSector(sectorOffset, false, out byte[] ddmSector, out _); if(errno != ErrorNumber.NoError) return false; @@ -154,7 +154,7 @@ public sealed partial class AppleMap : IPartition } } - errno = imagePlugin.ReadSector(1 + sectorOffset, out byte[] partSector, out _); + errno = imagePlugin.ReadSector(1 + sectorOffset, false, out byte[] partSector, out _); if(errno != ErrorNumber.NoError) return false; @@ -258,7 +258,7 @@ public sealed partial class AppleMap : IPartition return partitions.Count > 0; } - errno = imagePlugin.ReadSectors(sectorOffset, sectorsToRead, out byte[] entries, out _); + errno = imagePlugin.ReadSectors(sectorOffset, false, sectorsToRead, out byte[] entries, out _); if(errno != ErrorNumber.NoError) return false; diff --git a/Aaru.Partitions/Apricot.cs b/Aaru.Partitions/Apricot.cs index fcf9ed3d0..69d6847da 100644 --- a/Aaru.Partitions/Apricot.cs +++ b/Aaru.Partitions/Apricot.cs @@ -334,7 +334,7 @@ public sealed class Apricot : IPartition // I think Apricot can't chain partitions so. if(sectorOffset != 0) return false; - ErrorNumber errno = imagePlugin.ReadSector(0, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(0, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError || sector.Length < 512) return false; diff --git a/Aaru.Partitions/Atari.cs b/Aaru.Partitions/Atari.cs index 8e377173b..c369ab9c9 100644 --- a/Aaru.Partitions/Atari.cs +++ b/Aaru.Partitions/Atari.cs @@ -116,7 +116,7 @@ public sealed class AtariPartitions : IPartition { partitions = []; - ErrorNumber errno = imagePlugin.ReadSector(sectorOffset, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(sectorOffset, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError || sector.Length < 512) return false; @@ -276,7 +276,7 @@ public sealed class AtariPartitions : IPartition break; case TYPE_EXTENDED: - errno = imagePlugin.ReadSector(table.Entries[i].Start, out byte[] extendedSector, out _); + errno = imagePlugin.ReadSector(table.Entries[i].Start, false, out byte[] extendedSector, out _); if(errno != ErrorNumber.NoError) break; diff --git a/Aaru.Partitions/BSD.cs b/Aaru.Partitions/BSD.cs index a5c45ad87..1610cb012 100644 --- a/Aaru.Partitions/BSD.cs +++ b/Aaru.Partitions/BSD.cs @@ -86,7 +86,7 @@ public sealed partial class BSD : IPartition { if(location + run + sectorOffset >= imagePlugin.Info.Sectors) return false; - ErrorNumber errno = imagePlugin.ReadSectors(location + sectorOffset, run, out byte[] tmp, out _); + ErrorNumber errno = imagePlugin.ReadSectors(location + sectorOffset, false, run, out byte[] tmp, out _); if(errno != ErrorNumber.NoError) continue; diff --git a/Aaru.Partitions/DEC.cs b/Aaru.Partitions/DEC.cs index 40cc9a031..a1cc7c75f 100644 --- a/Aaru.Partitions/DEC.cs +++ b/Aaru.Partitions/DEC.cs @@ -91,7 +91,7 @@ public sealed class DEC : IPartition if(31 + sectorOffset >= imagePlugin.Info.Sectors) return false; - ErrorNumber errno = imagePlugin.ReadSector(31 + sectorOffset, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(31 + sectorOffset, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError || sector.Length < 512) return false; diff --git a/Aaru.Partitions/DragonFlyBSD.cs b/Aaru.Partitions/DragonFlyBSD.cs index 583e44275..5ab930903 100644 --- a/Aaru.Partitions/DragonFlyBSD.cs +++ b/Aaru.Partitions/DragonFlyBSD.cs @@ -69,7 +69,7 @@ public sealed class DragonFlyBSD : IPartition if(sectorOffset + nSectors >= imagePlugin.Info.Sectors) return false; - ErrorNumber errno = imagePlugin.ReadSectors(sectorOffset, nSectors, out byte[] sectors, out _); + ErrorNumber errno = imagePlugin.ReadSectors(sectorOffset, false, nSectors, out byte[] sectors, out _); if(errno != ErrorNumber.NoError || sectors.Length < 2048) return false; diff --git a/Aaru.Partitions/GPT.cs b/Aaru.Partitions/GPT.cs index 68fc8cc89..ef3a5b1bd 100644 --- a/Aaru.Partitions/GPT.cs +++ b/Aaru.Partitions/GPT.cs @@ -71,7 +71,7 @@ public sealed class GuidPartitionTable : IPartition if(sectorOffset + 2 >= imagePlugin.Info.Sectors) return false; - ErrorNumber errno = imagePlugin.ReadSector(1 + sectorOffset, out byte[] hdrBytes, out _); + ErrorNumber errno = imagePlugin.ReadSector(1 + sectorOffset, false, out byte[] hdrBytes, out _); if(errno != ErrorNumber.NoError) return false; @@ -86,7 +86,7 @@ public sealed class GuidPartitionTable : IPartition { if(imagePlugin.Info.MetadataMediaType == MetadataMediaType.OpticalDisc) { - errno = imagePlugin.ReadSector(sectorOffset, out hdrBytes, out _); + errno = imagePlugin.ReadSector(sectorOffset, false, out hdrBytes, out _); if(errno != ErrorNumber.NoError) return false; @@ -156,7 +156,11 @@ public sealed class GuidPartitionTable : IPartition if(hdr.entries * hdr.entriesSize % imagePlugin.Info.SectorSize > 0) totalEntriesSectors++; - errno = imagePlugin.ReadSectors(hdr.entryLBA / divisor, totalEntriesSectors + modulo, out byte[] temp, out _); + errno = imagePlugin.ReadSectors(hdr.entryLBA / divisor, + false, + totalEntriesSectors + modulo, + out byte[] temp, + out _); if(errno != ErrorNumber.NoError) return false; diff --git a/Aaru.Partitions/Human68k.cs b/Aaru.Partitions/Human68k.cs index f3312f56a..9361f7a54 100644 --- a/Aaru.Partitions/Human68k.cs +++ b/Aaru.Partitions/Human68k.cs @@ -109,17 +109,17 @@ public sealed partial class Human68K : IPartition switch(imagePlugin.Info.SectorSize) { case 256: - errno = imagePlugin.ReadSector(4 + sectorOffset, out sector, out _); + errno = imagePlugin.ReadSector(4 + sectorOffset, false, out sector, out _); sectsPerUnit = 1; break; case 512: - errno = imagePlugin.ReadSector(4 + sectorOffset, out sector, out _); + errno = imagePlugin.ReadSector(4 + sectorOffset, false, out sector, out _); sectsPerUnit = 2; break; case 1024: - errno = imagePlugin.ReadSector(2 + sectorOffset, out sector, out _); + errno = imagePlugin.ReadSector(2 + sectorOffset, false, out sector, out _); sectsPerUnit = 1; break; diff --git a/Aaru.Partitions/MBR.cs b/Aaru.Partitions/MBR.cs index 9ff175f20..8b2c8a68b 100644 --- a/Aaru.Partitions/MBR.cs +++ b/Aaru.Partitions/MBR.cs @@ -308,7 +308,7 @@ public sealed class MBR : IPartition { partitions = []; - ErrorNumber errno = imagePlugin.ReadSector(start, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(start, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -643,7 +643,7 @@ public sealed class MBR : IPartition divider = 4; } - ErrorNumber errno = imagePlugin.ReadSector(sectorOffset, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(sectorOffset, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -664,7 +664,7 @@ public sealed class MBR : IPartition if(mbr.magic != MBR_MAGIC) return false; // Not MBR - errno = imagePlugin.ReadSector(1 + sectorOffset, out byte[] hdrBytes, out _); + errno = imagePlugin.ReadSector(1 + sectorOffset, false, out byte[] hdrBytes, out _); if(errno != ErrorNumber.NoError) return false; @@ -676,7 +676,7 @@ public sealed class MBR : IPartition if(imagePlugin.Info.MetadataMediaType == MetadataMediaType.OpticalDisc) { - errno = imagePlugin.ReadSector(sectorOffset, out hdrBytes, out _); + errno = imagePlugin.ReadSector(sectorOffset, false, out hdrBytes, out _); if(errno != ErrorNumber.NoError) return false; @@ -824,7 +824,7 @@ public sealed class MBR : IPartition while(processingExtended) { - errno = imagePlugin.ReadSector(lbaStart, out sector, out _); + errno = imagePlugin.ReadSector(lbaStart, false, out sector, out _); if(errno != ErrorNumber.NoError) break; diff --git a/Aaru.Partitions/NeXT.cs b/Aaru.Partitions/NeXT.cs index 3cbc467ec..e140d5d6f 100644 --- a/Aaru.Partitions/NeXT.cs +++ b/Aaru.Partitions/NeXT.cs @@ -95,7 +95,7 @@ public sealed partial class NeXTDisklabel : IPartition 0, 4, 15, 16 }.TakeWhile(i => i + sectorOffset < imagePlugin.Info.Sectors)) { - errno = imagePlugin.ReadSector(i + sectorOffset, out labelSector, out _); + errno = imagePlugin.ReadSector(i + sectorOffset, false, out labelSector, out _); if(errno != ErrorNumber.NoError) continue; @@ -115,7 +115,7 @@ public sealed partial class NeXTDisklabel : IPartition if(7680 % imagePlugin.Info.SectorSize > 0) sectorsToRead++; - errno = imagePlugin.ReadSectors(labelPosition, sectorsToRead, out labelSector, out _); + errno = imagePlugin.ReadSectors(labelPosition, false, sectorsToRead, out labelSector, out _); if(errno != ErrorNumber.NoError) return false; diff --git a/Aaru.Partitions/PC98.cs b/Aaru.Partitions/PC98.cs index d6f80b94b..6631c3566 100644 --- a/Aaru.Partitions/PC98.cs +++ b/Aaru.Partitions/PC98.cs @@ -121,11 +121,11 @@ public sealed class PC98 : IPartition if(sectorOffset != 0) return false; - ErrorNumber errno = imagePlugin.ReadSector(0, out byte[] bootSector, out _); + ErrorNumber errno = imagePlugin.ReadSector(0, false, out byte[] bootSector, out _); if(errno != ErrorNumber.NoError || bootSector[^2] != 0x55 || bootSector[^1] != 0xAA) return false; - errno = imagePlugin.ReadSector(1, out byte[] sector, out _); + errno = imagePlugin.ReadSector(1, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; diff --git a/Aaru.Partitions/Plan9.cs b/Aaru.Partitions/Plan9.cs index 1ae4d771d..96db0c55a 100644 --- a/Aaru.Partitions/Plan9.cs +++ b/Aaru.Partitions/Plan9.cs @@ -67,7 +67,7 @@ public sealed class Plan9 : IPartition if(sectorOffset + 2 >= imagePlugin.Info.Sectors) return false; - ErrorNumber errno = imagePlugin.ReadSector(sectorOffset + 1, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(sectorOffset + 1, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; diff --git a/Aaru.Partitions/RDB.cs b/Aaru.Partitions/RDB.cs index a0201c1c9..af1843850 100644 --- a/Aaru.Partitions/RDB.cs +++ b/Aaru.Partitions/RDB.cs @@ -203,7 +203,7 @@ public sealed class AmigaRigidDiskBlock : IPartition if(rdbBlock + sectorOffset >= imagePlugin.Info.Sectors) break; - errno = imagePlugin.ReadSector(rdbBlock + sectorOffset, out byte[] tmpSector, out _); + errno = imagePlugin.ReadSector(rdbBlock + sectorOffset, false, out byte[] tmpSector, out _); if(errno != ErrorNumber.NoError) { @@ -234,7 +234,7 @@ public sealed class AmigaRigidDiskBlock : IPartition var rdb = new RigidDiskBlock(); - errno = imagePlugin.ReadSector(rdbBlock, out byte[] sector, out _); + errno = imagePlugin.ReadSector(rdbBlock, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError) return false; @@ -374,7 +374,7 @@ public sealed class AmigaRigidDiskBlock : IPartition { AaruLogging.Debug(MODULE_NAME, Localization.Going_to_block_0_in_search_of_a_BadBlock_block, nextBlock); - errno = imagePlugin.ReadSector(nextBlock, out sector, out _); + errno = imagePlugin.ReadSector(nextBlock, false, out sector, out _); if(errno != ErrorNumber.NoError) break; @@ -435,7 +435,7 @@ public sealed class AmigaRigidDiskBlock : IPartition Localization.Going_to_block_0_in_search_of_a_PartitionEntry_block, nextBlock + sectorOffset); - errno = imagePlugin.ReadSector(nextBlock + sectorOffset, out sector, out _); + errno = imagePlugin.ReadSector(nextBlock + sectorOffset, false, out sector, out _); if(errno != ErrorNumber.NoError) break; @@ -595,7 +595,7 @@ public sealed class AmigaRigidDiskBlock : IPartition Localization.Going_to_block_0_in_search_of_a_FileSystemHeader_block, nextBlock); - errno = imagePlugin.ReadSector(nextBlock, out sector, out _); + errno = imagePlugin.ReadSector(nextBlock, false, out sector, out _); if(errno != ErrorNumber.NoError) break; @@ -674,7 +674,7 @@ public sealed class AmigaRigidDiskBlock : IPartition Localization.Going_to_block_0_in_search_of_a_LoadSegment_block, nextBlock); - errno = imagePlugin.ReadSector(nextBlock, out sector, out _); + errno = imagePlugin.ReadSector(nextBlock, false, out sector, out _); if(errno != ErrorNumber.NoError) break; diff --git a/Aaru.Partitions/RioKarma.cs b/Aaru.Partitions/RioKarma.cs index f7ac36aac..ff21ec07b 100644 --- a/Aaru.Partitions/RioKarma.cs +++ b/Aaru.Partitions/RioKarma.cs @@ -94,7 +94,7 @@ public sealed class RioKarma : IPartition public bool GetInformation(IMediaImage imagePlugin, out List partitions, ulong sectorOffset) { partitions = null; - ErrorNumber errno = imagePlugin.ReadSector(sectorOffset, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(sectorOffset, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError || sector.Length < 512) return false; diff --git a/Aaru.Partitions/SGI.cs b/Aaru.Partitions/SGI.cs index b279ea4fe..c7301363b 100644 --- a/Aaru.Partitions/SGI.cs +++ b/Aaru.Partitions/SGI.cs @@ -70,7 +70,7 @@ public sealed partial class SGI : IPartition { partitions = []; - ErrorNumber errno = imagePlugin.ReadSector(sectorOffset, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(sectorOffset, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError || sector.Length < 512) return false; diff --git a/Aaru.Partitions/Sun.cs b/Aaru.Partitions/Sun.cs index bc902053b..140b0b847 100644 --- a/Aaru.Partitions/Sun.cs +++ b/Aaru.Partitions/Sun.cs @@ -106,7 +106,7 @@ public sealed partial class SunDisklabel : IPartition bool useDkl = false, useDkl8 = false, useDkl16 = false; - ErrorNumber errno = imagePlugin.ReadSector(sectorOffset, out byte[] sunSector, out _); + ErrorNumber errno = imagePlugin.ReadSector(sectorOffset, false, out byte[] sunSector, out _); if(errno != ErrorNumber.NoError) return false; @@ -130,7 +130,7 @@ public sealed partial class SunDisklabel : IPartition if(!useDkl && !useDkl8 && !useDkl16) { - errno = imagePlugin.ReadSector(sectorOffset + 1, out sunSector, out _); + errno = imagePlugin.ReadSector(sectorOffset + 1, false, out sunSector, out _); if(errno == ErrorNumber.NoError) { diff --git a/Aaru.Partitions/VTOC.cs b/Aaru.Partitions/VTOC.cs index 2bea4a1d6..93e466a72 100644 --- a/Aaru.Partitions/VTOC.cs +++ b/Aaru.Partitions/VTOC.cs @@ -86,7 +86,7 @@ public sealed partial class VTOC : IPartition 0, 1, 8, 29 }.TakeWhile(i => i + sectorOffset < imagePlugin.Info.Sectors)) { - errno = imagePlugin.ReadSector(i + sectorOffset, out pdsector, out _); + errno = imagePlugin.ReadSector(i + sectorOffset, false, out pdsector, out _); if(errno != ErrorNumber.NoError) continue; @@ -169,7 +169,7 @@ public sealed partial class VTOC : IPartition magicFound = false; var useOld = false; - errno = imagePlugin.ReadSector(pdloc + sectorOffset + 1, out byte[] vtocsector, out _); + errno = imagePlugin.ReadSector(pdloc + sectorOffset + 1, false, out byte[] vtocsector, out _); if(errno != ErrorNumber.NoError) return false; @@ -249,7 +249,7 @@ public sealed partial class VTOC : IPartition return false; } - errno = imagePlugin.ReadSectors(relSecPtr + sectorOffset, secCount, out byte[] tmp, out _); + errno = imagePlugin.ReadSectors(relSecPtr + sectorOffset, false, secCount, out byte[] tmp, out _); if(errno != ErrorNumber.NoError) return false; diff --git a/Aaru.Partitions/XENIX.cs b/Aaru.Partitions/XENIX.cs index 3b57eb303..52cc7dfa5 100644 --- a/Aaru.Partitions/XENIX.cs +++ b/Aaru.Partitions/XENIX.cs @@ -94,7 +94,7 @@ public sealed class XENIX : IPartition if(42 + sectorOffset >= imagePlugin.Info.Sectors) return false; - ErrorNumber errno = imagePlugin.ReadSector(42 + sectorOffset, out byte[] tblsector, out _); + ErrorNumber errno = imagePlugin.ReadSector(42 + sectorOffset, false, out byte[] tblsector, out _); if(errno != ErrorNumber.NoError) return false; diff --git a/Aaru.Partitions/Xbox.cs b/Aaru.Partitions/Xbox.cs index 4e447048a..0999fc3f6 100644 --- a/Aaru.Partitions/Xbox.cs +++ b/Aaru.Partitions/Xbox.cs @@ -84,7 +84,7 @@ public sealed partial class Xbox : IPartition // Xbox partitions always start on 0 if(sectorOffset != 0) return false; - ErrorNumber errno = imagePlugin.ReadSector(0, out byte[] sector, out _); + ErrorNumber errno = imagePlugin.ReadSector(0, false, out byte[] sector, out _); if(errno != ErrorNumber.NoError || sector.Length < 512) return false; @@ -127,6 +127,7 @@ public sealed partial class Xbox : IPartition if(imagePlugin.Info.Sectors > (ulong)(MEMORY_UNIT_DATA_OFF / imagePlugin.Info.SectorSize)) { errno = imagePlugin.ReadSector((ulong)(MEMORY_UNIT_DATA_OFF / imagePlugin.Info.SectorSize), + false, out sector, out _); @@ -169,7 +170,10 @@ public sealed partial class Xbox : IPartition if(imagePlugin.Info.Sectors <= (ulong)(XBOX_360DATA_OFF / imagePlugin.Info.SectorSize)) return false; { - errno = imagePlugin.ReadSector((ulong)(XBOX_360DATA_OFF / imagePlugin.Info.SectorSize), out sector, out _); + errno = imagePlugin.ReadSector((ulong)(XBOX_360DATA_OFF / imagePlugin.Info.SectorSize), + false, + out sector, + out _); if(errno != ErrorNumber.NoError) return false; diff --git a/Aaru.Tests/Images/BlockMediaImageTest.cs b/Aaru.Tests/Images/BlockMediaImageTest.cs index 43a4f16e0..bd0c739c3 100644 --- a/Aaru.Tests/Images/BlockMediaImageTest.cs +++ b/Aaru.Tests/Images/BlockMediaImageTest.cs @@ -118,12 +118,13 @@ public abstract class BlockMediaImageTest : BaseMediaImageTest if(image.Info.Sectors - doneSectors >= SECTORS_TO_READ) { - errno = image.ReadSectors(doneSectors, SECTORS_TO_READ, out sector, out _); + errno = image.ReadSectors(doneSectors, false, SECTORS_TO_READ, out sector, out _); doneSectors += SECTORS_TO_READ; } else { errno = image.ReadSectors(doneSectors, + false, (uint)(image.Info.Sectors - doneSectors), out sector, out _); diff --git a/Aaru.Tests/Images/OpticalMediaImageTest.cs b/Aaru.Tests/Images/OpticalMediaImageTest.cs index 92d807748..713691ce7 100644 --- a/Aaru.Tests/Images/OpticalMediaImageTest.cs +++ b/Aaru.Tests/Images/OpticalMediaImageTest.cs @@ -119,10 +119,10 @@ public abstract class OpticalMediaImageTest : BaseMediaImageTest if(image.Info.ReadableSectorTags.Contains(SectorTagType.CdTrackFlags)) { - ErrorNumber errno = - image.ReadSectorTag(currentTrack.Sequence, - SectorTagType.CdTrackFlags, - out byte[] tmp); + ErrorNumber errno = image.ReadSectorTag(currentTrack.Sequence, + false, + SectorTagType.CdTrackFlags, + out byte[] tmp); if(errno != ErrorNumber.NoError) continue; @@ -523,6 +523,7 @@ public abstract class OpticalMediaImageTest : BaseMediaImageTest if(image.Info.Sectors - doneSectors >= SECTORS_TO_READ) { errno = image.ReadSectors(doneSectors, + false, SECTORS_TO_READ, out sector, out SectorStatus[] _); @@ -532,6 +533,7 @@ public abstract class OpticalMediaImageTest : BaseMediaImageTest else { errno = image.ReadSectors(doneSectors, + false, (uint)(image.Info.Sectors - doneSectors), out sector, out SectorStatus[] _); diff --git a/Aaru.Tests/Images/TapeMediaImageTest.cs b/Aaru.Tests/Images/TapeMediaImageTest.cs index 83eff545b..1351092c1 100644 --- a/Aaru.Tests/Images/TapeMediaImageTest.cs +++ b/Aaru.Tests/Images/TapeMediaImageTest.cs @@ -166,12 +166,13 @@ public abstract class TapeMediaImageTest : BaseMediaImageTest if(image.Info.Sectors - doneSectors >= SECTORS_TO_READ) { - errno = image.ReadSectors(doneSectors, SECTORS_TO_READ, out sector, out _); + errno = image.ReadSectors(doneSectors, false, SECTORS_TO_READ, out sector, out _); doneSectors += SECTORS_TO_READ; } else { errno = image.ReadSectors(doneSectors, + false, (uint)(image.Info.Sectors - doneSectors), out sector, out _); diff --git a/Aaru.Tests/Issues/ImageReadIssueTest.cs b/Aaru.Tests/Issues/ImageReadIssueTest.cs index 546b89a5c..fcce00e5a 100644 --- a/Aaru.Tests/Issues/ImageReadIssueTest.cs +++ b/Aaru.Tests/Issues/ImageReadIssueTest.cs @@ -50,12 +50,17 @@ public abstract class ImageReadIssueTest if(image.Info.Sectors - doneSectors >= SECTORS_TO_READ) { - errno = image.ReadSectors(doneSectors, SECTORS_TO_READ, out sector, out _); + errno = image.ReadSectors(doneSectors, false, SECTORS_TO_READ, out sector, out _); doneSectors += SECTORS_TO_READ; } else { - errno = image.ReadSectors(doneSectors, (uint)(image.Info.Sectors - doneSectors), out sector, out _); + errno = image.ReadSectors(doneSectors, + false, + (uint)(image.Info.Sectors - doneSectors), + out sector, + out _); + doneSectors += image.Info.Sectors - doneSectors; } diff --git a/Aaru.Tests/Issues/OpticalImageConvertIssueTest.cs b/Aaru.Tests/Issues/OpticalImageConvertIssueTest.cs index 93c149d11..cfd2dae17 100644 --- a/Aaru.Tests/Issues/OpticalImageConvertIssueTest.cs +++ b/Aaru.Tests/Issues/OpticalImageConvertIssueTest.cs @@ -157,9 +157,11 @@ public abstract class OpticalImageConvertIssueTest { errno = sectorsToDo == 1 ? inputFormat.ReadSectorLong(doneSectors + track.StartSector, + false, out sector, out sectorStatus) : inputFormat.ReadSectorsLong(doneSectors + track.StartSector, + false, sectorsToDo, out sector, out sectorStatuses); @@ -169,9 +171,11 @@ public abstract class OpticalImageConvertIssueTest result = sectorsToDo == 1 ? outputOptical.WriteSectorLong(sector, doneSectors + track.StartSector, + false, sectorStatus) : outputOptical.WriteSectorsLong(sector, doneSectors + track.StartSector, + false, sectorsToDo, sectorStatuses); } @@ -184,8 +188,12 @@ public abstract class OpticalImageConvertIssueTest if(!UseLong || useNotLong) { errno = sectorsToDo == 1 - ? inputFormat.ReadSector(doneSectors + track.StartSector, out sector, out sectorStatus) + ? inputFormat.ReadSector(doneSectors + track.StartSector, + false, + out sector, + out sectorStatus) : inputFormat.ReadSectors(doneSectors + track.StartSector, + false, sectorsToDo, out sector, out sectorStatuses); @@ -193,9 +201,13 @@ public abstract class OpticalImageConvertIssueTest Assert.That(errno, Is.EqualTo(ErrorNumber.NoError)); result = sectorsToDo == 1 - ? outputOptical.WriteSector(sector, doneSectors + track.StartSector, sectorStatus) + ? outputOptical.WriteSector(sector, + doneSectors + track.StartSector, + false, + sectorStatus) : outputOptical.WriteSectors(sector, doneSectors + track.StartSector, + false, sectorsToDo, sectorStatuses); } @@ -242,7 +254,7 @@ public abstract class OpticalImageConvertIssueTest { foreach(Track track in tracks) { - errno = inputFormat.ReadSectorTag(track.Sequence, tag, out byte[] isrc); + errno = inputFormat.ReadSectorTag(track.Sequence, false, tag, out byte[] isrc); if(errno != ErrorNumber.NoError) continue; @@ -255,7 +267,7 @@ public abstract class OpticalImageConvertIssueTest { foreach(Track track in tracks) { - errno = inputFormat.ReadSectorTag(track.Sequence, tag, out byte[] flags); + errno = inputFormat.ReadSectorTag(track.Sequence, false, tag, out byte[] flags); if(errno != ErrorNumber.NoError) continue; @@ -301,7 +313,7 @@ public abstract class OpticalImageConvertIssueTest { case SectorTagType.CdTrackFlags: case SectorTagType.CdTrackIsrc: - errno = inputFormat.ReadSectorTag(track.Sequence, tag, out sector); + errno = inputFormat.ReadSectorTag(track.Sequence, false, tag, out sector); if(errno == ErrorNumber.NoData) continue; @@ -309,7 +321,7 @@ public abstract class OpticalImageConvertIssueTest Is.EqualTo(ErrorNumber.NoError), string.Format(Localization.Error_0_reading_tag_not_continuing, errno)); - result = outputOptical.WriteSectorTag(sector, track.Sequence, tag); + result = outputOptical.WriteSectorTag(sector, track.Sequence, false, tag); Assert.That(result, string.Format(Localization.Error_0_writing_tag_not_continuing, @@ -329,7 +341,7 @@ public abstract class OpticalImageConvertIssueTest if(sectorsToDo == 1) { - errno = inputFormat.ReadSectorTag(doneSectors + track.StartSector, tag, out sector); + errno = inputFormat.ReadSectorTag(doneSectors + track.StartSector, false, tag, out sector); Assert.That(errno, Is.EqualTo(ErrorNumber.NoError), @@ -362,11 +374,12 @@ public abstract class OpticalImageConvertIssueTest result = true; } else - result = outputOptical.WriteSectorTag(sector, doneSectors + track.StartSector, tag); + result = outputOptical.WriteSectorTag(sector, doneSectors + track.StartSector, false, tag); } else { errno = inputFormat.ReadSectorsTag(doneSectors + track.StartSector, + false, sectorsToDo, tag, out sector); @@ -405,6 +418,7 @@ public abstract class OpticalImageConvertIssueTest { result = outputOptical.WriteSectorsTag(sector, doneSectors + track.StartSector, + false, sectorsToDo, tag); } @@ -421,12 +435,15 @@ public abstract class OpticalImageConvertIssueTest } foreach(KeyValuePair isrc in isrcs) - outputOptical.WriteSectorTag(Encoding.UTF8.GetBytes(isrc.Value), isrc.Key, SectorTagType.CdTrackIsrc); + outputOptical.WriteSectorTag(Encoding.UTF8.GetBytes(isrc.Value), + isrc.Key, + false, + SectorTagType.CdTrackIsrc); if(trackFlags.Count > 0) { foreach((byte track, byte flags) in trackFlags) - outputOptical.WriteSectorTag([flags], track, SectorTagType.CdTrackFlags); + outputOptical.WriteSectorTag([flags], track, false, SectorTagType.CdTrackFlags); } if(mcn != null) outputOptical.WriteMediaTag(Encoding.UTF8.GetBytes(mcn), MediaTagType.CD_MCN); diff --git a/Aaru.Tests/WritableImages/WritableOpticalMediaImageTest.cs b/Aaru.Tests/WritableImages/WritableOpticalMediaImageTest.cs index 88e518cf4..d34d39511 100644 --- a/Aaru.Tests/WritableImages/WritableOpticalMediaImageTest.cs +++ b/Aaru.Tests/WritableImages/WritableOpticalMediaImageTest.cs @@ -115,6 +115,7 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest if(image.Info.ReadableSectorTags.Contains(SectorTagType.CdTrackFlags)) { errno = image.ReadSectorTag(currentTrack.Sequence, + false, SectorTagType.CdTrackFlags, out byte[] tmp); @@ -249,9 +250,11 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest { errno = sectorsToDo == 1 ? inputFormat.ReadSectorLong(doneSectors + track.StartSector, + false, out sector, out sectorStatus) : inputFormat.ReadSectorsLong(doneSectors + track.StartSector, + false, sectorsToDo, out sector, out sectorStatusArray); @@ -261,9 +264,11 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest result = sectorsToDo == 1 ? outputFormat.WriteSectorLong(sector, doneSectors + track.StartSector, + false, sectorStatus) : outputFormat.WriteSectorsLong(sector, doneSectors + track.StartSector, + false, sectorsToDo, sectorStatusArray); } @@ -277,9 +282,11 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest { errno = sectorsToDo == 1 ? inputFormat.ReadSector(doneSectors + track.StartSector, + false, out sector, out sectorStatus) : inputFormat.ReadSectors(doneSectors + track.StartSector, + false, sectorsToDo, out sector, out sectorStatusArray); @@ -289,9 +296,11 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest result = sectorsToDo == 1 ? outputFormat.WriteSector(sector, doneSectors + track.StartSector, + false, sectorStatus) : outputFormat.WriteSectors(sector, doneSectors + track.StartSector, + false, sectorsToDo, sectorStatusArray); } @@ -339,7 +348,7 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest { foreach(Track track in tracks) { - errno = inputFormat.ReadSectorTag(track.Sequence, tag, out byte[] isrc); + errno = inputFormat.ReadSectorTag(track.Sequence, false, tag, out byte[] isrc); if(errno != ErrorNumber.NoError) continue; @@ -353,7 +362,7 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest { foreach(Track track in tracks) { - errno = inputFormat.ReadSectorTag(track.Sequence, tag, out byte[] flags); + errno = inputFormat.ReadSectorTag(track.Sequence, false, tag, out byte[] flags); if(errno != ErrorNumber.NoError) continue; @@ -400,13 +409,13 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest { case SectorTagType.CdTrackFlags: case SectorTagType.CdTrackIsrc: - errno = inputFormat.ReadSectorTag(track.Sequence, tag, out sector); + errno = inputFormat.ReadSectorTag(track.Sequence, false, tag, out sector); Assert.That(errno, Is.EqualTo(ErrorNumber.NoError), string.Format(Localization.Error_0_reading_tag_not_continuing, errno)); - result = outputFormat.WriteSectorTag(sector, track.Sequence, tag); + result = outputFormat.WriteSectorTag(sector, track.Sequence, false, tag); Assert.That(result, string.Format(Localization.Error_0_writing_tag_not_continuing, @@ -426,7 +435,10 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest if(sectorsToDo == 1) { - errno = inputFormat.ReadSectorTag(doneSectors + track.StartSector, tag, out sector); + errno = inputFormat.ReadSectorTag(doneSectors + track.StartSector, + false, + tag, + out sector); Assert.That(errno, Is.EqualTo(ErrorNumber.NoError), @@ -459,11 +471,15 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest result = true; } else - result = outputFormat.WriteSectorTag(sector, doneSectors + track.StartSector, tag); + result = outputFormat.WriteSectorTag(sector, + doneSectors + track.StartSector, + false, + tag); } else { errno = inputFormat.ReadSectorsTag(doneSectors + track.StartSector, + false, sectorsToDo, tag, out sector); @@ -502,6 +518,7 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest { result = outputFormat.WriteSectorsTag(sector, doneSectors + track.StartSector, + false, sectorsToDo, tag); } @@ -521,13 +538,14 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest { outputFormat.WriteSectorTag(Encoding.UTF8.GetBytes(isrc.Value), isrc.Key, + false, SectorTagType.CdTrackIsrc); } if(trackFlags.Count > 0) { foreach((byte track, byte flags) in trackFlags) - outputFormat.WriteSectorTag([flags], track, SectorTagType.CdTrackFlags); + outputFormat.WriteSectorTag([flags], track, false, SectorTagType.CdTrackFlags); } if(mcn != null) outputFormat.WriteMediaTag(Encoding.UTF8.GetBytes(mcn), MediaTagType.CD_MCN); @@ -660,6 +678,7 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest if(image.Info.ReadableSectorTags.Contains(SectorTagType.CdTrackFlags)) { errno = image.ReadSectorTag(currentTrack.Sequence, + false, SectorTagType.CdTrackFlags, out byte[] tmp); diff --git a/Aaru.Tui/ViewModels/Windows/HexViewWindowViewModel.cs b/Aaru.Tui/ViewModels/Windows/HexViewWindowViewModel.cs index 8629bc475..8c979b613 100644 --- a/Aaru.Tui/ViewModels/Windows/HexViewWindowViewModel.cs +++ b/Aaru.Tui/ViewModels/Windows/HexViewWindowViewModel.cs @@ -168,7 +168,7 @@ public sealed partial class HexViewWindowViewModel : ViewModelBase if(_longMode) { - ErrorNumber errno = _imageFormat.ReadSectorLong(CurrentSector, out sector, out _); + ErrorNumber errno = _imageFormat.ReadSectorLong(CurrentSector, false, out sector, out _); if(errno != ErrorNumber.NoError) { @@ -178,7 +178,7 @@ public sealed partial class HexViewWindowViewModel : ViewModelBase } } else - _imageFormat.ReadSector(CurrentSector, out sector, out _); + _imageFormat.ReadSector(CurrentSector, false, out sector, out _); using var stream = new MemoryStream(sector); var buffer = new byte[BYTES_PER_LINE]; diff --git a/Aaru/Commands/Image/Checksum.cs b/Aaru/Commands/Image/Checksum.cs index 2b57c24ef..56364c578 100644 --- a/Aaru/Commands/Image/Checksum.cs +++ b/Aaru/Commands/Image/Checksum.cs @@ -365,7 +365,7 @@ sealed class ChecksumCommand : Command { preFileTask.Description = string.Format(UI.Hashing_file_less_block_0, i); - errno = tapeImage.ReadSector(i, out byte[] hiddenSector, out _); + errno = tapeImage.ReadSector(i, false, out byte[] hiddenSector, out _); if(errno != ErrorNumber.NoError) { @@ -404,6 +404,7 @@ sealed class ChecksumCommand : Command if(sectors - doneSectors >= SECTORS_TO_READ) { errno = tapeImage.ReadSectors(doneSectors + currentFile.FirstBlock, + false, SECTORS_TO_READ, out sector, out _); @@ -430,6 +431,7 @@ sealed class ChecksumCommand : Command else { errno = tapeImage.ReadSectors(doneSectors + currentFile.FirstBlock, + false, (uint)(sectors - doneSectors), out sector, out _); @@ -492,7 +494,7 @@ sealed class ChecksumCommand : Command { postFileTask.Description = string.Format(UI.Hashing_file_less_block_0, i); - errno = tapeImage.ReadSector(i, out byte[] hiddenSector, out _); + errno = tapeImage.ReadSector(i, false, out byte[] hiddenSector, out _); if(errno != ErrorNumber.NoError) { @@ -624,7 +626,11 @@ sealed class ChecksumCommand : Command if(sectors - doneSectors >= SECTORS_TO_READ) { - errno = mediaImage.ReadSectors(doneSectors, SECTORS_TO_READ, out sector, out _); + errno = mediaImage.ReadSectors(doneSectors, + false, + SECTORS_TO_READ, + out sector, + out _); if(errno != ErrorNumber.NoError) { @@ -647,6 +653,7 @@ sealed class ChecksumCommand : Command else { errno = mediaImage.ReadSectors(doneSectors, + false, (uint)(sectors - doneSectors), out sector, out _); diff --git a/Aaru/Commands/Image/Compare.cs b/Aaru/Commands/Image/Compare.cs index 1091b61a2..20ef0f809 100644 --- a/Aaru/Commands/Image/Compare.cs +++ b/Aaru/Commands/Image/Compare.cs @@ -438,7 +438,7 @@ sealed class CompareCommand : Command try { - errno = input1MediaImage.ReadSector(sector, out byte[] image1Sector, out _); + errno = input1MediaImage.ReadSector(sector, false, out byte[] image1Sector, out _); if(errno != ErrorNumber.NoError) { @@ -447,7 +447,7 @@ sealed class CompareCommand : Command sector)); } - errno = input2MediaImage.ReadSector(sector, out byte[] image2Sector, out _); + errno = input2MediaImage.ReadSector(sector, false, out byte[] image2Sector, out _); if(errno != ErrorNumber.NoError) { diff --git a/Aaru/Commands/Image/Convert.cs b/Aaru/Commands/Image/Convert.cs index 4a95ea974..250495d64 100644 --- a/Aaru/Commands/Image/Convert.cs +++ b/Aaru/Commands/Image/Convert.cs @@ -709,9 +709,11 @@ sealed class ConvertImageCommand : Command { errno = sectorsToDo == 1 ? inputOptical.ReadSectorLong(doneSectors + track.StartSector, + false, out sector, out sectorStatus) : inputOptical.ReadSectorsLong(doneSectors + track.StartSector, + false, sectorsToDo, out sector, out sectorStatusArray); @@ -721,9 +723,11 @@ sealed class ConvertImageCommand : Command result = sectorsToDo == 1 ? outputOptical.WriteSectorLong(sector, doneSectors + track.StartSector, + false, sectorStatus) : outputOptical.WriteSectorsLong(sector, doneSectors + track.StartSector, + false, sectorsToDo, sectorStatusArray); } @@ -769,9 +773,11 @@ sealed class ConvertImageCommand : Command { errno = sectorsToDo == 1 ? inputOptical.ReadSector(doneSectors + track.StartSector, + false, out sector, out sectorStatus) : inputOptical.ReadSectors(doneSectors + track.StartSector, + false, sectorsToDo, out sector, out sectorStatusArray); @@ -792,10 +798,12 @@ sealed class ConvertImageCommand : Command if(sectorsToDo == 1) { if(inputOptical.ReadSectorTag(doneSectors + track.StartSector, + false, SectorTagType.DvdSectorCmi, out cmi) == ErrorNumber.NoError && inputOptical.ReadSectorTag(doneSectors + track.StartSector, + false, SectorTagType.DvdTitleKeyDecrypted, out titleKey) == ErrorNumber.NoError) @@ -848,11 +856,13 @@ sealed class ConvertImageCommand : Command else { if(inputOptical.ReadSectorsTag(doneSectors + track.StartSector, + false, sectorsToDo, SectorTagType.DvdSectorCmi, out cmi) == ErrorNumber.NoError && inputOptical.ReadSectorsTag(doneSectors + track.StartSector, + false, sectorsToDo, SectorTagType.DvdTitleKeyDecrypted, out titleKey) == @@ -912,9 +922,11 @@ sealed class ConvertImageCommand : Command result = sectorsToDo == 1 ? outputOptical.WriteSector(sector, doneSectors + track.StartSector, + false, sectorStatus) : outputOptical.WriteSectors(sector, doneSectors + track.StartSector, + false, sectorsToDo, sectorStatusArray); } @@ -1005,7 +1017,7 @@ sealed class ConvertImageCommand : Command { foreach(Track track in tracks) { - errno = inputOptical.ReadSectorTag(track.Sequence, tag, out byte[] isrc); + errno = inputOptical.ReadSectorTag(track.Sequence, false, tag, out byte[] isrc); if(errno != ErrorNumber.NoError) continue; @@ -1019,7 +1031,7 @@ sealed class ConvertImageCommand : Command { foreach(Track track in tracks) { - errno = inputOptical.ReadSectorTag(track.Sequence, tag, out byte[] flags); + errno = inputOptical.ReadSectorTag(track.Sequence, false, tag, out byte[] flags); if(errno != ErrorNumber.NoError) continue; @@ -1087,7 +1099,7 @@ sealed class ConvertImageCommand : Command { case SectorTagType.CdTrackFlags: case SectorTagType.CdTrackIsrc: - errno = inputOptical.ReadSectorTag(track.Sequence, tag, out sector); + errno = inputOptical.ReadSectorTag(track.Sequence, false, tag, out sector); switch(errno) { @@ -1096,7 +1108,10 @@ sealed class ConvertImageCommand : Command continue; case ErrorNumber.NoError: - result = outputOptical.WriteSectorTag(sector, track.Sequence, tag); + result = outputOptical.WriteSectorTag(sector, + track.Sequence, + false, + tag); break; default: @@ -1161,6 +1176,7 @@ sealed class ConvertImageCommand : Command if(sectorsToDo == 1) { errno = inputOptical.ReadSectorTag(doneSectors + track.StartSector, + false, tag, out sector); @@ -1197,6 +1213,7 @@ sealed class ConvertImageCommand : Command { result = outputOptical.WriteSectorTag(sector, doneSectors + track.StartSector, + false, tag); } } @@ -1224,6 +1241,7 @@ sealed class ConvertImageCommand : Command else { errno = inputOptical.ReadSectorsTag(doneSectors + track.StartSector, + false, sectorsToDo, tag, out sector); @@ -1261,6 +1279,7 @@ sealed class ConvertImageCommand : Command { result = outputOptical.WriteSectorsTag(sector, doneSectors + track.StartSector, + false, sectorsToDo, tag); } @@ -1320,12 +1339,15 @@ sealed class ConvertImageCommand : Command } foreach(KeyValuePair isrc in isrcs) - outputOptical.WriteSectorTag(Encoding.UTF8.GetBytes(isrc.Value), isrc.Key, SectorTagType.CdTrackIsrc); + outputOptical.WriteSectorTag(Encoding.UTF8.GetBytes(isrc.Value), + isrc.Key, + false, + SectorTagType.CdTrackIsrc); if(trackFlags.Count > 0) { foreach((byte track, byte flags) in trackFlags) - outputOptical.WriteSectorTag([flags], track, SectorTagType.CdTrackFlags); + outputOptical.WriteSectorTag([flags], track, false, SectorTagType.CdTrackFlags); } if(mcn != null) outputOptical.WriteMediaTag(Encoding.UTF8.GetBytes(mcn), MediaTagType.CD_MCN); @@ -1446,8 +1468,12 @@ sealed class ConvertImageCommand : Command if(useLong) { errno = sectorsToDo == 1 - ? inputFormat.ReadSectorLong(doneSectors, out sector, out sectorStatus) + ? inputFormat.ReadSectorLong(doneSectors, + false, + out sector, + out sectorStatus) : inputFormat.ReadSectorsLong(doneSectors, + false, sectorsToDo, out sector, out sectorStatusArray); @@ -1455,9 +1481,13 @@ sealed class ConvertImageCommand : Command if(errno == ErrorNumber.NoError) { result = sectorsToDo == 1 - ? outputMedia.WriteSectorLong(sector, doneSectors, sectorStatus) + ? outputMedia.WriteSectorLong(sector, + doneSectors, + false, + sectorStatus) : outputMedia.WriteSectorsLong(sector, doneSectors, + false, sectorsToDo, sectorStatusArray); } @@ -1484,8 +1514,12 @@ sealed class ConvertImageCommand : Command else { errno = sectorsToDo == 1 - ? inputFormat.ReadSector(doneSectors, out sector, out sectorStatus) + ? inputFormat.ReadSector(doneSectors, + false, + out sector, + out sectorStatus) : inputFormat.ReadSectors(doneSectors, + false, sectorsToDo, out sector, out sectorStatusArray); @@ -1493,9 +1527,10 @@ sealed class ConvertImageCommand : Command if(errno == ErrorNumber.NoError) { result = sectorsToDo == 1 - ? outputMedia.WriteSector(sector, doneSectors, sectorStatus) + ? outputMedia.WriteSector(sector, doneSectors, false, sectorStatus) : outputMedia.WriteSectors(sector, doneSectors, + false, sectorsToDo, sectorStatusArray); } @@ -1588,15 +1623,20 @@ sealed class ConvertImageCommand : Command bool result; errno = sectorsToDo == 1 - ? inputFormat.ReadSectorTag(doneSectors, tag, out byte[] sector) - : inputFormat.ReadSectorsTag(doneSectors, sectorsToDo, tag, out sector); + ? inputFormat.ReadSectorTag(doneSectors, false, tag, out byte[] sector) + : inputFormat.ReadSectorsTag(doneSectors, + false, + sectorsToDo, + tag, + out sector); if(errno == ErrorNumber.NoError) { result = sectorsToDo == 1 - ? outputMedia.WriteSectorTag(sector, doneSectors, tag) + ? outputMedia.WriteSectorTag(sector, doneSectors, false, tag) : outputMedia.WriteSectorsTag(sector, doneSectors, + false, sectorsToDo, tag); } diff --git a/Aaru/Commands/Image/Print.cs b/Aaru/Commands/Image/Print.cs index 0bf1e5e66..d99ad8927 100644 --- a/Aaru/Commands/Image/Print.cs +++ b/Aaru/Commands/Image/Print.cs @@ -186,8 +186,8 @@ sealed class PrintHexCommand : Command ctx.AddTask(UI.Reading_sector).IsIndeterminate(); errno = longSectors - ? blockImage.ReadSectorLong(settings.Start + i, out sector, out _) - : blockImage.ReadSector(settings.Start + i, out sector, out _); + ? blockImage.ReadSectorLong(settings.Start + i, false, out sector, out _) + : blockImage.ReadSector(settings.Start + i, false, out sector, out _); }); if(errno == ErrorNumber.NoError)