mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-02-04 13:45:28 +00:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7eb86b223f | ||
|
|
a4ee4529ca | ||
|
|
abc68d8503 | ||
|
|
aaff4bad1b | ||
|
|
d5c81857c3 | ||
|
|
c2594cdd2d | ||
|
|
2412042cef | ||
|
|
1f5c1a8100 | ||
|
|
78cc67f30e | ||
|
|
5b78ba5621 | ||
|
|
c4734cfc3d | ||
|
|
dd45384226 | ||
|
|
3e75d9fa3b | ||
|
|
aa690ab602 |
@@ -11,7 +11,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<Version>3.1.10</Version>
|
||||
<Version>3.1.13</Version>
|
||||
<!-- Mostly added due to external libraries -->
|
||||
<WarningsNotAsErrors>CS0162;CS0612;CS8600;CS8601;CS8602;CS8603;CS8604;CS8605;CS8618;CS8625;CS8634;CS8765;IL3000;NU5100</WarningsNotAsErrors>
|
||||
|
||||
@@ -85,11 +85,11 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SabreTools.Compression" Version="0.5.1" />
|
||||
<PackageReference Include="SabreTools.Hashing" Version="1.2.0" />
|
||||
<PackageReference Include="SabreTools.IO" Version="1.4.10" />
|
||||
<PackageReference Include="SabreTools.IO" Version="1.4.11" />
|
||||
<PackageReference Include="SabreTools.Matching" Version="1.3.1" />
|
||||
<PackageReference Include="SabreTools.Models" Version="1.4.5" />
|
||||
<PackageReference Include="SabreTools.Serialization" Version="1.6.3" />
|
||||
<PackageReference Include="UnshieldSharp" Version="1.8.2" />
|
||||
<PackageReference Include="SabreTools.Models" Version="1.4.8" />
|
||||
<PackageReference Include="SabreTools.Serialization" Version="1.6.7" />
|
||||
<PackageReference Include="UnshieldSharp" Version="1.8.3" />
|
||||
<PackageReference Include="WiseUnpacker" Version="1.4.2" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -20,10 +20,13 @@ namespace BinaryObjectScanner.Packer
|
||||
if (nex.Model.ResidentNameTable == null)
|
||||
return null;
|
||||
|
||||
// Check for the WinZip name string
|
||||
// Check for the WinZip name strings
|
||||
bool winZipNameFound = nex.Model.ResidentNameTable
|
||||
.Select(rnte => rnte?.NameString == null ? string.Empty : Encoding.ASCII.GetString(rnte.NameString))
|
||||
.Any(s => s.Contains("WZ-SE-01"));
|
||||
winZipNameFound |= nex.Model.NonResidentNameTable?
|
||||
.Select(nrnte => nrnte?.NameString == null ? string.Empty : Encoding.ASCII.GetString(nrnte.NameString))
|
||||
.Any(s => s.Contains("WinZip(R) Self-Extractor")) ?? false;
|
||||
|
||||
// If we didn't find it
|
||||
if (!winZipNameFound)
|
||||
|
||||
@@ -71,6 +71,12 @@ namespace BinaryObjectScanner.Protection
|
||||
{
|
||||
if (strs.Any(s => s.Contains("This Game is Japan Only")))
|
||||
return "Alpha-ROM";
|
||||
// Found in "Filechk.exe" in Redump entry 115358.
|
||||
if (strs.Any(s => s.Contains("AlphaCheck.exe")))
|
||||
return "Alpha-ROM";
|
||||
// Found in "Uninstall.exe" in Redump entry 115358.
|
||||
if (strs.Any(s => s.Contains("AlphaCheck.dat")))
|
||||
return "Alpha-ROM";
|
||||
}
|
||||
|
||||
// Get the overlay data, if it exists
|
||||
|
||||
@@ -72,6 +72,10 @@ namespace BinaryObjectScanner.Protection
|
||||
return "SafeDisc Lite";
|
||||
if (strs.Any(s => s.Contains("LTDLL_Unwrap")))
|
||||
return "SafeDisc Lite";
|
||||
|
||||
// Present in "Setup.exe" from the earlier "safedisc.exe" driver update provided by Macrovision.
|
||||
if (strs.Any(s => s.Contains("Failed to get the DRVMGT.DLL Setup API address")))
|
||||
return "Macrovision SecDrv Update Installer";
|
||||
}
|
||||
|
||||
var name = pex.FileDescription;
|
||||
@@ -79,14 +83,23 @@ namespace BinaryObjectScanner.Protection
|
||||
if (name?.Equals("SafeDisc SRV Tool APP", StringComparison.OrdinalIgnoreCase) == true)
|
||||
return $"SafeDisc SRV Tool APP {GetSafeDiscDiagExecutableVersion(pex)}";
|
||||
|
||||
// Present in "Setup.exe" from the later "safedisc.exe" driver update provided by Macrovision.
|
||||
if (name?.Equals("Macrovision SecDrv Update", StringComparison.OrdinalIgnoreCase) == true)
|
||||
return "Macrovision SecDrv Update Installer";
|
||||
|
||||
// Present on all "CLOKSPL.DLL" versions before SafeDisc 1.06.000. Found on Redump entries 61731 and 66004.
|
||||
name = pex.ProductName;
|
||||
if (name?.Equals("SafeDisc CDROM Protection System", StringComparison.OrdinalIgnoreCase) == true)
|
||||
return "SafeDisc 1.00.025-1.01.044";
|
||||
|
||||
// Present in "Diag.exe" files from SafeDisc 4.50.000+.
|
||||
else if (name?.Equals("SafeDisc SRV Tool APP", StringComparison.OrdinalIgnoreCase) == true)
|
||||
return $"SafeDisc SRV Tool APP {GetSafeDiscDiagExecutableVersion(pex)}";
|
||||
|
||||
// Present in "Setup.exe" from the later "safedisc.exe" driver update provided by Macrovision.
|
||||
if (name?.Equals("Macrovision SecDrv Update", StringComparison.OrdinalIgnoreCase) == true)
|
||||
return "Macrovision SecDrv Update Installer";
|
||||
|
||||
// Present on all "CLOKSPL.EXE" versions before SafeDisc 1.06.000. Found on Redump entries 61731 and 66004.
|
||||
// Only found so far on SafeDisc 1.00.025-1.01.044, but the report is currently left generic due to the generic nature of the check.
|
||||
name = pex.FileDescription;
|
||||
|
||||
@@ -52,6 +52,14 @@ namespace BinaryObjectScanner.Protection
|
||||
// return "Roxxe (Possibly remnants)";
|
||||
}
|
||||
|
||||
// If any dialog boxes match
|
||||
// Found in "Data6.OWP" in IA item "game4u-22-cd".
|
||||
if (pex.FindDialogBoxByItemTitle("SharpTiny Version 1.0").Any())
|
||||
return "Roxxe";
|
||||
// Found in "Data8.OWP" in IA item "game4u-22-cd".
|
||||
else if (pex.FindDialogBoxByItemTitle("T32xWin Version 1.0").Any())
|
||||
return "Roxxe";
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,11 +8,14 @@ using System.Linq;
|
||||
#if NET462_OR_GREATER || NETCOREAPP
|
||||
using System.Text;
|
||||
#endif
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
using System.Threading.Tasks;
|
||||
#endif
|
||||
using BinaryObjectScanner.FileType;
|
||||
using BinaryObjectScanner.Interfaces;
|
||||
using BinaryObjectScanner.Utilities;
|
||||
using SabreTools.IO.Extensions;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
using SabreTools.Serialization.Wrappers;
|
||||
using static BinaryObjectScanner.Utilities.Dictionary;
|
||||
|
||||
@@ -327,11 +330,7 @@ namespace BinaryObjectScanner
|
||||
}
|
||||
|
||||
// Get the file type either from magic number or extension
|
||||
WrapperType fileType = WrapperFactory.GetFileType(magic);
|
||||
if (fileType == WrapperType.UNKNOWN)
|
||||
fileType = WrapperFactory.GetFileType(extension);
|
||||
|
||||
// If we still got unknown, just return null
|
||||
WrapperType fileType = WrapperFactory.GetFileType(magic, extension);
|
||||
if (fileType == WrapperType.UNKNOWN)
|
||||
return null;
|
||||
|
||||
@@ -427,9 +426,18 @@ namespace BinaryObjectScanner
|
||||
#endif
|
||||
{
|
||||
// Try to create a wrapper for the proper executable type
|
||||
var wrapper = WrapperFactory.CreateExecutableWrapper(stream);
|
||||
if (wrapper == null)
|
||||
IWrapper? wrapper;
|
||||
try
|
||||
{
|
||||
wrapper = WrapperFactory.CreateExecutableWrapper(stream);
|
||||
if (wrapper == null)
|
||||
return null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (IncludeDebug) Console.WriteLine(ex);
|
||||
return null;
|
||||
}
|
||||
|
||||
// Create the output dictionary
|
||||
#if NET20 || NET35
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.IO;
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
using System.Text;
|
||||
#endif
|
||||
using BinaryObjectScanner.Utilities;
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
using OpenMcdf;
|
||||
#endif
|
||||
@@ -24,14 +23,43 @@ using UnshieldSharp.Archive;
|
||||
|
||||
namespace Test
|
||||
{
|
||||
internal static class Extractor
|
||||
internal class Extractor
|
||||
{
|
||||
#region Options
|
||||
|
||||
/// <inheritdoc cref="BinaryObjectScanner.Options.IncludeDebug"/>
|
||||
public bool IncludeDebug => _options?.IncludeDebug ?? false;
|
||||
|
||||
/// <summary>
|
||||
/// Options object for configuration
|
||||
/// </summary>
|
||||
private readonly BinaryObjectScanner.Options _options;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="includeDebug">Enable including debug information</param>
|
||||
public Extractor(bool includeDebug)
|
||||
{
|
||||
this._options = new BinaryObjectScanner.Options
|
||||
{
|
||||
IncludeDebug = includeDebug,
|
||||
};
|
||||
|
||||
#if NET462_OR_GREATER || NETCOREAPP
|
||||
// Register the codepages
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wrapper to extract data for a single path
|
||||
/// </summary>
|
||||
/// <param name="path">File or directory path</param>
|
||||
/// <param name="outputDirectory">Output directory path</param>
|
||||
public static void ExtractPath(string path, string outputDirectory)
|
||||
public void ExtractPath(string path, string outputDirectory)
|
||||
{
|
||||
Console.WriteLine($"Checking possible path: {path}");
|
||||
|
||||
@@ -56,17 +84,30 @@ namespace Test
|
||||
/// <summary>
|
||||
/// Print information for a single file, if possible
|
||||
/// </summary>
|
||||
private static void ExtractFile(string file, string outputDirectory)
|
||||
private void ExtractFile(string file, string outputDirectory)
|
||||
{
|
||||
Console.WriteLine($"Attempting to extract all files from {file}");
|
||||
using Stream stream = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
|
||||
// Read the first 8 bytes
|
||||
byte[]? magic = stream.ReadBytes(8);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
// Get the extension for certain checks
|
||||
string extension = Path.GetExtension(file).ToLower().TrimStart('.');
|
||||
|
||||
// Get the first 16 bytes for matching
|
||||
byte[] magic = new byte[16];
|
||||
try
|
||||
{
|
||||
stream.Read(magic, 0, 16);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (IncludeDebug) Console.WriteLine(ex);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the file type
|
||||
WrapperType ft = WrapperFactory.GetFileType(magic ?? []);
|
||||
WrapperType ft = WrapperFactory.GetFileType(magic, extension);
|
||||
|
||||
// Executables technically can be "extracted", but let's ignore that
|
||||
// TODO: Support executables that include other stuff
|
||||
|
||||
@@ -1,20 +1,50 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
using System.Text;
|
||||
#endif
|
||||
using SabreTools.IO.Extensions;
|
||||
using SabreTools.Serialization.Wrappers;
|
||||
using SPrinter = SabreTools.Serialization.Printer;
|
||||
|
||||
namespace Test
|
||||
{
|
||||
internal static class Printer
|
||||
internal class Printer
|
||||
{
|
||||
#region Options
|
||||
|
||||
/// <inheritdoc cref="BinaryObjectScanner.Options.IncludeDebug"/>
|
||||
public bool IncludeDebug => _options?.IncludeDebug ?? false;
|
||||
|
||||
/// <summary>
|
||||
/// Wrapper to print information for a single path
|
||||
/// Options object for configuration
|
||||
/// </summary>
|
||||
/// <param name="path">File or directory path</param>
|
||||
/// <param name="json">Enable JSON output, if supported</param>
|
||||
/// <param name="debug">Enable debug output</param>
|
||||
public static void PrintPathInfo(string path, bool json, bool debug)
|
||||
private readonly BinaryObjectScanner.Options _options;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="includeDebug">Enable including debug information</param>
|
||||
public Printer(bool includeDebug)
|
||||
{
|
||||
this._options = new BinaryObjectScanner.Options
|
||||
{
|
||||
IncludeDebug = includeDebug,
|
||||
};
|
||||
|
||||
#if NET462_OR_GREATER || NETCOREAPP
|
||||
// Register the codepages
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
#endif
|
||||
}/// <summary>
|
||||
/// Wrapper to print information for a single path
|
||||
/// </summary>
|
||||
/// <param name="path">File or directory path</param>
|
||||
/// <param name="json">Enable JSON output, if supported</param>
|
||||
/// <param name="debug">Enable debug output</param>
|
||||
public void PrintPathInfo(string path, bool json, bool debug)
|
||||
{
|
||||
Console.WriteLine($"Checking possible path: {path}");
|
||||
|
||||
@@ -39,7 +69,7 @@ namespace Test
|
||||
/// <summary>
|
||||
/// Print information for a single file, if possible
|
||||
/// </summary>
|
||||
private static void PrintFileInfo(string file, bool json, bool debug)
|
||||
private void PrintFileInfo(string file, bool json, bool debug)
|
||||
{
|
||||
Console.WriteLine($"Attempting to print info for {file}");
|
||||
|
||||
@@ -47,17 +77,25 @@ namespace Test
|
||||
{
|
||||
using Stream stream = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
|
||||
// Read the first 8 bytes
|
||||
byte[]? magic = stream.ReadBytes(8);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
// Get the extension for certain checks
|
||||
string extension = Path.GetExtension(file).ToLower().TrimStart('.');
|
||||
|
||||
// Get the first 16 bytes for matching
|
||||
byte[] magic = new byte[16];
|
||||
try
|
||||
{
|
||||
stream.Read(magic, 0, 16);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (IncludeDebug) Console.WriteLine(ex);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the file type
|
||||
WrapperType ft = WrapperFactory.GetFileType(magic ?? []);
|
||||
if (ft == WrapperType.UNKNOWN)
|
||||
{
|
||||
string extension = Path.GetExtension(file).TrimStart('.');
|
||||
ft = WrapperFactory.GetFileType(extension);
|
||||
}
|
||||
WrapperType ft = WrapperFactory.GetFileType(magic, extension);
|
||||
|
||||
// Print out the file format
|
||||
Console.WriteLine($"File format found: {ft}");
|
||||
|
||||
@@ -28,6 +28,12 @@ namespace Test
|
||||
return;
|
||||
}
|
||||
|
||||
// Create extractor for all paths
|
||||
var extractor = new Extractor(options.Debug);
|
||||
|
||||
// Create printer for all paths
|
||||
var printer = new Printer(options.Debug);
|
||||
|
||||
// Create scanner for all paths
|
||||
var scanner = new Scanner(
|
||||
options.ScanArchives,
|
||||
@@ -43,14 +49,14 @@ namespace Test
|
||||
{
|
||||
// Extraction
|
||||
if (options.EnableExtraction)
|
||||
Extractor.ExtractPath(inputPath, options.OutputPath);
|
||||
extractor.ExtractPath(inputPath, options.OutputPath);
|
||||
|
||||
// Information printing
|
||||
if (options.EnableInformation)
|
||||
#if NETFRAMEWORK
|
||||
Printer.PrintPathInfo(inputPath, false, options.Debug);
|
||||
printer.PrintPathInfo(inputPath, false, options.Debug);
|
||||
#else
|
||||
Printer.PrintPathInfo(inputPath, options.Json, options.Debug);
|
||||
printer.PrintPathInfo(inputPath, options.Json, options.Debug);
|
||||
#endif
|
||||
|
||||
// Scanning
|
||||
|
||||
@@ -28,11 +28,11 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SabreTools.Compression" Version="0.5.1" />
|
||||
<PackageReference Include="SabreTools.IO" Version="1.4.10" />
|
||||
<PackageReference Include="SabreTools.IO" Version="1.4.11" />
|
||||
<PackageReference Include="SabreTools.Matching" Version="1.3.1" />
|
||||
<PackageReference Include="SabreTools.Models" Version="1.4.5" />
|
||||
<PackageReference Include="SabreTools.Serialization" Version="1.6.3" />
|
||||
<PackageReference Include="UnshieldSharp" Version="1.8.2" />
|
||||
<PackageReference Include="SabreTools.Models" Version="1.4.8" />
|
||||
<PackageReference Include="SabreTools.Serialization" Version="1.6.7" />
|
||||
<PackageReference Include="UnshieldSharp" Version="1.8.3" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,4 +1,4 @@
|
||||
#! /bin/bash
|
||||
#!/bin/bash
|
||||
|
||||
# This batch file assumes the following:
|
||||
# - .NET 8.0 (or newer) SDK is installed and in PATH
|
||||
|
||||
Reference in New Issue
Block a user