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/UniqueIdDelete.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/UniqueIdDelete.cs')
| -rw-r--r-- | LibTSforge/Modifiers/UniqueIdDelete.cs | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/LibTSforge/Modifiers/UniqueIdDelete.cs b/LibTSforge/Modifiers/UniqueIdDelete.cs new file mode 100644 index 0000000..b83d328 --- /dev/null +++ b/LibTSforge/Modifiers/UniqueIdDelete.cs @@ -0,0 +1,55 @@ +namespace LibTSforge.Modifiers +{ + using System; + using LibTSforge.PhysicalStore; + using LibTSforge.SPP; + + public static class UniqueIdDelete + { + public static void DeleteUniqueId(PSVersion version, bool production, Guid actId) + { + Guid appId; + + if (actId == Guid.Empty) + { + appId = SLApi.WINDOWS_APP_ID; + actId = SLApi.GetDefaultActivationID(appId, true); + + if (actId == Guid.Empty) + { + throw new Exception("No applicable activation IDs found."); + } + } + else + { + appId = SLApi.GetAppId(actId); + } + + string instId = SLApi.GetInstallationID(actId); + Guid pkeyId = SLApi.GetInstalledPkeyID(actId); + + Utils.KillSPP(); + + Logger.WriteLine("Writing TrustedStore data..."); + + using (IPhysicalStore store = Utils.GetStore(version, production)) + { + string key = string.Format("SPPSVC\\{0}\\{1}", appId, actId); + PSBlock keyBlock = store.GetBlock(key, pkeyId.ToString()); + + if (keyBlock == null) + { + throw new Exception("No product key found."); + } + + VariableBag pkb = new VariableBag(keyBlock.Data); + + pkb.DeleteBlock("SppPkeyUniqueIdToken"); + + store.SetBlock(key, pkeyId.ToString(), pkb.Serialize()); + } + + Logger.WriteLine("Successfully removed Unique ID for product key ID " + pkeyId); + } + } +} |
