summaryrefslogtreecommitdiff
path: root/LibTSforge/Modifiers/RearmReset.cs
diff options
context:
space:
mode:
authorWither OrNot2025-02-13 14:49:35 +0000
committerWither OrNot2025-02-13 14:49:37 +0000
commit0d59561bee4cf7db10d53a8aa58952ae65e856b5 (patch)
treeb2ddb66c883dd2ef75426de4c080f3121f0a8658 /LibTSforge/Modifiers/RearmReset.cs
downloadTSforge-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/RearmReset.cs')
-rw-r--r--LibTSforge/Modifiers/RearmReset.cs45
1 files changed, 45 insertions, 0 deletions
diff --git a/LibTSforge/Modifiers/RearmReset.cs b/LibTSforge/Modifiers/RearmReset.cs
new file mode 100644
index 0000000..be2b174
--- /dev/null
+++ b/LibTSforge/Modifiers/RearmReset.cs
@@ -0,0 +1,45 @@
+namespace LibTSforge.Modifiers
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using LibTSforge.PhysicalStore;
+
+ public static class RearmReset
+ {
+ public static void Reset(PSVersion version, bool production)
+ {
+ Utils.KillSPP();
+
+ Logger.WriteLine("Writing TrustedStore data...");
+
+ using (IPhysicalStore store = Utils.GetStore(version, production))
+ {
+ List<PSBlock> blocks;
+
+ if (version == PSVersion.Win7)
+ {
+ blocks = store.FindBlocks(0xA0000).ToList();
+ }
+ else
+ {
+ blocks = store.FindBlocks("__##USERSEP-RESERVED##__$$REARM-COUNT$$").ToList();
+ }
+
+ foreach (PSBlock block in blocks)
+ {
+ if (version == PSVersion.Win7)
+ {
+ store.SetBlock(block.KeyAsStr, block.ValueAsInt, new byte[8]);
+ }
+ else
+ {
+ store.SetBlock(block.KeyAsStr, block.ValueAsStr, new byte[8]);
+ }
+ }
+
+ Logger.WriteLine("Successfully reset all rearm counters.");
+ }
+ }
+ }
+}