Portable Tool for an Ideal Windows Setup
C# activatorbloatware-removalcsharpdebloatdebloaterdisable-servicesmonitoring-systemportableprivacy-toolsregistry-tweakssystem-tuningsystem-utilitytelemetrytweakerwindows-10windows-11windows-debloatwindows-defenderwindows-optimizationwindows-tweaks
-correction
Greedeksead31d9efe0a
diff --git a/.Source/GTweak/Utilities/Helpers/TakingOwnership.cs b/.Source/GTweak/Utilities/Helpers/TakingOwnership.csindex 1c80705a..1fbaf4fd 100644--- a/.Source/GTweak/Utilities/Helpers/TakingOwnership.cs+++ b/.Source/GTweak/Utilities/Helpers/TakingOwnership.cs@@ -5,14 +5,14 @@ namespace GTweak.Utilities.Helpers{internal class TakingOwnership{- [StructLayoutAttribute(LayoutKind.Sequential)]+ [StructLayout(LayoutKind.Sequential)]private struct SID_IDENTIFIER_AUTHORITY{- [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 6, ArraySubType = UnmanagedType.I1)]+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6, ArraySubType = UnmanagedType.I1)]public byte[] Value;}- [StructLayoutAttribute(LayoutKind.Sequential)]+ [StructLayout(LayoutKind.Sequential)]private struct TRUSTEE{public System.IntPtr pMultipleTrustee;@@ -22,7 +22,7 @@ namespace GTweak.Utilities.Helperspublic IntPtr ptstrName;}- [StructLayoutAttribute(LayoutKind.Sequential)]+ [StructLayout(LayoutKind.Sequential)]private struct EXPLICIT_ACCESS{public ACCESS_MASK grfAccessPermissions;@@ -31,22 +31,22 @@ namespace GTweak.Utilities.Helperspublic TRUSTEE Trustee;}- [StructLayoutAttribute(LayoutKind.Sequential)]+ [StructLayout(LayoutKind.Sequential)]private struct TOKEN_PRIVILEGES{public uint PrivilegeCount;- [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 1, ArraySubType = UnmanagedType.Struct)]+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1, ArraySubType = UnmanagedType.Struct)]public LUID_AND_ATTRIBUTES[] Privileges;}- [StructLayoutAttribute(LayoutKind.Sequential)]+ [StructLayout(LayoutKind.Sequential)]private struct LUID_AND_ATTRIBUTES{public LUID Luid;public uint Attributes;}- [StructLayoutAttribute(LayoutKind.Sequential)]+ [StructLayout(LayoutKind.Sequential)]private struct LUID{public uint LowPart;@@ -104,21 +104,21 @@ namespace GTweak.Utilities.Helpersprivate 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 uint 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);+ [DllImport("advapi32.dll", EntryPoint = "OpenProcessToken")]+ [return: MarshalAs(UnmanagedType.Bool)]+ private static extern bool OpenProcessToken([In] IntPtr ProcessHandle, uint DesiredAccess, out IntPtr TokenHandle);- [DllImportAttribute("advapi32.dll", EntryPoint = "AllocateAndInitializeSid")]- [return: MarshalAsAttribute(UnmanagedType.Bool)]+ [DllImport("advapi32.dll", EntryPoint = "AllocateAndInitializeSid")]+ [return: MarshalAs(UnmanagedType.Bool)]private static extern bool AllocateAndInitializeSid(- [InAttribute] ref SID_IDENTIFIER_AUTHORITY pIdentifierAuthority,+ [In] ref SID_IDENTIFIER_AUTHORITY pIdentifierAuthority,byte nSubAuthorityCount,uint nSubAuthority0,uint nSubAuthority1,@@ -130,27 +130,27 @@ namespace GTweak.Utilities.Helpersuint nSubAuthority7,ref IntPtr pSid);- [DllImportAttribute("kernel32.dll", EntryPoint = "CloseHandle")]- [return: MarshalAsAttribute(UnmanagedType.Bool)]- private static extern bool CloseHandle([InAttribute] IntPtr hObject);+ [DllImport("kernel32.dll", EntryPoint = "CloseHandle")]+ [return: MarshalAs(UnmanagedType.Bool)]+ private static extern bool CloseHandle([In] IntPtr hObject);- [DllImportAttribute("kernel32.dll", EntryPoint = "GetCurrentProcess")]+ [DllImport("kernel32.dll", EntryPoint = "GetCurrentProcess")]private static extern IntPtr GetCurrentProcess();- [DllImportAttribute("advapi32.dll", EntryPoint = "FreeSid")]- private static extern IntPtr FreeSid([InAttribute] IntPtr pSid);+ [DllImport("advapi32.dll", EntryPoint = "FreeSid")]+ private static extern IntPtr FreeSid([In] IntPtr pSid);- [DllImportAttribute("kernel32.dll", EntryPoint = "LocalFree")]+ [DllImport("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);+ [DllImport("advapi32.dll", EntryPoint = "LookupPrivilegeValueA")]+ [return: MarshalAs(UnmanagedType.Bool)]+ private static extern bool LookupPrivilegeValueA([In] [MarshalAs(UnmanagedType.LPStr)] string lpSystemName, [In] [MarshalAs(UnmanagedType.LPStr)] string lpName, [Out] 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()]+ [DllImport("advapi32.dll", EntryPoint = "AdjustTokenPrivileges")]+ [return: MarshalAs(UnmanagedType.Bool)]+ private static extern bool AdjustTokenPrivileges([In()] IntPtr TokenHandle, [MarshalAs(UnmanagedType.Bool)] bool DisableAllPrivileges,+ [In()]ref TOKEN_PRIVILEGES NewState,uint BufferLength,IntPtr PreviousState,@@ -166,7 +166,7 @@ namespace GTweak.Utilities.HelpersIntPtr pDacl,IntPtr pSacl);- [DllImport("Advapi32.dll", EntryPoint = "SetEntriesInAclA",+ [DllImport("advapi32.dll", EntryPoint = "SetEntriesInAclA",CallingConvention = CallingConvention.Winapi,SetLastError = true, CharSet = CharSet.Ansi)]private static extern int SetEntriesInAcl(diff --git a/.Source/GTweak/Utilities/Helpers/TrustedInstaller.cs b/.Source/GTweak/Utilities/Helpers/TrustedInstaller.csindex 7c89daff..2eadf375 100644--- a/.Source/GTweak/Utilities/Helpers/TrustedInstaller.cs+++ b/.Source/GTweak/Utilities/Helpers/TrustedInstaller.cs@@ -63,7 +63,7 @@ namespace GTweak.Utilities.Helpersconst int PROC_THREAD_ATTRIBUTE_PARENT_PROCESS = 0x00020000;const uint EXTENDED_STARTUPINFO_PRESENT = 0x00080000;- const uint CREATE_NO_WINDOW = 0x08000000;+ const uint CREATE_NO_WINDOW = 0x00000010;[StructLayout(LayoutKind.Sequential)]struct SECURITY_ATTRIBUTES@@ -199,9 +199,8 @@ namespace GTweak.Utilities.Helpersthrow new Win32Exception("OpenService failed: " + Marshal.GetLastWin32Error());}- uint bytesNeeded;SERVICE_STATUS_PROCESS statusBuffer = new SERVICE_STATUS_PROCESS();- while (QueryServiceStatusEx(hService, SC_STATUS_PROCESS_INFO, ref statusBuffer, (uint)Marshal.SizeOf(statusBuffer), out bytesNeeded))+ while (QueryServiceStatusEx(hService, SC_STATUS_PROCESS_INFO, ref statusBuffer, (uint)Marshal.SizeOf(statusBuffer), out _)){if (statusBuffer.dwCurrentState == (uint)ServiceControllerStatus.Stopped){@@ -233,12 +232,8 @@ namespace GTweak.Utilities.Helpers{ImpersonateSystem();-- var pInfo = new PROCESS_INFORMATION();+ _ = new PROCESS_INFORMATION();var siEx = new STARTUPINFOEX();-- IntPtr lpValueProc = IntPtr.Zero;- IntPtr hSourceProcessHandle = IntPtr.Zero;var lpSize = IntPtr.Zero;InitializeProcThreadAttributeList(IntPtr.Zero, 1, 0, ref lpSize);@@ -247,7 +242,7 @@ namespace GTweak.Utilities.HelpersIntPtr parentHandle = OpenProcess(ProcessAccessFlags.CreateProcess | ProcessAccessFlags.DuplicateHandle, false, parentProcessId);- lpValueProc = Marshal.AllocHGlobal(IntPtr.Size);+ IntPtr lpValueProc = Marshal.AllocHGlobal(IntPtr.Size);Marshal.WriteIntPtr(lpValueProc, parentHandle);UpdateProcThreadAttribute(siEx.lpAttributeList, 0, (IntPtr)PROC_THREAD_ATTRIBUTE_PARENT_PROCESS, lpValueProc, (IntPtr)IntPtr.Size, IntPtr.Zero, IntPtr.Zero);@@ -256,10 +251,8 @@ namespace GTweak.Utilities.Helpersvar ts = new SECURITY_ATTRIBUTES();ps.nLength = Marshal.SizeOf(ps);ts.nLength = Marshal.SizeOf(ts);-- bool ret = CreateProcess(null, binaryPath, ref ps, ref ts, true, EXTENDED_STARTUPINFO_PRESENT | CREATE_NO_WINDOW, IntPtr.Zero, null, ref siEx, out pInfo);-- string stringPid = pInfo.dwProcessId.ToString();+ _ = CreateProcess(null, binaryPath, ref ps, ref ts, true, EXTENDED_STARTUPINFO_PRESENT | CREATE_NO_WINDOW, IntPtr.Zero, null, ref siEx, out PROCESS_INFORMATION pInfo);+ _ = pInfo.dwProcessId.ToString();}}diff --git a/.Source/GTweak/Utilities/Tweaks/ClearingMemory.cs b/.Source/GTweak/Utilities/Tweaks/ClearingMemory.csindex e19af30a..dfe328e6 100644--- a/.Source/GTweak/Utilities/Tweaks/ClearingMemory.cs+++ b/.Source/GTweak/Utilities/Tweaks/ClearingMemory.cs@@ -7,7 +7,6 @@ using System.Security.Principal;using System.Threading;using System.Threading.Tasks;using System.Windows;-using XamlRadialProgressBar;namespace GTweak.Utilities.Tweaks{