base vs future configurable patches, add amplitude redirect and signalr handshake patches, galvanic corrosion support,

This commit is contained in:
2025-03-22 21:20:04 -04:00
parent 400bd791db
commit e9a241d742
15 changed files with 472 additions and 152 deletions

View File

@@ -1,63 +0,0 @@
using System;
using System.Reflection;
using HarmonyLib;
namespace undead_universal_patch_il2cpp.Patches
{
[HarmonyPatch]
public class BestHTTP_Unob
{
static string TargetTypeName = "BestHTTP.HTTPManager";
static string TargetMethodName = "SendRequest";
static string Description = "Unobfuscated BestHTTP request URL rewrite patch";
static readonly Type targetType = AccessTools.TypeByName(TargetTypeName);
static readonly Type requestType = AccessTools.TypeByName("BestHTTP.HTTPRequest");
static readonly MethodInfo targetMethod = AccessTools.Method(targetType, TargetMethodName, [requestType]);
static bool Prepare()
{
if (targetType == null)
{
Plugin.Log.LogWarning($"'{Description}' disabled. The type for this patch was not found.");
return false;
}
if (targetMethod == null)
{
Plugin.Log.LogWarning($"'{Description}' disabled. The method for this patch was not found.");
return false;
}
Plugin.Log.LogInfo($"'{Description}' succeeded validation.");
return true;
}
static MethodBase TargetMethod() => targetMethod;
[HarmonyPrefix]
static bool Prefix(ref object request)
{
PropertyInfo uriProperty = AccessTools.Property(requestType, "Uri");
if (uriProperty == null)
{
Plugin.Log.LogFatal("BestHTTP_Unob failed: uriProperty was null.");
return false;
}
var uriInstance = (Il2CppSystem.Uri)uriProperty.GetValue(request, null);
if (uriInstance == null)
{
Plugin.Log.LogFatal("BestHTTP_Unob failed: uriInstance was null.");
return false;
}
if (GenericConfig.LogAllRequests.Value) Plugin.Log.LogInfo($"BestHTTP_Unob request (Before) URL: {uriInstance.ToString()}");
Il2CppSystem.Uri newUri = new(uriInstance.ToString().Contains("ns.rec.net") ? NameserverConfig.NewUrl.Value : uriInstance.ToString());
if (GenericConfig.LogAllRequests.Value) Plugin.Log.LogInfo($"BestHTTP_Unob request (After) URL: {newUri.ToString()}");
uriProperty.SetValue(request, NameserverConfig.Rewrite.Value ? newUri : uriInstance, null);
return true;
}
}
}

View File

@@ -1,63 +0,0 @@
using HarmonyLib;
using System;
using System.Reflection;
using UnityEngine;
namespace undead_universal_patch_il2cpp.Patches
{
[HarmonyPatch]
public static class HilePatch
{
public static void Patch()
{
Plugin.Log.LogInfo("Attempting hile patch");
HileManager man = GameObject.Find("/GameRoot/Startup/Core Systems/[CheatManager]").GetComponent<HileManager>();
string[] asdf = [
"GameAssembly.dll",
"UnityPlayer.dll",
"WinPixEventRuntime.dll",
"steam_api64.dll",
"steam_api.dll",
"d3d11.dll",
"d3d9.dll",
"d3d8.dll",
"ddraw.dll",
"dxgi.dll",
"winhttp.dll"
];
man.KnownDlls = asdf;
Plugin.Log.LogInfo("Hile patch successful.");
}
static string TargetTypeName = "BootSequence";
static string TargetMethodName = "set_CurrentState";
static string Description = "Add BepInEx to allowed DLLs";
static Type targetType = AccessTools.TypeByName(TargetTypeName);
static MethodInfo targetMethod = AccessTools.Method(targetType, TargetMethodName);
static bool Prepare()
{
if (targetMethod == null)
{
Plugin.Log.LogWarning($"'{Description}' disabled. The type for this patch was not found.");
return false;
}
Plugin.Log.LogInfo($"'{Description}' succeeded validation.");
return true;
}
static MethodBase TargetMethod()
{
return targetMethod;
}
static void Prefix(ref BootSequence __instance)
{
if (GenericConfig.HilePatch.Value && __instance.CurrentState == BootSequence.BootSequenceState.RECNET_CONNECTION) Patch();
}
}
}

View File

@@ -1,50 +0,0 @@
using HarmonyLib;
using Il2CppInterop.Runtime;
using System;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
namespace undead_universal_patch_il2cpp.Patches
{
[HarmonyPatch]
public class PhotonPatchEvent
{
static readonly string TargetTypeName = "RecNet.Core";
static readonly string TargetMethodName = "ConnectToRecNet";
static readonly string Description = "Photon Patch event method";
static readonly MethodInfo connectMethod = AccessTools.Method(AccessTools.TypeByName(TargetTypeName), TargetMethodName);
static bool Prepare()
{
if (connectMethod == null)
{
Plugin.Log.LogWarning($"'{Description}' disabled. The type for this patch was not found.");
return false;
}
Plugin.Log.LogInfo($"'{Description}' succeeded validation.");
return true;
}
static MethodBase TargetMethod() => connectMethod;
static void Prefix()
{
if (PhotonConfig.PatchPhotonIds.Value) Photon.Patch();
}
}
public class Photon
{
public static void Patch()
{
/*
Normally, I would be using reflection and AccessTools to create a new instance of ServerSettings and set the value of PhotonNetwork.PhotonServerSettings,
but since it was difficult and confusing with IL2CPP, I ended up just using explicit references.. every targeted game build *should* have these types anyway.
Now I'm wondering if the patch runs faster when using explicit references rather than reflection
*/
PhotonNetwork.PhotonServerSettings.AppID = PhotonConfig.AppID.Value;
PhotonNetwork.PhotonServerSettings.VoiceAppID = PhotonConfig.VoiceAppID.Value;
}
}
}

View File

@@ -1,15 +0,0 @@
using ExitGames.Client.Photon;
using HarmonyLib;
using System;
namespace undead_universal_patch_il2cpp.Patches
{
[HarmonyPatch(typeof(PhotonNetwork), nameof(PhotonNetwork.ConnectUsingSettings))]
public class RealPhotonPatchEvent
{
public static void Prefix()
{
Photon.Patch();
}
}
}

View File

@@ -1,41 +0,0 @@
using System;
using System.Reflection;
using HarmonyLib;
namespace undead_universal_patch_il2cpp.Patches
{
[HarmonyPatch]
public class TLSPatch
{
static string TargetTypeName = "Org.BouncyCastle.Crypto.Tls.LegacyTlsAuthentication";
static string TargetMethodName = "NotifyServerCertificate";
static string Description = "Certificate patch";
static Type targetType = AccessTools.TypeByName(TargetTypeName);
static MethodInfo targetMethod = AccessTools.Method(targetType, TargetMethodName);
static bool Prepare()
{
if (targetMethod == null)
{
Plugin.Log.LogWarning($"'{Description}' disabled. The type for this patch was not found.");
return false;
}
if (targetMethod == null)
{
Plugin.Log.LogWarning($"'{Description}' disabled. The method for this patch was not found.");
return false;
}
Plugin.Log.LogInfo($"'{Description}' succeeded validation.");
return true;
}
static MethodBase TargetMethod() => targetMethod;
static bool Prefix()
{
return !(GenericConfig.CertificatePatch.Value);
}
}
}