Skip to content

Commit

Permalink
Changed defender startup condition
Browse files Browse the repository at this point in the history
  • Loading branch information
Inestic committed Mar 16, 2022
1 parent 88fff94 commit 99f9901
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion SophiApp/SophiApp/Commons/Tags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace SophiApp.Commons
{
internal enum ConditionsTag
{
DefenderIsBroken,
DefenderWarning,
NewVersion,
OsBuildVersion,
OsVersion,
Expand Down
2 changes: 1 addition & 1 deletion SophiApp/SophiApp/Controls/TitleLeft.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
Margin="5, 0, 0, 0"
Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource TemplatedParent}}"
Style="{DynamicResource SmallText}"
Text="beta"
Text="RC1"
Visibility="Collapsed" />
</StackPanel>
</Grid>
Expand Down
2 changes: 1 addition & 1 deletion SophiApp/SophiApp/Customisations/CustomisationConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ internal static class CustomisationConstants
internal const string _339_AUTOPLAY_HANDLERS_PATH = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers";
internal const byte _339_DISABLED_VALUE = 1;
internal const byte _339_ENABLED_VALUE = 0;
internal const string _340_AUTOPLAY = "Autorun";
internal const string _340_AUTORUN = "Autorun";
internal const string _340_DISABLE_NET_BINDING_PS = "Disable-NetAdapterBinding –Name * –ComponentID ms_tcpip6";
internal const byte _340_DISABLED_VALUE = 0;
internal const string _340_ENABLE_NET_BINDING_PS = "Enable-NetAdapterBinding –Name * –ComponentID ms_tcpip6";
Expand Down
2 changes: 1 addition & 1 deletion SophiApp/SophiApp/Customisations/CustomisationOs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ public static void _339(bool IsChecked) => RegHelper.SetValue(RegistryHive.Curre

public static void _340(bool IsChecked) => RegHelper.SetValue(RegistryHive.LocalMachine,
_340_THUMBNAIL_CACHE_PATH,
_340_AUTOPLAY,
_340_AUTORUN,
IsChecked ? _340_ENABLED_VALUE
: _340_DISABLED_VALUE,
RegistryValueKind.DWord);
Expand Down
9 changes: 5 additions & 4 deletions SophiApp/SophiApp/Customisations/CustomisationStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ public static bool _338() => RegHelper.GetStringValue(RegistryHive.CurrentUser,
public static bool _339() => RegHelper.GetNullableIntValue(RegistryHive.CurrentUser, _339_AUTOPLAY_HANDLERS_PATH, _339_AUTOPLAY)
.HasNullOrValue(_339_ENABLED_VALUE);

public static bool _340() => RegHelper.GetNullableIntValue(RegistryHive.LocalMachine, _340_THUMBNAIL_CACHE_PATH, _340_AUTOPLAY)
public static bool _340() => RegHelper.GetNullableIntValue(RegistryHive.LocalMachine, _340_THUMBNAIL_CACHE_PATH, _340_AUTORUN)
.HasNullOrValue(_340_ENABLED_VALUE);

public static bool _341() => RegHelper.GetNullableIntValue(RegistryHive.CurrentUser, WINLOGON_PATH, _341_RESTART_APPS)
Expand Down Expand Up @@ -449,11 +449,12 @@ public static bool _502() => UwpHelper.PackageExist(_502_UWP_MICROSOFT_TEAMS)
? RegHelper.GetByteValue(RegistryHive.CurrentUser, _502_TEAMS_STARTUP_PATH, STATE) == _502_TEAMS_ENABLED_VALUE
: throw new UwpAppNotFoundException(_502_UWP_MICROSOFT_TEAMS);

public static bool _600() => RegHelper.GetNullableByteValue(RegistryHive.CurrentUser, _600_GAME_DVR_PATH, _600_APP_CAPTURE) == ENABLED_VALUE
&& RegHelper.GetNullableByteValue(RegistryHive.CurrentUser, _600_GAME_CONFIG_PATH, _600_GAME_DVR) == ENABLED_VALUE;
public static bool _600() => (RegHelper.GetNullableByteValue(RegistryHive.CurrentUser, _600_GAME_DVR_PATH, _600_APP_CAPTURE) == DISABLED_VALUE
& RegHelper.GetNullableByteValue(RegistryHive.CurrentUser, _600_GAME_CONFIG_PATH, _600_GAME_DVR) == DISABLED_VALUE).Invert();

public static bool _601() => UwpHelper.PackageExist(_601_UWP_XBOX_GAMING_OVERLAY) || UwpHelper.PackageExist(_601_UWP_GAMING_APP)
? RegHelper.GetNullableByteValue(RegistryHive.CurrentUser, _601_GAME_BAR_PATH, _601_SHOW_PANEL) == ENABLED_VALUE
? (RegHelper.GetNullableByteValue(RegistryHive.CurrentUser, _601_GAME_BAR_PATH, _601_SHOW_PANEL) == DISABLED_VALUE)
.Invert()
: throw new UwpAppNotFoundException($"{_601_UWP_XBOX_GAMING_OVERLAY} or {_601_UWP_GAMING_APP}");

public static bool _602()
Expand Down
4 changes: 2 additions & 2 deletions SophiApp/SophiApp/Helpers/DebugHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ internal static void HasUpdateRelease(ReleaseDto release) => WriteInfoLog(new Li

internal static void LinkClicked(string link) => WriteStatusLog($"Link clicked: \"{link}\"");

internal static void OsConditionHasProblem(IStartupCondition condition) => WriteStatusLog($"{condition.Tag} has a problem: {condition.HasProblem}");
internal static void OsConditionHasValue(IStartupCondition condition) => WriteStatusLog($"{condition.Tag} has value: {condition.HasProblem}");

internal static void RiskAgreed() => WriteStatusLog("USER AGREED TO ASSUME THE RISK AND LIABILITY FOR ANY POSSIBLE DAMAGE");

Expand Down Expand Up @@ -142,4 +142,4 @@ internal static void HasUpdateRelease(ReleaseDto release) => WriteInfoLog(new Li

internal static void VisibleViewChanged(string value) => WriteStatusLog($"Active view is: {value}");
}
}
}
2 changes: 1 addition & 1 deletion SophiApp/SophiApp/Helpers/StartupConditionsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public StartupConditionsHelper(EventHandler<Exception> errorHandler, EventHandle
{
new OsVersionCondition(), new OsBuildVersionCondition(), new RebootRequiredCondition(), new SingleInstanceCondition(),
new SingleAdminSessionCondition(), new Win10TweakerCondition(), new SycnexScriptCondition(),
new DefenderIsBrokenCondition(), new NewVersionCondition()
new DefenderWarningCondition(), new NewVersionCondition()
};

internal async Task CheckAsync()
Expand Down
5 changes: 2 additions & 3 deletions SophiApp/SophiApp/Helpers/WmiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ internal static bool AntiVirusProtectionDisabled()
{
var _3rdAntivirus = GetManagementObjectSearcher(scope, query).Get().Cast<ManagementBaseObject>()
.Where(avProduct => avProduct.GetPropertyValue(DEFENDER_INSTANCE_GUID) as string != DEFENDER_GUID)
.First();
.FirstOrDefault();

if (_3rdAntivirus.GetPropertyValue(PRODUCT_STATE) == null)
return true;
return _3rdAntivirus?.GetPropertyValue(PRODUCT_STATE) == null;
}

return false;
Expand Down
2 changes: 1 addition & 1 deletion SophiApp/SophiApp/Localizations/RU.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@
<system:String x:Key="Localization.ViewSearch.Running">Поиск...</system:String>
<system:String x:Key="Localization.ViewUwpApps.ForAllUsers">Для всех пользователей</system:String>
<system:String x:Key="Localization.ViewUwpApps.ForAllUsers.Description">При удалении UWP-приложений для всех пользователей новые учетные записи не будут включать удаленные UWP-приложения, и становится невозможно восстановить их обратно без использования установочных пакетов или скачивания из Microsoft Store. Но установка последних будет произведена лишь в текущий профиль</system:String>
</ResourceDictionary>
</ResourceDictionary>
2 changes: 1 addition & 1 deletion SophiApp/SophiApp/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@
</StackPanel>
</views:ViewConditionsTemplate.TextContent>
</views:ViewConditionsTemplate>
<views:ViewConditionsTemplate x:Name="ViewDefenderIsBrokenCondition" Grid.Column="1" Panel.ZIndex="20" Tag="DefenderIsBroken">
<views:ViewConditionsTemplate x:Name="ViewDefenderWarningCondition" Grid.Column="1" Panel.ZIndex="20" Tag="DefenderWarning">
<views:ViewConditionsTemplate.TextContent>
<StackPanel>
<TextBlock Text="{DynamicResource Conditions.DefenderIsBroken}" Style="{StaticResource BoldText}" Margin="{StaticResource MarginViewConditionsText}" HorizontalAlignment="Center" />
Expand Down
2 changes: 1 addition & 1 deletion SophiApp/SophiApp/SophiApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Helpers\HttpHelper.cs" />
<Compile Include="StartupConditions\DefenderIsBrokenCondition.cs" />
<Compile Include="StartupConditions\DefenderWarningCondition.cs" />
<Compile Include="StartupConditions\SingleAdminSessionCondition.cs" />
<Compile Include="StartupConditions\SingleInstanceCondition.cs" />
<Compile Include="StartupConditions\RebootRequiredCondition.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace SophiApp.StartupConditions
{
internal class DefenderIsBrokenCondition : IStartupCondition
internal class DefenderWarningCondition : IStartupCondition
{
public bool HasProblem { get; set; }
public ConditionsTag Tag { get; set; } = ConditionsTag.DefenderIsBroken;
public ConditionsTag Tag { get; set; } = ConditionsTag.DefenderWarning;

public bool Invoke() => HasProblem = WmiHelper.AntiVirusProtectionDisabled();
}
Expand Down
6 changes: 3 additions & 3 deletions SophiApp/SophiApp/ViewModels/Methods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ private void InitializeProperties()
}

private async Task InitializeTextedElements(string tag) => await Task.Run(() => TextedElements.Where(element => element.Tag == tag)
.ToList()
.ForEach(element => element.Initialize()));
.ToList()
.ForEach(element => element.Initialize()));

private async Task InitializeTextedElementsAsync()
{
Expand Down Expand Up @@ -295,7 +295,7 @@ private void OnConditionsHasError(object sender, Exception e)

private void OnConditionsHasProblem(object sender, IStartupCondition e)
{
DebugHelper.OsConditionHasProblem(e);
DebugHelper.OsConditionHasValue(e);
SetVisibleViewTag($"{e.Tag}");
}

Expand Down

0 comments on commit 99f9901

Please sign in to comment.