diff options
| author | Wither OrNot | 2025-02-13 14:49:35 +0000 |
|---|---|---|
| committer | Wither OrNot | 2025-02-13 14:49:37 +0000 |
| commit | 0d59561bee4cf7db10d53a8aa58952ae65e856b5 (patch) | |
| tree | b2ddb66c883dd2ef75426de4c080f3121f0a8658 /LibTSforge/Modifiers/TamperedFlagsDelete.cs | |
| download | TSforge-0d59561bee4cf7db10d53a8aa58952ae65e856b5.zip | |
Initial commit1.0.0
Co-authored-by: neko <[email protected]>
Co-authored-by: Lyssa <[email protected]>
Co-authored-by: abbodi1406 <[email protected]>
Diffstat (limited to 'LibTSforge/Modifiers/TamperedFlagsDelete.cs')
| -rw-r--r-- | LibTSforge/Modifiers/TamperedFlagsDelete.cs | 44 |
1 files changed, 44 insertions, 0 deletions
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])); + } + } +} |
