Skip to content

Commit

Permalink
Auto delete RUNASADMIN flag on launch
Browse files Browse the repository at this point in the history
yeah idk how this happens
  • Loading branch information
pizzaboxer committed Jul 24, 2023
1 parent c2a96f8 commit 7b3eaa5
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion Bloxstrap/Bootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ private async Task ApplyModifications()
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)
Expand All @@ -939,6 +939,24 @@ private async Task ApplyModifications()
}
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));
Expand Down

0 comments on commit 7b3eaa5

Please sign in to comment.