diff --git a/SabreTools.Serialization/Wrappers/BFPK.cs b/SabreTools.Serialization/Wrappers/BFPK.cs
index 445b1984..8ce7e84b 100644
--- a/SabreTools.Serialization/Wrappers/BFPK.cs
+++ b/SabreTools.Serialization/Wrappers/BFPK.cs
@@ -132,7 +132,7 @@ namespace SabreTools.Serialization.Wrappers
int compressedSize = file.CompressedSize;
// Some files can lack the length prefix
- if (compressedSize > GetEndOffset())
+ if (compressedSize > Length)
{
offset -= 4;
compressedSize = file.UncompressedSize;
diff --git a/SabreTools.Serialization/Wrappers/CFB.cs b/SabreTools.Serialization/Wrappers/CFB.cs
index 2fe0a5e4..24534dd8 100644
--- a/SabreTools.Serialization/Wrappers/CFB.cs
+++ b/SabreTools.Serialization/Wrappers/CFB.cs
@@ -314,7 +314,7 @@ namespace SabreTools.Serialization.Wrappers
{
// Try to get the sector data offset
int sectorDataOffset = (int)FATSectorToFileOffset(sectorChain[i]);
- if (sectorDataOffset < 0 || sectorDataOffset >= GetEndOffset())
+ if (sectorDataOffset < 0 || sectorDataOffset >= Length)
return null;
// Try to read the sector data
diff --git a/SabreTools.Serialization/Wrappers/LinearExecutable.cs b/SabreTools.Serialization/Wrappers/LinearExecutable.cs
index fecc0565..a4589d5f 100644
--- a/SabreTools.Serialization/Wrappers/LinearExecutable.cs
+++ b/SabreTools.Serialization/Wrappers/LinearExecutable.cs
@@ -165,9 +165,9 @@ namespace SabreTools.Serialization.Wrappers
if (InformationBlock == null)
return -1;
- // Get the end of the file, if possible
- long endOfFile = GetEndOffset();
- if (endOfFile == -1)
+ // Get the available source length, if possible
+ long dataLength = Length;
+ if (dataLength == -1)
return -1;
// Get the matching entry
@@ -177,7 +177,7 @@ namespace SabreTools.Serialization.Wrappers
// Verify the entry offset
int offset = (int)(entry.PageDataOffset << (int)InformationBlock.BytesOnLastPage);
- if (offset < 0 || offset + entry.DataSize >= endOfFile)
+ if (offset < 0 || offset + entry.DataSize >= dataLength)
return -1;
// Return the verified offset
@@ -267,9 +267,9 @@ namespace SabreTools.Serialization.Wrappers
if (InformationBlock == null)
return -1;
- // Get the end of the file, if possible
- long endOfFile = GetEndOffset();
- if (endOfFile == -1)
+ // Get the available source length, if possible
+ long dataLength = Length;
+ if (dataLength == -1)
return -1;
// Get the matching entry
@@ -309,7 +309,7 @@ namespace SabreTools.Serialization.Wrappers
// If we have an unset length, read the whole source
if (length == -1)
- length = GetEndOffset();
+ length = Length;
return ReadFromDataSource(rangeStart, (int)length);
}
diff --git a/SabreTools.Serialization/Wrappers/NewExecutable.cs b/SabreTools.Serialization/Wrappers/NewExecutable.cs
index 65045cfd..ea4e646e 100644
--- a/SabreTools.Serialization/Wrappers/NewExecutable.cs
+++ b/SabreTools.Serialization/Wrappers/NewExecutable.cs
@@ -39,9 +39,9 @@ namespace SabreTools.Serialization.Wrappers
if (_overlayAddress != null)
return _overlayAddress.Value;
- // Get the end of the file, if possible
- long endOfFile = GetEndOffset();
- if (endOfFile == -1)
+ // Get the available source length, if possible
+ long dataLength = Length;
+ if (dataLength == -1)
return -1;
// If a required property is missing
@@ -109,9 +109,9 @@ namespace SabreTools.Serialization.Wrappers
if (_overlayData != null)
return _overlayData;
- // Get the end of the file, if possible
- long endOfFile = GetEndOffset();
- if (endOfFile == -1)
+ // Get the available source length, if possible
+ long dataLength = Length;
+ if (dataLength == -1)
return null;
// If a required property is missing
@@ -151,14 +151,14 @@ namespace SabreTools.Serialization.Wrappers
endOfSectionData += 705;
// If we're at the end of the file, cache an empty byte array
- if (endOfSectionData >= endOfFile)
+ if (endOfSectionData >= dataLength)
{
_overlayData = [];
return _overlayData;
}
// Otherwise, cache and return the data
- long overlayLength = endOfFile - endOfSectionData;
+ long overlayLength = dataLength - endOfSectionData;
_overlayData = ReadFromDataSource(endOfSectionData, (int)overlayLength);
return _overlayData;
}
@@ -178,9 +178,9 @@ namespace SabreTools.Serialization.Wrappers
if (_overlayStrings != null)
return _overlayStrings;
- // Get the end of the file, if possible
- long endOfFile = GetEndOffset();
- if (endOfFile == -1)
+ // Get the available source length, if possible
+ long dataLength = Length;
+ if (dataLength == -1)
return null;
// If a required property is missing
@@ -220,7 +220,7 @@ namespace SabreTools.Serialization.Wrappers
endOfSectionData += 705;
// If we're at the end of the file, cache an empty list
- if (endOfSectionData >= endOfFile)
+ if (endOfSectionData >= dataLength)
{
_overlayStrings = [];
return _overlayStrings;
@@ -228,7 +228,7 @@ namespace SabreTools.Serialization.Wrappers
// TODO: Revisit the 16 MiB limit
// Cap the check for overlay strings to 16 MiB (arbitrary)
- long overlayLength = Math.Min(endOfFile - endOfSectionData, 16 * 1024 * 1024);
+ long overlayLength = Math.Min(dataLength - endOfSectionData, 16 * 1024 * 1024);
// Otherwise, cache and return the strings
_overlayStrings = ReadStringsFromDataSource(endOfSectionData, (int)overlayLength, charLimit: 3);
@@ -384,9 +384,9 @@ namespace SabreTools.Serialization.Wrappers
if (Header == null)
return null;
- // Get the end of the file, if possible
- long endOfFile = GetEndOffset();
- if (endOfFile == -1)
+ // Get the available source length, if possible
+ long dataLength = Length;
+ if (dataLength == -1)
return null;
// If the resource table is invalid
@@ -462,9 +462,9 @@ namespace SabreTools.Serialization.Wrappers
/// Resource offset on success, -1 otherwise
public int GetResourceOffset(int id)
{
- // Get the end of the file, if possible
- long endOfFile = GetEndOffset();
- if (endOfFile == -1)
+ // Get the available source length, if possible
+ long dataLength = Length;
+ if (dataLength == -1)
return -1;
// If the resource table is invalid
@@ -478,7 +478,7 @@ namespace SabreTools.Serialization.Wrappers
// Verify the resource offset
int offset = resource.Offset << ResourceTable.AlignmentShiftCount;
- if (offset < 0 || offset + resource.Length >= endOfFile)
+ if (offset < 0 || offset + resource.Length >= dataLength)
return -1;
// Return the verified offset
@@ -558,9 +558,9 @@ namespace SabreTools.Serialization.Wrappers
if (Header == null)
return -1;
- // Get the end of the file, if possible
- long endOfFile = GetEndOffset();
- if (endOfFile == -1)
+ // Get the available source length, if possible
+ long dataLength = Length;
+ if (dataLength == -1)
return -1;
// Get the matching segment
@@ -570,7 +570,7 @@ namespace SabreTools.Serialization.Wrappers
// Verify the segment offset
int offset = segment.Offset << Header.SegmentAlignmentShiftCount;
- if (offset < 0 || offset + segment.Length >= endOfFile)
+ if (offset < 0 || offset + segment.Length >= dataLength)
return -1;
// Return the verified offset
@@ -596,7 +596,7 @@ namespace SabreTools.Serialization.Wrappers
// If we have an unset length, read the whole source
if (length == -1)
- length = GetEndOffset();
+ length = Length;
return ReadFromDataSource(rangeStart, (int)length);
}
diff --git a/SabreTools.Serialization/Wrappers/PortableExecutable.cs b/SabreTools.Serialization/Wrappers/PortableExecutable.cs
index 80e8594f..0c601668 100644
--- a/SabreTools.Serialization/Wrappers/PortableExecutable.cs
+++ b/SabreTools.Serialization/Wrappers/PortableExecutable.cs
@@ -207,9 +207,9 @@ namespace SabreTools.Serialization.Wrappers
if (_overlayAddress != null)
return _overlayAddress.Value;
- // Get the end of the file, if possible
- long endOfFile = GetEndOffset();
- if (endOfFile == -1)
+ // Get the available source length, if possible
+ long dataLength = Length;
+ if (dataLength == -1)
return -1;
// If the section table is missing
@@ -220,8 +220,8 @@ namespace SabreTools.Serialization.Wrappers
if (OptionalHeader?.CertificateTable != null)
{
int certificateTableAddress = (int)OptionalHeader.CertificateTable.VirtualAddress.ConvertVirtualAddress(SectionTable);
- if (certificateTableAddress != 0 && certificateTableAddress < endOfFile)
- endOfFile = certificateTableAddress;
+ if (certificateTableAddress != 0 && certificateTableAddress < dataLength)
+ dataLength = certificateTableAddress;
}
// Search through all sections and find the furthest a section goes
@@ -278,9 +278,9 @@ namespace SabreTools.Serialization.Wrappers
if (_overlayData != null)
return _overlayData;
- // Get the end of the file, if possible
- long endOfFile = GetEndOffset();
- if (endOfFile == -1)
+ // Get the available source length, if possible
+ long dataLength = Length;
+ if (dataLength == -1)
return null;
// If the section table is missing
@@ -291,8 +291,8 @@ namespace SabreTools.Serialization.Wrappers
if (OptionalHeader?.CertificateTable != null)
{
int certificateTableAddress = (int)OptionalHeader.CertificateTable.VirtualAddress.ConvertVirtualAddress(SectionTable);
- if (certificateTableAddress != 0 && certificateTableAddress < endOfFile)
- endOfFile = certificateTableAddress;
+ if (certificateTableAddress != 0 && certificateTableAddress < dataLength)
+ dataLength = certificateTableAddress;
}
// Search through all sections and find the furthest a section goes
@@ -329,14 +329,14 @@ namespace SabreTools.Serialization.Wrappers
return null;
// If we're at the end of the file, cache an empty byte array
- if (endOfSectionData >= endOfFile)
+ if (endOfSectionData >= dataLength)
{
_overlayData = [];
return _overlayData;
}
// Otherwise, cache and return the data
- long overlayLength = endOfFile - endOfSectionData;
+ long overlayLength = dataLength - endOfSectionData;
_overlayData = ReadFromDataSource(endOfSectionData, (int)overlayLength);
return _overlayData;
}
@@ -356,9 +356,9 @@ namespace SabreTools.Serialization.Wrappers
if (_overlayStrings != null)
return _overlayStrings;
- // Get the end of the file, if possible
- long endOfFile = GetEndOffset();
- if (endOfFile == -1)
+ // Get the available source length, if possible
+ long dataLength = Length;
+ if (dataLength == -1)
return null;
// If the section table is missing
@@ -369,8 +369,8 @@ namespace SabreTools.Serialization.Wrappers
if (OptionalHeader?.CertificateTable != null)
{
int certificateTableAddress = (int)OptionalHeader.CertificateTable.VirtualAddress.ConvertVirtualAddress(SectionTable);
- if (certificateTableAddress != 0 && certificateTableAddress < endOfFile)
- endOfFile = certificateTableAddress;
+ if (certificateTableAddress != 0 && certificateTableAddress < dataLength)
+ dataLength = certificateTableAddress;
}
// Search through all sections and find the furthest a section goes
@@ -407,7 +407,7 @@ namespace SabreTools.Serialization.Wrappers
return null;
// If we're at the end of the file, cache an empty list
- if (endOfSectionData >= endOfFile)
+ if (endOfSectionData >= dataLength)
{
_overlayStrings = [];
return _overlayStrings;
@@ -415,7 +415,7 @@ namespace SabreTools.Serialization.Wrappers
// TODO: Revisit the 16 MiB limit
// Cap the check for overlay strings to 16 MiB (arbitrary)
- long overlayLength = Math.Min(endOfFile - endOfSectionData, 16 * 1024 * 1024);
+ long overlayLength = Math.Min(dataLength - endOfSectionData, 16 * 1024 * 1024);
// Otherwise, cache and return the strings
_overlayStrings = ReadStringsFromDataSource(endOfSectionData, (int)overlayLength, charLimit: 3);
diff --git a/SabreTools.Serialization/Wrappers/Quantum.cs b/SabreTools.Serialization/Wrappers/Quantum.cs
index 0c23d23c..1f35015d 100644
--- a/SabreTools.Serialization/Wrappers/Quantum.cs
+++ b/SabreTools.Serialization/Wrappers/Quantum.cs
@@ -135,7 +135,7 @@ namespace SabreTools.Serialization.Wrappers
// Read the entire compressed data
int compressedDataOffset = (int)CompressedDataOffset;
- long compressedDataLength = GetEndOffset() - compressedDataOffset;
+ long compressedDataLength = Length - compressedDataOffset;
var compressedData = ReadFromDataSource(compressedDataOffset, (int)compressedDataLength);
// Print a debug reminder
diff --git a/SabreTools.Serialization/Wrappers/WrapperBaseT.cs b/SabreTools.Serialization/Wrappers/WrapperBaseT.cs
index dff4f47b..cd5e6c42 100644
--- a/SabreTools.Serialization/Wrappers/WrapperBaseT.cs
+++ b/SabreTools.Serialization/Wrappers/WrapperBaseT.cs
@@ -93,12 +93,6 @@ namespace SabreTools.Serialization.Wrappers
#region Data
- ///
- /// Get the ending offset of the source
- ///
- /// Value greater than 0 for a valid end of file, -1 on error
- public long GetEndOffset() => _dataSource.GetEndOffset();
-
///
/// Read data from the source
///