Skip to content

Commit

Permalink
Use SabreTools.Hashing
Browse files Browse the repository at this point in the history
  • Loading branch information
mnadareski committed Mar 5, 2024
1 parent 3f52c24 commit 1d3bd2f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 61 deletions.
1 change: 1 addition & 0 deletions BinaryObjectScanner/BinaryObjectScanner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@

<ItemGroup>
<PackageReference Include="SabreTools.Compression" Version="0.3.0" />
<PackageReference Include="SabreTools.Hashing" Version="1.1.2" />
<PackageReference Include="SabreTools.IO" Version="1.3.0" />
<PackageReference Include="SabreTools.Matching" Version="1.3.0" />
<PackageReference Include="SabreTools.Models" Version="1.3.0" />
Expand Down
4 changes: 2 additions & 2 deletions BinaryObjectScanner/Protection/Macrovision.RipGuard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#endif
using System.Collections.Generic;
using System.IO;
using SabreTools.Hashing;
using SabreTools.Matching;
using SabreTools.Serialization.Wrappers;
using static BinaryObjectScanner.Utilities.Hashing;

namespace BinaryObjectScanner.Protection
{
Expand Down Expand Up @@ -47,7 +47,7 @@ public partial class Macrovision
// So far, every seemingly-randomly named EXE on RipGuard discs have a consistent hash.
if (fi.Length == 49_152)
{
var sha1 = GetFileSHA1(file);
var sha1 = HashTool.GetFileHash(file, HashType.SHA1);
if (sha1 == "6A7B8545800E0AB252773A8CD0A2185CA2497938")
return "RipGuard";
}
Expand Down
12 changes: 6 additions & 6 deletions BinaryObjectScanner/Protection/Macrovision.SafeDisc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using SabreTools.Hashing;
using SabreTools.Matching;
using SabreTools.Serialization.Wrappers;
using static BinaryObjectScanner.Utilities.Hashing;

namespace BinaryObjectScanner.Protection
{
Expand Down Expand Up @@ -363,7 +363,7 @@ internal static string GetSafeDiscCLCD16Version(string firstMatchedString, IEnum
return string.Empty;

// The hash of the file CLCD16.dll is able to provide a broad version range that appears to be consistent, but it seems it was rarely updated so these checks are quite broad.
var sha1 = GetFileSHA1(firstMatchedString);
var sha1 = HashTool.GetFileHash(firstMatchedString, HashType.SHA1);
return sha1 switch
{
// Found in Redump entries 61731 and 66005.
Expand All @@ -386,7 +386,7 @@ internal static string GetSafeDiscCLCD32Version(string firstMatchedString, IEnum
return string.Empty;

// The hash of the file CLCD32.dll so far appears to be a solid indicator of version for versions it was used with. It appears to have been updated with every release, unlike its counterpart, CLCD16.dll.
var sha1 = GetFileSHA1(firstMatchedString);
var sha1 = HashTool.GetFileHash(firstMatchedString, HashType.SHA1);
return sha1 switch
{
// Found in Redump entry 66005.
Expand Down Expand Up @@ -485,7 +485,7 @@ internal static string GetSafeDiscCLOKSPLVersion(string firstMatchedString, IEnu


// The hash of every "CLOKSPL.EXE" correlates directly to a specific SafeDisc version.
var sha1 = GetFileSHA1(firstMatchedString);
var sha1 = HashTool.GetFileHash(firstMatchedString, HashType.SHA1);
return sha1 switch
{
// Found in Redump entry 66005.
Expand Down Expand Up @@ -632,7 +632,7 @@ internal static string GetSafeDiscDrvmgtVersion(string firstMatchedString, IEnum
// There are occasionaly inconsistencies, even within the well detected version range. This seems to me to mostly happen with later (3.20+) games, and seems to me to be an example of the SafeDisc distribution becoming more disorganized with time.
// Particularly interesting inconsistencies will be noted below:
// Redump entry 73786 has an EXE with a scrubbed version, a DIAG.exe with a version of 4.60.000, and a copy of drvmgt.dll belonging to version 3.10.020. This seems like an accidental(?) distribution of older drivers, as this game was released 3 years after the use of 3.10.020.
var sha1 = GetFileSHA1(firstMatchedString);
var sha1 = HashTool.GetFileHash(firstMatchedString, HashType.SHA1);
return sha1 switch
{
// Found in Redump entry 102979.
Expand Down Expand Up @@ -780,7 +780,7 @@ internal static string GetSafeDiscDrvmgtVersion(string firstMatchedString, IEnum
if (string.IsNullOrEmpty(firstMatchedString) || !File.Exists(firstMatchedString))
return string.Empty;

var sha1 = GetFileSHA1(firstMatchedString);
var sha1 = HashTool.GetFileHash(firstMatchedString, HashType.SHA1);
switch (sha1)
{
// Found in Redump entry 63488.
Expand Down
53 changes: 0 additions & 53 deletions BinaryObjectScanner/Utilities/Hashing.cs

This file was deleted.

0 comments on commit 1d3bd2f

Please sign in to comment.