From 6d759899d85939c95f2b97c8e041d7b4865208f9 Mon Sep 17 00:00:00 2001 From: WitherOrNot Date: Sat, 1 Mar 2025 02:01:39 -0500 Subject: Add partial support (zcid, rtmr, non-functional kms4k) for vista Co-authored-by: InvoxiPlayGames <22731889+InvoxiPlayGames@users.noreply.github.com> --- LibTSforge/Common.cs | 195 +-------------------------------------------------- 1 file changed, 2 insertions(+), 193 deletions(-) (limited to 'LibTSforge/Common.cs') diff --git a/LibTSforge/Common.cs b/LibTSforge/Common.cs index d414ab5..6973f6f 100644 --- a/LibTSforge/Common.cs +++ b/LibTSforge/Common.cs @@ -226,157 +226,6 @@ namespace LibTSforge return ~crc; } - public static void KillSPP() - { - ServiceController sc; - - try - { - sc = new ServiceController("sppsvc"); - - if (sc.Status == ServiceControllerStatus.Stopped) - return; - } - catch (InvalidOperationException ex) - { - throw new InvalidOperationException("Unable to access sppsvc: " + ex.Message); - } - - Logger.WriteLine("Stopping sppsvc..."); - - bool stopped = false; - - for (int i = 0; stopped == false && i < 60; i++) - { - try - { - if (sc.Status != ServiceControllerStatus.StopPending) - sc.Stop(); - - sc.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromMilliseconds(500)); - } - catch (System.ServiceProcess.TimeoutException) - { - continue; - } - catch (InvalidOperationException) - { - System.Threading.Thread.Sleep(500); - continue; - } - - stopped = true; - } - - if (!stopped) - throw new System.TimeoutException("Failed to stop sppsvc"); - - Logger.WriteLine("sppsvc stopped successfully."); - } - - public static string GetPSPath(PSVersion version) - { - switch (version) - { - case PSVersion.Win7: - return Directory.GetFiles( - Environment.GetFolderPath(Environment.SpecialFolder.System), - "7B296FB0-376B-497e-B012-9C450E1B7327-*.C7483456-A289-439d-8115-601632D005A0") - .FirstOrDefault() ?? ""; - case PSVersion.Win8Early: - case PSVersion.WinBlue: - case PSVersion.Win8: - case PSVersion.WinModern: - return Path.Combine( - Environment.ExpandEnvironmentVariables( - (string)Registry.GetValue( - @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform", - "TokenStore", - string.Empty - ) - ), - "data.dat" - ); - default: - return ""; - } - } - - public static string GetTokensPath(PSVersion version) - { - switch (version) - { - case PSVersion.Win7: - return Path.Combine( - Environment.ExpandEnvironmentVariables("%WINDIR%"), - @"ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform\tokens.dat" - ); - case PSVersion.Win8Early: - case PSVersion.WinBlue: - case PSVersion.Win8: - case PSVersion.WinModern: - return Path.Combine( - Environment.ExpandEnvironmentVariables( - (string)Registry.GetValue( - @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform", - "TokenStore", - string.Empty - ) - ), - "tokens.dat" - ); - default: - return ""; - } - } - - public static IPhysicalStore GetStore(PSVersion version, bool production) - { - string psPath; - - try - { - psPath = GetPSPath(version); - } - catch - { - throw new FileNotFoundException("Failed to get path of physical store."); - } - - if (string.IsNullOrEmpty(psPath) || !File.Exists(psPath)) - { - throw new FileNotFoundException(string.Format("Physical store not found at expected path {0}.", psPath)); - } - - if (version == PSVersion.Vista) - { - throw new NotSupportedException("Physical store editing is not supported for Windows Vista."); - } - - return version == PSVersion.Win7 ? new PhysicalStoreWin7(psPath, production) : (IPhysicalStore)new PhysicalStoreModern(psPath, production, version); - } - - public static ITokenStore GetTokenStore(PSVersion version) - { - string tokPath; - - try - { - tokPath = GetTokensPath(version); - } - catch - { - throw new FileNotFoundException("Failed to get path of physical store."); - } - - if (string.IsNullOrEmpty(tokPath) || !File.Exists(tokPath)) - { - throw new FileNotFoundException(string.Format("Token store not found at expected path {0}.", tokPath)); - } - - return new TokenStoreModern(tokPath); - } - public static string GetArchitecture() { string arch = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE", EnvironmentVariableTarget.Machine).ToUpperInvariant(); @@ -392,7 +241,7 @@ namespace LibTSforge if (build >= 7600 && build <= 7602) return PSVersion.Win7; if (build == 9200) return PSVersion.Win8; - throw new NotSupportedException("Unable to auto-detect version info, please specify one manually using the /ver argument."); + throw new NotSupportedException("Unable to auto-detect version info"); } public static bool DetectCurrentKey() @@ -403,7 +252,7 @@ namespace LibTSforge { foreach (string subKey in wpaKey.GetSubKeyNames()) { - if (subKey.StartsWith("8DEC0AF1") && subKey.EndsWith("-1")) + if (subKey.StartsWith("8DEC0AF1")) { return subKey.Contains("P"); } @@ -412,46 +261,6 @@ namespace LibTSforge throw new FileNotFoundException("Failed to autodetect key type, specify physical store key with /prod or /test arguments."); } - - public static void DumpStore(PSVersion version, bool production, string filePath, string encrFilePath) - { - if (encrFilePath == null) - { - encrFilePath = GetPSPath(version); - } - - if (string.IsNullOrEmpty(encrFilePath) || !File.Exists(encrFilePath)) - { - throw new FileNotFoundException("Store does not exist at expected path '" + encrFilePath + "'."); - } - - KillSPP(); - - using (FileStream fs = File.Open(encrFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None)) - { - byte[] encrData = fs.ReadAllBytes(); - File.WriteAllBytes(filePath, PhysStoreCrypto.DecryptPhysicalStore(encrData, production)); - } - - Logger.WriteLine("Store dumped successfully to '" + filePath + "'."); - } - - public static void LoadStore(PSVersion version, bool production, string filePath) - { - if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath)) - { - throw new FileNotFoundException("Store file '" + filePath + "' does not exist."); - } - - KillSPP(); - - using (IPhysicalStore store = GetStore(version, production)) - { - store.WriteRaw(File.ReadAllBytes(filePath)); - } - - Logger.WriteLine("Loaded store file succesfully."); - } } public static class Logger -- cgit v1.2.3 From f2ad15e5a25c9cc2cdf0d198927be0562f466156 Mon Sep 17 00:00:00 2001 From: WitherOrNot Date: Sun, 2 Mar 2025 19:02:36 -0500 Subject: fix vista kms4k, add reset support --- LibTSforge/Activators/KMS4K.cs | 17 ++++++++++++----- LibTSforge/Common.cs | 4 ++-- LibTSforge/Modifiers/KeyChangeLockDelete.cs | 3 +++ LibTSforge/Modifiers/RearmReset.cs | 13 +++++++++++-- LibTSforge/Modifiers/TamperedFlagsDelete.cs | 17 ++++++++++------- LibTSforge/SPP/SPPUtils.cs | 4 ++++ 6 files changed, 42 insertions(+), 16 deletions(-) (limited to 'LibTSforge/Common.cs') diff --git a/LibTSforge/Activators/KMS4K.cs b/LibTSforge/Activators/KMS4K.cs index 315e082..01b7395 100644 --- a/LibTSforge/Activators/KMS4K.cs +++ b/LibTSforge/Activators/KMS4K.cs @@ -1,6 +1,7 @@ namespace LibTSforge.Activators { using System; + using System.IO; using LibTSforge.PhysicalStore; using LibTSforge.SPP; @@ -62,12 +63,18 @@ namespace LibTSforge.Activators { VistaTimer vistaTimer = new VistaTimer(); vistaTimer.Time = time2; - vistaTimer.Expiry = expiry; + vistaTimer.Expiry = Constants.TimerMax; string vistaTimerName = string.Format("msft:sl/timer/VLExpiration/VOLUME/{0}/{1}", appId, actId); store.DeleteBlock(key, vistaTimerName); - store.DeleteBlock(key, "45E81E65-6944-422E-9C02-D83F7E5F5A58"); + store.DeleteBlock(key, actId.ToString()); + + BinaryWriter writer = new BinaryWriter(new MemoryStream()); + writer.Write(Constants.KMSv4Response.Length); + writer.Write(Constants.KMSv4Response); + writer.Write(Constants.UniversalHWIDBlock); + byte[] kmsData = writer.GetBytes(); store.AddBlocks(new PSBlock[] { @@ -84,8 +91,8 @@ namespace LibTSforge.Activators Type = BlockType.NAMED, Flags = 0, KeyAsStr = key, - ValueAsStr = "45E81E65-6944-422E-9C02-D83F7E5F5A58", - Data = new Guid().ToByteArray() + ValueAsStr = actId.ToString(), + Data = kmsData } }); } @@ -191,7 +198,7 @@ namespace LibTSforge.Activators } } - SPPUtils.RestartSPP(version); + SPPUtils.RestartSPP(version); SLApi.FireStateChangedEvent(appId); Logger.WriteLine("Activated using KMS4k successfully."); } diff --git a/LibTSforge/Common.cs b/LibTSforge/Common.cs index 6973f6f..a1b4294 100644 --- a/LibTSforge/Common.cs +++ b/LibTSforge/Common.cs @@ -87,8 +87,8 @@ namespace LibTSforge 0x92, 0xA6, 0x56, 0x96 }; - // 2^31 - 1 minutes - public static ulong TimerMax = (ulong)TimeSpan.FromMinutes(2147483647).Ticks; + // 2^31 - 8 minutes + public static ulong TimerMax = (ulong)TimeSpan.FromMinutes(2147483640).Ticks; public static readonly string ZeroCID = new string('0', 48); } diff --git a/LibTSforge/Modifiers/KeyChangeLockDelete.cs b/LibTSforge/Modifiers/KeyChangeLockDelete.cs index 5150a41..3883d3c 100644 --- a/LibTSforge/Modifiers/KeyChangeLockDelete.cs +++ b/LibTSforge/Modifiers/KeyChangeLockDelete.cs @@ -5,11 +5,14 @@ namespace LibTSforge.Modifiers using LibTSforge.PhysicalStore; using LibTSforge.SPP; using LibTSforge; + using System; public static class KeyChangeLockDelete { public static void Delete(PSVersion version, bool production) { + if (version == PSVersion.Vista) throw new NotSupportedException("This feature is not supported on Windows Vista/Server 2008."); + SPPUtils.KillSPP(version); Logger.WriteLine("Writing TrustedStore data..."); using (IPhysicalStore store = SPPUtils.GetStore(version, production)) diff --git a/LibTSforge/Modifiers/RearmReset.cs b/LibTSforge/Modifiers/RearmReset.cs index a17c005..4b611b6 100644 --- a/LibTSforge/Modifiers/RearmReset.cs +++ b/LibTSforge/Modifiers/RearmReset.cs @@ -2,6 +2,7 @@ namespace LibTSforge.Modifiers { using System; using System.Collections.Generic; + using System.Data; using System.Linq; using LibTSforge.PhysicalStore; using LibTSforge.SPP; @@ -18,7 +19,11 @@ namespace LibTSforge.Modifiers { List blocks; - if (version == PSVersion.Win7) + if (version == PSVersion.Vista) + { + blocks = store.FindBlocks("740D70D8-6448-4b2f-9063-4A7A463600C5").ToList(); + } + else if (version == PSVersion.Win7) { blocks = store.FindBlocks(0xA0000).ToList(); } @@ -29,7 +34,11 @@ namespace LibTSforge.Modifiers foreach (PSBlock block in blocks) { - if (version == PSVersion.Win7) + if (version == PSVersion.Vista) + { + store.DeleteBlock(block.KeyAsStr, block.ValueAsStr); + } + else if (version == PSVersion.Win7) { store.SetBlock(block.KeyAsStr, block.ValueAsInt, new byte[8]); } diff --git a/LibTSforge/Modifiers/TamperedFlagsDelete.cs b/LibTSforge/Modifiers/TamperedFlagsDelete.cs index 55ba1ec..ecd9267 100644 --- a/LibTSforge/Modifiers/TamperedFlagsDelete.cs +++ b/LibTSforge/Modifiers/TamperedFlagsDelete.cs @@ -15,21 +15,24 @@ namespace LibTSforge.Modifiers using (IPhysicalStore store = SPPUtils.GetStore(version, production)) { - if (version != PSVersion.Win7) + if (version == PSVersion.Vista) { - string recreatedFlag = "__##USERSEP-RESERVED##__$$RECREATED-FLAG$$"; - string recoveredFlag = "__##USERSEP-RESERVED##__$$RECOVERED-FLAG$$"; - - DeleteFlag(store, recreatedFlag); - DeleteFlag(store, recoveredFlag); + DeleteFlag(store, "6BE8425B-E3CF-4e86-A6AF-5863E3DCB606"); } - else + else if (version == PSVersion.Win7) { SetFlag(store, 0xA0001); } + else + { + DeleteFlag(store, "__##USERSEP-RESERVED##__$$RECREATED-FLAG$$"); + DeleteFlag(store, "__##USERSEP-RESERVED##__$$RECOVERED-FLAG$$"); + } Logger.WriteLine("Successfully cleared the tamper state."); } + + SPPUtils.RestartSPP(version); } private static void DeleteFlag(IPhysicalStore store, string flag) diff --git a/LibTSforge/SPP/SPPUtils.cs b/LibTSforge/SPP/SPPUtils.cs index f1aa32f..08dbe03 100644 --- a/LibTSforge/SPP/SPPUtils.cs +++ b/LibTSforge/SPP/SPPUtils.cs @@ -252,6 +252,8 @@ namespace LibTSforge.SPP File.WriteAllBytes(filePath, PhysStoreCrypto.DecryptPhysicalStore(encrData, production, version)); } + RestartSPP(version); + Logger.WriteLine("Store dumped successfully to '" + filePath + "'."); } @@ -269,6 +271,8 @@ namespace LibTSforge.SPP store.WriteRaw(File.ReadAllBytes(filePath)); } + RestartSPP(version); + Logger.WriteLine("Loaded store file succesfully."); } } -- cgit v1.2.3 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/Common.cs | 18 ------------------ LibTSforge/SPP/SPPUtils.cs | 20 ++++++++++++++++++-- 2 files changed, 18 insertions(+), 20 deletions(-) (limited to 'LibTSforge/Common.cs') diff --git a/LibTSforge/Common.cs b/LibTSforge/Common.cs index a1b4294..4a95a08 100644 --- a/LibTSforge/Common.cs +++ b/LibTSforge/Common.cs @@ -243,24 +243,6 @@ namespace LibTSforge throw new NotSupportedException("Unable to auto-detect version info"); } - - 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 class Logger 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 From b8558d8fb2de25a97572ec9d3e33618b8fac3027 Mon Sep 17 00:00:00 2001 From: Lyssa Date: Wed, 2 Apr 2025 14:06:52 +0400 Subject: basic cleanup --- LibTSforge/Activators/KMS4K.cs | 8 ++++--- LibTSforge/Common.cs | 6 ----- LibTSforge/Crypto/PhysStoreCrypto.cs | 2 -- LibTSforge/Modifiers/GracePeriodReset.cs | 1 - LibTSforge/Modifiers/RearmReset.cs | 2 -- LibTSforge/Modifiers/TamperedFlagsDelete.cs | 1 - LibTSforge/PhysicalStore/VariableBag.cs | 3 +-- LibTSforge/SPP/PKeyConfig.cs | 36 ++++++++++++++++------------- LibTSforge/SPP/SPSys.cs | 7 ++---- LibTSforge/TokenStore/TokenStoreModern.cs | 5 ++-- 10 files changed, 30 insertions(+), 41 deletions(-) (limited to 'LibTSforge/Common.cs') diff --git a/LibTSforge/Activators/KMS4K.cs b/LibTSforge/Activators/KMS4K.cs index 01b7395..a68e263 100644 --- a/LibTSforge/Activators/KMS4K.cs +++ b/LibTSforge/Activators/KMS4K.cs @@ -61,9 +61,11 @@ namespace LibTSforge.Activators if (version == PSVersion.Vista) { - VistaTimer vistaTimer = new VistaTimer(); - vistaTimer.Time = time2; - vistaTimer.Expiry = Constants.TimerMax; + VistaTimer vistaTimer = new VistaTimer + { + Time = time2, + Expiry = Constants.TimerMax + }; string vistaTimerName = string.Format("msft:sl/timer/VLExpiration/VOLUME/{0}/{1}", appId, actId); diff --git a/LibTSforge/Common.cs b/LibTSforge/Common.cs index 4a95a08..75e31e4 100644 --- a/LibTSforge/Common.cs +++ b/LibTSforge/Common.cs @@ -1,16 +1,10 @@ namespace LibTSforge { - using Microsoft.Win32; using System; using System.IO; using System.Linq; using System.Runtime.InteropServices; - using System.ServiceProcess; using System.Text; - using LibTSforge.Crypto; - using LibTSforge.PhysicalStore; - using LibTSforge.SPP; - using LibTSforge.TokenStore; public enum PSVersion { diff --git a/LibTSforge/Crypto/PhysStoreCrypto.cs b/LibTSforge/Crypto/PhysStoreCrypto.cs index c0491db..b0acc2e 100644 --- a/LibTSforge/Crypto/PhysStoreCrypto.cs +++ b/LibTSforge/Crypto/PhysStoreCrypto.cs @@ -2,10 +2,8 @@ namespace LibTSforge.Crypto { using System; using System.Collections.Generic; - using System.Diagnostics; using System.IO; using System.Linq; - using System.Security.Cryptography; using System.Text; public static class PhysStoreCrypto diff --git a/LibTSforge/Modifiers/GracePeriodReset.cs b/LibTSforge/Modifiers/GracePeriodReset.cs index ddca3f7..059b1c5 100644 --- a/LibTSforge/Modifiers/GracePeriodReset.cs +++ b/LibTSforge/Modifiers/GracePeriodReset.cs @@ -1,6 +1,5 @@ namespace LibTSforge.Modifiers { - using System; using System.Collections.Generic; using System.Linq; using LibTSforge.PhysicalStore; diff --git a/LibTSforge/Modifiers/RearmReset.cs b/LibTSforge/Modifiers/RearmReset.cs index 4b611b6..89a12f3 100644 --- a/LibTSforge/Modifiers/RearmReset.cs +++ b/LibTSforge/Modifiers/RearmReset.cs @@ -1,8 +1,6 @@ namespace LibTSforge.Modifiers { - using System; using System.Collections.Generic; - using System.Data; using System.Linq; using LibTSforge.PhysicalStore; using LibTSforge.SPP; diff --git a/LibTSforge/Modifiers/TamperedFlagsDelete.cs b/LibTSforge/Modifiers/TamperedFlagsDelete.cs index ecd9267..8369d4e 100644 --- a/LibTSforge/Modifiers/TamperedFlagsDelete.cs +++ b/LibTSforge/Modifiers/TamperedFlagsDelete.cs @@ -1,6 +1,5 @@ namespace LibTSforge.Modifiers { - using System; using System.Linq; using LibTSforge.PhysicalStore; using LibTSforge.SPP; diff --git a/LibTSforge/PhysicalStore/VariableBag.cs b/LibTSforge/PhysicalStore/VariableBag.cs index 76098a9..ebe413f 100644 --- a/LibTSforge/PhysicalStore/VariableBag.cs +++ b/LibTSforge/PhysicalStore/VariableBag.cs @@ -3,7 +3,6 @@ namespace LibTSforge.PhysicalStore using System; using System.Collections.Generic; using System.IO; - using System.Runtime.CompilerServices; public enum CRCBlockType : uint { @@ -155,7 +154,7 @@ namespace LibTSforge.PhysicalStore public class VariableBag { public List Blocks = new List(); - private PSVersion Version; + private readonly PSVersion Version; public void Deserialize(byte[] data) { diff --git a/LibTSforge/SPP/PKeyConfig.cs b/LibTSforge/SPP/PKeyConfig.cs index a608608..6733940 100644 --- a/LibTSforge/SPP/PKeyConfig.cs +++ b/LibTSforge/SPP/PKeyConfig.cs @@ -75,7 +75,7 @@ namespace LibTSforge.SPP public class PKeyConfig { public Dictionary Products = new Dictionary(); - private List loadedPkeyConfigs = new List(); + private readonly List loadedPkeyConfigs = new List(); public void LoadConfig(Guid actId) { @@ -136,12 +136,14 @@ namespace LibTSforge.SPP ranges[refActIdStr] = new List(); } - KeyRange keyRange = new KeyRange(); - keyRange.Start = int.Parse(rangeNode.SelectSingleNode("./p:Start", nsmgr).InnerText); - keyRange.End = int.Parse(rangeNode.SelectSingleNode("./p:End", nsmgr).InnerText); - keyRange.EulaType = rangeNode.SelectSingleNode("./p:EulaType", nsmgr).InnerText; - keyRange.PartNumber = rangeNode.SelectSingleNode("./p:PartNumber", nsmgr).InnerText; - keyRange.Valid = rangeNode.SelectSingleNode("./p:IsValid", nsmgr).InnerText.ToLower() == "true"; + KeyRange keyRange = new KeyRange + { + Start = int.Parse(rangeNode.SelectSingleNode("./p:Start", nsmgr).InnerText), + End = int.Parse(rangeNode.SelectSingleNode("./p:End", nsmgr).InnerText), + EulaType = rangeNode.SelectSingleNode("./p:EulaType", nsmgr).InnerText, + PartNumber = rangeNode.SelectSingleNode("./p:PartNumber", nsmgr).InnerText, + Valid = rangeNode.SelectSingleNode("./p:IsValid", nsmgr).InnerText.ToLower() == "true" + }; ranges[refActIdStr].Add(keyRange); } @@ -155,15 +157,17 @@ namespace LibTSforge.SPP if (keyRanges.Count > 0 && !Products.ContainsKey(refActId)) { - ProductConfig productConfig = new ProductConfig(); - productConfig.GroupId = group; - productConfig.Edition = configNode.SelectSingleNode("./p:EditionId", nsmgr).InnerText; - productConfig.Description = configNode.SelectSingleNode("./p:ProductDescription", nsmgr).InnerText; - productConfig.Channel = configNode.SelectSingleNode("./p:ProductKeyType", nsmgr).InnerText; - productConfig.Randomized = configNode.SelectSingleNode("./p:ProductKeyType", nsmgr).InnerText.ToLower() == "true"; - productConfig.Algorithm = algorithms[group]; - productConfig.Ranges = keyRanges; - productConfig.ActivationId = refActId; + ProductConfig productConfig = new ProductConfig + { + GroupId = group, + Edition = configNode.SelectSingleNode("./p:EditionId", nsmgr).InnerText, + Description = configNode.SelectSingleNode("./p:ProductDescription", nsmgr).InnerText, + Channel = configNode.SelectSingleNode("./p:ProductKeyType", nsmgr).InnerText, + Randomized = configNode.SelectSingleNode("./p:ProductKeyType", nsmgr).InnerText.ToLower() == "true", + Algorithm = algorithms[group], + Ranges = keyRanges, + ActivationId = refActId + }; Products[refActId] = productConfig; } diff --git a/LibTSforge/SPP/SPSys.cs b/LibTSforge/SPP/SPSys.cs index 10b8d04..18b3655 100644 --- a/LibTSforge/SPP/SPSys.cs +++ b/LibTSforge/SPP/SPSys.cs @@ -2,10 +2,7 @@ namespace LibTSforge.SPP { using Microsoft.Win32.SafeHandles; using System; - using System.Collections.Generic; - using System.Linq; using System.Runtime.InteropServices; - using System.Text; public class SPSys { @@ -24,7 +21,7 @@ namespace LibTSforge.SPP { SafeFileHandle file = CreateFileSafe(@"\\.\SpDevice"); IntPtr buffer = Marshal.AllocHGlobal(1); - int bytesReturned = 0; + int bytesReturned; DeviceIoControl(file, 0x80006008, IntPtr.Zero, 0, buffer, 1, out bytesReturned, IntPtr.Zero); bool running = Marshal.ReadByte(buffer) != 0; Marshal.FreeHGlobal(buffer); @@ -36,7 +33,7 @@ namespace LibTSforge.SPP { SafeFileHandle file = CreateFileSafe(@"\\.\SpDevice"); IntPtr buffer = Marshal.AllocHGlobal(4); - int bytesReturned = 0; + int bytesReturned; DeviceIoControl(file, start ? 0x8000a000 : 0x8000a004, IntPtr.Zero, 0, buffer, 4, out bytesReturned, IntPtr.Zero); int result = Marshal.ReadInt32(buffer); Marshal.FreeHGlobal(buffer); diff --git a/LibTSforge/TokenStore/TokenStoreModern.cs b/LibTSforge/TokenStore/TokenStoreModern.cs index c3483ff..cfb35d0 100644 --- a/LibTSforge/TokenStore/TokenStoreModern.cs +++ b/LibTSforge/TokenStore/TokenStoreModern.cs @@ -25,17 +25,16 @@ namespace LibTSforge.TokenStore if (TokensFile.Length < BLOCK_SIZE) return; TokensFile.Seek(0x24, SeekOrigin.Begin); - uint nextBlock = 0; + uint nextBlock; BinaryReader reader = new BinaryReader(TokensFile); do { - uint curOffset = reader.ReadUInt32(); nextBlock = reader.ReadUInt32(); for (int i = 0; i < ENTRIES_PER_BLOCK; i++) { - curOffset = reader.ReadUInt32(); + uint curOffset = reader.ReadUInt32(); bool populated = reader.ReadUInt32() == 1; uint contentOffset = reader.ReadUInt32(); uint contentLength = reader.ReadUInt32(); -- cgit v1.2.3 From 6c2df14898532996db6f23a220513e9d52eb6430 Mon Sep 17 00:00:00 2001 From: Lyssa Date: Wed, 2 Apr 2025 20:00:42 +0400 Subject: remove 8early --- LibTSforge/Common.cs | 1 - TSforgeCLI/Program.cs | 3 +-- vista.dat | Bin 21788 -> 0 bytes 3 files changed, 1 insertion(+), 3 deletions(-) delete mode 100644 vista.dat (limited to 'LibTSforge/Common.cs') diff --git a/LibTSforge/Common.cs b/LibTSforge/Common.cs index 75e31e4..b9c274a 100644 --- a/LibTSforge/Common.cs +++ b/LibTSforge/Common.cs @@ -10,7 +10,6 @@ namespace LibTSforge { Vista, Win7, - Win8Early, Win8, WinBlue, WinModern diff --git a/TSforgeCLI/Program.cs b/TSforgeCLI/Program.cs index 2c636b4..865e51d 100644 --- a/TSforgeCLI/Program.cs +++ b/TSforgeCLI/Program.cs @@ -223,7 +223,7 @@ namespace TSforgeCLI Logger.WriteLine("\t/revl Remove the key change lock in evaluation edition store."); Logger.WriteLine("\t/prod Use SPP production key."); Logger.WriteLine("\t/test Use SPP test key."); - Logger.WriteLine("\t/ver Override the detected version. Available versions: vista, 7, 8early, 8, blue, modern."); + Logger.WriteLine("\t/ver Override the detected version. Available versions: vista, 7, 8, blue, modern."); Logger.WriteLine("\t A specific activation ID. Useful if you want to activate specific addons like ESU."); Logger.WriteLine("\t/? Display this help message."); } @@ -234,7 +234,6 @@ namespace TSforgeCLI { case "vista": return PSVersion.Vista; case "7": return PSVersion.Win7; - case "8early": return PSVersion.Win8Early; case "8": return PSVersion.Win8; case "blue": return PSVersion.WinBlue; case "modern": return PSVersion.WinModern; diff --git a/vista.dat b/vista.dat deleted file mode 100644 index 97ff497..0000000 Binary files a/vista.dat and /dev/null differ -- cgit v1.2.3 From 17a7c90245ccd45b6e32d8bbe01a1a3eddeeae4d Mon Sep 17 00:00:00 2001 From: Wither OrNot Date: Thu, 3 Apr 2025 18:22:33 -0400 Subject: miscellaneous fixes --- LibTSforge/Activators/AVMA4K.cs | 2 +- LibTSforge/Common.cs | 9 ++++++--- LibTSforge/SPP/SPPUtils.cs | 4 ++-- LibTSforge/TokenStore/TokenStoreModern.cs | 1 + TSforgeCLI/Program.cs | 2 ++ 5 files changed, 12 insertions(+), 6 deletions(-) (limited to 'LibTSforge/Common.cs') diff --git a/LibTSforge/Activators/AVMA4K.cs b/LibTSforge/Activators/AVMA4K.cs index ec09daf..2127652 100644 --- a/LibTSforge/Activators/AVMA4K.cs +++ b/LibTSforge/Activators/AVMA4K.cs @@ -8,7 +8,7 @@ namespace LibTSforge.Activators { public static void Activate(PSVersion version, bool production, Guid actId) { - if (version != PSVersion.WinModern) + if (version != PSVersion.WinModern && version != PSVersion.WinBlue) { throw new NotSupportedException("AVMA licenses are not available for this product."); } diff --git a/LibTSforge/Common.cs b/LibTSforge/Common.cs index b9c274a..4d61770 100644 --- a/LibTSforge/Common.cs +++ b/LibTSforge/Common.cs @@ -183,6 +183,12 @@ namespace LibTSforge public static class Utils { + [DllImport("kernel32.dll")] + public static extern uint GetSystemDefaultLCID(); + + [DllImport("kernel32.dll")] + public static extern bool Wow64EnableWow64FsRedirection(bool Wow64FsEnableRedirection); + public static string DecodeString(byte[] data) { return Encoding.Unicode.GetString(data).Trim('\0'); @@ -193,9 +199,6 @@ namespace LibTSforge return Encoding.Unicode.GetBytes(str + '\0'); } - [DllImport("kernel32.dll")] - public static extern uint GetSystemDefaultLCID(); - public static uint CRC32(byte[] data) { const uint polynomial = 0x04C11DB7; diff --git a/LibTSforge/SPP/SPPUtils.cs b/LibTSforge/SPP/SPPUtils.cs index 1a6ef62..5621305 100644 --- a/LibTSforge/SPP/SPPUtils.cs +++ b/LibTSforge/SPP/SPPUtils.cs @@ -33,7 +33,7 @@ namespace LibTSforge.SPP bool stopped = false; - for (int i = 0; stopped == false && i < 360; i++) + for (int i = 0; stopped == false && i < 1080; i++) { try { @@ -48,7 +48,7 @@ namespace LibTSforge.SPP } catch (InvalidOperationException ex) { - Logger.WriteLine("Warning: Stopping sppsvc failed, retrying. Details:" + ex.Message); + Logger.WriteLine("Warning: Stopping sppsvc failed, retrying. Details: " + ex.Message); System.Threading.Thread.Sleep(500); continue; } diff --git a/LibTSforge/TokenStore/TokenStoreModern.cs b/LibTSforge/TokenStore/TokenStoreModern.cs index cfb35d0..ee51e7a 100644 --- a/LibTSforge/TokenStore/TokenStoreModern.cs +++ b/LibTSforge/TokenStore/TokenStoreModern.cs @@ -30,6 +30,7 @@ namespace LibTSforge.TokenStore BinaryReader reader = new BinaryReader(TokensFile); do { + reader.ReadUInt32(); nextBlock = reader.ReadUInt32(); for (int i = 0; i < ENTRIES_PER_BLOCK; i++) diff --git a/TSforgeCLI/Program.cs b/TSforgeCLI/Program.cs index 865e51d..86945d5 100644 --- a/TSforgeCLI/Program.cs +++ b/TSforgeCLI/Program.cs @@ -35,6 +35,8 @@ namespace TSforgeCLI { Logger.WriteLine("TSforge (c) MASSGRAVE 2025"); + Utils.Wow64EnableWow64FsRedirection(false); + try { if (args.Length == 0) -- cgit v1.2.3 From be6682e8c3920a41ea67616582744c132def0f97 Mon Sep 17 00:00:00 2001 From: Lyssa Date: Sun, 6 Apr 2025 19:33:14 +0400 Subject: readonly usage inconsistency --- LibTSforge/Common.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'LibTSforge/Common.cs') diff --git a/LibTSforge/Common.cs b/LibTSforge/Common.cs index 4d61770..a45870d 100644 --- a/LibTSforge/Common.cs +++ b/LibTSforge/Common.cs @@ -81,7 +81,7 @@ namespace LibTSforge }; // 2^31 - 8 minutes - public static ulong TimerMax = (ulong)TimeSpan.FromMinutes(2147483640).Ticks; + public static readonly ulong TimerMax = (ulong)TimeSpan.FromMinutes(2147483640).Ticks; public static readonly string ZeroCID = new string('0', 48); } -- cgit v1.2.3 From 3f1c87831802817f0cb3effacde954d3cbadfb6c Mon Sep 17 00:00:00 2001 From: Lyssa Date: Sun, 6 Apr 2025 19:35:08 +0400 Subject: remove unused CastToStruct function --- LibTSforge/Common.cs | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'LibTSforge/Common.cs') diff --git a/LibTSforge/Common.cs b/LibTSforge/Common.cs index a45870d..6b05bce 100644 --- a/LibTSforge/Common.cs +++ b/LibTSforge/Common.cs @@ -149,20 +149,6 @@ namespace LibTSforge } return result; } - - public static T CastToStruct(this byte[] data) where T : struct - { - GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned); - try - { - IntPtr ptr = handle.AddrOfPinnedObject(); - return (T)Marshal.PtrToStructure(ptr, typeof(T)); - } - finally - { - handle.Free(); - } - } } public static class FileStreamExt -- cgit v1.2.3