using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
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 HDeMods.MUTE;
using HarmonyLib;
using IL;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using Unity.Netcode;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LogMuteLethal")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+19295335d08c23093500d5d4e3e3454743ee0976")]
[assembly: AssemblyProduct("LogMuteLethal")]
[assembly: AssemblyTitle("LogMuteLethal")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NativeIntegerAttribute : Attribute
{
public readonly bool[] TransformFlags;
public NativeIntegerAttribute()
{
TransformFlags = new bool[1] { true };
}
public NativeIntegerAttribute(bool[] P_0)
{
TransformFlags = P_0;
}
}
}
namespace HDeMods
{
internal static class LogMuteLethal
{
private static ILHook networkVarDirtyHook;
private static ILHook oneShotHook;
private static ILHook playerLevelHook;
private static bool RemoveLogFormat(this ILCursor c, string logName)
{
return c.RemoveLog(logName, 2);
}
private static bool RemoveLog(this ILCursor c, string logName, int count = 1)
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
if (!c.TryGotoNext(new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Debug>(x, logName)
}))
{
Log.Error("Failed to silence " + ((MemberReference)c.Method).Name);
return false;
}
for (int i = 0; i < count; i++)
{
c.Emit(OpCodes.Pop);
}
c.Remove();
return true;
}
internal static void Startup()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Expected O, but got Unknown
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Expected O, but got Unknown
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Expected O, but got Unknown
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Expected O, but got Unknown
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Expected O, but got Unknown
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Expected O, but got Unknown
HoarderBugAI.SetGoTowardsTargetObject += new Manipulator(HoarderBugAI_SetGoTowardsTargetObject);
DepositItemsDesk.Update += new Manipulator(DepositItemsDesk_Update);
playerLevelHook = new ILHook((MethodBase)AccessTools.EnumeratorMoveNext((MethodBase)AccessTools.Method(typeof(HUDManager), "SetPlayerLevelSmoothly", (Type[])null, (Type[])null)), new Manipulator(HUDManager_SetPlayerLevelSmoothly));
networkVarDirtyHook = new ILHook((MethodBase)AccessTools.Method(typeof(NetworkVariableBase), "SetDirty", (Type[])null, (Type[])null), new Manipulator(NetworkVariableBase_SetDirty));
oneShotHook = new ILHook((MethodBase)AccessTools.Method(typeof(AudioSource), "PlayOneShot", new Type[2]
{
typeof(AudioClip),
typeof(float)
}, (Type[])null), new Manipulator(AudioSource_PlayOneShot));
LogMuteUnity.Startup();
LogMuteReveal.Startup();
}
private static void HUDManager_SetPlayerLevelSmoothly(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
RemoveLog(new ILCursor(il), "Log");
}
private static void HoarderBugAI_SetGoTowardsTargetObject(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
//IL_001e: Expected O, but got Unknown
ILCursor val = new ILCursor(il);
RemoveLog(val, "Log");
RemoveLog(val, "Log");
}
private static void DepositItemsDesk_Update(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
//IL_001e: Expected O, but got Unknown
ILCursor val = new ILCursor(il);
RemoveLog(val, "Log");
RemoveLog(val, "Log");
}
private static void NetworkVariableBase_SetDirty(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
RemoveLog(new ILCursor(il), "LogWarning");
}
private static void AudioSource_PlayOneShot(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
RemoveLog(new ILCursor(il), "LogWarning");
}
}
internal static class LogMuteReveal
{
public static void Startup()
{
}
}
internal static class LogMuteUnity
{
[DllImport("kernel32", ExactSpelling = true)]
private unsafe static extern int FlushInstructionCache(nint handle, void* baseAddr, nuint size);
[DllImport("kernel32.dll")]
private static extern bool VirtualProtectEx(IntPtr hProcess, IntPtr lpAddress, UIntPtr dwSize, uint flNewProtect, out uint lpflOldProtect);
public static void Startup()
{
Process currentProcess = Process.GetCurrentProcess();
IntPtr baseAddress = currentProcess.Modules.Cast<ProcessModule>().Single((ProcessModule m) => m.ModuleName == "UnityPlayer.dll").BaseAddress;
if (!NopLocation(currentProcess, baseAddress, 12188160, 11280188857790794728uL))
{
Log.Error("Failed to silence Audio Source!");
}
if (!NopLocation(currentProcess, baseAddress, 983177, 13558103175015826152uL))
{
Log.Error("Failed to silence Look Zero!");
}
if (!NopLocation(currentProcess, baseAddress, 12190251, 9023032223454486760uL))
{
Log.Error("Failed to silence Custom Filter!");
}
if (!NopLocation(currentProcess, baseAddress, 10703121, 1782721766651165416uL))
{
Log.Error("Failed to silence NavMesh!");
}
if (!NopLocation(currentProcess, baseAddress, 10723257, 5242244943489716968uL))
{
Log.Error("Failed to silence SetDestination!");
}
}
private unsafe static bool NopLocation(Process currentProc, IntPtr baseAddress, nint offset, ulong instrToReplace)
{
ulong num = 18446742974197923840uL;
byte* ptr = (byte*)((nint)baseAddress + offset);
if (*(long*)ptr != (long)instrToReplace)
{
string text = ((long*)ptr)->ToString("X");
long num2 = (long)instrToReplace;
Log.Error("No Match. " + text + " " + num2.ToString("X"));
return false;
}
num &= instrToReplace;
num |= 0x9048904866uL;
VirtualProtectEx(currentProc.Handle, (IntPtr)ptr, (UIntPtr)8uL, 64u, out var lpflOldProtect);
*(ulong*)ptr = num;
VirtualProtectEx(currentProc.Handle, (IntPtr)ptr, (UIntPtr)8uL, lpflOldProtect, out var _);
if (FlushInstructionCache(currentProc.Handle, ptr, 8u) == 0)
{
return false;
}
return true;
}
}
[BepInPlugin("com.HDeDeDe.LogMuteLethal", "LogMuteLethal", "1.0.0")]
public sealed class LogMuteLethalPlugin : BaseUnityPlugin
{
public const string PluginGUID = "com.HDeDeDe.LogMuteLethal";
public const string PluginAuthor = "HDeDeDe";
public const string PluginName = "LogMuteLethal";
public const string PluginVersion = "1.0.0";
public static LogMuteLethalPlugin instance;
private void Awake()
{
if ((Object)(object)instance != (Object)null)
{
Log.Error("There can be only 1 instance of LogMuteLethal!");
Object.Destroy((Object)(object)this);
}
else
{
Log.Init(((BaseUnityPlugin)this).Logger);
instance = this;
LogMuteLethal.Startup();
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "LogMuteLethal";
public const string PLUGIN_NAME = "LogMuteLethal";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace HDeMods.MUTE
{
internal static class Log
{
private static ManualLogSource logMe;
internal static void Init(ManualLogSource logSource)
{
logMe = logSource;
}
internal static void Debug(object data)
{
logMe.LogDebug(data);
}
internal static void Error(object data)
{
logMe.LogError(data);
}
internal static void Fatal(object data)
{
logMe.LogFatal(data);
}
internal static void Info(object data)
{
logMe.LogInfo(data);
}
internal static void Message(object data)
{
logMe.LogMessage(data);
}
internal static void Warning(object data)
{
logMe.LogWarning(data);
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}