diff --git a/project/Aki.Core/AkiCorePlugin.cs b/project/Aki.Core/AkiCorePlugin.cs index a27100b..4d91738 100644 --- a/project/Aki.Core/AkiCorePlugin.cs +++ b/project/Aki.Core/AkiCorePlugin.cs @@ -21,6 +21,7 @@ namespace Aki.Core { new ConsistencySinglePatch().Enable(); new ConsistencyMultiPatch().Enable(); + new GameValidationPatch().Enable(); new BattlEyePatch().Enable(); new SslCertificatePatch().Enable(); new UnityWebRequestPatch().Enable(); diff --git a/project/Aki.Core/Models/FakeCertificateHandler.cs b/project/Aki.Core/Models/FakeCertificateHandler.cs index 2780b81..3e38a56 100644 --- a/project/Aki.Core/Models/FakeCertificateHandler.cs +++ b/project/Aki.Core/Models/FakeCertificateHandler.cs @@ -5,9 +5,6 @@ namespace Aki.Core.Models { public class FakeCertificateHandler : CertificateHandler { - protected override bool ValidateCertificate(byte[] certificateData) - { - return ValidationUtil.Validate(); - } + protected override bool ValidateCertificate(byte[] certificateData) => true; } } diff --git a/project/Aki.Core/Patches/GameValidationPatch.cs b/project/Aki.Core/Patches/GameValidationPatch.cs new file mode 100644 index 0000000..0311cb4 --- /dev/null +++ b/project/Aki.Core/Patches/GameValidationPatch.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using Aki.Common.Utils; +using Aki.Core.Utils; +using Aki.Reflection.Patching; +using HarmonyLib; + +namespace Aki.Core.Patches +{ + public class GameValidationPatch : ModulePatch + { + private const string PluginName = "Aki.Core"; + private const string ErrorMessage = "Validation failed"; + private static BepInEx.Logging.ManualLogSource _logger = null; + private static bool _hasRun = false; + + protected override MethodBase GetTargetMethod() + { + return AccessTools.Method(typeof(BattleeyePatchClass), nameof(BattleeyePatchClass.RunValidation)); + } + + [PatchPostfix] + private static void PatchPostfix() + { + if (ValidationUtil.Validate() || _hasRun) + return; + + if (_logger == null) + _logger = BepInEx.Logging.Logger.CreateLogSource(PluginName); + + _hasRun = true; + ServerLog.Warn($"Warning: {PluginName}", ErrorMessage); + _logger?.LogWarning(ErrorMessage); + } + } +} \ No newline at end of file diff --git a/project/Aki.Core/Patches/SslCertificatePatch.cs b/project/Aki.Core/Patches/SslCertificatePatch.cs index 83893f3..f2c7f5b 100644 --- a/project/Aki.Core/Patches/SslCertificatePatch.cs +++ b/project/Aki.Core/Patches/SslCertificatePatch.cs @@ -16,7 +16,7 @@ namespace Aki.Core.Patches [PatchPrefix] private static bool PatchPrefix(ref bool __result) { - __result = ValidationUtil.Validate(); + __result = true; return false; // Skip original } }