From a84182e220410ae758bd59abbba6655c37cbcf01 Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Sat, 17 Aug 2019 17:17:05 -0500 Subject: [PATCH] Added basic anti-piracy checks --- IPA.Injector/AntiPiracy.cs | 28 ++++++++++++++++++++++++++++ IPA.Injector/GameVersionEarly.cs | 2 +- IPA.Injector/IPA.Injector.csproj | 11 ++++++----- IPA.Injector/Injector.cs | 7 +++++++ 4 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 IPA.Injector/AntiPiracy.cs diff --git a/IPA.Injector/AntiPiracy.cs b/IPA.Injector/AntiPiracy.cs new file mode 100644 index 00000000..dfb94024 --- /dev/null +++ b/IPA.Injector/AntiPiracy.cs @@ -0,0 +1,28 @@ +using System; +using System.IO; +using IPA.Utilities; +#if NET3 +using Net3_Proxy; +using Path = Net3_Proxy.Path; +using File = Net3_Proxy.File; +using Directory = Net3_Proxy.Directory; +#endif + +namespace IPA.Injector +{ + internal class AntiPiracy + { + public static bool IsInvalid(string path) + { + var dataPlugins = Path.Combine(GameVersionEarly.ResolveDataPath(path), "Plugins"); + + return + File.Exists(Path.Combine(path, "IGG-GAMES.COM.url")) || + File.Exists(Path.Combine(path, "SmartSteamEmu.ini")) || + File.Exists(Path.Combine(path, "GAMESTORRENT.CO.url")) || + File.Exists(Path.Combine(dataPlugins, "BSteam crack.dll")) || + File.Exists(Path.Combine(dataPlugins, "HUHUVR_steam_api64.dll")) || + Directory.GetFiles(BeatSaber.PluginsPath, "*.ini", SearchOption.TopDirectoryOnly).Length > 0; + } + } +} diff --git a/IPA.Injector/GameVersionEarly.cs b/IPA.Injector/GameVersionEarly.cs index ece652f7..78de36c9 100644 --- a/IPA.Injector/GameVersionEarly.cs +++ b/IPA.Injector/GameVersionEarly.cs @@ -14,7 +14,7 @@ namespace IPA.Injector { internal static class GameVersionEarly { - private static string ResolveDataPath(string installDir) => + internal static string ResolveDataPath(string installDir) => Path.Combine(Directory.EnumerateDirectories(installDir, "*_Data").First(), "globalgamemanagers"); internal static string GetGameVersion() diff --git a/IPA.Injector/IPA.Injector.csproj b/IPA.Injector/IPA.Injector.csproj index eeda835b..bd4a6719 100644 --- a/IPA.Injector/IPA.Injector.csproj +++ b/IPA.Injector/IPA.Injector.csproj @@ -13,10 +13,10 @@ true $(SolutionDir)=C:\ portable - false true net461;net35 + true true @@ -60,6 +60,7 @@ + @@ -75,12 +76,12 @@ {5ad344f0-01a0-4ca8-92e5-9d095737744d} IPA.Loader - + {642F52DA-90F9-40E3-8784-6964F36752FB} Net3-Proxy - + Libraries\Mono\I18N.dll Always @@ -89,7 +90,7 @@ Libraries\Mono\I18N.West.dll Always - + Libraries\Mono\Microsoft.CSharp.dll Always @@ -98,7 +99,7 @@ Always - + Libraries\Mono\I18N.dll Always diff --git a/IPA.Injector/Injector.cs b/IPA.Injector/Injector.cs index f8f05623..106d2418 100644 --- a/IPA.Injector/Injector.cs +++ b/IPA.Injector/Injector.cs @@ -76,6 +76,13 @@ namespace IPA.Injector SelfConfig.ReadCommandLine(Environment.GetCommandLineArgs()); DisabledConfig.Load(); + if (AntiPiracy.IsInvalid(Environment.CurrentDirectory)) + { + loader.Error("Invalid installation; please buy the game to run BSIPA."); + + return; + } + loader.Debug("Prepping bootstrapper"); // updates backup