Portable Tool for an Ideal Windows Setup
C# activatorbloatware-removalcsharpdebloatdebloaterdisable-servicesmonitoring-systemportableprivacy-toolsregistry-tweakssystem-tuningsystem-utilitytelemetrytweakerwindows-10windows-11windows-debloatwindows-defenderwindows-optimizationwindows-tweaks
-re objects
Greedeksf9de15d53fc2
diff --git a/.Source/GTweak/Core/RelayCommand.cs b/.Source/GTweak/Core/RelayCommand.csindex def73440..35fd2ad6 100644--- a/.Source/GTweak/Core/RelayCommand.cs+++ b/.Source/GTweak/Core/RelayCommand.cs@@ -18,7 +18,7 @@ namespace GTweak.Coreexecute = _execute;canExecute = _canExecute;}- public bool CanExecute(object _parameter) => canExecute == null || canExecute(_parameter);- public void Execute(object _parameter) => execute(_parameter);+ public bool CanExecute(object parameter) => canExecute == null || canExecute(parameter);+ public void Execute(object parameter) => execute(parameter);}}diff --git a/.Source/GTweak/Core/ViewModelBase.cs b/.Source/GTweak/Core/ViewModelBase.csindex 4904fe3f..2ee99b85 100644--- a/.Source/GTweak/Core/ViewModelBase.cs+++ b/.Source/GTweak/Core/ViewModelBase.cs@@ -7,9 +7,9 @@ namespace GTweak.Coreinternal class ViewModelBase : MainModel, INotifyPropertyChanged{public event PropertyChangedEventHandler PropertyChanged;- public void OnPropertyChanged([CallerMemberName] string _propName = null)+ public void OnPropertyChanged([CallerMemberName] string propName = null){- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(_propName));+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propName));}}}diff --git a/.Source/GTweak/Utilities/BlockRunTweaker.cs b/.Source/GTweak/Utilities/BlockRunTweaker.csindex 916d424e..ace3e555 100644--- a/.Source/GTweak/Utilities/BlockRunTweaker.cs+++ b/.Source/GTweak/Utilities/BlockRunTweaker.cs@@ -51,8 +51,7 @@ namespace GTweak.Utilities});if (SystemData.СomputerСonfiguration.clientWinVersion.Contains("11") || SystemData.СomputerСonfiguration.clientWinVersion.Contains("10")) return;- MessageWindow messageWindow = new MessageWindow(true);- messageWindow.ShowDialog();+ new MessageWindow(true).ShowDialog();}}}diff --git a/.Source/GTweak/Utilities/DisablingWinKeys.cs b/.Source/GTweak/Utilities/DisablingWinKeys.csindex 1b29b488..78526481 100644--- a/.Source/GTweak/Utilities/DisablingWinKeys.cs+++ b/.Source/GTweak/Utilities/DisablingWinKeys.cs@@ -10,11 +10,11 @@ namespace GTweak.Utilities[StructLayout(LayoutKind.Sequential)]private struct KBDLLHOOKSTRUCT{- public Keys key;- public int scanCode;- public int flags;- public int time;- public IntPtr extra;+ internal Keys key;+ internal int scanCode;+ internal int flags;+ internal int time;+ internal IntPtr extra;}internal delegate IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam);[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]diff --git a/.Source/GTweak/Utilities/Helpers/BackgroundQueue.cs b/.Source/GTweak/Utilities/Helpers/BackgroundQueue.csindex cc50902b..68990c27 100644--- a/.Source/GTweak/Utilities/Helpers/BackgroundQueue.cs+++ b/.Source/GTweak/Utilities/Helpers/BackgroundQueue.cs@@ -20,11 +20,11 @@ namespace GTweak.Utilities.Helpers}}- internal Task<T> QueueTask<T>(Func<T> work)+ internal Task<T> QueueTask<T>(Func<T> func){lock (key){- var task = previousTask.ContinueWith(t => work()+ var task = previousTask.ContinueWith(t => func(), CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.Default);diff --git a/.Source/GTweak/Utilities/Helpers/TrustedInstaller.cs b/.Source/GTweak/Utilities/Helpers/TrustedInstaller.csindex 735114a0..543a2589 100644--- a/.Source/GTweak/Utilities/Helpers/TrustedInstaller.cs+++ b/.Source/GTweak/Utilities/Helpers/TrustedInstaller.cs@@ -2,7 +2,6 @@using System.ComponentModel;using System.Diagnostics;using System.Runtime.InteropServices;-using System.Security.Principal;using System.ServiceProcess;namespace GTweak.Utilities.Helpers@@ -10,38 +9,38 @@ namespace GTweak.Utilities.Helpersinternal sealed class TrustedInstaller{[DllImport("kernel32.dll", SetLastError = true)]- static extern bool CloseHandle(IntPtr hObject);+ private static extern bool CloseHandle(IntPtr hObject);[DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]- internal static extern bool AdjustTokenPrivileges(IntPtr htok, bool disall, ref TokPrivLuid newst, int len, IntPtr prev, IntPtr relen);+ private static extern bool AdjustTokenPrivileges(IntPtr htok, bool disall, ref TokPrivLuid newst, int len, IntPtr prev, IntPtr relen);[DllImport("advapi32.dll", SetLastError = true)]- static extern bool OpenProcessToken(IntPtr ProcessHandle, uint DesiredAccess, out IntPtr TokenHandle);+ private static extern bool OpenProcessToken(IntPtr ProcessHandle, uint DesiredAccess, out IntPtr TokenHandle);[DllImport("advapi32.dll", SetLastError = true)]- static extern bool ImpersonateLoggedOnUser(IntPtr hToken);+ private static extern bool ImpersonateLoggedOnUser(IntPtr hToken);[DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]- static extern IntPtr OpenSCManager(string lpMachineName, string lpDatabaseName, uint dwDesiredAccess);+ private static extern IntPtr OpenSCManager(string lpMachineName, string lpDatabaseName, uint dwDesiredAccess);[DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]- static extern IntPtr OpenService(IntPtr hSCManager, string lpServiceName, uint dwDesiredAccess);+ private static extern IntPtr OpenService(IntPtr hSCManager, string lpServiceName, uint dwDesiredAccess);[DllImport("advapi32.dll", SetLastError = true)]- static extern bool QueryServiceStatusEx(IntPtr hService, int InfoLevel, ref SERVICE_STATUS_PROCESS lpBuffer, uint cbBufSize, out uint pcbBytesNeeded);+ private static extern bool QueryServiceStatusEx(IntPtr hService, int InfoLevel, ref SERVICE_STATUS_PROCESS lpBuffer, uint cbBufSize, out uint pcbBytesNeeded);[DllImport("advapi32.dll", SetLastError = true)]- static extern bool StartService(IntPtr hService, uint dwNumServiceArgs, IntPtr lpServiceArgVectors);+ private static extern bool StartService(IntPtr hService, uint dwNumServiceArgs, IntPtr lpServiceArgVectors);[DllImport("advapi32.dll", SetLastError = true)]- static extern bool CloseServiceHandle(IntPtr hSCObject);+ private static extern bool CloseServiceHandle(IntPtr hSCObject);[DllImport("kernel32.dll")][return: MarshalAs(UnmanagedType.Bool)]- static extern bool CreateProcess(string lpApplicationName, string lpCommandLine, ref SECURITY_ATTRIBUTES lpProcessAttributes, ref SECURITY_ATTRIBUTES lpThreadAttributes, bool bInheritHandles, uint dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, [In] ref STARTUPINFOEX lpStartupInfo, out PROCESS_INFORMATION lpProcessInformation);+ private static extern bool CreateProcess(string lpApplicationName, string lpCommandLine, ref SECURITY_ATTRIBUTES lpProcessAttributes, ref SECURITY_ATTRIBUTES lpThreadAttributes, bool bInheritHandles, uint dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, [In] ref STARTUPINFOEX lpStartupInfo, out PROCESS_INFORMATION lpProcessInformation);[DllImport("kernel32.dll", SetLastError = true)]- public static extern IntPtr OpenProcess(ProcessAccessFlags processAccess, bool bInheritHandle, int processId);+ private static extern IntPtr OpenProcess(ProcessAccessFlags processAccess, bool bInheritHandle, int processId);[DllImport("kernel32.dll", SetLastError = true)][return: MarshalAs(UnmanagedType.Bool)]@@ -66,76 +65,76 @@ namespace GTweak.Utilities.Helpersconst uint CREATE_NO_WINDOW = 0x08000000;[StructLayout(LayoutKind.Sequential)]- struct SECURITY_ATTRIBUTES+ private struct SECURITY_ATTRIBUTES{- public int nLength;- public IntPtr lpSecurityDescriptor;- public bool bInheritHandle;+ internal int nLength;+ internal IntPtr lpSecurityDescriptor;+ internal bool bInheritHandle;}[StructLayout(LayoutKind.Sequential)]- struct SERVICE_STATUS_PROCESS+ private struct SERVICE_STATUS_PROCESS{- public uint dwServiceType;- public uint dwCurrentState;- public uint dwControlsAccepted;- public uint dwWin32ExitCode;- public uint dwServiceSpecificExitCode;- public uint dwCheckPoint;- public uint dwWaitHint;- public uint dwProcessId;- public uint dwServiceFlags;+ internal uint dwServiceType;+ internal uint dwCurrentState;+ internal uint dwControlsAccepted;+ internal uint dwWin32ExitCode;+ internal uint dwServiceSpecificExitCode;+ internal uint dwCheckPoint;+ internal uint dwWaitHint;+ internal uint dwProcessId;+ internal uint dwServiceFlags;}[StructLayout(LayoutKind.Sequential)]- public struct STARTUPINFO+ private struct STARTUPINFO{- public int cb;- public string lpReserved;- public string lpDesktop;- public string lpTitle;- public uint dwX;- public uint dwY;- public uint dwXSize;- public uint dwYSize;- public uint dwXCountChars;- public uint dwYCountChars;- public uint dwFillAttribute;- public uint dwFlags;- public short wShowWindow;- public short cbReserved2;- public IntPtr lpReserved2;- public IntPtr hStdInput;- public IntPtr hStdOutput;- public IntPtr hStdError;+ internal int cb;+ internal string lpReserved;+ internal string lpDesktop;+ internal string lpTitle;+ internal uint dwX;+ internal uint dwY;+ internal uint dwXSize;+ internal uint dwYSize;+ internal uint dwXCountChars;+ internal uint dwYCountChars;+ internal uint dwFillAttribute;+ internal uint dwFlags;+ internal short wShowWindow;+ internal short cbReserved2;+ internal IntPtr lpReserved2;+ internal IntPtr hStdInput;+ internal IntPtr hStdOutput;+ internal IntPtr hStdError;}[StructLayout(LayoutKind.Sequential)]- public struct PROCESS_INFORMATION+ private struct PROCESS_INFORMATION{- public IntPtr hProcess;- public IntPtr hThread;- public uint dwProcessId;- public uint dwThreadId;+ internal IntPtr hProcess;+ internal IntPtr hThread;+ internal uint dwProcessId;+ internal uint dwThreadId;}[StructLayout(LayoutKind.Sequential)]- public struct TokPrivLuid+ private struct TokPrivLuid{- public int Count;- public long Luid;- public int Attr;+ internal int Count;+ internal long Luid;+ internal int Attr;}[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]- struct STARTUPINFOEX+ private struct STARTUPINFOEX{- public STARTUPINFO StartupInfo;- public IntPtr lpAttributeList;+ internal STARTUPINFO StartupInfo;+ internal IntPtr lpAttributeList;}[Flags]- public enum ProcessAccessFlags : uint+ private enum ProcessAccessFlags : uint{All = 0x001F0FFF,Terminate = 0x00000001,@@ -152,13 +151,7 @@ namespace GTweak.Utilities.HelpersSynchronize = 0x00100000}- public static bool CheckIfAdmin()- {- WindowsIdentity currentIdentity = WindowsIdentity.GetCurrent();- WindowsPrincipal currentPrincipal = new WindowsPrincipal(currentIdentity);- return currentPrincipal.IsInRole(WindowsBuiltInRole.Administrator);- }- public static bool ImpersonateSystem()+ private static bool ImpersonateSystem(){Process[] processlist = Process.GetProcesses();IntPtr tokenHandle = IntPtr.Zero;@@ -184,7 +177,7 @@ namespace GTweak.Utilities.HelpersCloseHandle(tokenHandle);return false;}- public static int StartTrustedInstallerService()+ internal static int StartTrustedInstallerService(){IntPtr hSCManager = OpenSCManager(null, ServicesActiveDatabase, SC_MANAGER_CONNECT | SC_MANAGER_ENUMERATE_SERVICE | SC_MANAGER_QUERY_LOCK_STATUS);if (hSCManager == IntPtr.Zero)@@ -228,7 +221,7 @@ namespace GTweak.Utilities.HelpersCloseServiceHandle(hSCManager);throw new Win32Exception("QueryServiceStatusEx failed: " + Marshal.GetLastWin32Error());}- public static void CreateProcessAsTrustedInstaller(int parentProcessId, string binaryPath)+ internal static void CreateProcessAsTrustedInstaller(int parentProcessId, string binaryPath){ImpersonateSystem();diff --git a/.Source/GTweak/Windows/ImportWindow.xaml.cs b/.Source/GTweak/Windows/ImportWindow.xaml.csindex e9044654..c4e7e8be 100644--- a/.Source/GTweak/Windows/ImportWindow.xaml.cs+++ b/.Source/GTweak/Windows/ImportWindow.xaml.cs@@ -3,6 +3,7 @@ using GTweak.Utilities.Helpers;using GTweak.Utilities.Tweaks;using System;using System.Collections.Generic;+using System.Diagnostics;using System.Linq;using System.Threading;using System.Threading.Tasks;@@ -36,11 +37,11 @@ namespace GTweak.Windowsprivate async void Window_Loaded(object sender, RoutedEventArgs e){- Progress<int> progress = new Progress<int>(ReportProgress);- try { await SortByPageDate(_cancellationTokenSource.Token, progress); } catch { }+ Progress<byte> progress = new Progress<byte>(ReportProgress);+ try { await SortByPageDate(_cancellationTokenSource.Token, progress); } catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }}- private void ReportProgress(int valueProgress)+ private void ReportProgress(byte valueProgress){if (valueProgress == 100){@@ -53,13 +54,13 @@ namespace GTweak.Windows}}- private async Task SortByPageDate(CancellationToken _token, IProgress<int> _progress)+ private async Task SortByPageDate(CancellationToken _token, IProgress<byte> _progress){List<string> tempKeys = new List<string>(), tempValues = new List<string>();INIManager iniManager = new INIManager(Settings.PathConfig);- for (int i = 1; i <= 100; i++)+ for (byte i = 1; i <= 100; i++){_token.ThrowIfCancellationRequested();diff --git a/.Source/GTweak/Windows/NotificationWindow.xaml.cs b/.Source/GTweak/Windows/NotificationWindow.xaml.csindex 76ea87c5..f755163c 100644--- a/.Source/GTweak/Windows/NotificationWindow.xaml.cs+++ b/.Source/GTweak/Windows/NotificationWindow.xaml.cs@@ -130,7 +130,7 @@ namespace GTweak.WindowsClosing -= Window_Closing;e.Cancel = true;DoubleAnimation doubleAnimation = new DoubleAnimation(0, TimeSpan.FromSeconds(0.1));- doubleAnimation.Completed += delegate { _mediaPlayer.Close(); Close(); };+ doubleAnimation.Completed += delegate { Close(); };Timeline.SetDesiredFrameRate(doubleAnimation, 400);BeginAnimation(OpacityProperty, doubleAnimation);}diff --git a/.Source/GTweak/Windows/WaitingWindow.xaml b/.Source/GTweak/Windows/WaitingWindow.xamlindex 5516e38a..c8470a23 100644--- a/.Source/GTweak/Windows/WaitingWindow.xaml+++ b/.Source/GTweak/Windows/WaitingWindow.xaml@@ -4,7 +4,7 @@xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:GTweak.Windows"- mc:Ignorable="d"+ mc:Ignorable="d" Title="GTweak"Height="Auto" Width="Auto" ShowInTaskbar="False" WindowState="Maximized" WindowStyle="None" AllowsTransparency="True" Opacity="0.5"Background="#000000" Topmost="True" Loaded="Window_Loaded" Closing="Window_Closing" IsEnabled="False" IsTabStop="False" IsHitTestVisible="False" ResizeMode="NoResize"></Window>