Skip to content

Commit

Permalink
Check UAC status
Browse files Browse the repository at this point in the history
not more debloat please
  • Loading branch information
shatyuka committed Jan 17, 2025
1 parent 83bac13 commit da68876
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
42 changes: 42 additions & 0 deletions CollapseLauncher/XAMLs/MainApp/Pages/HomePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,10 @@ await CurrentGameProperty.GameInstall.GetInstallationPath(true) == 0)
}

if (!(m_arguments.StartGame?.Play ?? false))
{
await CheckUserAccountControlStatus();
return;
}

m_arguments.StartGame.Play = false;

Expand Down Expand Up @@ -3285,5 +3288,44 @@ private bool ToggleRegionPlayingRpc
CurrentGameProperty.GameSettings.SaveSettings();
}
}

private async Task CheckUserAccountControlStatus()
{
try
{
var skipChecking = GetAppConfigValue("SkipCheckingUAC").ToBool();
if (skipChecking)
return;

var enabled =
(int)Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",
"EnableLUA", 1)!;
if (enabled != 1)
{
var result = await SpawnDialog(Lang._Dialogs.UACWarningTitle, Lang._Dialogs.UACWarningContent, this, Lang._Misc.Close,
Lang._Dialogs.UACWarningLearnMore, Lang._Dialogs.UACWarningDontShowAgain,
ContentDialogButton.Close, ContentDialogTheme.Warning);
if (result == ContentDialogResult.Primary)
{
new Process
{
StartInfo = new ProcessStartInfo
{
UseShellExecute = true,
FileName = "https://learn.microsoft.com/windows/security/application-security/application-control/user-account-control/settings-and-configuration?tabs=reg"
}
}.Start();
}
else if (result == ContentDialogResult.Secondary)
{
SetAndSaveConfigValue("SkipCheckingUAC", true);
}
}
}
catch (Exception)
{
// ignore
}
}
}
}
4 changes: 4 additions & 0 deletions Hi3Helper.Core/Lang/Locale/LangDialogs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ public sealed partial class LangDialogs
public string SophonIncrementUpdateUnavailSubtitle2 { get; set; } = LangFallback?._Dialogs.SophonIncrementUpdateUnavailSubtitle2;
public string SophonIncrementUpdateUnavailSubtitle3 { get; set; } = LangFallback?._Dialogs.SophonIncrementUpdateUnavailSubtitle3;
public string SophonIncrementUpdateUnavailSubtitle4 { get; set; } = LangFallback?._Dialogs.SophonIncrementUpdateUnavailSubtitle4;
public string UACWarningTitle { get; set; } = LangFallback?._Dialogs.UACWarningTitle;
public string UACWarningContent { get; set; } = LangFallback?._Dialogs.UACWarningContent;
public string UACWarningLearnMore { get; set; } = LangFallback?._Dialogs.UACWarningLearnMore;
public string UACWarningDontShowAgain { get; set; } = LangFallback?._Dialogs.UACWarningDontShowAgain;
}
}
#endregion
Expand Down
7 changes: 6 additions & 1 deletion Hi3Helper.Core/Lang/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,12 @@
"SophonIncrementUpdateUnavailSubtitle1": "Your game version: {0}",
"SophonIncrementUpdateUnavailSubtitle2": " is too obsolete",
"SophonIncrementUpdateUnavailSubtitle3": " and incremental update for your version is not available. However, you could still update your game by re-downloading the entire thing from scratch.",
"SophonIncrementUpdateUnavailSubtitle4": "Click \"{0}\" to continue updating the entire thing or click \"{1}\" to cancel the process"
"SophonIncrementUpdateUnavailSubtitle4": "Click \"{0}\" to continue updating the entire thing or click \"{1}\" to cancel the process",

"UACWarningTitle": "Warning: UAC Disabled Detected",
"UACWarningContent": "Disabling User Account Control (UAC) is never a good idea.\nThe security of the OS will be compromised and the game may not run properly.\n\nClick the \"Learn More\" button to see how to enable UAC.\nThe related entry is: Run all administrators in Admin Approval Mode.",
"UACWarningLearnMore": "Learn More",
"UACWarningDontShowAgain": "Don't Show Again"
},

"_FileMigrationProcess": {
Expand Down

0 comments on commit da68876

Please sign in to comment.