Decompiled source of SteamApiUpgrade v0.0.1

patchers/SteamApiUpgrade.dll

Decompiled 6 hours ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using SteamApiUpgrade.Properties;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SteamApiUpgrade")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: AssemblyInformationalVersion("0.0.1")]
[assembly: AssemblyProduct("Steam API Upgrade")]
[assembly: AssemblyTitle("SteamApiUpgrade")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SteamApiUpgrade
{
	internal static class Native
	{
		[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
		internal static extern IntPtr LoadLibrary(string libname);
	}
	public static class Patcher
	{
		private const string GUID = "com.lalabuff.lethal.steamapiupgrade";

		private const string NAME = "Steam API Upgrade";

		private const string VERSION = "0.0.1";

		internal static ManualLogSource Log;

		private const string STEAMAPI = "steam_api64_patched";

		private const string STEAMWORKS = "Facepunch.Steamworks.Win64";

		private const string TRANSPORT = "Facepunch Transport for Netcode for GameObjects";

		public static IEnumerable<string> TargetDLLs => new <>z__ReadOnlyArray<string>(new string[2] { "Facepunch.Steamworks.Win64.dll", "Facepunch Transport for Netcode for GameObjects.dll" });

		public static void Initialize()
		{
			Log = Logger.CreateLogSource("Steam API Upgrade");
			Log.LogInfo((object)"Loading prepatcher for Steam API Upgrade (com.lalabuff.lethal.steamapiupgrade) v0.0.1...");
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "steam_api64_patched.dll");
			Log.LogDebug((object)("Attempting to load [" + text + "]..."));
			if (Native.LoadLibrary(text) == IntPtr.Zero)
			{
				int lastWin32Error = Marshal.GetLastWin32Error();
				Log.LogError((object)string.Format("Failed to load [{0}.dll] with error code [{1}].", "steam_api64_patched", lastWin32Error));
			}
			else
			{
				Log.LogInfo((object)"Successfully loaded [steam_api64_patched.dll].");
			}
		}

		public static void Patch(ref AssemblyDefinition assembly)
		{
			string name = ((AssemblyNameReference)assembly.Name).Name;
			byte[] array = ((name == "Facepunch.Steamworks.Win64") ? Resources.Facepunch_Steamworks_Win64 : ((!(name == "Facepunch Transport for Netcode for GameObjects")) ? Array.Empty<byte>() : Resources.FacepunchTransport));
			byte[] array2 = array;
			if (array2.Length == 0)
			{
				Log.LogError((object)("Failed to patch unexpected assembly [" + name + "]."));
				return;
			}
			if (array2 == null)
			{
				Log.LogError((object)("Something went horribly wrong. Got null assembly for [" + name + "]."));
				return;
			}
			AssemblyDefinition val = AssemblyDefinition.ReadAssembly((Stream)new MemoryStream(array2));
			val.Name = assembly.Name;
			assembly = val;
			Log.LogInfo((object)("Patched assembly [" + name + "]."));
		}

		public static void Finish()
		{
			Log.LogInfo((object)"Finished prepatching Steam API Upgrade (com.lalabuff.lethal.steamapiupgrade) v0.0.1!");
		}
	}
}
namespace SteamApiUpgrade.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					resourceMan = new ResourceManager("SteamApiUpgrade.Properties.Resources", typeof(Resources).Assembly);
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal static byte[] Facepunch_Steamworks_Win64 => (byte[])ResourceManager.GetObject("Facepunch.Steamworks.Win64", resourceCulture);

		internal static byte[] FacepunchTransport => (byte[])ResourceManager.GetObject("FacepunchTransport", resourceCulture);

		internal Resources()
		{
		}
	}
}
[CompilerGenerated]
internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	int ICollection.Count => _items.Length;

	bool ICollection.IsSynchronized => false;

	object ICollection.SyncRoot => this;

	object IList.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	bool IList.IsFixedSize => true;

	bool IList.IsReadOnly => true;

	int IReadOnlyCollection<T>.Count => _items.Length;

	T IReadOnlyList<T>.this[int index] => _items[index];

	int ICollection<T>.Count => _items.Length;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlyArray(T[] items)
	{
		_items = items;
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return ((IEnumerable)_items).GetEnumerator();
	}

	void ICollection.CopyTo(Array array, int index)
	{
		((ICollection)_items).CopyTo(array, index);
	}

	int IList.Add(object value)
	{
		throw new NotSupportedException();
	}

	void IList.Clear()
	{
		throw new NotSupportedException();
	}

	bool IList.Contains(object value)
	{
		return ((IList)_items).Contains(value);
	}

	int IList.IndexOf(object value)
	{
		return ((IList)_items).IndexOf(value);
	}

	void IList.Insert(int index, object value)
	{
		throw new NotSupportedException();
	}

	void IList.Remove(object value)
	{
		throw new NotSupportedException();
	}

	void IList.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}

	IEnumerator<T> IEnumerable<T>.GetEnumerator()
	{
		return ((IEnumerable<T>)_items).GetEnumerator();
	}

	void ICollection<T>.Add(T item)
	{
		throw new NotSupportedException();
	}

	void ICollection<T>.Clear()
	{
		throw new NotSupportedException();
	}

	bool ICollection<T>.Contains(T item)
	{
		return ((ICollection<T>)_items).Contains(item);
	}

	void ICollection<T>.CopyTo(T[] array, int arrayIndex)
	{
		((ICollection<T>)_items).CopyTo(array, arrayIndex);
	}

	bool ICollection<T>.Remove(T item)
	{
		throw new NotSupportedException();
	}

	int IList<T>.IndexOf(T item)
	{
		return ((IList<T>)_items).IndexOf(item);
	}

	void IList<T>.Insert(int index, T item)
	{
		throw new NotSupportedException();
	}

	void IList<T>.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}
}