summaryrefslogtreecommitdiff
path: root/LibTSforge/SPP/ProductKey.cs
diff options
context:
space:
mode:
Diffstat (limited to 'LibTSforge/SPP/ProductKey.cs')
-rw-r--r--LibTSforge/SPP/ProductKey.cs37
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);
}