summaryrefslogtreecommitdiff
path: root/LibTSforge
diff options
context:
space:
mode:
authorWither OrNot2025-04-04 07:43:27 +0000
committerWither OrNot2025-04-04 07:43:27 +0000
commit28acb8012f3471262aa999071fbadde5ebe7edf9 (patch)
tree41e65167a7c8f566c4481c550fc6226298e837fa /LibTSforge
parente86f43a2864585f8430e01849a04a51bc46c1908 (diff)
downloadTSforge-28acb8012f3471262aa999071fbadde5ebe7edf9.zip
add /siid option
Diffstat (limited to 'LibTSforge')
-rw-r--r--LibTSforge/Modifiers/SetIIDParams.cs69
-rw-r--r--LibTSforge/SPP/ProductKey.cs6
2 files changed, 71 insertions, 4 deletions
diff --git a/LibTSforge/Modifiers/SetIIDParams.cs b/LibTSforge/Modifiers/SetIIDParams.cs
new file mode 100644
index 0000000..d7fa2c5
--- /dev/null
+++ b/LibTSforge/Modifiers/SetIIDParams.cs
@@ -0,0 +1,69 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using LibTSforge.PhysicalStore;
+using LibTSforge.SPP;
+
+namespace LibTSforge.Modifiers
+{
+ public static class SetIIDParams
+ {
+ public static void SetParams(PSVersion version, bool production, Guid actId, PKeyAlgorithm algorithm, int group, int serial, ulong security)
+ {
+ if (version == PSVersion.Vista) throw new NotSupportedException("This feature is not supported on Windows Vista/Server 2008.");
+
+ 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);
+ }
+
+ Guid pkeyId = SLApi.GetInstalledPkeyID(actId);
+
+ SPPUtils.KillSPP(version);
+
+ Logger.WriteLine("Writing TrustedStore data...");
+
+ using (IPhysicalStore store = SPPUtils.GetStore(version, production))
+ {
+ string key = string.Format("SPPSVC\\{0}\\{1}", appId, actId);
+ PSBlock keyBlock = store.GetBlock(key, pkeyId.ToString());
+
+ if (keyBlock == null)
+ {
+ throw new InvalidDataException("Failed to get product key data for activation ID " + actId + ".");
+ }
+
+ VariableBag pkb = new VariableBag(keyBlock.Data, version);
+
+ ProductKey pkey = new ProductKey
+ {
+ Group = group,
+ Serial = serial,
+ Security = security,
+ Algorithm = algorithm,
+ Upgrade = false
+ };
+
+ string blockName = version == PSVersion.Win7 ? "SppPkeyShortAuthenticator" : "SppPkeyPhoneActivationData";
+ pkb.SetBlock(blockName, pkey.GetPhoneData(version));
+ store.SetBlock(key, pkeyId.ToString(), pkb.Serialize());
+ }
+
+ Logger.WriteLine("Successfully set IID parameters.");
+ }
+ }
+}
diff --git a/LibTSforge/SPP/ProductKey.cs b/LibTSforge/SPP/ProductKey.cs
index ce454d8..ae48893 100644
--- a/LibTSforge/SPP/ProductKey.cs
+++ b/LibTSforge/SPP/ProductKey.cs
@@ -249,10 +249,8 @@ namespace LibTSforge.SPP
{
if (version == PSVersion.Win7)
{
- Random rnd = new Random(Group * 1000000000 + Serial);
- byte[] data = new byte[8];
- rnd.NextBytes(data);
- return data;
+ ulong shortauth = ((ulong)Group << 41) | ((ulong)Security << 31) | ((ulong)Serial << 1) | (Upgrade ? (ulong)1 : 0);
+ return BitConverter.GetBytes(shortauth);
}
int serialHigh = Serial / 1000000;