diff --git a/BurnOutSharp/ProtectionType/CDCops.cs b/BurnOutSharp/ProtectionType/CDCops.cs
index 8c67c9a4..2b7cb9cb 100644
--- a/BurnOutSharp/ProtectionType/CDCops.cs
+++ b/BurnOutSharp/ProtectionType/CDCops.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.IO;
using System.Linq;
using BurnOutSharp.Matching;
@@ -30,31 +29,33 @@ namespace BurnOutSharp.ProtectionType
///
public string CheckDirectoryPath(string path, IEnumerable files)
{
- if (files.Any(f => Path.GetFileName(f).Equals("CDCOPS.DLL", StringComparison.OrdinalIgnoreCase))
- && (files.Any(f => Path.GetExtension(f).Trim('.').Equals("GZ_", StringComparison.OrdinalIgnoreCase))
- || files.Any(f => Path.GetExtension(f).Trim('.').Equals("W_X", StringComparison.OrdinalIgnoreCase))
- || files.Any(f => Path.GetExtension(f).Trim('.').Equals("Qz", StringComparison.OrdinalIgnoreCase))
- || files.Any(f => Path.GetExtension(f).Trim('.').Equals("QZ_", StringComparison.OrdinalIgnoreCase))))
+ // TODO: Original had "CDCOPS.DLL" required and all the rest in a combined OR
+ var matchers = new List
{
- return "CD-Cops";
- }
+ new PathMatchSet(new PathMatch("CDCOPS.DLL", useEndsWith: true), "CD-Cops"),
+ new PathMatchSet(new PathMatch(".GZ_", useEndsWith: true), "CD-Cops"),
+ new PathMatchSet(new PathMatch(".W_X", useEndsWith: true), "CD-Cops"),
+ new PathMatchSet(new PathMatch(".Qz", useEndsWith: true), "CD-Cops"),
+ new PathMatchSet(new PathMatch(".QZ_", useEndsWith: true), "CD-Cops"),
+ };
- return null;
+ var matches = MatchUtil.GetAllMatches(files, matchers, any: true);
+ return string.Join(", ", matches);
}
///
public string CheckFilePath(string path)
{
- if (Path.GetFileName(path).Equals("CDCOPS.DLL", StringComparison.OrdinalIgnoreCase)
- || Path.GetExtension(path).Trim('.').Equals("GZ_", StringComparison.OrdinalIgnoreCase)
- || Path.GetExtension(path).Trim('.').Equals("W_X", StringComparison.OrdinalIgnoreCase)
- || Path.GetExtension(path).Trim('.').Equals("Qz", StringComparison.OrdinalIgnoreCase)
- || Path.GetExtension(path).Trim('.').Equals("QZ_", StringComparison.OrdinalIgnoreCase))
+ var matchers = new List
{
- return "CD-Cops";
- }
-
- return null;
+ new PathMatchSet(new PathMatch("CDCOPS.DLL", useEndsWith: true), "CD-Cops"),
+ new PathMatchSet(new PathMatch(".GZ_", useEndsWith: true), "CD-Cops"),
+ new PathMatchSet(new PathMatch(".W_X", useEndsWith: true), "CD-Cops"),
+ new PathMatchSet(new PathMatch(".Qz", useEndsWith: true), "CD-Cops"),
+ new PathMatchSet(new PathMatch(".QZ_", useEndsWith: true), "CD-Cops"),
+ };
+
+ return MatchUtil.GetFirstMatch(path, matchers, any: true);
}
public static string GetVersion(string file, byte[] fileContent, List positions)
diff --git a/BurnOutSharp/ProtectionType/CDLock.cs b/BurnOutSharp/ProtectionType/CDLock.cs
index e7c4feea..188edb60 100644
--- a/BurnOutSharp/ProtectionType/CDLock.cs
+++ b/BurnOutSharp/ProtectionType/CDLock.cs
@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
+using System.Collections.Generic;
using BurnOutSharp.Matching;
namespace BurnOutSharp.ProtectionType
@@ -29,19 +26,24 @@ namespace BurnOutSharp.ProtectionType
///
public string CheckDirectoryPath(string path, IEnumerable files)
{
- if (files.Any(f => Path.GetExtension(f).Trim('.').Equals("AFP", StringComparison.OrdinalIgnoreCase)))
- return "CD-Lock";
+ var matchers = new List
+ {
+ new PathMatchSet(new PathMatch(".AFP", useEndsWith: true), "CD-Lock"),
+ };
- return null;
+ var matches = MatchUtil.GetAllMatches(files, matchers, any: true);
+ return string.Join(", ", matches);
}
///
public string CheckFilePath(string path)
{
- if (Path.GetExtension(path).Trim('.').Equals("AFP", StringComparison.OrdinalIgnoreCase))
- return "CD-Lock";
-
- return null;
+ var matchers = new List
+ {
+ new PathMatchSet(new PathMatch(".AFP", useEndsWith: true), "CD-Lock"),
+ };
+
+ return MatchUtil.GetFirstMatch(path, matchers, any: true);
}
}
}
diff --git a/BurnOutSharp/ProtectionType/CDProtector.cs b/BurnOutSharp/ProtectionType/CDProtector.cs
index 69e78eeb..7734a077 100644
--- a/BurnOutSharp/ProtectionType/CDProtector.cs
+++ b/BurnOutSharp/ProtectionType/CDProtector.cs
@@ -1,7 +1,5 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
+using System.Collections.Generic;
+using BurnOutSharp.Matching;
namespace BurnOutSharp.ProtectionType
{
@@ -11,29 +9,30 @@ namespace BurnOutSharp.ProtectionType
public string CheckDirectoryPath(string path, IEnumerable files)
{
// TODO: Verify if these are OR or AND
- if (files.Any(f => Path.GetFileName(f).Equals("_cdp16.dat", StringComparison.OrdinalIgnoreCase))
- || files.Any(f => Path.GetFileName(f).Equals("_cdp16.dll", StringComparison.OrdinalIgnoreCase))
- || files.Any(f => Path.GetFileName(f).Equals("_cdp32.dat", StringComparison.OrdinalIgnoreCase))
- || files.Any(f => Path.GetFileName(f).Equals("_cdp32.dll", StringComparison.OrdinalIgnoreCase)))
+ var matchers = new List
{
- return "CD-Protector";
- }
+ new PathMatchSet(new PathMatch("_cdp16.dat", useEndsWith: true), "CD-Protector"),
+ new PathMatchSet(new PathMatch("_cdp16.dll", useEndsWith: true), "CD-Protector"),
+ new PathMatchSet(new PathMatch("_cdp32.dat", useEndsWith: true), "CD-Protector"),
+ new PathMatchSet(new PathMatch("_cdp32.dll", useEndsWith: true), "CD-Protector"),
+ };
- return null;
+ var matches = MatchUtil.GetAllMatches(files, matchers, any: true);
+ return string.Join(", ", matches);
}
///
public string CheckFilePath(string path)
{
- if (Path.GetFileName(path).Equals("_cdp16.dat", StringComparison.OrdinalIgnoreCase)
- || Path.GetFileName(path).Equals("_cdp16.dll", StringComparison.OrdinalIgnoreCase)
- || Path.GetFileName(path).Equals("_cdp32.dat", StringComparison.OrdinalIgnoreCase)
- || Path.GetFileName(path).Equals("_cdp32.dll", StringComparison.OrdinalIgnoreCase))
+ var matchers = new List
{
- return "CD-Protector";
- }
-
- return null;
+ new PathMatchSet(new PathMatch("_cdp16.dat", useEndsWith: true), "CD-Protector"),
+ new PathMatchSet(new PathMatch("_cdp16.dll", useEndsWith: true), "CD-Protector"),
+ new PathMatchSet(new PathMatch("_cdp32.dat", useEndsWith: true), "CD-Protector"),
+ new PathMatchSet(new PathMatch("_cdp32.dll", useEndsWith: true), "CD-Protector"),
+ };
+
+ return MatchUtil.GetFirstMatch(path, matchers, any: true);
}
}
}
diff --git a/BurnOutSharp/ProtectionType/CDX.cs b/BurnOutSharp/ProtectionType/CDX.cs
index bab33e71..41f1bc95 100644
--- a/BurnOutSharp/ProtectionType/CDX.cs
+++ b/BurnOutSharp/ProtectionType/CDX.cs
@@ -1,7 +1,5 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
+using System.Collections.Generic;
+using BurnOutSharp.Matching;
namespace BurnOutSharp.ProtectionType
{
@@ -11,27 +9,28 @@ namespace BurnOutSharp.ProtectionType
public string CheckDirectoryPath(string path, IEnumerable files)
{
// TODO: Verify if these are OR or AND
- if (files.Any(f => Path.GetFileName(f).Equals("CHKCDX16.DLL", StringComparison.OrdinalIgnoreCase))
- || files.Any(f => Path.GetFileName(f).Equals("CHKCDX32.DLL", StringComparison.OrdinalIgnoreCase))
- || files.Any(f => Path.GetFileName(f).Equals("CHKCDXNT.DLL", StringComparison.OrdinalIgnoreCase)))
+ var matchers = new List
{
- return "CD-X";
- }
+ new PathMatchSet(new PathMatch("CHKCDX16.DLL", useEndsWith: true), "CD-X"),
+ new PathMatchSet(new PathMatch("CHKCDX32.DLL", useEndsWith: true), "CD-X"),
+ new PathMatchSet(new PathMatch("CHKCDXNT.DLL", useEndsWith: true), "CD-X"),
+ };
- return null;
+ var matches = MatchUtil.GetAllMatches(files, matchers, any: true);
+ return string.Join(", ", matches);
}
///
public string CheckFilePath(string path)
{
- if (Path.GetFileName(path).Equals("CHKCDX16.DLL", StringComparison.OrdinalIgnoreCase)
- || Path.GetFileName(path).Equals("CHKCDX32.DLL", StringComparison.OrdinalIgnoreCase)
- || Path.GetFileName(path).Equals("CHKCDXNT.DLL", StringComparison.OrdinalIgnoreCase))
+ var matchers = new List
{
- return "CD-X";
- }
-
- return null;
+ new PathMatchSet(new PathMatch("CHKCDX16.DLL", useEndsWith: true), "CD-X"),
+ new PathMatchSet(new PathMatch("CHKCDX32.DLL", useEndsWith: true), "CD-X"),
+ new PathMatchSet(new PathMatch("CHKCDXNT.DLL", useEndsWith: true), "CD-X"),
+ };
+
+ return MatchUtil.GetFirstMatch(path, matchers, any: true);
}
}
}
diff --git a/BurnOutSharp/ProtectionType/CactusDataShield.cs b/BurnOutSharp/ProtectionType/CactusDataShield.cs
index 7f10e14b..fe67715c 100644
--- a/BurnOutSharp/ProtectionType/CactusDataShield.cs
+++ b/BurnOutSharp/ProtectionType/CactusDataShield.cs
@@ -30,42 +30,50 @@ namespace BurnOutSharp.ProtectionType
///
public string CheckDirectoryPath(string path, IEnumerable files)
{
- if (files.Any(f => Path.GetFileName(f).Equals("CACTUSPJ.exe", StringComparison.OrdinalIgnoreCase))
- || files.Any(f => Path.GetFileName(f).Equals("CDSPlayer.app", StringComparison.OrdinalIgnoreCase))
- || files.Any(f => Path.GetFileName(f).Equals("PJSTREAM.DLL", StringComparison.OrdinalIgnoreCase))
- || files.Any(f => Path.GetFileName(f).Equals("wmmp.exe", StringComparison.OrdinalIgnoreCase))
- || files.Any(f => Path.GetExtension(f).Trim('.').Equals("cds", StringComparison.OrdinalIgnoreCase)))
+ // TODO: Verify if these are OR or AND
+ var matchers = new List
{
- string versionPath = files.FirstOrDefault(f => Path.GetFileName(f).Equals("version.txt", StringComparison.OrdinalIgnoreCase));
- if (!string.IsNullOrWhiteSpace(versionPath))
- {
- string version = GetVersion(versionPath);
- if (!string.IsNullOrWhiteSpace(version))
- return $"Cactus Data Shield {version}";
- }
+ new PathMatchSet(new PathMatch("CACTUSPJ.exe", useEndsWith: true), GetVersion, "Cactus Data Shield"),
+ new PathMatchSet(new PathMatch("CDSPlayer.app", useEndsWith: true), GetVersion, "Cactus Data Shield"),
+ new PathMatchSet(new PathMatch("PJSTREAM.DLL", useEndsWith: true), GetVersion, "Cactus Data Shield"),
+ new PathMatchSet(new PathMatch("wmmp.exe", useEndsWith: true), GetVersion, "Cactus Data Shield"),
+ new PathMatchSet(new PathMatch(".cds", useEndsWith: true), GetVersion, "Cactus Data Shield"),
+ };
- return "Cactus Data Shield 200";
- }
-
- return null;
+ var matches = MatchUtil.GetAllMatches(files, matchers, any: true);
+ return string.Join(", ", matches);
}
///
public string CheckFilePath(string path)
{
- if (Path.GetFileName(path).Equals("CACTUSPJ.exe", StringComparison.OrdinalIgnoreCase)
- || Path.GetFileName(path).Equals("CDSPlayer.app", StringComparison.OrdinalIgnoreCase)
- || Path.GetFileName(path).Equals("PJSTREAM.DLL", StringComparison.OrdinalIgnoreCase)
- || Path.GetFileName(path).Equals("wmmp.exe", StringComparison.OrdinalIgnoreCase)
- || Path.GetExtension(path).Trim('.').Equals("cds", StringComparison.OrdinalIgnoreCase))
+ var matchers = new List
{
- return "Cactus Data Shield 200";
- }
-
- return null;
+ new PathMatchSet(new PathMatch("CACTUSPJ.exe", useEndsWith: true), "Cactus Data Shield 200"),
+ new PathMatchSet(new PathMatch("CDSPlayer.app", useEndsWith: true), "Cactus Data Shield 200"),
+ new PathMatchSet(new PathMatch("PJSTREAM.DLL", useEndsWith: true), "Cactus Data Shield 200"),
+ new PathMatchSet(new PathMatch("wmmp.exe", useEndsWith: true), "Cactus Data Shield 200"),
+ new PathMatchSet(new PathMatch(".cds", useEndsWith: true), "Cactus Data Shield 200"),
+ };
+
+ return MatchUtil.GetFirstMatch(path, matchers, any: true);
}
- private static string GetVersion(string path)
+ public static string GetVersion(string firstMatchedString, IEnumerable files)
+ {
+ // Find the version.txt file first
+ string versionPath = files.FirstOrDefault(f => Path.GetFileName(f).Equals("version.txt", StringComparison.OrdinalIgnoreCase));
+ if (!string.IsNullOrWhiteSpace(versionPath))
+ {
+ string version = GetInternalVersion(versionPath);
+ if (!string.IsNullOrWhiteSpace(version))
+ return version;
+ }
+
+ return "200";
+ }
+
+ private static string GetInternalVersion(string path)
{
if (!File.Exists(path))
return null;
diff --git a/BurnOutSharp/ProtectionType/CopyKiller.cs b/BurnOutSharp/ProtectionType/CopyKiller.cs
index 6cefa7a2..cc4e94a3 100644
--- a/BurnOutSharp/ProtectionType/CopyKiller.cs
+++ b/BurnOutSharp/ProtectionType/CopyKiller.cs
@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
+using System.Collections.Generic;
using BurnOutSharp.Matching;
namespace BurnOutSharp.ProtectionType
@@ -28,20 +25,25 @@ namespace BurnOutSharp.ProtectionType
public string CheckDirectoryPath(string path, IEnumerable files)
{
// TODO: The following checks are overly broad and should be refined
- // if (files.Any(f => Path.GetFileName(f).Equals("Autorun.dat", StringComparison.OrdinalIgnoreCase)))
- // return "CopyKiller";
+ var matchers = new List
+ {
+ //new PathMatchSet(new PathMatch("Autorun.dat", useEndsWith: true), "CopyKiller"),
+ };
- return null;
+ var matches = MatchUtil.GetAllMatches(files, matchers, any: true);
+ return string.Join(", ", matches);
}
///
public string CheckFilePath(string path)
{
// TODO: The following checks are overly broad and should be refined
- // if (Path.GetFileName(path).Equals("Autorun.dat", StringComparison.OrdinalIgnoreCase))
- // return "CopyKiller";
-
- return null;
+ var matchers = new List
+ {
+ //new PathMatchSet(new PathMatch("Autorun.dat", useEndsWith: true), "CopyKiller"),
+ };
+
+ return MatchUtil.GetFirstMatch(path, matchers, any: true);
}
}
}
diff --git a/BurnOutSharp/ProtectionType/DVDCrypt.cs b/BurnOutSharp/ProtectionType/DVDCrypt.cs
index cb1e0703..9c80ade5 100644
--- a/BurnOutSharp/ProtectionType/DVDCrypt.cs
+++ b/BurnOutSharp/ProtectionType/DVDCrypt.cs
@@ -1,7 +1,5 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
+using System.Collections.Generic;
+using BurnOutSharp.Matching;
namespace BurnOutSharp.ProtectionType
{
@@ -10,19 +8,24 @@ namespace BurnOutSharp.ProtectionType
///
public string CheckDirectoryPath(string path, IEnumerable files)
{
- if (files.Any(f => Path.GetFileName(f).Equals("DvdCrypt.pdb", StringComparison.OrdinalIgnoreCase)))
- return "DVD Crypt";
+ var matchers = new List
+ {
+ new PathMatchSet(new PathMatch("DvdCrypt.pdb", useEndsWith: true), "DVD Crypt"),
+ };
- return null;
+ var matches = MatchUtil.GetAllMatches(files, matchers, any: true);
+ return string.Join(", ", matches);
}
///
public string CheckFilePath(string path)
{
- if (Path.GetFileName(path).Equals("DvdCrypt.pdb", StringComparison.OrdinalIgnoreCase))
- return "DVD Crypt";
-
- return null;
+ var matchers = new List
+ {
+ new PathMatchSet(new PathMatch("DvdCrypt.pdb", useEndsWith: true), "DVD Crypt"),
+ };
+
+ return MatchUtil.GetFirstMatch(path, matchers, any: true);
}
}
}
diff --git a/BurnOutSharp/ProtectionType/DVDMoviePROTECT.cs b/BurnOutSharp/ProtectionType/DVDMoviePROTECT.cs
index 5ad04bad..11651210 100644
--- a/BurnOutSharp/ProtectionType/DVDMoviePROTECT.cs
+++ b/BurnOutSharp/ProtectionType/DVDMoviePROTECT.cs
@@ -4,6 +4,7 @@ using System.Linq;
namespace BurnOutSharp.ProtectionType
{
+ // TODO: Figure out how to use path check framework here
public class DVDMoviePROTECT : IPathCheck
{
///
diff --git a/BurnOutSharp/ProtectionType/DiscGuard.cs b/BurnOutSharp/ProtectionType/DiscGuard.cs
index 41a5a1a0..d0b72e4f 100644
--- a/BurnOutSharp/ProtectionType/DiscGuard.cs
+++ b/BurnOutSharp/ProtectionType/DiscGuard.cs
@@ -1,7 +1,5 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
+using System.Collections.Generic;
+using BurnOutSharp.Matching;
namespace BurnOutSharp.ProtectionType
{
@@ -10,27 +8,31 @@ namespace BurnOutSharp.ProtectionType
///
public string CheckDirectoryPath(string path, IEnumerable files)
{
- if (files.Any(f => Path.GetFileName(f).Equals("IOSLINK.VXD", StringComparison.OrdinalIgnoreCase))
- && files.Any(f => Path.GetFileName(f).Equals("IOSLINK.DLL", StringComparison.OrdinalIgnoreCase))
- && files.Any(f => Path.GetFileName(f).Equals("IOSLINK.SYS", StringComparison.OrdinalIgnoreCase)))
+ var matchers = new List
{
- return "DiscGuard";
- }
+ new PathMatchSet(new List
+ {
+ new PathMatch("IOSLINK.VXD", useEndsWith: true),
+ new PathMatch("IOSLINK.DLL", useEndsWith: true),
+ new PathMatch("IOSLINK.SYS", useEndsWith: true),
+ }, "DiscGuard"),
+ };
- return null;
+ var matches = MatchUtil.GetAllMatches(files, matchers, any: false);
+ return string.Join(", ", matches);
}
///
public string CheckFilePath(string path)
{
- if (Path.GetFileName(path).Equals("IOSLINK.VXD", StringComparison.OrdinalIgnoreCase)
- || Path.GetFileName(path).Equals("IOSLINK.DLL", StringComparison.OrdinalIgnoreCase)
- || Path.GetFileName(path).Equals("IOSLINK.SYS", StringComparison.OrdinalIgnoreCase))
+ var matchers = new List
{
- return "DiscGuard";
- }
-
- return null;
+ new PathMatchSet(new PathMatch("IOSLINK.VXD", useEndsWith: true), "DiscGuard"),
+ new PathMatchSet(new PathMatch("IOSLINK.DLL", useEndsWith: true), "DiscGuard"),
+ new PathMatchSet(new PathMatch("IOSLINK.SYS", useEndsWith: true), "DiscGuard"),
+ };
+
+ return MatchUtil.GetFirstMatch(path, matchers, any: true);
}
}
}
diff --git a/BurnOutSharp/ProtectionType/FreeLock.cs b/BurnOutSharp/ProtectionType/FreeLock.cs
index 88b96c13..906de789 100644
--- a/BurnOutSharp/ProtectionType/FreeLock.cs
+++ b/BurnOutSharp/ProtectionType/FreeLock.cs
@@ -1,7 +1,5 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
+using System.Collections.Generic;
+using BurnOutSharp.Matching;
namespace BurnOutSharp.ProtectionType
{
@@ -10,19 +8,24 @@ namespace BurnOutSharp.ProtectionType
///
public string CheckDirectoryPath(string path, IEnumerable files)
{
- if (files.Any(f => Path.GetFileName(f).Equals("FREELOCK.IMG", StringComparison.OrdinalIgnoreCase)))
- return "FreeLock";
-
- return null;
+ var matchers = new List
+ {
+ new PathMatchSet(new PathMatch("FREELOCK.IMG", useEndsWith: true), "FreeLock"),
+ };
+
+ var matches = MatchUtil.GetAllMatches(files, matchers, any: true);
+ return string.Join(", ", matches);
}
///
public string CheckFilePath(string path)
{
- if (Path.GetFileName(path).Equals("FREELOCK.IMG", StringComparison.OrdinalIgnoreCase))
- return "FreeLock";
+ var matchers = new List
+ {
+ new PathMatchSet(new PathMatch("FREELOCK.IMG", useEndsWith: true), "FreeLock"),
+ };
- return null;
+ return MatchUtil.GetFirstMatch(path, matchers, any: true);
}
}
}
diff --git a/BurnOutSharp/ProtectionType/GFWL.cs b/BurnOutSharp/ProtectionType/GFWL.cs
index a10ba311..00b0b41c 100644
--- a/BurnOutSharp/ProtectionType/GFWL.cs
+++ b/BurnOutSharp/ProtectionType/GFWL.cs
@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
+using System.Collections.Generic;
using BurnOutSharp.Matching;
namespace BurnOutSharp.ProtectionType
@@ -23,19 +20,24 @@ namespace BurnOutSharp.ProtectionType
///
public string CheckDirectoryPath(string path, IEnumerable files)
{
- if (files.Any(f => Path.GetFileName(f).Equals("XLiveRedist.msi", StringComparison.OrdinalIgnoreCase)))
- return "Games for Windows - Live";
-
- return null;
+ var matchers = new List
+ {
+ new PathMatchSet(new PathMatch("XLiveRedist.msi", useEndsWith: true), "Games for Windows - Live"),
+ };
+
+ var matches = MatchUtil.GetAllMatches(files, matchers, any: true);
+ return string.Join(", ", matches);
}
///
public string CheckFilePath(string path)
{
- if (Path.GetFileName(path).Equals("XLiveRedist.msi", StringComparison.OrdinalIgnoreCase))
- return "Games for Windows - Live";
+ var matchers = new List
+ {
+ new PathMatchSet(new PathMatch("XLiveRedist.msi", useEndsWith: true), "Games for Windows - Live"),
+ };
- return null;
+ return MatchUtil.GetFirstMatch(path, matchers, any: true);
}
}
}
diff --git a/BurnOutSharp/ProtectionType/HexalockAutoLock.cs b/BurnOutSharp/ProtectionType/HexalockAutoLock.cs
index dcf63250..22642f00 100644
--- a/BurnOutSharp/ProtectionType/HexalockAutoLock.cs
+++ b/BurnOutSharp/ProtectionType/HexalockAutoLock.cs
@@ -1,7 +1,5 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
+using System.Collections.Generic;
+using BurnOutSharp.Matching;
namespace BurnOutSharp.ProtectionType
{
@@ -11,29 +9,30 @@ namespace BurnOutSharp.ProtectionType
public string CheckDirectoryPath(string path, IEnumerable files)
{
// TODO: Verify if these are OR or AND
- if (files.Any(f => Path.GetFileName(f).Equals("Start_Here.exe", StringComparison.OrdinalIgnoreCase))
- || files.Any(f => Path.GetFileName(f).Equals("HCPSMng.exe", StringComparison.OrdinalIgnoreCase))
- || files.Any(f => Path.GetFileName(f).Equals("MFINT.DLL", StringComparison.OrdinalIgnoreCase))
- || files.Any(f => Path.GetFileName(f).Equals("MFIMP.DLL", StringComparison.OrdinalIgnoreCase)))
+ var matchers = new List
{
- return "Hexalock AutoLock";
- }
-
- return null;
+ new PathMatchSet(new PathMatch("Start_Here.exe", useEndsWith: true), "Hexalock AutoLock"),
+ new PathMatchSet(new PathMatch("HCPSMng.exe", useEndsWith: true), "Hexalock AutoLock"),
+ new PathMatchSet(new PathMatch("MFINT.DLL", useEndsWith: true), "Hexalock AutoLock"),
+ new PathMatchSet(new PathMatch("MFIMP.DLL", useEndsWith: true), "Hexalock AutoLock"),
+ };
+
+ var matches = MatchUtil.GetAllMatches(files, matchers, any: true);
+ return string.Join(", ", matches);
}
///
public string CheckFilePath(string path)
{
- if (Path.GetFileName(path).Equals("Start_Here.exe", StringComparison.OrdinalIgnoreCase)
- || Path.GetFileName(path).Equals("HCPSMng.exe", StringComparison.OrdinalIgnoreCase)
- || Path.GetFileName(path).Equals("MFINT.DLL", StringComparison.OrdinalIgnoreCase)
- || Path.GetFileName(path).Equals("MFIMP.DLL", StringComparison.OrdinalIgnoreCase))
+ var matchers = new List
{
- return "Hexalock AutoLock";
- }
+ new PathMatchSet(new PathMatch("Start_Here.exe", useEndsWith: true), "Hexalock AutoLock"),
+ new PathMatchSet(new PathMatch("HCPSMng.exe", useEndsWith: true), "Hexalock AutoLock"),
+ new PathMatchSet(new PathMatch("MFINT.DLL", useEndsWith: true), "Hexalock AutoLock"),
+ new PathMatchSet(new PathMatch("MFIMP.DLL", useEndsWith: true), "Hexalock AutoLock"),
+ };
- return null;
+ return MatchUtil.GetFirstMatch(path, matchers, any: true);
}
}
}
diff --git a/BurnOutSharp/ProtectionType/ImpulseReactor.cs b/BurnOutSharp/ProtectionType/ImpulseReactor.cs
index 5190ee24..9176e070 100644
--- a/BurnOutSharp/ProtectionType/ImpulseReactor.cs
+++ b/BurnOutSharp/ProtectionType/ImpulseReactor.cs
@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
+using System.Collections.Generic;
using BurnOutSharp.Matching;
namespace BurnOutSharp.ProtectionType
@@ -50,19 +47,24 @@ namespace BurnOutSharp.ProtectionType
///
public string CheckDirectoryPath(string path, IEnumerable files)
{
- if (files.Any(f => Path.GetFileName(f).Equals("ImpulseReactor.dll", StringComparison.OrdinalIgnoreCase)))
- return "Impulse Reactor " + Utilities.GetFileVersion(files.First(f => Path.GetFileName(f).Equals("ImpulseReactor.dll", StringComparison.OrdinalIgnoreCase)));
-
- return null;
+ var matchers = new List
+ {
+ new PathMatchSet(new PathMatch("ImpulseReactor.dll", useEndsWith: true), Utilities.GetFileVersion, "Impulse Reactor"),
+ };
+
+ var matches = MatchUtil.GetAllMatches(files, matchers, any: true);
+ return string.Join(", ", matches);
}
///
public string CheckFilePath(string path)
{
- if (Path.GetFileName(path).Equals("ImpulseReactor.dll", StringComparison.OrdinalIgnoreCase))
- return "Impulse Reactor " + Utilities.GetFileVersion(path);
+ var matchers = new List
+ {
+ new PathMatchSet(new PathMatch("ImpulseReactor.dll", useEndsWith: true), Utilities.GetFileVersion, "Impulse Reactor"),
+ };
- return null;
+ return MatchUtil.GetFirstMatch(path, matchers, any: true);
}
}
}
diff --git a/BurnOutSharp/ProtectionType/IndyVCD.cs b/BurnOutSharp/ProtectionType/IndyVCD.cs
index 4ac9cbfd..e8381736 100644
--- a/BurnOutSharp/ProtectionType/IndyVCD.cs
+++ b/BurnOutSharp/ProtectionType/IndyVCD.cs
@@ -1,7 +1,5 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
+using System.Collections.Generic;
+using BurnOutSharp.Matching;
namespace BurnOutSharp.ProtectionType
{
@@ -11,25 +9,26 @@ namespace BurnOutSharp.ProtectionType
public string CheckDirectoryPath(string path, IEnumerable files)
{
// TODO: Verify if these are OR or AND
- if (files.Any(f => Path.GetFileName(f).Equals("INDYVCD.AX", StringComparison.OrdinalIgnoreCase))
- || files.Any(f => Path.GetFileName(f).Equals("INDYMP3.idt", StringComparison.OrdinalIgnoreCase)))
+ var matchers = new List
{
- return "IndyVCD";
- }
-
- return null;
+ new PathMatchSet(new PathMatch("INDYVCD.AX", useEndsWith: true), "IndyVCD"),
+ new PathMatchSet(new PathMatch("INDYMP3.idt", useEndsWith: true), "IndyVCD"),
+ };
+
+ var matches = MatchUtil.GetAllMatches(files, matchers, any: true);
+ return string.Join(", ", matches);
}
///
public string CheckFilePath(string path)
{
- if (Path.GetFileName(path).Equals("INDYVCD.AX", StringComparison.OrdinalIgnoreCase)
- || Path.GetFileName(path).Equals("INDYMP3.idt", StringComparison.OrdinalIgnoreCase))
+ var matchers = new List
{
- return "IndyVCD";
- }
+ new PathMatchSet(new PathMatch("INDYVCD.AX", useEndsWith: true), "IndyVCD"),
+ new PathMatchSet(new PathMatch("INDYMP3.idt", useEndsWith: true), "IndyVCD"),
+ };
- return null;
+ return MatchUtil.GetFirstMatch(path, matchers, any: true);
}
}
}
diff --git a/BurnOutSharp/ProtectionType/Key2AudioXS.cs b/BurnOutSharp/ProtectionType/Key2AudioXS.cs
index ee78d511..7ef86d1f 100644
--- a/BurnOutSharp/ProtectionType/Key2AudioXS.cs
+++ b/BurnOutSharp/ProtectionType/Key2AudioXS.cs
@@ -1,7 +1,5 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
+using System.Collections.Generic;
+using BurnOutSharp.Matching;
namespace BurnOutSharp.ProtectionType
{
@@ -11,25 +9,26 @@ namespace BurnOutSharp.ProtectionType
public string CheckDirectoryPath(string path, IEnumerable files)
{
// TODO: Verify if these are OR or AND
- if (files.Any(f => Path.GetFileName(f).Equals("SDKHM.EXE", StringComparison.OrdinalIgnoreCase))
- || files.Any(f => Path.GetFileName(f).Equals("SDKHM.DLL", StringComparison.OrdinalIgnoreCase)))
+ var matchers = new List
{
- return "key2AudioXS";
- }
-
- return null;
+ new PathMatchSet(new PathMatch("SDKHM.EXE", useEndsWith: true), "key2AudioXS"),
+ new PathMatchSet(new PathMatch("SDKHM.DLL", useEndsWith: true), "key2AudioXS"),
+ };
+
+ var matches = MatchUtil.GetAllMatches(files, matchers, any: true);
+ return string.Join(", ", matches);
}
///
public string CheckFilePath(string path)
{
- if (Path.GetFileName(path).Equals("SDKHM.EXE", StringComparison.OrdinalIgnoreCase)
- || Path.GetFileName(path).Equals("SDKHM.DLL", StringComparison.OrdinalIgnoreCase))
+ var matchers = new List
{
- return "key2AudioXS";
- }
+ new PathMatchSet(new PathMatch("SDKHM.EXE", useEndsWith: true), "key2AudioXS"),
+ new PathMatchSet(new PathMatch("SDKHM.DLL", useEndsWith: true), "key2AudioXS"),
+ };
- return null;
+ return MatchUtil.GetFirstMatch(path, matchers, any: true);
}
}
}
diff --git a/BurnOutSharp/Utilities.cs b/BurnOutSharp/Utilities.cs
index 2765f3c7..5de86d92 100644
--- a/BurnOutSharp/Utilities.cs
+++ b/BurnOutSharp/Utilities.cs
@@ -244,7 +244,7 @@ namespace BurnOutSharp
}
///
- /// Wrapper for GetFileVersion for use in matching
+ /// Wrapper for GetFileVersion for use in content matching
///
/// File to check for version
/// Byte array representing the file contents
@@ -255,6 +255,17 @@ namespace BurnOutSharp
return GetFileVersion(file);
}
+ ///
+ /// Wrapper for GetFileVersion for use in path matching
+ ///
+ /// File to check for version
+ /// Full list of input paths
+ /// Version string, null on error
+ public static string GetFileVersion(string firstMatchedString, IEnumerable files)
+ {
+ return GetFileVersion(firstMatchedString);
+ }
+
///
/// Get the assembly version as determined by an embedded assembly manifest
///