Browse Source

Added piracy check and warning

piracy-check
Anairkoen Schno 6 years ago
parent
commit
f5fdba3e25
2 changed files with 88 additions and 1 deletions
  1. +12
    -1
      IPA.Injector/Injector.cs
  2. +76
    -0
      IPA.Loader/Utilities/AntiPiracy.cs

+ 12
- 1
IPA.Injector/Injector.cs View File

@ -38,8 +38,11 @@ namespace IPA.Injector
loader.Debug("Prepping bootstrapper"); loader.Debug("Prepping bootstrapper");
// // This will load Mono.Cecil
// This will load Mono.Cecil
InstallBootstrapPatch(); InstallBootstrapPatch();
// loads Assembly-CSharp-firstpass
PiracyChecks();
} }
catch (Exception e) catch (Exception e)
{ {
@ -143,6 +146,14 @@ namespace IPA.Injector
#endregion #endregion
} }
private static void PiracyChecks()
{
if (Utilities.AntiPiracy.PiracyChecks.IsPirated)
{
log.Critical("You are using a pirated copy of the game! You will not recieve support for any mods.");
}
}
private static bool bootstrapped = false; private static bool bootstrapped = false;
private static void CreateBootstrapper() private static void CreateBootstrapper()
{ {


+ 76
- 0
IPA.Loader/Utilities/AntiPiracy.cs View File

@ -0,0 +1,76 @@
using System;
using System.IO;
using UnityEngine;
using Steamworks;
namespace IPA.Utilities.AntiPiracy
{
/// <summary>
/// Provides checks for whether or not the game is pirated.
/// </summary>
public static class PiracyChecks
{
/// <summary>
/// Runs through a list of checks to detect whether a game is pirated
/// </summary>
/// <returns></returns>
public static bool IsPirated
{
get
{
// Check for spoofed Steam Client
if (BeatSaber.ReleaseType == BeatSaber.Release.Steam && IsSpoofedSteam())
return true;
// Check for the presence of known pirated files
if (HasKnownFiles())
return true;
// If we get here, probably not a pirate
return false;
}
}
/// <summary>
/// Check common Steam Emulator values for red flags
/// </summary>
/// <returns></returns>
static bool IsSpoofedSteam()
{
// Always resolves to "IGGGAMES"
string userName = SteamFriends.GetFriendPersonaName(SteamUser.GetSteamID());
// Always resolves to "SteamFriends"
string friendName = SteamFriends.GetFriendPersonaName(new CSteamID(76561198042581607));
// Return if they both resolve to known spoofed values
return userName == "IGGGAMES" && friendName == "SteamFriends";
}
/// <summary>
/// Check for files that are present in pirated copies
/// </summary>
/// <returns></returns>
static bool HasKnownFiles()
{
// All known files
string[] paths = new string[]
{
Path.Combine(Application.dataPath, "Plugins", "valve.ini"),
Path.Combine(Application.dataPath, "Plugins", "steam.ini"),
Path.Combine(Application.dataPath, "Plugins", "huhuvr.ini"),
Path.GetFullPath(Path.Combine(Application.dataPath, "..", "SmartSteamEmu.ini")),
};
// Check for the existence of each file
foreach (string path in paths)
{
// If one is found, probably pirated
if (File.Exists(path))
return true;
}
return false;
}
}
}

Loading…
Cancel
Save