Files
BinaryObjectScanner/BurnOutSharp/ProtectionType/GFWL.cs

68 lines
2.8 KiB
C#
Raw Normal View History

using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
2022-12-08 15:16:43 -08:00
using System.Linq;
2022-05-01 17:41:50 -07:00
using BurnOutSharp.Interfaces;
2021-03-21 15:34:19 -07:00
using BurnOutSharp.Matching;
2021-08-25 15:09:42 -07:00
using BurnOutSharp.Tools;
using BurnOutSharp.Wrappers;
namespace BurnOutSharp.ProtectionType
{
2022-05-01 17:23:00 -07:00
public class GFWL : IPathCheck, IPortableExecutableCheck
{
/// <inheritdoc/>
2022-05-01 17:17:15 -07:00
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
{
// Get the sections from the executable, if possible
var sections = pex?.SectionTable;
if (sections == null)
return null;
2022-04-02 16:12:23 -07:00
string name = pex.FileDescription;
if (name?.StartsWith("Games for Windows - LIVE Zero Day Piracy Protection", StringComparison.OrdinalIgnoreCase) == true)
2022-04-01 10:16:31 -07:00
return $"Games for Windows LIVE - Zero Day Piracy Protection Module {Utilities.GetInternalVersion(pex)}";
else if (name?.StartsWith("Games for Windows", StringComparison.OrdinalIgnoreCase) == true)
2022-04-01 10:16:31 -07:00
return $"Games for Windows LIVE {Utilities.GetInternalVersion(pex)}";
2022-12-08 15:16:43 -08:00
// Get the import directory table
if (pex.ImportTable?.ImportDirectoryTable != null)
{
2022-12-08 15:16:43 -08:00
bool match = pex.ImportTable.ImportDirectoryTable.Any(idte => idte.Name == "xlive.dll");
if (match)
return "Games for Windows LIVE";
}
return null;
}
2021-02-26 00:32:09 -08:00
/// <inheritdoc/>
public ConcurrentQueue<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
2021-03-22 23:02:01 -07:00
var matchers = new List<PathMatchSet>
{
2021-07-17 21:45:37 -07:00
// Might be specifically GFWL/Gfwlivesetup.exe
new PathMatchSet(new PathMatch("Gfwlivesetup.exe", useEndsWith: true), "Games for Windows LIVE"),
new PathMatchSet(new PathMatch("xliveinstall.dll", useEndsWith: true), "Games for Windows LIVE"),
new PathMatchSet(new PathMatch("XLiveRedist.msi", useEndsWith: true), "Games for Windows LIVE"),
2021-03-22 23:02:01 -07:00
};
return MatchUtil.GetAllMatches(files, matchers, any: true);
2021-03-19 15:41:49 -07:00
}
/// <inheritdoc/>
public string CheckFilePath(string path)
{
2021-03-22 23:02:01 -07:00
var matchers = new List<PathMatchSet>
{
2021-07-17 21:45:37 -07:00
// Might be specifically GFWL/Gfwlivesetup.exe
new PathMatchSet(new PathMatch("Gfwlivesetup.exe", useEndsWith: true), "Games for Windows LIVE"),
new PathMatchSet(new PathMatch("xliveinstall.dll", useEndsWith: true), "Games for Windows LIVE"),
new PathMatchSet(new PathMatch("XLiveRedist.msi", useEndsWith: true), "Games for Windows LIVE"),
2021-03-22 23:02:01 -07:00
};
2021-03-22 23:02:01 -07:00
return MatchUtil.GetFirstMatch(path, matchers, any: true);
}
}
}