summaryrefslogtreecommitdiff
path: root/LibTSforge/Modifiers/GenPKeyInstall.cs
diff options
context:
space:
mode:
Diffstat (limited to 'LibTSforge/Modifiers/GenPKeyInstall.cs')
-rw-r--r--LibTSforge/Modifiers/GenPKeyInstall.cs41
1 files changed, 21 insertions, 20 deletions
diff --git a/LibTSforge/Modifiers/GenPKeyInstall.cs b/LibTSforge/Modifiers/GenPKeyInstall.cs
index 28d0027..a747952 100644
--- a/LibTSforge/Modifiers/GenPKeyInstall.cs
+++ b/LibTSforge/Modifiers/GenPKeyInstall.cs
@@ -3,9 +3,9 @@ namespace LibTSforge.Modifiers
using System;
using System.IO;
using Microsoft.Win32;
- using LibTSforge.PhysicalStore;
- using LibTSforge.SPP;
- using LibTSforge.TokenStore;
+ using PhysicalStore;
+ using SPP;
+ using TokenStore;
public static class GenPKeyInstall
{
@@ -31,6 +31,7 @@ namespace LibTSforge.Modifiers
public static void InstallGenPKey(PSVersion version, bool production, Guid actId)
{
+ if (version == PSVersion.Vista) throw new NotSupportedException("This feature is not supported on Windows Vista/Server 2008.");
if (actId == Guid.Empty) throw new ArgumentException("Activation ID must be specified for generated product key install.");
PKeyConfig pkc = new PKeyConfig();
@@ -57,7 +58,7 @@ namespace LibTSforge.Modifiers
if (pkey.Algorithm == PKeyAlgorithm.PKEY2009)
{
uint status = SLApi.InstallProductKey(pkey);
- Logger.WriteLine(string.Format("Installing generated product key {0} status {1:X}", pkey.ToString(), status));
+ Logger.WriteLine(string.Format("Installing generated product key {0} status {1:X}", pkey, status));
if ((int)status < 0)
{
@@ -72,57 +73,57 @@ namespace LibTSforge.Modifiers
if (pkey.Channel == "Volume:GVLK" && version == PSVersion.Win7) throw new NotSupportedException("Fake GVLK generation is not supported on Windows 7.");
- VariableBag pkb = new VariableBag();
- pkb.Blocks.AddRange(new CRCBlock[]
+ VariableBag pkb = new VariableBag(version);
+ pkb.Blocks.AddRange(new[]
{
- new CRCBlock
+ new CRCBlockModern
{
DataType = CRCBlockType.STRING,
KeyAsStr = "SppPkeyBindingProductKey",
ValueAsStr = pkey.ToString()
},
- new CRCBlock
+ new CRCBlockModern
{
DataType = CRCBlockType.STRING,
KeyAsStr = "SppPkeyBindingMPC",
ValueAsStr = pkey.GetMPC()
},
- new CRCBlock {
+ new CRCBlockModern {
DataType = CRCBlockType.BINARY,
KeyAsStr = "SppPkeyBindingPid2",
ValueAsStr = pkey.GetPid2()
},
- new CRCBlock
+ new CRCBlockModern
{
DataType = CRCBlockType.BINARY,
KeyAsStr = "SppPkeyBindingPid3",
Value = pkey.GetPid3()
},
- new CRCBlock
+ new CRCBlockModern
{
DataType = CRCBlockType.BINARY,
KeyAsStr = "SppPkeyBindingPid4",
Value = pkey.GetPid4()
},
- new CRCBlock
+ new CRCBlockModern
{
DataType = CRCBlockType.STRING,
KeyAsStr = "SppPkeyChannelId",
ValueAsStr = pkey.Channel
},
- new CRCBlock
+ new CRCBlockModern
{
DataType = CRCBlockType.STRING,
KeyAsStr = "SppPkeyBindingEditionId",
ValueAsStr = pkey.Edition
},
- new CRCBlock
+ new CRCBlockModern
{
DataType = CRCBlockType.BINARY,
KeyAsStr = (version == PSVersion.Win7) ? "SppPkeyShortAuthenticator" : "SppPkeyPhoneActivationData",
Value = pkey.GetPhoneData(version)
},
- new CRCBlock
+ new CRCBlockModern
{
DataType = CRCBlockType.BINARY,
KeyAsStr = "SppPkeyBindingMiscData",
@@ -140,11 +141,11 @@ namespace LibTSforge.Modifiers
SLApi.UninstallAllProductKeys(appId);
}
- Utils.KillSPP();
+ SPPUtils.KillSPP(version);
- using (IPhysicalStore ps = Utils.GetStore(version, production))
+ using (IPhysicalStore ps = SPPUtils.GetStore(version, production))
{
- using (ITokenStore tks = Utils.GetTokenStore(version))
+ using (ITokenStore tks = SPPUtils.GetTokenStore(version))
{
Logger.WriteLine("Writing to physical store and token store...");
@@ -168,7 +169,7 @@ namespace LibTSforge.Modifiers
uriMap.Data[pkeyId] = pkey.GetAlgoUri();
tks.SetEntry(uriMapName, "xml", uriMap.Serialize());
- string skuMetaName = actId.ToString() + metSuffix;
+ string skuMetaName = actId + metSuffix;
TokenMeta skuMeta = tks.GetMetaEntry(skuMetaName);
foreach (string k in skuMeta.Data.Keys)
@@ -195,7 +196,7 @@ namespace LibTSforge.Modifiers
Data = pkb.Serialize()
});
- string cachePath = Utils.GetTokensPath(version).Replace("tokens.dat", @"cache\cache.dat");
+ string cachePath = SPPUtils.GetTokensPath(version).Replace("tokens.dat", @"cache\cache.dat");
if (File.Exists(cachePath)) File.Delete(cachePath);
}
}