TSforge/LibTSforge/Modifiers/RearmReset.cs
WitherOrNot 6d759899d8 Add partial support (zcid, rtmr, non-functional kms4k) for vista
Co-authored-by: InvoxiPlayGames <22731889+InvoxiPlayGames@users.noreply.github.com>
2025-03-01 02:06:21 -05:00

47 lines
1.3 KiB
C#

namespace LibTSforge.Modifiers
{
using System;
using System.Collections.Generic;
using System.Linq;
using LibTSforge.PhysicalStore;
using LibTSforge.SPP;
public static class RearmReset
{
public static void Reset(PSVersion version, bool production)
{
SPPUtils.KillSPP(version);
Logger.WriteLine("Writing TrustedStore data...");
using (IPhysicalStore store = SPPUtils.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.");
}
}
}
}