Skip to content

Commit 3b3cb7a

Browse files
committed
Case-insensitive hash comparisons
1 parent 810d20d commit 3b3cb7a

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

BinaryObjectScanner/Protection/Macrovision.RipGuard.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public partial class Macrovision
4848
if (fi.Length == 49_152)
4949
{
5050
var sha1 = HashTool.GetFileHash(file, HashType.SHA1);
51-
if (sha1 == "6A7B8545800E0AB252773A8CD0A2185CA2497938")
51+
if (string.Equals(sha1, "6A7B8545800E0AB252773A8CD0A2185CA2497938", StringComparison.OrdinalIgnoreCase))
5252
return "RipGuard";
5353
}
5454
}

BinaryObjectScanner/Protection/Macrovision.SafeDisc.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ internal static string GetSafeDiscCLCD16Version(string firstMatchedString, IEnum
364364

365365
// 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.
366366
var sha1 = HashTool.GetFileHash(firstMatchedString, HashType.SHA1);
367-
return sha1 switch
367+
return sha1?.ToUpperInvariant() switch
368368
{
369369
// Found in Redump entries 61731 and 66005.
370370
"C13493AB753891B8BEE9E4E014896B026C01AC92" => "1.00.025-1.01.044",
@@ -387,7 +387,7 @@ internal static string GetSafeDiscCLCD32Version(string firstMatchedString, IEnum
387387

388388
// 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.
389389
var sha1 = HashTool.GetFileHash(firstMatchedString, HashType.SHA1);
390-
return sha1 switch
390+
return sha1?.ToUpperInvariant() switch
391391
{
392392
// Found in Redump entry 66005.
393393
"BAD49BA0DEA041E85EF1CABAA9F0ECD822CE1376" => "1.00.025",
@@ -486,7 +486,7 @@ internal static string GetSafeDiscCLOKSPLVersion(string firstMatchedString, IEnu
486486

487487
// The hash of every "CLOKSPL.EXE" correlates directly to a specific SafeDisc version.
488488
var sha1 = HashTool.GetFileHash(firstMatchedString, HashType.SHA1);
489-
return sha1 switch
489+
return sha1?.ToUpperInvariant() switch
490490
{
491491
// Found in Redump entry 66005.
492492
"DD131A7B988065764E2A0F20B66C89049B20A7DE" => "1.00.025",
@@ -633,7 +633,7 @@ internal static string GetSafeDiscDrvmgtVersion(string firstMatchedString, IEnum
633633
// Particularly interesting inconsistencies will be noted below:
634634
// 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.
635635
var sha1 = HashTool.GetFileHash(firstMatchedString, HashType.SHA1);
636-
return sha1 switch
636+
return sha1?.ToUpperInvariant() switch
637637
{
638638
// Found in Redump entry 102979.
639639
"B858CB282617FB0956D960215C8E84D1CCF909C6" => "(Empty File)",
@@ -781,7 +781,7 @@ internal static string GetSafeDiscDrvmgtVersion(string firstMatchedString, IEnum
781781
return string.Empty;
782782

783783
var sha1 = HashTool.GetFileHash(firstMatchedString, HashType.SHA1);
784-
switch (sha1)
784+
switch (sha1?.ToUpperInvariant())
785785
{
786786
// Found in Redump entry 63488.
787787
case "DA39A3EE5E6B4B0D3255BFEF95601890AFD80709":

0 commit comments

Comments
 (0)