Add kmsc support for vista
This commit is contained in:
parent
74cce5e941
commit
4c7c58e62d
@ -9,8 +9,6 @@ namespace LibTSforge.Modifiers
|
|||||||
{
|
{
|
||||||
public static void Charge(PSVersion version, bool production, Guid actId)
|
public static void Charge(PSVersion version, bool production, Guid actId)
|
||||||
{
|
{
|
||||||
if (version == PSVersion.Vista) throw new NotSupportedException("This feature is not supported on Windows Vista/Server 2008.");
|
|
||||||
|
|
||||||
if (actId == Guid.Empty)
|
if (actId == Guid.Empty)
|
||||||
{
|
{
|
||||||
actId = SLApi.GetDefaultActivationID(SLApi.WINDOWS_APP_ID, true);
|
actId = SLApi.GetDefaultActivationID(SLApi.WINDOWS_APP_ID, true);
|
||||||
@ -33,76 +31,113 @@ 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[] reqCounts = new byte[] { };
|
||||||
|
byte[] kmsChargeData = new byte[] { };
|
||||||
|
|
||||||
BinaryWriter writer = new BinaryWriter(new MemoryStream());
|
BinaryWriter writer = new BinaryWriter(new MemoryStream());
|
||||||
|
|
||||||
for (int i = 0; i < currClients; i++)
|
if (version == PSVersion.Vista)
|
||||||
{
|
{
|
||||||
writer.Write(ldapTimestamp - (10 * (i + 1)));
|
writer.Write(new byte[44]);
|
||||||
writer.Write(Guid.NewGuid().ToByteArray());
|
writer.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
|
writer.Write(totalClients);
|
||||||
|
writer.Write(43200);
|
||||||
|
writer.Write(32);
|
||||||
|
|
||||||
|
writer.Seek(20, SeekOrigin.Begin);
|
||||||
|
writer.Write((byte)currClients);
|
||||||
|
|
||||||
|
writer.Seek(32, SeekOrigin.Begin);
|
||||||
|
writer.Write((byte)currClients);
|
||||||
|
|
||||||
|
writer.Seek(0, SeekOrigin.End);
|
||||||
|
|
||||||
|
for (int i = 0; i < currClients; i++)
|
||||||
|
{
|
||||||
|
writer.Write(Guid.NewGuid().ToByteArray());
|
||||||
|
writer.Write(ldapTimestamp - (10 * (i + 1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
kmsChargeData = writer.GetBytes();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 0; i < currClients; i++)
|
||||||
|
{
|
||||||
|
writer.Write(ldapTimestamp - (10 * (i + 1)));
|
||||||
|
writer.Write(Guid.NewGuid().ToByteArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
cmidGuids = writer.GetBytes();
|
||||||
|
|
||||||
|
writer = new BinaryWriter(new MemoryStream());
|
||||||
|
|
||||||
|
writer.Write(new byte[40]);
|
||||||
|
|
||||||
|
writer.Seek(4, SeekOrigin.Begin);
|
||||||
|
writer.Write((byte)currClients);
|
||||||
|
|
||||||
|
writer.Seek(24, SeekOrigin.Begin);
|
||||||
|
writer.Write((byte)currClients);
|
||||||
|
|
||||||
|
reqCounts = writer.GetBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] cmidGuids = writer.GetBytes();
|
|
||||||
|
|
||||||
writer = new BinaryWriter(new MemoryStream());
|
|
||||||
|
|
||||||
writer.Write(new byte[40]);
|
|
||||||
|
|
||||||
writer.Seek(4, SeekOrigin.Begin);
|
|
||||||
writer.Write((byte)currClients);
|
|
||||||
|
|
||||||
writer.Seek(24, SeekOrigin.Begin);
|
|
||||||
writer.Write((byte)currClients);
|
|
||||||
byte[] reqCounts = writer.GetBytes();
|
|
||||||
|
|
||||||
SPPUtils.KillSPP(version);
|
SPPUtils.KillSPP(version);
|
||||||
|
|
||||||
Logger.WriteLine("Writing TrustedStore data...");
|
Logger.WriteLine("Writing TrustedStore data...");
|
||||||
|
|
||||||
using (IPhysicalStore store = SPPUtils.GetStore(version, production))
|
using (IPhysicalStore store = SPPUtils.GetStore(version, production))
|
||||||
{
|
{
|
||||||
VariableBag kmsCountData = new VariableBag(version);
|
if (version != PSVersion.Vista)
|
||||||
kmsCountData.Blocks.AddRange(new CRCBlockModern[]
|
|
||||||
{
|
{
|
||||||
new CRCBlockModern
|
VariableBag kmsCountData = new VariableBag(version);
|
||||||
|
kmsCountData.Blocks.AddRange(new CRCBlockModern[]
|
||||||
{
|
{
|
||||||
DataType = CRCBlockType.BINARY,
|
new CRCBlockModern
|
||||||
KeyAsStr = "SppBindingLicenseData",
|
{
|
||||||
Value = hwidBlock
|
DataType = CRCBlockType.BINARY,
|
||||||
},
|
KeyAsStr = "SppBindingLicenseData",
|
||||||
new CRCBlockModern
|
Value = hwidBlock
|
||||||
{
|
},
|
||||||
DataType = CRCBlockType.UINT,
|
new CRCBlockModern
|
||||||
Key = new byte[] { },
|
{
|
||||||
ValueAsInt = (uint)totalClients
|
DataType = CRCBlockType.UINT,
|
||||||
},
|
Key = new byte[] { },
|
||||||
new CRCBlockModern
|
ValueAsInt = (uint)totalClients
|
||||||
{
|
},
|
||||||
DataType = CRCBlockType.UINT,
|
new CRCBlockModern
|
||||||
Key = new byte[] { },
|
{
|
||||||
ValueAsInt = 1051200000
|
DataType = CRCBlockType.UINT,
|
||||||
},
|
Key = new byte[] { },
|
||||||
new CRCBlockModern
|
ValueAsInt = 1051200000
|
||||||
{
|
},
|
||||||
DataType = CRCBlockType.UINT,
|
new CRCBlockModern
|
||||||
Key = new byte[] { },
|
{
|
||||||
ValueAsInt = (uint)currClients
|
DataType = CRCBlockType.UINT,
|
||||||
},
|
Key = new byte[] { },
|
||||||
new CRCBlockModern
|
ValueAsInt = (uint)currClients
|
||||||
{
|
},
|
||||||
DataType = CRCBlockType.BINARY,
|
new CRCBlockModern
|
||||||
Key = new byte[] { },
|
{
|
||||||
Value = cmidGuids
|
DataType = CRCBlockType.BINARY,
|
||||||
},
|
Key = new byte[] { },
|
||||||
new CRCBlockModern
|
Value = cmidGuids
|
||||||
{
|
},
|
||||||
DataType = CRCBlockType.BINARY,
|
new CRCBlockModern
|
||||||
Key = new byte[] { },
|
{
|
||||||
Value = reqCounts
|
DataType = CRCBlockType.BINARY,
|
||||||
}
|
Key = new byte[] { },
|
||||||
});
|
Value = reqCounts
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
byte[] kmsChargeData = kmsCountData.Serialize();
|
kmsChargeData = kmsCountData.Serialize();
|
||||||
string countVal = string.Format("msft:spp/kms/host/2.0/store/counters/{0}", appId);
|
}
|
||||||
|
|
||||||
|
string countVal = version == PSVersion.Vista ? "C8F6FFF1-79CE-404C-B150-F97991273DF1" : string.Format("msft:spp/kms/host/2.0/store/counters/{0}", appId);
|
||||||
|
|
||||||
store.DeleteBlock(key, countVal);
|
store.DeleteBlock(key, countVal);
|
||||||
store.AddBlock(new PSBlock
|
store.AddBlock(new PSBlock
|
||||||
@ -116,6 +151,8 @@ namespace LibTSforge.Modifiers
|
|||||||
|
|
||||||
Logger.WriteLine(string.Format("Set charge count to {0} successfully.", currClients));
|
Logger.WriteLine(string.Format("Set charge count to {0} successfully.", currClients));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SPPUtils.RestartSPP(version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user