Yeah you can just increase the values until it works, allthough i think the C++ uses all proper lengths, no need to gamble
ill mess around with it then ill tell you what happens i was thinking instead of a number like 40 or 60 there put a variable then have it parse the data differently for every key
Code: Dim pid As String = enc.GetString(pidb).Replace(vbNullChar, "") 'PID Dim epid As String = enc.GetString(core, 8, 96).Replace(vbNullChar, "") 'Extendend PID Dim aid As String = enc.GetString(core, 136, 72).Replace(vbNullChar, "") 'Activation ID Dim edi As String = enc.GetString(core, 280, 256).Replace(vbNullChar, "") 'Edition Dim As String = enc.GetString(core, 888, 64).Replace(vbNullChar, "") 'SubType Dim lit As String = enc.GetString(core, 1016, 64).Replace(vbNullChar, "") 'License Type Dim lic As String = enc.GetString(core, 1144, 64).Replace(vbNullChar, "") 'License Channel Dim cid As String = epid.Substring(8, 3) 'Crypto ID Editing it like above seems to work as well how are the hex values for the C# version calculated? do i overlook something, or what? just don't get it i guess...
that works fine for me i dont know how its done in C# MasterDisaster is the one to ask im the vb.net guy
The C# version seems to have been off a liitle sinse the beginning, guess that is what was putting me on the wrong track Code: string pid = enc.GetString(gpid).Replace("\0", ""); //PID string eid = enc.GetString(npid, 0x08, 0x68).Replace("\0", ""); //Extendend PID string aid = enc.GetString(npid, 0x88, 0x48).Replace("\0", ""); //Activation ID string edi = enc.GetString(npid, 0x118, 0x18).Replace("\0", ""); //Edition Type string sub = enc.GetString(npid, 0x378, 0x18).Replace("\0", ""); //Edition ID string lit = enc.GetString(npid, 0x3F8, 0x18).Replace("\0", ""); //Key Type string lic = enc.GetString(npid, 0x478, 0x10).Replace("\0", ""); //EULA string cid = eid.Substring(8, 3); //Crypto ID Code: string pid = enc.GetString(gpid).Replace("\0", ""); //PID string eid = enc.GetString(npid, 0x08, 0x60).Replace("\0", ""); //Extendend PID string aid = enc.GetString(npid, 0x88, 0x48).Replace("\0", ""); //Activation ID string edi = enc.GetString(npid, 0x118, 0x100).Replace("\0", ""); //Edition Type string sub = enc.GetString(npid, 0x378, 0x40).Replace("\0", ""); //Edition ID string lit = enc.GetString(npid, 0x3F8, 0x40).Replace("\0", ""); //Key Type string lic = enc.GetString(npid, 0x478, 0x40).Replace("\0", ""); //EULA string cid = eid.Substring(8, 3); //Crypto ID
I came up with those values by viewing the DigitalProductId4 key in the registry. The C++ struct values seem to be safe. The string "ServerMediumBusinessManagement" seems to be the longest string for the EditionID, so instead of assigning 256 bytes that can hold 128 chars we can assign 64 bytes that can hold 32 chars. For the SubType it is enough to assign 18 bytes because it is of fixed length "X15-39278". The License Channel and License Type do not require 64 bytes, 32 bytes would be enough. Extended PID - 96 0x60 Activation ID - 72 0x48 Edition ID - 64 0x32 Sub Type - 18 0x12 License Channel - 32 0x20 Licence Type - 32 0x20
@MasterDisaster, License Channel it to short as well, eg 'Retail:TB:Eval' is shortened to 'Retail:TB:Ev' Anyway, i believe the C++ code uses proper lengths, so i gonna use that values
This function returns a null terminated string Code: static string GetString(byte[] bytes, int index) { int n = index; while (!(bytes[n] == 0 && bytes[n + 1] == 0)) n++; return Encoding.ASCII.GetString(bytes, index, n - index).Replace("\0", ""); } Replace your existing code with this one. Looks a bit cleaner than the previous one. Code: string pid = GetString(gpid, 0x0000); string eid = GetString(npid, 0x0008); string aid = GetString(npid, 0x0088); string edi = GetString(npid, 0x0118); string sub = GetString(npid, 0x0378); string lit = GetString(npid, 0x03F8); string lic = GetString(npid, 0x0478); string cid = eid.Substring(8, 3);