using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Net; using System.Net.Http; using System.Net.Http.Headers; using System.Net.NetworkInformation; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Security.Principal; using System.Text; using System.Text.Json; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using Awwdio; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using BepInEx.NET.Common; using BepInExResoniteShim; using BepisResoniteWrapper; using BepuPhysics.Collidables; using DesktopBuddy.Shared; using Elements.Assets; using Elements.Core; using FFmpeg.AutoGen; using FrooxEngine; using FrooxEngine.CommonAvatar; using FrooxEngine.UIX; using HarmonyLib; using InterprocessLib; using Microsoft.CodeAnalysis; using Microsoft.Win32; using Microsoft.Win32.SafeHandles; using Renderite.Shared; using SkyFrost.Base; using WinRT; using Windows.Foundation; using Windows.Foundation.Metadata; using Windows.Graphics; using Windows.Graphics.Capture; using Windows.Graphics.DirectX; using Windows.Graphics.DirectX.Direct3D11; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(/*Could not decode attribute arguments.*/)] [assembly: TargetFramework(".NETCoreApp,Version=v10.0", FrameworkDisplayName = ".NET 10.0")] [assembly: AssemblyCompany("DesktopBuddy")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+e5251e37dd743ac1b5ffad5e3f95aa6063a3aabc")] [assembly: AssemblyProduct("DesktopBuddy")] [assembly: AssemblyTitle("DesktopBuddy")] [assembly: TargetPlatform("Windows10.0.26100.0")] [assembly: SupportedOSPlatform("Windows10.0.19041.0")] [assembly: SecurityPermission((SecurityAction)8, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace BepInEx { [AttributeUsage(/*Could not decode attribute arguments.*/)] [Conditional("CodeGeneration")] [Embedded] internal sealed class BepInAutoPluginAttribute : global::System.Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null, string? authors = null, string? link = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(/*Could not decode attribute arguments.*/)] [Conditional("CodeGeneration")] [Embedded] internal sealed class PatcherAutoPluginAttribute : global::System.Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace Microsoft.CodeAnalysis { [Embedded] internal sealed class EmbeddedAttribute : global::System.Attribute { } } namespace DesktopBuddy { internal static class DesktopBuddyFirstRunSetup { internal enum SetupAction { SoftCamRegistration, VBCableInstall, VBCableLoopback, UrlAcl } internal sealed class SetupState { internal static readonly SetupState Ok = new SetupState(); [field: CompilerGenerated] internal global::System.Collections.Generic.IReadOnlyList Items { [CompilerGenerated] get; [CompilerGenerated] init; } = global::System.Array.Empty(); [field: CompilerGenerated] internal global::System.Collections.Generic.IReadOnlyList RequiredActions { [CompilerGenerated] get; [CompilerGenerated] init; } = global::System.Array.Empty(); internal bool HasIssues => Enumerable.Any((global::System.Collections.Generic.IEnumerable)Items, (Func)((SetupItem item) => !item.IsOk)); internal bool HasRequiredActions => ((global::System.Collections.Generic.IReadOnlyCollection)RequiredActions).Count > 0; } internal sealed class SetupItem { [field: CompilerGenerated] internal string Name { [CompilerGenerated] get; [CompilerGenerated] init; } [field: CompilerGenerated] internal string Status { [CompilerGenerated] get; [CompilerGenerated] init; } [field: CompilerGenerated] internal string Detail { [CompilerGenerated] get; [CompilerGenerated] init; } [field: CompilerGenerated] internal bool IsOk { [CompilerGenerated] get; [CompilerGenerated] init; } [field: CompilerGenerated] internal bool RequiresAdminAction { [CompilerGenerated] get; [CompilerGenerated] init; } [field: CompilerGenerated] internal SetupAction? Action { [CompilerGenerated] get; [CompilerGenerated] init; } } [CompilerGenerated] private sealed class d__31 : global::System.Collections.Generic.IEnumerable>, global::System.Collections.IEnumerable, global::System.Collections.Generic.IEnumerator>, global::System.Collections.IEnumerator, global::System.IDisposable { private int <>1__state; private ValueTuple <>2__current; private int <>l__initialThreadId; ValueTuple global::System.Collections.Generic.IEnumerator>.Current { [DebuggerHidden] get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return <>2__current; } } object global::System.Collections.IEnumerator.Current { [DebuggerHidden] get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return <>2__current; } } [DebuggerHidden] public d__31(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void global::System.IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = new ValueTuple(Registry.ClassesRoot, "CLSID\\{AEF3B972-5FA5-4647-9571-358EB472BC9E}\\InprocServer32"); <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = new ValueTuple(Registry.CurrentUser, "Software\\Classes\\CLSID\\{AEF3B972-5FA5-4647-9571-358EB472BC9E}\\InprocServer32"); <>1__state = 2; return true; case 2: <>1__state = -1; <>2__current = new ValueTuple(Registry.CurrentUser, "Software\\Classes\\WOW6432Node\\CLSID\\{AEF3B972-5FA5-4647-9571-358EB472BC9E}\\InprocServer32"); <>1__state = 3; return true; case 3: <>1__state = -1; <>2__current = new ValueTuple(Registry.LocalMachine, "Software\\Classes\\CLSID\\{AEF3B972-5FA5-4647-9571-358EB472BC9E}\\InprocServer32"); <>1__state = 4; return true; case 4: <>1__state = -1; <>2__current = new ValueTuple(Registry.LocalMachine, "Software\\Classes\\WOW6432Node\\CLSID\\{AEF3B972-5FA5-4647-9571-358EB472BC9E}\\InprocServer32"); <>1__state = 5; return true; case 5: <>1__state = -1; return false; } } bool global::System.Collections.IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void global::System.Collections.IEnumerator.Reset() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(); } [DebuggerHidden] global::System.Collections.Generic.IEnumerator> global::System.Collections.Generic.IEnumerable>.GetEnumerator() { if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; return this; } return new d__31(0); } [DebuggerHidden] global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() { return (global::System.Collections.IEnumerator)((global::System.Collections.Generic.IEnumerable>)this).GetEnumerator(); } } [CompilerGenerated] private sealed class d__30 : global::System.Collections.Generic.IEnumerable, global::System.Collections.IEnumerable, global::System.Collections.Generic.IEnumerator, global::System.Collections.IEnumerator, global::System.IDisposable { private int <>1__state; private string <>2__current; private int <>l__initialThreadId; private global::System.Collections.Generic.IEnumerator> <>7__wrap1; private RegistryKey 5__3; string global::System.Collections.Generic.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object global::System.Collections.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__30(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void global::System.IDisposable.Dispose() { int num = <>1__state; if ((uint)(num - -4) <= 1u || num == 1) { try { if (num == -4 || num == 1) { try { } finally { <>m__Finally2(); } } } finally { <>m__Finally1(); } } <>7__wrap1 = null; 5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) try { int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -4; goto IL_00aa; } <>1__state = -1; <>7__wrap1 = GetSoftCamInprocKeys().GetEnumerator(); <>1__state = -3; goto IL_00b7; IL_00aa: <>m__Finally2(); 5__3 = null; goto IL_00b7; IL_00b7: if (((global::System.Collections.IEnumerator)<>7__wrap1).MoveNext()) { ValueTuple current = <>7__wrap1.Current; 5__3 = current.Item1.OpenSubKey(current.Item2); <>1__state = -4; RegistryKey obj = 5__3; string text = ((obj != null) ? obj.GetValue("") : null) as string; if (!string.IsNullOrWhiteSpace(text)) { <>2__current = text.Trim('"'); <>1__state = 1; return true; } goto IL_00aa; } <>m__Finally1(); <>7__wrap1 = null; return false; } catch { //try-fault ((global::System.IDisposable)this).Dispose(); throw; } } bool global::System.Collections.IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap1 != null) { ((global::System.IDisposable)<>7__wrap1).Dispose(); } } private void <>m__Finally2() { <>1__state = -3; if (5__3 != null) { ((global::System.IDisposable)5__3).Dispose(); } } [DebuggerHidden] void global::System.Collections.IEnumerator.Reset() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(); } [DebuggerHidden] global::System.Collections.Generic.IEnumerator global::System.Collections.Generic.IEnumerable.GetEnumerator() { if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; return this; } return new d__30(0); } [DebuggerHidden] global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() { return (global::System.Collections.IEnumerator)((global::System.Collections.Generic.IEnumerable)this).GetEnumerator(); } } [CompilerGenerated] private sealed class d__32 : global::System.Collections.Generic.IEnumerable>, global::System.Collections.IEnumerable, global::System.Collections.Generic.IEnumerator>, global::System.Collections.IEnumerator, global::System.IDisposable { private int <>1__state; private ValueTuple <>2__current; private int <>l__initialThreadId; ValueTuple global::System.Collections.Generic.IEnumerator>.Current { [DebuggerHidden] get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return <>2__current; } } object global::System.Collections.IEnumerator.Current { [DebuggerHidden] get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return <>2__current; } } [DebuggerHidden] public d__32(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void global::System.IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = new ValueTuple(Registry.CurrentUser, "Software\\Classes\\CLSID\\{AEF3B972-5FA5-4647-9571-358EB472BC9E}"); <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = new ValueTuple(Registry.CurrentUser, "Software\\Classes\\WOW6432Node\\CLSID\\{AEF3B972-5FA5-4647-9571-358EB472BC9E}"); <>1__state = 2; return true; case 2: <>1__state = -1; <>2__current = new ValueTuple(Registry.LocalMachine, "Software\\Classes\\CLSID\\{AEF3B972-5FA5-4647-9571-358EB472BC9E}"); <>1__state = 3; return true; case 3: <>1__state = -1; <>2__current = new ValueTuple(Registry.LocalMachine, "Software\\Classes\\WOW6432Node\\CLSID\\{AEF3B972-5FA5-4647-9571-358EB472BC9E}"); <>1__state = 4; return true; case 4: <>1__state = -1; <>2__current = new ValueTuple(Registry.CurrentUser, "Software\\Classes\\CLSID\\{860BB310-5D01-11d0-BD3B-00A0C911CE86}\\Instance\\DesktopBuddy - Camera"); <>1__state = 5; return true; case 5: <>1__state = -1; <>2__current = new ValueTuple(Registry.CurrentUser, "Software\\Classes\\CLSID\\{860BB310-5D01-11d0-BD3B-00A0C911CE86}\\Instance\\DirectShow Softcam"); <>1__state = 6; return true; case 6: <>1__state = -1; <>2__current = new ValueTuple(Registry.CurrentUser, "Software\\Classes\\WOW6432Node\\CLSID\\{860BB310-5D01-11d0-BD3B-00A0C911CE86}\\Instance\\DesktopBuddy - Camera"); <>1__state = 7; return true; case 7: <>1__state = -1; <>2__current = new ValueTuple(Registry.CurrentUser, "Software\\Classes\\WOW6432Node\\CLSID\\{860BB310-5D01-11d0-BD3B-00A0C911CE86}\\Instance\\DirectShow Softcam"); <>1__state = 8; return true; case 8: <>1__state = -1; <>2__current = new ValueTuple(Registry.LocalMachine, "Software\\Classes\\CLSID\\{860BB310-5D01-11d0-BD3B-00A0C911CE86}\\Instance\\DesktopBuddy - Camera"); <>1__state = 9; return true; case 9: <>1__state = -1; <>2__current = new ValueTuple(Registry.LocalMachine, "Software\\Classes\\CLSID\\{860BB310-5D01-11d0-BD3B-00A0C911CE86}\\Instance\\DirectShow Softcam"); <>1__state = 10; return true; case 10: <>1__state = -1; <>2__current = new ValueTuple(Registry.LocalMachine, "Software\\Classes\\WOW6432Node\\CLSID\\{860BB310-5D01-11d0-BD3B-00A0C911CE86}\\Instance\\DesktopBuddy - Camera"); <>1__state = 11; return true; case 11: <>1__state = -1; <>2__current = new ValueTuple(Registry.LocalMachine, "Software\\Classes\\WOW6432Node\\CLSID\\{860BB310-5D01-11d0-BD3B-00A0C911CE86}\\Instance\\DirectShow Softcam"); <>1__state = 12; return true; case 12: <>1__state = -1; return false; } } bool global::System.Collections.IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void global::System.Collections.IEnumerator.Reset() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(); } [DebuggerHidden] global::System.Collections.Generic.IEnumerator> global::System.Collections.Generic.IEnumerable>.GetEnumerator() { if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; return this; } return new d__32(0); } [DebuggerHidden] global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() { return (global::System.Collections.IEnumerator)((global::System.Collections.Generic.IEnumerable>)this).GetEnumerator(); } } [CompilerGenerated] private sealed class d__29 : global::System.Collections.Generic.IEnumerable, global::System.Collections.IEnumerable, global::System.Collections.Generic.IEnumerator, global::System.Collections.IEnumerator, global::System.IDisposable { private int <>1__state; private string <>2__current; private int <>l__initialThreadId; private string runtimeDir; public string <>3__runtimeDir; private global::System.Collections.Generic.IEnumerator <>7__wrap1; string global::System.Collections.Generic.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object global::System.Collections.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__29(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void global::System.IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 3) { try { } finally { <>m__Finally1(); } } <>7__wrap1 = null; <>1__state = -2; } private bool MoveNext() { try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = Path.Combine(runtimeDir, "softcam64.dll"); <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = Path.Combine(runtimeDir, "softcam.dll"); <>1__state = 2; return true; case 2: <>1__state = -1; <>7__wrap1 = GetSoftCamRegisteredDlls().GetEnumerator(); <>1__state = -3; break; case 3: <>1__state = -3; break; } if (((global::System.Collections.IEnumerator)<>7__wrap1).MoveNext()) { string current = <>7__wrap1.Current; <>2__current = current; <>1__state = 3; return true; } <>m__Finally1(); <>7__wrap1 = null; return false; } catch { //try-fault ((global::System.IDisposable)this).Dispose(); throw; } } bool global::System.Collections.IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap1 != null) { ((global::System.IDisposable)<>7__wrap1).Dispose(); } } [DebuggerHidden] void global::System.Collections.IEnumerator.Reset() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(); } [DebuggerHidden] global::System.Collections.Generic.IEnumerator global::System.Collections.Generic.IEnumerable.GetEnumerator() { d__29 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__29(0); } d__.runtimeDir = <>3__runtimeDir; return d__; } [DebuggerHidden] global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() { return (global::System.Collections.IEnumerator)((global::System.Collections.Generic.IEnumerable)this).GetEnumerator(); } } private const string SoftCamClsid = "{AEF3B972-5FA5-4647-9571-358EB472BC9E}"; private const string VideoInputCategoryClsid = "{860BB310-5D01-11d0-BD3B-00A0C911CE86}"; private const string SetupHashFile = "DesktopBuddySetupHashes.txt"; private const string PackagedSetupHashFile = "DesktopBuddySetupPayloads.md5"; internal static SetupState Check() { try { string runtimeDir = GetRuntimeDir(); Log.Msg("[Setup] Checking DesktopBuddy local setup"); Log.Msg("[Setup] Runtime path: " + runtimeDir); global::System.Collections.Generic.IReadOnlyList setupItems = GetSetupItems(runtimeDir); return new SetupState { Items = setupItems, RequiredActions = (global::System.Collections.Generic.IReadOnlyList)GetRequiredActions(setupItems) }; } catch (global::System.Exception ex) { Log.Msg($"[Setup] First-run setup check failed: {ex}"); SetupState setupState = new SetupState(); setupState.Items = new SetupItem[1] { new SetupItem { Name = "Setup check", Status = "Error", Detail = ex.Message, IsOk = false } }; return setupState; } } internal static Process StartElevatedSetup(global::System.Collections.Generic.IReadOnlyCollection actions = null) { string runtimeDir = GetRuntimeDir(); List val = ((actions == null || actions.Count == 0) ? GetRequiredAdminActions(runtimeDir) : NormalizeSetupActions((global::System.Collections.Generic.IEnumerable)actions)); if (val.Count == 0) { Log.Msg("[Setup] No elevated setup actions are required"); return null; } Log.Msg("[Setup] User requested admin setup: " + string.Join(", ", Enumerable.Select((global::System.Collections.Generic.IEnumerable)val, (Func)GetActionLabel))); if (IsAdministrator()) { RunAdminSetup((global::System.Collections.Generic.IReadOnlyCollection)val, runtimeDir); return null; } return StartElevatedSetupHelper((global::System.Collections.Generic.IReadOnlyCollection)val, runtimeDir); } private static List GetRequiredAdminActions(string runtimeDir) { return GetRequiredActions(GetSetupItems(runtimeDir)); } private static List GetRequiredActions(global::System.Collections.Generic.IReadOnlyList items) { return NormalizeSetupActions(Enumerable.Select(Enumerable.Where((global::System.Collections.Generic.IEnumerable)items, (Func)((SetupItem item) => item.RequiresAdminAction && item.Action.HasValue)), (Func)((SetupItem item) => item.Action.Value))); } private static List NormalizeSetupActions(global::System.Collections.Generic.IEnumerable actions) { List val = Enumerable.ToList(Enumerable.Distinct(actions)); if (val.Contains(SetupAction.VBCableInstall) && !val.Contains(SetupAction.VBCableLoopback)) { int num = val.IndexOf(SetupAction.VBCableInstall); val.Insert(num + 1, SetupAction.VBCableLoopback); } return val; } private static string GetActionLabel(SetupAction action) { return action switch { SetupAction.SoftCamRegistration => "SoftCam registration", SetupAction.VBCableInstall => "VB-Cable install", SetupAction.VBCableLoopback => "VB-Cable loopback disable", SetupAction.UrlAcl => "streaming access", _ => ((object)action/*cast due to .constrained prefix*/).ToString(), }; } private static global::System.Collections.Generic.IReadOnlyList GetSetupItems(string runtimeDir) { List obj = new List(); obj.Add(GetSoftCamSetupItem(runtimeDir)); obj.Add(GetVBCableInstallSetupItem(runtimeDir)); obj.Add(GetVBCableLoopbackSetupItem()); obj.Add(GetUrlAclSetupItem()); return (global::System.Collections.Generic.IReadOnlyList)obj; } private static SetupItem GetSoftCamSetupItem(string runtimeDir) { string text = ((File.Exists(Path.Combine(runtimeDir, "softcam64.dll")) || !File.Exists(Path.Combine(runtimeDir, "softcam.dll"))) ? "softcam64.dll" : "softcam.dll"); string text2 = Path.Combine(runtimeDir, text); string text3 = ReadPackagedSetupHash(runtimeDir, text); string text4 = Enumerable.FirstOrDefault(GetSoftCamRegisteredDlls()); string text5 = ReadSetupHash(runtimeDir, text); global::System.Collections.Generic.IReadOnlyList runningRestartSensitiveProcesses = GetRunningRestartSensitiveProcesses(); bool flag = !File.Exists(text2); bool flag2 = string.IsNullOrWhiteSpace(text4); bool flag3 = !flag2 && !PathsEqual(text4, text2); bool flag4 = !flag && !string.IsNullOrWhiteSpace(text3) && !string.Equals(text5, text3, (StringComparison)5); bool flag5 = flag || flag2 || flag3 || flag4; return new SetupItem { Name = "SoftCam", Status = (flag5 ? "Not installed" : "Installed"), Detail = (flag5 ? GetSoftCamSetupDetail(runningRestartSensitiveProcesses) : "Virtual camera support."), IsOk = !flag5, RequiresAdminAction = (flag5 && !flag), Action = SetupAction.SoftCamRegistration }; } private static string GetSoftCamSetupDetail(global::System.Collections.Generic.IReadOnlyList runningApps) { if (runningApps == null || ((global::System.Collections.Generic.IReadOnlyCollection)runningApps).Count == 0) { return "Virtual camera support."; } string[] array = Enumerable.ToArray(Enumerable.Take((global::System.Collections.Generic.IEnumerable)runningApps, 3)); string text = ((((global::System.Collections.Generic.IReadOnlyCollection)runningApps).Count > array.Length) ? $" +{((global::System.Collections.Generic.IReadOnlyCollection)runningApps).Count - array.Length}" : ""); return "Restart: " + string.Join(", ", array) + text; } private static SetupItem GetVBCableInstallSetupItem(string runtimeDir) { string text = Path.Combine(runtimeDir, "VBCABLE_Setup_x64.exe"); string text2 = ReadPackagedSetupHash(runtimeDir, "VBCABLE_Setup_x64.exe"); string text3 = ReadSetupHash(runtimeDir, "VBCABLE_Setup_x64.exe"); bool num = IsVBCableInstalled(); bool flag = !File.Exists(text); bool flag2 = num && !string.IsNullOrWhiteSpace(text2) && !string.Equals(text3, text2, (StringComparison)5); bool flag3 = !num || flag2; string status = (flag3 ? "Not installed" : "Installed"); string detail = "Virtual microphone audio route."; return new SetupItem { Name = "VB-Cable", Status = status, Detail = detail, IsOk = !flag3, RequiresAdminAction = (flag3 && !flag), Action = SetupAction.VBCableInstall }; } private static SetupItem GetVBCableLoopbackSetupItem() { bool flag = IsVBCableInstalled(); bool flag2 = IsVBCableLoopbackDisabled(); return new SetupItem { Name = "VB-Cable loopback", Status = ((!flag || flag2) ? "Installed" : "Not installed"), Detail = "Prevents microphone echo.", IsOk = (!flag || flag2), RequiresAdminAction = (flag && !flag2), Action = SetupAction.VBCableLoopback }; } private static SetupItem GetUrlAclSetupItem() { bool flag = IsUrlAclConfigured(); return new SetupItem { Name = "Streaming access", Status = (flag ? "Installed" : "Not installed"), Detail = "Allows local stream hosting.", IsOk = flag, RequiresAdminAction = !flag, Action = SetupAction.UrlAcl }; } private static void RunAdminSetup(global::System.Collections.Generic.IReadOnlyCollection actions, string runtimeDir) { Log.Msg("[Setup] Running admin setup inside DesktopBuddy"); global::System.Collections.Generic.IEnumerator enumerator = ((global::System.Collections.Generic.IEnumerable)actions).GetEnumerator(); try { while (((global::System.Collections.IEnumerator)enumerator).MoveNext()) { switch (enumerator.Current) { case SetupAction.SoftCamRegistration: RegisterSoftCam(runtimeDir); break; case SetupAction.VBCableInstall: InstallVBCable(runtimeDir); break; case SetupAction.VBCableLoopback: ConfigureVBCableLoopback(); break; case SetupAction.UrlAcl: ConfigureUrlAcl(); break; } } } finally { ((global::System.IDisposable)enumerator)?.Dispose(); } WriteSetupHashes(runtimeDir); Log.Msg("[Setup] Admin setup complete"); } private static Process StartElevatedSetupHelper(global::System.Collections.Generic.IReadOnlyCollection actions, string runtimeDir) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown string logPath = Path.Combine(runtimeDir, "DesktopBuddySetup.log"); string text = BuildElevatedSetupScript(actions, runtimeDir, logPath); string text2 = Path.Combine(runtimeDir, "DesktopBuddyElevatedSetup.ps1"); File.WriteAllText(text2, text, Encoding.UTF8); string arguments = "-NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -File \"" + text2 + "\""; ProcessStartInfo val = new ProcessStartInfo { FileName = "powershell.exe", Arguments = arguments, UseShellExecute = true, Verb = "runas", WindowStyle = (ProcessWindowStyle)1 }; try { Log.Msg("[Setup] Requesting administrator permission for user-approved setup"); Process val2 = Process.Start(val); if (val2 == null) { Log.Msg("[Setup] Elevated setup helper did not start"); return null; } return val2; } catch (object obj) when (((Func)delegate { // Could not convert BlockContainer to single expression object obj2 = ((obj is Win32Exception) ? obj : null); return obj2 != null && ((Win32Exception)obj2).NativeErrorCode == 1223; }).Invoke()) { Log.Msg("[Setup] Administrator setup was cancelled by the user"); } catch (global::System.Exception ex) { Log.Msg("[Setup] Failed to start elevated setup helper: " + ex.Message); } return null; } private static string BuildElevatedSetupScript(global::System.Collections.Generic.IReadOnlyCollection actions, string runtimeDir, string logPath) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown StringBuilder val = new StringBuilder(); val.AppendLine("$ErrorActionPreference = 'Continue'"); StringBuilder val2 = val; StringBuilder obj = val2; AppendInterpolatedStringHandler val3 = default(AppendInterpolatedStringHandler); ((AppendInterpolatedStringHandler)(ref val3))..ctor(11, 1, val2); ((AppendInterpolatedStringHandler)(ref val3)).AppendLiteral("$runtime = "); ((AppendInterpolatedStringHandler)(ref val3)).AppendFormatted(PsSingleQuote(runtimeDir)); obj.AppendLine(ref val3); val2 = val; StringBuilder obj2 = val2; ((AppendInterpolatedStringHandler)(ref val3))..ctor(7, 1, val2); ((AppendInterpolatedStringHandler)(ref val3)).AppendLiteral("$log = "); ((AppendInterpolatedStringHandler)(ref val3)).AppendFormatted(PsSingleQuote(logPath)); obj2.AppendLine(ref val3); val.AppendLine("New-Item -ItemType Directory -Force -Path (Split-Path -Parent $log) | Out-Null"); val.AppendLine("\"[{0:yyyy-MM-dd HH:mm:ss}] DesktopBuddy elevated setup started\" -f (Get-Date) | Set-Content -LiteralPath $log"); val.AppendLine("function Write-SetupLog([string]$Message) { Add-Content -LiteralPath $log -Value (\"[{0:HH:mm:ss}] {1}\" -f (Get-Date), $Message) }"); val.AppendLine("function Run-SetupProcess([string]$File, [string]$Arguments, [string]$WorkingDirectory = $runtime, [int]$TimeoutMs = 60000) {"); val.AppendLine(" Write-SetupLog ($File + ' ' + $Arguments)"); val.AppendLine(" try {"); val.AppendLine(" $process = Start-Process -FilePath $File -ArgumentList $Arguments -WorkingDirectory $WorkingDirectory -WindowStyle Hidden -PassThru"); val.AppendLine(" if (-not $process.WaitForExit($TimeoutMs)) { try { $process.Kill() } catch {}; Write-SetupLog ($File + ' timed out'); return }"); val.AppendLine(" Write-SetupLog ($File + ' exit=' + $process.ExitCode)"); val.AppendLine(" } catch { Write-SetupLog ($File + ' failed: ' + $_.Exception.Message) }"); val.AppendLine("}"); val2 = val; StringBuilder obj3 = val2; ((AppendInterpolatedStringHandler)(ref val3))..ctor(16, 1, val2); ((AppendInterpolatedStringHandler)(ref val3)).AppendLiteral("$softCamClsid = "); ((AppendInterpolatedStringHandler)(ref val3)).AppendFormatted(PsSingleQuote("{AEF3B972-5FA5-4647-9571-358EB472BC9E}")); obj3.AppendLine(ref val3); val2 = val; StringBuilder obj4 = val2; ((AppendInterpolatedStringHandler)(ref val3))..ctor(27, 1, val2); ((AppendInterpolatedStringHandler)(ref val3)).AppendLiteral("$videoInputCategoryClsid = "); ((AppendInterpolatedStringHandler)(ref val3)).AppendFormatted(PsSingleQuote("{860BB310-5D01-11d0-BD3B-00A0C911CE86}")); obj4.AppendLine(ref val3); global::System.Collections.Generic.IEnumerator enumerator = ((global::System.Collections.Generic.IEnumerable)actions).GetEnumerator(); try { while (((global::System.Collections.IEnumerator)enumerator).MoveNext()) { switch (enumerator.Current) { case SetupAction.SoftCamRegistration: AppendSoftCamRegistrationScript(val); break; case SetupAction.VBCableInstall: AppendVBCableInstallScript(val); break; case SetupAction.VBCableLoopback: AppendVBCableLoopbackScript(val); break; case SetupAction.UrlAcl: AppendUrlAclScript(val); break; } } } finally { ((global::System.IDisposable)enumerator)?.Dispose(); } AppendSetupHashScript(val); val.AppendLine("Write-SetupLog 'DesktopBuddy elevated setup finished'"); return ((object)val).ToString(); } private static void AppendSoftCamRegistrationScript(StringBuilder script) { script.AppendLine("Write-SetupLog 'Registering SoftCam'"); script.AppendLine("$softCamCandidates = @((Join-Path $runtime 'softcam64.dll'), (Join-Path $runtime 'softcam.dll'))"); script.AppendLine("foreach ($candidate in $softCamCandidates) { if (Test-Path -LiteralPath $candidate) { Run-SetupProcess 'regsvr32.exe' ('/s /u \"' + $candidate + '\"') $runtime 10000 } }"); script.AppendLine("$softCamKeys = @("); script.AppendLine(" 'HKCU:\\Software\\Classes\\CLSID\\' + $softCamClsid,"); script.AppendLine(" 'HKCU:\\Software\\Classes\\WOW6432Node\\CLSID\\' + $softCamClsid,"); script.AppendLine(" 'HKLM:\\Software\\Classes\\CLSID\\' + $softCamClsid,"); script.AppendLine(" 'HKLM:\\Software\\Classes\\WOW6432Node\\CLSID\\' + $softCamClsid,"); script.AppendLine(" 'HKCU:\\Software\\Classes\\CLSID\\' + $videoInputCategoryClsid + '\\Instance\\DesktopBuddy - Camera',"); script.AppendLine(" 'HKCU:\\Software\\Classes\\CLSID\\' + $videoInputCategoryClsid + '\\Instance\\DirectShow Softcam',"); script.AppendLine(" 'HKCU:\\Software\\Classes\\WOW6432Node\\CLSID\\' + $videoInputCategoryClsid + '\\Instance\\DesktopBuddy - Camera',"); script.AppendLine(" 'HKCU:\\Software\\Classes\\WOW6432Node\\CLSID\\' + $videoInputCategoryClsid + '\\Instance\\DirectShow Softcam',"); script.AppendLine(" 'HKLM:\\Software\\Classes\\CLSID\\' + $videoInputCategoryClsid + '\\Instance\\DesktopBuddy - Camera',"); script.AppendLine(" 'HKLM:\\Software\\Classes\\CLSID\\' + $videoInputCategoryClsid + '\\Instance\\DirectShow Softcam',"); script.AppendLine(" 'HKLM:\\Software\\Classes\\WOW6432Node\\CLSID\\' + $videoInputCategoryClsid + '\\Instance\\DesktopBuddy - Camera',"); script.AppendLine(" 'HKLM:\\Software\\Classes\\WOW6432Node\\CLSID\\' + $videoInputCategoryClsid + '\\Instance\\DirectShow Softcam'"); script.AppendLine(")"); script.AppendLine("foreach ($key in $softCamKeys) { if (Test-Path -LiteralPath $key) { Remove-Item -LiteralPath $key -Recurse -Force -ErrorAction SilentlyContinue; Write-SetupLog ('Removed registry key ' + $key) } }"); script.AppendLine("$softCamDll = Join-Path $runtime 'softcam64.dll'"); script.AppendLine("if (-not (Test-Path -LiteralPath $softCamDll)) { $softCamDll = Join-Path $runtime 'softcam.dll' }"); script.AppendLine("if (Test-Path -LiteralPath $softCamDll) { Run-SetupProcess 'regsvr32.exe' ('/s \"' + $softCamDll + '\"') $runtime 10000 } else { Write-SetupLog 'SoftCam DLL missing' }"); } private static void AppendVBCableInstallScript(StringBuilder script) { script.AppendLine("Write-SetupLog 'Installing VB-Cable'"); script.AppendLine("$vbCableInstaller = Join-Path $runtime 'VBCABLE_Setup_x64.exe'"); script.AppendLine("if (Test-Path -LiteralPath $vbCableInstaller) { Run-SetupProcess $vbCableInstaller '-i -h' $runtime 60000 } else { Write-SetupLog 'VB-Cable installer missing' }"); } private static void AppendVBCableLoopbackScript(StringBuilder script) { script.AppendLine("Write-SetupLog 'Disabling VB-Cable loopback'"); script.AppendLine("$vbCableKey = 'HKLM:\\Software\\VB-Audio\\Cable'"); script.AppendLine("if (Test-Path -LiteralPath $vbCableKey) {"); script.AppendLine(" Set-ItemProperty -LiteralPath $vbCableKey -Name 'VBAudioCableWDM_LoopBack' -Type DWord -Value 0"); script.AppendLine(" Run-SetupProcess 'net.exe' 'stop \"AudioEndpointBuilder\" /yes' $runtime 15000"); script.AppendLine(" Run-SetupProcess 'net.exe' 'start \"AudioEndpointBuilder\"' $runtime 15000"); script.AppendLine(" Run-SetupProcess 'net.exe' 'stop \"AudioSrv\" /yes' $runtime 15000"); script.AppendLine(" Run-SetupProcess 'net.exe' 'start \"AudioSrv\"' $runtime 15000"); script.AppendLine("} else { Write-SetupLog 'VB-Cable registry key not present yet' }"); } private static void AppendUrlAclScript(StringBuilder script) { script.AppendLine("Write-SetupLog 'Configuring HTTP URL ACL'"); script.AppendLine("Run-SetupProcess 'netsh' 'http add urlacl url=http://+:48080/ sddl=D:(A;;GX;;;S-1-1-0)' $runtime 10000"); } private static void AppendSetupHashScript(StringBuilder script) { script.AppendLine("$packagedHashFile = Join-Path $runtime 'DesktopBuddySetupPayloads.md5'"); script.AppendLine("$hashFile = Join-Path $runtime 'DesktopBuddySetupHashes.txt'"); script.AppendLine("if (Test-Path -LiteralPath $packagedHashFile) { Copy-Item -LiteralPath $packagedHashFile -Destination $hashFile -Force; Write-SetupLog ('Wrote setup hash marker ' + $hashFile) }"); script.AppendLine("else { Write-SetupLog 'Packaged setup hash manifest missing' }"); } private static string PsSingleQuote(string value) { return "'" + value.Replace("'", "''") + "'"; } private static void RegisterSoftCam(string runtimeDir) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) Log.Msg("[Setup] Registering SoftCam"); global::System.Collections.Generic.IEnumerator enumerator = GetSoftCamUnregisterCandidates(runtimeDir).GetEnumerator(); try { while (((global::System.Collections.IEnumerator)enumerator).MoveNext()) { string current = enumerator.Current; if (File.Exists(current)) { RunProcess("regsvr32.exe", "/s /u \"" + current + "\"", null, 10000); } } } finally { ((global::System.IDisposable)enumerator)?.Dispose(); } global::System.Collections.Generic.IEnumerator> enumerator2 = GetSoftCamRegistryTrees().GetEnumerator(); try { while (((global::System.Collections.IEnumerator)enumerator2).MoveNext()) { ValueTuple current2 = enumerator2.Current; DeleteRegistryTree(current2.Item1, current2.Item2); } } finally { ((global::System.IDisposable)enumerator2)?.Dispose(); } string text = Path.Combine(runtimeDir, "softcam64.dll"); if (!File.Exists(text)) { text = Path.Combine(runtimeDir, "softcam.dll"); } if (!File.Exists(text)) { Log.Msg("[Setup] SoftCam DLL missing in " + runtimeDir); return; } RunProcess("regsvr32.exe", "/s \"" + text + "\"", null, 10000); Log.Msg(IsSoftCamRegistered(runtimeDir) ? "[Setup] SoftCam registered" : "[Setup] WARNING: SoftCam registration did not resolve to expected path"); } [IteratorStateMachine(typeof(d__29))] private static global::System.Collections.Generic.IEnumerable GetSoftCamUnregisterCandidates(string runtimeDir) { yield return Path.Combine(runtimeDir, "softcam64.dll"); yield return Path.Combine(runtimeDir, "softcam.dll"); global::System.Collections.Generic.IEnumerator enumerator = GetSoftCamRegisteredDlls().GetEnumerator(); try { while (((global::System.Collections.IEnumerator)enumerator).MoveNext()) { yield return enumerator.Current; } } finally { ((global::System.IDisposable)enumerator)?.Dispose(); } } [IteratorStateMachine(typeof(d__30))] private static global::System.Collections.Generic.IEnumerable GetSoftCamRegisteredDlls() { global::System.Collections.Generic.IEnumerator> enumerator = GetSoftCamInprocKeys().GetEnumerator(); try { while (((global::System.Collections.IEnumerator)enumerator).MoveNext()) { ValueTuple current = enumerator.Current; RegistryKey opened = current.Item1.OpenSubKey(current.Item2); try { string text = ((opened != null) ? opened.GetValue("") : null) as string; if (!string.IsNullOrWhiteSpace(text)) { yield return text.Trim('"'); } } finally { ((global::System.IDisposable)opened)?.Dispose(); } } } finally { ((global::System.IDisposable)enumerator)?.Dispose(); } } [IteratorStateMachine(typeof(d__31))] private static global::System.Collections.Generic.IEnumerable> GetSoftCamInprocKeys() { yield return new ValueTuple(Registry.ClassesRoot, "CLSID\\{AEF3B972-5FA5-4647-9571-358EB472BC9E}\\InprocServer32"); yield return new ValueTuple(Registry.CurrentUser, "Software\\Classes\\CLSID\\{AEF3B972-5FA5-4647-9571-358EB472BC9E}\\InprocServer32"); yield return new ValueTuple(Registry.CurrentUser, "Software\\Classes\\WOW6432Node\\CLSID\\{AEF3B972-5FA5-4647-9571-358EB472BC9E}\\InprocServer32"); yield return new ValueTuple(Registry.LocalMachine, "Software\\Classes\\CLSID\\{AEF3B972-5FA5-4647-9571-358EB472BC9E}\\InprocServer32"); yield return new ValueTuple(Registry.LocalMachine, "Software\\Classes\\WOW6432Node\\CLSID\\{AEF3B972-5FA5-4647-9571-358EB472BC9E}\\InprocServer32"); } [IteratorStateMachine(typeof(d__32))] private static global::System.Collections.Generic.IEnumerable> GetSoftCamRegistryTrees() { yield return new ValueTuple(Registry.CurrentUser, "Software\\Classes\\CLSID\\{AEF3B972-5FA5-4647-9571-358EB472BC9E}"); yield return new ValueTuple(Registry.CurrentUser, "Software\\Classes\\WOW6432Node\\CLSID\\{AEF3B972-5FA5-4647-9571-358EB472BC9E}"); yield return new ValueTuple(Registry.LocalMachine, "Software\\Classes\\CLSID\\{AEF3B972-5FA5-4647-9571-358EB472BC9E}"); yield return new ValueTuple(Registry.LocalMachine, "Software\\Classes\\WOW6432Node\\CLSID\\{AEF3B972-5FA5-4647-9571-358EB472BC9E}"); yield return new ValueTuple(Registry.CurrentUser, "Software\\Classes\\CLSID\\{860BB310-5D01-11d0-BD3B-00A0C911CE86}\\Instance\\DesktopBuddy - Camera"); yield return new ValueTuple(Registry.CurrentUser, "Software\\Classes\\CLSID\\{860BB310-5D01-11d0-BD3B-00A0C911CE86}\\Instance\\DirectShow Softcam"); yield return new ValueTuple(Registry.CurrentUser, "Software\\Classes\\WOW6432Node\\CLSID\\{860BB310-5D01-11d0-BD3B-00A0C911CE86}\\Instance\\DesktopBuddy - Camera"); yield return new ValueTuple(Registry.CurrentUser, "Software\\Classes\\WOW6432Node\\CLSID\\{860BB310-5D01-11d0-BD3B-00A0C911CE86}\\Instance\\DirectShow Softcam"); yield return new ValueTuple(Registry.LocalMachine, "Software\\Classes\\CLSID\\{860BB310-5D01-11d0-BD3B-00A0C911CE86}\\Instance\\DesktopBuddy - Camera"); yield return new ValueTuple(Registry.LocalMachine, "Software\\Classes\\CLSID\\{860BB310-5D01-11d0-BD3B-00A0C911CE86}\\Instance\\DirectShow Softcam"); yield return new ValueTuple(Registry.LocalMachine, "Software\\Classes\\WOW6432Node\\CLSID\\{860BB310-5D01-11d0-BD3B-00A0C911CE86}\\Instance\\DesktopBuddy - Camera"); yield return new ValueTuple(Registry.LocalMachine, "Software\\Classes\\WOW6432Node\\CLSID\\{860BB310-5D01-11d0-BD3B-00A0C911CE86}\\Instance\\DirectShow Softcam"); } private static void DeleteRegistryTree(RegistryKey root, string subKey) { try { root.DeleteSubKeyTree(subKey, false); Log.Msg("[Setup] Removed registry key " + root.Name + "\\" + subKey); } catch (global::System.Exception ex) { Log.Msg($"[Setup] Unable to remove registry key {root.Name}\\{subKey}: {ex.Message}"); } } private static bool IsSoftCamRegistered(string runtimeDir) { RegistryKey val = Registry.ClassesRoot.OpenSubKey("CLSID\\{AEF3B972-5FA5-4647-9571-358EB472BC9E}\\InprocServer32"); try { string text = ((val != null) ? val.GetValue("") : null) as string; if (string.IsNullOrWhiteSpace(text)) { return false; } string text2 = Path.Combine(runtimeDir, "softcam64.dll"); return string.Equals(text.Trim('"'), text2, (StringComparison)5); } finally { ((global::System.IDisposable)val)?.Dispose(); } } private static void WriteSetupHashes(string runtimeDir) { try { Directory.CreateDirectory(runtimeDir); string text = Path.Combine(runtimeDir, "DesktopBuddySetupPayloads.md5"); if (File.Exists(text)) { File.Copy(text, Path.Combine(runtimeDir, "DesktopBuddySetupHashes.txt"), true); } } catch (global::System.Exception ex) { Log.Msg("[Setup] Failed to write setup hash marker: " + ex.Message); } } private static string ReadSetupHash(string runtimeDir, string fileName) { return ReadHashFile(Path.Combine(runtimeDir, "DesktopBuddySetupHashes.txt"), fileName); } private static string ReadPackagedSetupHash(string runtimeDir, string fileName) { return ReadHashFile(Path.Combine(runtimeDir, "DesktopBuddySetupPayloads.md5"), fileName); } private static string ReadHashFile(string path, string fileName) { if (string.IsNullOrWhiteSpace(path) || string.IsNullOrWhiteSpace(fileName)) { return null; } try { if (!File.Exists(path)) { return null; } global::System.Collections.Generic.IEnumerator enumerator = File.ReadLines(path).GetEnumerator(); try { while (((global::System.Collections.IEnumerator)enumerator).MoveNext()) { string current = enumerator.Current; int num = current.IndexOf('='); if (num > 0 && string.Equals(current.Substring(0, num).Trim(), fileName, (StringComparison)5)) { return current.Substring(num + 1).Trim(); } } } finally { ((global::System.IDisposable)enumerator)?.Dispose(); } } catch (global::System.Exception ex) { Log.Msg("[Setup] Failed to read setup hash marker: " + ex.Message); } return null; } private static bool PathsEqual(string left, string right) { if (string.IsNullOrWhiteSpace(left) || string.IsNullOrWhiteSpace(right)) { return false; } try { left = Path.GetFullPath(left.Trim('"')); right = Path.GetFullPath(right.Trim('"')); } catch { left = left.Trim('"'); right = right.Trim('"'); } return string.Equals(left, right, (StringComparison)5); } private static global::System.Collections.Generic.IReadOnlyList GetRunningRestartSensitiveProcesses() { HashSet val = new HashSet((global::System.Collections.Generic.IEnumerable)new string[16] { "Discord", "DiscordCanary", "DiscordPTB", "obs64", "obs32", "zoom", "Teams", "ms-teams", "chrome", "msedge", "firefox", "brave", "slack", "Skype", "Webex", "ManyCam" }, (IEqualityComparer)(object)StringComparer.OrdinalIgnoreCase); SortedSet val2 = new SortedSet((IComparer)(object)StringComparer.OrdinalIgnoreCase); try { Process[] processes = Process.GetProcesses(); foreach (Process val3 in processes) { Process val4 = val3; try { string processName = val3.ProcessName; if (val.Contains(processName)) { val2.Add(processName); } } finally { ((global::System.IDisposable)val4)?.Dispose(); } } } catch { } return Enumerable.ToArray((global::System.Collections.Generic.IEnumerable)val2); } private static void InstallVBCable(string runtimeDir) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) string text = Path.Combine(runtimeDir, "VBCABLE_Setup_x64.exe"); if (!File.Exists(text)) { Log.Msg("[Setup] VB-Cable installer missing at " + text); return; } RunProcess(text, "-i -h", runtimeDir); Log.Msg(IsVBCableInstalled() ? "[Setup] VB-Cable detected" : "[Setup] VB-Cable not detected yet; reboot may be required"); } private static bool IsVBCableInstalled() { RegistryKey val = Registry.LocalMachine.OpenSubKey("Software\\VB-Audio\\Cable"); try { return val != null; } finally { ((global::System.IDisposable)val)?.Dispose(); } } private static void ConfigureVBCableLoopback() { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) RegistryKey val = Registry.LocalMachine.OpenSubKey("Software\\VB-Audio\\Cable", true); try { if (val == null) { Log.Msg("[Setup] VB-Cable registry key not present yet"); return; } if (val.GetValue("VBAudioCableWDM_LoopBack") as int? == 0) { Log.Msg("[Setup] VB-Cable loopback already disabled"); return; } val.SetValue("VBAudioCableWDM_LoopBack", (object)0, (RegistryValueKind)4); Log.Msg("[Setup] VB-Cable loopback disabled"); RunProcess("net.exe", "stop \"AudioEndpointBuilder\" /yes", null, 15000); RunProcess("net.exe", "start \"AudioEndpointBuilder\"", null, 15000); RunProcess("net.exe", "stop \"AudioSrv\" /yes", null, 15000); RunProcess("net.exe", "start \"AudioSrv\"", null, 15000); } finally { ((global::System.IDisposable)val)?.Dispose(); } } private static bool IsVBCableLoopbackDisabled() { RegistryKey val = Registry.LocalMachine.OpenSubKey("Software\\VB-Audio\\Cable"); try { return ((val != null) ? val.GetValue("VBAudioCableWDM_LoopBack") : null) as int? == 0; } finally { ((global::System.IDisposable)val)?.Dispose(); } } private static void ConfigureUrlAcl() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (IsUrlAclConfigured()) { Log.Msg("[Setup] HTTP URL ACL already configured"); return; } RunProcess("netsh", "http add urlacl url=http://+:48080/ sddl=D:(A;;GX;;;S-1-1-0)", null, 10000); Log.Msg(IsUrlAclConfigured() ? "[Setup] HTTP URL ACL added" : "[Setup] WARNING: HTTP URL ACL was not detected after setup"); } private static bool IsUrlAclConfigured() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) ValueTuple val = RunProcess("netsh", "http show urlacl url=http://+:48080/", null, 10000, captureOutput: true); if (val.Item1 == 0) { return val.Item2.Contains("48080", (StringComparison)5); } return false; } private static ValueTuple RunProcess(string fileName, string arguments, string workingDirectory = null, int timeoutMs = 60000, bool captureOutput = false) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) Process val = Process.Start(new ProcessStartInfo { FileName = fileName, Arguments = arguments, WorkingDirectory = (workingDirectory ?? ResolveResoniteRoot()), UseShellExecute = false, CreateNoWindow = true, RedirectStandardOutput = captureOutput, RedirectStandardError = captureOutput, WindowStyle = (ProcessWindowStyle)1 }); try { if (val == null) { return new ValueTuple(-1, ""); } if (!val.WaitForExit(timeoutMs)) { try { val.Kill(); } catch { } Log.Msg("[Setup] " + fileName + " timed out"); return new ValueTuple(-1, ""); } string text = ""; if (captureOutput) { text = (((TextReader)val.StandardOutput).ReadToEnd() + "\n" + ((TextReader)val.StandardError).ReadToEnd()).Trim(); } Log.Msg($"[Setup] {fileName} {arguments} exit={val.ExitCode}"); return new ValueTuple(val.ExitCode, text); } finally { ((global::System.IDisposable)val)?.Dispose(); } } private static bool IsAdministrator() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) WindowsIdentity current = WindowsIdentity.GetCurrent(); try { return new WindowsPrincipal(current).IsInRole((WindowsBuiltInRole)544); } finally { ((global::System.IDisposable)current)?.Dispose(); } } private static string GetRuntimeDir() { return DesktopBuddyRuntimePaths.GetDirectory(); } private static string ResolveResoniteRoot() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown string text = Path.GetDirectoryName(typeof(DesktopBuddyMod).Assembly.Location) ?? "."; for (DirectoryInfo val = new DirectoryInfo(text); val != null; val = val.Parent) { if (File.Exists(Path.Combine(((FileSystemInfo)val).FullName, "Resonite.exe"))) { return ((FileSystemInfo)val).FullName; } } return AppDomain.CurrentDomain.BaseDirectory ?? text; } } [ResonitePlugin("com.devl0rd.DesktopBuddy", "DesktopBuddy", "1.1.0", "DevL0rd", "https://github.com/DevL0rd/DesktopBuddy")] [BepInPlugin("com.devl0rd.DesktopBuddy", "DesktopBuddy", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class DesktopBuddyMod : BasePlugin { [UnmanagedFunctionPointer(/*Could not decode attribute arguments.*/)] private delegate int UnhandledExceptionFilterDelegate(nint exceptionPointers); private struct JOBOBJECT_BASIC_LIMIT_INFORMATION { public long PerProcessUserTimeLimit; public long PerJobUserTimeLimit; public uint LimitFlags; public nuint MinimumWorkingSetSize; public nuint MaximumWorkingSetSize; public uint ActiveProcessLimit; public long Affinity; public uint PriorityClass; public uint SchedulingClass; } private struct IO_COUNTERS { public ulong ReadOperationCount; public ulong WriteOperationCount; public ulong OtherOperationCount; public ulong ReadTransferCount; public ulong WriteTransferCount; public ulong OtherTransferCount; } private struct JOBOBJECT_EXTENDED_LIMIT_INFORMATION { public JOBOBJECT_BASIC_LIMIT_INFORMATION BasicLimitInformation; public IO_COUNTERS IoInfo; public nuint ProcessMemoryLimit; public nuint JobMemoryLimit; public nuint PeakProcessMemoryUsed; public nuint PeakJobMemoryUsed; } private sealed class SetupStatusRowRefs { public Text Name; public Text Detail; public Text Status; public Image Badge; } [CompilerGenerated] private static class <>O { public static Action <0>__Msg; public static ThreadStart <1>__WindowPollerLoop; public static ResolveEventHandler <2>__ResolveDesktopBuddyManagedDependency; public static UnhandledExceptionFilterDelegate <3>__NativeCrashFilter; public static Func <4>__IsGitHubReleaseNotFound; public static Action <5>__CloseSetupPanel; public static Action <6>__PollSetupInstall; } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnhandledExceptionEventHandler <>9__13_0; public static EventHandler <>9__13_1; public static Action <>9__14_0; public static Action <>9__14_1; public static Action <>9__14_2; public static EventHandler <>9__15_0; public static Action <>9__249_0; public static DataReceivedEventHandler <>9__250_1; public static DataReceivedEventHandler <>9__250_2; public static Action <>9__261_0; public static Predicate <>9__281_10; public static Predicate <>9__281_14; public static ButtonEventHandler <>9__282_0; public static Func <>9__312_0; public static Action <>9__355_0; public static Action <>9__355_1; public static Action <>9__355_2; public static Action <>9__355_3; public static Action <>9__355_4; public static Action <>9__355_5; public static Action <>9__355_6; public static Action <>9__355_7; public static Action <>9__355_8; public static Action <>9__355_9; public static Action <>9__355_10; public static Action <>9__355_11; public static Action <>9__355_12; public static Action <>9__355_13; public static Action <>9__355_14; public static Action <>9__355_15; public static Action <>9__375_0; public static Action <>9__375_1; public static Action <>9__379_0; public static Action <>9__379_1; public static Action <>9__379_2; public static Action <>9__379_3; public static Action <>9__379_4; public static Action <>9__379_5; public static Action <>9__379_6; public static Action <>9__393_1; public static Action <>9__393_2; public static Action <>9__393_3; public static Func, ValueTuple> <>9__405_0; public static Func, ValueTuple> <>9__405_2; public static Func <>9__405_6; public static Func <>9__405_7; public static Func, WgcCapture.GpuAdapterInfo> <>9__405_8; public static Func> <>9__405_9; public static Func <>9__450_0; public static Func <>9__450_1; public static Func <>9__451_1; public static Func <>9__451_3; public static Func, DesktopSession> <>9__451_2; public static Func <>9__461_1; public static Func <>9__461_2; public static Action <>9__477_0; public static Func <>9__488_0; internal void b__13_0(object sender, UnhandledExceptionEventArgs e) { Log.Msg($"UNHANDLED EXCEPTION (terminating={e.IsTerminating}):\n{e.ExceptionObject}"); } internal void b__13_1(object? sender, UnobservedTaskExceptionEventArgs e) { Log.Msg($"UNOBSERVED TASK EXCEPTION:\n{e.Exception}"); e.SetObserved(); } internal void b__14_0() { StartTunnel(); } internal void b__14_1() { try { if (SoftCam.IsFilterRegistered()) { VCam = new VirtualCamera(); VCam.StartIdle(); } else { Msg("[VirtualCamera] DirectShow filter not registered, virtual camera unavailable"); } } catch (global::System.Exception ex) { Msg("[VirtualCamera] Setup error: " + ex.Message); } try { if (!VBCable.HasCableInputDevice()) { Msg("[VirtualMic] VB-Cable not installed, virtual mic unavailable"); } } catch (global::System.Exception ex2) { Msg("[VirtualMic] Setup error: " + ex2.Message); } } internal void b__14_2() { try { VirtualCamera virtualCamera = new VirtualCamera(); if (virtualCamera.StartIdle()) { VCam = virtualCamera; Msg("[VirtualCamera] Linux v4l2 virtual camera ready"); } else { virtualCamera.Dispose(); Msg("[VirtualCamera] Linux virtual camera unavailable; run setup in the Devices tab"); } } catch (global::System.Exception ex) { Msg("[VirtualCamera] Linux setup error: " + ex.Message); } } internal void b__15_0(object? s, EventArgs e) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) HashSet val = new HashSet(); Enumerator enumerator = ActiveSessions.GetEnumerator(); try { while (enumerator.MoveNext()) { DesktopSession current = enumerator.Current; if (!DesktopBuddyPlatform.IsLinux && current.OwnsAudioRedirect && current.ProcessId != 0 && val.Add(current.ProcessId)) { AudioRouter.ResetProcessToDefault(current.ProcessId); } } } finally { ((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } KillTunnel(); RemovePortForwardNatMapping(); try { StreamServer?.Dispose(); } catch { } } internal void b__249_0() { try { Msg("[Tunnel] === RESTART ==="); KillTunnel(); TunnelUrl = null; Thread.Sleep(2000); StartTunnel(); } catch (global::System.Exception ex) { Msg($"[Tunnel] Restart task error: {ex}"); } finally { _tunnelRestarting = false; } } internal void b__250_1(object s, DataReceivedEventArgs e) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) if (e.Data == null) { return; } if (e.Data.Contains("https://") && e.Data.Contains(".trycloudflare.com")) { int num = e.Data.IndexOf("https://"); string text = e.Data.Substring(num).Trim(); int num2 = text.IndexOf(' '); if (num2 > 0) { text = text.Substring(0, num2); } try { text = new Uri(text).GetLeftPart((UriPartial)1); } catch (global::System.Exception ex) { Msg("[Tunnel] URL parse error: " + ex.Message); } string tunnelUrl = TunnelUrl; TunnelUrl = text; if (tunnelUrl != text) { Msg("[Tunnel] PUBLIC URL: " + TunnelUrl); try { UpdateSessionTunnelUrls(); } catch (global::System.Exception ex2) { Msg($"[Tunnel] PUBLIC URL refresh error: {ex2}"); } } } else if (ShouldLogCloudflaredLine(e.Data)) { Msg("[Tunnel] " + e.Data); } OnTunnelError(e.Data); } internal void b__250_2(object s, DataReceivedEventArgs e) { if (e.Data != null && ShouldLogCloudflaredLine(e.Data)) { Msg("[Tunnel] " + e.Data); } } internal void b__261_0() { StartTunnel(); } internal bool b__281_10(Image image) { return ((Component)image).Slot.Name == "Background"; } internal bool b__281_14(Image image) { return ((Component)image).Slot.Name == "Background"; } internal void b__282_0(IButton b, ButtonEventData d) { if (VCam == null) { Msg("[VirtualCamera] Not available"); return; } VCam.ManuallyDisabled = !VCam.ManuallyDisabled; Msg("[VirtualCamera] " + (VCam.ManuallyDisabled ? "Disabled" : "Enabled")); } internal bool b__312_0(User u) { return u.IsPresentInWorld; } internal void b__355_0(string value) { SaveConfigValue(StreamAudioGlobalMode, NormalizeStreamAudioGlobalMode(value)); ApplyStreamAudioSettingsToAllSessions(); } internal void b__355_1(bool value) { SaveConfigValue(StreamAudioSpatialize, value); ApplyStreamAudioSettingsToAllSessions(); } internal void b__355_2(float value) { SaveConfigValue(StreamAudioSpatialBlend, Math.Clamp(value, 0f, 1f)); ApplyStreamAudioSettingsToAllSessions(); } internal void b__355_3(string value) { SaveConfigValue(StreamAudioDistanceSpace, NormalizeStreamAudioDistanceSpace(value)); ApplyStreamAudioSettingsToAllSessions(); } internal void b__355_4(string value) { SaveConfigValue(StreamAudioRolloffMode, NormalizeStreamAudioRolloffMode(value)); ApplyStreamAudioSettingsToAllSessions(); } internal void b__355_5(float value) { SaveConfigValue(StreamAudioMinDistance, Math.Clamp(value, 0f, 10f)); ApplyStreamAudioSettingsToAllSessions(); } internal void b__355_6(float value) { SaveConfigValue(StreamAudioMaxDistance, Math.Clamp(value, 1f, 50f)); ApplyStreamAudioSettingsToAllSessions(); } internal void b__355_7(float value) { SaveConfigValue(StreamAudioSpatializationStartDistance, Math.Clamp(value, 0f, 10f)); ApplyStreamAudioSettingsToAllSessions(); } internal void b__355_8(float value) { SaveConfigValue(StreamAudioSpatializationTransitionRange, Math.Clamp(value, 0f, 10f)); ApplyStreamAudioSettingsToAllSessions(); } internal void b__355_9(float value) { SaveConfigValue(StreamAudioMinScale, Math.Clamp(value, 0f, 1000f)); ApplyStreamAudioSettingsToAllSessions(); } internal void b__355_10(float value) { SaveConfigValue(StreamAudioMaxScale, Math.Clamp(value, 0f, 1000f)); ApplyStreamAudioSettingsToAllSessions(); } internal void b__355_11(string value) { SaveConfigValue(StreamAudioTypeGroup, NormalizeStreamAudioTypeGroup(value)); ApplyStreamAudioSettingsToAllSessions(); } internal void b__355_12(bool value) { SaveConfigValue(StreamAudioIgnoreAudioEffects, value); ApplyStreamAudioSettingsToAllSessions(); } internal void b__355_13(float value) { SaveConfigValue(StreamAudioPitch, Math.Clamp(value, 0.5f, 2f)); ApplyStreamAudioSettingsToAllSessions(); } internal void b__355_14(float value) { SaveConfigValue(StreamAudioDopplerLevel, Math.Clamp(value, 0f, 1f)); ApplyStreamAudioSettingsToAllSessions(); } internal void b__355_15(int value) { SaveConfigValue(StreamAudioPriority, Math.Clamp(value, 0, 256)); ApplyStreamAudioSettingsToAllSessions(); } internal void b__375_0(bool value) { if (VCam != null) { VCam.ManuallyDisabled = !value; } } internal void b__375_1() { LinuxVirtualCameraSetup.Run(); } internal void b__379_0(bool value) { SaveConfigValue(ShowContextMenuItem, value); } internal void b__379_1(bool value) { SaveConfigValue(ThrowToDestroy, value); } internal void b__379_2(bool value) { SaveConfigValue(DynamicLightsEnabled, value); } internal void b__379_3(bool value) { SaveConfigValue(SpawnNewWindowsInGame, value); } internal void b__379_4(bool value) { SaveConfigValue(SpawnNewWindowsPrivate, value); } internal void b__379_5(bool value) { SaveConfigValue(NewWindowsStartPrivate, value); } internal void b__379_6(bool value) { SaveConfigValue(SpatialAudioEnabled, value); } internal void b__393_1(bool value) { SaveConfigValue(PortForwardUseNat, value); ApplyStreamNetworkMode(); } internal void b__393_2(string value) { SaveConfigValue(PortForwardHostMode, NormalizePortForwardHostMode(value)); ApplyStreamNetworkMode(); } internal void b__393_3(string value) { SaveConfigValue(PortForwardHost, value.Trim()); ApplyStreamNetworkMode(); } internal ValueTuple b__405_0(ValueTuple option) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) return new ValueTuple(option.Item1.ToString((IFormatProvider)(object)CultureInfo.InvariantCulture), option.Item2); } internal ValueTuple b__405_2(ValueTuple option) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) return new ValueTuple(option.Item1.ToString((IFormatProvider)(object)CultureInfo.InvariantCulture), option.Item2); } internal bool b__405_6(WgcCapture.GpuAdapterInfo g) { if (!g.IsBasicRenderDriver) { return !string.IsNullOrWhiteSpace(g.Name); } return false; } internal string b__405_7(WgcCapture.GpuAdapterInfo g) { return NormalizeGpuDisplayName(g.Name); } internal WgcCapture.GpuAdapterInfo b__405_8(IGrouping group) { return Enumerable.First((global::System.Collections.Generic.IEnumerable)group); } internal ValueTuple b__405_9(WgcCapture.GpuAdapterInfo gpu) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) return new ValueTuple("0x" + gpu.Luid.ToString("X16", (IFormatProvider)(object)CultureInfo.InvariantCulture), NormalizeGpuDisplayName(gpu.Name)); } internal bool b__450_0(User u) { return u.IsPresentInWorld; } internal string b__450_1(User u) { return u.UserName; } internal int b__451_1(DesktopSession s) { return s.StreamId; } internal DesktopSession b__451_2(IGrouping group) { global::System.Collections.Generic.IEnumerator enumerator = ((global::System.Collections.Generic.IEnumerable)group).GetEnumerator(); try { while (((global::System.Collections.IEnumerator)enumerator).MoveNext()) { DesktopSession current = enumerator.Current; DesktopSession sharedStreamDriver = GetSharedStreamDriver(current.Hwnd, current.StreamId); if (sharedStreamDriver != null && Enumerable.Contains((global::System.Collections.Generic.IEnumerable)group, sharedStreamDriver)) { return sharedStreamDriver; } } } finally { ((global::System.IDisposable)enumerator)?.Dispose(); } return Enumerable.FirstOrDefault((global::System.Collections.Generic.IEnumerable)group, (Func)((DesktopSession s) => s.Streamer != null)) ?? Enumerable.First((global::System.Collections.Generic.IEnumerable)group); } internal bool b__451_3(DesktopSession s) { return s.Streamer != null; } internal bool b__461_1(User u) { return u.IsPresentInWorld; } internal string b__461_2(User u) { return u.UserName; } internal void b__477_0(IDestroyable _) { bool num = _setupCompleteAwaitingClose && !_setupNoticeDismissed; if (_setupPanelRoot != null && ((ContainerWorker)(object)_setupPanelRoot).IsDestroyed) { _setupPanelRoot = null; } _setupPanelCanvas = null; _setupBodyText = null; _setupInstallButtonSlot = null; _setupStatusRows.Clear(); if (num) { Msg("[SetupPanel] Setup panel closed after completion; continuing DesktopBuddy initialization"); _setupNoticeDismissed = true; _setupCompleteAwaitingClose = false; EnsureDependencyRuntimeStarted(); } } internal bool b__488_0(DesktopBuddyFirstRunSetup.SetupItem item) { if (!item.IsOk) { return !item.RequiresAdminAction; } return false; } internal bool <.cctor>b__499_0() { return false; } internal bool <.cctor>b__499_1() { return true; } internal bool <.cctor>b__499_2() { return true; } internal bool <.cctor>b__499_3() { return true; } internal bool <.cctor>b__499_4() { return true; } internal bool <.cctor>b__499_5() { return true; } internal bool <.cctor>b__499_6() { return false; } internal bool <.cctor>b__499_7() { return false; } internal int <.cctor>b__499_8() { return 10; } internal int <.cctor>b__499_9() { return 60; } internal int <.cctor>b__499_10() { return 2560; } internal bool <.cctor>b__499_11() { return false; } internal string <.cctor>b__499_12() { return ""; } internal int <.cctor>b__499_13() { return 8554; } internal string <.cctor>b__499_14() { return ""; } internal string <.cctor>b__499_15() { return "cloudflare"; } internal string <.cctor>b__499_16() { return "auto"; } internal string <.cctor>b__499_17() { return "external"; } internal string <.cctor>b__499_18() { return ""; } internal bool <.cctor>b__499_19() { return false; } internal string <.cctor>b__499_20() { return ""; } internal string <.cctor>b__499_21() { return ""; } internal string <.cctor>b__499_22() { return "frustum"; } internal bool <.cctor>b__499_23() { return false; } internal float <.cctor>b__499_24() { return 120f; } internal float <.cctor>b__499_25() { return 3f; } internal float <.cctor>b__499_26() { return 3f; } internal string <.cctor>b__499_27() { return "auto"; } internal string <.cctor>b__499_28() { return ""; } internal float <.cctor>b__499_29() { return 0f; } internal string <.cctor>b__499_30() { return "positional"; } internal bool <.cctor>b__499_31() { return true; } internal float <.cctor>b__499_32() { return 1f; } internal string <.cctor>b__499_33() { return "global"; } internal float <.cctor>b__499_34() { return 0f; } internal float <.cctor>b__499_35() { return 1f; } internal bool <.cctor>b__499_36() { return true; } internal string <.cctor>b__499_37() { return "multimedia"; } internal string <.cctor>b__499_38() { return "linear"; } internal float <.cctor>b__499_39() { return 1f; } internal float <.cctor>b__499_40() { return 30f; } internal float <.cctor>b__499_41() { return 0.01f; } internal float <.cctor>b__499_42() { return 0.01f; } internal int <.cctor>b__499_43() { return 128; } internal float <.cctor>b__499_44() { return 0f; } internal float <.cctor>b__499_45() { return 1000f; } } [CompilerGenerated] private sealed class <>c__DisplayClass281_1 { [StructLayout((LayoutKind)3)] private struct <b__34>d : IAsyncStateMachine { public int <>1__state; public AsyncTaskMethodBuilder <>t__builder; public <>c__DisplayClass281_1 <>4__this; private <>c__DisplayClass281_2 <>8__1; private ConfiguredTaskAwaiter <>u__1; private void MoveNext() { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Expected O, but got Unknown //IL_012f: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; <>c__DisplayClass281_1 <>c__DisplayClass281_ = <>4__this; try { try { ConfiguredTaskAwaiter val2; if (num != 0) { <>8__1 = new <>c__DisplayClass281_2(); <>8__1.CS$<>8__locals1 = <>c__DisplayClass281_; Bitmap2D val = new Bitmap2D(<>c__DisplayClass281_.data, <>c__DisplayClass281_.texW, <>c__DisplayClass281_.texH, (TextureFormat)18, false, (ColorProfile)0, false, (string)null); val2 = <>c__DisplayClass281_.engine.LocalDB.SaveAssetAsync(val, "webp", 2147483647, true).ConfigureAwait(false).GetAwaiter(); if (!val2.IsCompleted) { num = (<>1__state = 0); <>u__1 = val2; ((AsyncTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted, <b__34>d>(ref val2, ref this); return; } } else { val2 = <>u__1; <>u__1 = default(ConfiguredTaskAwaiter); num = (<>1__state = -1); } Uri result = val2.GetResult(); <>8__1.uri = result; if (!(<>8__1.uri == (Uri)null)) { World world = ((Worker)<>c__DisplayClass281_.tex).World; if (world != null && !((ComponentBase)(object)<>c__DisplayClass281_.tex).IsDestroyed && !((ComponentBase)(object)<>c__DisplayClass281_.blur).IsDestroyed) { world.RunInUpdates(0, (Action)delegate { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) if (!((ComponentBase)(object)<>8__1.CS$<>8__locals1.tex).IsDestroyed && !((ComponentBase)(object)<>8__1.CS$<>8__locals1.blur).IsDestroyed) { ((SyncField)(object)((StaticAssetProvider)(object)<>8__1.CS$<>8__locals1.tex).URL).Value = <>8__1.uri; ((SyncRef>)(object)<>8__1.CS$<>8__locals1.blur.SpreadMagnitudeTexture).Target = (IAssetProvider)(object)<>8__1.CS$<>8__locals1.tex; ((SyncField)(object)<>8__1.CS$<>8__locals1.blur.SpreadTextureScale).Value = float2.One; ((SyncField)(object)<>8__1.CS$<>8__locals1.blur.SpreadTextureOffset).Value = float2.Zero; } }); <>8__1 = null; } } } catch (global::System.Exception ex) { Msg("[TopBar] Blur mask generation failed: " + ex.Message); } } catch (global::System.Exception exception) { <>1__state = -2; ((AsyncTaskMethodBuilder)(ref <>t__builder)).SetException(exception); return; } <>1__state = -2; ((AsyncTaskMethodBuilder)(ref <>t__builder)).SetResult(); } [DebuggerHidden] private void SetStateMachine(IAsyncStateMachine stateMachine) { ((AsyncTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine); } } public byte[] data; public int texW; public int texH; public Engine engine; public StaticTexture2D tex; public BlurMaterial blur; [AsyncStateMachine(typeof(<b__34>d))] internal global::System.Threading.Tasks.Task? b__34() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) <b__34>d <b__34>d = default(<b__34>d); <b__34>d.<>t__builder = AsyncTaskMethodBuilder.Create(); <b__34>d.<>4__this = this; <b__34>d.<>1__state = -1; ((AsyncTaskMethodBuilder)(ref <b__34>d.<>t__builder)).Start<<b__34>d>(ref <b__34>d); return ((AsyncTaskMethodBuilder)(ref <b__34>d.<>t__builder)).Task; } } [CompilerGenerated] private sealed class <>c__DisplayClass281_2 { public Uri uri; public <>c__DisplayClass281_1 CS$<>8__locals1; internal void b__35() { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) if (!((ComponentBase)(object)CS$<>8__locals1.tex).IsDestroyed && !((ComponentBase)(object)CS$<>8__locals1.blur).IsDestroyed) { ((SyncField)(object)((StaticAssetProvider)(object)CS$<>8__locals1.tex).URL).Value = uri; ((SyncRef>)(object)CS$<>8__locals1.blur.SpreadMagnitudeTexture).Target = (IAssetProvider)(object)CS$<>8__locals1.tex; ((SyncField)(object)CS$<>8__locals1.blur.SpreadTextureScale).Value = float2.One; ((SyncField)(object)CS$<>8__locals1.blur.SpreadTextureOffset).Value = float2.Zero; } } } [CompilerGenerated] private sealed class <>c__DisplayClass384_0 { [StructLayout((LayoutKind)3)] private struct <b__0>d : IAsyncStateMachine { public int <>1__state; public AsyncTaskMethodBuilder <>t__builder; public <>c__DisplayClass384_0 <>4__this; private <>c__DisplayClass384_1 <>8__1; private ConfiguredTaskAwaiter <>u__1; private void MoveNext() { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; <>c__DisplayClass384_0 <>c__DisplayClass384_ = <>4__this; try { try { ConfiguredTaskAwaiter val2; if (num != 0) { <>8__1 = new <>c__DisplayClass384_1(); <>8__1.CS$<>8__locals1 = <>c__DisplayClass384_; Bitmap2D val = new Bitmap2D(<>c__DisplayClass384_.data, <>c__DisplayClass384_.texW, <>c__DisplayClass384_.texH, (TextureFormat)18, false, (ColorProfile)0, false, (string)null); val2 = <>c__DisplayClass384_.engine.LocalDB.SaveAssetAsync(val, "webp", 2147483647, true).ConfigureAwait(false).GetAwaiter(); if (!val2.IsCompleted) { num = (<>1__state = 0); <>u__1 = val2; ((AsyncTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted, <b__0>d>(ref val2, ref this); return; } } else { val2 = <>u__1; <>u__1 = default(ConfiguredTaskAwaiter); num = (<>1__state = -1); } Uri result = val2.GetResult(); <>8__1.uri = result; if (!(<>8__1.uri == (Uri)null)) { ((Worker)<>c__DisplayClass384_.tex).World.RunInUpdates(0, (Action)delegate { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) if (!((ComponentBase)(object)<>8__1.CS$<>8__locals1.tex).IsDestroyed && !((ComponentBase)(object)<>8__1.CS$<>8__locals1.blur).IsDestroyed) { ((SyncField)(object)((StaticAssetProvider)(object)<>8__1.CS$<>8__locals1.tex).URL).Value = <>8__1.uri; ((SyncRef>)(object)<>8__1.CS$<>8__locals1.blur.SpreadMagnitudeTexture).Target = (IAssetProvider)(object)<>8__1.CS$<>8__locals1.tex; ((SyncField)(object)<>8__1.CS$<>8__locals1.blur.SpreadTextureScale).Value = float2.One; ((SyncField)(object)<>8__1.CS$<>8__locals1.blur.SpreadTextureOffset).Value = float2.Zero; } }); <>8__1 = null; } } catch (global::System.Exception ex) { Msg("[Settings] Blur mask generation failed: " + ex.Message); } } catch (global::System.Exception exception) { <>1__state = -2; ((AsyncTaskMethodBuilder)(ref <>t__builder)).SetException(exception); return; } <>1__state = -2; ((AsyncTaskMethodBuilder)(ref <>t__builder)).SetResult(); } [DebuggerHidden] private void SetStateMachine(IAsyncStateMachine stateMachine) { ((AsyncTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine); } } public byte[] data; public int texW; public int texH; public Engine engine; public StaticTexture2D tex; public BlurMaterial blur; [AsyncStateMachine(typeof(<b__0>d))] internal global::System.Threading.Tasks.Task? b__0() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) <b__0>d <b__0>d = default(<b__0>d); <b__0>d.<>t__builder = AsyncTaskMethodBuilder.Create(); <b__0>d.<>4__this = this; <b__0>d.<>1__state = -1; ((AsyncTaskMethodBuilder)(ref <b__0>d.<>t__builder)).Start<<b__0>d>(ref <b__0>d); return ((AsyncTaskMethodBuilder)(ref <b__0>d.<>t__builder)).Task; } } [CompilerGenerated] private sealed class <>c__DisplayClass384_1 { public Uri uri; public <>c__DisplayClass384_0 CS$<>8__locals1; internal void b__1() { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) if (!((ComponentBase)(object)CS$<>8__locals1.tex).IsDestroyed && !((ComponentBase)(object)CS$<>8__locals1.blur).IsDestroyed) { ((SyncField)(object)((StaticAssetProvider)(object)CS$<>8__locals1.tex).URL).Value = uri; ((SyncRef>)(object)CS$<>8__locals1.blur.SpreadMagnitudeTexture).Target = (IAssetProvider)(object)CS$<>8__locals1.tex; ((SyncField)(object)CS$<>8__locals1.blur.SpreadTextureScale).Value = float2.One; ((SyncField)(object)CS$<>8__locals1.blur.SpreadTextureOffset).Value = float2.Zero; } } } [CompilerGenerated] private sealed class <>c__DisplayClass449_0 { [StructLayout((LayoutKind)3)] private struct <b__0>d : IAsyncStateMachine { public int <>1__state; public AsyncTaskMethodBuilder <>t__builder; public <>c__DisplayClass449_0 <>4__this; private <>c__DisplayClass449_1 <>8__1; private ConfiguredTaskAwaiter> <>u__1; private void MoveNext() { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown //IL_00fe: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; <>c__DisplayClass449_0 <>c__DisplayClass449_ = <>4__this; try { try { ConfiguredTaskAwaiter> val; if (num != 0) { <>8__1 = new <>c__DisplayClass449_1(); <>8__1.CS$<>8__locals1 = <>c__DisplayClass449_; val = ((SkyFrostInterface)<>c__DisplayClass449_.engine.Cloud).Users.GetUserCached(<>c__DisplayClass449_.userId).ConfigureAwait(false).GetAwaiter(); if (!val.IsCompleted) { num = (<>1__state = 0); <>u__1 = val; ((AsyncTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted>, <b__0>d>(ref val, ref this); return; } } else { val = <>u__1; <>u__1 = default(ConfiguredTaskAwaiter>); num = (<>1__state = -1); } CloudResult result = val.GetResult(); if (result != null && ((CloudResult)result).IsOK) { User entity = result.Entity; object obj; if (entity == null) { obj = null; } else { UserProfile profile = entity.Profile; obj = ((profile != null) ? profile.IconUrl : null); } if (Uri.TryCreate((string)obj, (UriKind)1, ref <>8__1.iconUri)) { <>c__DisplayClass449_.world.RunInUpdates(0, (Action)delegate { if (<>8__1.CS$<>8__locals1.avatarRoot != null && !((ContainerWorker)(object)<>8__1.CS$<>8__locals1.avatarRoot).IsDestroyed && <>8__1.CS$<>8__locals1.avatarTex != null && !((ComponentBase)(object)<>8__1.CS$<>8__locals1.avatarTex).IsDestroyed) { ((SyncField)(object)((StaticAssetProvider)(object)<>8__1.CS$<>8__locals1.avatarTex).URL).Value = <>8__1.iconUri; } }); <>8__1 = null; } } } catch { } } catch (global::System.Exception exception) { <>1__state = -2; ((AsyncTaskMethodBuilder)(ref <>t__builder)).SetException(exception); return; } <>1__state = -2; ((AsyncTaskMethodBuilder)(ref <>t__builder)).SetResult(); } [DebuggerHidden] private void SetStateMachine(IAsyncStateMachine stateMachine) { ((AsyncTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine); } } public Engine engine; public string userId; public World world; public Slot avatarRoot; public StaticTexture2D avatarTex; [AsyncStateMachine(typeof(<b__0>d))] internal global::System.Threading.Tasks.Task? b__0() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) <b__0>d <b__0>d = default(<b__0>d); <b__0>d.<>t__builder = AsyncTaskMethodBuilder.Create(); <b__0>d.<>4__this = this; <b__0>d.<>1__state = -1; ((AsyncTaskMethodBuilder)(ref <b__0>d.<>t__builder)).Start<<b__0>d>(ref <b__0>d); return ((AsyncTaskMethodBuilder)(ref <b__0>d.<>t__builder)).Task; } } [CompilerGenerated] private sealed class <>c__DisplayClass449_1 { public Uri iconUri; public <>c__DisplayClass449_0 CS$<>8__locals1; internal void b__1() { if (CS$<>8__locals1.avatarRoot != null && !((ContainerWorker)(object)CS$<>8__locals1.avatarRoot).IsDestroyed && CS$<>8__locals1.avatarTex != null && !((ComponentBase)(object)CS$<>8__locals1.avatarTex).IsDestroyed) { ((SyncField)(object)((StaticAssetProvider)(object)CS$<>8__locals1.avatarTex).URL).Value = iconUri; } } } internal const string PluginGuid = "com.devl0rd.DesktopBuddy"; internal const string PluginName = "DesktopBuddy"; internal const string PluginAuthor = "DevL0rd"; internal const string PluginUrl = "https://github.com/DevL0rd/DesktopBuddy"; internal const string DesktopBuddyVersion = "1.1.0"; private static int _initialized; private static int _dependencyRuntimeStarted; private static readonly HashSet DesktopBuddyManagedDependencies; private static bool _managedDependencyResolverInstalled; private static UnhandledExceptionFilterDelegate _nativeCrashDelegate; private static nint _previousFilter; private const int STREAM_PORT = 48080; internal static readonly PerfTimer Perf; private const string ReleasesUrl = "https://github.com/DevL0rd/DesktopBuddy/releases"; private const string LatestReleaseApiUrl = "https://api.github.com/repos/DevL0rd/DesktopBuddy/releases/latest"; private const string ChangelogUrl = "https://raw.githubusercontent.com/DevL0rd/DesktopBuddy/main/CHANGELOG.md"; internal static DesktopBuddyConfig Config; private static int _runtimeBitrateMbps; private static int _runtimeStreamFps; private static int _runtimeMaxStreamResolution; private static string _runtimeEncoderPreference; internal static readonly DesktopBuddyConfigKey SpatialAudioEnabled; internal static readonly DesktopBuddyConfigKey CheckForUpdates; internal static readonly DesktopBuddyConfigKey ShowContextMenuItem; internal static readonly DesktopBuddyConfigKey ThrowToDestroy; internal static readonly DesktopBuddyConfigKey SpawnNewWindowsInGame; internal static readonly DesktopBuddyConfigKey SpawnNewWindowsPrivate; internal static readonly DesktopBuddyConfigKey NewWindowsStartPrivate; internal static readonly DesktopBuddyConfigKey DynamicLightsEnabled; internal static readonly DesktopBuddyConfigKey Bitrate; internal static readonly DesktopBuddyConfigKey StreamFps; internal static readonly DesktopBuddyConfigKey MaxStreamResolution; internal static readonly DesktopBuddyConfigKey UseMediaMtx; internal static readonly DesktopBuddyConfigKey MediaMtxHost; internal static readonly DesktopBuddyConfigKey MediaMtxPort; internal static readonly DesktopBuddyConfigKey MediaMtxStreamName; internal static readonly DesktopBuddyConfigKey StreamNetworkMode; internal static readonly DesktopBuddyConfigKey PortForwardHostMode; internal static readonly DesktopBuddyConfigKey PortForwardAutoIpMode; internal static readonly DesktopBuddyConfigKey PortForwardHost; internal static readonly DesktopBuddyConfigKey PortForwardUseNat; internal static readonly DesktopBuddyConfigKey PanelCurvePreferences; internal static readonly DesktopBuddyConfigKey LinuxSharedSources; internal static readonly DesktopBuddyConfigKey ViewerCullingMode; internal static readonly DesktopBuddyConfigKey ViewerCullingPreview; internal static readonly DesktopBuddyConfigKey ViewerFrustumWidth; internal static readonly DesktopBuddyConfigKey ViewerFrustumDepth; internal static readonly DesktopBuddyConfigKey ViewerDistance; internal static readonly DesktopBuddyConfigKey EncoderPreference; internal static readonly DesktopBuddyConfigKey PreferredGpuLuid; internal static readonly DesktopBuddyConfigKey StreamAudioOutputVolume; internal static readonly DesktopBuddyConfigKey StreamAudioGlobalMode; internal static readonly DesktopBuddyConfigKey StreamAudioSpatialize; internal static readonly DesktopBuddyConfigKey StreamAudioSpatialBlend; internal static readonly DesktopBuddyConfigKey StreamAudioDistanceSpace; internal static readonly DesktopBuddyConfigKey StreamAudioDopplerLevel; internal static readonly DesktopBuddyConfigKey StreamAudioPitch; internal static readonly DesktopBuddyConfigKey StreamAudioIgnoreAudioEffects; internal static readonly DesktopBuddyConfigKey StreamAudioTypeGroup; internal static readonly DesktopBuddyConfigKey StreamAudioRolloffMode; internal static readonly DesktopBuddyConfigKey StreamAudioMinDistance; internal static readonly DesktopBuddyConfigKey StreamAudioMaxDistance; internal static readonly DesktopBuddyConfigKey StreamAudioSpatializationStartDistance; internal static readonly DesktopBuddyConfigKey StreamAudioSpatializationTransitionRange; internal static readonly DesktopBuddyConfigKey StreamAudioPriority; internal static readonly DesktopBuddyConfigKey StreamAudioMinScale; internal static readonly DesktopBuddyConfigKey StreamAudioMaxScale; private static string _mediaMtxStreamBase; private const uint JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE = 8192u; private const int JobObjectExtendedLimitInformation = 9; private static SafeFileHandle _tunnelJob; private const string LaunchClientName = "steam-runtime-launch-client"; private static string _launchClientPath; private static bool _launchClientResolved; private static readonly object ExternalIpGate; private static readonly object NatMappingGate; private static readonly HttpClient ExternalIpClient; private static string _cachedExternalIPv4; private static global::System.DateTime _cachedExternalIPv4At; private static bool _natMappingActive; private static readonly long AdaptiveLightSampleIntervalTicks; private const float AdaptiveLightSurfaceZOffset = -0.02f; private static readonly HashSet _scheduledWorlds; private const int VirtualCameraTargetFps = 60; private static int _updateCount; private const double VBCableInputCheckIntervalSeconds = 5.0; private static long _lastVBCableInputCheckTicks; private static bool _lastVBCableInputPresent; private const int WindowPollIntervalMs = 250; private const float DesktopPanelCurvature = 0.18f; private const int DesktopPanelCurveSegments = 48; private const int SettingsUiRenderQueue = 3004; private const float TopBarSurfaceZOffset = -0.006f; private const float TopBarBackZOffset = 0.004f; private const float TopBarHoverCollapseDelaySeconds = 2f; private static int _nextTopBarRenderHostId; private const float SettingsPanelZOffset = -0.018f; private const int SettingsPanelRenderQueue = 3004; private const float SettingsStickScrollDeadzone = 0.16f; private const float SettingsStickScrollPixelsPerTick = 36f; private static readonly colorX SettingsBg; private static readonly colorX SettingsPanel; private static readonly colorX SettingsPanelSoft; private static readonly colorX SettingsAccent; private static readonly colorX SettingsAccentSoft; private static readonly colorX SettingsGradientPurple; private static readonly colorX SettingsGradientBlue; private static readonly colorX SettingsGradientMid; private static readonly UiGradientPalette SettingsGradientPalette; private static readonly UiScrollbarStyle SettingsScrollbarStyle; private static readonly colorX SettingsExperimentalOrange; private static readonly colorX SettingsStatusGood; private static readonly colorX SettingsStatusWarn; private static readonly colorX SettingsStatusBad; private static readonly colorX SettingsStatusNeutral; private static readonly colorX SettingsText; private static readonly colorX SettingsSubtext; private static readonly Uri DefaultViewerAvatar; private static readonly ValueTuple[] SettingsTabs; private static readonly ValueTuple[] StreamResolutionOptions; private static readonly ValueTuple[] StreamFpsOptions; private const int SetupPanelWidth = 920; private const int SetupPanelHeight = 600; private const float SetupPanelScale = 0.00055f; private static Slot _setupPanelRoot; private static Canvas _setupPanelCanvas; private static Text _setupBodyText; private static Slot _setupInstallButtonSlot; private static readonly List _setupStatusRows; private static bool _setupNoticeDismissed; private static bool _setupInstallInProgress; private static bool _setupCompleteAwaitingClose; private static global::System.DateTime _setupInstallStartedUtc; [field: CompilerGenerated] internal static ManualLogSource PluginLog { [CompilerGenerated] get; [CompilerGenerated] private set; } internal static List ActiveSessions => RuntimeStore.ActiveSessions; internal static HashSet DesktopCanvasIds => RuntimeStore.DesktopCanvasIds; private static object TopBarRaycastGate => RuntimeStore.TopBarRaycastGate; private static Dictionary TopBarRaycastTargets => RuntimeStore.TopBarRaycastTargets; private static Dictionary _sharedStreams => SharedStreamRegistry.Streams; internal static BuiltInStreamServer StreamServer { get { return RuntimeStore.StreamServer; } set { RuntimeStore.StreamServer = value; } } internal static VirtualCamera VCam { get { return RuntimeStore.VCam; } set { RuntimeStore.VCam = value; } } internal static VirtualMic VMic { get { return RuntimeStore.VMic; } set { RuntimeStore.VMic = value; } } internal static string TunnelUrl { get { return RuntimeStore.TunnelUrl; } set { RuntimeStore.TunnelUrl = value; } } private static Process _tunnelProcess { get { return RuntimeStore.TunnelProcess; } set { RuntimeStore.TunnelProcess = value; } } private static string _cfPath { get { return RuntimeStore.CloudflaredPath; } set { RuntimeStore.CloudflaredPath = value; } } private static bool _tunnelRestarting { get { return RuntimeStore.TunnelRestarting; } set { RuntimeStore.TunnelRestarting = value; } } internal static SharedTextureBridgeChannel TextureBridgeChannel { get { return RuntimeStore.TextureBridgeChannel; } set { RuntimeStore.TextureBridgeChannel = value; } } private static bool _textureBridgeOpened { get { return RuntimeStore.TextureBridgeOpened; } set { RuntimeStore.TextureBridgeOpened = value; } } internal static HashSet OurProviders => RuntimeStore.OurProviders; private static Thread _windowPollerThread { get { return RuntimeStore.WindowPollerThread; } set { RuntimeStore.WindowPollerThread = value; } } private static bool _windowPollerRunning { get { return RuntimeStore.WindowPollerRunning; } set { RuntimeStore.WindowPollerRunning = value; } } internal static ConcurrentQueue _windowEvents => RuntimeStore.WindowEvents; private static HashSet AutoSpawnSeenWindows => RuntimeStore.AutoSpawnSeenWindows; private static bool AutoSpawnWindowBaselineInitialized { get { return RuntimeStore.AutoSpawnWindowBaselineInitialized; } set { RuntimeStore.AutoSpawnWindowBaselineInitialized = value; } } private static string _latestVersion { get { return RuntimeStore.LatestVersion; } set { RuntimeStore.LatestVersion = value; } } private static string _remoteVersion { get { return RuntimeStore.RemoteVersion; } set { RuntimeStore.RemoteVersion = value; } } private static string _remoteSha { get { return RuntimeStore.RemoteSha; } set { RuntimeStore.RemoteSha = value; } } private static string _remoteChangelog { get { return RuntimeStore.RemoteChangelog; } set { RuntimeStore.RemoteChangelog = value; } } private static string _updateCheckError { get { return RuntimeStore.UpdateCheckError; } set { RuntimeStore.UpdateCheckError = value; } } private static global::System.DateTime _lastUpdateCheckUtc { get { return RuntimeStore.LastUpdateCheckUtc; } set { RuntimeStore.LastUpdateCheckUtc = value; } } private static bool _updateCheckInProgress { get { return RuntimeStore.UpdateCheckInProgress; } set { RuntimeStore.UpdateCheckInProgress = value; } } private static bool _updateShown { get { return RuntimeStore.UpdateShown; } set { RuntimeStore.UpdateShown = value; } } private static bool _settingsConfigDirty { get { return RuntimeStore.SettingsConfigDirty; } set { RuntimeStore.SettingsConfigDirty = value; } } internal static bool IsMediaMtxEnabled { get { DesktopBuddyConfig config = Config; if (config != null && config.GetValue(UseMediaMtx)) { return !string.IsNullOrWhiteSpace(Config?.GetValue(MediaMtxHost)); } return false; } } internal static int RuntimeBitrateMbps => Math.Clamp(Volatile.Read(ref _runtimeBitrateMbps), 1, 200); internal static int RuntimeStreamFps => Math.Clamp(Volatile.Read(ref _runtimeStreamFps), 1, 240); internal static int RuntimeMaxStreamResolution => Math.Clamp(Volatile.Read(ref _runtimeMaxStreamResolution), 128, 8192); internal static string RuntimeEncoderPreference => NormalizeEncoderPreference(_runtimeEncoderPreference); internal static bool UseCloudflareTunnel { get { if (Config != null) { return NormalizeStreamNetworkMode(Config.GetValue(StreamNetworkMode)) == "cloudflare"; } return true; } } private static string CloudflaredFileName => "cloudflared.exe"; public override void Load() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown PluginLog = ((BasePlugin)this).Log; Log.SetLogger(PluginLog); InstallManagedDependencyResolver(); ResoniteHooks.OnEngineReady += new Action(OnEngineReady); Msg("Plugin com.devl0rd.DesktopBuddy loaded; waiting for Resonite engine"); } private void OnEngineReady() { Log.StartSession(); Msg("[Startup] Runtime platform: " + DesktopBuddyPlatform.RuntimeLabel); DesktopBuddyFirstRunSetup.SetupState setupState; if (DesktopBuddyPlatform.IsLinux) { setupState = DesktopBuddyFirstRunSetup.SetupState.Ok; Msg("[Setup] Linux detected; skipping Windows-only first-run setup"); } else { setupState = DesktopBuddyFirstRunSetup.Check(); if (setupState.HasIssues) { Msg("[Setup] Local setup has missing or outdated items; dependency runtime deferred until setup notice is dismissed"); } } InitializeCore(); if (!setupState.HasIssues) { EnsureDependencyRuntimeStarted(); } } private void InitializeCore() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown if (Interlocked.Exchange(ref _initialized, 1) == 1) { return; } Config = new DesktopBuddyConfig(((BasePlugin)this).Config); BindConfigKeys(); SaveCurrentConfigDefaults(); AppDomain currentDomain = AppDomain.CurrentDomain; object obj = <>c.<>9__13_0; if (obj == null) { UnhandledExceptionEventHandler val = delegate(object sender, UnhandledExceptionEventArgs e) { Log.Msg($"UNHANDLED EXCEPTION (terminating={e.IsTerminating}):\n{e.ExceptionObject}"); }; <>c.<>9__13_0 = val; obj = (object)val; } currentDomain.UnhandledException += (UnhandledExceptionEventHandler)obj; TaskScheduler.UnobservedTaskException += delegate(object? sender, UnobservedTaskExceptionEventArgs e) { Log.Msg($"UNOBSERVED TASK EXCEPTION:\n{e.Exception}"); e.SetObserved(); }; if (!DesktopBuddyPlatform.IsLinux) { InstallNativeCrashHandler(); } else { Msg("[NativeCrash] Linux runtime detected; skipping Windows native crash handler"); } Harmony val2 = new Harmony("com.desktopbuddy.mod"); val2.PatchAll(); TopBarRaycastPortalPatch.Install(val2); AudioCapture.LogHandler = Msg; RegisterShutdownCleanup(); Msg("DesktopBuddy core initialized!"); } internal static void EnsureDependencyRuntimeStarted() { //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Expected O, but got Unknown //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Expected O, but got Unknown //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Expected O, but got Unknown if (Interlocked.Exchange(ref _dependencyRuntimeStarted, 1) == 1) { return; } Msg("[Startup] Starting DesktopBuddy dependency runtime"); PrewarmSharedResources(); if (IsMediaMtxEnabled) { Msg("[MediaMTX] Explicit RTSP mode enabled; built-in Cloudflare HTTP stream will not start"); } else { try { StreamServer = new BuiltInStreamServer(); StreamServer.Start(); Msg($"Stream server started on port {48080}"); if (UseCloudflareTunnel) { object obj = <>c.<>9__14_0; if (obj == null) { Action val = delegate { StartTunnel(); }; <>c.<>9__14_0 = val; obj = (object)val; } global::System.Threading.Tasks.Task.Run((Action)obj); } else { Msg("[PortForward] Built-in stream available at " + (GetBuiltInStreamBaseUrl() ?? "(no host configured)")); ApplyPortForwardNatMapping(); } } catch (global::System.Exception ex) { Msg("Stream server failed to start: " + ex.Message); StreamServer = null; } } if (!DesktopBuddyPlatform.IsLinux) { object obj2 = <>c.<>9__14_1; if (obj2 == null) { Action val2 = delegate { try { if (SoftCam.IsFilterRegistered()) { VCam = new VirtualCamera(); VCam.StartIdle(); } else { Msg("[VirtualCamera] DirectShow filter not registered, virtual camera unavailable"); } } catch (global::System.Exception ex2) { Msg("[VirtualCamera] Setup error: " + ex2.Message); } try { if (!VBCable.HasCableInputDevice()) { Msg("[VirtualMic] VB-Cable not installed, virtual mic unavailable"); } } catch (global::System.Exception ex3) { Msg("[VirtualMic] Setup error: " + ex3.Message); } }; <>c.<>9__14_1 = val2; obj2 = (object)val2; } global::System.Threading.Tasks.Task.Run((Action)obj2); } else { Msg("[Startup] Linux detected; skipping Windows VB-Cable and audio-routing setup"); object obj3 = <>c.<>9__14_2; if (obj3 == null) { Action val3 = delegate { try { VirtualCamera virtualCamera = new VirtualCamera(); if (virtualCamera.StartIdle()) { VCam = virtualCamera; Msg("[VirtualCamera] Linux v4l2 virtual camera ready"); } else { virtualCamera.Dispose(); Msg("[VirtualCamera] Linux virtual camera unavailable; run setup in the Devices tab"); } } catch (global::System.Exception ex2) { Msg("[VirtualCamera] Linux setup error: " + ex2.Message); } }; <>c.<>9__14_2 = val3; obj3 = (object)val3; } global::System.Threading.Tasks.Task.Run((Action)obj3); } if (!DesktopBuddyPlatform.IsLinux) { _windowPollerRunning = true; object obj4 = <>O.<1>__WindowPollerLoop; if (obj4 == null) { ThreadStart val4 = WindowPollerLoop; <>O.<1>__WindowPollerLoop = val4; obj4 = (object)val4; } _windowPollerThread = new Thread((ThreadStart)obj4) { Name = "DesktopBuddy:WindowPoller", IsBackground = true }; _windowPollerThread.Start(); } else { Msg("[Startup] Linux detected; skipping Win32 window poller"); } Msg("DesktopBuddy dependency runtime initialized!"); OpenSharedTextureBridge(); } private static void RegisterShutdownCleanup() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown AppDomain currentDomain = AppDomain.CurrentDomain; object obj = <>c.<>9__15_0; if (obj == null) { EventHandler val = delegate { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) HashSet val2 = new HashSet(); Enumerator enumerator = ActiveSessions.GetEnumerator(); try { while (enumerator.MoveNext()) { DesktopSession current = enumerator.Current; if (!DesktopBuddyPlatform.IsLinux && current.OwnsAudioRedirect && current.ProcessId != 0 && val2.Add(current.ProcessId)) { AudioRouter.ResetProcessToDefault(current.ProcessId); } } } finally { ((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } KillTunnel(); RemovePortForwardNatMapping(); try { StreamServer?.Dispose(); } catch { } }; <>c.<>9__15_0 = val; obj = (object)val; } currentDomain.ProcessExit += (EventHandler)obj; } private static void InstallManagedDependencyResolver() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown if (!_managedDependencyResolverInstalled) { AppDomain currentDomain = AppDomain.CurrentDomain; object obj = <>O.<2>__ResolveDesktopBuddyManagedDependency; if (obj == null) { ResolveEventHandler val = ResolveDesktopBuddyManagedDependency; <>O.<2>__ResolveDesktopBuddyManagedDependency = val; obj = (object)val; } currentDomain.AssemblyResolve += (ResolveEventHandler)obj; _managedDependencyResolverInstalled = true; } } private static Assembly ResolveDesktopBuddyManagedDependency(object sender, ResolveEventArgs args) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) string name = new AssemblyName(args.Name).Name; if (!DesktopBuddyManagedDependencies.Contains(name)) { return null; } string desktopBuddyManagedDependencyPath = GetDesktopBuddyManagedDependencyPath(name); try { if (File.Exists(desktopBuddyManagedDependencyPath)) { return Assembly.LoadFrom(desktopBuddyManagedDependencyPath); } } catch (global::System.Exception ex) { Log.Msg($"[Dependencies] Failed to load {name} from {desktopBuddyManagedDependencyPath}: {ex.Message}"); } Log.Msg("[Dependencies] Missing " + name + " at " + desktopBuddyManagedDependencyPath); return null; } private static string GetDesktopBuddyManagedDependencyPath(string assemblyName) { return DesktopBuddyRuntimePaths.FindFile(assemblyName + ".dll"); } [DllImport("kernel32.dll")] private static extern nint SetUnhandledExceptionFilter(nint lpTopLevelExceptionFilter); private static void InstallNativeCrashHandler() { try { _nativeCrashDelegate = NativeCrashFilter; _previousFilter = SetUnhandledExceptionFilter(Marshal.GetFunctionPointerForDelegate(_nativeCrashDelegate)); Log.Msg("[NativeCrash] Handler installed"); } catch (global::System.Exception ex) { Log.Msg("[NativeCrash] Failed to install handler: " + ex.Message); } } private static int NativeCrashFilter(nint exceptionPointersPtr) { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown try { global::System.IntPtr intPtr = Marshal.ReadIntPtr((global::System.IntPtr)exceptionPointersPtr, 0); uint num = (uint)Marshal.ReadInt32(intPtr, 0); nint num2 = Marshal.ReadIntPtr(intPtr, (global::System.IntPtr.Size == 8) ? 24 : 12); string text = $"[NativeCrash] FATAL: code=0x{num:X8} addr=0x{num2:X}\n"; try { foreach (ProcessModule item in (ReadOnlyCollectionBase)Process.GetCurrentProcess().Modules) { ProcessModule val = item; long num3 = ((global::System.IntPtr)(nint)val.BaseAddress).ToInt64(); long num4 = num3 + val.ModuleMemorySize; if (((global::System.IntPtr)num2).ToInt64() >= num3 && ((global::System.IntPtr)num2).ToInt64() < num4) { long num5 = ((global::System.IntPtr)num2).ToInt64() - num3; text += $"[NativeCrash] Faulting module: {val.ModuleName}+0x{num5:X} ({val.FileName})\n"; break; } } } catch { } try { text = text + "[NativeCrash] Managed stack:\n" + Environment.StackTrace + "\n"; } catch { } Log.Msg(text); } catch { try { Log.Msg("[NativeCrash] FATAL: crash handler failed to log details"); } catch { } } return 0; } internal static void Msg(string msg) { Log.Msg(msg); } internal static void Error(string msg) { Log.Error(msg); } internal static void RegisterTopBarRaycastPortal(Slot portalSlot, Slot targetRoot) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) if (portalSlot != null && targetRoot != null) { RefID portalId = ((Worker)portalSlot).ReferenceID; lock (TopBarRaycastGate) { TopBarRaycastTargets[portalId] = targetRoot; } portalSlot.Destroyed += delegate { //IL_0001: Unknown result type (might be due to invalid IL or missing references) UnregisterTopBarRaycastPortal(portalId); }; targetRoot.Destroyed += delegate { //IL_0001: Unknown result type (might be due to invalid IL or missing references) UnregisterTopBarRaycastPortal(portalId); }; Msg($"[TopBarRaycast] Registered portal={portalId} target={((Worker)targetRoot).ReferenceID}"); } } internal static Slot GetTopBarRaycastTarget(Slot portalSlot) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (portalSlot == null) { return null; } RefID referenceID = ((Worker)portalSlot).ReferenceID; lock (TopBarRaycastGate) { Slot val = default(Slot); if (!TopBarRaycastTargets.TryGetValue(referenceID, ref val) || val == null || ((ContainerWorker)(object)val).IsDestroyed) { TopBarRaycastTargets.Remove(referenceID); return null; } return val; } } private static void UnregisterTopBarRaycastPortal(RefID portalId) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) lock (TopBarRaycastGate) { TopBarRaycastTargets.Remove(portalId); } } internal static bool IsDesktopMode(World world) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 try { int result; if (world == null) { result = 0; } else { User localUser = world.LocalUser; result = (((int)((localUser != null) ? new HeadOutputDevice?(localUser.HeadDevice) : ((HeadOutputDevice?)null)).GetValueOrDefault() == 2) ? 1 : 0); } return (byte)result != 0; } catch { return false; } } private static int NextStreamId() { return SharedStreamRegistry.NextStreamId(); } private static void PrewarmSharedResources() { if (!DesktopBuddyPlatform.IsLinux) { try { WgcCapture.PrewarmSharedDevice(); } catch (global::System.Exception ex) { Msg("[Startup] WGC adapter prewarm failed: " + ex.Message); } try { WgcCapture.PrewarmCaptureFactory(); } catch (global::System.Exception ex2) { Msg("[Startup] WGC capture factory prewarm failed: " + ex2.Message); } } else { Msg("[Startup] Linux runtime detected; skipping WGC prewarm"); } if (!DesktopBuddyPlatform.IsLinux) { try { FfmpegEncoder.SetFfmpegPath(); } catch (global::System.Exception ex3) { Msg("[Startup] FFmpeg prewarm failed: " + ex3.Message); } } if (!DesktopBuddyPlatform.IsLinux) { try { WindowInput.PrewarmTouchInjection(); } catch (global::System.Exception ex4) { Msg("[Startup] Touch injection prewarm failed: " + ex4.Message); } } try { DesktopTextureProviderPatch.PrewarmReflection(); } catch (global::System.Exception ex5) { Msg("[Startup] DesktopTexture reflection prewarm failed: " + ex5.Message); } if (!DesktopBuddyPlatform.IsLinux) { try { AudioRouter.PrewarmFactory(); } catch (global::System.Exception ex6) { Msg("[Startup] Audio router prewarm failed: " + ex6.Message); } } } private static void OpenSharedTextureBridge() { if (_textureBridgeOpened) { return; } try { TextureBridgeChannel = new SharedTextureBridgeChannel(); TextureBridgeChannel.Open(); _textureBridgeOpened = true; Msg("[SharedTextureBridge] Opened successfully"); } catch (global::System.Exception ex) { Msg($"[SharedTextureBridge] Error: {ex}"); } } private static void CheckForUpdate() { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) try { _updateCheckError = null; string text = "e5251e3"; string text2 = "1.1.0"; Msg($"[Update] Current version: {text2} ({text})"); HttpClient val = new HttpClient(); try { val.Timeout = TimeSpan.FromSeconds(8L); ((HttpHeaders)val.DefaultRequestHeaders).Add("User-Agent", "DesktopBuddy"); JsonDocument val2 = JsonDocument.Parse(val.GetStringAsync("https://api.github.com/repos/DevL0rd/DesktopBuddy/releases/latest").Result, default(JsonDocumentOptions)); try { JsonElement rootElement = val2.RootElement; JsonElement val3 = default(JsonElement); if (((JsonElement)(ref rootElement)).TryGetProperty("tag_name", ref val3)) { string text3 = (((JsonElement)(ref val3)).GetString() ?? "").Trim(); if (text3.StartsWith("v", (StringComparison)5)) { text3 = text3.Substring(1); } _remoteVersion = text3; JsonElement val4 = default(JsonElement); _remoteSha = (((JsonElement)(ref rootElement)).TryGetProperty("target_commitish", ref val4) ? (((JsonElement)(ref val4)).GetString() ?? ("v" + text3)) : ("v" + text3)); _remoteChangelog = FetchChangelog(val); _lastUpdateCheckUtc = global::System.DateTime.UtcNow; Msg("[Update] Latest GitHub release version: " + text3); _latestVersion = (IsRemoteVersionNewer(text3, text2) ? text3 : null); } } finally { ((global::System.IDisposable)val2)?.Dispose(); } } finally { ((global::System.IDisposable)val)?.Dispose(); } } catch (global::System.Exception ex) when (IsGitHubReleaseNotFound(ex)) { _updateCheckError = "No GitHub release is published yet."; _lastUpdateCheckUtc = global::System.DateTime.UtcNow; Msg("[Update] No GitHub release is published yet"); } catch (global::System.Exception ex2) { _updateCheckError = ex2.Message; _lastUpdateCheckUtc = global::System.DateTime.UtcNow; Msg("[Update] Check failed: " + ex2.Message); } } private static bool IsGitHubReleaseNotFound(global::System.Exception ex) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Invalid comparison between Unknown and I4 HttpRequestException ex2 = (HttpRequestException)(object)((ex is HttpRequestException) ? ex : null); if (ex2 != null && (int)ex2.StatusCode.GetValueOrDefault() == 404) { return true; } AggregateException ex3 = (AggregateException)(object)((ex is AggregateException) ? ex : null); if (ex3 != null) { return Enumerable.Any((global::System.Collections.Generic.IEnumerable)ex3.Flatten().InnerExceptions, (Func)IsGitHubReleaseNotFound); } if (ex.InnerException != null) { return IsGitHubReleaseNotFound(ex.InnerException); } return false; } private static string FetchChangelog(HttpClient http) { try { string result = http.GetStringAsync("https://raw.githubusercontent.com/DevL0rd/DesktopBuddy/main/CHANGELOG.md").Result; if (!string.IsNullOrWhiteSpace(result)) { return TrimChangelog(result); } } catch (global::System.Exception ex) { Msg("[Update] Changelog fetch failed: " + ex.Message); } return ""; } private static bool IsRemoteVersionNewer(string remoteVersion, string currentVersion) { if (TryParseSemanticVersion(remoteVersion, out var parsed) && TryParseSemanticVersion(currentVersion, out var parsed2)) { return parsed.CompareTo(parsed2) > 0; } return !string.Equals(remoteVersion, currentVersion, (StringComparison)5); } private static bool TryParseSemanticVersion(string version, out Version parsed) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown parsed = null; if (string.IsNullOrWhiteSpace(version)) { return false; } Match val = Regex.Match(version.Trim(), "^v?(\\d+)\\.(\\d+)\\.(\\d+)$", (RegexOptions)1); if (!((Group)val).Success) { return false; } parsed = new Version(int.Parse(((Capture)val.Groups[1]).Value), int.Parse(((Capture)val.Groups[2]).Value), int.Parse(((Capture)val.Groups[3]).Value)); return true; } private static string TrimChangelog(string text) { if (string.IsNullOrWhiteSpace(text)) { return ""; } string[] array = Enumerable.ToArray(Enumerable.Take((global::System.Collections.Generic.IEnumerable)text.Replace("\r\n", "\n").Replace('\r', '\n').Split('\n', (StringSplitOptions)0), 80)); string text2 = string.Join("\n", array).Trim(); if (text2.Length > 5000) { return text2.Substring(0, 5000).TrimEnd() + "\n..."; } return text2; } private static void QueueUpdateInfoCheck(SettingsPanelState state) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (_updateCheckInProgress || (_lastUpdateCheckUtc != default(global::System.DateTime) && global::System.DateTime.UtcNow - _lastUpdateCheckUtc < TimeSpan.FromMinutes(5L))) { return; } _updateCheckInProgress = true; Action val2 = default(Action); ThreadPool.QueueUserWorkItem((WaitCallback)delegate { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_004f: Expected O, but got Unknown try { CheckForUpdate(); } finally { _updateCheckInProgress = false; SettingsPanelState settingsPanelState = state; object obj; if (settingsPanelState == null) { obj = null; } else { Slot ownerRoot = settingsPanelState.OwnerRoot; obj = ((ownerRoot != null) ? ((Worker)ownerRoot).World : null); } World val = (World)obj; if (val != null) { Action obj2 = val2; if (obj2 == null) { Action val3 = delegate { if (state.SurfaceSlot != null && !((ContainerWorker)(object)state.SurfaceSlot).IsDestroyed && state.SurfaceSlot.ActiveSelf && state.ActiveTab == SettingsPanelTab.UpdateInfo) { RebuildSettingsPanel(state, state.Session); } }; Action val4 = val3; val2 = val3; obj2 = val4; } val.RunInUpdates(1, obj2); } } }); } private static void ShowUpdatePopup(Slot root, float w, float canvasScale) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Expected O, but got Unknown //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Expected O, but got Unknown //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Expected O, but got Unknown //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) Msg("[Update] Showing update popup: " + _latestVersion); Slot updateSlot = root.AddSlot("UpdateNotice", true); updateSlot.LocalPosition = new float3(0f, 0f, -0.002f); Slot obj = updateSlot; float3 one = float3.One; obj.LocalScale = (ref one) * canvasScale; Canvas obj2 = ((ContainerWorker)(object)updateSlot).AttachComponent(true, (Action)null); float num = Math.Min(w * 0.6f, 400f); ((SyncField)(object)obj2.Size).Value = new float2(num, 160f); UIBuilder val = new UIBuilder(obj2); colorX val2 = new colorX(0.12f, 0.12f, 0.15f, 0.95f, (ColorProfile)1); Image val3 = val.Image(ref val2, false); val.NestInto(((UIComponent)val3).RectTransform); val.VerticalLayout(8f, 0f, (Alignment?)(Alignment)4, (bool?)null, (bool?)null); val.Style.FlexibleWidth = 1f; val.Style.MinHeight = 32f; LocaleString val4 = LocaleString.op_Implicit("Update available!"); Text obj3 = val.Text(ref val4, false, (Alignment?)(Alignment)4, true, (string)null); ((SyncField)(object)obj3.Size).Value = 22f; ((SyncField)(object)obj3.Color).Value = new colorX(0.95f, 0.85f, 0.3f, 1f, (ColorProfile)1); val.Style.MinHeight = 36f; val4 = LocaleString.op_Implicit("Download"); Button val5 = val.Button(ref val4); TextRenderer componentInChildren = ((Component)val5).Slot.GetComponentInChildren((Predicate)null, false, false); if (componentInChildren != null) { ((SyncField)(object)componentInChildren.Color).Value = new colorX(0.9f, 0.9f, 0.9f, 1f, (ColorProfile)1); ((SyncField)(object)componentInChildren.Size).Value = 18f; } if (((SyncElementList)(object)((InteractionElement)val5).ColorDrivers).Count > 0) { ColorDriver obj4 = ((SyncElementList)(object)((InteractionElement)val5).ColorDrivers)[0]; ((SyncField)(object)obj4.NormalColor).Value = new colorX(0.2f, 0.4f, 0.6f, 1f, (ColorProfile)1); ((SyncField)(object)obj4.HighlightColor).Value = new colorX(0.25f, 0.5f, 0.75f, 1f, (ColorProfile)1); ((SyncField)(object)obj4.PressColor).Value = new colorX(0.15f, 0.3f, 0.45f, 1f, (ColorProfile)1); } val5.LocalPressed += (ButtonEventHandler)delegate { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown try { Msg("[Update] Opening releases page"); try { Process.Start(new ProcessStartInfo("https://github.com/DevL0rd/DesktopBuddy/releases") { UseShellExecute = true }); } catch (global::System.Exception ex) { Msg("[Update] Failed: " + ex.Message); } if (!((ContainerWorker)(object)updateSlot).IsDestroyed) { updateSlot.Destroy(); } } catch (global::System.Exception ex2) { Msg($"[Update] Download button error: {ex2}"); } }; val.Style.MinHeight = 30f; val4 = LocaleString.op_Implicit("Dismiss"); Button val6 = val.Button(ref val4); TextRenderer componentInChildren2 = ((Component)val6).Slot.GetComponentInChildren((Predicate)null, false, false); if (componentInChildren2 != null) { ((SyncField)(object)componentInChildren2.Color).Value = new colorX(0.7f, 0.7f, 0.7f, 1f, (ColorProfile)1); ((SyncField)(object)componentInChildren2.Size).Value = 14f; } if (((SyncElementList)(object)((InteractionElement)val6).ColorDrivers).Count > 0) { ColorDriver obj5 = ((SyncElementList)(object)((InteractionElement)val6).ColorDrivers)[0]; ((SyncField)(object)obj5.NormalColor).Value = new colorX(0.2f, 0.2f, 0.25f, 1f, (ColorProfile)1); ((SyncField)(object)obj5.HighlightColor).Value = new colorX(0.3f, 0.3f, 0.35f, 1f, (ColorProfile)1); ((SyncField)(object)obj5.PressColor).Value = new colorX(0.15f, 0.15f, 0.18f, 1f, (ColorProfile)1); } val6.LocalPressed += (ButtonEventHandler)delegate { try { if (!((ContainerWorker)(object)updateSlot).IsDestroyed) { updateSlot.Destroy(); } } catch (global::System.Exception ex) { Msg($"[Update] Dismiss button error: {ex}"); } }; ((Worker)root).World.RunInUpdates(900, (Action)delegate { try { if (!((ContainerWorker)(object)updateSlot).IsDestroyed) { updateSlot.Destroy(); } } catch (global::System.Exception ex) { Msg($"[Update] Auto-dismiss error: {ex}"); } }); } private static void SaveCurrentConfigDefaults() { try { if (Config != null) { Config.Set(SpatialAudioEnabled, Config.GetValue(SpatialAudioEnabled)); Config.Set(Bitrate, Config.GetValue(Bitrate)); Config.Set(StreamFps, Math.Clamp(Config.GetValue(StreamFps), 1, 240)); Config.Set(MaxStreamResolution, Math.Clamp(Config.GetValue(MaxStreamResolution), 128, 8192)); Config.Set(CheckForUpdates, Config.GetValue(CheckForUpdates)); Config.Set(ShowContextMenuItem, Config.GetValue(ShowContextMenuItem)); Config.Set(ThrowToDestroy, Config.GetValue(ThrowToDestroy)); Config.Set(SpawnNewWindowsInGame, Config.GetValue(SpawnNewWindowsInGame)); Config.Set(SpawnNewWindowsPrivate, Config.GetValue(SpawnNewWindowsPrivate)); Config.Set(NewWindowsStartPrivate, Config.GetValue(NewWindowsStartPrivate)); Config.Set(DynamicLightsEnabled, Config.GetValue(DynamicLightsEnabled)); Config.Set(UseMediaMtx, Config.GetValue(UseMediaMtx)); Config.Set(MediaMtxHost, Config.GetValue(MediaMtxHost)); Config.Set(MediaMtxPort, Config.GetValue(MediaMtxPort)); Config.Set(MediaMtxStreamName, Config.GetValue(MediaMtxStreamName)); Config.Set(StreamNetworkMode, NormalizeStreamNetworkMode(Config.GetValue(StreamNetworkMode))); Config.Set(PortForwardHostMode, NormalizePortForwardHostMode(Config.GetValue(PortForwardHostMode))); Config.Set(PortForwardAutoIpMode, NormalizePortForwardAutoIpMode(Config.GetValue(PortForwardAutoIpMode))); Config.Set(PortForwardHost, Config.GetValue(PortForwardHost)?.Trim() ?? ""); Config.Set(PortForwardUseNat, Config.GetValue(PortForwardUseNat)); Config.Set(PanelCurvePreferences, Config.GetValue(PanelCurvePreferences) ?? ""); Config.Set(LinuxSharedSources, Config.GetValue(LinuxSharedSources) ?? ""); Config.Set(ViewerCullingMode, NormalizeViewerCullingMode(Config.GetValue(ViewerCullingMode))); Config.Set(ViewerCullingPreview, Config.GetValue(ViewerCullingPreview)); float value = Config.GetValue(ViewerFrustumWidth); Config.Set(ViewerFrustumWidth, (value < 5f) ? 120f : Math.Clamp(value, 30f, 170f)); Config.Set(ViewerFrustumDepth, Math.Clamp(Config.GetValue(ViewerFrustumDepth), 1f, 10f)); Config.Set(ViewerDistance, Math.Clamp(Config.GetValue(ViewerDistance), 1f, 10f)); Config.Set(EncoderPreference, NormalizeEncoderPreference(Config.GetValue(EncoderPreference))); Config.Set(PreferredGpuLuid, Config.GetValue(PreferredGpuLuid)?.Trim() ?? ""); Config.Set(StreamAudioOutputVolume, NormalizeStreamAudioOutputVolume(Config.GetValue(StreamAudioOutputVolume))); Config.Set(StreamAudioGlobalMode, NormalizeStreamAudioGlobalMode(Config.GetValue(StreamAudioGlobalMode))); Config.Set(StreamAudioSpatialize, Config.GetValue(StreamAudioSpatialize)); Config.Set(StreamAudioSpatialBlend, Math.Clamp(Config.GetValue(StreamAudioSpatialBlend), 0f, 1f)); Config.Set(StreamAudioDistanceSpace, NormalizeStreamAudioDistanceSpace(Config.GetValue(StreamAudioDistanceSpace))); Config.Set(StreamAudioDopplerLevel, Math.Clamp(Config.GetValue(StreamAudioDopplerLevel), 0f, 1f)); Config.Set(StreamAudioPitch, Math.Clamp(Config.GetValue(StreamAudioPitch), 0.5f, 2f)); Config.Set(StreamAudioIgnoreAudioEffects, Config.GetValue(StreamAudioIgnoreAudioEffects)); Config.Set(StreamAudioTypeGroup, NormalizeStreamAudioTypeGroup(Config.GetValue(StreamAudioTypeGroup))); Config.Set(StreamAudioRolloffMode, NormalizeStreamAudioRolloffMode(Config.GetValue(StreamAudioRolloffMode))); Config.Set(StreamAudioMinDistance, Math.Clamp(Config.GetValue(StreamAudioMinDistance), 0f, 10f)); Config.Set(StreamAudioMaxDistance, Math.Clamp(Config.GetValue(StreamAudioMaxDistance), 1f, 50f)); Config.Set(StreamAudioSpatializationStartDistance, Math.Clamp(Config.GetValue(StreamAudioSpatializationStartDistance), 0f, 10f)); Config.Set(StreamAudioSpatializationTransitionRange, Math.Clamp(Config.GetValue(StreamAudioSpatializationTransitionRange), 0f, 10f)); Config.Set(StreamAudioPriority, Math.Clamp(Config.GetValue(StreamAudioPriority), 0, 256)); Config.Set(StreamAudioMinScale, Math.Clamp(Config.GetValue(StreamAudioMinScale), 0f, 1000f)); Config.Set(StreamAudioMaxScale, Math.Clamp(Config.GetValue(StreamAudioMaxScale), 0f, 1000f)); Config.Save(); RefreshRuntimeStreamSettingsFromConfig(); } } catch (global::System.Exception ex) { Msg("[Config] Failed to save current defaults: " + ex.Message); } } private static void RefreshRuntimeStreamSettingsFromConfig() { try { if (Config != null) { Volatile.Write(ref _runtimeBitrateMbps, Math.Clamp(Config.GetValue(Bitrate), 1, 200)); Volatile.Write(ref _runtimeStreamFps, Math.Clamp(Config.GetValue(StreamFps), 1, 240)); Volatile.Write(ref _runtimeMaxStreamResolution, Math.Clamp(Config.GetValue(MaxStreamResolution), 128, 8192)); _runtimeEncoderPreference = NormalizeEncoderPreference(Config.GetValue(EncoderPreference)); } } catch (global::System.Exception ex) { Msg("[Config] Failed to refresh runtime stream settings: " + ex.Message); } } private static void ApplyFreshConfigDefaults() { Config.Set(SpatialAudioEnabled, SpatialAudioEnabled.DefaultValue); Config.Set(CheckForUpdates, CheckForUpdates.DefaultValue); Config.Set(ShowContextMenuItem, ShowContextMenuItem.DefaultValue); Config.Set(ThrowToDestroy, ThrowToDestroy.DefaultValue); Config.Set(SpawnNewWindowsInGame, SpawnNewWindowsInGame.DefaultValue); Config.Set(SpawnNewWindowsPrivate, SpawnNewWindowsPrivate.DefaultValue); Config.Set(NewWindowsStartPrivate, NewWindowsStartPrivate.DefaultValue); Config.Set(DynamicLightsEnabled, DynamicLightsEnabled.DefaultValue); Config.Set(Bitrate, Bitrate.DefaultValue); Config.Set(StreamFps, StreamFps.DefaultValue); Config.Set(MaxStreamResolution, MaxStreamResolution.DefaultValue); Config.Set(UseMediaMtx, UseMediaMtx.DefaultValue); Config.Set(MediaMtxHost, MediaMtxHost.DefaultValue); Config.Set(MediaMtxPort, MediaMtxPort.DefaultValue); Config.Set(MediaMtxStreamName, MediaMtxStreamName.DefaultValue); Config.Set(StreamNetworkMode, StreamNetworkMode.DefaultValue); Config.Set(PortForwardHostMode, PortForwardHostMode.DefaultValue); Config.Set(PortForwardAutoIpMode, PortForwardAutoIpMode.DefaultValue); Config.Set(PortForwardHost, PortForwardHost.DefaultValue); Config.Set(PortForwardUseNat, PortForwardUseNat.DefaultValue); Config.Set(PanelCurvePreferences, PanelCurvePreferences.DefaultValue); Config.Set(LinuxSharedSources, LinuxSharedSources.DefaultValue); Config.Set(ViewerCullingMode, ViewerCullingMode.DefaultValue); Config.Set(ViewerCullingPreview, ViewerCullingPreview.DefaultValue); Config.Set(ViewerFrustumWidth, ViewerFrustumWidth.DefaultValue); Config.Set(ViewerFrustumDepth, ViewerFrustumDepth.DefaultValue); Config.Set(ViewerDistance, ViewerDistance.DefaultValue); Config.Set(EncoderPreference, EncoderPreference.DefaultValue); Config.Set(PreferredGpuLuid, PreferredGpuLuid.DefaultValue); Config.Set(StreamAudioOutputVolume, StreamAudioOutputVolume.DefaultValue); Config.Set(StreamAudioGlobalMode, StreamAudioGlobalMode.DefaultValue); Config.Set(StreamAudioSpatialize, StreamAudioSpatialize.DefaultValue); Config.Set(StreamAudioSpatialBlend, StreamAudioSpatialBlend.DefaultValue); Config.Set(StreamAudioDistanceSpace, StreamAudioDistanceSpace.DefaultValue); Config.Set(StreamAudioDopplerLevel, StreamAudioDopplerLevel.DefaultValue); Config.Set(StreamAudioPitch, StreamAudioPitch.DefaultValue); Config.Set(StreamAudioIgnoreAudioEffects, StreamAudioIgnoreAudioEffects.DefaultValue); Config.Set(StreamAudioTypeGroup, StreamAudioTypeGroup.DefaultValue); Config.Set(StreamAudioRolloffMode, StreamAudioRolloffMode.DefaultValue); Config.Set(StreamAudioMinDistance, StreamAudioMinDistance.DefaultValue); Config.Set(StreamAudioMaxDistance, StreamAudioMaxDistance.DefaultValue); Config.Set(StreamAudioSpatializationStartDistance, StreamAudioSpatializationStartDistance.DefaultValue); Config.Set(StreamAudioSpatializationTransitionRange, StreamAudioSpatializationTransitionRange.DefaultValue); Config.Set(StreamAudioPriority, StreamAudioPriority.DefaultValue); Config.Set(StreamAudioMinScale, StreamAudioMinScale.DefaultValue); Config.Set(StreamAudioMaxScale, StreamAudioMaxScale.DefaultValue); } private static void ApplyRuntimeSetting(DesktopBuddyConfigKey key, T value) { if ((object)key == Bitrate && value is int num) { Volatile.Write(ref _runtimeBitrateMbps, Math.Clamp(num, 1, 200)); } else if ((object)key == StreamFps && value is int num2) { Volatile.Write(ref _runtimeStreamFps, Math.Clamp(num2, 1, 240)); } else if ((object)key == MaxStreamResolution && value is int num3) { Volatile.Write(ref _runtimeMaxStreamResolution, Math.Clamp(num3, 128, 8192)); } else if ((object)key == EncoderPreference && value is string value2) { _runtimeEncoderPreference = NormalizeEncoderPreference(value2); } } internal static void SaveConfigValue(DesktopBuddyConfigKey key, T value) { try { if (Config != null) { ApplyRuntimeSetting(key, value); Config.Set(key, value); _settingsConfigDirty = true; } } catch (global::System.Exception ex) { Msg("[Config] Failed to set " + key?.Name + ": " + ex.Message); } } internal static void FlushSettingsConfig() { try { if (Config != null && _settingsConfigDirty) { _settingsConfigDirty = false; Config.Save(); } } catch (global::System.Exception ex) { Msg("[Config] Failed to save settings: " + ex.Message); _settingsConfigDirty = true; } } private static void BindConfigKeys() { Config.Bind(SpatialAudioEnabled); Config.Bind(CheckForUpdates); Config.Bind(ShowContextMenuItem); Config.Bind(ThrowToDestroy); Config.Bind(SpawnNewWindowsInGame); Config.Bind(SpawnNewWindowsPrivate); Config.Bind(NewWindowsStartPrivate); Config.Bind(DynamicLightsEnabled); Config.Bind(Bitrate); Config.Bind(StreamFps); Config.Bind(MaxStreamResolution); Config.Bind(UseMediaMtx); Config.Bind(MediaMtxHost); Config.Bind(MediaMtxPort); Config.Bind(MediaMtxStreamName); Config.Bind(StreamNetworkMode); Config.Bind(PortForwardHostMode); Config.Bind(PortForwardAutoIpMode); Config.Bind(PortForwardHost); Config.Bind(PortForwardUseNat); Config.Bind(PanelCurvePreferences); Config.Bind(LinuxSharedSources); Config.Bind(ViewerCullingMode); Config.Bind(ViewerCullingPreview); Config.Bind(ViewerFrustumWidth); Config.Bind(ViewerFrustumDepth); Config.Bind(ViewerDistance); Config.Bind(EncoderPreference); Config.Bind(PreferredGpuLuid); Config.Bind(StreamAudioOutputVolume); Config.Bind(StreamAudioGlobalMode); Config.Bind(StreamAudioSpatialize); Config.Bind(StreamAudioSpatialBlend); Config.Bind(StreamAudioDistanceSpace); Config.Bind(StreamAudioDopplerLevel); Config.Bind(StreamAudioPitch); Config.Bind(StreamAudioIgnoreAudioEffects); Config.Bind(StreamAudioTypeGroup); Config.Bind(StreamAudioRolloffMode); Config.Bind(StreamAudioMinDistance); Config.Bind(StreamAudioMaxDistance); Config.Bind(StreamAudioSpatializationStartDistance); Config.Bind(StreamAudioSpatializationTransitionRange); Config.Bind(StreamAudioPriority); Config.Bind(StreamAudioMinScale); Config.Bind(StreamAudioMaxScale); } internal static string GetMediaMtxRtspUrl(int streamId) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) string text = Config.GetValue(MediaMtxHost).Trim(); int value = Config.GetValue(MediaMtxPort); string text2 = Config.GetValue(MediaMtxStreamName)?.Trim(); if (string.IsNullOrEmpty(text2)) { if (_mediaMtxStreamBase == null) { Guid val = Guid.NewGuid(); _mediaMtxStreamBase = "desktopbuddy-" + ((Guid)(ref val)).ToString("N").Substring(0, 8); } text2 = _mediaMtxStreamBase; } return $"rtsp://{text}:{value}/{text2}_{streamId}"; } internal static string GetPanelCurvePreferenceKey(nint hwnd) { if (hwnd == (nint)global::System.IntPtr.Zero) { return "desktop"; } string executablePath = WindowIconExtractor.GetExecutablePath(hwnd); if (!string.IsNullOrWhiteSpace(executablePath)) { return "app:" + executablePath.ToLowerInvariant(); } WindowEnumerator.GetWindowThreadProcessId(hwnd, out var lpdwProcessId); if (lpdwProcessId != 0) { return $"pid:{lpdwProcessId}"; } return $"hwnd:{((global::System.IntPtr)hwnd).ToInt64():X}"; } internal static float GetPanelCurvePreference(string key, float fallback) { try { float num = default(float); return ParsePanelCurvePreferences(Config?.GetValue(PanelCurvePreferences)).TryGetValue(key, ref num) ? Math.Clamp(num, 0f, 1f) : fallback; } catch (global::System.Exception ex) { Msg("[Curve] Failed to load preference: " + ex.Message); return fallback; } } internal static void SetPanelCurvePreference(string key, float value) { try { if (Config != null && !string.IsNullOrWhiteSpace(key)) { Dictionary val = ParsePanelCurvePreferences(Config.GetValue(PanelCurvePreferences)); val[key] = Math.Clamp(value, 0f, 1f); Config.Set(PanelCurvePreferences, SerializePanelCurvePreferences(val)); Config.Save(); } } catch (global::System.Exception ex) { Msg("[Curve] Failed to save preference: " + ex.Message); } } private static Dictionary ParsePanelCurvePreferences(string serialized) { Dictionary val = new Dictionary((IEqualityComparer)(object)StringComparer.OrdinalIgnoreCase); if (string.IsNullOrWhiteSpace(serialized)) { return val; } string[] array = serialized.Split(new char[2] { '\n', '\r' }, (StringSplitOptions)1); float num2 = default(float); foreach (string text in array) { int num = text.IndexOf('='); if (num > 0) { string text2 = Uri.UnescapeDataString(text.Substring(0, num)); if (float.TryParse(text.Substring(num + 1), (NumberStyles)167, (IFormatProvider)(object)CultureInfo.InvariantCulture, ref num2)) { val[text2] = Math.Clamp(num2, 0f, 1f); } } } return val; } private static string SerializePanelCurvePreferences(Dictionary prefs) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) List val = new List(); Enumerator enumerator = prefs.GetEnumerator(); try { while (enumerator.MoveNext()) { KeyValuePair current = enumerator.Current; string text = Uri.EscapeDataString(current.Key); string text2 = Math.Clamp(current.Value, 0f, 1f).ToString("R", (IFormatProvider)(object)CultureInfo.InvariantCulture); val.Add(text + "=" + text2); } } finally { ((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } return string.Join("\n", (global::System.Collections.Generic.IEnumerable)val); } internal static string NormalizeViewerCullingMode(string value) { value = (value ?? "").Trim().ToLowerInvariant(); if (!(value == "distance")) { return "frustum"; } return "distance"; } internal static string NormalizeEncoderPreference(string value) { value = (value ?? "").Trim().ToLowerInvariant().Replace("-", "_") .Replace(" ", "_"); if (value != null) { switch (value.Length) { case 10: { char c = value[1]; if (c != '2') { if (c != 'e' || !(value == "hevc_nvenc")) { break; } } else if (!(value == "h264_nvenc")) { break; } goto IL_0112; } case 8: { char c = value[1]; if (c != '2') { if (c != 'e' || (!(value == "hevc_amf") && !(value == "hevc_qsv"))) { break; } } else if (!(value == "h264_amf") && !(value == "h264_qsv")) { break; } goto IL_0112; } case 7: { char c = value[6]; if (c != '4') { if (c != '5' || !(value == "libx265")) { break; } } else if (!(value == "libx264")) { break; } goto IL_0112; } IL_0112: return value; } } return "auto"; } internal static float NormalizeStreamAudioOutputVolume(float value) { return Math.Clamp(value, 0f, 1f); } internal static string NormalizeStreamAudioGlobalMode(string value) { value = (value ?? "").Trim().ToLowerInvariant(); if (!(value == "auto") && !(value == "global")) { return "positional"; } return value; } internal static string NormalizeStreamAudioDistanceSpace(string value) { value = (value ?? "").Trim().ToLowerInvariant(); if (!(value == "local")) { return "global"; } return "local"; } internal static string NormalizeStreamAudioTypeGroup(string value) { value = (value ?? "").Trim().ToLowerInvariant().Replace("-", "_") .Replace(" ", "_"); if (!(value == "soundeffect") && !(value == "sound_effect")) { if (!(value == "voice")) { if (value == "ui" || value == "user_interface") { return "ui"; } return "multimedia"; } return "voice"; } return "sound_effect"; } internal static string NormalizeStreamAudioRolloffMode(string value) { value = (value ?? "").Trim().ToLowerInvariant().Replace("-", "_") .Replace(" ", "_"); if (!(value == "logarithmic_fade_off") && !(value == "logarithmicfadeoff")) { return "linear"; } return "logarithmic_fade_off"; } private static bool? ParseStreamAudioGlobalMode(string value) { string text = NormalizeStreamAudioGlobalMode(value); if (!(text == "auto")) { if (text == "positional") { return false; } return true; } return null; } private static AudioDistanceSpace ParseStreamAudioDistanceSpace(string value) { if (NormalizeStreamAudioDistanceSpace(value) == "local") { return (AudioDistanceSpace)0; } return (AudioDistanceSpace)1; } private static AudioTypeGroup ParseStreamAudioTypeGroup(string value) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) string text = NormalizeStreamAudioTypeGroup(value); if (!(text == "sound_effect")) { if (!(text == "voice")) { if (text == "ui") { return (AudioTypeGroup)3; } return (AudioTypeGroup)1; } return (AudioTypeGroup)2; } return (AudioTypeGroup)0; } private static AudioRolloffCurve ParseStreamAudioRolloffMode(string value) { if (NormalizeStreamAudioRolloffMode(value) == "linear") { return (AudioRolloffCurve)3; } return (AudioRolloffCurve)2; } internal static void ApplyStreamAudioSettings(DesktopSession session) { //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) if (session == null || Config == null) { return; } try { if (session.VideoTexture != null && !((ComponentBase)(object)session.VideoTexture).IsDestroyed) { ((SyncField)(object)session.VideoTexture.Volume).Value = 1f; } AudioOutput streamAudioOutput = session.StreamAudioOutput; if (streamAudioOutput != null && !((ComponentBase)(object)streamAudioOutput).IsDestroyed) { ((SyncField)(object)streamAudioOutput.Global).Value = ParseStreamAudioGlobalMode(Config.GetValue(StreamAudioGlobalMode)); ((SyncField)(object)streamAudioOutput.Spatialize).Value = Config.GetValue(StreamAudioSpatialize); ((SyncField)(object)streamAudioOutput.SpatialBlend).Value = Math.Clamp(Config.GetValue(StreamAudioSpatialBlend), 0f, 1f); ((SyncField)(object)streamAudioOutput.DistanceSpace).Value = ParseStreamAudioDistanceSpace(Config.GetValue(StreamAudioDistanceSpace)); ((SyncField)(object)streamAudioOutput.DopplerLevel).Value = Math.Clamp(Config.GetValue(StreamAudioDopplerLevel), 0f, 1f); ((SyncField)(object)streamAudioOutput.Pitch).Value = Math.Clamp(Config.GetValue(StreamAudioPitch), 0.5f, 2f); ((SyncField)(object)streamAudioOutput.IgnoreAudioEffects).Value = Config.GetValue(StreamAudioIgnoreAudioEffects); ((SyncField)(object)streamAudioOutput.AudioTypeGroup).Value = ParseStreamAudioTypeGroup(Config.GetValue(StreamAudioTypeGroup)); ((SyncField)(object)streamAudioOutput.RolloffMode).Value = ParseStreamAudioRolloffMode(Config.GetValue(StreamAudioRolloffMode)); ((SyncField)(object)streamAudioOutput.MinDistance).Value = Math.Clamp(Config.GetValue(StreamAudioMinDistance), 0f, 10f); ((SyncField)(object)streamAudioOutput.MaxDistance).Value = Math.Clamp(Config.GetValue(StreamAudioMaxDistance), 1f, 50f); ((SyncField)(object)streamAudioOutput.SpatializationStartDistance).Value = Math.Clamp(Config.GetValue(StreamAudioSpatializationStartDistance), 0f, 10f); ((SyncField)(object)streamAudioOutput.SpatializationTransitionRange).Value = Math.Clamp(Config.GetValue(StreamAudioSpatializationTransitionRange), 0f, 10f); ((SyncField)(object)streamAudioOutput.Priority).Value = Math.Clamp(Config.GetValue(StreamAudioPriority), 0, 256); ((SyncField)(object)streamAudioOutput.MinScale).Value = Math.Clamp(Config.GetValue(StreamAudioMinScale), 0f, 1000f); ((SyncField)(object)streamAudioOutput.MaxScale).Value = Math.Clamp(Config.GetValue(StreamAudioMaxScale), 0f, 1000f); } } catch (global::System.Exception ex) { Msg("[StreamAudio] Failed to apply settings: " + ex.Message); } } internal static void ApplyStreamAudioSettingsToAllSessions() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) Enumerator enumerator = Enumerable.ToList((global::System.Collections.Generic.IEnumerable)ActiveSessions).GetEnumerator(); try { while (enumerator.MoveNext()) { DesktopSession current = enumerator.Current; if (current != null && !current.Cleaned) { ApplyStreamAudioSettings(current); } } } finally { ((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } } internal static string NormalizeStreamNetworkMode(string value) { value = (value ?? "").Trim().ToLowerInvariant().Replace("-", "_") .Replace(" ", "_"); if (!(value == "port_forward")) { return "cloudflare"; } return "port_forward"; } internal static string NormalizePortForwardHostMode(string value) { value = (value ?? "").Trim().ToLowerInvariant(); if (!(value == "manual")) { return "auto"; } return "manual"; } internal static string NormalizePortForwardAutoIpMode(string value) { return "external"; } internal static Uri GetBuiltInStreamUrl(int streamId) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown string builtInStreamBaseUrl = GetBuiltInStreamBaseUrl(); if (!string.IsNullOrWhiteSpace(builtInStreamBaseUrl)) { return new Uri($"{builtInStreamBaseUrl}/stream/{streamId}"); } return null; } internal static string GetBuiltInStreamBaseUrl() { if (NormalizeStreamNetworkMode(Config?.GetValue(StreamNetworkMode)) == "cloudflare") { return TunnelUrl; } string text = ResolvePortForwardHost(); if (!string.IsNullOrWhiteSpace(text)) { return $"http://{text}:{48080}"; } return null; } internal static string ResolvePortForwardHost() { if (Config != null && NormalizePortForwardHostMode(Config.GetValue(PortForwardHostMode)) == "manual") { return Config.GetValue(PortForwardHost)?.Trim(); } return GetAutoExternalIPv4Address(); } internal static string GetBestLocalIPv4Address() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Invalid comparison between Unknown and I4 try { NetworkInterface[] allNetworkInterfaces = NetworkInterface.GetAllNetworkInterfaces(); foreach (NetworkInterface val in allNetworkInterfaces) { if ((int)val.OperationalStatus != 1 || (int)val.NetworkInterfaceType == 24) { continue; } global::System.Collections.Generic.IEnumerator enumerator = val.GetIPProperties().UnicastAddresses.GetEnumerator(); try { while (((global::System.Collections.IEnumerator)enumerator).MoveNext()) { UnicastIPAddressInformation current = enumerator.Current; if ((int)((IPAddressInformation)current).Address.AddressFamily == 2 && !IPAddress.IsLoopback(((IPAddressInformation)current).Address)) { return ((object)((IPAddressInformation)current).Address).ToString(); } } } finally { ((global::System.IDisposable)enumerator)?.Dispose(); } } } catch (global::System.Exception ex) { Msg("[Network] Failed to auto-detect local IP: " + ex.Message); } return ""; } [DllImport("kernel32.dll", CharSet = (CharSet)3, SetLastError = true)] private static extern SafeFileHandle CreateJobObject(nint lpJobAttributes, string lpName); [DllImport("kernel32.dll", SetLastError = true)] private static extern bool SetInformationJobObject(SafeFileHandle hJob, int jobObjectInfoClass, nint lpJobObjectInfo, uint cbJobObjectInfoLength); [DllImport("kernel32.dll", SetLastError = true)] private static extern bool AssignProcessToJobObject(SafeFileHandle hJob, nint hProcess); private static string LaunchClientPath() { if (_launchClientResolved) { return _launchClientPath; } _launchClientResolved = true; _launchClientPath = (DesktopBuddyPlatform.IsLinux ? ResolveLaunchClient() : null); if (_launchClientPath != null) { Msg("[Tunnel] In Steam container; cloudflared will run on the host via " + _launchClientPath); } return _launchClientPath; } private static string ResolveLaunchClient() { try { if (!File.Exists("/run/host/container-manager") && !Directory.Exists("/run/pressure-vessel")) { return null; } string[] array = new string[2] { "/usr/bin/steam-runtime-launch-client", "/usr/lib/pressure-vessel/from-host/bin/steam-runtime-launch-client" }; foreach (string text in array) { if (File.Exists(text)) { return text; } } return "steam-runtime-launch-client"; } catch (global::System.Exception ex) { Msg("[Tunnel] Launch-client probe failed: " + ex.Message); return null; } } internal static string RunOnHostCapture(string exe, string args, int timeoutMs) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown try { ProcessStartInfo val = new ProcessStartInfo { RedirectStandardOutput = true, RedirectStandardError = true, UseShellExecute = false, CreateNoWindow = true }; string text = LaunchClientPath(); if (text != null) { val.FileName = text; val.Arguments = "--alongside-steam -- " + exe + " " + args; } else { val.FileName = exe; val.Arguments = args; } Process val2 = Process.Start(val); if (val2 == null) { return null; } string text2 = ((TextReader)val2.StandardOutput).ReadToEnd(); if (!val2.WaitForExit(timeoutMs)) { try { val2.Kill(); } catch { } return null; } return text2?.Trim(); } catch (global::System.Exception ex) { Msg("[HostCmd] " + exe + " failed: " + ex.Message); return null; } } private static ProcessStartInfo MakeCloudflaredPsi(string exe, string args) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown ProcessStartInfo val = new ProcessStartInfo { RedirectStandardOutput = true, RedirectStandardError = true, UseShellExecute = false, CreateNoWindow = true }; string text = LaunchClientPath(); if (text != null) { val.FileName = text; val.Arguments = "--alongside-steam -- \"" + exe + "\" " + args; } else { val.FileName = exe; val.Arguments = args; } return val; } private static void EnsureExecutable(string path) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) if (!DesktopBuddyPlatform.IsLinux) { return; } try { UnixFileMode unixFileMode = File.GetUnixFileMode(path); UnixFileMode val = (UnixFileMode)(unixFileMode | 0x40 | 8 | 1); if (unixFileMode != val) { File.SetUnixFileMode(path, val); } } catch (global::System.Exception ex) { Msg("[Tunnel] Could not set exec bit on " + path + ": " + ex.Message); } } private static string FindCloudflared() { if (DesktopBuddyPlatform.IsLinux) { if (ProbeCloudflared("cloudflared", isPath: false)) { return "cloudflared"; } Msg("[Tunnel] cloudflared not found on host PATH (install it: sudo pacman -S cloudflared)"); return null; } string text = DesktopBuddyRuntimePaths.FindFile(CloudflaredFileName); if (ProbeCloudflared(text, isPath: true)) { return text; } Msg("[Tunnel] cloudflared not usable (bundled='" + text + "')"); return null; } private static bool ProbeCloudflared(string fileName, bool isPath) { try { if (isPath && !File.Exists(fileName)) { Msg("[Tunnel] cloudflared not present at " + fileName); return false; } if (isPath) { EnsureExecutable(fileName); } Process val = Process.Start(MakeCloudflaredPsi(fileName, "version")); if (val == null) { Msg("[Tunnel] cloudflared probe: Process.Start returned null for " + fileName); return false; } string text = ((TextReader)val.StandardOutput).ReadToEnd(); string text2 = ((TextReader)val.StandardError).ReadToEnd(); val.WaitForExit(5000); if (val.HasExited && val.ExitCode == 0) { Msg($"[Tunnel] Found cloudflared: {fileName} ({text.Trim()})"); return true; } string text3 = (val.HasExited ? $"exit={val.ExitCode}" : "did not exit in 5s"); Msg($"[Tunnel] cloudflared probe {text3} for {fileName}{(string.IsNullOrWhiteSpace(text2) ? "" : (" err=" + text2.Trim()))}"); return false; } catch (global::System.Exception ex) { Msg("[Tunnel] cloudflared probe failed for " + fileName + ": " + ex.Message); return false; } } private static void KillTunnel() { try { if (_tunnelProcess != null && !_tunnelProcess.HasExited) { _tunnelProcess.Kill(); } } catch (global::System.Exception ex) { Msg("[Tunnel] Kill failed: " + ex.Message); } _tunnelProcess = null; try { SafeFileHandle tunnelJob = _tunnelJob; if (tunnelJob != null) { ((SafeHandle)tunnelJob).Dispose(); } } catch (global::System.Exception ex2) { Msg("[Tunnel] Job dispose failed: " + ex2.Message); } _tunnelJob = null; } private static void OnTunnelError(string data) { } private static void UpdateSessionTunnelUrls() { //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Expected O, but got Unknown //IL_0112: Unknown result type (might be due to invalid IL or missing references) try { if (TunnelUrl == null || !UseCloudflareTunnel) { return; } DesktopSession[] array; try { array = ActiveSessions.ToArray(); } catch (global::System.Exception ex) { Msg($"[Tunnel] Active session snapshot failed: {ex}"); return; } DesktopSession[] array2 = array; foreach (DesktopSession desktopSession in array2) { try { if (desktopSession == null || desktopSession.Cleaned || desktopSession.StreamId <= 0) { continue; } VideoTextureProvider videoTexture = desktopSession.VideoTexture; if (videoTexture == null || ((ComponentBase)(object)videoTexture).IsDestroyed) { continue; } Slot root = desktopSession.Root; World val = ((root != null) ? ((Worker)root).World : null) ?? ((Worker)videoTexture).World; if (val == null) { continue; } Uri newUrl = GetBuiltInStreamUrl(desktopSession.StreamId); if (newUrl == (Uri)null) { continue; } DesktopSession capturedSession = desktopSession; int capturedStreamId = desktopSession.StreamId; val.RunInUpdates(0, (Action)delegate { try { if (capturedSession != null && !capturedSession.Cleaned) { VideoTextureProvider videoTexture2 = capturedSession.VideoTexture; if (videoTexture2 != null && !((ComponentBase)(object)videoTexture2).IsDestroyed) { Msg($"[Tunnel] Updating session VTP -> {newUrl}"); SetRemoteStreamUrl(capturedSession, newUrl, $"tunnel refresh streamId={capturedStreamId}"); } } } catch (global::System.Exception ex4) { Msg($"[Tunnel] VTP update callback error: {ex4}"); } }); } catch (global::System.Exception ex2) { Msg($"[Tunnel] Session URL refresh skipped: {ex2}"); } } } catch (global::System.Exception ex3) { Msg($"[Tunnel] URL refresh error: {ex3}"); } } private static void RestartTunnel() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown if (_tunnelRestarting) { return; } _tunnelRestarting = true; object obj = <>c.<>9__249_0; if (obj == null) { Action val = delegate { try { Msg("[Tunnel] === RESTART ==="); KillTunnel(); TunnelUrl = null; Thread.Sleep(2000); StartTunnel(); } catch (global::System.Exception ex) { Msg($"[Tunnel] Restart task error: {ex}"); } finally { _tunnelRestarting = false; } }; <>c.<>9__249_0 = val; obj = (object)val; } global::System.Threading.Tasks.Task.Run((Action)obj); } private static void StartTunnel() { //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Expected O, but got Unknown //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Expected O, but got Unknown //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Expected O, but got Unknown try { if (!UseCloudflareTunnel) { Msg("[Tunnel] Cloudflare disabled by network mode"); return; } if (_cfPath == null) { _cfPath = FindCloudflared(); if (_cfPath == null) { Msg("[Tunnel] cloudflared not found - tunnel unavailable"); return; } } Msg("[Tunnel] Starting cloudflared tunnel: " + _cfPath); string text = (DesktopBuddyPlatform.IsLinux ? "/dev/null" : "NUL"); string args = $"tunnel --config {text} --url http://localhost:{48080} --proxy-keepalive-timeout 5m --proxy-keepalive-connections 100 --proxy-tcp-keepalive 15s --proxy-connect-timeout 30s --compression-quality 0 --grace-period 30s --no-autoupdate --edge-ip-version 4"; _tunnelProcess = Process.Start(MakeCloudflaredPsi(_cfPath, args)); if (_tunnelProcess == null) { Msg("[Tunnel] Failed to start cloudflared"); return; } Process proc = _tunnelProcess; if (!DesktopBuddyPlatform.IsLinux) { AttachTunnelToKillJob(proc); } proc.EnableRaisingEvents = true; proc.Exited += (EventHandler)delegate { Msg($"[Tunnel] cloudflared exited (code={proc.ExitCode}), restarting"); try { SafeFileHandle tunnelJob = _tunnelJob; if (tunnelJob != null) { ((SafeHandle)tunnelJob).Dispose(); } } catch { } _tunnelJob = null; RestartTunnel(); }; Process obj = proc; object obj2 = <>c.<>9__250_1; if (obj2 == null) { DataReceivedEventHandler val = delegate(object s, DataReceivedEventArgs e) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) if (e.Data != null) { if (e.Data.Contains("https://") && e.Data.Contains(".trycloudflare.com")) { int num = e.Data.IndexOf("https://"); string text2 = e.Data.Substring(num).Trim(); int num2 = text2.IndexOf(' '); if (num2 > 0) { text2 = text2.Substring(0, num2); } try { text2 = new Uri(text2).GetLeftPart((UriPartial)1); } catch (global::System.Exception ex2) { Msg("[Tunnel] URL parse error: " + ex2.Message); } string tunnelUrl = TunnelUrl; TunnelUrl = text2; if (tunnelUrl != text2) { Msg("[Tunnel] PUBLIC URL: " + TunnelUrl); try { UpdateSessionTunnelUrls(); } catch (global::System.Exception ex3) { Msg($"[Tunnel] PUBLIC URL refresh error: {ex3}"); } } } else if (ShouldLogCloudflaredLine(e.Data)) { Msg("[Tunnel] " + e.Data); } OnTunnelError(e.Data); } }; <>c.<>9__250_1 = val; obj2 = (object)val; } obj.ErrorDataReceived += (DataReceivedEventHandler)obj2; Process obj3 = proc; object obj4 = <>c.<>9__250_2; if (obj4 == null) { DataReceivedEventHandler val2 = delegate(object s, DataReceivedEventArgs e) { if (e.Data != null && ShouldLogCloudflaredLine(e.Data)) { Msg("[Tunnel] " + e.Data); } }; <>c.<>9__250_2 = val2; obj4 = (object)val2; } obj3.OutputDataReceived += (DataReceivedEventHandler)obj4; proc.BeginErrorReadLine(); proc.BeginOutputReadLine(); } catch (global::System.Exception ex) { Msg("[Tunnel] Error: " + ex.Message); } } private static bool ShouldLogCloudflaredLine(string line) { if (string.IsNullOrWhiteSpace(line)) { return false; } if (line.Contains(" INF ", (StringComparison)4)) { return false; } if (line.Contains("Configuration file NUL was empty", (StringComparison)5)) { return false; } if (line.Contains("Cannot determine default configuration path", (StringComparison)5)) { return false; } if (line.Contains("stream ", (StringComparison)5) && line.Contains("canceled by remote", (StringComparison)5)) { return false; } if (line.Contains("Request failed", (StringComparison)5) && line.Contains("canceled by remote", (StringComparison)5)) { return false; } if (!line.Contains(" ERR ", (StringComparison)4) && !line.Contains(" WRN ", (StringComparison)4) && !line.Contains("error", (StringComparison)5)) { return line.Contains("failed", (StringComparison)5); } return true; } private static void AttachTunnelToKillJob(Process proc) { try { SafeFileHandle tunnelJob = _tunnelJob; if (tunnelJob != null) { ((SafeHandle)tunnelJob).Dispose(); } _tunnelJob = CreateJobObject(global::System.IntPtr.Zero, null); if (_tunnelJob == null || ((SafeHandle)_tunnelJob).IsInvalid) { Msg($"[Tunnel] CreateJobObject failed: {Marshal.GetLastWin32Error()}"); return; } JOBOBJECT_EXTENDED_LIMIT_INFORMATION jOBOBJECT_EXTENDED_LIMIT_INFORMATION = new JOBOBJECT_EXTENDED_LIMIT_INFORMATION { BasicLimitInformation = { LimitFlags = 8192u } }; int num = Marshal.SizeOf(); nint num2 = Marshal.AllocHGlobal(num); try { Marshal.StructureToPtr(jOBOBJECT_EXTENDED_LIMIT_INFORMATION, (global::System.IntPtr)num2, false); if (!SetInformationJobObject(_tunnelJob, 9, num2, (uint)num)) { Msg($"[Tunnel] SetInformationJobObject failed: {Marshal.GetLastWin32Error()}"); return; } } finally { Marshal.FreeHGlobal((global::System.IntPtr)num2); } if (!AssignProcessToJobObject(_tunnelJob, proc.Handle)) { Msg($"[Tunnel] AssignProcessToJobObject failed: {Marshal.GetLastWin32Error()}"); } else { Msg($"[Tunnel] cloudflared attached to kill-on-close job pid={proc.Id}"); } } catch (global::System.Exception ex) { Msg("[Tunnel] Job attach failed: " + ex.Message); } } internal static void ClearExternalIpCache() { lock (ExternalIpGate) { _cachedExternalIPv4 = null; _cachedExternalIPv4At = global::System.DateTime.MinValue; } } internal static string GetAutoExternalIPv4Address() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Invalid comparison between Unknown and I4 lock (ExternalIpGate) { if (!string.IsNullOrWhiteSpace(_cachedExternalIPv4) && global::System.DateTime.UtcNow - _cachedExternalIPv4At < TimeSpan.FromMinutes(10L)) { return _cachedExternalIPv4; } } string[] array = new string[2] { "https://api.ipify.org", "https://checkip.amazonaws.com" }; IPAddress val = default(IPAddress); foreach (string text in array) { try { if (IPAddress.TryParse(ExternalIpClient.GetStringAsync(text).GetAwaiter().GetResult()?.Trim(), ref val) && (int)val.AddressFamily == 2) { string text2 = ((object)val).ToString(); lock (ExternalIpGate) { _cachedExternalIPv4 = text2; _cachedExternalIPv4At = global::System.DateTime.UtcNow; } return text2; } } catch (global::System.Exception ex) { Msg("[PortForward] External IP lookup failed at " + text + ": " + ex.Message); } } return ""; } internal static void ApplyStreamNetworkMode() { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown if (IsMediaMtxEnabled) { RemovePortForwardNatMapping(); KillTunnel(); TunnelUrl = null; RefreshBuiltInStreamUrls(); return; } if (StreamServer == null) { RemovePortForwardNatMapping(); RefreshBuiltInStreamUrls(); return; } if (UseCloudflareTunnel) { RemovePortForwardNatMapping(); bool flag = false; try { flag = _tunnelProcess != null && !_tunnelProcess.HasExited; } catch { } if (!flag) { object obj2 = <>c.<>9__261_0; if (obj2 == null) { Action val = delegate { StartTunnel(); }; <>c.<>9__261_0 = val; obj2 = (object)val; } global::System.Threading.Tasks.Task.Run((Action)obj2); } } else { KillTunnel(); TunnelUrl = null; ApplyPortForwardNatMapping(); } RefreshBuiltInStreamUrls(); } internal static bool ApplyPortForwardNatMapping() { DesktopBuddyConfig config = Config; if (config == null || !config.GetValue(PortForwardUseNat) || UseCloudflareTunnel || IsMediaMtxEnabled) { RemovePortForwardNatMapping(); return false; } string bestLocalIPv4Address = GetBestLocalIPv4Address(); if (string.IsNullOrWhiteSpace(bestLocalIPv4Address)) { Msg("[PortForward] UPnP/NAT mapping skipped: no local IPv4 address found"); return false; } lock (NatMappingGate) { try { object upnpMappings = GetUpnpMappings(); if (upnpMappings == null) { Msg("[PortForward] UPnP/NAT is not available on this system or router"); return false; } TryRemoveUpnpMapping(upnpMappings); upnpMappings.GetType().InvokeMember("Add", (BindingFlags)256, (Binder)null, upnpMappings, new object[6] { 48080, "TCP", 48080, bestLocalIPv4Address, true, "DesktopBuddy" }); _natMappingActive = true; Msg($"[PortForward] UPnP/NAT TCP {48080} -> {bestLocalIPv4Address}:{48080}"); return true; } catch (global::System.Exception ex) { Msg("[PortForward] UPnP/NAT mapping failed: " + ex.GetBaseException().Message); return false; } } } internal static void RemovePortForwardNatMapping() { lock (NatMappingGate) { bool natMappingActive = _natMappingActive; try { object upnpMappings = GetUpnpMappings(); if (upnpMappings != null) { TryRemoveUpnpMapping(upnpMappings); } if (natMappingActive) { Msg($"[PortForward] Removed UPnP/NAT TCP {48080}"); } } catch (global::System.Exception ex) { if (natMappingActive) { Msg("[PortForward] UPnP/NAT removal failed: " + ex.GetBaseException().Message); } } finally { _natMappingActive = false; } } } internal static void RefreshBuiltInStreamUrls() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Expected O, but got Unknown Uri val = null; try { string builtInStreamBaseUrl = GetBuiltInStreamBaseUrl(); if (!string.IsNullOrWhiteSpace(builtInStreamBaseUrl)) { val = new Uri(builtInStreamBaseUrl); } } catch (global::System.Exception ex) { Msg("[PortForward] Stream base URL refresh failed: " + ex.Message); } Enumerator enumerator = ActiveSessions.GetEnumerator(); try { while (enumerator.MoveNext()) { DesktopSession current = enumerator.Current; if (current?.VideoTexture == null || ((ComponentBase)(object)current.VideoTexture).IsDestroyed || current.StreamId <= 0 || val == (Uri)null) { continue; } VideoTextureProvider vtp = current.VideoTexture; DesktopSession capturedSession = current; Uri newUrl = new Uri(val, $"/stream/{current.StreamId}"); ((Worker)vtp).World.RunInUpdates(0, (Action)delegate { if (vtp != null && !((ComponentBase)(object)vtp).IsDestroyed) { SetRemoteStreamUrl(capturedSession, newUrl, $"network base refresh streamId={capturedSession.StreamId}"); } }); } } finally { ((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } lock (_sharedStreams) { Enumerator enumerator2 = _sharedStreams.Values.GetEnumerator(); try { while (enumerator2.MoveNext()) { SharedStream current2 = enumerator2.Current; if (current2 != null && current2.StreamId > 0 && !(val == (Uri)null)) { current2.StreamUrl = new Uri(val, $"/stream/{current2.StreamId}"); } } } finally { ((global::System.IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose(); } } } private static object GetUpnpMappings() { global::System.Type typeFromProgID = global::System.Type.GetTypeFromProgID("HNetCfg.NATUPnP"); if (typeFromProgID == (global::System.Type)null) { return null; } object obj = Activator.CreateInstance(typeFromProgID); return typeFromProgID.InvokeMember("StaticPortMappingCollection", (BindingFlags)4096, (Binder)null, obj, (object[])null); } private static void TryRemoveUpnpMapping(object mappings) { try { mappings.GetType().InvokeMember("Remove", (BindingFlags)256, (Binder)null, mappings, new object[2] { 48080, "TCP" }); } catch { } } private static void CreateAdaptiveScreenLight(Slot root, DesktopSession session, nint hwnd, nint monitorHandle) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) if (root != null && !((ContainerWorker)(object)root).IsDestroyed && session != null) { Slot obj = root.AddSlot("DesktopBuddyAdaptiveLight", true); obj.PersistentSelf = false; obj.LocalPosition = new float3(0f, 0f, GetAdaptiveLightZOffset(session)); Light val = ((ContainerWorker)(object)obj).AttachComponent(true, (Action)null); ((SyncField)(object)val.LightType).Value = (LightType)0; ((SyncField)(object)val.Intensity).Value = 1f; ((SyncField)(object)val.Range).Value = 15f; ((SyncField)(object)val.ShadowType).Value = (ShadowType)2; ((SyncField)(object)val.ShadowStrength).Value = 1f; ((SyncField)(object)val.Color).Value = new colorX(1f, 1f, 1f, 1f, (ColorProfile)1); session.AdaptiveLight = val; session.AdaptiveLightSampler = new D3D11AverageColorSampler(); } } private static void UpdateAdaptiveScreenLightPosition(DesktopSession session) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (session?.AdaptiveLight != null && !((ComponentBase)(object)session.AdaptiveLight).IsDestroyed) { ((Component)session.AdaptiveLight).Slot.LocalPosition = new float3(0f, 0f, GetAdaptiveLightZOffset(session)); } } private static float GetAdaptiveLightZOffset(DesktopSession session) { float scale = ((session != null && session.PanelCanvasScale > 0f) ? session.PanelCanvasScale : 1f); return GetCurvedPanelDepth(session?.PanelMesh, scale) + -0.02f; } private static void TryUpdateAdaptiveScreenLightFromGpuFrame(DesktopSession session, nint device, nint context, nint texture, int width, int height) { //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Expected O, but got Unknown //IL_0114: Unknown result type (might be due to invalid IL or missing references) if (session?.AdaptiveLight == null || ((ComponentBase)(object)session.AdaptiveLight).IsDestroyed || session.AdaptiveLightSampler == null || device == (nint)global::System.IntPtr.Zero || context == (nint)global::System.IntPtr.Zero || texture == (nint)global::System.IntPtr.Zero || width <= 0 || height <= 0) { return; } long timestamp = Stopwatch.GetTimestamp(); long num = Interlocked.Read(ref session.AdaptiveLightLastSampleTicks); if (num != 0L && timestamp - num < AdaptiveLightSampleIntervalTicks) { return; } Interlocked.Exchange(ref session.AdaptiveLightLastSampleTicks, timestamp); colorX color; try { if (!session.AdaptiveLightSampler.TrySample(device, context, texture, width, height, out color)) { return; } } catch (global::System.Exception ex) { Msg("[AdaptiveLight] GPU average sample failed: " + ex.Message); return; } Slot root = session.Root; if (root == null || ((ContainerWorker)(object)root).IsDestroyed) { return; } ((Worker)root).World.RunInUpdates(0, (Action)delegate { //IL_004b: Unknown result type (might be due to invalid IL or missing references) if (!session.Cleaned && !((ContainerWorker)(object)root).IsDestroyed && session.AdaptiveLight != null && !((ComponentBase)(object)session.AdaptiveLight).IsDestroyed) { ((SyncField)(object)session.AdaptiveLight.Color).Value = color; } }); } private static void StartThrowDismissalTracker(Slot root, Grabbable grabbable, User localUser) { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) DesktopBuddyConfig config = Config; float3[] posHistory; floatQ[] rotHistory; double[] timeHistory; int histIdx; bool wasGrabbed; bool thrown; if (config == null || config.GetValue(ThrowToDestroy)) { posHistory = (float3[])(object)new float3[5]; rotHistory = (floatQ[])(object)new floatQ[5]; timeHistory = new double[5]; histIdx = 0; wasGrabbed = false; thrown = false; ((Worker)root).World.RunInUpdates(1, new Action(ThrowTrackLoop)); } void ThrowTrackLoop() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Expected O, but got Unknown //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) if (!(((ContainerWorker)(object)root).IsDestroyed || thrown)) { bool isGrabbed = grabbable.IsGrabbed; if (isGrabbed) { int num = histIdx % 5; posHistory[num] = root.GlobalPosition; rotHistory[num] = root.GlobalRotation; timeHistory[num] = ((Worker)root).World.Time.WorldTime; histIdx++; } else if (wasGrabbed && histIdx >= 2) { int num2 = (histIdx - 1) % 5; int num3 = ((histIdx >= 5) ? (histIdx % 5) : 0); double num4 = timeHistory[num2] - timeHistory[num3]; if (num4 > 0.001) { float3 val = (ref posHistory[num2]) - (ref posHistory[num3]); float3 linearVelocity = (ref val) / (float)num4; if (((float3)(ref linearVelocity)).Magnitude > 3f) { thrown = true; CharacterController obj = ((ContainerWorker)(object)root).AttachComponent(true, (Action)null); obj.SimulatingUser.Target = localUser; ((SyncField)(object)obj.Gravity).Value = new float3(0f, -9.81f, 0f); ((SyncField)(object)obj.LinearDamping).Value = 0.3f; obj.LinearVelocity = linearVelocity; int num5 = (histIdx - 2 + 5) % 5; double num6 = timeHistory[num2] - timeHistory[num5]; floatQ perFrameRot = floatQ.Identity; if (num6 > 0.001) { ref floatQ reference = ref rotHistory[num2]; floatQ conjugated = ((floatQ)(ref rotHistory[num5])).Conjugated; floatQ val2 = (ref reference) * (ref conjugated); float num7 = 1f / 60f / (float)num6; floatQ identity = floatQ.Identity; perFrameRot = MathX.Slerp(ref identity, val2, num7); } StartThrowFade(root, perFrameRot); return; } } histIdx = 0; } wasGrabbed = isGrabbed; ((Worker)root).World.RunInUpdates(isGrabbed ? 1 : 10, new Action(ThrowTrackLoop)); } } } private static void StartThrowFade(Slot root, floatQ perFrameRot) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) double startTime = ((Worker)root).World.Time.WorldTime; float3 lastPos = root.GlobalPosition; int frameCount = 0; ((Worker)root).World.RunInUpdates(1, new Action(FadeAndCollisionLoop)); void FadeAndCollisionLoop() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Expected O, but got Unknown //IL_0118: Unknown result type (might be due to invalid IL or missing references) if (!((ContainerWorker)(object)root).IsDestroyed) { frameCount++; float num = MathX.Clamp01((float)((((Worker)root).World.Time.WorldTime - startTime) / 1.0)); float num2 = MathX.Lerp(1f, 0f, num * num); Slot obj = root; float3 val = float3.One; obj.LocalScale = (ref val) * MathX.Max(0.01f, num2); Slot obj2 = root; floatQ localRotation = root.LocalRotation; obj2.LocalRotation = (ref localRotation) * (ref perFrameRot); float3 globalPosition = root.GlobalPosition; if (frameCount > 5) { val = (ref globalPosition) - (ref lastPos); if (((float3)(ref val)).Magnitude < 0.001f) { root.Destroy(); return; } } lastPos = globalPosition; if (num >= 1f) { root.Destroy(); } else { ((Worker)root).World.RunInUpdates(1, new Action(FadeAndCollisionLoop)); } } } } private static RemoteStreamVisual BuildRemoteStream(RemoteStreamBuildContext context) { //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_049b: Unknown result type (might be due to invalid IL or missing references) //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_04ac: Unknown result type (might be due to invalid IL or missing references) //IL_04c2: Unknown result type (might be due to invalid IL or missing references) //IL_04c7: Unknown result type (might be due to invalid IL or missing references) //IL_04da: Unknown result type (might be due to invalid IL or missing references) //IL_04f1: Unknown result type (might be due to invalid IL or missing references) //IL_0521: Unknown result type (might be due to invalid IL or missing references) Slot root = context.Root; DesktopSession session = context.Session; if (!context.UseMediaMtx && StreamServer == null) { Msg($"[RemoteStream] Skipped: MediaMtx={IsMediaMtxEnabled} StreamServer={StreamServer != null} StreamBase={GetBuiltInStreamBaseUrl() ?? "null"}"); return null; } try { SharedStream sharedStream = AcquireSharedStream(context.Hwnd, context.UseMediaMtx, context.LinuxPipeWireNodeId, context.Width, context.Height); session.StreamId = sharedStream.StreamId; session.Encoder = sharedStream.Encoder; session.StreamSource = sharedStream.Source; session.StreamUsesMediaMtx = sharedStream.UsesMediaMtx; session.StreamAudioCapture = sharedStream.Audio; session.StartStreamAudioCapture = sharedStream.StartAudio; FfmpegEncoder encoder = sharedStream.Encoder; ILiveStreamSource source = sharedStream.Source; if (session.SpatialAudioSource != null && sharedStream.Audio != null) { session.SpatialAudioSource.SetAudioCapture(sharedStream.Audio); } if (encoder != null && TryClaimSharedStreamDriver(context.Hwnd, sharedStream.StreamId, session)) { ConnectEncoder(session, encoder, sharedStream.Audio, sharedStream.StartAudio); Msg($"[RemoteStream] This panel drives the encoder for stream {sharedStream.StreamId}"); } else if (DesktopBuddyPlatform.IsLinux) { Msg($"[RemoteStream] Linux native stream owns capture for stream {sharedStream.StreamId}"); } else { Msg($"[RemoteStream] This panel shares encoder from stream {sharedStream.StreamId}, no encoding hook"); } Slot obj = root.AddSlot("StreamProvider", true); VideoTextureProvider val = TextureProviderSettings.ClampWrap(((ContainerWorker)(object)obj).AttachComponent(true, (Action)null)); ((SyncField)(object)val.Stream).Value = true; ((SyncField)(object)val.URL).Value = null; ((SyncField)(object)val.Volume).Value = 1f; session.VideoTexture = val; Uri streamUrl = sharedStream.StreamUrl; AudioOutput val2 = ((ContainerWorker)(object)obj).AttachComponent(true, (Action)null); ((SyncRef)(object)val2.Source).Target = (IWorldAudioDataSource)(object)val; ((SyncField)(object)val2.Volume).Value = context.StreamOutputVolume; ((SyncField)(object)val2.Global).Value = true; ((SyncField)(object)val2.Spatialize).Value = false; ((SyncField)(object)val2.SpatialBlend).Value = 0f; ((SyncField)(object)val2.DistanceSpace).Value = (AudioDistanceSpace)1; ((SyncField)(object)val2.DopplerLevel).Value = 0f; ((SyncField)(object)val2.Pitch).Value = 1f; ((SyncField)(object)val2.IgnoreAudioEffects).Value = true; ((SyncField)(object)val2.AudioTypeGroup).Value = (AudioTypeGroup)1; session.StreamAudioOutput = val2; ApplyStreamAudioSettings(session); ValueDriver obj2 = ((ContainerWorker)(object)obj).AttachComponent>(true, (Action>)null); ((SyncRef>)(object)obj2.DriveTarget).Target = (IField)(object)val2.Volume; obj2.ValueSource.Target = (IValue)(object)context.VolumeSlider.Value; if (session.SpatialAudioOutput != null) { AudioOutput spatialOut = session.SpatialAudioOutput; ((SyncField)(object)context.VolumeSlider.Value).OnValueChange += delegate(SyncField field) { if (spatialOut != null && !((ComponentBase)(object)spatialOut).IsDestroyed) { ((SyncField)(object)spatialOut.Volume).Value = field.Value; } }; } Slot val3 = root.AddSlot("RemoteStreamVisual", true); float3 one = float3.One; val3.LocalScale = (ref one) * context.CanvasScale; ValueUserOverride val4 = ((ContainerWorker)(object)val3).AttachComponent>(true, (Action>)null); ((SyncRef>)(object)val4.Target).Target = (IField)(object)val3.ActiveSelf_Field; ((SyncField)(object)((ValueOverrideBase)(object)val4).Default).Value = true; ((SyncField)(object)((ValueOverrideBase)(object)val4).CreateOverrideOnWrite).Value = false; ((SyncField)(object)((ValueOverrideBase)(object)val4).ClearOnUserLeave).Value = true; ((ValueOverrideBase)(object)val4).SetOverride(((Worker)root).World.LocalUser, false); session.StreamVisualAllowed = val4; Msg("[RemoteStream] Per-user culling gate controls stream visibility and playback"); CreateViewerCullingGate(session, val3, val, ((Worker)root).World.LocalUser); CurvedPlaneMesh val5 = AddCurvedTexturePlane(val3, "VideoTextureCurvedPlane", context.Width, context.Height, 1f, (IAssetProvider)(object)val, 0f, flipY: false, -100f); ((SyncField)(object)val5.Curvature).Value = MathX.Clamp(context.CurrentPanelCurvature.Invoke(), 0f, 1f); Canvas val6 = ((ContainerWorker)(object)val3).AttachComponent(true, (Action)null); ((ComponentBase)(object)val6.Collider.RawTarget).Enabled = false; ((SyncField)(object)val6.Size).Value = new float2((float)context.Width, (float)context.Height); UIBuilder val7 = new UIBuilder(val6); colorX val8 = new colorX(0f, 0f, 0f, 1f, (ColorProfile)1); Image val9 = val7.Image(ref val8, false); ((SyncField)(object)val9.Tint).Value = colorX.Clear; ((SyncField)(object)((ImageBase)val9).InteractionTarget).Value = false; val7.NestInto(((UIComponent)val9).RectTransform); RawImage obj3 = val7.RawImage((IAssetProvider)(object)val, false); ((SyncField)(object)obj3.Tint).Value = new colorX(1f, 1f, 1f, 0f, (ColorProfile)1); UI_UnlitMaterial val10 = ((ContainerWorker)(object)val3).AttachComponent(true, (Action)null); ((SyncField)(object)val10.BlendMode).Value = (BlendMode)2; ((SyncField)(object)val10.ZWrite).Value = (ZWrite)2; ((SyncField)(object)val10.OffsetUnits).Value = -100f; ((SyncRef>)(object)obj3.Material).Target = (IAssetProvider)(object)val10; Msg($"[RemoteStream] Created, URL={streamUrl}, streamId={sharedStream.StreamId}, refs={sharedStream.RefCount}"); ScheduleRemoteStreamBinding(root, session, val, source, streamUrl, sharedStream.StreamId, context.IsPrivate); ScheduleRemoteStreamPlaybackWatch(root, session, val, sharedStream.StreamId); return new RemoteStreamVisual { VideoTexture = val, StreamPlane = val5, StreamCanvas = val6 }; } catch (global::System.Exception ex) { Msg($"[RemoteStream] ERROR: {ex}"); return null; } } private static void ScheduleRemoteStreamBinding(Slot root, DesktopSession session, VideoTextureProvider videoTex, ILiveStreamSource streamSource, Uri streamUrl, int streamId, Func isPrivate) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) ((Worker)root).World.RunInUpdates(1, (Action)delegate { BindStreamUrlWhenReady(0); }); void BindStreamUrlWhenReady(int attempt) { //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Expected O, but got Unknown //IL_029e: Unknown result type (might be due to invalid IL or missing references) if (videoTex != null && !((ComponentBase)(object)videoTex).IsDestroyed && !((ContainerWorker)(object)root).IsDestroyed) { bool flag = streamSource?.IsRunning ?? false; bool flag2 = isPrivate.Invoke(); Uri val = streamUrl ?? GetBuiltInStreamUrl(streamId); if (flag && !flag2 && val != (Uri)null) { SetRemoteStreamUrl(session, val, $"initial bind streamId={streamId}"); Msg($"[RemoteStream] URL bound after stream readiness: attempt={attempt} streamId={streamId} {streamSource.ReadableStreamState}"); } else if (attempt >= 300) { Msg($"[RemoteStream] URL not bound: ready={flag}, urlReady={val != (Uri)null}, private={flag2}, streamId={streamId}, {streamSource?.ReadableStreamState ?? "no source"}"); } else { if (attempt == 0 || attempt % 30 == 0) { Msg($"[RemoteStream] Waiting before URL bind: attempt={attempt}, ready={flag}, urlReady={val != (Uri)null}, private={flag2}, {streamSource?.ReadableStreamState ?? "no source"}"); } ((Worker)root).World.RunInUpdates(6, (Action)delegate { BindStreamUrlWhenReady(attempt + 1); }); } } } } private static void ScheduleRemoteStreamPlaybackWatch(Slot root, DesktopSession session, VideoTextureProvider videoTex, int streamId) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) int checkCount = 0; bool loggedPlaybackReady = false; bool streamUrlBound = false; ((Worker)root).World.RunInUpdates(30, (Action)delegate { CheckVideoState(); }); void CheckVideoState() { //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Expected O, but got Unknown //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Expected O, but got Unknown //IL_01ba: Unknown result type (might be due to invalid IL or missing references) if (videoTex != null && !((ComponentBase)(object)videoTex).IsDestroyed && !((ContainerWorker)(object)root).IsDestroyed) { checkCount++; bool isAssetAvailable = ((AssetProvider)(object)videoTex).IsAssetAvailable; string text = videoTex.CurrentPlaybackEngine?.Value ?? "null"; bool isPlaying = videoTex.IsPlaying; float num = videoTex.CurrentClockError?.Value ?? (-1f); streamUrlBound = session.StreamUrl != (Uri)null || streamUrlBound; if (isAssetAvailable && !loggedPlaybackReady) { loggedPlaybackReady = true; Msg($"[RemoteStream] Playback ready: streamId={streamId} engine={text}"); } if (streamUrlBound && isAssetAvailable && !isPlaying && IsLocalStreamPlaybackAllowedNow(session)) { videoTex.Play(); Msg($"[RemoteStream] Restarted VideoTextureProvider playback streamId={streamId} clockErr={num:F2}"); } if (checkCount < 10) { ((Worker)root).World.RunInUpdates(60, (Action)delegate { CheckVideoState(); }); } else if (checkCount < 30) { ((Worker)root).World.RunInUpdates(1800, (Action)delegate { CheckVideoState(); }); } } } } internal static void SpawnStreaming(World world, nint hwnd, string title, nint monitorHandle = 0, int monitorIndex = -1, bool startPrivate = false) { //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) try { Msg($"[SpawnStreaming] Starting for '{title}' hwnd={hwnd} monitorIndex={monitorIndex} startPrivate={startPrivate}"); if (hwnd != (nint)global::System.IntPtr.Zero) { WindowEnumerator.GetWindowThreadProcessId(hwnd, out var lpdwProcessId); if (!WindowEnumerator.TryValidateStandaloneProcessWindow(hwnd, lpdwProcessId, out var title2, out var reason)) { Msg($"[SpawnStreaming] Ignored hwnd={hwnd}: {reason}"); return; } if (!string.IsNullOrWhiteSpace(title2)) { title = title2; } } User localUser = world.LocalUser; if (localUser == null) { Msg("[SpawnStreaming] LocalUser is null, aborting"); return; } UserRoot root = localUser.Root; if (root == null) { Msg("[SpawnStreaming] UserRoot is null, aborting"); return; } Slot val = (((Component)localUser.Root).Slot.Parent ?? world.RootSlot).AddSlot("Desktop Buddy", true); float3 headPosition = root.HeadPosition; floatQ headRotation = root.HeadRotation; float3 forward = float3.Forward; float3 val2 = (ref headRotation) * (ref forward); float userSpawnScale = GetUserSpawnScale(root); forward = float3.One; val.LocalScale = (ref forward) * userSpawnScale; forward = (ref val2) * (0.8f * userSpawnScale); val.GlobalPosition = (ref headPosition) + (ref forward); forward = float3.Up; val.GlobalRotation = floatQ.LookRotation(ref val2, ref forward); ((ContainerWorker)(object)val).AttachComponent(true, (Action)null).TargetUser.Target = localUser; Msg($"[SpawnStreaming] Slot created at pos={val.GlobalPosition} userScale={userSpawnScale}"); StartStreaming(val, hwnd, title, monitorHandle, monitorIndex, startPrivate); } catch (global::System.Exception ex) { Msg($"ERROR in SpawnStreaming: {ex}"); } } private static float GetUserSpawnScale(UserRoot userRoot) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) try { float3? obj; if (userRoot == null) { obj = null; } else { Slot slot = ((Component)userRoot).Slot; obj = ((slot != null) ? new float3?(slot.GlobalScale) : ((float3?)null)); } float3 val = (float3)(((??)obj) ?? float3.One); float num = MathF.Max(val.x, MathF.Max(val.y, val.z)); return (float.IsFinite(num) && num > 0.001f) ? num : 1f; } catch (global::System.Exception ex) { Msg("[SpawnStreaming] Failed to read user scale, using 1: " + ex.Message); return 1f; } } private static void StartStreaming(Slot root, nint hwnd, string title, nint monitorHandle = 0, int monitorIndex = -1, bool startPrivate = false) { //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown Msg($"[StartStreaming] Window: {title} (hwnd={hwnd} monitorIndex={monitorIndex})"); if (!DesktopBuddyPlatform.IsLinux) { WindowInput.RestoreIfMinimized(hwnd); } DesktopStreamer streamer = new DesktopStreamer(hwnd, monitorHandle); World world = ((Worker)root).World; Action val = default(Action); Action val4 = default(Action); Action val6 = default(Action); global::System.Threading.Tasks.Task.Run((Action)delegate { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_0083: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_0052: Expected O, but got Unknown //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Expected O, but got Unknown //IL_011a: Expected O, but got Unknown try { if (!streamer.TryInitialCapture()) { Msg("[StartStreaming] Failed initial capture for: " + title); streamer.Dispose(); World obj = world; Action obj2 = val; if (obj2 == null) { Action val2 = delegate { try { if (root != null && !((ContainerWorker)(object)root).IsDestroyed) { root.Destroy(); } } catch (global::System.Exception ex4) { Msg($"[StartStreaming] Failed-capture destroy error: {ex4}"); } }; Action val3 = val2; val = val2; obj2 = val3; } obj.RunInUpdates(0, obj2); } else { World obj3 = world; Action obj4 = val4; if (obj4 == null) { Action val5 = delegate { try { FinishStartStreaming(root, hwnd, title, streamer, monitorIndex, startPrivate); } catch (global::System.Exception ex4) { Msg($"[StartStreaming] FinishStartStreaming callback error: {ex4}"); try { streamer.Dispose(); } catch (global::System.Exception ex5) { Msg($"[StartStreaming] Streamer dispose after finish error: {ex5}"); } try { if (root != null && !((ContainerWorker)(object)root).IsDestroyed) { root.Destroy(); } } catch (global::System.Exception ex6) { Msg($"[StartStreaming] Root destroy after finish error: {ex6}"); } } }; Action val3 = val5; val4 = val5; obj4 = val3; } obj3.RunInUpdates(0, obj4); } } catch (global::System.Exception ex) { Msg($"[StartStreaming] Background capture task error: {ex}"); try { streamer.Dispose(); } catch (global::System.Exception ex2) { Msg($"[StartStreaming] Streamer dispose after task error: {ex2}"); } try { World obj5 = world; Action obj6 = val6; if (obj6 == null) { Action val7 = delegate { try { if (root != null && !((ContainerWorker)(object)root).IsDestroyed) { root.Destroy(); } } catch (global::System.Exception ex4) { Msg($"[StartStreaming] Root destroy after task error: {ex4}"); } }; Action val3 = val7; val6 = val7; obj6 = val3; } obj5.RunInUpdates(0, obj6); } catch (global::System.Exception ex3) { Msg($"[StartStreaming] Failed to schedule cleanup after task error: {ex3}"); } } }); } private static void FinishStartStreaming(Slot root, nint hwnd, string title, DesktopStreamer streamer, int monitorIndex = -1, bool startPrivate = false) { //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Expected O, but got Unknown //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_0436: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0636: Unknown result type (might be due to invalid IL or missing references) //IL_0664: Unknown result type (might be due to invalid IL or missing references) //IL_0805: Unknown result type (might be due to invalid IL or missing references) //IL_0832: Unknown result type (might be due to invalid IL or missing references) //IL_08af: Unknown result type (might be due to invalid IL or missing references) //IL_0946: Unknown result type (might be due to invalid IL or missing references) //IL_0973: Unknown result type (might be due to invalid IL or missing references) //IL_09e9: Unknown result type (might be due to invalid IL or missing references) //IL_0a6d: Unknown result type (might be due to invalid IL or missing references) //IL_0a9e: Unknown result type (might be due to invalid IL or missing references) //IL_0c98: Unknown result type (might be due to invalid IL or missing references) //IL_0cc5: Unknown result type (might be due to invalid IL or missing references) //IL_0d7a: Unknown result type (might be due to invalid IL or missing references) //IL_0d81: Expected O, but got Unknown //IL_0e16: Unknown result type (might be due to invalid IL or missing references) //IL_0e6e: Unknown result type (might be due to invalid IL or missing references) //IL_0e7b: Unknown result type (might be due to invalid IL or missing references) //IL_0e82: Expected O, but got Unknown //IL_0e9a: Unknown result type (might be due to invalid IL or missing references) //IL_0e9f: Unknown result type (might be due to invalid IL or missing references) //IL_0f07: Unknown result type (might be due to invalid IL or missing references) //IL_106e: Unknown result type (might be due to invalid IL or missing references) //IL_10f8: Unknown result type (might be due to invalid IL or missing references) //IL_10ff: Expected O, but got Unknown //IL_115a: Unknown result type (might be due to invalid IL or missing references) //IL_1164: Expected O, but got Unknown //IL_115f: Unknown result type (might be due to invalid IL or missing references) //IL_123a: Unknown result type (might be due to invalid IL or missing references) //IL_123f: Unknown result type (might be due to invalid IL or missing references) //IL_12d8: Unknown result type (might be due to invalid IL or missing references) //IL_12df: Expected O, but got Unknown //IL_1391: Unknown result type (might be due to invalid IL or missing references) //IL_1396: Unknown result type (might be due to invalid IL or missing references) //IL_13bd: Unknown result type (might be due to invalid IL or missing references) //IL_13c7: Expected O, but got Unknown //IL_1435: Unknown result type (might be due to invalid IL or missing references) //IL_143a: Unknown result type (might be due to invalid IL or missing references) //IL_14d1: Unknown result type (might be due to invalid IL or missing references) //IL_14d6: Unknown result type (might be due to invalid IL or missing references) //IL_155e: Unknown result type (might be due to invalid IL or missing references) //IL_1563: Unknown result type (might be due to invalid IL or missing references) //IL_1585: Unknown result type (might be due to invalid IL or missing references) //IL_158a: Unknown result type (might be due to invalid IL or missing references) //IL_15ac: Unknown result type (might be due to invalid IL or missing references) //IL_15b1: Unknown result type (might be due to invalid IL or missing references) //IL_1626: Unknown result type (might be due to invalid IL or missing references) //IL_162b: Unknown result type (might be due to invalid IL or missing references) //IL_16b3: Unknown result type (might be due to invalid IL or missing references) //IL_16b8: Unknown result type (might be due to invalid IL or missing references) //IL_172d: Unknown result type (might be due to invalid IL or missing references) //IL_1732: Unknown result type (might be due to invalid IL or missing references) //IL_17a8: Unknown result type (might be due to invalid IL or missing references) //IL_17ad: Unknown result type (might be due to invalid IL or missing references) //IL_17ea: Unknown result type (might be due to invalid IL or missing references) //IL_1867: Unknown result type (might be due to invalid IL or missing references) //IL_186e: Expected O, but got Unknown //IL_18c0: Unknown result type (might be due to invalid IL or missing references) //IL_18d1: Unknown result type (might be due to invalid IL or missing references) //IL_18e2: Unknown result type (might be due to invalid IL or missing references) //IL_1a64: Unknown result type (might be due to invalid IL or missing references) //IL_1a69: Unknown result type (might be due to invalid IL or missing references) //IL_1aa6: Unknown result type (might be due to invalid IL or missing references) //IL_1b23: Unknown result type (might be due to invalid IL or missing references) //IL_1b2a: Expected O, but got Unknown //IL_1c04: Unknown result type (might be due to invalid IL or missing references) //IL_1c15: Unknown result type (might be due to invalid IL or missing references) //IL_1c26: Unknown result type (might be due to invalid IL or missing references) //IL_1f21: Unknown result type (might be due to invalid IL or missing references) //IL_1f2b: Expected O, but got Unknown //IL_1f26: Unknown result type (might be due to invalid IL or missing references) //IL_1e7f: Unknown result type (might be due to invalid IL or missing references) //IL_1e8c: Unknown result type (might be due to invalid IL or missing references) //IL_1e99: Unknown result type (might be due to invalid IL or missing references) //IL_1ea5: Unknown result type (might be due to invalid IL or missing references) //IL_1ff4: Unknown result type (might be due to invalid IL or missing references) //IL_2008: Unknown result type (might be due to invalid IL or missing references) //IL_2054: Unknown result type (might be due to invalid IL or missing references) //IL_205e: Expected O, but got Unknown //IL_2059: Unknown result type (might be due to invalid IL or missing references) //IL_2084: Unknown result type (might be due to invalid IL or missing references) //IL_208e: Expected O, but got Unknown //IL_20a2: Unknown result type (might be due to invalid IL or missing references) //IL_20ac: Expected O, but got Unknown //IL_20b9: Unknown result type (might be due to invalid IL or missing references) //IL_20c3: Expected O, but got Unknown //IL_20e0: Unknown result type (might be due to invalid IL or missing references) //IL_20e5: Unknown result type (might be due to invalid IL or missing references) //IL_20f7: Unknown result type (might be due to invalid IL or missing references) //IL_2101: Expected O, but got Unknown //IL_21d3: Unknown result type (might be due to invalid IL or missing references) //IL_21dd: Expected O, but got Unknown //IL_22f9: Unknown result type (might be due to invalid IL or missing references) //IL_2303: Expected O, but got Unknown //IL_22fe: Unknown result type (might be due to invalid IL or missing references) //IL_23ce: Unknown result type (might be due to invalid IL or missing references) //IL_23d8: Expected O, but got Unknown //IL_22d0: Unknown result type (might be due to invalid IL or missing references) //IL_22da: Expected O, but got Unknown //IL_2411: Unknown result type (might be due to invalid IL or missing references) //IL_241b: Expected O, but got Unknown if (root == null || ((ContainerWorker)(object)root).IsDestroyed) { Msg("[StartStreaming] Root slot destroyed before capture completed: " + title); streamer.Dispose(); return; } int w = streamer.Width; int h = streamer.Height; Grabbable grabbable = null; Msg($"[StartStreaming] Capture size: {w}x{h}"); float canvasScale = 0.0005f; float worldHalfH = (float)h / 2f * canvasScale; float worldHalfW = (float)w / 2f * canvasScale; BoxCollider collider = null; Msg("[StartStreaming] Panel grab/click colliders are curved mesh colliders"); CurvedPlaneMesh frontPlaneRef = null; CurvedPlaneMesh backPlaneRef = null; CurvedPlaneMesh streamPlaneRef = null; CurvedPlaneMesh topBarStripRef = null; CurvedPlaneMesh topBarBackStripRef = null; DesktopUVRayExit displayRayExitRef = null; TextRenderer titleText = null; Slot deviceIndicatorsSlot = null; string panelCurvePreferenceKey = GetPanelCurvePreferenceKey(hwnd); float currentPanelCurvature = GetPanelCurvePreference(panelCurvePreferenceKey, 0.18f); DesktopSession session = null; Slot displaySlot = root.AddLocalSlot("Display", false); Slot obj = displaySlot; float3 one = float3.One; obj.LocalScale = (ref one) * canvasScale; Msg("[StartStreaming] Display slot (local) created"); DesktopTextureProvider val = TextureProviderSettings.ClampWrap(((ContainerWorker)(object)displaySlot.AddSlot("Texture", true)).AttachComponent(true, (Action)null)); ((SyncField)(object)val.DisplayIndex).Value = -2147483648; OurProviders.Add(val); int sharedTextureSlot = -1; int num = -1; bool flag = TextureBridgeChannel != null && TextureBridgeChannel.IsOpen && (DesktopBuddyPlatform.IsLinux || hwnd != (nint)global::System.IntPtr.Zero || streamer.MonitorHandle != (nint)global::System.IntPtr.Zero || monitorIndex >= 0); if (flag) { Msg("[StartStreaming] Shared texture bridge registration deferred until first current-size frame"); } else if (hwnd == (nint)global::System.IntPtr.Zero && monitorIndex >= 0) { ((SyncField)(object)val.DisplayIndex).Value = monitorIndex; Msg($"[StartStreaming] WARNING: Shared texture bridge unavailable; falling back to built-in monitor DisplayIndex={monitorIndex}"); } else { Msg($"[StartStreaming] WARNING: Cannot set up texture (hwnd={hwnd}, monitorIndex={monitorIndex}, bridge={TextureBridgeChannel?.IsOpen ?? false})"); } Msg("[StartStreaming] Texture component created"); Slot obj2 = displaySlot.AddSlot("InteractionCanvas", true); obj2.LocalScale = float3.One; Canvas val2 = ((ContainerWorker)(object)obj2).AttachComponent(true, (Action)null); ((SyncField)(object)val2.Size).Value = new float2((float)w, (float)h); UIBuilder ui = new UIBuilder(val2); ((ComponentBase)(object)ui.Canvas.Collider.RawTarget).Enabled = false; UIBuilder obj3 = ui; colorX val3 = new colorX(0f, 0f, 0f, 1f, (ColorProfile)1); Image val4 = obj3.Image(ref val3, false); ((SyncField)(object)val4.Tint).Value = colorX.Clear; ((SyncField)(object)((ImageBase)val4).InteractionTarget).Value = false; ui.NestInto(((UIComponent)val4).RectTransform); Msg("[StartStreaming] Interaction canvas created"); Slot val5 = obj2.AddSlot("InteractionCamera", true); val5.LocalPosition = float3.Zero; val5.LocalRotation = floatQ.Identity; displayRayExitRef = ((ContainerWorker)(object)val5).AttachComponent(true, (Action)null); displayRayExitRef.Size = new float2((float)w, (float)h); frontPlaneRef = AddCurvedTexturePlane(displaySlot, "FrontCurvedPlane", w, h, 1f, (IAssetProvider)(object)val, 0f, flipY: true, 100f); ApplyPanelCurvature(currentPanelCurvature); uint processId = 0u; if (!DesktopBuddyPlatform.IsLinux) { WindowEnumerator.GetWindowThreadProcessId(hwnd, out processId); } Msg($"[StartStreaming] Process ID: {processId}"); HashSet seenRelatedHwnds = new HashSet(); DesktopSession obj4 = new DesktopSession { Streamer = streamer, LinuxInputSessionId = streamer.LinuxInputSessionId, Texture = val, Canvas = ui.Canvas, Root = root, Hwnd = hwnd, ProcessId = processId, Collider = collider, UseTextureBridge = flag, BridgeRegistrationPending = flag, SharedTextureSlot = sharedTextureSlot, PendingBridgeDisplayIndex = num, BridgeDisplayIndexApplied = (num < 0), LastKnownW = w, LastKnownH = h, PanelMesh = frontPlaneRef, PanelCanvasScale = canvasScale }; User localUser = ((Worker)root).World.LocalUser; obj4.OwnerUserId = ((localUser != null) ? localUser.UserID : null); obj4.SeenRelatedHwnds = seenRelatedHwnds; session = obj4; ActiveSessions.Add(session); root.Destroyed += delegate { CleanupAndRemoveSession(session, "root destroyed"); }; DesktopBuddyConfig config = Config; if (config != null && config.GetValue(DynamicLightsEnabled)) { CreateAdaptiveScreenLight(root, session, hwnd, streamer.MonitorHandle); } DesktopCanvasIds.Add(((Worker)ui.Canvas).ReferenceID); Msg($"[StartStreaming] Registered canvas {((Worker)ui.Canvas).ReferenceID} for locomotion suppression"); DesktopInputWiring.Wire(root, hwnd, streamer, session, frontPlaneRef, () => grabbable); float barH = 60f; float barMarginBottom = 12f * canvasScale; float num2 = 7f; float num3 = 8f; float num4 = 46f; int num5 = Math.Max(1, w); int num6 = Interlocked.Increment(ref _nextTopBarRenderHostId); Slot barRenderHost = root.AddSlot($"DesktopBuddyTopBarRenderHost {num6}", false); session.TopBarRenderHost = barRenderHost; barRenderHost.PersistentSelf = false; ((ContainerWorker)(object)barRenderHost).AttachComponent(true, (Action)null); Msg($"[TopBar] Render host created under buddy root id={num6}"); root.Destroyed += delegate { if (barRenderHost != null && !((ContainerWorker)(object)barRenderHost).IsDestroyed) { barRenderHost.Destroy(); } }; Slot val6 = barRenderHost.AddSlot("TopBarRender", true); ((ContainerWorker)(object)val6).AttachComponent(true, (Action)null); Slot val7 = barRenderHost.AddSlot("TopBarBackRender", true); ((ContainerWorker)(object)val7).AttachComponent(true, (Action)null); Slot val8 = barRenderHost.AddSlot("TopBarCamera", true); val8.LocalPosition = new float3(0f, 0f, -1f); RenderTextureProvider barRenderTex = ((ContainerWorker)(object)val8).AttachComponent(true, (Action)null); ((SyncField)(object)barRenderTex.Size).Value = new int2(num5, (int)barH); ((SyncField)(object)barRenderTex.WrapModeU).Value = (TextureWrapMode)1; ((SyncField)(object)barRenderTex.WrapModeV).Value = (TextureWrapMode)1; Camera val9 = ((ContainerWorker)(object)val8).AttachComponent(true, (Action)null); ((SyncField)(object)val9.Projection).Value = (CameraProjection)1; ((SyncField)(object)val9.OrthographicSize).Value = barH * 0.5f; ((SyncField)(object)val9.UseTransformScale).Value = true; ((SyncField)(object)val9.Clear).Value = (CameraClearMode)1; ((SyncField)(object)val9.ClearColor).Value = colorX.Clear; ((SyncField)(object)val9.NearClipping).Value = 0.01f; ((SyncField)(object)val9.FarClipping).Value = 4f; ((SyncField)(object)val9.Postprocessing).Value = false; ((SyncField)(object)val9.RenderShadows).Value = false; ((SyncField)(object)val9.ForwardOnly).Value = true; ((SyncRef>)(object)val9.RenderTexture).Target = (IAssetProvider)(object)barRenderTex; val9.SelectiveRender.Add(val6); Slot val10 = barRenderHost.AddSlot("TopBarBackCamera", true); val10.LocalPosition = new float3(0f, 0f, -1f); RenderTextureProvider barBackRenderTex = ((ContainerWorker)(object)val10).AttachComponent(true, (Action)null); ((SyncField)(object)barBackRenderTex.Size).Value = new int2(num5, (int)barH); ((SyncField)(object)barBackRenderTex.WrapModeU).Value = (TextureWrapMode)1; ((SyncField)(object)barBackRenderTex.WrapModeV).Value = (TextureWrapMode)1; Camera obj5 = ((ContainerWorker)(object)val10).AttachComponent(true, (Action)null); ((SyncField)(object)obj5.Projection).Value = (CameraProjection)1; ((SyncField)(object)obj5.OrthographicSize).Value = barH * 0.5f; ((SyncField)(object)obj5.UseTransformScale).Value = true; ((SyncField)(object)obj5.Clear).Value = (CameraClearMode)1; ((SyncField)(object)obj5.ClearColor).Value = colorX.Clear; ((SyncField)(object)obj5.NearClipping).Value = 0.01f; ((SyncField)(object)obj5.FarClipping).Value = 4f; ((SyncField)(object)obj5.Postprocessing).Value = false; ((SyncField)(object)obj5.RenderShadows).Value = false; ((SyncField)(object)obj5.ForwardOnly).Value = true; ((SyncRef>)(object)obj5.RenderTexture).Target = (IAssetProvider)(object)barBackRenderTex; obj5.SelectiveRender.Add(val7); Slot barSlot = val6.AddSlot("TopBar", true); barSlot.LocalScale = float3.One; Canvas barCanvas = ((ContainerWorker)(object)barSlot).AttachComponent(true, (Action)null); ((SyncField)(object)barCanvas.Size).Value = new float2((float)num5, barH); ((Collider)barCanvas.Collider.Target).SetTrigger(); UI_UnlitMaterial val11 = ((ContainerWorker)(object)barSlot).AttachComponent(true, (Action)null); ((SyncField)(object)val11.BlendMode).Value = (BlendMode)2; ((SyncField)(object)val11.ZWrite).Value = (ZWrite)1; ((SyncField)(object)val11.OffsetUnits).Value = 500f; UI_UnlitMaterial barElementMat = ((ContainerWorker)(object)barSlot).AttachComponent(true, (Action)null); ((SyncField)(object)barElementMat.BlendMode).Value = (BlendMode)2; ((SyncField)(object)barElementMat.Sidedness).Value = (Sidedness)1; ((SyncField)(object)barElementMat.ZWrite).Value = (ZWrite)1; ((SyncField)(object)barElementMat.OffsetFactor).Value = -1f; ((SyncField)(object)barElementMat.OffsetUnits).Value = -500f; UI_UnlitMaterial val12 = ((ContainerWorker)(object)barSlot).AttachComponent(true, (Action)null); ((SyncField)(object)val12.BlendMode).Value = (BlendMode)2; ((SyncField)(object)val12.Sidedness).Value = (Sidedness)1; ((SyncField)(object)val12.ZWrite).Value = (ZWrite)1; ((SyncField)(object)val12.OffsetFactor).Value = -1f; ((SyncField)(object)val12.OffsetUnits).Value = -1000f; UI_UnlitMaterial val13 = ((ContainerWorker)(object)barSlot).AttachComponent(true, (Action)null); ((SyncField)(object)val13.BlendMode).Value = (BlendMode)2; ((SyncField)(object)val13.Sidedness).Value = (Sidedness)1; ((SyncField)(object)val13.ZWrite).Value = (ZWrite)1; ((SyncField)(object)val13.OffsetFactor).Value = -1f; ((SyncField)(object)val13.OffsetUnits).Value = -1500f; UI_TextUnlitMaterial barTextMat = ((ContainerWorker)(object)barSlot).AttachComponent(true, (Action)null); ((SyncField)(object)((TextUnlitMaterial)barTextMat).BlendMode).Value = (BlendMode)2; ((SyncField)(object)((TextUnlitMaterial)barTextMat).Sidedness).Value = (Sidedness)1; ((SyncField)(object)((TextUnlitMaterial)barTextMat).ZWrite).Value = (ZWrite)1; ((SyncField)(object)((TextUnlitMaterial)barTextMat).OffsetFactor).Value = -1f; ((SyncField)(object)((TextUnlitMaterial)barTextMat).OffsetUnits).Value = -2000f; Slot val14 = val7.AddSlot("TopBarBackPanel", true); val14.LocalScale = float3.One; Canvas barBackCanvas = ((ContainerWorker)(object)val14).AttachComponent(true, (Action)null); ((SyncField)(object)barBackCanvas.Size).Value = new float2((float)num5, barH); ((ComponentBase)(object)barBackCanvas.Collider.RawTarget).Enabled = false; UI_UnlitMaterial val15 = ((ContainerWorker)(object)val14).AttachComponent(true, (Action)null); ((SyncField)(object)val15.BlendMode).Value = (BlendMode)2; ((SyncField)(object)val15.Sidedness).Value = (Sidedness)3; ((SyncField)(object)val15.ZWrite).Value = (ZWrite)1; ((SyncField)(object)val15.OffsetUnits).Value = 500f; UI_TextUnlitMaterial obj6 = ((ContainerWorker)(object)val14).AttachComponent(true, (Action)null); ((SyncField)(object)((TextUnlitMaterial)obj6).BlendMode).Value = (BlendMode)2; ((SyncField)(object)((TextUnlitMaterial)obj6).Sidedness).Value = (Sidedness)3; ((SyncField)(object)((TextUnlitMaterial)obj6).ZWrite).Value = (ZWrite)1; ((SyncField)(object)((TextUnlitMaterial)obj6).OffsetFactor).Value = -1f; ((SyncField)(object)((TextUnlitMaterial)obj6).OffsetUnits).Value = -2000f; UIBuilder val16 = new UIBuilder(barCanvas); colorX value = default(colorX); ((colorX)(ref value))..ctor(0.055f, 0.06f, 0.08f, 0.8f, (ColorProfile)1); Image barBg = val16.Image(ref value, false); ((SyncRef>)(object)((ImageBase)barBg).Material).Target = (IAssetProvider)(object)val11; SpriteProvider roundedSprite = TextureProviderSettings.ClampWrap(((ContainerWorker)(object)barSlot).AttachComponent(true, (Action)null)); ((SyncRef>)(object)roundedSprite.Texture).Target = UIBuilder.GetCircleTexture(((Worker)root).World); ((SyncField)(object)roundedSprite.Borders).Value = new float4(0.49f, 0.49f, 0.49f, 0.49f); ((SyncField)(object)roundedSprite.FixedSize).Value = barH * 0.5f; ((SyncRef>)(object)((ImageBase)barBg).Sprite).Target = (IAssetProvider)(object)roundedSprite; ((SyncField)(object)((ImageBase)barBg).NineSliceSizing).Value = (NineSliceSizing)0; ((SyncField)(object)barBg.Tint).Value = value; UIBuilder val17 = new UIBuilder(barBackCanvas); val3 = new colorX(0.08f, 0.08f, 0.1f, 1f, (ColorProfile)1); Image barBackBg = val17.Image(ref val3, false); ((SyncRef>)(object)((ImageBase)barBackBg).Material).Target = (IAssetProvider)(object)val15; ((SyncRef>)(object)((ImageBase)barBackBg).Sprite).Target = (IAssetProvider)(object)roundedSprite; ((SyncField)(object)((ImageBase)barBackBg).NineSliceSizing).Value = (NineSliceSizing)0; ((SyncField)(object)barBackBg.Tint).Value = new colorX(0.055f, 0.06f, 0.08f, 0.8f, (ColorProfile)1); ((SyncField)(object)((ContainerWorker)(object)((Component)barBg).Slot).AttachComponent(true, (Action)null).ShowMaskGraphic).Value = true; val16.NestInto(((UIComponent)barBg).RectTransform); ((SyncField)(object)((DirectionalLayout)val16.HorizontalLayout(8f, 8f, (Alignment?)(Alignment)3)).ForceExpandWidth).Value = false; val16.Style.FlexibleWidth = -1f; val16.Style.FlexibleHeight = 1f; User localUser2 = ((Worker)root).World.LocalUser; val16.Style.MinWidth = 48f; val16.Style.PreferredWidth = 48f; val16.Style.MinHeight = 48f; val16.Style.PreferredHeight = 48f; val16.Style.FlexibleWidth = -1f; val16.Style.FlexibleHeight = -1f; Slot val18 = val16.Empty("Image Space"); ((SyncField)(object)((ContainerWorker)(object)val18).AttachComponent(true, (Action)null).ShowMaskGraphic).Value = false; Image component = ((ContainerWorker)(object)val18).GetComponent((Predicate)null, false); SpriteProvider val19 = TextureProviderSettings.ClampWrap(((ContainerWorker)(object)val18).AttachComponent(true, (Action)null)); ((SyncRef>)(object)val19.Texture).Target = UIBuilder.GetCircleTexture(((Worker)root).World); ((SyncField)(object)val19.Borders).Value = new float4(0.49f, 0.49f, 0.49f, 0.49f); ((SyncField)(object)val19.FixedSize).Value = num4 * 0.5f; ((SyncRef>)(object)((ImageBase)component).Sprite).Target = (IAssetProvider)(object)val19; ((SyncField)(object)((ImageBase)component).NineSliceSizing).Value = (NineSliceSizing)0; ((SyncRef>)(object)((ImageBase)component).Material).Target = (IAssetProvider)(object)barElementMat; val16.NestInto(val18); val16.Style.FlexibleWidth = -1f; val16.Style.FlexibleHeight = -1f; CloudUserInfo cloudUserInfo = ((ContainerWorker)(object)barSlot).AttachComponent(true, (Action)null); Uri value2 = new Uri("resdb:///bb7d7f1414e0c0a44b4684ecd2a5dc2086c18b3f70c9ed53d467fe96af94e9a9.png"); StaticTexture2D avatarTex = TextureProviderSettings.ClampWrap(((ContainerWorker)(object)barSlot).AttachComponent(true, (Action)null)); cloudUserInfo.UserId.ForceSet(localUser2.UserID); ((SyncField)(object)((StaticAssetProvider)(object)avatarTex).URL).Value = value2; int avatarRefreshAttempts = 0; ((Worker)root).World.RunInUpdates(1, new Action(RefreshAvatarIcon)); Image obj7 = val16.Image((IAssetProvider)(object)avatarTex); ((SyncRef>)(object)((ImageBase)obj7).Material).Target = (IAssetProvider)(object)val13; ((SyncField)(object)((ImageBase)obj7).InteractionTarget).Value = false; val16.NestOut(); float barCollapsedW = num2 * 2f + num4; float num7 = 545f; float barExpandedW = barCollapsedW + num3 + num7; int barRenderW = Math.Max(1, w); val16.Style.MinWidth = 0f; val16.Style.PreferredWidth = 0f; val16.Style.MinHeight = 0f; val16.Style.PreferredHeight = 0f; val16.Style.FlexibleWidth = -1f; val16.Style.FlexibleHeight = -1f; LocaleString val20 = LocaleString.op_Implicit("≡"); Button obj8 = val16.Button(ref val20); val16.Style.FlexibleWidth = -1f; val16.Style.FlexibleHeight = 1f; ((Component)obj8).Slot.ActiveSelf = false; val16.Style.MinWidth = num7; val16.Style.PreferredWidth = num7; val16.Style.MinHeight = 48f; val16.Style.PreferredHeight = 48f; Slot expandPanel = val16.Empty("ExpandPanel"); expandPanel.ActiveSelf = false; UIBuilder val21 = new UIBuilder(expandPanel, (Slot)null); ((SyncField)(object)((DirectionalLayout)val21.HorizontalLayout(6f, 6f, (Alignment?)(Alignment)3)).ForceExpandWidth).Value = false; val21.Style.FlexibleWidth = -1f; val21.Style.FlexibleHeight = 1f; val21.Style.MinWidth = 36f; val21.Style.PreferredWidth = 36f; val21.Style.MinHeight = 40f; val21.Style.PreferredHeight = 40f; val21.Style.FlexibleWidth = -1f; val21.Style.FlexibleHeight = -1f; val20 = LocaleString.op_Implicit("⚙"); Button settingsBtn = val21.Button(ref val20); StyleButton(settingsBtn); settingsBtn.LocalPressed += (ButtonEventHandler)delegate { int width = ((session.LastKnownW > 0) ? session.LastKnownW : w); int height = ((session.LastKnownH > 0) ? session.LastKnownH : h); ToggleSettingsPanel(root, session, width, height, canvasScale, currentPanelCurvature); }; val21.Style.MinWidth = 36f; val21.Style.PreferredWidth = 36f; val21.Style.MinHeight = 40f; val21.Style.PreferredHeight = 40f; val21.Style.FlexibleWidth = -1f; val21.Style.FlexibleHeight = -1f; val20 = LocaleString.op_Implicit("\ud83d\udc41"); Button previewBtn = val21.Button(ref val20); StyleButton(previewBtn); val21.Style.MinWidth = 1f; val21.Style.PreferredWidth = 1f; val21.Style.MinHeight = 32f; val21.Style.PreferredHeight = 32f; val21.Style.FlexibleWidth = -1f; val21.Style.FlexibleHeight = -1f; val3 = new colorX(0.42f, 0.44f, 0.48f, 0.48f, (ColorProfile)1); ((SyncRef>)(object)((ImageBase)val21.Image(ref val3, false)).Material).Target = (IAssetProvider)(object)barElementMat; val21.Style.MinWidth = 36f; val21.Style.PreferredWidth = 36f; val21.Style.MinHeight = 40f; val21.Style.PreferredHeight = 40f; val21.Style.FlexibleWidth = -1f; val21.Style.FlexibleHeight = -1f; val20 = LocaleString.op_Implicit("⌨\ufe0f"); Button kbBtn = val21.Button(ref val20); StyleButton(kbBtn); val20 = LocaleString.op_Implicit("⚓"); Button anchorBtn = val21.Button(ref val20); StyleButton(anchorBtn); val20 = LocaleString.op_Implicit("\ud83d\udd12"); Button privateBtn = val21.Button(ref val20); StyleButton(privateBtn); val21.Style.MinWidth = 1f; val21.Style.PreferredWidth = 1f; val21.Style.MinHeight = 32f; val21.Style.PreferredHeight = 32f; val3 = new colorX(0.42f, 0.44f, 0.48f, 0.48f, (ColorProfile)1); ((SyncRef>)(object)((ImageBase)val21.Image(ref val3, false)).Material).Target = (IAssetProvider)(object)barElementMat; val21.Style.MinWidth = 36f; val21.Style.PreferredWidth = 36f; val21.Style.MinHeight = 40f; val21.Style.PreferredHeight = 40f; val21.Style.FlexibleWidth = -1f; val21.Style.FlexibleHeight = -1f; val20 = LocaleString.op_Implicit("\ud83d\udd04"); Button resyncBtn = val21.Button(ref val20); StyleButton(resyncBtn); val21.Style.MinWidth = 1f; val21.Style.PreferredWidth = 1f; val21.Style.MinHeight = 32f; val21.Style.PreferredHeight = 32f; val3 = new colorX(0.42f, 0.44f, 0.48f, 0.48f, (ColorProfile)1); ((SyncRef>)(object)((ImageBase)val21.Image(ref val3, false)).Material).Target = (IAssetProvider)(object)barElementMat; val21.Style.MinWidth = 38f; val21.Style.PreferredWidth = 38f; val21.Style.MinHeight = 48f; val21.Style.PreferredHeight = 48f; val21.Style.FlexibleWidth = -1f; val20 = LocaleString.op_Implicit("Curve"); Text obj9 = val21.Text(ref val20, true, (Alignment?)(Alignment)4, true, (string)null); ((SyncField)(object)obj9.Size).Value = 14f; ((SyncField)(object)obj9.Color).Value = new colorX(0.6f, 0.6f, 0.6f, 1f, (ColorProfile)1); ((SyncRef>)(object)obj9.Material).Target = (IAssetProvider)(object)barTextMat; val21.Style.FlexibleWidth = -1f; val21.Style.MinWidth = 80f; val21.Style.PreferredWidth = 80f; val21.Style.MinHeight = 48f; val21.Style.PreferredHeight = 48f; Slot obj10 = val21.Empty("Curve"); UIBuilder val22 = new UIBuilder(obj10, (Slot)null); val22.Style.FlexibleWidth = 1f; val22.Style.FlexibleHeight = 1f; Image val23 = default(Image); Image val24 = default(Image); Image val25 = default(Image); Slider curveSlider = val22.Slider(20f, currentPanelCurvature, 0f, 1f, false, ref val23, ref val24, ref val25); ((SyncField)(object)val23.Tint).Value = SettingsPanelSoft; ((SyncField)(object)val24.Tint).Value = SettingsAccent; ((SyncField)(object)val25.Tint).Value = SettingsText; ((SyncRef>)(object)((ImageBase)val23).Material).Target = (IAssetProvider)(object)barElementMat; ((SyncRef>)(object)((ImageBase)val24).Material).Target = (IAssetProvider)(object)val12; ((SyncRef>)(object)((ImageBase)val25).Material).Target = (IAssetProvider)(object)val13; ApplyPurpleBlueGradient(val24, 10f, 0.98f, interactionTarget: false); GradientImage val26 = ApplyPurpleBlueGradient(val25, 18f, 0.98f, interactionTarget: false); if (val26 != null && ((SyncElementList)(object)((InteractionElement)curveSlider).ColorDrivers).Count > 0) { ((SyncRef>)(object)((SyncElementList)(object)((InteractionElement)curveSlider).ColorDrivers)[0].ColorDrive).Target = (IField)(object)val26.TintBottomRight; } ((SyncRef>)(object)((ImageBase)obj10.GetComponentInChildren((Predicate)((Image image) => ((Component)image).Slot.Name == "Background"), false, false)).Material).Target = (IAssetProvider)(object)barElementMat; obj10.ForeachComponentInChildren((Action)delegate(Text text) { ((SyncRef>)(object)text.Material).Target = (IAssetProvider)(object)barTextMat; }, false, false); float pendingPanelCurvature = currentPanelCurvature; ((SyncField)(object)curveSlider.Value).OnValueChange += delegate(SyncField field) { pendingPanelCurvature = MathX.Clamp(field.Value, 0f, 1f); SetPanelCurvePreference(panelCurvePreferenceKey, pendingPanelCurvature); }; ((SyncField)(object)((InteractionElement)curveSlider).IsPressed).OnValueChange += delegate(SyncField field) { if (!field.Value) { ApplyPanelCurvature(pendingPanelCurvature); UpdateDeviceIndicators(); } }; val21.Style.MinWidth = 24f; val21.Style.PreferredWidth = 24f; val21.Style.MinHeight = 48f; val21.Style.PreferredHeight = 48f; val21.Style.FlexibleWidth = -1f; val20 = LocaleString.op_Implicit("\ud83d\udd0a"); Text obj11 = val21.Text(ref val20, false, (Alignment?)(Alignment)4, true, (string)null); ((SyncField)(object)obj11.Size).Value = 16f; ((SyncField)(object)obj11.Color).Value = new colorX(0.6f, 0.6f, 0.6f, 1f, (ColorProfile)1); ((SyncRef>)(object)obj11.Material).Target = (IAssetProvider)(object)barTextMat; val21.Style.FlexibleWidth = -1f; val21.Style.MinWidth = 80f; val21.Style.PreferredWidth = 100f; val21.Style.MinHeight = 48f; val21.Style.PreferredHeight = 48f; Slot obj12 = val21.Empty("StreamVol"); UIBuilder val27 = new UIBuilder(obj12, (Slot)null); val27.Style.FlexibleWidth = 1f; val27.Style.FlexibleHeight = 1f; float streamOutputVolume = NormalizeStreamAudioOutputVolume(Config?.GetValue(StreamAudioOutputVolume) ?? 1f); Image val28 = default(Image); Image val29 = default(Image); Image val30 = default(Image); Slider volSlider = val27.Slider(20f, streamOutputVolume, 0f, 1f, false, ref val28, ref val29, ref val30); session.StreamVolumeSlider = volSlider; ValueUserOverride obj13 = ((ContainerWorker)(object)obj12).AttachComponent>(true, (Action>)null); ((SyncRef>)(object)obj13.Target).Target = (IField)(object)volSlider.Value; ((SyncField)(object)((ValueOverrideBase)(object)obj13).Default).Value = streamOutputVolume; ((SyncField)(object)((ValueOverrideBase)(object)obj13).CreateOverrideOnWrite).Value = true; ((SyncField)(object)((ValueOverrideBase)(object)obj13).PersistentOverrides).Value = false; ((SyncField)(object)((ValueOverrideBase)(object)obj13).ClearOnUserLeave).Value = true; ((SyncField)(object)val28.Tint).Value = SettingsPanelSoft; ((SyncField)(object)val29.Tint).Value = SettingsAccent; ((SyncField)(object)val30.Tint).Value = SettingsText; ((SyncRef>)(object)((ImageBase)val28).Material).Target = (IAssetProvider)(object)barElementMat; ((SyncRef>)(object)((ImageBase)val29).Material).Target = (IAssetProvider)(object)val12; ((SyncRef>)(object)((ImageBase)val30).Material).Target = (IAssetProvider)(object)val13; ApplyPurpleBlueGradient(val29, 10f, 0.98f, interactionTarget: false); GradientImage val31 = ApplyPurpleBlueGradient(val30, 18f, 0.98f, interactionTarget: false); if (val31 != null && ((SyncElementList)(object)((InteractionElement)volSlider).ColorDrivers).Count > 0) { ((SyncRef>)(object)((SyncElementList)(object)((InteractionElement)volSlider).ColorDrivers)[0].ColorDrive).Target = (IField)(object)val31.TintBottomRight; } ((SyncRef>)(object)((ImageBase)obj12.GetComponentInChildren((Predicate)((Image image) => ((Component)image).Slot.Name == "Background"), false, false)).Material).Target = (IAssetProvider)(object)barElementMat; obj12.ForeachComponentInChildren((Action)delegate(Text text) { ((SyncRef>)(object)text.Material).Target = (IAssetProvider)(object)barTextMat; }, false, false); ValueField widthField = ((ContainerWorker)(object)barSlot).AttachComponent>(true, (Action>)null); ((SyncField)(object)widthField.Value).Value = barCollapsedW; SmoothValue widthSmooth = ((ContainerWorker)(object)barSlot).AttachComponent>(true, (Action>)null); ((SyncField)(object)widthSmooth.Speed).Value = 10f; ((SyncField)(object)widthSmooth.TargetValue).Value = barCollapsedW; ((SyncRef>)(object)widthSmooth.Value).Target = (IField)(object)widthField.Value; ((SyncField)(object)widthSmooth.WriteBack).Value = false; BlurMaterial topBarBlur = null; StaticTexture2D topBarBlurMask = null; int topBarBlurMaskCanvasWidth = 0; int topBarBlurMaskCanvasHeight = 0; int topBarBlurMaskPillWidth = 0; int topBarBlurMaskPillHeight = 0; float barYPos = 0f - worldHalfH - barH / 2f * canvasScale - barMarginBottom; ((SyncField)(object)widthField.Value).Value = barCollapsedW; ((SyncField)(object)widthSmooth.TargetValue).Value = barCollapsedW; float currentBarWidth = barCollapsedW; bool barExpanded = false; Button barHoverButton = ((ContainerWorker)(object)((Component)barBg).Slot).AttachComponent