basic cleanup
This commit is contained in:
parent
07f43e2613
commit
b8558d8fb2
@ -61,9 +61,11 @@ namespace LibTSforge.Activators
|
|||||||
|
|
||||||
if (version == PSVersion.Vista)
|
if (version == PSVersion.Vista)
|
||||||
{
|
{
|
||||||
VistaTimer vistaTimer = new VistaTimer();
|
VistaTimer vistaTimer = new VistaTimer
|
||||||
vistaTimer.Time = time2;
|
{
|
||||||
vistaTimer.Expiry = Constants.TimerMax;
|
Time = time2,
|
||||||
|
Expiry = Constants.TimerMax
|
||||||
|
};
|
||||||
|
|
||||||
string vistaTimerName = string.Format("msft:sl/timer/VLExpiration/VOLUME/{0}/{1}", appId, actId);
|
string vistaTimerName = string.Format("msft:sl/timer/VLExpiration/VOLUME/{0}/{1}", appId, actId);
|
||||||
|
|
||||||
|
@ -1,16 +1,10 @@
|
|||||||
namespace LibTSforge
|
namespace LibTSforge
|
||||||
{
|
{
|
||||||
using Microsoft.Win32;
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.ServiceProcess;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using LibTSforge.Crypto;
|
|
||||||
using LibTSforge.PhysicalStore;
|
|
||||||
using LibTSforge.SPP;
|
|
||||||
using LibTSforge.TokenStore;
|
|
||||||
|
|
||||||
public enum PSVersion
|
public enum PSVersion
|
||||||
{
|
{
|
||||||
|
@ -2,10 +2,8 @@ namespace LibTSforge.Crypto
|
|||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Cryptography;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
public static class PhysStoreCrypto
|
public static class PhysStoreCrypto
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
namespace LibTSforge.Modifiers
|
namespace LibTSforge.Modifiers
|
||||||
{
|
{
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using LibTSforge.PhysicalStore;
|
using LibTSforge.PhysicalStore;
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
namespace LibTSforge.Modifiers
|
namespace LibTSforge.Modifiers
|
||||||
{
|
{
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using LibTSforge.PhysicalStore;
|
using LibTSforge.PhysicalStore;
|
||||||
using LibTSforge.SPP;
|
using LibTSforge.SPP;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
namespace LibTSforge.Modifiers
|
namespace LibTSforge.Modifiers
|
||||||
{
|
{
|
||||||
using System;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using LibTSforge.PhysicalStore;
|
using LibTSforge.PhysicalStore;
|
||||||
using LibTSforge.SPP;
|
using LibTSforge.SPP;
|
||||||
|
@ -3,7 +3,6 @@ namespace LibTSforge.PhysicalStore
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
|
|
||||||
public enum CRCBlockType : uint
|
public enum CRCBlockType : uint
|
||||||
{
|
{
|
||||||
@ -155,7 +154,7 @@ namespace LibTSforge.PhysicalStore
|
|||||||
public class VariableBag
|
public class VariableBag
|
||||||
{
|
{
|
||||||
public List<CRCBlock> Blocks = new List<CRCBlock>();
|
public List<CRCBlock> Blocks = new List<CRCBlock>();
|
||||||
private PSVersion Version;
|
private readonly PSVersion Version;
|
||||||
|
|
||||||
public void Deserialize(byte[] data)
|
public void Deserialize(byte[] data)
|
||||||
{
|
{
|
||||||
|
@ -75,7 +75,7 @@ namespace LibTSforge.SPP
|
|||||||
public class PKeyConfig
|
public class PKeyConfig
|
||||||
{
|
{
|
||||||
public Dictionary<Guid, ProductConfig> Products = new Dictionary<Guid, ProductConfig>();
|
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)
|
public void LoadConfig(Guid actId)
|
||||||
{
|
{
|
||||||
@ -136,12 +136,14 @@ namespace LibTSforge.SPP
|
|||||||
ranges[refActIdStr] = new List<KeyRange>();
|
ranges[refActIdStr] = new List<KeyRange>();
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyRange keyRange = new 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);
|
Start = int.Parse(rangeNode.SelectSingleNode("./p:Start", nsmgr).InnerText),
|
||||||
keyRange.EulaType = rangeNode.SelectSingleNode("./p:EulaType", nsmgr).InnerText;
|
End = int.Parse(rangeNode.SelectSingleNode("./p:End", nsmgr).InnerText),
|
||||||
keyRange.PartNumber = rangeNode.SelectSingleNode("./p:PartNumber", nsmgr).InnerText;
|
EulaType = rangeNode.SelectSingleNode("./p:EulaType", nsmgr).InnerText,
|
||||||
keyRange.Valid = rangeNode.SelectSingleNode("./p:IsValid", nsmgr).InnerText.ToLower() == "true";
|
PartNumber = rangeNode.SelectSingleNode("./p:PartNumber", nsmgr).InnerText,
|
||||||
|
Valid = rangeNode.SelectSingleNode("./p:IsValid", nsmgr).InnerText.ToLower() == "true"
|
||||||
|
};
|
||||||
|
|
||||||
ranges[refActIdStr].Add(keyRange);
|
ranges[refActIdStr].Add(keyRange);
|
||||||
}
|
}
|
||||||
@ -155,15 +157,17 @@ namespace LibTSforge.SPP
|
|||||||
|
|
||||||
if (keyRanges.Count > 0 && !Products.ContainsKey(refActId))
|
if (keyRanges.Count > 0 && !Products.ContainsKey(refActId))
|
||||||
{
|
{
|
||||||
ProductConfig productConfig = new ProductConfig();
|
ProductConfig productConfig = new ProductConfig
|
||||||
productConfig.GroupId = group;
|
{
|
||||||
productConfig.Edition = configNode.SelectSingleNode("./p:EditionId", nsmgr).InnerText;
|
GroupId = group,
|
||||||
productConfig.Description = configNode.SelectSingleNode("./p:ProductDescription", nsmgr).InnerText;
|
Edition = configNode.SelectSingleNode("./p:EditionId", nsmgr).InnerText,
|
||||||
productConfig.Channel = configNode.SelectSingleNode("./p:ProductKeyType", nsmgr).InnerText;
|
Description = configNode.SelectSingleNode("./p:ProductDescription", nsmgr).InnerText,
|
||||||
productConfig.Randomized = configNode.SelectSingleNode("./p:ProductKeyType", nsmgr).InnerText.ToLower() == "true";
|
Channel = configNode.SelectSingleNode("./p:ProductKeyType", nsmgr).InnerText,
|
||||||
productConfig.Algorithm = algorithms[group];
|
Randomized = configNode.SelectSingleNode("./p:ProductKeyType", nsmgr).InnerText.ToLower() == "true",
|
||||||
productConfig.Ranges = keyRanges;
|
Algorithm = algorithms[group],
|
||||||
productConfig.ActivationId = refActId;
|
Ranges = keyRanges,
|
||||||
|
ActivationId = refActId
|
||||||
|
};
|
||||||
|
|
||||||
Products[refActId] = productConfig;
|
Products[refActId] = productConfig;
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,7 @@ namespace LibTSforge.SPP
|
|||||||
{
|
{
|
||||||
using Microsoft.Win32.SafeHandles;
|
using Microsoft.Win32.SafeHandles;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
public class SPSys
|
public class SPSys
|
||||||
{
|
{
|
||||||
@ -24,7 +21,7 @@ namespace LibTSforge.SPP
|
|||||||
{
|
{
|
||||||
SafeFileHandle file = CreateFileSafe(@"\\.\SpDevice");
|
SafeFileHandle file = CreateFileSafe(@"\\.\SpDevice");
|
||||||
IntPtr buffer = Marshal.AllocHGlobal(1);
|
IntPtr buffer = Marshal.AllocHGlobal(1);
|
||||||
int bytesReturned = 0;
|
int bytesReturned;
|
||||||
DeviceIoControl(file, 0x80006008, IntPtr.Zero, 0, buffer, 1, out bytesReturned, IntPtr.Zero);
|
DeviceIoControl(file, 0x80006008, IntPtr.Zero, 0, buffer, 1, out bytesReturned, IntPtr.Zero);
|
||||||
bool running = Marshal.ReadByte(buffer) != 0;
|
bool running = Marshal.ReadByte(buffer) != 0;
|
||||||
Marshal.FreeHGlobal(buffer);
|
Marshal.FreeHGlobal(buffer);
|
||||||
@ -36,7 +33,7 @@ namespace LibTSforge.SPP
|
|||||||
{
|
{
|
||||||
SafeFileHandle file = CreateFileSafe(@"\\.\SpDevice");
|
SafeFileHandle file = CreateFileSafe(@"\\.\SpDevice");
|
||||||
IntPtr buffer = Marshal.AllocHGlobal(4);
|
IntPtr buffer = Marshal.AllocHGlobal(4);
|
||||||
int bytesReturned = 0;
|
int bytesReturned;
|
||||||
DeviceIoControl(file, start ? 0x8000a000 : 0x8000a004, IntPtr.Zero, 0, buffer, 4, out bytesReturned, IntPtr.Zero);
|
DeviceIoControl(file, start ? 0x8000a000 : 0x8000a004, IntPtr.Zero, 0, buffer, 4, out bytesReturned, IntPtr.Zero);
|
||||||
int result = Marshal.ReadInt32(buffer);
|
int result = Marshal.ReadInt32(buffer);
|
||||||
Marshal.FreeHGlobal(buffer);
|
Marshal.FreeHGlobal(buffer);
|
||||||
|
@ -25,17 +25,16 @@ namespace LibTSforge.TokenStore
|
|||||||
if (TokensFile.Length < BLOCK_SIZE) return;
|
if (TokensFile.Length < BLOCK_SIZE) return;
|
||||||
|
|
||||||
TokensFile.Seek(0x24, SeekOrigin.Begin);
|
TokensFile.Seek(0x24, SeekOrigin.Begin);
|
||||||
uint nextBlock = 0;
|
uint nextBlock;
|
||||||
|
|
||||||
BinaryReader reader = new BinaryReader(TokensFile);
|
BinaryReader reader = new BinaryReader(TokensFile);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
uint curOffset = reader.ReadUInt32();
|
|
||||||
nextBlock = reader.ReadUInt32();
|
nextBlock = reader.ReadUInt32();
|
||||||
|
|
||||||
for (int i = 0; i < ENTRIES_PER_BLOCK; i++)
|
for (int i = 0; i < ENTRIES_PER_BLOCK; i++)
|
||||||
{
|
{
|
||||||
curOffset = reader.ReadUInt32();
|
uint curOffset = reader.ReadUInt32();
|
||||||
bool populated = reader.ReadUInt32() == 1;
|
bool populated = reader.ReadUInt32() == 1;
|
||||||
uint contentOffset = reader.ReadUInt32();
|
uint contentOffset = reader.ReadUInt32();
|
||||||
uint contentLength = reader.ReadUInt32();
|
uint contentLength = reader.ReadUInt32();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user