diff --git a/SebWindowsConfig/SEBSettings.cs b/SebWindowsConfig/SEBSettings.cs index b9c4257d..62151e30 100644 --- a/SebWindowsConfig/SEBSettings.cs +++ b/SebWindowsConfig/SEBSettings.cs @@ -445,6 +445,7 @@ namespace SebWindowsConfig // from/to a human-readable .xml and an encrypted.seb file format. public static DictObj settingsDefault = new DictObj(); public static DictObj settingsCurrent = new DictObj(); + public static DictObj settingsCurrentOriginal = new DictObj(); public static int permittedProcessIndex; public static ListObj permittedProcessList = new ListObj(); diff --git a/SebWindowsConfig/Utilities/SEBConfigFileManager.cs b/SebWindowsConfig/Utilities/SEBConfigFileManager.cs index 7463fd74..677fb834 100644 --- a/SebWindowsConfig/Utilities/SEBConfigFileManager.cs +++ b/SebWindowsConfig/Utilities/SEBConfigFileManager.cs @@ -257,11 +257,15 @@ namespace SebWindowsConfig.Utilities // Get preferences dictionary from decrypted data DictObj sebPreferencesDict = GetPreferencesDictFromConfigData(sebData, forEditing); + DictObj sebPreferencesDictOriginal = GetPreferencesDictFromConfigData(sebData, false); // If we didn't get a preferences dict back, we abort reading settings if (sebPreferencesDict == null) return null; // We need to set the right value for the key sebConfigPurpose to know later where to store the new settings sebPreferencesDict[SEBSettings.KeySebConfigPurpose] = (int)SEBSettings.sebConfigPurposes.sebConfigPurposeStartingExam; + sebPreferencesDictOriginal[SEBSettings.KeySebConfigPurpose] = (int)SEBSettings.sebConfigPurposes.sebConfigPurposeStartingExam; + + SEBSettings.settingsCurrentOriginal = sebPreferencesDictOriginal; // Reading preferences was successful! return sebPreferencesDict; @@ -289,6 +293,7 @@ namespace SebWindowsConfig.Utilities // We use always uppercase letters in the base16 hashed admin password used for encrypting hashedAdminPassword = hashedAdminPassword.ToUpper(); DictObj sebPreferencesDict = null; + DictObj sebPreferencesDictOriginal = null; byte[] decryptedSebData = SEBProtectionController.DecryptDataWithPassword(sebData, hashedAdminPassword); if (decryptedSebData == null) { @@ -344,6 +349,7 @@ namespace SebWindowsConfig.Utilities try { sebPreferencesDict = (DictObj)Plist.readPlist(decryptedSebData); + sebPreferencesDictOriginal = (DictObj)Plist.readPlist(decryptedSebData); } catch (Exception readPlistException) { @@ -419,6 +425,9 @@ namespace SebWindowsConfig.Utilities // We need to set the right value for the key sebConfigPurpose to know later where to store the new settings sebPreferencesDict[SEBSettings.KeySebConfigPurpose] = (int)SEBSettings.sebConfigPurposes.sebConfigPurposeConfiguringClient; + sebPreferencesDictOriginal[SEBSettings.KeySebConfigPurpose] = (int)SEBSettings.sebConfigPurposes.sebConfigPurposeConfiguringClient; + + SEBSettings.settingsCurrentOriginal = sebPreferencesDictOriginal; // Reading preferences was successful! return sebPreferencesDict; @@ -653,6 +662,8 @@ namespace SebWindowsConfig.Utilities // Get current settings dictionary and clean it from empty arrays and dictionaries //DictObj cleanedCurrentSettings = SEBSettings.CleanSettingsDictionary(); + SEBSettings.settingsCurrentOriginal = SEBSettings.settingsCurrent; + // Serialize preferences dictionary to an XML string string sebXML = Plist.writeXml(SEBSettings.settingsCurrent); string cleanedSebXML = sebXML.Replace("", ""); diff --git a/SebWindowsConfig/Utilities/SEBProtectionController.cs b/SebWindowsConfig/Utilities/SEBProtectionController.cs index 4f60f7ea..803b18dc 100644 --- a/SebWindowsConfig/Utilities/SEBProtectionController.cs +++ b/SebWindowsConfig/Utilities/SEBProtectionController.cs @@ -599,7 +599,7 @@ namespace SebWindowsConfig.Utilities using (var stream = new MemoryStream()) using (var writer = new StreamWriter(stream)) { - Serialize(SEBSettings.settingsCurrent, writer); + Serialize(SEBSettings.settingsCurrentOriginal, writer); writer.Flush(); stream.Seek(0, SeekOrigin.Begin);