diff --git a/Bloxstrap/App.xaml.cs b/Bloxstrap/App.xaml.cs index f6e7072..4118020 100644 --- a/Bloxstrap/App.xaml.cs +++ b/Bloxstrap/App.xaml.cs @@ -138,6 +138,21 @@ namespace Bloxstrap Paths.Initialize(BaseDirectory); + // disallow running as administrator except for uninstallation + if (Utilities.IsAdministrator && !LaunchSettings.IsUninstall) + { + Frontend.ShowMessageBox(Bloxstrap.Resources.Strings.Bootstrapper_RanInAdminMode, MessageBoxImage.Error); + Terminate(ErrorCode.ERROR_INVALID_FUNCTION); + return; + } + + if (LaunchSettings.IsUninstall && IsFirstRun) + { + Frontend.ShowMessageBox(Bloxstrap.Resources.Strings.Bootstrapper_FirstRunUninstall, MessageBoxImage.Error); + Terminate(ErrorCode.ERROR_INVALID_FUNCTION); + return; + } + // we shouldn't save settings on the first run until the first installation is finished, // just in case the user decides to cancel the install if (!IsFirstRun) @@ -175,13 +190,8 @@ namespace Bloxstrap } else { - if (Process.GetProcessesByName(ProjectName).Length > 1 && !LaunchSettings.IsQuiet) - Frontend.ShowMessageBox( - Bloxstrap.Resources.Strings.Menu_AlreadyRunning, - MessageBoxImage.Information - ); - - Frontend.ShowMenu(); + bool showAlreadyRunningWarning = Process.GetProcessesByName(ProjectName).Length > 1 && !LaunchSettings.IsQuiet; + Frontend.ShowMenu(showAlreadyRunningWarning); } StartupFinished(); diff --git a/Bloxstrap/Bloxstrap.csproj b/Bloxstrap/Bloxstrap.csproj index aa1b921..4056f8a 100644 --- a/Bloxstrap/Bloxstrap.csproj +++ b/Bloxstrap/Bloxstrap.csproj @@ -40,7 +40,7 @@ - + all diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index a0befdf..b63b34f 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -1202,7 +1202,7 @@ namespace Bloxstrap if (App.IsFirstRun && App.CustomFontLocation is not null) { Directory.CreateDirectory(Path.GetDirectoryName(Paths.CustomFont)!); - File.Copy(App.CustomFontLocation, Paths.CustomFont); + File.Copy(App.CustomFontLocation, Paths.CustomFont, true); } if (File.Exists(Paths.CustomFont)) diff --git a/Bloxstrap/Enums/ErrorCode.cs b/Bloxstrap/Enums/ErrorCode.cs index ba6b65e..f6b6609 100644 --- a/Bloxstrap/Enums/ErrorCode.cs +++ b/Bloxstrap/Enums/ErrorCode.cs @@ -8,6 +8,7 @@ public enum ErrorCode { ERROR_SUCCESS = 0, + ERROR_INVALID_FUNCTION = 1, ERROR_INSTALL_USEREXIT = 1602, ERROR_INSTALL_FAILURE = 1603, ERROR_CANCELLED = 1223, diff --git a/Bloxstrap/Resources/Strings.Designer.cs b/Bloxstrap/Resources/Strings.Designer.cs index 4f01855..2a7a0da 100644 --- a/Bloxstrap/Resources/Strings.Designer.cs +++ b/Bloxstrap/Resources/Strings.Designer.cs @@ -133,6 +133,15 @@ namespace Bloxstrap.Resources { } } + /// + /// Looks up a localized string similar to You must first install Bloxstrap before uninstalling.. + /// + public static string Bootstrapper_FirstRunUninstall { + get { + return ResourceManager.GetString("Bootstrapper.FirstRunUninstall", resourceCulture); + } + } + /// /// Looks up a localized string similar to Roblox has now finished rolling out the new game client update, featuring 64-bit support and the Hyperion anticheat. ReShade does not work with this update, and so it has now been disabled and removed from Bloxstrap. /// @@ -153,6 +162,15 @@ namespace Bloxstrap.Resources { } } + /// + /// Looks up a localized string similar to Bloxstrap does not support running in administrator mode. Relaunch or reinstall Bloxstrap with lower privileges.. + /// + public static string Bootstrapper_RanInAdminMode { + get { + return ResourceManager.GetString("Bootstrapper.RanInAdminMode", resourceCulture); + } + } + /// /// Looks up a localized string similar to Applying Roblox modifications.... /// @@ -1462,11 +1480,20 @@ namespace Bloxstrap.Resources { } /// - /// Looks up a localized string similar to Bloxstrap is currently running, likely as a background Roblox process. Please note that not all your changes will immediately apply until you close all currently open Roblox instances.. + /// Looks up a localized string similar to Please note that not all your changes will immediately apply until you close all currently open Roblox instances.. /// - public static string Menu_AlreadyRunning { + public static string Menu_AlreadyRunning_Caption { get { - return ResourceManager.GetString("Menu.AlreadyRunning", resourceCulture); + return ResourceManager.GetString("Menu.AlreadyRunning.Caption", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Bloxstrap is already running. + /// + public static string Menu_AlreadyRunning_Title { + get { + return ResourceManager.GetString("Menu.AlreadyRunning.Title", resourceCulture); } } diff --git a/Bloxstrap/Resources/Strings.resx b/Bloxstrap/Resources/Strings.resx index afaea78..d24de5b 100644 --- a/Bloxstrap/Resources/Strings.resx +++ b/Bloxstrap/Resources/Strings.resx @@ -142,6 +142,9 @@ Would you like to switch to the default channel ({1})? Roblox was launched via a deeplink, however the desktop app is required for deeplink launching to work. Because you've opted to disable the desktop app, it will temporarily be re-enabled for this launch only. + + You must first install Bloxstrap before uninstalling. + Roblox has now finished rolling out the new game client update, featuring 64-bit support and the Hyperion anticheat. ReShade does not work with this update, and so it has now been disabled and removed from Bloxstrap. @@ -150,6 +153,9 @@ Your ReShade configuration files will still be saved, and you can locate them by Bloxstrap does not have enough disk space to download and install Roblox. Please free up some disk space and try again. + + Bloxstrap does not support running in administrator mode. Relaunch or reinstall Bloxstrap with lower privileges. + Applying Roblox modifications... @@ -590,8 +596,11 @@ Would you like to upgrade your currently installed version? All files - - Bloxstrap is currently running, likely as a background Roblox process. Please note that not all your changes will immediately apply until you close all currently open Roblox instances. + + Please note that not all your changes will immediately apply until you close all currently open Roblox instances. + + + Bloxstrap is already running You can make it look different, retro, or even just like Roblox. diff --git a/Bloxstrap/UI/Elements/Menu/MainWindow.xaml b/Bloxstrap/UI/Elements/Menu/MainWindow.xaml index ad73178..86a1ce1 100644 --- a/Bloxstrap/UI/Elements/Menu/MainWindow.xaml +++ b/Bloxstrap/UI/Elements/Menu/MainWindow.xaml @@ -1,4 +1,4 @@ - + + diff --git a/Bloxstrap/UI/Elements/Menu/MainWindow.xaml.cs b/Bloxstrap/UI/Elements/Menu/MainWindow.xaml.cs index dfa4e1f..4f317fc 100644 --- a/Bloxstrap/UI/Elements/Menu/MainWindow.xaml.cs +++ b/Bloxstrap/UI/Elements/Menu/MainWindow.xaml.cs @@ -10,7 +10,7 @@ namespace Bloxstrap.UI.Elements.Menu /// public partial class MainWindow : INavigationWindow { - public MainWindow() + public MainWindow(bool showAlreadyRunningWarning) { InitializeComponent(); ApplyTheme(); @@ -22,6 +22,15 @@ namespace Bloxstrap.UI.Elements.Menu #if DEBUG // easier access PreInstallNavItem.Visibility = System.Windows.Visibility.Visible; #endif + + if (showAlreadyRunningWarning) + _ = ShowAlreadyRunningSnackbar(); + } + + private async Task ShowAlreadyRunningSnackbar() + { + await Task.Delay(500); // wait for everything to finish loading + AlreadyRunningSnackbar.Show(); } public void OpenWiki(object? sender, EventArgs e) => Utilities.ShellExecute($"https://github.com/{App.ProjectRepository}/wiki"); diff --git a/Bloxstrap/UI/Frontend.cs b/Bloxstrap/UI/Frontend.cs index 1561f7f..c4ddeef 100644 --- a/Bloxstrap/UI/Frontend.cs +++ b/Bloxstrap/UI/Frontend.cs @@ -8,7 +8,7 @@ namespace Bloxstrap.UI { static class Frontend { - public static void ShowMenu() => new MainWindow().ShowDialog(); + public static void ShowMenu(bool showAlreadyRunningWarning = false) => new MainWindow(showAlreadyRunningWarning).ShowDialog(); public static MessageBoxResult ShowMessageBox(string message, MessageBoxImage icon = MessageBoxImage.None, MessageBoxButton buttons = MessageBoxButton.OK, MessageBoxResult defaultResult = MessageBoxResult.None) { diff --git a/Bloxstrap/Utilities.cs b/Bloxstrap/Utilities.cs index 7f33a19..eaf3816 100644 --- a/Bloxstrap/Utilities.cs +++ b/Bloxstrap/Utilities.cs @@ -1,9 +1,18 @@ using System.ComponentModel; +using System.Security.Principal; namespace Bloxstrap { static class Utilities { + /// + /// Is process running as administrator + /// https://stackoverflow.com/a/11660205 + /// + public static bool IsAdministrator => + new WindowsPrincipal(WindowsIdentity.GetCurrent()) + .IsInRole(WindowsBuiltInRole.Administrator); + public static void ShellExecute(string website) { try