From 0c8b1efaa9005de1d101ebab5e66117edfaec3b2 Mon Sep 17 00:00:00 2001 From: Lyssa Date: Mon, 7 Apr 2025 19:19:24 +0400 Subject: Minor fixups --- LibTSforge/Activators/AVMA4K.cs | 22 +++++++++------------- LibTSforge/Activators/KMS4K.cs | 12 ++++++------ LibTSforge/Activators/ZeroCID.cs | 13 ++++++------- 3 files changed, 21 insertions(+), 26 deletions(-) (limited to 'LibTSforge/Activators') diff --git a/LibTSforge/Activators/AVMA4K.cs b/LibTSforge/Activators/AVMA4K.cs index 2127652..51b546a 100644 --- a/LibTSforge/Activators/AVMA4K.cs +++ b/LibTSforge/Activators/AVMA4K.cs @@ -1,8 +1,8 @@ namespace LibTSforge.Activators { using System; - using LibTSforge.PhysicalStore; - using LibTSforge.SPP; + using PhysicalStore; + using SPP; public static class AVMA4k { @@ -42,24 +42,20 @@ namespace LibTSforge.Activators { string key = string.Format("SPPSVC\\{0}\\{1}", appId, actId); - ulong unknown = 0; - ulong time1; - ulong crcBindTime = (ulong)DateTime.UtcNow.ToFileTime(); - ulong timerTime; - - ulong expiry = Constants.TimerMax; - long creationTime = BitConverter.ToInt64(store.GetBlock("__##USERSEP##\\$$_RESERVED_$$\\NAMESPACE__", "__##USERSEP-RESERVED##__$$GLOBAL-CREATION-TIME$$").Data, 0); long tickCount = BitConverter.ToInt64(store.GetBlock("__##USERSEP##\\$$_RESERVED_$$\\NAMESPACE__", "__##USERSEP-RESERVED##__$$GLOBAL-TICKCOUNT-UPTIME$$").Data, 0); long deltaTime = BitConverter.ToInt64(store.GetBlock(key, "__##USERSEP-RESERVED##__$$UP-TIME-DELTA$$").Data, 0); - time1 = (ulong)(creationTime + tickCount + deltaTime); - timerTime = crcBindTime / 10000; + const ulong unknown = 0; + ulong time1 = (ulong)(creationTime + tickCount + deltaTime); + ulong crcBindTime = (ulong)DateTime.UtcNow.ToFileTime(); + ulong timerTime = crcBindTime / 10000; + ulong expiry = Constants.TimerMax; expiry /= 10000; VariableBag avmaBinding = new VariableBag(version); - avmaBinding.Blocks.AddRange(new CRCBlockModern[] + avmaBinding.Blocks.AddRange(new[] { new CRCBlockModern { @@ -97,7 +93,7 @@ namespace LibTSforge.Activators store.DeleteBlock(key, storeVal); store.DeleteBlock(key, timerVal); - store.AddBlocks(new PSBlock[] + store.AddBlocks(new[] { new PSBlock { diff --git a/LibTSforge/Activators/KMS4K.cs b/LibTSforge/Activators/KMS4K.cs index a68e263..6287c39 100644 --- a/LibTSforge/Activators/KMS4K.cs +++ b/LibTSforge/Activators/KMS4K.cs @@ -2,8 +2,8 @@ namespace LibTSforge.Activators { using System; using System.IO; - using LibTSforge.PhysicalStore; - using LibTSforge.SPP; + using PhysicalStore; + using SPP; public class KMS4k { @@ -78,7 +78,7 @@ namespace LibTSforge.Activators writer.Write(Constants.UniversalHWIDBlock); byte[] kmsData = writer.GetBytes(); - store.AddBlocks(new PSBlock[] + store.AddBlocks(new[] { new PSBlock { @@ -121,7 +121,7 @@ namespace LibTSforge.Activators VariableBag kmsBinding = new VariableBag(version); - kmsBinding.Blocks.AddRange(new CRCBlockModern[] + kmsBinding.Blocks.AddRange(new[] { new CRCBlockModern { @@ -145,7 +145,7 @@ namespace LibTSforge.Activators if (version == PSVersion.WinModern) { - kmsBinding.Blocks.AddRange(new CRCBlockModern[] + kmsBinding.Blocks.AddRange(new[] { new CRCBlockModern { @@ -178,7 +178,7 @@ namespace LibTSforge.Activators store.DeleteBlock(key, storeVal); store.DeleteBlock(key, timerVal); - store.AddBlocks(new PSBlock[] + store.AddBlocks(new[] { new PSBlock { diff --git a/LibTSforge/Activators/ZeroCID.cs b/LibTSforge/Activators/ZeroCID.cs index 1675173..147dceb 100644 --- a/LibTSforge/Activators/ZeroCID.cs +++ b/LibTSforge/Activators/ZeroCID.cs @@ -3,14 +3,13 @@ namespace LibTSforge.Activators using System; using System.IO; using System.Linq; - using System.Text.RegularExpressions; - using LibTSforge.Crypto; - using LibTSforge.PhysicalStore; - using LibTSforge.SPP; + using Crypto; + using PhysicalStore; + using SPP; public static class ZeroCID { - public static void Deposit(Guid actId, string instId) + private static void Deposit(Guid actId, string instId) { uint status = SLApi.DepositConfirmationID(actId, instId, Constants.ZeroCID); Logger.WriteLine(string.Format("Depositing fake CID status {0:X}", status)); @@ -98,7 +97,7 @@ namespace LibTSforge.Activators string uniqueId = Utils.DecodeString(pkeyData.Skip(0x120).Take(0x80).ToArray()); string extPid = Utils.DecodeString(pkeyData.Skip(0x1A0).Take(0x80).ToArray()); - uint group = 0; + uint group; uint.TryParse(extPid.Split('-')[1], out group); if (group == 0) @@ -154,7 +153,7 @@ namespace LibTSforge.Activators store.DeleteBlock(key, hwidBlockName); store.DeleteBlock(key, pkeyInfoName); - store.AddBlocks(new PSBlock[] { + store.AddBlocks(new[] { new PSBlock { Type = BlockType.NAMED, -- cgit v1.2.3 From 91e85088480b4734a9d7302cc980be761f68161b Mon Sep 17 00:00:00 2001 From: Wither OrNot Date: Mon, 7 Apr 2025 18:12:53 -0400 Subject: stylistic fixes --- LibTSforge/Activators/AVMA4K.cs | 3 +-- LibTSforge/Modifiers/SetIIDParams.cs | 1 + LibTSforge/PhysicalStore/Common.cs | 4 ++-- LibTSforge/SPP/ProductKey.cs | 27 +++++++++++---------------- LibTSforge/SPP/SPPUtils.cs | 2 +- 5 files changed, 16 insertions(+), 21 deletions(-) (limited to 'LibTSforge/Activators') diff --git a/LibTSforge/Activators/AVMA4K.cs b/LibTSforge/Activators/AVMA4K.cs index 51b546a..236b727 100644 --- a/LibTSforge/Activators/AVMA4K.cs +++ b/LibTSforge/Activators/AVMA4K.cs @@ -50,8 +50,7 @@ namespace LibTSforge.Activators ulong time1 = (ulong)(creationTime + tickCount + deltaTime); ulong crcBindTime = (ulong)DateTime.UtcNow.ToFileTime(); ulong timerTime = crcBindTime / 10000; - ulong expiry = Constants.TimerMax; - expiry /= 10000; + ulong expiry = Constants.TimerMax / 10000; VariableBag avmaBinding = new VariableBag(version); diff --git a/LibTSforge/Modifiers/SetIIDParams.cs b/LibTSforge/Modifiers/SetIIDParams.cs index 2f34a7d..3d54b9d 100644 --- a/LibTSforge/Modifiers/SetIIDParams.cs +++ b/LibTSforge/Modifiers/SetIIDParams.cs @@ -4,6 +4,7 @@ namespace LibTSforge.Modifiers using SPP; using System.IO; using System; + public static class SetIIDParams { public static void SetParams(PSVersion version, bool production, Guid actId, PKeyAlgorithm algorithm, int group, int serial, ulong security) diff --git a/LibTSforge/PhysicalStore/Common.cs b/LibTSforge/PhysicalStore/Common.cs index aef77f8..d0ad4fe 100644 --- a/LibTSforge/PhysicalStore/Common.cs +++ b/LibTSforge/PhysicalStore/Common.cs @@ -4,9 +4,9 @@ namespace LibTSforge.PhysicalStore public enum BlockType : uint { - NONE, // unused + NONE, NAMED, - ATTRIBUTE, //unused + ATTRIBUTE, TIMER } diff --git a/LibTSforge/SPP/ProductKey.cs b/LibTSforge/SPP/ProductKey.cs index f4cf15a..03eb729 100644 --- a/LibTSforge/SPP/ProductKey.cs +++ b/LibTSforge/SPP/ProductKey.cs @@ -18,16 +18,16 @@ namespace LibTSforge.SPP public ulong Security; public bool Upgrade; public PKeyAlgorithm Algorithm; - private readonly string EulaType; - private readonly string PartNumber; + public readonly string EulaType; + public readonly string PartNumber; public readonly string Edition; public readonly string Channel; - private readonly Guid ActivationId; + public readonly Guid ActivationId; private string mpc; private string pid2; - private byte[] KeyBytes + public byte[] KeyBytes { get { return BitConverter.GetBytes(klow).Concat(BitConverter.GetBytes(khigh)).ToArray(); } } @@ -91,16 +91,6 @@ namespace LibTSforge.SPP return new Guid(CryptoUtils.SHA256Hash(pkb.Serialize()).Take(16).ToArray()); } - private string GetDefaultMPC() - { - int build = Environment.OSVersion.Version.Build; - string defaultMPC = build >= 10240 ? "03612" : - build >= 9600 ? "06401" : - build >= 9200 ? "05426" : - "55041"; - return defaultMPC; - } - public string GetMPC() { if (mpc != null) @@ -108,7 +98,12 @@ namespace LibTSforge.SPP return mpc; } - mpc = GetDefaultMPC(); + int build = Environment.OSVersion.Version.Build; + + mpc = build >= 10240 ? "03612" : + build >= 9600 ? "06401" : + build >= 9200 ? "05426" : + "55041"; // setup.cfg doesn't exist in Windows 8+ string setupcfg = string.Format(@"{0}\oobe\{1}", Environment.SystemDirectory, "setup.cfg"); @@ -205,7 +200,7 @@ namespace LibTSforge.SPP return writer.GetBytes(); } - private string GetExtendedPid() + public string GetExtendedPid() { string mpc = GetMPC(); int serialHigh = Serial / 1000000; diff --git a/LibTSforge/SPP/SPPUtils.cs b/LibTSforge/SPP/SPPUtils.cs index 062e5ca..fc4967b 100644 --- a/LibTSforge/SPP/SPPUtils.cs +++ b/LibTSforge/SPP/SPPUtils.cs @@ -148,7 +148,7 @@ namespace LibTSforge.SPP throw new FileNotFoundException("Failed to autodetect key type, specify physical store key with /prod or /test arguments."); } - private static string GetPSPath(PSVersion version) + public static string GetPSPath(PSVersion version) { switch (version) { -- cgit v1.2.3