Portable Tool for an Ideal Windows Setup
C# activatorbloatware-removalcsharpdebloatdebloaterdisable-servicesmonitoring-systemportableprivacy-toolsregistry-tweakssystem-tuningsystem-utilitytelemetrytweakerwindows-10windows-11windows-debloatwindows-defenderwindows-optimizationwindows-tweaks
fix stale PID causes crash on elevated tweaks (#130)
Yayo Razofc9167aa6caa
diff --git a/.Source/GTweak/Utilities/Helpers/TrustedInstaller.cs b/.Source/GTweak/Utilities/Helpers/TrustedInstaller.csindex c5045ac6..5fd1dcc6 100644--- a/.Source/GTweak/Utilities/Helpers/TrustedInstaller.cs+++ b/.Source/GTweak/Utilities/Helpers/TrustedInstaller.cs@@ -153,6 +153,19 @@ namespace GTweak.Utilities.HelpersSynchronize = 0x00100000}+ private static bool IsProcessRunning(int processId)+ {+ try+ {+ using Process process = Process.GetProcessById(processId);+ return !process.HasExited;+ }+ catch (ArgumentException)+ {+ return false;+ }+ }+private static bool ImpersonateSystem(){IntPtr tokenHandle = IntPtr.Zero;@@ -269,6 +282,12 @@ namespace GTweak.Utilities.Helpersthrow new Win32Exception("Failed to impersonate SYSTEM identity");}+ if (!IsProcessRunning(parentProcessId))+ {+ StartTrustedInstallerService();+ parentProcessId = CommandExecutor.PID;+ }+attributeList = Marshal.AllocHGlobal((IntPtr)(long)lpSize);if (!InitializeProcThreadAttributeList(attributeList, 1, 0, ref lpSize))