Archived
1
1

First release build.

This commit is contained in:
Mona Lassa
2025-05-22 01:31:03 +02:00
parent ec55169d57
commit f90695dfda
30 changed files with 499 additions and 1389 deletions

View File

@@ -0,0 +1,36 @@
using System;
using MetroUnlocker.LibTSForge.SPP;
namespace MetroUnlocker.LibTSForge.Modifiers
{
public static class ProductKeyInstaller
{
public static void InstallGeneratedProductKey(PhysicalStoreVersion version, bool production, Guid actId)
{
ProductKeyConfig keyConfig = new ProductKeyConfig();
keyConfig.LoadConfig(actId);
ProductConfig config;
keyConfig.Products.TryGetValue(actId, out config);
if (config == null) throw new ArgumentException("Activation ID " + actId + " not found in ProductKeyConfig.");
ProductKey pkey = config.GetRandomKey();
Guid instPkeyId = SLApi.GetInstalledProductKeyId(actId);
if (instPkeyId != Guid.Empty) SLApi.UninstallProductKey(instPkeyId);
if (pkey.Algorithm != PKeyAlgorithm.PKEY2009)
throw new Exception("The key algorithm isn't 2009");
uint status = SLApi.InstallProductKey(pkey);
if (status != 0)
throw new ApplicationException("Failed to install generated product key.");
return;
}
}
}