2021-08-31 20:53:17 -07:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Concurrent;
|
2021-07-18 09:44:23 -07:00
|
|
|
|
using System.Collections.Generic;
|
2022-03-14 10:40:44 -07:00
|
|
|
|
using BurnOutSharp.ExecutableType.Microsoft.PE;
|
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;
|
2019-09-27 23:52:24 -07:00
|
|
|
|
|
|
|
|
|
|
namespace BurnOutSharp.ProtectionType
|
|
|
|
|
|
{
|
2022-05-01 17:23:00 -07:00
|
|
|
|
public class GFWL : IPathCheck, IPortableExecutableCheck
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
2021-08-31 20:53:17 -07:00
|
|
|
|
/// <inheritdoc/>
|
2022-05-01 17:17:15 -07:00
|
|
|
|
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
2021-08-31 20:53:17 -07:00
|
|
|
|
// 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;
|
2022-08-21 20:34:59 -07:00
|
|
|
|
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)}";
|
2022-08-21 20:34:59 -07:00
|
|
|
|
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)}";
|
2021-08-31 20:53:17 -07:00
|
|
|
|
|
|
|
|
|
|
// Get the .rdata section, if it exists
|
2021-09-11 16:47:25 -07:00
|
|
|
|
if (pex.ResourceDataSectionRaw != null)
|
2021-08-31 20:53:17 -07:00
|
|
|
|
{
|
|
|
|
|
|
var matchers = new List<ContentMatchSet>
|
2021-07-18 21:50:58 -07:00
|
|
|
|
{
|
2021-08-31 20:53:17 -07:00
|
|
|
|
// xlive.dll
|
2021-09-11 16:47:25 -07:00
|
|
|
|
new ContentMatchSet(new byte?[] { 0x78, 0x6C, 0x69, 0x76, 0x65, 0x2E, 0x64, 0x6C, 0x6C }, "Games for Windows LIVE"),
|
2021-08-31 20:53:17 -07:00
|
|
|
|
};
|
2021-07-17 23:40:16 -07:00
|
|
|
|
|
2021-09-11 16:47:25 -07:00
|
|
|
|
string match = MatchUtil.GetFirstMatch(file, pex.ResourceDataSectionRaw, matchers, includeDebug);
|
2021-08-31 20:53:17 -07:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(match))
|
|
|
|
|
|
return match;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
2019-09-27 23:52:24 -07:00
|
|
|
|
|
2021-02-26 00:32:09 -08:00
|
|
|
|
/// <inheritdoc/>
|
2021-07-18 09:44:23 -07:00
|
|
|
|
public ConcurrentQueue<string> CheckDirectoryPath(string path, IEnumerable<string> files)
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
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
|
2021-07-18 21:50:58 -07:00
|
|
|
|
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-23 13:35:12 -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
|
2021-07-18 21:50:58 -07:00
|
|
|
|
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
|
|
|
|
};
|
2019-09-27 23:52:24 -07:00
|
|
|
|
|
2021-03-22 23:02:01 -07:00
|
|
|
|
return MatchUtil.GetFirstMatch(path, matchers, any: true);
|
2019-09-27 23:52:24 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|