Merge branch 'longhorn' of https://github.com/massgravel/TSforge into longhorn
This commit is contained in:
commit
b7868ff296
@ -1,8 +1,8 @@
|
|||||||
namespace LibTSforge.Activators
|
namespace LibTSforge.Activators
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
using LibTSforge.PhysicalStore;
|
using PhysicalStore;
|
||||||
using LibTSforge.SPP;
|
using SPP;
|
||||||
|
|
||||||
public static class AVMA4k
|
public static class AVMA4k
|
||||||
{
|
{
|
||||||
@ -42,24 +42,19 @@ namespace LibTSforge.Activators
|
|||||||
{
|
{
|
||||||
string key = string.Format("SPPSVC\\{0}\\{1}", appId, actId);
|
string key = string.Format("SPPSVC\\{0}\\{1}", appId, actId);
|
||||||
|
|
||||||
ulong unknown = 0;
|
|
||||||
ulong time1;
|
|
||||||
ulong crcBindTime = (ulong)DateTime.UtcNow.ToFileTime();
|
|
||||||
ulong timerTime;
|
|
||||||
|
|
||||||
ulong expiry = Constants.TimerMax;
|
|
||||||
|
|
||||||
long creationTime = BitConverter.ToInt64(store.GetBlock("__##USERSEP##\\$$_RESERVED_$$\\NAMESPACE__", "__##USERSEP-RESERVED##__$$GLOBAL-CREATION-TIME$$").Data, 0);
|
long creationTime = BitConverter.ToInt64(store.GetBlock("__##USERSEP##\\$$_RESERVED_$$\\NAMESPACE__", "__##USERSEP-RESERVED##__$$GLOBAL-CREATION-TIME$$").Data, 0);
|
||||||
long tickCount = BitConverter.ToInt64(store.GetBlock("__##USERSEP##\\$$_RESERVED_$$\\NAMESPACE__", "__##USERSEP-RESERVED##__$$GLOBAL-TICKCOUNT-UPTIME$$").Data, 0);
|
long tickCount = BitConverter.ToInt64(store.GetBlock("__##USERSEP##\\$$_RESERVED_$$\\NAMESPACE__", "__##USERSEP-RESERVED##__$$GLOBAL-TICKCOUNT-UPTIME$$").Data, 0);
|
||||||
long deltaTime = BitConverter.ToInt64(store.GetBlock(key, "__##USERSEP-RESERVED##__$$UP-TIME-DELTA$$").Data, 0);
|
long deltaTime = BitConverter.ToInt64(store.GetBlock(key, "__##USERSEP-RESERVED##__$$UP-TIME-DELTA$$").Data, 0);
|
||||||
|
|
||||||
time1 = (ulong)(creationTime + tickCount + deltaTime);
|
const ulong unknown = 0;
|
||||||
timerTime = crcBindTime / 10000;
|
ulong time1 = (ulong)(creationTime + tickCount + deltaTime);
|
||||||
expiry /= 10000;
|
ulong crcBindTime = (ulong)DateTime.UtcNow.ToFileTime();
|
||||||
|
ulong timerTime = crcBindTime / 10000;
|
||||||
|
ulong expiry = Constants.TimerMax / 10000;
|
||||||
|
|
||||||
VariableBag avmaBinding = new VariableBag(version);
|
VariableBag avmaBinding = new VariableBag(version);
|
||||||
|
|
||||||
avmaBinding.Blocks.AddRange(new CRCBlockModern[]
|
avmaBinding.Blocks.AddRange(new[]
|
||||||
{
|
{
|
||||||
new CRCBlockModern
|
new CRCBlockModern
|
||||||
{
|
{
|
||||||
@ -97,7 +92,7 @@ namespace LibTSforge.Activators
|
|||||||
store.DeleteBlock(key, storeVal);
|
store.DeleteBlock(key, storeVal);
|
||||||
store.DeleteBlock(key, timerVal);
|
store.DeleteBlock(key, timerVal);
|
||||||
|
|
||||||
store.AddBlocks(new PSBlock[]
|
store.AddBlocks(new[]
|
||||||
{
|
{
|
||||||
new PSBlock
|
new PSBlock
|
||||||
{
|
{
|
||||||
|
@ -2,8 +2,8 @@ namespace LibTSforge.Activators
|
|||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using LibTSforge.PhysicalStore;
|
using PhysicalStore;
|
||||||
using LibTSforge.SPP;
|
using SPP;
|
||||||
|
|
||||||
public class KMS4k
|
public class KMS4k
|
||||||
{
|
{
|
||||||
@ -78,7 +78,7 @@ namespace LibTSforge.Activators
|
|||||||
writer.Write(Constants.UniversalHWIDBlock);
|
writer.Write(Constants.UniversalHWIDBlock);
|
||||||
byte[] kmsData = writer.GetBytes();
|
byte[] kmsData = writer.GetBytes();
|
||||||
|
|
||||||
store.AddBlocks(new PSBlock[]
|
store.AddBlocks(new[]
|
||||||
{
|
{
|
||||||
new PSBlock
|
new PSBlock
|
||||||
{
|
{
|
||||||
@ -121,7 +121,7 @@ namespace LibTSforge.Activators
|
|||||||
|
|
||||||
VariableBag kmsBinding = new VariableBag(version);
|
VariableBag kmsBinding = new VariableBag(version);
|
||||||
|
|
||||||
kmsBinding.Blocks.AddRange(new CRCBlockModern[]
|
kmsBinding.Blocks.AddRange(new[]
|
||||||
{
|
{
|
||||||
new CRCBlockModern
|
new CRCBlockModern
|
||||||
{
|
{
|
||||||
@ -145,7 +145,7 @@ namespace LibTSforge.Activators
|
|||||||
|
|
||||||
if (version == PSVersion.WinModern)
|
if (version == PSVersion.WinModern)
|
||||||
{
|
{
|
||||||
kmsBinding.Blocks.AddRange(new CRCBlockModern[]
|
kmsBinding.Blocks.AddRange(new[]
|
||||||
{
|
{
|
||||||
new CRCBlockModern
|
new CRCBlockModern
|
||||||
{
|
{
|
||||||
@ -178,7 +178,7 @@ namespace LibTSforge.Activators
|
|||||||
store.DeleteBlock(key, storeVal);
|
store.DeleteBlock(key, storeVal);
|
||||||
store.DeleteBlock(key, timerVal);
|
store.DeleteBlock(key, timerVal);
|
||||||
|
|
||||||
store.AddBlocks(new PSBlock[]
|
store.AddBlocks(new[]
|
||||||
{
|
{
|
||||||
new PSBlock
|
new PSBlock
|
||||||
{
|
{
|
||||||
|
@ -3,14 +3,13 @@ namespace LibTSforge.Activators
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using Crypto;
|
||||||
using LibTSforge.Crypto;
|
using PhysicalStore;
|
||||||
using LibTSforge.PhysicalStore;
|
using SPP;
|
||||||
using LibTSforge.SPP;
|
|
||||||
|
|
||||||
public static class ZeroCID
|
public static class ZeroCID
|
||||||
{
|
{
|
||||||
public static void Deposit(Guid actId, string instId)
|
private static void Deposit(Guid actId, string instId)
|
||||||
{
|
{
|
||||||
uint status = SLApi.DepositConfirmationID(actId, instId, Constants.ZeroCID);
|
uint status = SLApi.DepositConfirmationID(actId, instId, Constants.ZeroCID);
|
||||||
Logger.WriteLine(string.Format("Depositing fake CID status {0:X}", status));
|
Logger.WriteLine(string.Format("Depositing fake CID status {0:X}", status));
|
||||||
@ -98,7 +97,7 @@ namespace LibTSforge.Activators
|
|||||||
string uniqueId = Utils.DecodeString(pkeyData.Skip(0x120).Take(0x80).ToArray());
|
string uniqueId = Utils.DecodeString(pkeyData.Skip(0x120).Take(0x80).ToArray());
|
||||||
string extPid = Utils.DecodeString(pkeyData.Skip(0x1A0).Take(0x80).ToArray());
|
string extPid = Utils.DecodeString(pkeyData.Skip(0x1A0).Take(0x80).ToArray());
|
||||||
|
|
||||||
uint group = 0;
|
uint group;
|
||||||
uint.TryParse(extPid.Split('-')[1], out group);
|
uint.TryParse(extPid.Split('-')[1], out group);
|
||||||
|
|
||||||
if (group == 0)
|
if (group == 0)
|
||||||
@ -154,7 +153,7 @@ namespace LibTSforge.Activators
|
|||||||
store.DeleteBlock(key, hwidBlockName);
|
store.DeleteBlock(key, hwidBlockName);
|
||||||
store.DeleteBlock(key, pkeyInfoName);
|
store.DeleteBlock(key, pkeyInfoName);
|
||||||
|
|
||||||
store.AddBlocks(new PSBlock[] {
|
store.AddBlocks(new[] {
|
||||||
new PSBlock
|
new PSBlock
|
||||||
{
|
{
|
||||||
Type = BlockType.NAMED,
|
Type = BlockType.NAMED,
|
||||||
|
@ -16,33 +16,33 @@ namespace LibTSforge.Crypto
|
|||||||
byte[] aesKeySig = br.ReadBytes(0x80);
|
byte[] aesKeySig = br.ReadBytes(0x80);
|
||||||
byte[] encAesKey = br.ReadBytes(0x80);
|
byte[] encAesKey = br.ReadBytes(0x80);
|
||||||
|
|
||||||
if (CryptoUtils.RSAVerifySignature(rsaKey, encAesKey, aesKeySig))
|
if (!CryptoUtils.RSAVerifySignature(rsaKey, encAesKey, aesKeySig))
|
||||||
{
|
{
|
||||||
byte[] aesKey = CryptoUtils.RSADecrypt(rsaKey, encAesKey);
|
throw new Exception("Failed to decrypt physical store.");
|
||||||
byte[] decData = CryptoUtils.AESDecrypt(br.ReadBytes((int)br.BaseStream.Length - 0x110), aesKey);
|
|
||||||
byte[] hmacKey = decData.Take(0x10).ToArray(); // SHA-1 salt on Vista
|
|
||||||
byte[] hmacSig = decData.Skip(0x10).Take(0x14).ToArray(); // SHA-1 hash on Vista
|
|
||||||
byte[] psData = decData.Skip(0x28).ToArray();
|
|
||||||
|
|
||||||
if (version != PSVersion.Vista)
|
|
||||||
{
|
|
||||||
if (!CryptoUtils.HMACVerify(hmacKey, psData, hmacSig))
|
|
||||||
{
|
|
||||||
throw new InvalidDataException("Failed to verify HMAC. Physical store is corrupt.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!CryptoUtils.SaltSHAVerify(hmacKey, psData, hmacSig))
|
|
||||||
{
|
|
||||||
throw new InvalidDataException("Failed to verify checksum. Physical store is corrupt.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return psData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Exception("Failed to decrypt physical store.");
|
byte[] aesKey = CryptoUtils.RSADecrypt(rsaKey, encAesKey);
|
||||||
|
byte[] decData = CryptoUtils.AESDecrypt(br.ReadBytes((int)br.BaseStream.Length - 0x110), aesKey);
|
||||||
|
byte[] hmacKey = decData.Take(0x10).ToArray(); // SHA-1 salt on Vista
|
||||||
|
byte[] hmacSig = decData.Skip(0x10).Take(0x14).ToArray(); // SHA-1 hash on Vista
|
||||||
|
byte[] psData = decData.Skip(0x28).ToArray();
|
||||||
|
|
||||||
|
if (version != PSVersion.Vista)
|
||||||
|
{
|
||||||
|
if (!CryptoUtils.HMACVerify(hmacKey, psData, hmacSig))
|
||||||
|
{
|
||||||
|
throw new InvalidDataException("Failed to verify HMAC. Physical store is corrupt.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!CryptoUtils.SaltSHAVerify(hmacKey, psData, hmacSig))
|
||||||
|
{
|
||||||
|
throw new InvalidDataException("Failed to verify checksum. Physical store is corrupt.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return psData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] EncryptPhysicalStore(byte[] data, bool production, PSVersion version)
|
public static byte[] EncryptPhysicalStore(byte[] data, bool production, PSVersion version)
|
||||||
@ -65,7 +65,7 @@ namespace LibTSforge.Crypto
|
|||||||
byte[] aesKeySig = CryptoUtils.RSASign(rsaKey, encAesKey);
|
byte[] aesKeySig = CryptoUtils.RSASign(rsaKey, encAesKey);
|
||||||
byte[] hmacSig = version != PSVersion.Vista ? CryptoUtils.HMACSign(hmacKey, data) : CryptoUtils.SaltSHASum(hmacKey, data);
|
byte[] hmacSig = version != PSVersion.Vista ? CryptoUtils.HMACSign(hmacKey, data) : CryptoUtils.SaltSHASum(hmacKey, data);
|
||||||
|
|
||||||
byte[] decData = new byte[] { };
|
byte[] decData = { };
|
||||||
decData = decData.Concat(hmacKey).Concat(hmacSig).Concat(BitConverter.GetBytes(0)).Concat(data).ToArray();
|
decData = decData.Concat(hmacKey).Concat(hmacSig).Concat(BitConverter.GetBytes(0)).Concat(data).ToArray();
|
||||||
byte[] encData = CryptoUtils.AESEncrypt(decData, aesKey);
|
byte[] encData = CryptoUtils.AESEncrypt(decData, aesKey);
|
||||||
|
|
||||||
|
@ -3,9 +3,9 @@ namespace LibTSforge.Modifiers
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using LibTSforge.PhysicalStore;
|
using PhysicalStore;
|
||||||
using LibTSforge.SPP;
|
using SPP;
|
||||||
using LibTSforge.TokenStore;
|
using TokenStore;
|
||||||
|
|
||||||
public static class GenPKeyInstall
|
public static class GenPKeyInstall
|
||||||
{
|
{
|
||||||
@ -58,7 +58,7 @@ namespace LibTSforge.Modifiers
|
|||||||
if (pkey.Algorithm == PKeyAlgorithm.PKEY2009)
|
if (pkey.Algorithm == PKeyAlgorithm.PKEY2009)
|
||||||
{
|
{
|
||||||
uint status = SLApi.InstallProductKey(pkey);
|
uint status = SLApi.InstallProductKey(pkey);
|
||||||
Logger.WriteLine(string.Format("Installing generated product key {0} status {1:X}", pkey.ToString(), status));
|
Logger.WriteLine(string.Format("Installing generated product key {0} status {1:X}", pkey, status));
|
||||||
|
|
||||||
if ((int)status < 0)
|
if ((int)status < 0)
|
||||||
{
|
{
|
||||||
@ -74,7 +74,7 @@ namespace LibTSforge.Modifiers
|
|||||||
if (pkey.Channel == "Volume:GVLK" && version == PSVersion.Win7) throw new NotSupportedException("Fake GVLK generation is not supported on Windows 7.");
|
if (pkey.Channel == "Volume:GVLK" && version == PSVersion.Win7) throw new NotSupportedException("Fake GVLK generation is not supported on Windows 7.");
|
||||||
|
|
||||||
VariableBag pkb = new VariableBag(version);
|
VariableBag pkb = new VariableBag(version);
|
||||||
pkb.Blocks.AddRange(new CRCBlockModern[]
|
pkb.Blocks.AddRange(new[]
|
||||||
{
|
{
|
||||||
new CRCBlockModern
|
new CRCBlockModern
|
||||||
{
|
{
|
||||||
@ -169,7 +169,7 @@ namespace LibTSforge.Modifiers
|
|||||||
uriMap.Data[pkeyId] = pkey.GetAlgoUri();
|
uriMap.Data[pkeyId] = pkey.GetAlgoUri();
|
||||||
tks.SetEntry(uriMapName, "xml", uriMap.Serialize());
|
tks.SetEntry(uriMapName, "xml", uriMap.Serialize());
|
||||||
|
|
||||||
string skuMetaName = actId.ToString() + metSuffix;
|
string skuMetaName = actId + metSuffix;
|
||||||
TokenMeta skuMeta = tks.GetMetaEntry(skuMetaName);
|
TokenMeta skuMeta = tks.GetMetaEntry(skuMetaName);
|
||||||
|
|
||||||
foreach (string k in skuMeta.Data.Keys)
|
foreach (string k in skuMeta.Data.Keys)
|
||||||
|
@ -2,8 +2,8 @@ namespace LibTSforge.Modifiers
|
|||||||
{
|
{
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using LibTSforge.PhysicalStore;
|
using PhysicalStore;
|
||||||
using LibTSforge.SPP;
|
using SPP;
|
||||||
|
|
||||||
public static class GracePeriodReset
|
public static class GracePeriodReset
|
||||||
{
|
{
|
||||||
|
@ -2,8 +2,8 @@ namespace LibTSforge.Modifiers
|
|||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using LibTSforge.PhysicalStore;
|
using PhysicalStore;
|
||||||
using LibTSforge.SPP;
|
using SPP;
|
||||||
|
|
||||||
public static class KMSHostCharge
|
public static class KMSHostCharge
|
||||||
{
|
{
|
||||||
@ -31,9 +31,9 @@ namespace LibTSforge.Modifiers
|
|||||||
string key = string.Format("SPPSVC\\{0}", appId);
|
string key = string.Format("SPPSVC\\{0}", appId);
|
||||||
long ldapTimestamp = DateTime.Now.ToFileTime();
|
long ldapTimestamp = DateTime.Now.ToFileTime();
|
||||||
|
|
||||||
byte[] cmidGuids = new byte[] { };
|
byte[] cmidGuids = { };
|
||||||
byte[] reqCounts = new byte[] { };
|
byte[] reqCounts = { };
|
||||||
byte[] kmsChargeData = new byte[] { };
|
byte[] kmsChargeData = { };
|
||||||
|
|
||||||
BinaryWriter writer = new BinaryWriter(new MemoryStream());
|
BinaryWriter writer = new BinaryWriter(new MemoryStream());
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ namespace LibTSforge.Modifiers
|
|||||||
if (version != PSVersion.Vista)
|
if (version != PSVersion.Vista)
|
||||||
{
|
{
|
||||||
VariableBag kmsCountData = new VariableBag(version);
|
VariableBag kmsCountData = new VariableBag(version);
|
||||||
kmsCountData.Blocks.AddRange(new CRCBlockModern[]
|
kmsCountData.Blocks.AddRange(new[]
|
||||||
{
|
{
|
||||||
new CRCBlockModern
|
new CRCBlockModern
|
||||||
{
|
{
|
||||||
|
@ -2,9 +2,8 @@ namespace LibTSforge.Modifiers
|
|||||||
{
|
{
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using LibTSforge.PhysicalStore;
|
using PhysicalStore;
|
||||||
using LibTSforge.SPP;
|
using SPP;
|
||||||
using LibTSforge;
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
public static class KeyChangeLockDelete
|
public static class KeyChangeLockDelete
|
||||||
|
@ -2,8 +2,8 @@ namespace LibTSforge.Modifiers
|
|||||||
{
|
{
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using LibTSforge.PhysicalStore;
|
using PhysicalStore;
|
||||||
using LibTSforge.SPP;
|
using SPP;
|
||||||
|
|
||||||
public static class RearmReset
|
public static class RearmReset
|
||||||
{
|
{
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using LibTSforge.PhysicalStore;
|
|
||||||
using LibTSforge.SPP;
|
|
||||||
|
|
||||||
namespace LibTSforge.Modifiers
|
namespace LibTSforge.Modifiers
|
||||||
{
|
{
|
||||||
|
using PhysicalStore;
|
||||||
|
using SPP;
|
||||||
|
using System.IO;
|
||||||
|
using System;
|
||||||
|
|
||||||
public static class SetIIDParams
|
public static class SetIIDParams
|
||||||
{
|
{
|
||||||
public static void SetParams(PSVersion version, bool production, Guid actId, PKeyAlgorithm algorithm, int group, int serial, ulong security)
|
public static void SetParams(PSVersion version, bool production, Guid actId, PKeyAlgorithm algorithm, int group, int serial, ulong security)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
namespace LibTSforge.Modifiers
|
namespace LibTSforge.Modifiers
|
||||||
{
|
{
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using LibTSforge.PhysicalStore;
|
using PhysicalStore;
|
||||||
using LibTSforge.SPP;
|
using SPP;
|
||||||
|
|
||||||
public static class TamperedFlagsDelete
|
public static class TamperedFlagsDelete
|
||||||
{
|
{
|
||||||
@ -14,7 +14,7 @@ namespace LibTSforge.Modifiers
|
|||||||
|
|
||||||
using (IPhysicalStore store = SPPUtils.GetStore(version, production))
|
using (IPhysicalStore store = SPPUtils.GetStore(version, production))
|
||||||
{
|
{
|
||||||
if (version == PSVersion.Vista)
|
if (version == PSVersion.Vista)
|
||||||
{
|
{
|
||||||
DeleteFlag(store, "6BE8425B-E3CF-4e86-A6AF-5863E3DCB606");
|
DeleteFlag(store, "6BE8425B-E3CF-4e86-A6AF-5863E3DCB606");
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
namespace LibTSforge.Modifiers
|
namespace LibTSforge.Modifiers
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
using LibTSforge.PhysicalStore;
|
using PhysicalStore;
|
||||||
using LibTSforge.SPP;
|
using SPP;
|
||||||
|
|
||||||
public static class UniqueIdDelete
|
public static class UniqueIdDelete
|
||||||
{
|
{
|
||||||
@ -27,7 +27,6 @@ namespace LibTSforge.Modifiers
|
|||||||
appId = SLApi.GetAppId(actId);
|
appId = SLApi.GetAppId(actId);
|
||||||
}
|
}
|
||||||
|
|
||||||
string instId = SLApi.GetInstallationID(actId);
|
|
||||||
Guid pkeyId = SLApi.GetInstalledPkeyID(actId);
|
Guid pkeyId = SLApi.GetInstalledPkeyID(actId);
|
||||||
|
|
||||||
SPPUtils.KillSPP(version);
|
SPPUtils.KillSPP(version);
|
||||||
|
@ -3,7 +3,7 @@ namespace LibTSforge.PhysicalStore
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using LibTSforge.Crypto;
|
using Crypto;
|
||||||
|
|
||||||
public class ModernBlock
|
public class ModernBlock
|
||||||
{
|
{
|
||||||
@ -93,7 +93,7 @@ namespace LibTSforge.PhysicalStore
|
|||||||
|
|
||||||
public sealed class PhysicalStoreModern : IPhysicalStore
|
public sealed class PhysicalStoreModern : IPhysicalStore
|
||||||
{
|
{
|
||||||
private byte[] PreHeaderBytes = new byte[] { };
|
private byte[] PreHeaderBytes = { };
|
||||||
private readonly Dictionary<string, List<ModernBlock>> Data = new Dictionary<string, List<ModernBlock>>();
|
private readonly Dictionary<string, List<ModernBlock>> Data = new Dictionary<string, List<ModernBlock>>();
|
||||||
private readonly FileStream TSFile;
|
private readonly FileStream TSFile;
|
||||||
private readonly PSVersion Version;
|
private readonly PSVersion Version;
|
||||||
@ -281,40 +281,44 @@ namespace LibTSforge.PhysicalStore
|
|||||||
|
|
||||||
public void DeleteBlock(string key, string value)
|
public void DeleteBlock(string key, string value)
|
||||||
{
|
{
|
||||||
if (Data.ContainsKey(key))
|
if (!Data.ContainsKey(key))
|
||||||
{
|
{
|
||||||
List<ModernBlock> blocks = Data[key];
|
return;
|
||||||
|
|
||||||
foreach (ModernBlock block in blocks)
|
|
||||||
{
|
|
||||||
if (block.ValueAsStr == value)
|
|
||||||
{
|
|
||||||
blocks.Remove(block);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Data[key] = blocks;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<ModernBlock> blocks = Data[key];
|
||||||
|
|
||||||
|
foreach (ModernBlock block in blocks)
|
||||||
|
{
|
||||||
|
if (block.ValueAsStr == value)
|
||||||
|
{
|
||||||
|
blocks.Remove(block);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Data[key] = blocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeleteBlock(string key, uint value)
|
public void DeleteBlock(string key, uint value)
|
||||||
{
|
{
|
||||||
if (Data.ContainsKey(key))
|
if (!Data.ContainsKey(key))
|
||||||
{
|
{
|
||||||
List<ModernBlock> blocks = Data[key];
|
return;
|
||||||
|
|
||||||
foreach (ModernBlock block in blocks)
|
|
||||||
{
|
|
||||||
if (block.ValueAsInt == value)
|
|
||||||
{
|
|
||||||
blocks.Remove(block);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Data[key] = blocks;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<ModernBlock> blocks = Data[key];
|
||||||
|
|
||||||
|
foreach (ModernBlock block in blocks)
|
||||||
|
{
|
||||||
|
if (block.ValueAsInt == value)
|
||||||
|
{
|
||||||
|
blocks.Remove(block);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Data[key] = blocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PhysicalStoreModern(string tsPath, bool production, PSVersion version)
|
public PhysicalStoreModern(string tsPath, bool production, PSVersion version)
|
||||||
|
@ -3,7 +3,7 @@ namespace LibTSforge.PhysicalStore
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using LibTSforge.Crypto;
|
using Crypto;
|
||||||
|
|
||||||
public class VistaBlock
|
public class VistaBlock
|
||||||
{
|
{
|
||||||
@ -88,7 +88,7 @@ namespace LibTSforge.PhysicalStore
|
|||||||
|
|
||||||
public sealed class PhysicalStoreVista : IPhysicalStore
|
public sealed class PhysicalStoreVista : IPhysicalStore
|
||||||
{
|
{
|
||||||
private byte[] PreHeaderBytes = new byte[] { };
|
private byte[] PreHeaderBytes = { };
|
||||||
private readonly List<VistaBlock> Blocks = new List<VistaBlock>();
|
private readonly List<VistaBlock> Blocks = new List<VistaBlock>();
|
||||||
private readonly FileStream TSPrimary;
|
private readonly FileStream TSPrimary;
|
||||||
private readonly FileStream TSSecondary;
|
private readonly FileStream TSSecondary;
|
||||||
|
@ -3,7 +3,7 @@ namespace LibTSforge.PhysicalStore
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using LibTSforge.Crypto;
|
using Crypto;
|
||||||
|
|
||||||
public class Win7Block
|
public class Win7Block
|
||||||
{
|
{
|
||||||
@ -105,7 +105,7 @@ namespace LibTSforge.PhysicalStore
|
|||||||
|
|
||||||
public sealed class PhysicalStoreWin7 : IPhysicalStore
|
public sealed class PhysicalStoreWin7 : IPhysicalStore
|
||||||
{
|
{
|
||||||
private byte[] PreHeaderBytes = new byte[] { };
|
private byte[] PreHeaderBytes = { };
|
||||||
private readonly List<Win7Block> Blocks = new List<Win7Block>();
|
private readonly List<Win7Block> Blocks = new List<Win7Block>();
|
||||||
private readonly FileStream TSPrimary;
|
private readonly FileStream TSPrimary;
|
||||||
private readonly FileStream TSSecondary;
|
private readonly FileStream TSSecondary;
|
||||||
|
@ -74,7 +74,6 @@ namespace LibTSforge.PhysicalStore
|
|||||||
public override void Decode(BinaryReader reader)
|
public override void Decode(BinaryReader reader)
|
||||||
{
|
{
|
||||||
uint type = reader.ReadUInt32();
|
uint type = reader.ReadUInt32();
|
||||||
uint unk_zero = reader.ReadUInt32();
|
|
||||||
uint lenName = reader.ReadUInt32();
|
uint lenName = reader.ReadUInt32();
|
||||||
uint lenVal = reader.ReadUInt32();
|
uint lenVal = reader.ReadUInt32();
|
||||||
uint crc = reader.ReadUInt32();
|
uint crc = reader.ReadUInt32();
|
||||||
@ -156,7 +155,7 @@ namespace LibTSforge.PhysicalStore
|
|||||||
public List<CRCBlock> Blocks = new List<CRCBlock>();
|
public List<CRCBlock> Blocks = new List<CRCBlock>();
|
||||||
private readonly PSVersion Version;
|
private readonly PSVersion Version;
|
||||||
|
|
||||||
public void Deserialize(byte[] data)
|
private void Deserialize(byte[] data)
|
||||||
{
|
{
|
||||||
int len = data.Length;
|
int len = data.Length;
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ namespace LibTSforge.SPP
|
|||||||
|
|
||||||
public class PKeyConfig
|
public class PKeyConfig
|
||||||
{
|
{
|
||||||
public Dictionary<Guid, ProductConfig> Products = new Dictionary<Guid, ProductConfig>();
|
public readonly Dictionary<Guid, ProductConfig> Products = new Dictionary<Guid, ProductConfig>();
|
||||||
private readonly List<Guid> loadedPkeyConfigs = new List<Guid>();
|
private readonly List<Guid> loadedPkeyConfigs = new List<Guid>();
|
||||||
|
|
||||||
public void LoadConfig(Guid actId)
|
public void LoadConfig(Guid actId)
|
||||||
@ -210,10 +210,5 @@ namespace LibTSforge.SPP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PKeyConfig()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@ namespace LibTSforge.SPP
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using LibTSforge.Crypto;
|
using Crypto;
|
||||||
using LibTSforge.PhysicalStore;
|
using PhysicalStore;
|
||||||
|
|
||||||
public class ProductKey
|
public class ProductKey
|
||||||
{
|
{
|
||||||
@ -18,11 +18,11 @@ namespace LibTSforge.SPP
|
|||||||
public ulong Security;
|
public ulong Security;
|
||||||
public bool Upgrade;
|
public bool Upgrade;
|
||||||
public PKeyAlgorithm Algorithm;
|
public PKeyAlgorithm Algorithm;
|
||||||
public string EulaType;
|
public readonly string EulaType;
|
||||||
public string PartNumber;
|
public readonly string PartNumber;
|
||||||
public string Edition;
|
public readonly string Edition;
|
||||||
public string Channel;
|
public readonly string Channel;
|
||||||
public Guid ActivationId;
|
public readonly Guid ActivationId;
|
||||||
|
|
||||||
private string mpc;
|
private string mpc;
|
||||||
private string pid2;
|
private string pid2;
|
||||||
@ -66,7 +66,7 @@ namespace LibTSforge.SPP
|
|||||||
public Guid GetPkeyId()
|
public Guid GetPkeyId()
|
||||||
{
|
{
|
||||||
VariableBag pkb = new VariableBag(PSVersion.WinModern);
|
VariableBag pkb = new VariableBag(PSVersion.WinModern);
|
||||||
pkb.Blocks.AddRange(new CRCBlockModern[]
|
pkb.Blocks.AddRange(new[]
|
||||||
{
|
{
|
||||||
new CRCBlockModern
|
new CRCBlockModern
|
||||||
{
|
{
|
||||||
@ -91,16 +91,6 @@ namespace LibTSforge.SPP
|
|||||||
return new Guid(CryptoUtils.SHA256Hash(pkb.Serialize()).Take(16).ToArray());
|
return new Guid(CryptoUtils.SHA256Hash(pkb.Serialize()).Take(16).ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetDefaultMPC()
|
|
||||||
{
|
|
||||||
int build = Environment.OSVersion.Version.Build;
|
|
||||||
string defaultMPC = build >= 10240 ? "03612" :
|
|
||||||
build >= 9600 ? "06401" :
|
|
||||||
build >= 9200 ? "05426" :
|
|
||||||
"55041";
|
|
||||||
return defaultMPC;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetMPC()
|
public string GetMPC()
|
||||||
{
|
{
|
||||||
if (mpc != null)
|
if (mpc != null)
|
||||||
@ -108,10 +98,15 @@ namespace LibTSforge.SPP
|
|||||||
return mpc;
|
return mpc;
|
||||||
}
|
}
|
||||||
|
|
||||||
mpc = GetDefaultMPC();
|
int build = Environment.OSVersion.Version.Build;
|
||||||
|
|
||||||
|
mpc = build >= 10240 ? "03612" :
|
||||||
|
build >= 9600 ? "06401" :
|
||||||
|
build >= 9200 ? "05426" :
|
||||||
|
"55041";
|
||||||
|
|
||||||
// setup.cfg doesn't exist in Windows 8+
|
// setup.cfg doesn't exist in Windows 8+
|
||||||
string setupcfg = string.Format("{0}\\oobe\\{1}", Environment.SystemDirectory, "setup.cfg");
|
string setupcfg = string.Format(@"{0}\oobe\{1}", Environment.SystemDirectory, "setup.cfg");
|
||||||
|
|
||||||
if (!File.Exists(setupcfg) || Edition.Contains(";"))
|
if (!File.Exists(setupcfg) || Edition.Contains(";"))
|
||||||
{
|
{
|
||||||
@ -249,7 +244,7 @@ namespace LibTSforge.SPP
|
|||||||
{
|
{
|
||||||
if (version == PSVersion.Win7)
|
if (version == PSVersion.Win7)
|
||||||
{
|
{
|
||||||
ulong shortauth = ((ulong)Group << 41) | ((ulong)Security << 31) | ((ulong)Serial << 1) | (Upgrade ? (ulong)1 : 0);
|
ulong shortauth = ((ulong)Group << 41) | (Security << 31) | ((ulong)Serial << 1) | (Upgrade ? (ulong)1 : 0);
|
||||||
return BitConverter.GetBytes(shortauth);
|
return BitConverter.GetBytes(shortauth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,9 +86,6 @@ namespace LibTSforge.SPP
|
|||||||
[DllImport("slc.dll", CharSet = CharSet.Unicode)]
|
[DllImport("slc.dll", CharSet = CharSet.Unicode)]
|
||||||
private static extern uint SLGetProductSkuInformation(IntPtr hSLC, ref Guid pProductSkuId, string pwszValueName, out SLDATATYPE peDataType, out uint pcbValue, out IntPtr ppbValue);
|
private static extern uint SLGetProductSkuInformation(IntPtr hSLC, ref Guid pProductSkuId, string pwszValueName, out SLDATATYPE peDataType, out uint pcbValue, out IntPtr ppbValue);
|
||||||
|
|
||||||
[DllImport("slc.dll", CharSet = CharSet.Unicode)]
|
|
||||||
private static extern uint SLGetProductSkuInformation(IntPtr hSLC, ref Guid pProductSkuId, string pwszValueName, IntPtr peDataType, out uint pcbValue, out IntPtr ppbValue);
|
|
||||||
|
|
||||||
[DllImport("slc.dll", CharSet = CharSet.Unicode)]
|
[DllImport("slc.dll", CharSet = CharSet.Unicode)]
|
||||||
private static extern uint SLGetLicense(IntPtr hSLC, ref Guid pLicenseFileId, out uint pcbLicenseFile, out IntPtr ppbLicenseFile);
|
private static extern uint SLGetLicense(IntPtr hSLC, ref Guid pLicenseFileId, out uint pcbLicenseFile, out IntPtr ppbLicenseFile);
|
||||||
|
|
||||||
@ -98,7 +95,7 @@ namespace LibTSforge.SPP
|
|||||||
[DllImport("slc.dll", CharSet = CharSet.Unicode)]
|
[DllImport("slc.dll", CharSet = CharSet.Unicode)]
|
||||||
private static extern uint SLFireEvent(IntPtr hSLC, string pwszEventId, ref Guid pApplicationId);
|
private static extern uint SLFireEvent(IntPtr hSLC, string pwszEventId, ref Guid pApplicationId);
|
||||||
|
|
||||||
public class SLContext : IDisposable
|
private class SLContext : IDisposable
|
||||||
{
|
{
|
||||||
public readonly IntPtr Handle;
|
public readonly IntPtr Handle;
|
||||||
|
|
||||||
@ -161,11 +158,10 @@ namespace LibTSforge.SPP
|
|||||||
{
|
{
|
||||||
using (SLContext sl = new SLContext())
|
using (SLContext sl = new SLContext())
|
||||||
{
|
{
|
||||||
uint status;
|
|
||||||
uint count;
|
uint count;
|
||||||
IntPtr pProductKeyIds;
|
IntPtr pProductKeyIds;
|
||||||
|
|
||||||
status = SLGetSLIDList(sl.Handle, SLIDTYPE.SL_ID_PRODUCT_SKU, ref actId, SLIDTYPE.SL_ID_PKEY, out count, out pProductKeyIds);
|
uint status = SLGetSLIDList(sl.Handle, SLIDTYPE.SL_ID_PRODUCT_SKU, ref actId, SLIDTYPE.SL_ID_PKEY, out count, out pProductKeyIds);
|
||||||
|
|
||||||
if (status != 0 || count == 0)
|
if (status != 0 || count == 0)
|
||||||
{
|
{
|
||||||
@ -189,7 +185,7 @@ namespace LibTSforge.SPP
|
|||||||
SLConsumeWindowsRight(0);
|
SLConsumeWindowsRight(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool RefreshTrustedTime(Guid actId)
|
public static void RefreshTrustedTime(Guid actId)
|
||||||
{
|
{
|
||||||
using (SLContext sl = new SLContext())
|
using (SLContext sl = new SLContext())
|
||||||
{
|
{
|
||||||
@ -197,8 +193,7 @@ namespace LibTSforge.SPP
|
|||||||
uint count;
|
uint count;
|
||||||
IntPtr ppbValue;
|
IntPtr ppbValue;
|
||||||
|
|
||||||
uint status = SLGetProductSkuInformation(sl.Handle, ref actId, "TrustedTime", out type, out count, out ppbValue);
|
SLGetProductSkuInformation(sl.Handle, ref actId, "TrustedTime", out type, out count, out ppbValue);
|
||||||
return (int)status >= 0 && status != 0xC004F012;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,11 +209,10 @@ namespace LibTSforge.SPP
|
|||||||
{
|
{
|
||||||
using (SLContext sl = new SLContext())
|
using (SLContext sl = new SLContext())
|
||||||
{
|
{
|
||||||
uint status;
|
|
||||||
uint count;
|
uint count;
|
||||||
IntPtr pAppIds;
|
IntPtr pAppIds;
|
||||||
|
|
||||||
status = SLGetSLIDList(sl.Handle, SLIDTYPE.SL_ID_PRODUCT_SKU, ref actId, SLIDTYPE.SL_ID_APPLICATION, out count, out pAppIds);
|
uint status = SLGetSLIDList(sl.Handle, SLIDTYPE.SL_ID_PRODUCT_SKU, ref actId, SLIDTYPE.SL_ID_APPLICATION, out count, out pAppIds);
|
||||||
|
|
||||||
if (status != 0 || count == 0)
|
if (status != 0 || count == 0)
|
||||||
{
|
{
|
||||||
@ -246,11 +240,10 @@ namespace LibTSforge.SPP
|
|||||||
{
|
{
|
||||||
using (SLContext sl = new SLContext())
|
using (SLContext sl = new SLContext())
|
||||||
{
|
{
|
||||||
uint status;
|
|
||||||
uint count;
|
uint count;
|
||||||
IntPtr ppReturnLics;
|
IntPtr ppReturnLics;
|
||||||
|
|
||||||
status = SLGetSLIDList(sl.Handle, SLIDTYPE.SL_ID_LICENSE, ref licId, SLIDTYPE.SL_ID_LICENSE_FILE, out count, out ppReturnLics);
|
uint status = SLGetSLIDList(sl.Handle, SLIDTYPE.SL_ID_LICENSE, ref licId, SLIDTYPE.SL_ID_LICENSE_FILE, out count, out ppReturnLics);
|
||||||
|
|
||||||
if (status != 0 || count == 0)
|
if (status != 0 || count == 0)
|
||||||
{
|
{
|
||||||
@ -312,7 +305,7 @@ namespace LibTSforge.SPP
|
|||||||
IntPtr ppbValue;
|
IntPtr ppbValue;
|
||||||
|
|
||||||
uint status = SLGetProductSkuInformation(sl.Handle, ref actId, "msft:sl/EUL/PHONE/PUBLIC", out type, out count, out ppbValue);
|
uint status = SLGetProductSkuInformation(sl.Handle, ref actId, "msft:sl/EUL/PHONE/PUBLIC", out type, out count, out ppbValue);
|
||||||
return status >= 0 && status != 0xC004F012;
|
return status != 0xC004F012;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -395,11 +388,11 @@ namespace LibTSforge.SPP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static uint UninstallProductKey(Guid pkeyId)
|
public static void UninstallProductKey(Guid pkeyId)
|
||||||
{
|
{
|
||||||
using (SLContext sl = new SLContext())
|
using (SLContext sl = new SLContext())
|
||||||
{
|
{
|
||||||
return SLUninstallProofOfPurchase(sl.Handle, ref pkeyId);
|
SLUninstallProofOfPurchase(sl.Handle, ref pkeyId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
namespace LibTSforge.SPP
|
namespace LibTSforge.SPP
|
||||||
{
|
{
|
||||||
using LibTSforge.Crypto;
|
|
||||||
using LibTSforge.PhysicalStore;
|
|
||||||
using LibTSforge.TokenStore;
|
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.ServiceProcess;
|
using System.ServiceProcess;
|
||||||
|
using Crypto;
|
||||||
|
using PhysicalStore;
|
||||||
|
using TokenStore;
|
||||||
|
|
||||||
public static class SPPUtils
|
public static class SPPUtils
|
||||||
{
|
{
|
||||||
@ -328,7 +328,7 @@ namespace LibTSforge.SPP
|
|||||||
|
|
||||||
RestartSPP(version);
|
RestartSPP(version);
|
||||||
|
|
||||||
Logger.WriteLine("Loaded store file succesfully.");
|
Logger.WriteLine("Loaded store file successfully.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ namespace LibTSforge.SPP
|
|||||||
|
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||||
public static extern bool DeviceIoControl([In] SafeFileHandle hDevice, [In] uint dwIoControlCode, [In] IntPtr lpInBuffer, [In] int nInBufferSize, [Out] IntPtr lpOutBuffer, [In] int nOutBufferSize, out int lpBytesReturned, [In] IntPtr lpOverlapped);
|
private static extern bool DeviceIoControl([In] SafeFileHandle hDevice, [In] uint dwIoControlCode, [In] IntPtr lpInBuffer, [In] int nInBufferSize, [Out] IntPtr lpOutBuffer, [In] int nOutBufferSize, out int lpBytesReturned, [In] IntPtr lpOverlapped);
|
||||||
|
|
||||||
public static bool IsSpSysRunning()
|
public static bool IsSpSysRunning()
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,7 @@ namespace LibTSforge.TokenStore
|
|||||||
public class TokenMeta
|
public class TokenMeta
|
||||||
{
|
{
|
||||||
public string Name;
|
public string Name;
|
||||||
public Dictionary<string, string> Data = new Dictionary<string, string>();
|
public readonly Dictionary<string, string> Data = new Dictionary<string, string>();
|
||||||
|
|
||||||
public byte[] Serialize()
|
public byte[] Serialize()
|
||||||
{
|
{
|
||||||
@ -37,7 +37,7 @@ namespace LibTSforge.TokenStore
|
|||||||
return writer.GetBytes();
|
return writer.GetBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Deserialize(byte[] data)
|
private void Deserialize(byte[] data)
|
||||||
{
|
{
|
||||||
BinaryReader reader = new BinaryReader(new MemoryStream(data));
|
BinaryReader reader = new BinaryReader(new MemoryStream(data));
|
||||||
reader.ReadInt32();
|
reader.ReadInt32();
|
||||||
|
@ -4,7 +4,7 @@ namespace LibTSforge.TokenStore
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using LibTSforge.Crypto;
|
using Crypto;
|
||||||
|
|
||||||
public class TokenStoreModern : ITokenStore
|
public class TokenStoreModern : ITokenStore
|
||||||
{
|
{
|
||||||
@ -18,7 +18,7 @@ namespace LibTSforge.TokenStore
|
|||||||
private static readonly byte[] CONTS_FOOTER = Enumerable.Repeat((byte)0xAA, 0x20).ToArray();
|
private static readonly byte[] CONTS_FOOTER = Enumerable.Repeat((byte)0xAA, 0x20).ToArray();
|
||||||
|
|
||||||
private List<TokenEntry> Entries = new List<TokenEntry>();
|
private List<TokenEntry> Entries = new List<TokenEntry>();
|
||||||
public FileStream TokensFile;
|
private readonly FileStream TokensFile;
|
||||||
|
|
||||||
public void Deserialize()
|
public void Deserialize()
|
||||||
{
|
{
|
||||||
@ -40,7 +40,7 @@ namespace LibTSforge.TokenStore
|
|||||||
uint contentOffset = reader.ReadUInt32();
|
uint contentOffset = reader.ReadUInt32();
|
||||||
uint contentLength = reader.ReadUInt32();
|
uint contentLength = reader.ReadUInt32();
|
||||||
uint allocLength = reader.ReadUInt32();
|
uint allocLength = reader.ReadUInt32();
|
||||||
byte[] contentData = new byte[] { };
|
byte[] contentData = { };
|
||||||
|
|
||||||
if (populated)
|
if (populated)
|
||||||
{
|
{
|
||||||
@ -140,11 +140,10 @@ namespace LibTSforge.TokenStore
|
|||||||
writer.WritePadding(BLOCK_PAD_SIZE);
|
writer.WritePadding(BLOCK_PAD_SIZE);
|
||||||
|
|
||||||
writer.BaseStream.Seek(curBlockOffset, SeekOrigin.Begin);
|
writer.BaseStream.Seek(curBlockOffset, SeekOrigin.Begin);
|
||||||
byte[] blockHash;
|
|
||||||
byte[] blockData = new byte[BLOCK_SIZE - 0x20];
|
byte[] blockData = new byte[BLOCK_SIZE - 0x20];
|
||||||
|
|
||||||
tokens.Read(blockData, 0, BLOCK_SIZE - 0x20);
|
tokens.Read(blockData, 0, BLOCK_SIZE - 0x20);
|
||||||
blockHash = CryptoUtils.SHA256Hash(blockData);
|
byte[] blockHash = CryptoUtils.SHA256Hash(blockData);
|
||||||
|
|
||||||
writer.BaseStream.Seek(curBlockOffset + BLOCK_SIZE - 0x20, SeekOrigin.Begin);
|
writer.BaseStream.Seek(curBlockOffset + BLOCK_SIZE - 0x20, SeekOrigin.Begin);
|
||||||
writer.Write(blockHash);
|
writer.Write(blockHash);
|
||||||
@ -275,11 +274,6 @@ namespace LibTSforge.TokenStore
|
|||||||
Deserialize();
|
Deserialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TokenStoreModern()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Serialize();
|
Serialize();
|
||||||
|
@ -10,30 +10,30 @@ namespace TSforgeCLI
|
|||||||
{
|
{
|
||||||
private class Options
|
private class Options
|
||||||
{
|
{
|
||||||
public bool Dump = false;
|
public bool Dump;
|
||||||
public string DumpFilePath = "dump.dat";
|
public string DumpFilePath = "dump.dat";
|
||||||
public string EncrFilePath = null;
|
public string EncrFilePath;
|
||||||
public bool Load = false;
|
public bool Load;
|
||||||
public string LoadFilePath = "load.dat";
|
public string LoadFilePath = "load.dat";
|
||||||
public bool KMS4k = false;
|
public bool KMS4k;
|
||||||
public bool AVMA4k = false;
|
public bool AVMA4k;
|
||||||
public bool ZCID = false;
|
public bool ZCID;
|
||||||
public bool TimerReset = false;
|
public bool TimerReset;
|
||||||
public bool RearmReset = false;
|
public bool RearmReset;
|
||||||
public bool DeleteUniqueId = false;
|
public bool DeleteUniqueId;
|
||||||
public bool InstallGenPKey = false;
|
public bool InstallGenPKey;
|
||||||
public bool KMSHostCharge = false;
|
public bool KMSHostCharge;
|
||||||
public bool TamperedFlagsDelete = false;
|
public bool TamperedFlagsDelete;
|
||||||
public bool KeyChangeLockDelete = false;
|
public bool KeyChangeLockDelete;
|
||||||
public bool SetIIDParams = false;
|
public bool SetIIDParams;
|
||||||
public bool? Production = null;
|
public bool? Production;
|
||||||
public PSVersion? Version = null;
|
public PSVersion? Version;
|
||||||
public Guid ActivationId = Guid.Empty;
|
public Guid ActivationId = Guid.Empty;
|
||||||
public bool ShowHelp = false;
|
public bool ShowHelp;
|
||||||
public PKeyAlgorithm? Algorithm = null;
|
public PKeyAlgorithm? Algorithm;
|
||||||
public int Group = 0;
|
public int Group;
|
||||||
public int Serial = 0;
|
public int Serial;
|
||||||
public ulong Security = 0;
|
public ulong Security;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user