Add better detection for XCP2

This commit is contained in:
Matt Nadareski
2020-10-26 20:34:47 -07:00
parent 9143e4c02c
commit 43cbafc0f5
2 changed files with 325 additions and 4 deletions

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using BurnOutSharp.FileType;
namespace BurnOutSharp.ProtectionType
{
@@ -11,9 +12,14 @@ namespace BurnOutSharp.ProtectionType
{
if (isDirectory)
{
// INI-like file that can be parsed out
string xcpDatPath = files.FirstOrDefault(f => Path.GetFileName(f).Equals("VERSION.DAT", StringComparison.OrdinalIgnoreCase))
?? files.FirstOrDefault(f => Path.GetFileName(f).Equals("XCP.DAT", StringComparison.OrdinalIgnoreCase));
if (!string.IsNullOrWhiteSpace(xcpDatPath))
return GetXCPVersion(xcpDatPath);
// TODO: Verify if these are OR or AND
if (files.Any(f => Path.GetFileName(f).Equals("XCP.DAT", StringComparison.OrdinalIgnoreCase))
|| files.Any(f => Path.GetFileName(f).Equals("ECDPlayerControl.ocx", StringComparison.OrdinalIgnoreCase))
if (files.Any(f => Path.GetFileName(f).Equals("ECDPlayerControl.ocx", StringComparison.OrdinalIgnoreCase))
|| files.Any(f => Path.GetFileName(f).Equals("go.exe", StringComparison.OrdinalIgnoreCase))) // Path.Combine("contents", "go.exe")
{
return "XCP";
@@ -21,8 +27,14 @@ namespace BurnOutSharp.ProtectionType
}
else
{
if (Path.GetFileName(path).Equals("XCP.DAT", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("ECDPlayerControl.ocx", StringComparison.OrdinalIgnoreCase)
// INI-like file that can be parsed out
if (Path.GetFileName(path).Equals("VERSION.DAT", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("XCP.DAT", StringComparison.OrdinalIgnoreCase))
{
return GetXCPVersion(path);
}
if (Path.GetFileName(path).Equals("ECDPlayerControl.ocx", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("go.exe", StringComparison.OrdinalIgnoreCase))
{
return "XCP";
@@ -31,5 +43,18 @@ namespace BurnOutSharp.ProtectionType
return null;
}
private static string GetXCPVersion(string path)
{
try
{
var xcpIni = new IniFile(path);
return xcpIni["XCP.VERSION"];
}
catch
{
return null;
}
}
}
}