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

93
BasePatches/BestHTTP.cs Normal file
View File

@@ -0,0 +1,93 @@
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 void Prefix(ref object request)
{
PropertyInfo uriProperty = AccessTools.Property(requestType, "Uri");
if (uriProperty == null)
{
Plugin.Log.LogFatal("BestHTTP_Unob failed: uriProperty was null.");
return;
}
var uriInstance = (Il2CppSystem.Uri)uriProperty.GetValue(request, null);
if (uriInstance == null)
{
Plugin.Log.LogFatal("BestHTTP_Unob failed: uriInstance was null.");
return;
}
if (GenericConfig.LogAllRequests.Value) Plugin.Log.LogInfo($"BestHTTP_Unob request b-URL: {uriInstance.ToString()}");
if (!NameserverConfig.Rewrite.Value) return;
Il2CppSystem.Uri newUri = new(uriInstance.ToString());
// Request changes below
if (newUri.ToString().Contains("ns.rec.net")) newUri = new Il2CppSystem.Uri(NameserverConfig.NewUrl.Value);
if (newUri.ToString().Contains("api.amplitude"))
{
Il2CppSystem.UriBuilder replaceUri = new(new Il2CppSystem.Uri(NameserverConfig.NewUrl.Value));
replaceUri.Path = "/amplitude";
newUri = replaceUri.Uri;
}
if (GalvanicConfig.Enabled.Value)
{
string[] applyHeader = [
"authservice/cachedlogin/forplatformid",
"accountservice/account/create",
"authservice/connect/token"
];
foreach (string header in applyHeader)
{
if (newUri.PathAndQuery.Contains(header))
{
Type httpRequestType = request.GetType();
MethodInfo addHeaderMethod = httpRequestType.GetMethod("AddHeader");
addHeaderMethod.Invoke(request, ["GalvanicAuth", GalvanicWebAuth.Token]);
break;
}
}
}
if (GenericConfig.LogAllRequests.Value) Plugin.Log.LogInfo($"BestHTTP_Unob request a-URL: {newUri.ToString()}");
uriProperty.SetValue(request, NameserverConfig.Rewrite.Value ? newUri : uriInstance, null);
}
}
}

View File

@@ -0,0 +1,21 @@
using HarmonyLib;
using System.Reflection;
namespace undead_universal_patch_il2cpp.Patches
{
[HarmonyPatch]
class GenuinePatch
{
static readonly MethodInfo methodType = AccessTools.Method(AccessTools.TypeByName("Application"), "get_productName");
static bool Prepare()
{
if (methodType == null) return false;
else return true;
}
static MethodBase TargetMethod() => methodType;
static void Prefix(ref string __result)
{
__result = string.Format("{0} (Custom Server)", __result);
}
}
}

34
BasePatches/HilePatch.cs Normal file
View File

@@ -0,0 +1,34 @@
using System.Collections.Generic;
using System.Reflection;
using HarmonyLib;
using Il2CppSystem;
using UnityEngine;
namespace undead_universal_patch_il2cpp.Patches
{
public static class HilePatch
{
public static void Patch()
{
GameObject cheatManagerObject = GameObject.Find("[CheatManager]");
HileManager hileManager = cheatManagerObject.GetComponent<HileManager>();
PropertyInfo knownDllsProperty = AccessTools.Property(typeof(HileManager), "KnownDlls");
knownDllsProperty.SetValue(hileManager, new Il2CppInterop.Runtime.InteropTypes.Arrays.Il2CppStringArray([
"GameAssembly.dll",
"UnityPlayer.dll",
"WinPixEventRuntime.dll",
"steam_api64.dll",
"steam_api.dll",
"d3d11.dll",
"d3d9.dll",
"d3d8.dll",
"ddraw.dll",
"dxgi.dll",
"winhttp.dll"
]));
Plugin.Log.LogInfo("Hile patch succeeded.");
}
}
}

View File

@@ -0,0 +1,61 @@
using HarmonyLib;
using System;
using System.ComponentModel;
using System.Reflection;
namespace undead_universal_patch_il2cpp.Patches
{
[HarmonyPatch]
public class ConnectToRecNetPatchEvent
{
static readonly string TargetTypeName = "RecNet.Core";
static readonly string TargetMethodName = "ConnectToRecNet";
static readonly string Description = "Photon/Hile Patch event method"; // It's convenient. Could patch at a different time. But this part was easy.
static readonly MethodInfo connectMethod = AccessTools.Method(AccessTools.TypeByName(TargetTypeName), TargetMethodName);
static bool Prepare()
{
if (connectMethod == 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() => connectMethod;
static void Prefix()
{
if (PhotonConfig.PatchPhotonIds.Value) PhotonPatch.Patch();
if (GenericConfig.HilePatch.Value) HilePatch.Patch();
}
}
public class PhotonPatch
{
public static void Patch()
{
Type photonNetworkType = AccessTools.TypeByName("PhotonNetwork");
Type serverSettingsType = AccessTools.TypeByName("ServerSettings");
if (photonNetworkType == null || serverSettingsType == null)
{
Plugin.Log.LogError("Cannot patch Photon: PhotonNetwork or ServerSettings types were not found. Is this build supported?");
return;
}
// The property PhotonServerSettings (which should be a field) didn't appear when I didn't specify `Runtime`. Not sure why. But this works.
PropertyInfo photonServerSettingsProperty = photonNetworkType.GetRuntimeProperty("PhotonServerSettings");
object serverSettings = photonServerSettingsProperty.GetValue(serverSettingsType);
PropertyInfo appIdField = serverSettingsType.GetRuntimeProperty("AppID");
PropertyInfo voiceAppIdField = serverSettingsType.GetRuntimeProperty("VoiceAppID");
appIdField.SetValue(serverSettings, PhotonConfig.AppID.Value);
voiceAppIdField.SetValue(serverSettings, PhotonConfig.VoiceAppID.Value);
Plugin.Log.LogInfo("Photon patch succeeded.");
}
}
}

View File

@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using HarmonyLib;
namespace undead_universal_patch_il2cpp.Patches
{
[HarmonyPatch]
public class SignalRHandshakeFix
{
public static string TargetTypeName = "JsonProtocol";
public static string TargetMethodName = "WithSeparator";
public static string Description = "SignalR Handshake Fix (quotes vs apostrophes)";
public static Type targetType = AccessTools.TypeByName(TargetTypeName);
public static MethodBase targetMethod = AccessTools.Method(targetType, TargetMethodName);
public 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;
}
public static MethodBase TargetMethod() => targetMethod;
public static void Prefix(ref string str)
{
if (str.Contains("protocol':"))
{
str = str.Replace("'", "\"");
}
}
}
}

41
BasePatches/TLS.cs Normal file
View File

@@ -0,0 +1,41 @@
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);
}
}
}