diff --git a/Aaru.Images/AaruFormat/Enums.cs b/Aaru.Images/AaruFormat/Enums.cs
index a58100126..77777b53a 100644
--- a/Aaru.Images/AaruFormat/Enums.cs
+++ b/Aaru.Images/AaruFormat/Enums.cs
@@ -109,6 +109,11 @@ public sealed partial class AaruFormat
///
Ok = 0,
///
+ /// Sector has not been dumped.
+ /// <remarks>AARUF_STATUS_SECTOR_NOT_DUMPED</remarks>
+ ///
+ SectorNotDumped = 1,
+ ///
/// Input file/stream failed magic or structural validation.
/// <remarks>AARUF_ERROR_NOT_AARUFORMAT</remarks>
///
diff --git a/Aaru.Images/AaruFormat/Read.cs b/Aaru.Images/AaruFormat/Read.cs
index 2cae671f5..a693de36e 100644
--- a/Aaru.Images/AaruFormat/Read.cs
+++ b/Aaru.Images/AaruFormat/Read.cs
@@ -10,6 +10,43 @@ namespace Aaru.Images;
public sealed partial class AaruFormat
{
+ // AARU_EXPORT int32_t AARU_CALL aaruf_read_media_tag(void *context, uint8_t *data, const int32_t tag, uint32_t *length)
+ [LibraryImport("libaaruformat", EntryPoint = "aaruf_read_media_tag", SetLastError = true)]
+ [UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
+ private static partial Status aaruf_read_media_tag(IntPtr context, byte[] data, MediaTagType tag, ref uint length);
+
+ // AARU_EXPORT int32_t AARU_CALL aaruf_read_sector(void *context, const uint64_t sector_address, bool negative,
+ // uint8_t *data, uint32_t *length, uint8_t *sector_status)
+ [LibraryImport("libaaruformat", EntryPoint = "aaruf_read_sector", SetLastError = true)]
+ [UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
+ private static partial Status aaruf_read_sector(IntPtr context, ulong sectorAddress,
+ [MarshalAs(UnmanagedType.I4)] bool negative, byte[] data,
+ ref uint length, out byte sectorStatus);
+
+ // AARU_EXPORT int32_t AARU_CALL aaruf_read_track_sector(void *context, uint8_t *data, const uint64_t sector_address,
+ // uint32_t *length, const uint8_t track, uint8_t *sector_status)
+ [LibraryImport("libaaruformat", EntryPoint = "aaruf_read_track_sector", SetLastError = true)]
+ [UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
+ private static partial Status aaruf_read_track_sector(IntPtr context, byte[] data, ulong sectorAddress,
+ ref uint length, byte track, out byte sectorStatus);
+
+ // AARU_EXPORT int32_t AARU_CALL aaruf_read_sector_long(void *context, const uint64_t sector_address, bool negative,
+ // uint8_t *data, uint32_t *length, uint8_t *sector_status)
+ [LibraryImport("libaaruformat", EntryPoint = "aaruf_read_sector_long", SetLastError = true)]
+ [UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
+ private static partial Status aaruf_read_sector_long(IntPtr context, ulong sectorAddress,
+ [MarshalAs(UnmanagedType.I4)] bool negative, byte[] data,
+ ref uint length, out byte sectorStatus);
+
+ // AARU_EXPORT int32_t AARU_CALL aaruf_read_sector_tag(const void *context, const uint64_t sector_address,
+ // const bool negative, uint8_t *buffer, uint32_t *length,
+ // const int32_t tag)
+ [LibraryImport("libaaruformat", EntryPoint = "aaruf_read_sector_tag", SetLastError = true)]
+ [UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
+ private static partial Status aaruf_read_sector_tag(IntPtr context, ulong sectorAddress,
+ [MarshalAs(UnmanagedType.I4)] bool negative, byte[] buffer,
+ ref uint length, SectorTagType tag);
+
#region IWritableOpticalImage Members
///
@@ -45,7 +82,12 @@ public sealed partial class AaruFormat
res = aaruf_read_sector(_context, sectorAddress, false, buffer, ref length, out _);
- return StatusToErrorNumber(res);
+ // Sector not dumped
+ if(res != Status.SectorNotDumped || length <= 0) return StatusToErrorNumber(res);
+
+ buffer = new byte[length];
+
+ return ErrorNumber.NoError;
}
///
@@ -62,7 +104,12 @@ public sealed partial class AaruFormat
res = aaruf_read_track_sector(_context, buffer, sectorAddress, ref length, (byte)track, out _);
- return StatusToErrorNumber(res);
+ // Sector not dumped
+ if(res != Status.SectorNotDumped || length <= 0) return StatusToErrorNumber(res);
+
+ buffer = new byte[length];
+
+ return ErrorNumber.NoError;
}
///
@@ -79,7 +126,12 @@ public sealed partial class AaruFormat
res = aaruf_read_sector_long(_context, sectorAddress, false, buffer, ref length, out _);
- return StatusToErrorNumber(res);
+ // Sector not dumped
+ if(res != Status.SectorNotDumped || length <= 0) return StatusToErrorNumber(res);
+
+ buffer = new byte[length];
+
+ return ErrorNumber.NoError;
}
///
@@ -259,41 +311,4 @@ public sealed partial class AaruFormat
}
#endregion
-
- // AARU_EXPORT int32_t AARU_CALL aaruf_read_media_tag(void *context, uint8_t *data, const int32_t tag, uint32_t *length)
- [LibraryImport("libaaruformat", EntryPoint = "aaruf_read_media_tag", SetLastError = true)]
- [UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
- private static partial Status aaruf_read_media_tag(IntPtr context, byte[] data, MediaTagType tag, ref uint length);
-
- // AARU_EXPORT int32_t AARU_CALL aaruf_read_sector(void *context, const uint64_t sector_address, bool negative,
- // uint8_t *data, uint32_t *length, uint8_t *sector_status)
- [LibraryImport("libaaruformat", EntryPoint = "aaruf_read_sector", SetLastError = true)]
- [UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
- private static partial Status aaruf_read_sector(IntPtr context, ulong sectorAddress,
- [MarshalAs(UnmanagedType.I4)] bool negative, byte[] data,
- ref uint length, out byte sectorStatus);
-
- // AARU_EXPORT int32_t AARU_CALL aaruf_read_track_sector(void *context, uint8_t *data, const uint64_t sector_address,
- // uint32_t *length, const uint8_t track, uint8_t *sector_status)
- [LibraryImport("libaaruformat", EntryPoint = "aaruf_read_track_sector", SetLastError = true)]
- [UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
- private static partial Status aaruf_read_track_sector(IntPtr context, byte[] data, ulong sectorAddress,
- ref uint length, byte track, out byte sectorStatus);
-
- // AARU_EXPORT int32_t AARU_CALL aaruf_read_sector_long(void *context, const uint64_t sector_address, bool negative,
- // uint8_t *data, uint32_t *length, uint8_t *sector_status)
- [LibraryImport("libaaruformat", EntryPoint = "aaruf_read_sector_long", SetLastError = true)]
- [UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
- private static partial Status aaruf_read_sector_long(IntPtr context, ulong sectorAddress,
- [MarshalAs(UnmanagedType.I4)] bool negative, byte[] data,
- ref uint length, out byte sectorStatus);
-
- // AARU_EXPORT int32_t AARU_CALL aaruf_read_sector_tag(const void *context, const uint64_t sector_address,
- // const bool negative, uint8_t *buffer, uint32_t *length,
- // const int32_t tag)
- [LibraryImport("libaaruformat", EntryPoint = "aaruf_read_sector_tag", SetLastError = true)]
- [UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
- private static partial Status aaruf_read_sector_tag(IntPtr context, ulong sectorAddress,
- [MarshalAs(UnmanagedType.I4)] bool negative, byte[] buffer,
- ref uint length, SectorTagType tag);
}
\ No newline at end of file