using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using Microsoft.CodeAnalysis; using Mono.Cecil; [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("DaXcess")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright (c) DaXcess 2024-2025")] [assembly: AssemblyDescription("LCVR Preloader")] [assembly: AssemblyFileVersion("1.4.6.0")] [assembly: AssemblyInformationalVersion("1.4.6+b4b3ff0a536f5a5f73d9d77c1cb2bc48e7ee6ea6")] [assembly: AssemblyProduct("LCVR.Preload")] [assembly: AssemblyTitle("LCVR.Preload")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/DaXcess/LCVR")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.4.6.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [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 BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace LCVR.Preload { public static class Preload { private const string VR_MANIFEST = "{\r\n \"name\": \"OpenXR XR Plugin\",\r\n \"version\": \"1.8.2\",\r\n \"libraryName\": \"UnityOpenXR\",\r\n \"displays\": [\r\n {\r\n \"id\": \"OpenXR Display\"\r\n }\r\n ],\r\n \"inputs\": [\r\n {\r\n \"id\": \"OpenXR Input\"\r\n }\r\n ]\r\n}"; private static readonly ManualLogSource Logger = Logger.CreateLogSource("LCVR.Preload"); public static IEnumerable TargetDLLs { get; } = Array.Empty(); public static void Initialize() { Logger.LogInfo((object)"Setting up VR runtime assets"); SetupRuntimeAssets(); Logger.LogInfo((object)"We're done here. Goodbye!"); } private static void SetupRuntimeAssets() { string path = Path.Combine(Paths.GameRootPath, "PEAK_Data"); string text = Path.Combine(path, "UnitySubsystems"); if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } string text2 = Path.Combine(text, "UnityOpenXR"); if (!Directory.Exists(text2)) { Directory.CreateDirectory(text2); } string path2 = Path.Combine(text2, "UnitySubsystemsManifest.json"); if (!File.Exists(path2)) { File.WriteAllText(path2, "{\r\n \"name\": \"OpenXR XR Plugin\",\r\n \"version\": \"1.8.2\",\r\n \"libraryName\": \"UnityOpenXR\",\r\n \"displays\": [\r\n {\r\n \"id\": \"OpenXR Display\"\r\n }\r\n ],\r\n \"inputs\": [\r\n {\r\n \"id\": \"OpenXR Input\"\r\n }\r\n ]\r\n}"); } string path3 = Path.Combine(path, "Plugins"); string destinationFile = Path.Combine(path3, "UnityOpenXR.dll"); string destinationFile2 = Path.Combine(path3, "openxr_loader.dll"); string? directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string sourceFile = Path.Combine(directoryName, "RuntimeDeps/UnityOpenXR.dll"); string sourceFile2 = Path.Combine(directoryName, "RuntimeDeps/openxr_loader.dll"); if (!CopyResourceFile(sourceFile, destinationFile)) { Logger.LogWarning((object)"Could not find plugin UnityOpenXR.dll, VR might not work!"); } if (!CopyResourceFile(sourceFile2, destinationFile2)) { Logger.LogWarning((object)"Could not find plugin openxr_loader.dll, VR might not work!"); } } private static bool CopyResourceFile(string sourceFile, string destinationFile) { if (!File.Exists(sourceFile)) { return false; } if (File.Exists(destinationFile)) { byte[] first = Utils.ComputeHash(File.ReadAllBytes(sourceFile)); byte[] second = Utils.ComputeHash(File.ReadAllBytes(destinationFile)); if (first.SequenceEqual(second)) { return true; } } File.Copy(sourceFile, destinationFile, overwrite: true); return true; } public static void Patch(AssemblyDefinition assembly) { } } public static class Utils { public static byte[] ComputeHash(byte[] input) { using SHA256 sHA = SHA256.Create(); return sHA.ComputeHash(input); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }