Skip to content

Commit

Permalink
Upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
hellzerg committed Feb 22, 2022
1 parent e3c97cb commit c70a27d
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 81 deletions.
130 changes: 66 additions & 64 deletions Optimizer/Forms/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Optimizer/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion Optimizer/Forms/MainForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,17 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="picLab.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
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
</value>
</data>
<data name="picUpdate.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
Expand Down Expand Up @@ -849,7 +860,7 @@ any application only by typing your desired keyword.</value>
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAC8
GgAAAk1TRnQBSQFMAgEBCQEAAbABAQGwAQEBIAEAASABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAGA
GgAAAk1TRnQBSQFMAgEBCQEAAdgBAQHYAQEBIAEAASABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAGA
AwABYAMAAQEBAAEgBgABwP8A/wD/AP8A/wD/AP8A/wAeAANHAYB0//8AiQADRwGAdP//AIkAAyoBQANH
AYADRwGAA0cBgANHAYADRwGAA0cBgANHAYADRwGAA0cBgANHAYADRwGAA0cBgANHAYADRwGAA0cBgANH
AYADRwGAA0cBgANHAYADRwGAA0cBgANHAYADRwGAA0cBgANHAYADRwGAA0cBgANHAYADRwGA/wD/AP8A
Expand Down
18 changes: 5 additions & 13 deletions Optimizer/Optimize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions Optimizer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
37 changes: 37 additions & 0 deletions Optimizer/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -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);
}
}
}
}

0 comments on commit c70a27d

Please sign in to comment.