From 07f43e261381c8b9229fcf376e310d8f02ccb16d Mon Sep 17 00:00:00 2001 From: Lyssa Date: Wed, 2 Apr 2025 13:53:00 +0400 Subject: move detectcurrentkey to common --- LibTSforge/SPP/SPPUtils.cs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'LibTSforge/SPP') diff --git a/LibTSforge/SPP/SPPUtils.cs b/LibTSforge/SPP/SPPUtils.cs index 08dbe03..1046439 100644 --- a/LibTSforge/SPP/SPPUtils.cs +++ b/LibTSforge/SPP/SPPUtils.cs @@ -5,11 +5,9 @@ namespace LibTSforge.SPP using LibTSforge.TokenStore; using Microsoft.Win32; using System; - using System.Collections.Generic; using System.IO; using System.Linq; using System.ServiceProcess; - using System.Text; public static class SPPUtils { @@ -130,6 +128,24 @@ namespace LibTSforge.SPP SLApi.RefreshLicenseStatus(); } + public static bool DetectCurrentKey() + { + SLApi.RefreshLicenseStatus(); + + using (RegistryKey wpaKey = Registry.LocalMachine.OpenSubKey(@"SYSTEM\WPA")) + { + foreach (string subKey in wpaKey.GetSubKeyNames()) + { + if (subKey.StartsWith("8DEC0AF1")) + { + return subKey.Contains("P"); + } + } + } + + throw new FileNotFoundException("Failed to autodetect key type, specify physical store key with /prod or /test arguments."); + } + public static string GetPSPath(PSVersion version) { switch (version) -- cgit v1.2.3