diff options
| author | Wither OrNot | 2025-04-07 23:23:19 +0000 |
|---|---|---|
| committer | Wither OrNot | 2025-04-07 23:23:19 +0000 |
| commit | b7868ff296016917c38657474117d5ca820b2312 (patch) | |
| tree | 5c3dd53fe258c322c14dc2d69b8864a98de91a4a /LibTSforge/SPP/ProductKey.cs | |
| parent | cb5c97d443982e547a8dd5a76032de8fa6859b61 (diff) | |
| parent | 3a3ac06ca3715127475c7a2c7b3f0782e1690dfb (diff) | |
| download | TSforge-b7868ff296016917c38657474117d5ca820b2312.zip | |
Merge branch 'longhorn' of https://github.com/massgravel/TSforge into longhorn1.1.0-longhorn+1
Diffstat (limited to 'LibTSforge/SPP/ProductKey.cs')
| -rw-r--r-- | LibTSforge/SPP/ProductKey.cs | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/LibTSforge/SPP/ProductKey.cs b/LibTSforge/SPP/ProductKey.cs index ae48893..03eb729 100644 --- a/LibTSforge/SPP/ProductKey.cs +++ b/LibTSforge/SPP/ProductKey.cs @@ -3,8 +3,8 @@ namespace LibTSforge.SPP using System; using System.IO; using System.Linq; - using LibTSforge.Crypto; - using LibTSforge.PhysicalStore; + using Crypto; + using PhysicalStore; public class ProductKey { @@ -18,11 +18,11 @@ namespace LibTSforge.SPP public ulong Security; public bool Upgrade; public PKeyAlgorithm Algorithm; - public string EulaType; - public string PartNumber; - public string Edition; - public string Channel; - public Guid ActivationId; + public readonly string EulaType; + public readonly string PartNumber; + public readonly string Edition; + public readonly string Channel; + public readonly Guid ActivationId; private string mpc; private string pid2; @@ -66,7 +66,7 @@ namespace LibTSforge.SPP public Guid GetPkeyId() { VariableBag pkb = new VariableBag(PSVersion.WinModern); - pkb.Blocks.AddRange(new CRCBlockModern[] + pkb.Blocks.AddRange(new[] { new CRCBlockModern { @@ -91,16 +91,6 @@ namespace LibTSforge.SPP return new Guid(CryptoUtils.SHA256Hash(pkb.Serialize()).Take(16).ToArray()); } - public 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,10 +98,15 @@ 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"); + string setupcfg = string.Format(@"{0}\oobe\{1}", Environment.SystemDirectory, "setup.cfg"); if (!File.Exists(setupcfg) || Edition.Contains(";")) { @@ -249,7 +244,7 @@ namespace LibTSforge.SPP { if (version == PSVersion.Win7) { - ulong shortauth = ((ulong)Group << 41) | ((ulong)Security << 31) | ((ulong)Serial << 1) | (Upgrade ? (ulong)1 : 0); + ulong shortauth = ((ulong)Group << 41) | (Security << 31) | ((ulong)Serial << 1) | (Upgrade ? (ulong)1 : 0); return BitConverter.GetBytes(shortauth); } |
