Fix build from package update

This commit is contained in:
Matt Nadareski
2023-09-10 23:26:32 -04:00
parent 96fb5a2f93
commit aeee6e9cda
5 changed files with 82 additions and 9 deletions

View File

@@ -73,13 +73,21 @@ namespace BinaryObjectScanner.Builders
#region DIFAT Sector Numbers
// Create a DIFAT sector table
#if NET48
var difatSectors = new List<SectorNumber>();
#else
var difatSectors = new List<SectorNumber?>();
#endif
// Add the sectors from the header
difatSectors.AddRange(fileHeader.DIFAT);
// Loop through and add the DIFAT sectors
SectorNumber currentSector = (SectorNumber)fileHeader.FirstDIFATSectorLocation;
#if NET48
var currentSector = (SectorNumber)fileHeader.FirstDIFATSectorLocation;
#else
var currentSector = (SectorNumber?)fileHeader.FirstDIFATSectorLocation;
#endif
for (int i = 0; i < fileHeader.NumberOfDIFATSectors; i++)
{
// If we have a readable sector
@@ -114,7 +122,11 @@ namespace BinaryObjectScanner.Builders
#region FAT Sector Numbers
// Create a FAT sector table
#if NET48
var fatSectors = new List<SectorNumber>();
#else
var fatSectors = new List<SectorNumber?>();
#endif
// Loop through and add the FAT sectors
currentSector = binary.DIFATSectorNumbers[0];
@@ -152,7 +164,11 @@ namespace BinaryObjectScanner.Builders
#region Mini FAT Sector Numbers
// Create a mini FAT sector table
#if NET48
var miniFatSectors = new List<SectorNumber>();
#else
var miniFatSectors = new List<SectorNumber?>();
#endif
// Loop through and add the mini FAT sectors
currentSector = (SectorNumber)fileHeader.FirstMiniFATSectorLocation;
@@ -296,7 +312,11 @@ namespace BinaryObjectScanner.Builders
header.NumberOfMiniFATSectors = data.ReadUInt32();
header.FirstDIFATSectorLocation = data.ReadUInt32();
header.NumberOfDIFATSectors = data.ReadUInt32();
#if NET48
header.DIFAT = new SectorNumber[109];
#else
header.DIFAT = new SectorNumber?[109];
#endif
for (int i = 0; i < header.DIFAT.Length; i++)
{
header.DIFAT[i] = (SectorNumber)data.ReadUInt32();
@@ -315,11 +335,19 @@ namespace BinaryObjectScanner.Builders
/// <param name="data">Stream to parse</param>
/// <param name="sectorShift">Sector shift from the header</param>
/// <returns>Filled sector full of sector numbers on success, null on error</returns>
#if NET48
private static SectorNumber[] ParseSectorNumbers(Stream data, ushort sectorShift)
#else
private static SectorNumber?[] ParseSectorNumbers(Stream data, ushort sectorShift)
#endif
{
// TODO: Use marshalling here instead of building
int sectorCount = (int)(Math.Pow(2, sectorShift) / sizeof(uint));
SectorNumber[] sectorNumbers = new SectorNumber[sectorCount];
#if NET48
var sectorNumbers = new SectorNumber[sectorCount];
#else
var sectorNumbers = new SectorNumber?[sectorCount];
#endif
for (int i = 0; i < sectorNumbers.Length; i++)
{

View File

@@ -1317,7 +1317,9 @@ namespace BinaryObjectScanner.Builders
// If we have not used up the full size, parse the remaining chunk as a single resource
if (data.Position - initialOffset < size)
{
Array.Resize(ref resourceDirectoryTable.Entries, totalEntryCount + 1);
var localEntries = resourceDirectoryTable.Entries;
Array.Resize(ref localEntries, totalEntryCount + 1);
resourceDirectoryTable.Entries = localEntries;
int length = (int)(size - (data.Position - initialOffset));
resourceDirectoryTable.Entries[totalEntryCount] = new ResourceDirectoryEntry

View File

@@ -11,8 +11,7 @@ namespace BinaryObjectScanner.Protection
/// <summary>
/// Engine32 is the presumed name of a specific disc check DRM. This disc check merely checks for the presence of a specifically named file on the disc.
/// The file "engine32.dll" is always present (hence the name), and is where the disc checking logic is present.
/// Engine32 appears to have been initially used in games localized by Nival and then later by Atomy.
/// There is mention of the file "engine32.dll" being present in Fritz 15 as well (https://steamcommunity.com/app/427480/discussions/0/358416640404165471), though that's likely an unrelated file with the same name.
/// <see href="https://github.com/TheRogueArchivist/DRML/blob/main/entries/engine32/engine32.md"/>
/// </summary>
public class Engine32 : IPathCheck, IPortableExecutableCheck
{

View File

@@ -70,35 +70,55 @@ namespace BinaryObjectScanner.Wrappers
public uint NumberOfDIFATSectors => _binary.Header.NumberOfDIFATSectors;
/// <inheritdoc cref="Models.CFB.FileHeader.DIFAT"/>
#if NET48
public SabreTools.Models.CFB.SectorNumber[] DIFAT => _binary.Header.DIFAT;
#else
public SabreTools.Models.CFB.SectorNumber?[] DIFAT => _binary.Header.DIFAT;
#endif
#endregion
#region FAT Sector Numbers
/// <inheritdoc cref="Models.CFB.Binary.FATSectorNumbers"/>
#if NET48
public SabreTools.Models.CFB.SectorNumber[] FATSectorNumbers => _binary.FATSectorNumbers;
#else
public SabreTools.Models.CFB.SectorNumber?[] FATSectorNumbers => _binary.FATSectorNumbers;
#endif
#endregion
#region Mini FAT Sector Numbers
/// <inheritdoc cref="Models.CFB.Binary.MiniFATSectorNumbers"/>
#if NET48
public SabreTools.Models.CFB.SectorNumber[] MiniFATSectorNumbers => _binary.MiniFATSectorNumbers;
#else
public SabreTools.Models.CFB.SectorNumber?[] MiniFATSectorNumbers => _binary.MiniFATSectorNumbers;
#endif
#endregion
#region DIFAT Sector Numbers
/// <inheritdoc cref="Models.CFB.Binary.DIFATSectorNumbers"/>
#if NET48
public SabreTools.Models.CFB.SectorNumber[] DIFATSectorNumbers => _binary.DIFATSectorNumbers;
#else
public SabreTools.Models.CFB.SectorNumber?[] DIFATSectorNumbers => _binary.DIFATSectorNumbers;
#endif
#endregion
#region Directory Entries
/// <inheritdoc cref="Models.CFB.Binary.DirectoryEntries"/>
#if NET48
public SabreTools.Models.CFB.DirectoryEntry[] DirectoryEntries => _binary.DirectoryEntries;
#else
public SabreTools.Models.CFB.DirectoryEntry?[] DirectoryEntries => _binary.DirectoryEntries;
#endif
#endregion
@@ -188,14 +208,22 @@ namespace BinaryObjectScanner.Wrappers
/// </summary>
/// <param name="startingSector">Initial FAT sector</param>
/// <returns>Ordered list of sector numbers, null on error</returns>
#if NET48
public List<SabreTools.Models.CFB.SectorNumber> GetFATSectorChain(SabreTools.Models.CFB.SectorNumber startingSector)
#else
public List<SabreTools.Models.CFB.SectorNumber?> GetFATSectorChain(SabreTools.Models.CFB.SectorNumber? startingSector)
#endif
{
// If we have an invalid sector
if (startingSector < 0 || (long)startingSector >= FATSectorNumbers.Length)
return null;
// Setup the returned list
#if NET48
var sectors = new List<SabreTools.Models.CFB.SectorNumber> { startingSector };
#else
var sectors = new List<SabreTools.Models.CFB.SectorNumber?> { startingSector };
#endif
var lastSector = startingSector;
while (true)
@@ -253,10 +281,14 @@ namespace BinaryObjectScanner.Wrappers
/// </summary>
/// <param name="sector">Sector to convert</param>
/// <returns>File offset in bytes, -1 on error</returns>
#if NET48
public long FATSectorToFileOffset(SabreTools.Models.CFB.SectorNumber sector)
#else
public long FATSectorToFileOffset(SabreTools.Models.CFB.SectorNumber? sector)
#endif
{
// If we have an invalid sector number
if (sector > SabreTools.Models.CFB.SectorNumber.MAXREGSECT)
if (sector == null || sector > SabreTools.Models.CFB.SectorNumber.MAXREGSECT)
return -1;
// Convert based on the sector shift value
@@ -272,14 +304,22 @@ namespace BinaryObjectScanner.Wrappers
/// </summary>
/// <param name="startingSector">Initial Mini FAT sector</param>
/// <returns>Ordered list of sector numbers, null on error</returns>
#if NET48
public List<SabreTools.Models.CFB.SectorNumber> GetMiniFATSectorChain(SabreTools.Models.CFB.SectorNumber startingSector)
#else
public List<SabreTools.Models.CFB.SectorNumber?> GetMiniFATSectorChain(SabreTools.Models.CFB.SectorNumber? startingSector)
#endif
{
// If we have an invalid sector
if (startingSector < 0 || (long)startingSector >= MiniFATSectorNumbers.Length)
return null;
// Setup the returned list
#if NET48
var sectors = new List<SabreTools.Models.CFB.SectorNumber> { startingSector };
#else
var sectors = new List<SabreTools.Models.CFB.SectorNumber?> { startingSector };
#endif
var lastSector = startingSector;
while (true)
@@ -337,10 +377,14 @@ namespace BinaryObjectScanner.Wrappers
/// </summary>
/// <param name="sector">Sector to convert</param>
/// <returns>File offset in bytes, -1 on error</returns>
#if NET48
public long MiniFATSectorToFileOffset(SabreTools.Models.CFB.SectorNumber sector)
#else
public long MiniFATSectorToFileOffset(SabreTools.Models.CFB.SectorNumber? sector)
#endif
{
// If we have an invalid sector number
if (sector > SabreTools.Models.CFB.SectorNumber.MAXREGSECT)
if (sector == null || sector > SabreTools.Models.CFB.SectorNumber.MAXREGSECT)
return -1;
// Convert based on the sector shift value
@@ -355,7 +399,7 @@ namespace BinaryObjectScanner.Wrappers
public override StringBuilder PrettyPrint()
{
StringBuilder builder = new StringBuilder();
builder.AppendLine("Compound File Binary Information:");
builder.AppendLine("-------------------------");
builder.AppendLine();

View File

@@ -112,7 +112,7 @@ Below is a list of protections detected by BurnOutSharp. The two columns explain
| XCP | True | True | |
| Zzxzz | False | True | |
**Notes**
### Notes
¹ - This means that I have not obtained one or more samples to ensure that either the original check from BurnOut or information found online is correct.