-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dfa1183
commit 9655402
Showing
10 changed files
with
327 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
using Microsoft.Win32; | ||
|
||
namespace Guard.Core | ||
{ | ||
public class RegistrySettings | ||
{ | ||
private static T? GetValue<T>(string keyPath, string value, T? defaultValue) | ||
{ | ||
try | ||
{ | ||
return (T?)Registry.GetValue(keyPath, value, defaultValue); | ||
} | ||
catch | ||
{ | ||
return defaultValue; | ||
} | ||
} | ||
|
||
private static bool GetValue(string keyPath, string value, bool defaultValue) | ||
{ | ||
try | ||
{ | ||
int? val = (int?)Registry.GetValue(keyPath, value, defaultValue ? 1 : 0); | ||
if (val == null) | ||
{ | ||
return defaultValue; | ||
} | ||
return val != 0; | ||
} | ||
catch | ||
{ | ||
return defaultValue; | ||
} | ||
} | ||
|
||
public static string? GetAppDataPath() | ||
{ | ||
string? path = GetValue<string>( | ||
@"HKEY_CURRENT_USER\Software\Policies\2FAGuard", | ||
"AppDataPath", | ||
null | ||
); | ||
if (path != null) | ||
{ | ||
path = Environment.ExpandEnvironmentVariables(path); | ||
} | ||
return path; | ||
} | ||
|
||
public static (bool hideSkip, bool hideWinHello, bool hidePassword) GetSetupHideOptions() | ||
{ | ||
bool hideSkip = GetValue( | ||
@"HKEY_CURRENT_USER\Software\Policies\2FAGuard\Setup", | ||
"HideSkip", | ||
false | ||
); | ||
bool hideWinHello = GetValue( | ||
@"HKEY_CURRENT_USER\Software\Policies\2FAGuard\Setup", | ||
"HideWinHello", | ||
false | ||
); | ||
bool hidePassword = GetValue( | ||
@"HKEY_CURRENT_USER\Software\Policies\2FAGuard\Setup", | ||
"HidePassword", | ||
false | ||
); | ||
|
||
// If all options are hidden, show them all | ||
if (hideSkip && hideWinHello && hidePassword) | ||
{ | ||
return (false, false, false); | ||
} | ||
|
||
return (hideSkip, hideWinHello, hidePassword); | ||
} | ||
|
||
public static ( | ||
bool hideWinHello, | ||
bool hidePreventScreenRecording, | ||
bool hideSecurityKey | ||
) GetSettingsPageOptions() | ||
{ | ||
bool hideWinHello = GetValue( | ||
@"HKEY_CURRENT_USER\Software\Policies\2FAGuard\Settings", | ||
"HideWinHello", | ||
false | ||
); | ||
bool hidePreventRecording = GetValue( | ||
@"HKEY_CURRENT_USER\Software\Policies\2FAGuard\Settings", | ||
"HidePreventRecording", | ||
false | ||
); | ||
bool hideSecurityKey = GetValue( | ||
@"HKEY_CURRENT_USER\Software\Policies\2FAGuard\Settings", | ||
"HideSecurityKey", | ||
false | ||
); | ||
|
||
return (hideWinHello, hidePreventRecording, hideSecurityKey); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.