mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
HDCopy: Fix a bug in sector calculation
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
// /***************************************************************************
|
// /***************************************************************************
|
||||||
// The Disc Image Chef
|
// The Disc Image Chef
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
@@ -247,7 +247,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
public byte[] ReadSector(ulong sectorAddress)
|
public byte[] ReadSector(ulong sectorAddress)
|
||||||
{
|
{
|
||||||
int trackNum = (int)(sectorAddress / imageInfo.SectorsPerTrack);
|
int trackNum = (int)(sectorAddress / imageInfo.SectorsPerTrack);
|
||||||
int sectorOffset = (int)(sectorAddress % (imageInfo.SectorsPerTrack * imageInfo.SectorSize));
|
int sectorOffset = (int)(sectorAddress % imageInfo.SectorsPerTrack);
|
||||||
|
|
||||||
if(sectorAddress > imageInfo.Sectors - 1)
|
if(sectorAddress > imageInfo.Sectors - 1)
|
||||||
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
|
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
|
||||||
@@ -262,7 +262,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
// track is present in file, make sure it has been loaded
|
// track is present in file, make sure it has been loaded
|
||||||
if(!trackCache.ContainsKey(trackNum)) ReadTrackIntoCache(hdcpImageFilter.GetDataForkStream(), trackNum);
|
if(!trackCache.ContainsKey(trackNum)) ReadTrackIntoCache(hdcpImageFilter.GetDataForkStream(), trackNum);
|
||||||
|
|
||||||
Array.Copy(trackCache[trackNum], sectorOffset, result, 0, imageInfo.SectorSize);
|
Array.Copy(trackCache[trackNum], sectorOffset * imageInfo.SectorSize, result, 0, imageInfo.SectorSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Reference in New Issue
Block a user