using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Steamworks;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("WesleyDebug")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("KG")]
[assembly: AssemblyProduct("WesleyDebug")]
[assembly: AssemblyCopyright("Copyright © KG 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("2F8C87A8-BA02-40F6-B236-E17789732893")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace WesleyDebug;
[BepInPlugin("kg.wesleydebug", "WesleyDebug", "1.2.0")]
public class WesleyDebug : BaseUnityPlugin
{
[HarmonyPatch(typeof(ZSteamSocket), "SendQueuedPackages")]
private static class ZSteamSocket_SendQueuedPackages_Patch
{
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> code)
{
MethodInfo targetInstruction = AccessTools.Method(typeof(ZLog), "Log", (Type[])null, (Type[])null);
foreach (CodeInstruction codeInstruction in code)
{
yield return codeInstruction;
if (codeInstruction.opcode == OpCodes.Call && targetInstruction == codeInstruction.operand)
{
yield return new CodeInstruction(OpCodes.Ldloc_0, (object)null);
yield return new CodeInstruction(OpCodes.Ldloc_3, (object)null);
yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(WesleyDebug), "ProcessBrokenPacket", (Type[])null, (Type[])null));
}
}
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
private static class ZRpc_Awake_Patch
{
private static void Postfix()
{
ZRpc.m_DEBUG = true;
}
}
private static readonly ManualLogSource Logger = Logger.CreateLogSource("WesleyDebug");
private void Awake()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
new Harmony("kg.wesleydebug").PatchAll();
}
private static void ProcessBrokenPacket(byte[] array, EResult result)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Invalid comparison between Unknown and I4
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
if ((int)result == 25 || (int)result == 8)
{
ZPackage val = new ZPackage(array);
if (val.ReadInt() != 0)
{
string arg = val.ReadString();
Logger.LogInfo((object)$"Broken Packet Detected! Method: {arg}, Size: {array.Length} bytes");
}
}
}
}