summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLyssa2025-04-02 10:06:52 +0000
committerLyssa2025-04-02 10:06:52 +0000
commitb8558d8fb2de25a97572ec9d3e33618b8fac3027 (patch)
tree4a6dc0d718918881f8461091974ea3afaf026186
parent07f43e261381c8b9229fcf376e310d8f02ccb16d (diff)
downloadTSforge-b8558d8fb2de25a97572ec9d3e33618b8fac3027.zip
basic cleanup
-rw-r--r--LibTSforge/Activators/KMS4K.cs8
-rw-r--r--LibTSforge/Common.cs6
-rw-r--r--LibTSforge/Crypto/PhysStoreCrypto.cs2
-rw-r--r--LibTSforge/Modifiers/GracePeriodReset.cs1
-rw-r--r--LibTSforge/Modifiers/RearmReset.cs2
-rw-r--r--LibTSforge/Modifiers/TamperedFlagsDelete.cs1
-rw-r--r--LibTSforge/PhysicalStore/VariableBag.cs3
-rw-r--r--LibTSforge/SPP/PKeyConfig.cs36
-rw-r--r--LibTSforge/SPP/SPSys.cs7
-rw-r--r--LibTSforge/TokenStore/TokenStoreModern.cs5
10 files changed, 30 insertions, 41 deletions
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<CRCBlock> Blocks = new List<CRCBlock>();
- 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<Guid, ProductConfig> Products = new Dictionary<Guid, ProductConfig>();
- private List<Guid> loadedPkeyConfigs = new List<Guid>();
+ private readonly List<Guid> loadedPkeyConfigs = new List<Guid>();
public void LoadConfig(Guid actId)
{
@@ -136,12 +136,14 @@ namespace LibTSforge.SPP
ranges[refActIdStr] = new List<KeyRange>();
}
- 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();