forked from zombieb/undead-universal-patch-il2cpp
OnLogout, Steam platform auth in account creation. Not configurable to ensure server uses ticket to validate.
This commit is contained in:
@@ -16,6 +16,8 @@ public class RecNetInteractions
|
|||||||
public static List<Action> postAuthenticationActions = [];
|
public static List<Action> postAuthenticationActions = [];
|
||||||
public static List<Action> postLocalAccountActions = [];
|
public static List<Action> postLocalAccountActions = [];
|
||||||
public static List<Action> onNotificationsOpen = [];
|
public static List<Action> onNotificationsOpen = [];
|
||||||
|
public static List<Action> onLogout = [];
|
||||||
|
public static List<Action> onPlatformInitialize = [];
|
||||||
|
|
||||||
public static Il2CppSystem.Uri CreateServiceUri(Service service, string pathAndQuery)
|
public static Il2CppSystem.Uri CreateServiceUri(Service service, string pathAndQuery)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ public class Initialization
|
|||||||
UniversalPatchPlugin.Log.LogInfo("PATCH LIST END =========================");
|
UniversalPatchPlugin.Log.LogInfo("PATCH LIST END =========================");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// to be removed in a future update
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CacheChangePatchConfigs();
|
CacheChangePatchConfigs();
|
||||||
@@ -62,8 +63,9 @@ public class Initialization
|
|||||||
{
|
{
|
||||||
UniversalPatchPlugin.Log.LogInfo("Attaching game objects");
|
UniversalPatchPlugin.Log.LogInfo("Attaching game objects");
|
||||||
|
|
||||||
if (ServerPatchesConfig.CustomEmotes.Value) UniversalPatchPlugin.Instance.AddComponent<CustomEmotes>();
|
UniversalPatchPlugin.Instance.AddComponent<SteamPlatform>();
|
||||||
UniversalPatchPlugin.Instance.AddComponent<CustomPhoton>();
|
UniversalPatchPlugin.Instance.AddComponent<CustomPhoton>();
|
||||||
|
if (ServerPatchesConfig.CustomEmotes.Value) UniversalPatchPlugin.Instance.AddComponent<CustomEmotes>();
|
||||||
if (ServerPatchesConfig.CustomKnownDlls.Value) UniversalPatchPlugin.Instance.AddComponent<CustomCheatManager>();
|
if (ServerPatchesConfig.CustomKnownDlls.Value) UniversalPatchPlugin.Instance.AddComponent<CustomCheatManager>();
|
||||||
if (ServerPatchesConfig.CustomGameConfigurations.Value) UniversalPatchPlugin.Instance.AddComponent<CustomGameManager>();
|
if (ServerPatchesConfig.CustomGameConfigurations.Value) UniversalPatchPlugin.Instance.AddComponent<CustomGameManager>();
|
||||||
}
|
}
|
||||||
|
|||||||
46
Core/SteamPlatform.cs
Normal file
46
Core/SteamPlatform.cs
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
using Il2CppInterop.Runtime;
|
||||||
|
using Steamworks;
|
||||||
|
using System;
|
||||||
|
using undead_universal_patch_il2cpp.Core.Content.CustomRecNet;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace undead_universal_patch_il2cpp.Core;
|
||||||
|
|
||||||
|
public class SteamPlatform : MonoBehaviour
|
||||||
|
{
|
||||||
|
public static string AuthTicket { get; set; } = null;
|
||||||
|
|
||||||
|
void GetAuthTicket() {
|
||||||
|
SteamPlatformManager manager = PlatformManager.Instance.GetComponentInChildren<SteamPlatformManager>();
|
||||||
|
manager.GetAuthSessionTicket().Then(
|
||||||
|
DelegateSupport.ConvertDelegate<Il2CppSystem.Action<SteamPlatformManager.AuthSessionTicket>>((SteamPlatformManager.AuthSessionTicket ticket) =>
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(ticket.Error)) UniversalPatchPlugin.Log.LogError($"Could not get Steam auth ticket!: {ticket.Error}");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AuthTicket = BitConverter.ToString(ticket.Ticket).Replace("-", "").ToUpperInvariant().TrimEnd('0');
|
||||||
|
Util.ConditionalDebug($"Got new Steam auth ticket");
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
RecNetInteractions.onLogout.Add(GetAuthTicket);
|
||||||
|
RecNetInteractions.onPlatformInitialize.Add(GetAuthTicket);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Every time the user logs out of matchmaking
|
||||||
|
or when PlatformManager initializes, fetch a new ticket.
|
||||||
|
The user might be logging out to the account selection screen
|
||||||
|
where they might create a new one; a Steam auth ticket is added to
|
||||||
|
the auth params in the create request and it must be valid.
|
||||||
|
|
||||||
|
It *is* possible (though very unlikely) that the user creates a new account
|
||||||
|
before the first ticket is fetched, since the method that gets a ticket is
|
||||||
|
an IPromise.
|
||||||
|
|
||||||
|
If this way of doing things isn't the best, fix it and I'll merge
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using BestHTTP;
|
using BestHTTP;
|
||||||
|
using BestHTTP.Forms;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using undead_universal_patch_il2cpp.Core;
|
using undead_universal_patch_il2cpp.Core;
|
||||||
using undead_universal_patch_il2cpp.Core.Config;
|
using undead_universal_patch_il2cpp.Core.Config;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace undead_universal_patch_il2cpp.Patches
|
namespace undead_universal_patch_il2cpp.Patches
|
||||||
{
|
{
|
||||||
@@ -22,6 +25,8 @@ namespace undead_universal_patch_il2cpp.Patches
|
|||||||
|
|
||||||
static readonly MethodInfo getHeaderMethod = requestType?.GetMethod("GetFirstHeaderValue");
|
static readonly MethodInfo getHeaderMethod = requestType?.GetMethod("GetFirstHeaderValue");
|
||||||
static readonly MethodInfo addHeaderMethod = requestType?.GetMethod("AddHeader");
|
static readonly MethodInfo addHeaderMethod = requestType?.GetMethod("AddHeader");
|
||||||
|
static readonly MethodInfo getFormFields = requestType?.GetMethod("GetFormFields");
|
||||||
|
static readonly PropertyInfo formImplProp = requestType?.GetProperty("FormImpl");
|
||||||
static readonly PropertyInfo methodTypeProp = requestType?.GetProperty("MethodType");
|
static readonly PropertyInfo methodTypeProp = requestType?.GetProperty("MethodType");
|
||||||
static readonly PropertyInfo uriProp = requestType?.GetProperty("Uri");
|
static readonly PropertyInfo uriProp = requestType?.GetProperty("Uri");
|
||||||
static readonly PropertyInfo customCertProp = requestType?.GetProperty("CustomCertificateVerifyer");
|
static readonly PropertyInfo customCertProp = requestType?.GetProperty("CustomCertificateVerifyer");
|
||||||
@@ -30,13 +35,13 @@ namespace undead_universal_patch_il2cpp.Patches
|
|||||||
getHeaderMethod,
|
getHeaderMethod,
|
||||||
addHeaderMethod,
|
addHeaderMethod,
|
||||||
methodTypeProp,
|
methodTypeProp,
|
||||||
|
getFormFields,
|
||||||
|
formImplProp,
|
||||||
uriProp,
|
uriProp,
|
||||||
customCertProp
|
customCertProp
|
||||||
]).Success;
|
]).Success;
|
||||||
|
|
||||||
static MethodBase TargetMethod() => patchResult.Method;
|
static MethodBase TargetMethod() => patchResult.Method;
|
||||||
|
|
||||||
[HarmonyPrefix]
|
|
||||||
static void Prefix(ref object request)
|
static void Prefix(ref object request)
|
||||||
{
|
{
|
||||||
if (PatchConfig.CertificatePatch.Value) customCertProp.GetSetMethod().Invoke(request, [null]);
|
if (PatchConfig.CertificatePatch.Value) customCertProp.GetSetMethod().Invoke(request, [null]);
|
||||||
@@ -59,6 +64,16 @@ namespace undead_universal_patch_il2cpp.Patches
|
|||||||
|
|
||||||
if (newUri.Host.Contains("ns.rec.net")) newUri = new Il2CppSystem.Uri(NameserverConfig.NewUrl.Value);
|
if (newUri.Host.Contains("ns.rec.net")) newUri = new Il2CppSystem.Uri(NameserverConfig.NewUrl.Value);
|
||||||
|
|
||||||
|
bool isAccCreate = newUri.PathAndQuery.Contains("account/create");
|
||||||
|
if (isAccCreate && SteamPlatform.AuthTicket != null)
|
||||||
|
{
|
||||||
|
HTTPFormBase form = (HTTPFormBase)formImplProp.GetValue(request, null);
|
||||||
|
|
||||||
|
form.AddField("x-steam-ticket", SteamPlatform.AuthTicket);
|
||||||
|
Util.ConditionalDebug("Added Steam ticket to create request");
|
||||||
|
}
|
||||||
|
else if (isAccCreate) UniversalPatchPlugin.Log.LogError("The Steam auth ticket has not yet been fetched, account creation might fail!");
|
||||||
|
|
||||||
// Finish request changes
|
// Finish request changes
|
||||||
|
|
||||||
string afterUrl = newUri.ToString();
|
string afterUrl = newUri.ToString();
|
||||||
@@ -71,9 +86,8 @@ namespace undead_universal_patch_il2cpp.Patches
|
|||||||
$" URL After : {(beforeUrl == afterUrl ? "(unmodified)" : afterUrl)}\n" +
|
$" URL After : {(beforeUrl == afterUrl ? "(unmodified)" : afterUrl)}\n" +
|
||||||
$" Method : {method}\n" +
|
$" Method : {method}\n" +
|
||||||
$" Content-Type : {contentType ?? "(not set)"}");
|
$" Content-Type : {contentType ?? "(not set)"}");
|
||||||
else UniversalPatchPlugin.Log.LogInfo("BestHTTPProxy Request Log\n" +
|
else UniversalPatchPlugin.Log.LogInfo("BestHTTPProxy Request\n" +
|
||||||
$" Before : {beforeUrl}\n" +
|
$" {method} {afterUrl}");
|
||||||
$" After : {afterUrl}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
30
Patches/Internals/OnLogout.cs
Normal file
30
Patches/Internals/OnLogout.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using HarmonyLib;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using undead_universal_patch_il2cpp.Core;
|
||||||
|
using undead_universal_patch_il2cpp.Core.Content.CustomRecNet;
|
||||||
|
|
||||||
|
namespace undead_universal_patch_il2cpp.Patches.Internals;
|
||||||
|
|
||||||
|
[HarmonyPatch]
|
||||||
|
public static class LogoutEvent
|
||||||
|
{
|
||||||
|
static PatchTypesResult typesResult = Util.PreparePatchTypes(
|
||||||
|
"RecNet logout event patch",
|
||||||
|
"RecNet.Login",
|
||||||
|
"OnLogout"
|
||||||
|
);
|
||||||
|
|
||||||
|
static MethodBase TargetMethod() => typesResult.Method;
|
||||||
|
static bool Prepare() => typesResult.Success;
|
||||||
|
|
||||||
|
static void Postfix()
|
||||||
|
{
|
||||||
|
Util.ConditionalDebug("Running onLogout actions");
|
||||||
|
foreach (var action in RecNetInteractions.onLogout) action();
|
||||||
|
}
|
||||||
|
}
|
||||||
29
Patches/Internals/PlatformManager.cs
Normal file
29
Patches/Internals/PlatformManager.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
using HarmonyLib;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using undead_universal_patch_il2cpp.Core;
|
||||||
|
using undead_universal_patch_il2cpp.Core.Content.CustomRecNet;
|
||||||
|
|
||||||
|
namespace undead_universal_patch_il2cpp.Patches.Internals;
|
||||||
|
|
||||||
|
[HarmonyPatch]
|
||||||
|
public class SteamPlatformManagerEvent
|
||||||
|
{
|
||||||
|
static PatchTypesResult typesResult = Util.PreparePatchTypes(
|
||||||
|
"On SteamPlatformManager.Initialize",
|
||||||
|
"SteamPlatformManager",
|
||||||
|
"Initialize"
|
||||||
|
);
|
||||||
|
|
||||||
|
static MethodBase TargetMethod() => typesResult.Method;
|
||||||
|
static bool Prepare() => typesResult.Success;
|
||||||
|
|
||||||
|
static void Postfix()
|
||||||
|
{
|
||||||
|
UniversalPatchPlugin.Log.LogInfo("Running post-steam platform initialize actions");
|
||||||
|
foreach (var action in RecNetInteractions.onPlatformInitialize) action();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,19 +22,13 @@ public class AuthenticationEventPatch
|
|||||||
|
|
||||||
static MethodBase TargetMethod() => patchResult.Method;
|
static MethodBase TargetMethod() => patchResult.Method;
|
||||||
|
|
||||||
private static bool RanPostActions { get; set; } = false;
|
|
||||||
static void Postfix(ref string accessToken)
|
static void Postfix(ref string accessToken)
|
||||||
{
|
{
|
||||||
UniversalPatchPlugin.Log.LogInfo("Intercepted AccessToken");
|
UniversalPatchPlugin.Log.LogInfo("Intercepted AccessToken");
|
||||||
RecNetInteractions.AccessToken = accessToken;
|
RecNetInteractions.AccessToken = accessToken;
|
||||||
|
|
||||||
if (!RanPostActions)
|
UniversalPatchPlugin.Log.LogInfo("Running post-authentication actions");
|
||||||
{
|
foreach (var action in RecNetInteractions.postAuthenticationActions)
|
||||||
bool value = (bool)hasAccessTokenProperty.GetValue(patchResult.Type);
|
action();
|
||||||
if (value) UniversalPatchPlugin.Log.LogInfo("Running post-authentication actions");
|
|
||||||
foreach (var action in RecNetInteractions.postAuthenticationActions)
|
|
||||||
action();
|
|
||||||
}
|
|
||||||
else RanPostActions = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user