From f08a8a68bae2cff33d7234fa6aefd289239d3d8a Mon Sep 17 00:00:00 2001
From: rounk-ctrl <70931017+rounk-ctrl@users.noreply.github.com>
Date: Thu, 28 Sep 2023 00:18:50 +0400
Subject: [PATCH] what
---
Rectify11.Phase2/Helper.cs | 188 ++++++++++++
Rectify11.Phase2/Patches.cs | 288 ++++++++-----------
Rectify11.Phase2/Program.cs | 250 ++--------------
Rectify11.Phase2/Rectify11.Phase2.csproj | 2 +
Rectify11.Phase2/Resources/rectify11.xml | 2 +-
Rectify11.Phase2/Variables.cs | 19 ++
Rectify11Installer/Core/Backend/Common.cs | 10 +-
Rectify11Installer/Core/Backend/Extras.cs | 17 +-
Rectify11Installer/Core/Backend/Icons.cs | 9 +-
Rectify11Installer/Core/Backend/Installer.cs | 10 +-
Rectify11Installer/Core/Backend/MMCHelper.cs | 2 +-
Rectify11Installer/Core/Backend/Themes.cs | 33 +--
Rectify11Installer/Core/Helpers.cs | 1 +
13 files changed, 395 insertions(+), 436 deletions(-)
create mode 100644 Rectify11.Phase2/Helper.cs
create mode 100644 Rectify11.Phase2/Variables.cs
diff --git a/Rectify11.Phase2/Helper.cs b/Rectify11.Phase2/Helper.cs
new file mode 100644
index 000000000..8b6dae5e4
--- /dev/null
+++ b/Rectify11.Phase2/Helper.cs
@@ -0,0 +1,188 @@
+using Microsoft.VisualBasic;
+using Microsoft.Win32;
+using System;
+using System.Globalization;
+using System.IO;
+using static Rectify11.Phase2.Program;
+
+namespace Rectify11.Phase2
+{
+ internal class Helper
+ {
+ #region Variables
+ public enum MoveType
+ {
+ General = 0,
+ x86,
+ Trouble
+ }
+ #endregion
+ public static bool SafeFileDeletion(string path)
+ {
+ try
+ {
+ if (File.Exists(path))
+ {
+ try
+ {
+ File.Delete(path);
+ }
+ catch
+ {
+ string name = Path.GetRandomFileName();
+ string tmpPath = Path.Combine(Path.GetTempPath(), name);
+ File.Move(path, tmpPath);
+ Program.MoveFileEx(tmpPath, null, Program.MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
+ }
+ return true;
+ }
+ return true;
+ }
+ catch
+ {
+ return false;
+ }
+ }
+ public static bool SafeFileCopy(string file)
+ {
+ // whatever, its only for one case
+ try
+ {
+ if (!SafeFileDeletion(Path.Combine(Variables.sys32Folder, file))) return false;
+ File.Copy(Path.Combine(Variables.r11Files, file), Path.Combine(Variables.sys32Folder, file), true);
+ return true;
+ }
+ catch
+ {
+ return false;
+ }
+ }
+ public static void ImportReg(string path)
+ {
+ try
+ {
+ Interaction.Shell(Path.Combine(Variables.sys32Folder, "reg.exe") + " import " + path, AppWinStyle.Hide);
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(Path.GetFileName(path) + " failed.", ex);
+ }
+ }
+ public static string FixString(string path, bool x86)
+ {
+ if (path.Contains("mun"))
+ {
+ return path.Replace(@"%sysresdir%", Variables.sysresdir);
+ }
+ else if (path.Contains("%sys32%"))
+ {
+ if (x86)
+ {
+ return path.Replace(@"%sys32%", Variables.sysWOWFolder);
+ }
+ else
+ {
+ return path.Replace(@"%sys32%", Variables.sys32Folder);
+ }
+ }
+ else if (path.Contains("%lang%"))
+ {
+ return path.Replace(@"%lang%", Path.Combine(Variables.sys32Folder, CultureInfo.CurrentUICulture.Name));
+ }
+ else if (path.Contains("%en-US%"))
+ {
+ return path.Replace(@"%en-US%", Path.Combine(Variables.sys32Folder, "en-US"));
+ }
+ else if (path.Contains("%windirLang%"))
+ {
+ return path.Replace(@"%windirLang%", Path.Combine(Variables.windir, CultureInfo.CurrentUICulture.Name));
+ }
+ else if (path.Contains("%windirEn-US%"))
+ {
+ return path.Replace(@"%windirEn-US%", Path.Combine(Variables.windir, "en-US"));
+ }
+ else if (path.Contains("%branding%"))
+ {
+ return path.Replace(@"%branding%", Variables.brandingFolder);
+ }
+ else if (path.Contains("%prog%"))
+ {
+ if (x86)
+ {
+ return path.Replace(@"%prog%", Variables.progfiles86);
+ }
+ else
+ {
+ return path.Replace(@"%prog%", Variables.progfiles);
+ }
+ }
+ else if (path.Contains("%windir%"))
+ {
+ return path.Replace(@"%windir%", Variables.windir);
+ }
+ else if (path.Contains("%diag%"))
+ {
+ return path.Replace("%diag%", Variables.diag);
+ }
+ return path;
+ }
+ public static void MoveFile(string newval, string file, MoveType type, string name)
+ {
+ Console.WriteLine(newval);
+ Console.Write("Final path: ");
+ string finalpath = string.Empty;
+ if (type == MoveType.General)
+ {
+ finalpath = Path.Combine(Variables.r11Folder, "Backup", Path.GetFileName(newval));
+ }
+ else if (type == MoveType.x86)
+ {
+ finalpath = Path.Combine(Variables.r11Folder, "Backup", Path.GetFileNameWithoutExtension(newval) + "86" + Path.GetExtension(newval));
+ }
+ else if (type == MoveType.Trouble)
+ {
+ finalpath = Path.Combine(Variables.r11Folder, "Backup", "Diag", Path.GetFileNameWithoutExtension(newval) + name + Path.GetExtension(newval));
+ }
+ if (string.IsNullOrWhiteSpace(finalpath)) return;
+ if (!File.Exists(finalpath))
+ {
+ Console.WriteLine(finalpath);
+ File.Move(newval, finalpath);
+ }
+ else if (File.Exists(finalpath))
+ {
+ bool wu = false;
+ var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Rectify11");
+ var b = key?.GetValue("WindowsUpdate");
+ var value = (int?)b;
+ if (value == 1) wu = true;
+ if (!wu)
+ {
+ finalpath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
+ Console.WriteLine(finalpath);
+ MoveFileEx(finalpath, null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
+ }
+ else
+ {
+ Console.WriteLine("WU: " + finalpath);
+ if (File.Exists(finalpath))
+ {
+ try
+ {
+ File.Delete(finalpath);
+ }
+ catch
+ {
+ string fil = Path.GetTempFileName();
+ File.Move(finalpath, Path.Combine(Path.GetTempPath(), fil));
+ MoveFileEx(Path.Combine(Path.GetTempPath(), fil), null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
+ }
+ }
+ }
+ File.Move(newval, finalpath);
+ }
+ File.Copy(file, newval, true);
+
+ }
+ }
+}
diff --git a/Rectify11.Phase2/Patches.cs b/Rectify11.Phase2/Patches.cs
index 54ff86414..26cbe896e 100644
--- a/Rectify11.Phase2/Patches.cs
+++ b/Rectify11.Phase2/Patches.cs
@@ -1,174 +1,118 @@
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.42000
-//
-//------------------------------------------------------------------------------
-
-//
-// This source code was auto-generated by xsd, Version=4.6.1055.0.
-//
-
-namespace Rectify11.Phase2
+using System;
+using System.CodeDom.Compiler;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.IO;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+
+#region Parser
+public class PatchesParser
+{
+ #region Public Methods
+ public static Patches GetAll()
+ {
+ XmlSerializer ser = new XmlSerializer(typeof(Patches));
+ Patches patches;
+ using (var reader = new StringReader(Rectify11.Phase2.Properties.Resources.rectify11))
+ {
+ patches = (Patches)ser.Deserialize(reader);
+ }
+ return patches;
+ }
+ #endregion
+}
+#endregion
+#region Deserializer Class
+
+[GeneratedCodeAttribute("xsd", "4.6.1055.0")]
+[SerializableAttribute()]
+[DebuggerStepThroughAttribute()]
+[DesignerCategoryAttribute("code")]
+[XmlTypeAttribute(AnonymousType = true)]
+[XmlRootAttribute(Namespace = "", IsNullable = false)]
+public partial class Patches
{
- public class PatchesParser
- {
- #region Public Methods
- public static Patches GetAll()
- {
- System.Xml.Serialization.XmlSerializer ser = new System.Xml.Serialization.XmlSerializer(typeof(Patches));
- Patches patches;
- using (var reader = new System.IO.StringReader(Rectify11.Phase2.Properties.Resources.rectify11))
- {
- patches = (Patches)ser.Deserialize(reader);
- }
- return patches;
- }
- #endregion
- }
-
- ///
- [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
- [System.SerializableAttribute()]
- [System.Diagnostics.DebuggerStepThroughAttribute()]
- [System.ComponentModel.DesignerCategoryAttribute("code")]
- [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
- [System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)]
- public partial class Patches {
-
- private PatchesPatch[] itemsField;
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("Patch", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
- public PatchesPatch[] Items {
- get {
- return this.itemsField;
- }
- set {
- this.itemsField = value;
- }
- }
- }
-
- ///
- [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
- [System.SerializableAttribute()]
- [System.Diagnostics.DebuggerStepThroughAttribute()]
- [System.ComponentModel.DesignerCategoryAttribute("code")]
- [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
- public partial class PatchesPatch {
-
- private string muiField;
-
- private string maskField;
-
- private string x86Field;
-
- private string hardlinkTargetField;
-
- private string disableOnSafeModeField;
-
- private string IgnoreField;
-
- private string MinVersionField;
-
- private string MaxVersionField;
-
- ///
- [System.Xml.Serialization.XmlAttributeAttribute()]
- public string Mui {
- get {
- return this.muiField;
- }
- set {
- this.muiField = value;
- }
- }
-
- ///
- [System.Xml.Serialization.XmlAttributeAttribute()]
- public string mask {
- get {
- return this.maskField;
- }
- set {
- this.maskField = value;
- }
- }
-
- ///
- [System.Xml.Serialization.XmlAttributeAttribute()]
- public string x86 {
- get {
- return this.x86Field;
- }
- set {
- this.x86Field = value;
- }
- }
-
- ///
- [System.Xml.Serialization.XmlAttributeAttribute()]
- public string HardlinkTarget {
- get {
- return this.hardlinkTargetField;
- }
- set {
- this.hardlinkTargetField = value;
- }
- }
-
- ///
- [System.Xml.Serialization.XmlAttributeAttribute()]
- public string DisableOnSafeMode {
- get {
- return this.disableOnSafeModeField;
- }
- set {
- this.disableOnSafeModeField = value;
- }
- }
-
- ///
- [System.Xml.Serialization.XmlAttributeAttribute()]
- public string Ignore
- {
- get
- {
- return this.IgnoreField;
- }
- set
- {
- this.IgnoreField = value;
- }
- }
-
- ///
- [System.Xml.Serialization.XmlAttributeAttribute()]
- public string MinVersion
- {
- get
- {
- return this.MinVersionField;
- }
- set
- {
- this.MinVersionField = value;
- }
- }
- ///
- [System.Xml.Serialization.XmlAttributeAttribute()]
- public string MaxVersion
- {
- get
- {
- return this.MaxVersionField;
- }
- set
- {
- this.MaxVersionField = value;
- }
- }
- }
-}
\ No newline at end of file
+ private PatchesPatch[] itemsField;
+ [XmlElementAttribute("Patch", Form = XmlSchemaForm.Unqualified)]
+ public PatchesPatch[] Items
+ {
+ get => this.itemsField;
+ set => this.itemsField = value;
+ }
+}
+
+[GeneratedCodeAttribute("xsd", "4.6.1055.0")]
+[SerializableAttribute()]
+[DebuggerStepThroughAttribute()]
+[DesignerCategoryAttribute("code")]
+[XmlTypeAttribute(AnonymousType = true)]
+public partial class PatchesPatch
+{
+ private string muiField;
+ private string maskField;
+ private string x86Field;
+ private string hardlinkTargetField;
+ private string disableOnSafeModeField;
+ private string IgnoreField;
+ private string MinVersionField;
+ private string MaxVersionField;
+
+ [XmlAttributeAttribute()]
+ public string Mui
+ {
+ get => this.muiField;
+ set => this.muiField = value;
+ }
+
+ [XmlAttributeAttribute()]
+ public string mask
+ {
+ get => this.maskField;
+ set => this.maskField = value;
+ }
+
+ [XmlAttributeAttribute()]
+ public string x86
+ {
+ get => this.x86Field;
+ set => this.x86Field = value;
+ }
+
+ [XmlAttributeAttribute()]
+ public string HardlinkTarget
+ {
+ get => this.hardlinkTargetField;
+ set => this.hardlinkTargetField = value;
+ }
+
+ [XmlAttributeAttribute()]
+ public string DisableOnSafeMode
+ {
+ get => this.disableOnSafeModeField;
+ set => this.disableOnSafeModeField = value;
+ }
+
+ [XmlAttributeAttribute()]
+ public string Ignore
+ {
+ get => this.IgnoreField;
+ set => this.IgnoreField = value;
+ }
+
+ [XmlAttributeAttribute()]
+ public string MinVersion
+ {
+ get => this.MinVersionField;
+ set => this.MinVersionField = value;
+ }
+
+ [XmlAttributeAttribute()]
+ public string MaxVersion
+ {
+ get => this.MaxVersionField;
+ set => this.MaxVersionField = value;
+ }
+}
+#endregion
\ No newline at end of file
diff --git a/Rectify11.Phase2/Program.cs b/Rectify11.Phase2/Program.cs
index 7597cd191..091409544 100644
--- a/Rectify11.Phase2/Program.cs
+++ b/Rectify11.Phase2/Program.cs
@@ -1,11 +1,11 @@
-using Microsoft.VisualBasic;
-using Microsoft.Win32;
+using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Runtime.InteropServices;
+using static Rectify11.Phase2.Helper;
namespace Rectify11.Phase2
{
@@ -54,11 +54,15 @@ private static void Main(string[] args)
}
}
- MoveIconres();
- MoveDUIRes();
- MoveIMFH();
- MoveTwinUIFonts();
+
+ // copy necessary files
+ SafeFileCopy("iconres.dll");
+ ImportReg(Path.Combine(Variables.r11Files, "icons.reg"));
+ SafeFileCopy("duires.dll");
+ SafeFileCopy("ImmersiveFontHandler.dll");
+ SafeFileCopy("twinuifonts.dll");
InstallFonts();
+
r11Reg?.Close();
if (pendingFiles != null)
{
@@ -377,228 +381,36 @@ private static void Main(string[] args)
}
Environment.Exit(0);
}
- private static string FixString(string path, bool x86)
- {
- if (path.Contains("mun"))
- {
- return path.Replace(@"%sysresdir%", Variables.sysresdir);
- }
- else if (path.Contains("%sys32%"))
- {
- if (x86)
- {
- return path.Replace(@"%sys32%", Variables.sysWOWFolder);
- }
- else
- {
- return path.Replace(@"%sys32%", Variables.sys32Folder);
- }
- }
- else if (path.Contains("%lang%"))
- {
- return path.Replace(@"%lang%", Path.Combine(Variables.sys32Folder, CultureInfo.CurrentUICulture.Name));
- }
- else if (path.Contains("%en-US%"))
- {
- return path.Replace(@"%en-US%", Path.Combine(Variables.sys32Folder, "en-US"));
- }
- else if (path.Contains("%windirLang%"))
- {
- return path.Replace(@"%windirLang%", Path.Combine(Variables.windir, CultureInfo.CurrentUICulture.Name));
- }
- else if (path.Contains("%windirEn-US%"))
- {
- return path.Replace(@"%windirEn-US%", Path.Combine(Variables.windir, "en-US"));
- }
- else if (path.Contains("%branding%"))
- {
- return path.Replace(@"%branding%", Variables.brandingFolder);
- }
- else if (path.Contains("%prog%"))
- {
- if (x86)
- {
- return path.Replace(@"%prog%", Variables.progfiles86);
- }
- else
- {
- return path.Replace(@"%prog%", Variables.progfiles);
- }
- }
- else if (path.Contains("%windir%"))
- {
- return path.Replace(@"%windir%", Variables.windir);
- }
- else if (path.Contains("%diag%"))
- {
- return path.Replace("%diag%", Variables.diag);
- }
- return path;
- }
- private enum MoveType
- {
- General = 0,
- x86,
- Trouble
- }
- private static void MoveFile(string newval, string file, MoveType type, string name)
- {
- Console.WriteLine(newval);
- Console.Write("Final path: ");
- string finalpath = string.Empty;
- if (type == MoveType.General)
- {
- finalpath = Path.Combine(Variables.r11Folder, "Backup", Path.GetFileName(newval));
- }
- else if (type == MoveType.x86)
- {
- finalpath = Path.Combine(Variables.r11Folder, "Backup", Path.GetFileNameWithoutExtension(newval) + "86" + Path.GetExtension(newval));
- }
- else if (type == MoveType.Trouble)
- {
- finalpath = Path.Combine(Variables.r11Folder, "Backup", "Diag", Path.GetFileNameWithoutExtension(newval) + name + Path.GetExtension(newval));
- }
- if (string.IsNullOrWhiteSpace(finalpath)) return;
- if (!File.Exists(finalpath))
- {
- Console.WriteLine(finalpath);
- File.Move(newval, finalpath);
- }
- else if (File.Exists(finalpath))
- {
- bool wu = false;
- var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Rectify11");
- var b = key?.GetValue("WindowsUpdate");
- var value = (int?)b;
- if (value == 1) wu = true;
- if (!wu)
- {
- finalpath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
- Console.WriteLine(finalpath);
- MoveFileEx(finalpath, null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
- }
- else
- {
- Console.WriteLine("WU: " + finalpath);
- if (File.Exists(finalpath))
- {
- try
- {
- File.Delete(finalpath);
- }
- catch
- {
- string fil = Path.GetTempFileName();
- File.Move(finalpath, Path.Combine(Path.GetTempPath(), fil));
- MoveFileEx(Path.Combine(Path.GetTempPath(), fil), null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
- }
- }
- }
- File.Move(newval, finalpath);
- }
- File.Copy(file, newval, true);
- }
- private static void MoveIconres()
- {
- var iconresDest = Path.Combine(Variables.sys32Folder, "iconres.dll");
- var iconres = Path.Combine(Variables.r11Files, "iconres.dll");
- try
- {
- File.Copy(iconres, iconresDest, true);
- Interaction.Shell(Path.Combine(Variables.sys32Folder, "reg.exe") + " import " + Path.Combine(Variables.r11Files, "icons.reg"), AppWinStyle.Hide, true);
- }
- catch
- {
- // ignored
- }
- }
- private static void MoveDUIRes()
- {
- var duiresDest = Path.Combine(Variables.sys32Folder, "duires.dll");
- var duires = Path.Combine(Variables.r11Files, "duires.dll");
- try
- {
- File.Copy(duires, duiresDest, true);
- }
- catch
- {
- // ignored
- }
- }
- private static void MoveIMFH()
- {
- var imfhDest = Path.Combine(Variables.sys32Folder, "ImmersiveFontHandler.dll");
- var imfh = Path.Combine(Variables.r11Files, "ImmersiveFontHandler.dll");
- try
- {
- File.Copy(imfh, imfhDest, true);
- }
- catch
- {
- // ignored
- }
- }
- private static void MoveTwinUIFonts()
- {
- var twinuifontsDest = Path.Combine(Variables.sys32Folder, "twinuifonts.dll");
- var twinuifonts = Path.Combine(Variables.r11Files, "twinuifonts.dll");
- try
- {
- File.Copy(twinuifonts, twinuifontsDest, true);
- }
- catch
- {
- // ignored
- }
- }
private static void InstallFonts()
{
+ // aaaaaaaaaaaa
var MarlettDest = Path.Combine(Variables.windir, "Fonts", "marlett.ttf");
var MarlettBackupDest = Path.Combine(Variables.windir, "Fonts", "marlett.ttf.backup");
var marlett = Path.Combine(Variables.r11Files, "marlett.ttf");
- try
- {
- File.Move(MarlettDest, MarlettBackupDest);
- File.Copy(marlett, MarlettDest, true);
- }
- catch
- {
- }
+ File.Move(MarlettDest, MarlettBackupDest);
+ File.Copy(marlett, MarlettDest, true);
+
var BackIconsDest = Path.Combine(Variables.windir, "Fonts", "BackIcons.ttf");
var backicons = Path.Combine(Variables.r11Files, "BackIcons.ttf");
- try
- {
- File.Copy(backicons, BackIconsDest, true);
- Interaction.Shell(Path.Combine(Variables.sys32Folder, "reg.exe") + " import " + Path.Combine(Variables.r11Files, "backicons.reg"), AppWinStyle.Hide, true);
- }
- catch
- {
- }
+ File.Copy(backicons, BackIconsDest, true);
+ Helper.ImportReg(Path.Combine(Variables.r11Files, "backicons.reg"));
+
if (Environment.OSVersion.Version.Build <= 21996)
{
var SegoeIconsDest = Path.Combine(Variables.windir, "Fonts", "SegoeIcons.ttf");
var segoeicons = Path.Combine(Variables.r11Files, "SegoeIcons.ttf");
- try
- {
- File.Copy(segoeicons, SegoeIconsDest, true);
- Interaction.Shell(Path.Combine(Variables.sys32Folder, "reg.exe") + " import " + Path.Combine(Variables.r11Files, "segoeicons.reg"), AppWinStyle.Hide, true);
- }
- catch
- {
- }
+ File.Copy(segoeicons, SegoeIconsDest, true);
+ Helper.ImportReg(Path.Combine(Variables.r11Files, "segoeicons.reg"));
+
var SegoeUIVarDest = Path.Combine(Variables.windir, "Fonts", "SegUIVar.ttf");
var segoeuivar = Path.Combine(Variables.r11Files, "SegUIVar.ttf");
- try
- {
- File.Copy(segoeuivar, SegoeUIVarDest, true);
- Interaction.Shell(Path.Combine(Variables.sys32Folder, "reg.exe") + " import " + Path.Combine(Variables.r11Files, "segoeuivar.reg"), AppWinStyle.Hide, true);
- }
- catch
- {
- }
+ File.Copy(segoeuivar, SegoeUIVarDest, true);
+ Helper.ImportReg(Path.Combine(Variables.r11Files, "segoeuivar.reg"));
}
}
+
+ #region P/Invoke
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, MoveFileFlags dwFlags);
[Flags]
@@ -611,18 +423,6 @@ public enum MoveFileFlags
MOVEFILE_CREATE_HARDLINK = 0x00000010,
MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x00000020
}
- }
- public class Variables
- {
- public static string windir = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
- public static string r11Folder = Path.Combine(windir, "Rectify11");
- public static string r11Files = Path.Combine(r11Folder, "files");
- public static string sys32Folder = Environment.SystemDirectory;
- public static string sysWOWFolder = Environment.GetFolderPath(Environment.SpecialFolder.SystemX86);
- public static string sysresdir = Path.Combine(windir, "SystemResources");
- public static string brandingFolder = Path.Combine(windir, "Branding");
- public static string progfiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
- public static string progfiles86 = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);
- public static string diag = Path.Combine(windir, "diagnostics", "system");
+ #endregion
}
}
diff --git a/Rectify11.Phase2/Rectify11.Phase2.csproj b/Rectify11.Phase2/Rectify11.Phase2.csproj
index 1505232ec..7041fe314 100644
--- a/Rectify11.Phase2/Rectify11.Phase2.csproj
+++ b/Rectify11.Phase2/Rectify11.Phase2.csproj
@@ -46,6 +46,7 @@
+
@@ -54,6 +55,7 @@
True
Resources.resx
+
diff --git a/Rectify11.Phase2/Resources/rectify11.xml b/Rectify11.Phase2/Resources/rectify11.xml
index 2903d50e1..4e336936b 100644
--- a/Rectify11.Phase2/Resources/rectify11.xml
+++ b/Rectify11.Phase2/Resources/rectify11.xml
@@ -436,7 +436,7 @@
-
+
diff --git a/Rectify11.Phase2/Variables.cs b/Rectify11.Phase2/Variables.cs
new file mode 100644
index 000000000..3dbe33080
--- /dev/null
+++ b/Rectify11.Phase2/Variables.cs
@@ -0,0 +1,19 @@
+using System;
+using System.IO;
+
+namespace Rectify11.Phase2
+{
+ public class Variables
+ {
+ public static string windir = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
+ public static string r11Folder = Path.Combine(windir, "Rectify11");
+ public static string r11Files = Path.Combine(r11Folder, "files");
+ public static string sys32Folder = Environment.SystemDirectory;
+ public static string sysWOWFolder = Environment.GetFolderPath(Environment.SpecialFolder.SystemX86);
+ public static string sysresdir = Path.Combine(windir, "SystemResources");
+ public static string brandingFolder = Path.Combine(windir, "Branding");
+ public static string progfiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
+ public static string progfiles86 = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);
+ public static string diag = Path.Combine(windir, "diagnostics", "system");
+ }
+}
diff --git a/Rectify11Installer/Core/Backend/Common.cs b/Rectify11Installer/Core/Backend/Common.cs
index d649ae89b..f9ab454bf 100644
--- a/Rectify11Installer/Core/Backend/Common.cs
+++ b/Rectify11Installer/Core/Backend/Common.cs
@@ -52,7 +52,7 @@ public static bool WriteFiles(bool icons, bool themes)
return false;
}
- Logger.WriteLine("WriteFiles() succeeded");
+ Logger.WriteLine("WriteFiles() succeeded.");
return true;
}
catch (Exception ex)
@@ -220,6 +220,9 @@ public static bool Cleanup()
{
try
{
+ Logger.WriteLine("Cleaning up");
+ Logger.WriteLine("───────────");
+
// we dont care about returned value
Helper.SafeDirectoryDeletion(Variables.r11Files, false);
Helper.SafeFileDeletion(Path.Combine(Variables.r11Folder, "files.7z"));
@@ -241,12 +244,13 @@ public static bool Cleanup()
Helper.SafeDirectoryDeletion(Path.Combine(Variables.r11Folder, "extras"), false);
}
}
- Logger.WriteLine("Cleanup() succeeded");
+ Logger.WriteLine("Cleanup() succeeded.");
+ Logger.WriteLine("══════════════════════════════════════════════");
return true;
}
catch (Exception ex)
{
- Logger.WriteLine("Cleanup() failed", ex);
+ Logger.Warn("Cleanup() failed", ex);
return false;
}
}
diff --git a/Rectify11Installer/Core/Backend/Extras.cs b/Rectify11Installer/Core/Backend/Extras.cs
index e8541e8f2..091b44031 100644
--- a/Rectify11Installer/Core/Backend/Extras.cs
+++ b/Rectify11Installer/Core/Backend/Extras.cs
@@ -60,7 +60,7 @@ public static bool Install(FrmWizard frm)
InstallUserAvatars();
Helper.SafeDirectoryDeletion(Path.Combine(Variables.r11Folder, "extras", "userAV"), false);
}
- Logger.WriteLine("InstallExtras() succeeded.");
+ Logger.WriteLine("Extras.Install() succeeded.");
Logger.WriteLine("══════════════════════════════════════════════");
return true;
}
@@ -70,6 +70,7 @@ public static bool Install(FrmWizard frm)
return false;
}
}
+
public static bool Uninstall()
{
try
@@ -87,6 +88,8 @@ public static bool Uninstall()
if (UninstallOptions.uninstExtrasList[i] == "gadgetsNode")
UninstallGadgets();
}
+ Logger.WriteLine("Extras.Uninstall() succeeded.");
+ Logger.WriteLine("══════════════════════════════════════════════");
return true;
}
catch (Exception ex)
@@ -325,7 +328,7 @@ private static bool UninstallWallpapers()
}
}
- Logger.WriteLine("UninstallWallpapers() succeeded");
+ Logger.WriteLine("UninstallWallpapers() succeeded.");
return true;
}
catch (Exception ex)
@@ -361,7 +364,7 @@ private static bool UninstallAsdf()
Helper.SafeDirectoryDeletion(epath, false);
}
- Logger.WriteLine("UninstallAsdf() succeeded");
+ Logger.WriteLine("UninstallAsdf() succeeded.");
return true;
}
return true;
@@ -382,7 +385,7 @@ private static bool UninstallGadgets()
gaduns.WaitForExit();
}
- Logger.WriteLine("UninstallGadgets() succeeded");
+ Logger.WriteLine("UninstallGadgets() succeeded.");
return true;
}
catch (Exception ex)
@@ -431,12 +434,12 @@ private static bool UninstallShell()
Thread.Sleep(3000);
}
}
- Logger.WriteLine("UninstallShell() succeeded");
+ Logger.WriteLine("UninstallShell() succeeded.");
return true;
}
catch (Exception ex)
{
- Logger.WriteLine("UninstallShell() failed", ex);
+ Logger.WriteLine("UninstallShell() failed.", ex);
return false;
}
}
@@ -445,7 +448,7 @@ private static bool UninstallUserAv()
try
{
Helper.SafeDirectoryDeletion(Path.Combine(Variables.progdata, "Microsoft", "User Account Pictures", "Default Pictures"), false);
- Logger.WriteLine("UninstallUserAv() succeeded");
+ Logger.WriteLine("UninstallUserAv() succeeded.");
return true;
}
catch (Exception ex)
diff --git a/Rectify11Installer/Core/Backend/Icons.cs b/Rectify11Installer/Core/Backend/Icons.cs
index f8ac29a69..3538c37ab 100644
--- a/Rectify11Installer/Core/Backend/Icons.cs
+++ b/Rectify11Installer/Core/Backend/Icons.cs
@@ -74,7 +74,7 @@ public static bool Install(FrmWizard frm)
}
}
}
- Logger.WriteLine("MatchAndApplyRule() succeeded");
+ Logger.WriteLine("MatchAndApplyRule() succeeded.");
if (!WritePendingFiles(fileList, x86List))
return false;
@@ -109,6 +109,8 @@ public static bool Install(FrmWizard frm)
Helper.ImportReg(Path.Combine(Variables.r11Files, "icons.reg"));
Variables.RestartRequired = true;
+ Logger.WriteLine("Icons.Install() succeeded.");
+ Logger.WriteLine("══════════════════════════════════════════════");
return true;
}
catch (Exception ex)
@@ -143,6 +145,9 @@ public static bool Uninstall()
Helper.SafeFileDeletion(Path.Combine(Variables.r11Folder, "Rectify11.Phase2.exe"));
Helper.SafeFileDeletion(Path.Combine(Variables.r11Folder, "aRun.exe"));
+
+ Logger.WriteLine("Icons.Uninstall() succeeded.");
+ Logger.WriteLine("══════════════════════════════════════════════");
return true;
}
catch (Exception ex)
@@ -179,7 +184,7 @@ private static bool FixOdbc()
shortcut.DisplayMode = ShellLink.LinkDisplayMode.edmNormal;
if (filename != null) shortcut.Save(Path.Combine(admintools, filename));
- Logger.WriteLine("FixOdbc() succeeded");
+ Logger.WriteLine("FixOdbc() succeeded.");
return true;
}
catch (Exception ex)
diff --git a/Rectify11Installer/Core/Backend/Installer.cs b/Rectify11Installer/Core/Backend/Installer.cs
index 9ffb2ec6b..0b61df8e8 100644
--- a/Rectify11Installer/Core/Backend/Installer.cs
+++ b/Rectify11Installer/Core/Backend/Installer.cs
@@ -99,15 +99,7 @@ public bool Install(FrmWizard frm)
// cleanup
frm.InstallerProgress = "Cleaning up...";
- Logger.WriteLine("Cleaning up");
- Logger.WriteLine("───────────");
- if (!Common.Cleanup())
- {
- Logger.WriteLine("Cleanup() failed");
- return false;
- }
- Logger.WriteLine("Cleanup() succeeded");
- Logger.WriteLine("══════════════════════════════════════════════");
+ Common.Cleanup();
Logger.CommitLog();
return true;
}
diff --git a/Rectify11Installer/Core/Backend/MMCHelper.cs b/Rectify11Installer/Core/Backend/MMCHelper.cs
index 70f15ab5a..97355c21e 100644
--- a/Rectify11Installer/Core/Backend/MMCHelper.cs
+++ b/Rectify11Installer/Core/Backend/MMCHelper.cs
@@ -51,7 +51,7 @@ public static bool PatchAll()
File.Copy(Path.Combine(msc, "WmiMgmt.msc"), Path.Combine(msc, CultureInfo.CurrentUICulture.Name, "WmiMgmt.msc"), true);
}
- Logger.WriteLine("MmcHelper.PatchAll() succeeded");
+ Logger.WriteLine("MmcHelper.PatchAll() succeeded.");
return true;
}
catch (Exception ex)
diff --git a/Rectify11Installer/Core/Backend/Themes.cs b/Rectify11Installer/Core/Backend/Themes.cs
index f221f402a..8db8aaefb 100644
--- a/Rectify11Installer/Core/Backend/Themes.cs
+++ b/Rectify11Installer/Core/Backend/Themes.cs
@@ -64,7 +64,7 @@ public static bool Install()
Logger.Warn("Installr11cpl() failed", ex);
}
Variables.RestartRequired = true;
- Logger.WriteLine("InstallThemes() succeeded.");
+ Logger.WriteLine("Themes.Install() succeeded.");
Logger.WriteLine("══════════════════════════════════════════════");
return true;
}
@@ -127,14 +127,15 @@ public static bool Uninstall()
key.SetValue("MenuHeight", "-285");
key.SetValue("MenuWidth", "-285");
key.Dispose();
- Logger.WriteLine("Remove registry entries");
+ Logger.WriteLine("Removed registry entries.");
}
catch { }
UninstallR11Cpl();
- Logger.WriteLine("Deleted Rectify11 Control Center");
+ Logger.WriteLine("Deleted Rectify11 Control Center.");
- Logger.WriteLine("Uninstall() succeeded");
+ Logger.WriteLine("Themes.Uninstall() succeeded.");
+ Logger.WriteLine("══════════════════════════════════════════════");
return true;
}
catch (Exception ex)
@@ -184,10 +185,10 @@ private static bool InstallThemes()
///
private static void InstallR11Cpl()
{
+ UninstallR11Cpl();
string cplPath = Path.Combine(Variables.r11Folder, "Rectify11CPL", "Rectify11CPL.dll");
//create files
- Helper.SafeDirectoryDeletion(Path.Combine(Variables.r11Folder, "Rectify11CPL"), false);
Directory.CreateDirectory(Path.Combine(Variables.r11Folder, "Rectify11CPL"));
File.WriteAllBytes(cplPath, Properties.Resources.Rectify11CPL);
@@ -208,7 +209,7 @@ private static void InstallR11Cpl()
}
catch (Exception ex)
{
- Logger.WriteLine("Error while saving shortcut: " + ex);
+ Logger.Warn("Error while saving shortcut: " + ex);
}
shortcut.Save(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Rectify11 Control Center.lnk"));
@@ -236,10 +237,10 @@ private static void UninstallR11Cpl()
string desktopShortcut = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Rectify11 Control Center.lnk");
// delete shortcut
- if (File.Exists(startmenuShortcut))
- File.Delete(startmenuShortcut);
- if (File.Exists(desktopShortcut))
- File.Delete(desktopShortcut);
+ Helper.SafeFileDeletion(startmenuShortcut);
+ Helper.SafeFileDeletion(desktopShortcut);
+
+ if (!File.Exists(cplPath)) return;
// unregister CPL
var proc = new Process();
@@ -250,7 +251,7 @@ private static void UninstallR11Cpl()
if (proc.ExitCode != 0)
{
- Logger.WriteLine("Error while unregistering CPL: " + proc.ExitCode);
+ Logger.Warn("Error while unregistering CPL: " + proc.ExitCode);
}
//delete folder
@@ -305,7 +306,7 @@ private static bool InstallThemeWallpapers()
}
catch (Exception ex)
{
- Logger.WriteLine("Error copying wallpapers. " + ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine);
+ Logger.WriteLine("Error copying wallpapers", ex);
}
return true;
}
@@ -334,11 +335,11 @@ private static bool UninstallThemeWallpapers()
Helper.SafeDirectoryDeletion(path, false);
Logger.WriteLine("Deleted " + path);
}
- Logger.WriteLine("Deleted old wallpapers");
+ Logger.WriteLine("Deleted old wallpapers.");
}
catch (Exception ex)
{
- Logger.WriteLine("Error deleting old wallpapers" + ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine);
+ Logger.WriteLine("Error deleting old wallpapers", ex);
}
}
return true;
@@ -397,7 +398,7 @@ private static bool UninstallMsstyles()
{
Helper.SafeFileDeletion(Path.Combine(Variables.Windir, "Resources", "Themes", themefiles[i]));
}
- Logger.WriteLine("Deleted themes");
+ Logger.WriteLine("Deleted themes.");
}
catch (Exception ex)
{
@@ -411,7 +412,7 @@ private static bool UninstallMsstyles()
}
catch (Exception ex)
{
- Logger.WriteLine("Error deleting " + Path.Combine(Variables.Windir, "Resources", "Themes", "Rectified") + ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine);
+ Logger.WriteLine("Error deleting " + Path.Combine(Variables.Windir, "Resources", "Themes", "Rectified"), ex);
return false;
}
return true;
diff --git a/Rectify11Installer/Core/Helpers.cs b/Rectify11Installer/Core/Helpers.cs
index f366cdb3b..b599d7cde 100644
--- a/Rectify11Installer/Core/Helpers.cs
+++ b/Rectify11Installer/Core/Helpers.cs
@@ -388,6 +388,7 @@ public static string InstalledVersion
}
#endregion
}
+
public class NavigationHelper
{
public static event EventHandler OnNavigate;