Skip to content

Portable Tool for an Ideal Windows Setup

-tweak windows defedner has been redesigned

Greedeks8bee5450ee0a
diff --git a/.Source/GTweak/GTweak.csproj b/.Source/GTweak/GTweak.csproj
index c6d588e6..a10c5187 100644
--- a/.Source/GTweak/GTweak.csproj
+++ b/.Source/GTweak/GTweak.csproj
@@ -247,6 +247,7 @@
<Compile Include="Utilities\DisablingWinKeys.cs" />
<Compile Include="Utilities\Helpers\RegistryHelp.cs" />
<Compile Include="Utilities\Settings.cs" />
+ <Compile Include="Utilities\TakingOwnership.cs" />
<Compile Include="Utilities\Tweaks\ClearingMemory.cs" />
<Compile Include="Utilities\СonfigSettings.cs" />
<Compile Include="Utilities\ViewNotification.cs" />
diff --git a/.Source/GTweak/Language/lang.xaml b/.Source/GTweak/Language/lang.xaml
index 0655edf3..319f662b 100644
--- a/.Source/GTweak/Language/lang.xaml
+++ b/.Source/GTweak/Language/lang.xaml
@@ -157,7 +157,7 @@
<v:String x:Key="tgl25_interface">Compression of wallpaper format .JPEG of the desktop</v:String>
<v:String x:Key="tgl26_interface">Tooltips for desktop elements</v:String>
<v:String x:Key="tgl27_interface">The search query with «Bing» integration in the Start menu</v:String>
- <v:String x:Key="tgl28_interface">Open «Quick Access» instead of «This computer»</v:String>
+ <v:String x:Key="tgl28_interface">Open «Quick Access» instead of «This PC»</v:String>
<v:String x:Key="textcolor_interface">This is an example of a new color.</v:String>
@@ -188,7 +188,7 @@
<v:String x:Key="TglButton25_description_interface">By default, when you set a jpeg image as your desktop wallpaper, Windows automatically reduces its quality to 85%. This tweak will set the jpeg wallpaper quality to 100%.</v:String>
<v:String x:Key="TglButton26_description_interface">Tweak will disable tooltips for desktop elements when hovering the mouse cursor.</v:String>
<v:String x:Key="TglButton27_description_interface">By default, Windows sends everything you search for in the «Start» menu to its servers to provide you with Bing search results. If you don't need Bing integration in the «Start» menu, you can apply a tweak to disable web search.</v:String>
- <v:String x:Key="TglButton28_description_interface">By default, when you open Explorer, the first tab will be «Quick Access». And to open any disk, you need to make unnecessary movements. This tweak will make «This computer» open when opened, rather than «Quick Access».</v:String>
+ <v:String x:Key="TglButton28_description_interface">By default, when you open Explorer, the first tab will be «Quick Access». And to open any disk, you need to make unnecessary movements. This tweak will make «This PC» open when opened, rather than «Quick Access».</v:String>
<!--#endregion-->
<!--#region Applications Page -->
diff --git a/.Source/GTweak/Utilities/TakingOwnership.cs b/.Source/GTweak/Utilities/TakingOwnership.cs
new file mode 100644
index 00000000..1a6e2594
--- /dev/null
+++ b/.Source/GTweak/Utilities/TakingOwnership.cs
@@ -0,0 +1,246 @@
+using System;
+using System.Runtime.InteropServices;
+
+namespace GTweak.Utilities
+{
+ internal class TakingOwnership
+ {
+ [StructLayoutAttribute(LayoutKind.Sequential)]
+ private struct SID_IDENTIFIER_AUTHORITY
+ {
+ [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 6, ArraySubType = UnmanagedType.I1)]
+ public byte[] Value;
+ }
+
+ [StructLayoutAttribute(LayoutKind.Sequential)]
+ private struct TRUSTEE
+ {
+ public System.IntPtr pMultipleTrustee;
+ public MULTIPLE_TRUSTEE_OPERATION MultipleTrusteeOperation;
+ public TRUSTEE_FORM TrusteeForm;
+ public TRUSTEE_TYPE TrusteeType;
+ public IntPtr ptstrName;
+ }
+
+ [StructLayoutAttribute(LayoutKind.Sequential)]
+ private struct EXPLICIT_ACCESS
+ {
+ public ACCESS_MASK grfAccessPermissions;
+ public ACCESS_MODE grfAccessMode;
+ public uint grfInheritance;
+ public TRUSTEE Trustee;
+ }
+
+ [StructLayoutAttribute(LayoutKind.Sequential)]
+ private struct TOKEN_PRIVILEGES
+ {
+ public uint PrivilegeCount;
+ [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 1, ArraySubType = UnmanagedType.Struct)]
+ public LUID_AND_ATTRIBUTES[] Privileges;
+ }
+
+ [StructLayoutAttribute(LayoutKind.Sequential)]
+ private struct LUID_AND_ATTRIBUTES
+ {
+ public LUID Luid;
+ public uint Attributes;
+ }
+
+ [StructLayoutAttribute(LayoutKind.Sequential)]
+ private struct LUID
+ {
+ public uint LowPart;
+ public int HighPart;
+ }
+
+ private enum TRUSTEE_TYPE
+ {
+ TRUSTEE_IS_GROUP,
+ }
+
+ private enum TRUSTEE_FORM
+ {
+ TRUSTEE_IS_SID,
+ }
+
+ private enum MULTIPLE_TRUSTEE_OPERATION { }
+
+ public enum SE_OBJECT_TYPE
+ {
+ SE_UNKNOWN_OBJECT_TYPE = 0,
+ SE_FILE_OBJECT,
+ SE_SERVICE,
+ SE_PRINTER,
+ SE_REGISTRY_KEY,
+ SE_LMSHARE,
+ SE_KERNEL_OBJECT,
+ SE_WINDOW_OBJECT,
+ SE_DS_OBJECT,
+ SE_DS_OBJECT_ALL,
+ SE_PROVIDER_DEFINED_OBJECT,
+ SE_WMIGUID_OBJECT,
+ SE_REGISTRY_WOW64_32KEY
+ }
+
+ [Flags]
+ private enum ACCESS_MASK : uint
+ {
+ GENERIC_ALL = 0x10000000,
+ }
+
+ [Flags]
+ private enum SECURITY_INFORMATION : uint
+ {
+ OWNER_SECURITY_INFORMATION = 0x00000001,
+ DACL_SECURITY_INFORMATION = 0x00000004,
+ }
+
+ private enum ACCESS_MODE
+ {
+ SET_ACCESS
+ }
+
+ private const string SE_TAKE_OWNERSHIP_NAME = "SeTakeOwnershipPrivilege";
+ private static SID_IDENTIFIER_AUTHORITY SECURITY_NT_AUTHORITY =
+ new SID_IDENTIFIER_AUTHORITY() { Value = new byte[] { 0, 0, 0, 0, 0, 5 } };
+
+ private const UInt32 TOKEN_ADJUST_PRIVILEGES = 0x0020;
+ private const int NO_INHERITANCE = 0x0;
+ private const int SECURITY_BUILTIN_DOMAIN_RID = 0x00000020;
+ private const int DOMAIN_ALIAS_RID_ADMINS = 0x00000220;
+ private const int TOKEN_QUERY = 8;
+ private const int SE_PRIVILEGE_ENABLED = 2;
+
+ [DllImportAttribute("advapi32.dll", EntryPoint = "OpenProcessToken")]
+ [return: MarshalAsAttribute(UnmanagedType.Bool)]
+ private static extern bool OpenProcessToken([InAttribute] IntPtr ProcessHandle, uint DesiredAccess, out IntPtr TokenHandle);
+
+ [DllImportAttribute("advapi32.dll", EntryPoint = "AllocateAndInitializeSid")]
+ [return: MarshalAsAttribute(UnmanagedType.Bool)]
+ private static extern bool AllocateAndInitializeSid(
+ [InAttribute] ref SID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
+ byte nSubAuthorityCount,
+ uint nSubAuthority0,
+ uint nSubAuthority1,
+ uint nSubAuthority2,
+ uint nSubAuthority3,
+ uint nSubAuthority4,
+ uint nSubAuthority5,
+ uint nSubAuthority6,
+ uint nSubAuthority7,
+ ref IntPtr pSid);
+
+ [DllImportAttribute("kernel32.dll", EntryPoint = "CloseHandle")]
+ [return: MarshalAsAttribute(UnmanagedType.Bool)]
+ private static extern bool CloseHandle([InAttribute] IntPtr hObject);
+
+ [DllImportAttribute("kernel32.dll", EntryPoint = "GetCurrentProcess")]
+ private static extern IntPtr GetCurrentProcess();
+
+ [DllImportAttribute("advapi32.dll", EntryPoint = "FreeSid")]
+ private static extern IntPtr FreeSid([InAttribute] IntPtr pSid);
+
+ [DllImportAttribute("kernel32.dll", EntryPoint = "LocalFree")]
+ private static extern IntPtr LocalFree(IntPtr hMem);
+
+ [DllImportAttribute("advapi32.dll", EntryPoint = "LookupPrivilegeValueA")]
+ [return: MarshalAsAttribute(UnmanagedType.Bool)]
+ private static extern bool LookupPrivilegeValueA([InAttribute] [MarshalAsAttribute(UnmanagedType.LPStr)] string lpSystemName, [InAttribute] [MarshalAsAttribute(UnmanagedType.LPStr)] string lpName, [OutAttribute] out LUID lpLuid);
+
+ [DllImportAttribute("advapi32.dll", EntryPoint = "AdjustTokenPrivileges")]
+ [return: MarshalAsAttribute(UnmanagedType.Bool)]
+ private static extern bool AdjustTokenPrivileges([InAttribute()] IntPtr TokenHandle, [MarshalAsAttribute(UnmanagedType.Bool)] bool DisableAllPrivileges,
+ [InAttribute()]
+ ref TOKEN_PRIVILEGES NewState,
+ uint BufferLength,
+ IntPtr PreviousState,
+ IntPtr ReturnLength);
+
+ [DllImport("advapi32.dll", CharSet = CharSet.Auto)]
+ private static extern int SetNamedSecurityInfo(
+ string pObjectName,
+ SE_OBJECT_TYPE ObjectType,
+ SECURITY_INFORMATION SecurityInfo,
+ IntPtr psidOwner,
+ IntPtr psidGroup,
+ IntPtr pDacl,
+ IntPtr pSacl);
+
+ [DllImport("Advapi32.dll", EntryPoint = "SetEntriesInAclA",
+ CallingConvention = CallingConvention.Winapi,
+ SetLastError = true, CharSet = CharSet.Ansi)]
+ private static extern int SetEntriesInAcl(
+ int CountofExplicitEntries,
+ ref EXPLICIT_ACCESS ea,
+ IntPtr OldAcl,
+ ref IntPtr NewAcl);
+
+ internal static void GrantAdministratorsAccess(string name, SE_OBJECT_TYPE type)
+ {
+ SID_IDENTIFIER_AUTHORITY sidNTAuthority = SECURITY_NT_AUTHORITY;
+
+ IntPtr sidAdmin = IntPtr.Zero;
+ AllocateAndInitializeSid(ref sidNTAuthority, 2,
+ SECURITY_BUILTIN_DOMAIN_RID,
+ DOMAIN_ALIAS_RID_ADMINS,
+ 0, 0, 0, 0, 0, 0,
+ ref sidAdmin);
+
+ EXPLICIT_ACCESS[] explicitAccesss = new EXPLICIT_ACCESS[1];
+ explicitAccesss[0].grfAccessPermissions = ACCESS_MASK.GENERIC_ALL;
+ explicitAccesss[0].grfAccessMode = ACCESS_MODE.SET_ACCESS;
+ explicitAccesss[0].grfInheritance = NO_INHERITANCE;
+ explicitAccesss[0].Trustee.TrusteeForm = TRUSTEE_FORM.TRUSTEE_IS_SID;
+ explicitAccesss[0].Trustee.TrusteeType = TRUSTEE_TYPE.TRUSTEE_IS_GROUP;
+ explicitAccesss[0].Trustee.ptstrName = sidAdmin;
+
+ IntPtr acl = IntPtr.Zero;
+ SetEntriesInAcl(1, ref explicitAccesss[0], (IntPtr)0, ref acl);
+
+ static void setPrivilege(string privilege, bool allow)
+ {
+ TOKEN_PRIVILEGES tokenPrivileges = new TOKEN_PRIVILEGES();
+ OpenProcessToken(GetCurrentProcess(),
+ TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, out IntPtr token);
+
+ if (allow)
+ {
+ LookupPrivilegeValueA(null, privilege, out LUID luid);
+ tokenPrivileges.PrivilegeCount = 1;
+ tokenPrivileges.Privileges = new LUID_AND_ATTRIBUTES[1];
+ tokenPrivileges.Privileges[0].Luid = luid;
+ tokenPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+ }
+
+ AdjustTokenPrivileges(token, false, ref tokenPrivileges, 0,
+ IntPtr.Zero, IntPtr.Zero);
+ CloseHandle(token);
+ }
+
+ setPrivilege(SE_TAKE_OWNERSHIP_NAME, true);
+
+ SetNamedSecurityInfo(
+ name,
+ type,
+ SECURITY_INFORMATION.OWNER_SECURITY_INFORMATION,
+ sidAdmin,
+ IntPtr.Zero,
+ IntPtr.Zero,
+ IntPtr.Zero);
+
+ setPrivilege(SE_TAKE_OWNERSHIP_NAME, false);
+
+ SetNamedSecurityInfo(
+ name,
+ type,
+ SECURITY_INFORMATION.DACL_SECURITY_INFORMATION,
+ IntPtr.Zero, IntPtr.Zero,
+ acl,
+ IntPtr.Zero);
+
+ FreeSid(sidAdmin);
+ LocalFree(acl);
+ }
+ }
+}
+
diff --git a/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs b/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs
index 5a293d6a..0431fc74 100644
--- a/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs
+++ b/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs
@@ -738,47 +738,60 @@ namespace GTweak.Utilities.Tweaks
case "TglButton25":
if (isChoose)
{
- TrustedInstaller.CreateProcessAsTrustedInstaller(Settings.PID, "cmd.exe /c reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\WarpJITSvc /t REG_DWORD /v Start /d 4 /f & " +
- "reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\wscsvc /t REG_DWORD /v Start /d 4 /f & " +
- "reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\wscsvc /t REG_DWORD /v DelayedAutoStart /d 1 /f");
+ TakingOwnership.GrantAdministratorsAccess(@"MACHINE\SYSTEM\CurrentControlSet\Services\wscsvc", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
+ RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\wscsvc", "Start", 4, RegistryValueKind.DWord);
+ RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\wscsvc", "DelayedAutoStart", 1, RegistryValueKind.DWord);
}
else
{
- TrustedInstaller.CreateProcessAsTrustedInstaller(Settings.PID, "cmd.exe /c reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\WarpJITSvc /t REG_DWORD /v Start /d 3 /f & " +
- "reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\wscsvc /t REG_DWORD /v Start /d 2 /f & " +
- "reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\wscsvc /t REG_DWORD /v DelayedAutoStart /d 0 /f");
+ TakingOwnership.GrantAdministratorsAccess(@"MACHINE\SYSTEM\CurrentControlSet\Services\wscsvc", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
+ RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\wscsvc", "Start", 2, RegistryValueKind.DWord);
+ RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\wscsvc", "DelayedAutoStart", 0, RegistryValueKind.DWord);
+
}
break;
case "TglButton26":
if (isChoose)
{
- TrustedInstaller.CreateProcessAsTrustedInstaller(Settings.PID, "cmd.exe /c reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\WdiSystemHost /t REG_DWORD /v Start /d 4 /f & " +
- "reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\WdiServiceHost /t REG_DWORD /v Start /d 4 /f & " +
- "reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\TroubleshootingSvc /t REG_DWORD /v Start /d 4 /f & " +
- "reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\DPS /t REG_DWORD /v Start /d 4 /f");
+ TakingOwnership.GrantAdministratorsAccess(@"MACHINE\SYSTEM\CurrentControlSet\Services\WdiServiceHost", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
+ TakingOwnership.GrantAdministratorsAccess(@"MACHINE\SYSTEM\CurrentControlSet\Services\TroubleshootingSvc", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
+ TakingOwnership.GrantAdministratorsAccess(@"MACHINE\SYSTEM\CurrentControlSet\Services\DPS", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
+ RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\WdiServiceHost", "Start", 4, RegistryValueKind.DWord);
+ RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\TroubleshootingSvc", "Start", 4, RegistryValueKind.DWord);
+ RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\DPS", "Start", 4, RegistryValueKind.DWord);
}
else
{
- TrustedInstaller.CreateProcessAsTrustedInstaller(Settings.PID, "cmd.exe /c reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\WdiSystemHost /t REG_DWORD /v Start /d 3 /f & " +
- "reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\WdiServiceHost /t REG_DWORD /v Start /d 3 /f & " +
- "reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\TroubleshootingSvc /t REG_DWORD /v Start /d 3 /f & " +
- "reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\DPS /t REG_DWORD /v Start /d 2 /f");
+ TakingOwnership.GrantAdministratorsAccess(@"MACHINE\SYSTEM\CurrentControlSet\Services\WdiServiceHost", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
+ TakingOwnership.GrantAdministratorsAccess(@"MACHINE\SYSTEM\CurrentControlSet\Services\TroubleshootingSvc", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
+ TakingOwnership.GrantAdministratorsAccess(@"MACHINE\SYSTEM\CurrentControlSet\Services\DPS", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
+ RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\WdiServiceHost", "Start", 3, RegistryValueKind.DWord);
+ RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\TroubleshootingSvc", "Start", 3, RegistryValueKind.DWord);
+ RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\DPS", "Start", 2, RegistryValueKind.DWord);
}
break;
case "TglButton27":
if (isChoose)
{
- TrustedInstaller.CreateProcessAsTrustedInstaller(Settings.PID, "cmd.exe /c reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\workfolderssvc /t REG_DWORD /v Start /d 4 /f & " +
- "reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\dot3svc /t REG_DWORD /v Start /d 4 /f & " +
- "reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\DevQueryBroker /t REG_DWORD /v Start /d 4 /f & " +
- "reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\AppMgmt /t REG_DWORD /v Start /d 4 /f");
+ TakingOwnership.GrantAdministratorsAccess(@"MACHINE\SYSTEM\CurrentControlSet\Services\workfolderssvc", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
+ TakingOwnership.GrantAdministratorsAccess(@"MACHINE\SYSTEM\CurrentControlSet\Services\dot3svc", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
+ TakingOwnership.GrantAdministratorsAccess(@"MACHINE\SYSTEM\CurrentControlSet\Services\DevQueryBroker", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
+ TakingOwnership.GrantAdministratorsAccess(@"MACHINE\SYSTEM\CurrentControlSet\Services\AppMgmt", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
+ RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\workfolderssvc", "Start", 4, RegistryValueKind.DWord);
+ RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\dot3svc", "Start", 4, RegistryValueKind.DWord);
+ RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\DevQueryBroker", "Start", 4, RegistryValueKind.DWord);
+ RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\AppMgmt", "Start", 4, RegistryValueKind.DWord);
}
else
{
- TrustedInstaller.CreateProcessAsTrustedInstaller(Settings.PID, "cmd.exe /c reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\workfolderssvc /t REG_DWORD /v Start /d 3 /f & " +
- "reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\dot3svc /t REG_DWORD /v Start /d 3 /f & " +
- "reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\DevQueryBroker /t REG_DWORD /v Start /d 3 /f & " +
- "reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\AppMgmt /t REG_DWORD /v Start /d 3 /f");
+ TakingOwnership.GrantAdministratorsAccess(@"MACHINE\SYSTEM\CurrentControlSet\Services\workfolderssvc", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
+ TakingOwnership.GrantAdministratorsAccess(@"MACHINE\SYSTEM\CurrentControlSet\Services\dot3svc", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
+ TakingOwnership.GrantAdministratorsAccess(@"MACHINE\SYSTEM\CurrentControlSet\Services\DevQueryBroker", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
+ TakingOwnership.GrantAdministratorsAccess(@"MACHINE\SYSTEM\CurrentControlSet\Services\AppMgmt", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
+ RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\workfolderssvc", "Start", 3, RegistryValueKind.DWord);
+ RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\dot3svc", "Start", 3, RegistryValueKind.DWord);
+ RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\DevQueryBroker", "Start", 3, RegistryValueKind.DWord);
+ RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\AppMgmt", "Start", 3, RegistryValueKind.DWord);
}
break;
case "TglButton28":
diff --git a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs
index 664917d9..40ea0260 100644
--- a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs
+++ b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs
@@ -12,6 +12,7 @@ using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
+using System.Windows;
namespace GTweak.Utilities.Tweaks
{
@@ -128,40 +129,20 @@ namespace GTweak.Utilities.Tweaks
catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }
- if (Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\MicrosoftEdge\PhishingFilter", "EnabledV9", null) == null ||
- Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\MicrosoftEdge\PhishingFilter", "EnabledV9", string.Empty).ToString() != "0" ||
- Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\System", "EnableSmartScreen", null) == null ||
- Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\System", "EnableSmartScreen", string.Empty).ToString() != "0" ||
- Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender", "DisableAntiSpyware", null) == null ||
- Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender", "DisableAntiSpyware", string.Empty).ToString() != "1" ||
- Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender", "DisableAntiVirus", null) == null ||
- Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender", "DisableAntiVirus", string.Empty).ToString() != "1" ||
- Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\SmartScreen", "ConfigureAppInstallControl", null) == null ||
- Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\SmartScreen", "ConfigureAppInstallControl", string.Empty).ToString() != "Anywhere" ||
- Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\SmartScreen", "ConfigureAppInstallControlEnabled", null) == null ||
- Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\SmartScreen", "ConfigureAppInstallControlEnabled", string.Empty).ToString() != "0" ||
+ systemV.TglButton8.StateNA = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SecurityHealthService", "Start", null) == null ||
+ Registry.GetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SecurityHealthService", "Start", string.Empty).ToString() != "4" ||
+ Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Defender\Features", "TamperProtection", null) == null ||
+ Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Defender\Features", "TamperProtection", string.Empty).ToString() != "0" ||
+ Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender Security Center\App and Browser protection", "DisallowExploitProtectionOverride", null) == null ||
+ Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender Security Center\App and Browser protection", "DisallowExploitProtectionOverride", string.Empty).ToString() != "0" ||
+ Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender Security Center\App and Browser protection", "UILockdown", null) == null ||
+ Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender Security Center\App and Browser protection", "UILockdown", string.Empty).ToString() != "1" ||
Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Defender\Real-Time Protection", "DisableBehaviorMonitoring", null) == null ||
Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Defender\Real-Time Protection", "DisableBehaviorMonitoring", string.Empty).ToString() != "1" ||
- Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Defender\Real-Time Protection", "DisableIOAVProtection", null) == null ||
- Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Defender\Real-Time Protection", "DisableIOAVProtection", string.Empty).ToString() != "1" ||
- Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Defender\Real-Time Protection", "DisableOnAccessProtection", null) == null ||
- Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Defender\Real-Time Protection", "DisableOnAccessProtection", string.Empty).ToString() != "1" ||
Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Defender\Real-Time Protection", "DisableRealtimeMonitoring", null) == null ||
- Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Defender\Real-Time Protection", "DisableRealtimeMonitoring", string.Empty).ToString() != "1" ||
- Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Defender\Real-Time Protection", "DisableScanOnRealtimeEnable", null) == null ||
- Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Defender\Real-Time Protection", "DisableScanOnRealtimeEnable", string.Empty).ToString() != "1" ||
- Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet", "SpyNetReporting", null) == null ||
- Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet", "SpyNetReporting", string.Empty).ToString() != "0" ||
- Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet", "SubmitSamplesConsent", null) == null ||
- Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet", "SubmitSamplesConsent", string.Empty).ToString() != "2" ||
- Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\AppHost", "EnableWebContentEvaluation", null) == null ||
- Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\AppHost", "EnableWebContentEvaluation", string.Empty).ToString() != "0" ||
- Registry.GetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SecurityHealthService", "Start", null) == null ||
- Registry.GetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SecurityHealthService", "Start", string.Empty).ToString() != "4")
- systemV.TglButton8.StateNA = true;
- else
- systemV.TglButton8.StateNA = false;
-
+ Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Defender\Real-Time Protection", "DisableRealtimeMonitoring", string.Empty).ToString() != "1"; ;
+
+
if (Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", "PromptOnSecureDesktop", null) == null ||
Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", "PromptOnSecureDesktop", string.Empty).ToString() != "0" ||
@@ -462,7 +443,7 @@ namespace GTweak.Utilities.Tweaks
backgroundWorker.DoWork += (s, e) =>
{
if (isChoose)
- new WindowsDefender().Disable();
+ new WindowsDefender().Disable();
else
new WindowsDefender().Enable();
};
diff --git a/.Source/GTweak/Utilities/Tweaks/WindowsDefender.cs b/.Source/GTweak/Utilities/Tweaks/WindowsDefender.cs
index 25c8c1c5..b425c347 100644
--- a/.Source/GTweak/Utilities/Tweaks/WindowsDefender.cs
+++ b/.Source/GTweak/Utilities/Tweaks/WindowsDefender.cs
@@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
+using System.Threading.Tasks;
namespace GTweak.Utilities.Tweaks
{
@@ -12,6 +13,13 @@ namespace GTweak.Utilities.Tweaks
{
internal void Enable()
{
+ TakingOwnership.GrantAdministratorsAccess(@"MACHINE\Software\Policies\Microsoft\Windows Defender\Real-Time Protection", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
+ TakingOwnership.GrantAdministratorsAccess(@"MACHINE\Software\Policies\Microsoft\Windows Defender\SpyNet", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
+ TakingOwnership.GrantAdministratorsAccess(@"MACHINE\SYSTEM\CurrentControlSet\Services\WinDefend", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
+ TakingOwnership.GrantAdministratorsAccess(@"MACHINE\SYSTEM\CurrentControlSet\Services\SecurityHealthService", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
+ TakingOwnership.GrantAdministratorsAccess(@"MACHINE\SOFTWARE\Microsoft\Windows Defender\Features", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
+ TakingOwnership.GrantAdministratorsAccess(@"MACHINE\SYSTEM\CurrentControlSet\Services\WdNisSvc", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
+
TrustedInstaller.CreateProcessAsTrustedInstaller(Settings.PID, "cmd.exe /c reg delete HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\AppHost /v EnableWebContentEvaluation /f & " +
"reg delete HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer /v SmartScreenEnabled /f & " +
"reg delete HKLM\\SOFTWARE\\Policies\\Microsoft\\MicrosoftEdge\\PhishingFilter /v EnabledV9 /f & " +
@@ -31,7 +39,9 @@ namespace GTweak.Utilities.Tweaks
"reg add \"HKLM\\SOFTWARE\\Policies\\Microsoft\\Windows Defender\\Spynet\" /t REG_DWORD /v SubmitSamplesConsent /d 0 /f & " +
"reg add \"HKLM\\SOFTWARE\\Microsoft\\Windows Defender\\Features\" /t REG_DWORD /v TamperProtection /d 1 /f & " +
"reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\SecurityHealthService /t REG_DWORD /v Start /d 2 /f &" +
- "reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\WinDefend /t REG_DWORD /v Start /d 2 /f");
+ "reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\WinDefend /t REG_DWORD /v Start /d 2 /f & " +
+ "reg delete HKLM\\SYSTEM\\CurrentControlSet\\Services\\WinDefend /t REG_DWORD /v AutorunsDisabled /f & " +
+ "reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\WdNisSvc /t REG_DWORD /v Start /d 3 /f");
EnableServices();
@@ -103,7 +113,7 @@ namespace GTweak.Utilities.Tweaks
RegistryHelp.DeleteValue(Registry.LocalMachine, @"Software\Microsoft\Windows\CurrentVersion\AppHost", "PreventOverride");
RegistryHelp.CreateFolder(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
- RegistryHelp.Write(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "SecurityHealth", @"%windir%\system32\SecurityHealthSystray.exe", RegistryValueKind.String);
+ RegistryHelp.Write(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "SecurityHealth", @"%windir%\system32\SecurityHealthSystray.exe", RegistryValueKind.ExpandString);
RunPowerShellCommand(@"Set-ExecutionPolicy UnRestricted; Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\WinDefend -Name Start -Value 0x00000002");
RunPowerShellCommand(@"Set-ExecutionPolicy UnRestricted; Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows Defender\Real-Time Protection' -Name DisableBehaviorMonitoring -Value 0x00000000");
@@ -114,14 +124,21 @@ namespace GTweak.Utilities.Tweaks
RunPowerShellCommand(@"Set-ExecutionPolicy UnRestricted; Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows Defender\Real-Time Protection' -Name DisableScriptScanning -Value 0x00000000");
RunPowerShellCommand(@"Set-ExecutionPolicy UnRestricted; Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows Defender\Real-Time Protection' -Name DisableScriptScanning -Value 0x00000000");
- Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run", "SecurityHealth", new byte[] { 0002, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 }, RegistryValueKind.Binary);
-
+ RegistryHelp.Write(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run", "SecurityHealth", new byte[] { 0002, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 }, RegistryValueKind.Binary);
+ RegistryHelp.Write(Registry.CurrentUser, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Windows Defender", "\"%ProgramFiles%\\Windows Defender\\MSASCui.exe\"-runkey", RegistryValueKind.String);
RunProcess(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + @"\Windows Defender\MpCmdRun.exe", "-SignatureUpdate");
+ RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\WinDefend", "Start", "2", RegistryValueKind.DWord);
+ RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\SecurityHealthService", "Start", "2", RegistryValueKind.DWord);
+ RegistryHelp.Write(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows Defender\Features", "TamperProtection", "1", RegistryValueKind.DWord);
+ RegistryHelp.DeleteValue(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\WinDefend", "AutorunsDisabled");
+
CloseDefenderSettings();
+
+ RunPowerShellCommand(@"Get-AppXpackage Microsoft.WindowsDefender | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register ""$($_.InstallLocation)\AppXManifest.xml""}");
}
- internal void Disable()
+ internal async void Disable()
{
KillProcess("smartscreen");
@@ -190,6 +207,8 @@ namespace GTweak.Utilities.Tweaks
RegistryHelp.Write(Registry.LocalMachine, @"Software\Policies\Microsoft\Windows Defender\MpEngine", "DisableGradualRelease", 1, RegistryValueKind.DWord);
RegistryHelp.CreateFolder(Registry.LocalMachine, @"Software\Policies\Microsoft\Windows Defender\Real-Time Protection");
+ TakingOwnership.GrantAdministratorsAccess(@"MACHINE\Software\Policies\Microsoft\Windows Defender\Real-Time Protection", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
+
RegistryHelp.Write(Registry.LocalMachine, @"Software\Policies\Microsoft\Windows Defender\Real-Time Protection", "DisableBehaviorMonitoring", 1, RegistryValueKind.DWord);
RegistryHelp.Write(Registry.LocalMachine, @"Software\Policies\Microsoft\Windows Defender\Real-Time Protection", "DisableIOAVProtection", 1, RegistryValueKind.DWord);
RegistryHelp.Write(Registry.LocalMachine, @"Software\Policies\Microsoft\Windows Defender\Real-Time Protection", "DisableOnAccessProtection", 1, RegistryValueKind.DWord);
@@ -218,6 +237,7 @@ namespace GTweak.Utilities.Tweaks
RunPowerShellCommand(@"Set-ExecutionPolicy UnRestricted; Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows Defender\Features -Name TamperProtection -Value 0x00000000");
RegistryHelp.CreateFolder(Registry.LocalMachine, @"Software\Policies\Microsoft\Windows Defender\SpyNet");
+ TakingOwnership.GrantAdministratorsAccess(@"MACHINE\Software\Policies\Microsoft\Windows Defender\SpyNet", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
RegistryHelp.Write(Registry.LocalMachine, @"Software\Policies\Microsoft\Windows Defender\SpyNet", "DisableBlockAtFirstSeen", 1, RegistryValueKind.DWord);
RegistryHelp.Write(Registry.LocalMachine, @"Software\Policies\Microsoft\Windows Defender\SpyNet", "SpynetReporting", 0, RegistryValueKind.DWord);
RegistryHelp.Write(Registry.LocalMachine, @"Software\Policies\Microsoft\Windows Defender\SpyNet", "SubmitSamplesConsent", 2, RegistryValueKind.DWord);
@@ -259,7 +279,9 @@ namespace GTweak.Utilities.Tweaks
RunPowerShellCommand(@"Set-ExecutionPolicy UnRestricted; Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows Defender\Real-Time Protection' -Name DisableScriptScanning -Value 0x00000001");
- Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run", "SecurityHealth", new byte[] { 0099, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99 }, RegistryValueKind.Binary);
+ RegistryHelp.Write(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run", "SecurityHealth", new byte[] { 0099, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99 }, RegistryValueKind.Binary);
+ RegistryHelp.DeleteValue(Registry.CurrentUser, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Windows Defender");
+ RegistryHelp.DeleteValue(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "SecurityHealth");
CloseDefenderSettings();
@@ -278,25 +300,40 @@ namespace GTweak.Utilities.Tweaks
RunPowerShellCommand("Stop-Service -Name WinDefend; Set-Service -Name WinDefend -StartupType Disabled");
TrustedInstaller.CreateProcessAsTrustedInstaller(Settings.PID, "cmd.exe /c taskkill /f /im MsMpEng.exe & reg add HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\AppHost /t REG_DWORD /v EnableWebContentEvaluation /d 0 /f & " +
- "reg add HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer /t REG_SZ /v SmartScreenEnabled /d \"off\" /f & " +
- "reg add HKLM\\SOFTWARE\\Policies\\Microsoft\\MicrosoftEdge\\PhishingFilter /t REG_DWORD /v EnabledV9 /d 0 /f & " +
- "reg add HKLM\\SOFTWARE\\Policies\\Microsoft\\Windows\\System /t REG_DWORD /v EnableSmartScreen /d 0 /f & " +
- "reg add \"HKLM\\SOFTWARE\\Policies\\Microsoft\\Windows Defender\" /t REG_DWORD /v DisableAntiSpyware /d 1 /f & " +
- "reg add \"HKLM\\SOFTWARE\\Policies\\Microsoft\\Windows Defender\" /t REG_DWORD /v DisableAntiVirus /d 1 /f & " +
- "reg add \"HKLM\\SOFTWARE\\Microsoft\\Windows Defender\\Real-Time Protection\" /t REG_DWORD /v DisableBehaviorMonitoring /d 1 /f & " +
- "reg add \"HKLM\\SOFTWARE\\Microsoft\\Windows Defender\\Real-Time Protection\" /t REG_DWORD /v DisableOnAccessProtection /d 1 /f & " +
- "reg add \"HKLM\\SOFTWARE\\Microsoft\\Windows Defender\\Real-Time Protection\" /t REG_DWORD /v DisableScanOnRealtimeEnable /d 1 /f & " +
- "reg add \"HKLM\\SOFTWARE\\Microsoft\\Windows Defender\\Real-Time Protection\" /t REG_DWORD /v DisableIOAVProtection /d 1 /f & " +
- "reg add \"HKLM\\SOFTWARE\\Microsoft\\Windows Defender\\Real-Time Protection\" /t REG_DWORD /v DisableRealtimeMonitoring /d 1 /f & " +
- "reg add \"HKLM\\SOFTWARE\\Policies\\Microsoft\\Windows Defender\\Spynet\" /t REG_DWORD /v SpyNetReporting /d 0 /f & " +
- "reg add \"HKLM\\SOFTWARE\\Policies\\Microsoft\\Windows Defender\\Spynet\" /t REG_DWORD /v SubmitSamplesConsent /d 2 /f & " +
- "reg add \"HKLM\\SOFTWARE\\Microsoft\\Windows Defender\\Features\" /t REG_DWORD /v TamperProtection /d 0 /f & " +
- "reg add HKLM\\SOFTWARE\\Policies\\Microsoft\\MRT /t REG_DWORD /v DontOfferThroughWUA /d 1 /f & " +
- "reg add HKLM\\SOFTWARE\\Policies\\Microsoft\\MRT /t REG_DWORD /v DontReportInfectionInformation /d 1 /f & " +
- "reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\SecurityHealthService /t REG_DWORD /v Start /d 4 /f &" +
- "reg add \"HKLM\\SOFTWARE\\Policies\\Microsoft\\Windows Defender\\SmartScreen\" /t REG_SZ /v ConfigureAppInstallControl /d \"Anywhere\" /f & " +
- "reg add \"HKLM\\SOFTWARE\\Policies\\Microsoft\\Windows Defender\\SmartScreen\" /t REG_DWORD /v ConfigureAppInstallControlEnabled /d 0 /f & " +
- "reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\WinDefend /t REG_DWORD /v Start /d 4 /f");
+ "reg add HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer /t REG_SZ /v SmartScreenEnabled /d \"off\" /f & " +
+ "reg add HKLM\\SOFTWARE\\Policies\\Microsoft\\MicrosoftEdge\\PhishingFilter /t REG_DWORD /v EnabledV9 /d 0 /f & " +
+ "reg add HKLM\\SOFTWARE\\Policies\\Microsoft\\Windows\\System /t REG_DWORD /v EnableSmartScreen /d 0 /f & " +
+ "reg add \"HKLM\\SOFTWARE\\Policies\\Microsoft\\Windows Defender\" /t REG_DWORD /v DisableAntiSpyware /d 1 /f & " +
+ "reg add \"HKLM\\SOFTWARE\\Policies\\Microsoft\\Windows Defender\" /t REG_DWORD /v DisableAntiVirus /d 1 /f & " +
+ "reg add \"HKLM\\SOFTWARE\\Microsoft\\Windows Defender\\Real-Time Protection\" /t REG_DWORD /v DisableBehaviorMonitoring /d 1 /f & " +
+ "reg add \"HKLM\\SOFTWARE\\Microsoft\\Windows Defender\\Real-Time Protection\" /t REG_DWORD /v DisableOnAccessProtection /d 1 /f & " +
+ "reg add \"HKLM\\SOFTWARE\\Microsoft\\Windows Defender\\Real-Time Protection\" /t REG_DWORD /v DisableScanOnRealtimeEnable /d 1 /f & " +
+ "reg add \"HKLM\\SOFTWARE\\Microsoft\\Windows Defender\\Real-Time Protection\" /t REG_DWORD /v DisableIOAVProtection /d 1 /f & " +
+ "reg add \"HKLM\\SOFTWARE\\Microsoft\\Windows Defender\\Real-Time Protection\" /t REG_DWORD /v DisableRealtimeMonitoring /d 1 /f & " +
+ "reg add \"HKLM\\SOFTWARE\\Policies\\Microsoft\\Windows Defender\\Spynet\" /t REG_DWORD /v SpyNetReporting /d 0 /f & " +
+ "reg add \"HKLM\\SOFTWARE\\Policies\\Microsoft\\Windows Defender\\Spynet\" /t REG_DWORD /v SubmitSamplesConsent /d 2 /f & " +
+ "reg add \"HKLM\\SOFTWARE\\Microsoft\\Windows Defender\\Features\" /t REG_DWORD /v TamperProtection /d 0 /f & " +
+ "reg add HKLM\\SOFTWARE\\Policies\\Microsoft\\MRT /t REG_DWORD /v DontOfferThroughWUA /d 1 /f & " +
+ "reg add HKLM\\SOFTWARE\\Policies\\Microsoft\\MRT /t REG_DWORD /v DontReportInfectionInformation /d 1 /f & " +
+ "reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\SecurityHealthService /t REG_DWORD /v Start /d 4 /f &" +
+ "reg add \"HKLM\\SOFTWARE\\Policies\\Microsoft\\Windows Defender\\SmartScreen\" /t REG_SZ /v ConfigureAppInstallControl /d \"Anywhere\" /f & " +
+ "reg add \"HKLM\\SOFTWARE\\Policies\\Microsoft\\Windows Defender\\SmartScreen\" /t REG_DWORD /v ConfigureAppInstallControlEnabled /d 0 /f & " +
+ "reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\WinDefend /t REG_DWORD /v Start /d 4 /f & " +
+ "reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\WinDefend /t REG_DWORD /v AutorunsDisabled / d 3 /f & " +
+ "reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\WdNisSvc /t REG_DWORD /v Start /d 4 /f");
+
+ TakingOwnership.GrantAdministratorsAccess(@"MACHINE\SYSTEM\CurrentControlSet\Services\WinDefend", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
+ TakingOwnership.GrantAdministratorsAccess(@"MACHINE\SYSTEM\CurrentControlSet\Services\SecurityHealthService", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
+ TakingOwnership.GrantAdministratorsAccess(@"MACHINE\SOFTWARE\Microsoft\Windows Defender\Features", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
+ TakingOwnership.GrantAdministratorsAccess(@"MACHINE\SYSTEM\CurrentControlSet\Services\WdNisSvc", TakingOwnership.SE_OBJECT_TYPE.SE_REGISTRY_KEY);
+
+ await Task.Delay(1000);
+
+ RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\WinDefend", "Start", "4", RegistryValueKind.DWord);
+ RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\WinDefend", "AutorunsDisabled", "3", RegistryValueKind.DWord);
+ RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\SecurityHealthService", "Start", "4", RegistryValueKind.DWord);
+ RegistryHelp.Write(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows Defender\Features", "TamperProtection", "0", RegistryValueKind.DWord);
+ RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\WdNisSvc", "Start", "4", RegistryValueKind.DWord);
}
private void KillProcess(string getName)