From 0d59561bee4cf7db10d53a8aa58952ae65e856b5 Mon Sep 17 00:00:00 2001 From: Wither OrNot Date: Thu, 13 Feb 2025 09:49:35 -0500 Subject: Initial commit Co-authored-by: neko <109633131+nekoppai@users.noreply.github.com> Co-authored-by: Lyssa <75037904+thecatontheceiling@users.noreply.github.com> Co-authored-by: abbodi1406 <33669284+abbodi1406@users.noreply.github.com> --- LibTSforge/Modifiers/TamperedFlagsDelete.cs | 44 +++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 LibTSforge/Modifiers/TamperedFlagsDelete.cs (limited to 'LibTSforge/Modifiers/TamperedFlagsDelete.cs') diff --git a/LibTSforge/Modifiers/TamperedFlagsDelete.cs b/LibTSforge/Modifiers/TamperedFlagsDelete.cs new file mode 100644 index 0000000..8ffb370 --- /dev/null +++ b/LibTSforge/Modifiers/TamperedFlagsDelete.cs @@ -0,0 +1,44 @@ +namespace LibTSforge.Modifiers +{ + using System; + using System.Linq; + using LibTSforge.PhysicalStore; + + public static class TamperedFlagsDelete + { + public static void DeleteTamperFlags(PSVersion version, bool production) + { + Utils.KillSPP(); + + Logger.WriteLine("Writing TrustedStore data..."); + + using (IPhysicalStore store = Utils.GetStore(version, production)) + { + if (version != PSVersion.Win7) + { + string recreatedFlag = "__##USERSEP-RESERVED##__$$RECREATED-FLAG$$"; + string recoveredFlag = "__##USERSEP-RESERVED##__$$RECOVERED-FLAG$$"; + + DeleteFlag(store, recreatedFlag); + DeleteFlag(store, recoveredFlag); + } + else + { + SetFlag(store, 0xA0001); + } + + Logger.WriteLine("Successfully cleared the tamper state."); + } + } + + private static void DeleteFlag(IPhysicalStore store, string flag) + { + store.FindBlocks(flag).ToList().ForEach(block => store.DeleteBlock(block.KeyAsStr, block.ValueAsStr)); + } + + private static void SetFlag(IPhysicalStore store, uint flag) + { + store.FindBlocks(flag).ToList().ForEach(block => store.SetBlock(block.KeyAsStr, block.ValueAsInt, new byte[8])); + } + } +} -- cgit v1.2.3