From 7b3eaa5a0162e2e37cf92f87863423943bd922ee Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Mon, 24 Jul 2023 14:22:56 +0100 Subject: [PATCH] Auto delete RUNASADMIN flag on launch yeah idk how this happens --- Bloxstrap/Bootstrapper.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index dcfe241..e4ff652 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -927,7 +927,7 @@ namespace Bloxstrap App.Logger.WriteLine("[Bootstrapper::ApplyModifications] Checking executable flags..."); using (RegistryKey appFlagsKey = Registry.CurrentUser.CreateSubKey($"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers")) { - const string flag = " DISABLEDXMAXIMIZEDWINDOWEDMODE"; + string flag = " DISABLEDXMAXIMIZEDWINDOWEDMODE"; string? appFlags = (string?)appFlagsKey.GetValue(_playerLocation); if (App.Settings.Prop.DisableFullscreenOptimizations) @@ -939,6 +939,24 @@ namespace Bloxstrap } else if (appFlags is not null && appFlags.Contains(flag)) { + App.Logger.WriteLine($"[Bootstrapper::ApplyModifications] Deleting flag '{flag.Trim()}'"); + + // if there's more than one space, there's more flags set we need to preserve + if (appFlags.Split(' ').Length > 2) + appFlagsKey.SetValue(_playerLocation, appFlags.Remove(appFlags.IndexOf(flag), flag.Length)); + else + appFlagsKey.DeleteValue(_playerLocation); + } + + // hmm, maybe make a unified handler for this? this is just lazily copy pasted from above + + flag = " RUNASADMIN"; + appFlags = (string?)appFlagsKey.GetValue(_playerLocation); + + if (appFlags is not null && appFlags.Contains(flag)) + { + App.Logger.WriteLine($"[Bootstrapper::ApplyModifications] Deleting flag '{flag.Trim()}'"); + // if there's more than one space, there's more flags set we need to preserve if (appFlags.Split(' ').Length > 2) appFlagsKey.SetValue(_playerLocation, appFlags.Remove(appFlags.IndexOf(flag), flag.Length));