From c70a27d2f9f30708ad989bac2d1a910d9d52ee4c Mon Sep 17 00:00:00 2001 From: deadmoon Date: Tue, 22 Feb 2022 20:44:29 +0200 Subject: [PATCH] Upstream --- Optimizer/Forms/MainForm.Designer.cs | 130 ++++++++++++++------------- Optimizer/Forms/MainForm.cs | 3 +- Optimizer/Forms/MainForm.resx | 13 ++- Optimizer/Optimize.cs | 18 ++-- Optimizer/Program.cs | 4 +- Optimizer/Utilities.cs | 37 ++++++++ 6 files changed, 124 insertions(+), 81 deletions(-) diff --git a/Optimizer/Forms/MainForm.Designer.cs b/Optimizer/Forms/MainForm.Designer.cs index a7fb1455..e3b1d6be 100644 --- a/Optimizer/Forms/MainForm.Designer.cs +++ b/Optimizer/Forms/MainForm.Designer.cs @@ -32,15 +32,16 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); - System.Windows.Forms.TreeNode treeNode1 = new System.Windows.Forms.TreeNode("Processors", 0, 0); - System.Windows.Forms.TreeNode treeNode2 = new System.Windows.Forms.TreeNode("Memory", 1, 1); - System.Windows.Forms.TreeNode treeNode3 = new System.Windows.Forms.TreeNode("Graphics", 2, 2); - System.Windows.Forms.TreeNode treeNode4 = new System.Windows.Forms.TreeNode("Motherboard", 3, 3); - System.Windows.Forms.TreeNode treeNode5 = new System.Windows.Forms.TreeNode("Storage", 4, 4); - System.Windows.Forms.TreeNode treeNode6 = new System.Windows.Forms.TreeNode("Network Adapters", 5, 5); - System.Windows.Forms.TreeNode treeNode7 = new System.Windows.Forms.TreeNode("Audio", 6, 6); - System.Windows.Forms.TreeNode treeNode8 = new System.Windows.Forms.TreeNode("Peripherals", 7, 7); + System.Windows.Forms.TreeNode treeNode9 = new System.Windows.Forms.TreeNode("Processors", 0, 0); + System.Windows.Forms.TreeNode treeNode10 = new System.Windows.Forms.TreeNode("Memory", 1, 1); + System.Windows.Forms.TreeNode treeNode11 = new System.Windows.Forms.TreeNode("Graphics", 2, 2); + System.Windows.Forms.TreeNode treeNode12 = new System.Windows.Forms.TreeNode("Motherboard", 3, 3); + System.Windows.Forms.TreeNode treeNode13 = new System.Windows.Forms.TreeNode("Storage", 4, 4); + System.Windows.Forms.TreeNode treeNode14 = new System.Windows.Forms.TreeNode("Network Adapters", 5, 5); + System.Windows.Forms.TreeNode treeNode15 = new System.Windows.Forms.TreeNode("Audio", 6, 6); + System.Windows.Forms.TreeNode treeNode16 = new System.Windows.Forms.TreeNode("Peripherals", 7, 7); this.tpanel = new System.Windows.Forms.Panel(); + this.picLab = new System.Windows.Forms.PictureBox(); this.picUpdate = new System.Windows.Forms.PictureBox(); this.txtNetFw = new System.Windows.Forms.Label(); this.txtBitness = new System.Windows.Forms.Label(); @@ -360,7 +361,6 @@ private void InitializeComponent() this.rJade = new System.Windows.Forms.RadioButton(); this.rSilver = new System.Windows.Forms.RadioButton(); this.languagesL = new System.Windows.Forms.Label(); - this.lblUpdateDisabled = new System.Windows.Forms.Label(); this.linkLabel5 = new System.Windows.Forms.LinkLabel(); this.btnOpenConf = new System.Windows.Forms.Button(); this.lblTroubleshoot = new System.Windows.Forms.Label(); @@ -401,6 +401,7 @@ private void InitializeComponent() this.launcherIcon = new System.Windows.Forms.NotifyIcon(this.components); this.helpBox = new Optimizer.MoonTip(); this.tpanel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.picLab)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.picUpdate)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.bpanel.SuspendLayout(); @@ -471,6 +472,7 @@ private void InitializeComponent() // tpanel // this.tpanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.tpanel.Controls.Add(this.picLab); this.tpanel.Controls.Add(this.picUpdate); this.tpanel.Controls.Add(this.txtNetFw); this.tpanel.Controls.Add(this.txtBitness); @@ -485,9 +487,22 @@ private void InitializeComponent() this.tpanel.Size = new System.Drawing.Size(1009, 64); this.tpanel.TabIndex = 1; // + // picLab + // + this.picLab.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.picLab.Image = ((System.Drawing.Image)(resources.GetObject("picLab.Image"))); + this.picLab.Location = new System.Drawing.Point(963, 15); + this.picLab.Name = "picLab"; + this.picLab.Size = new System.Drawing.Size(30, 30); + this.picLab.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.picLab.TabIndex = 72; + this.picLab.TabStop = false; + this.picLab.Visible = false; + // // picUpdate // this.picUpdate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.picUpdate.Cursor = System.Windows.Forms.Cursors.Hand; this.picUpdate.Image = ((System.Drawing.Image)(resources.GetObject("picUpdate.Image"))); this.picUpdate.Location = new System.Drawing.Point(963, 15); this.picUpdate.Name = "picUpdate"; @@ -3476,47 +3491,47 @@ private void InitializeComponent() this.specsTree.ForeColor = System.Drawing.Color.White; this.specsTree.Location = new System.Drawing.Point(0, 0); this.specsTree.Name = "specsTree"; - treeNode1.ImageIndex = 0; - treeNode1.Name = "cpu"; - treeNode1.SelectedImageIndex = 0; - treeNode1.Text = "Processors"; - treeNode2.ImageIndex = 1; - treeNode2.Name = "ram"; - treeNode2.SelectedImageIndex = 1; - treeNode2.Text = "Memory"; - treeNode3.ImageIndex = 2; - treeNode3.Name = "gpu"; - treeNode3.SelectedImageIndex = 2; - treeNode3.Text = "Graphics"; - treeNode4.ImageIndex = 3; - treeNode4.Name = "mobo"; - treeNode4.SelectedImageIndex = 3; - treeNode4.Text = "Motherboard"; - treeNode5.ImageIndex = 4; - treeNode5.Name = "disk"; - treeNode5.SelectedImageIndex = 4; - treeNode5.Text = "Storage"; - treeNode6.ImageIndex = 5; - treeNode6.Name = "inet"; - treeNode6.SelectedImageIndex = 5; - treeNode6.Text = "Network Adapters"; - treeNode7.ImageIndex = 6; - treeNode7.Name = "audio"; - treeNode7.SelectedImageIndex = 6; - treeNode7.Text = "Audio"; - treeNode8.ImageIndex = 7; - treeNode8.Name = "dev"; - treeNode8.SelectedImageIndex = 7; - treeNode8.Text = "Peripherals"; + treeNode9.ImageIndex = 0; + treeNode9.Name = "cpu"; + treeNode9.SelectedImageIndex = 0; + treeNode9.Text = "Processors"; + treeNode10.ImageIndex = 1; + treeNode10.Name = "ram"; + treeNode10.SelectedImageIndex = 1; + treeNode10.Text = "Memory"; + treeNode11.ImageIndex = 2; + treeNode11.Name = "gpu"; + treeNode11.SelectedImageIndex = 2; + treeNode11.Text = "Graphics"; + treeNode12.ImageIndex = 3; + treeNode12.Name = "mobo"; + treeNode12.SelectedImageIndex = 3; + treeNode12.Text = "Motherboard"; + treeNode13.ImageIndex = 4; + treeNode13.Name = "disk"; + treeNode13.SelectedImageIndex = 4; + treeNode13.Text = "Storage"; + treeNode14.ImageIndex = 5; + treeNode14.Name = "inet"; + treeNode14.SelectedImageIndex = 5; + treeNode14.Text = "Network Adapters"; + treeNode15.ImageIndex = 6; + treeNode15.Name = "audio"; + treeNode15.SelectedImageIndex = 6; + treeNode15.Text = "Audio"; + treeNode16.ImageIndex = 7; + treeNode16.Name = "dev"; + treeNode16.SelectedImageIndex = 7; + treeNode16.Text = "Peripherals"; this.specsTree.Nodes.AddRange(new System.Windows.Forms.TreeNode[] { - treeNode1, - treeNode2, - treeNode3, - treeNode4, - treeNode5, - treeNode6, - treeNode7, - treeNode8}); + treeNode9, + treeNode10, + treeNode11, + treeNode12, + treeNode13, + treeNode14, + treeNode15, + treeNode16}); this.specsTree.Size = new System.Drawing.Size(991, 567); this.specsTree.TabIndex = 0; this.specsTree.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.specsTree_NodeMouseClick); @@ -4612,7 +4627,6 @@ private void InitializeComponent() this.optionsTab.Controls.Add(this.panel9); this.optionsTab.Controls.Add(this.panel8); this.optionsTab.Controls.Add(this.languagesL); - this.optionsTab.Controls.Add(this.lblUpdateDisabled); this.optionsTab.Controls.Add(this.linkLabel5); this.optionsTab.Controls.Add(this.btnOpenConf); this.optionsTab.Controls.Add(this.lblTroubleshoot); @@ -5137,19 +5151,6 @@ private void InitializeComponent() this.languagesL.Text = "Choose language"; this.languagesL.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // - // lblUpdateDisabled - // - this.lblUpdateDisabled.AutoSize = true; - this.lblUpdateDisabled.Font = new System.Drawing.Font("Segoe UI Semibold", 10F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblUpdateDisabled.ForeColor = System.Drawing.Color.Silver; - this.lblUpdateDisabled.Location = new System.Drawing.Point(32, 358); - this.lblUpdateDisabled.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); - this.lblUpdateDisabled.Name = "lblUpdateDisabled"; - this.lblUpdateDisabled.Size = new System.Drawing.Size(208, 19); - this.lblUpdateDisabled.TabIndex = 69; - this.lblUpdateDisabled.Text = "Disabled in experimental builds"; - this.lblUpdateDisabled.Visible = false; - // // linkLabel5 // this.linkLabel5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); @@ -5591,6 +5592,7 @@ private void InitializeComponent() this.Load += new System.EventHandler(this.Main_Load); this.tpanel.ResumeLayout(false); this.tpanel.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.picLab)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.picUpdate)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.bpanel.ResumeLayout(false); @@ -5896,7 +5898,6 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem trayAD; private System.Windows.Forms.ToolStripMenuItem trayExit; private System.Windows.Forms.LinkLabel linkLabel5; - private System.Windows.Forms.Label lblUpdateDisabled; private System.Windows.Forms.ToolStripMenuItem trayRestartExplorer; private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.Button flushCacheB; @@ -6048,6 +6049,7 @@ private void InitializeComponent() private PictureBox pictureBox13; private PictureBox pictureBox12; private PictureBox pictureBox14; + private PictureBox picLab; } } diff --git a/Optimizer/Forms/MainForm.cs b/Optimizer/Forms/MainForm.cs index f1bc2389..87286ebc 100644 --- a/Optimizer/Forms/MainForm.cs +++ b/Optimizer/Forms/MainForm.cs @@ -415,6 +415,7 @@ private void SetHelpBoxTranslation() helpBox.SetToolTip(classicRibbonSw.Label, Options.TranslationList["classicRibbonTip"].ToString()); helpBox.SetToolTip(classicContextSw.Label, Options.TranslationList["classicContextTip"].ToString()); helpBox.SetToolTip(picUpdate, Options.TranslationList["linkUpdate"].ToString() + "!"); + helpBox.SetToolTip(picLab, Options.TranslationList["lblLab"].ToString()); helpBox.SetToolTip(ffTelemetrySw.Label, Options.TranslationList["ffTelemetryTip"].ToString()); helpBox.SetToolTip(vsSw.Label, Options.TranslationList["vsTip"].ToString()); helpBox.SetToolTip(chromeTelemetrySw.Label, Options.TranslationList["chromeTelemetryTip"].ToString()); @@ -874,7 +875,7 @@ public MainForm(SplashForm _splashForm, bool disableIndicium = false, bool disab if (Program.EXPERIMENTAL_BUILD) { btnUpdate.Enabled = false; - lblUpdateDisabled.Visible = true; + picLab.Visible = true; } // network monitoring diff --git a/Optimizer/Forms/MainForm.resx b/Optimizer/Forms/MainForm.resx index 9079bc64..eeb39025 100644 --- a/Optimizer/Forms/MainForm.resx +++ b/Optimizer/Forms/MainForm.resx @@ -118,6 +118,17 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL + EgAACxIB0t1+/AAAASJJREFUaEPtjkEOBCEIBOf/P51X7F44EIKTUsG+WAkHsYF6Lhcx7/v+dsrW6Mik + ZsrW6MikZsrW6CFiJCODyJGMDCJHMjKIHMnIIHIkI4PIkYwMIkcyMogcycggciQjg8iRjAwiRzIyiBzJ + yCByJCODyJGMDCJHMjKiHCkb1ZPJkbJxPZkcKRvXkonNlK3RMSs0m28lyhChlZk2iEj273u+f5QoMRLJ + /n0v/h2DSoz+fT/+tROPrwhU7Fim4njFjiUqD1fuwoyOxjfBz8zOLvF1MOsR/NzK/BRfx7Iewc+tzE+x + e2g06/vZfwkVR0azvp/9l1Bx4Gve/40yy7QuN1pvtC0OtN1pWxxouxMXnyo7v0+2/ETZ+X2y5SfKzl8u + fTzPH/7wS2w8ChpKAAAAAElFTkSuQmCC + + iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL @@ -849,7 +860,7 @@ any application only by typing your desired keyword. AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAC8 - GgAAAk1TRnQBSQFMAgEBCQEAAbABAQGwAQEBIAEAASABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAGA + GgAAAk1TRnQBSQFMAgEBCQEAAdgBAQHYAQEBIAEAASABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAGA AwABYAMAAQEBAAEgBgABwP8A/wD/AP8A/wD/AP8A/wAeAANHAYB0//8AiQADRwGAdP//AIkAAyoBQANH AYADRwGAA0cBgANHAYADRwGAA0cBgANHAYADRwGAA0cBgANHAYADRwGAA0cBgANHAYADRwGAA0cBgANH AYADRwGAA0cBgANHAYADRwGAA0cBgANHAYADRwGAA0cBgANHAYADRwGAA0cBgANHAYADRwGA/wD/AP8A diff --git a/Optimizer/Optimize.cs b/Optimizer/Optimize.cs index a74b96da..6deaa6e6 100644 --- a/Optimizer/Optimize.cs +++ b/Optimizer/Optimize.cs @@ -9,17 +9,12 @@ public static class Optimize { readonly static string DiagnosisAutoLoggerFolder = Path.Combine(CleanHelper.ProgramData, @"Microsoft\Diagnosis\ETLLogs\AutoLogger"); + + internal static void DisableTelemetryRunner() { - Registry.SetValue( - @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\CompatTelRunner.exe", - "Debugger", @"%windir%\System32\taskkill.exe" - ); - - Registry.SetValue( - @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\DeviceCensus.exe", - "Debugger", @"%windir%\System32\taskkill.exe" - ); + Utilities.PreventProcessFromRunning("CompatTelRunner.exe"); + Utilities.PreventProcessFromRunning("DeviceCensus.exe"); } internal static void EnablePerformanceTweaks() @@ -1624,10 +1619,7 @@ internal static void EnableVisualStudioTelemetry() // CHROME TELEMETRY + SOFTWARE REPORTER TOOL internal static void DisableChromeTelemetry() { - Registry.SetValue( - @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\software_reporter_tool.exe", - "Debugger", @"%windir%\System32\taskkill.exe" - ); + Utilities.PreventProcessFromRunning("software_reporter_tool.exe"); Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome", "MetricsReportingEnabled", 0); Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome", "ChromeCleanupReportingEnabled", 0); diff --git a/Optimizer/Program.cs b/Optimizer/Program.cs index 38d1915a..4ebaf7a5 100644 --- a/Optimizer/Program.cs +++ b/Optimizer/Program.cs @@ -13,8 +13,8 @@ static class Program /* VERSION PROPERTIES */ /* DO NOT LEAVE THEM EMPTY */ - internal readonly static float Major = 11; - internal readonly static float Minor = 8; + internal readonly static float Major = 0; + internal readonly static float Minor = 0; internal readonly static bool EXPERIMENTAL_BUILD = false; diff --git a/Optimizer/Utilities.cs b/Optimizer/Utilities.cs index f45ebca3..3f9d34bc 100644 --- a/Optimizer/Utilities.cs +++ b/Optimizer/Utilities.cs @@ -736,6 +736,8 @@ internal static void DisableProtectedService(string serviceName) allServicesKey.GrantFullControlOnSubKey(serviceName); using (RegistryKey serviceKey = allServicesKey.OpenSubKeyWritable(serviceName)) { + if (serviceKey == null) return; + foreach (string subkeyName in serviceKey.GetSubKeyNames()) { serviceKey.TakeOwnershipOnSubKey(subkeyName); @@ -780,6 +782,8 @@ internal static void EnableProtectedService(string serviceName) allServicesKey.GrantFullControlOnSubKey(serviceName); using (RegistryKey serviceKey = allServicesKey.OpenSubKeyWritable(serviceName)) { + if (serviceKey == null) return; + foreach (string subkeyName in serviceKey.GetSubKeyNames()) { serviceKey.TakeOwnershipOnSubKey(subkeyName); @@ -794,6 +798,7 @@ internal static void EnableProtectedService(string serviceName) public static RegistryKey OpenSubKeyWritable(this RegistryKey registryKey, string subkeyName, RegistryRights? rights = null) { RegistryKey subKey = null; + if (rights == null) subKey = registryKey.OpenSubKey(subkeyName, RegistryKeyPermissionCheck.ReadWriteSubTree); else @@ -892,5 +897,37 @@ internal static void SearchWith(string term, bool ddg) } catch { } } + + internal static void PreventProcessFromRunning(string pName) + { + try + { + using (RegistryKey ifeo = Registry.LocalMachine.OpenSubKeyWritable(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion")) + { + if (ifeo == null) return; + + ifeo.GrantFullControlOnSubKey("Image File Execution Options"); + + using (RegistryKey k = ifeo.OpenSubKeyWritable("Image File Execution Options")) + { + if (k == null) return; + + k.CreateSubKey(pName); + k.GrantFullControlOnSubKey(pName); + + using (RegistryKey f = k.OpenSubKeyWritable(pName)) + { + if (f == null) return; + + f.SetValue("Debugger", @"%windir%\System32\taskkill.exe"); + } + } + } + } + catch (Exception ex) + { + ErrorLogger.LogError("Utilities.PreventProcessFromRunning", ex.Message, ex.StackTrace); + } + } } }