Update confid.cpp

This commit is contained in:
TheTank20 2024-04-13 18:43:32 +00:00 committed by GitHub
parent 2bc3503fd8
commit c965b88113
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 31 additions and 25 deletions

View File

@ -773,7 +773,7 @@ void ConfirmationID::Unmix(unsigned char* buffer, size_t bufSize, const unsigned
}
}
int ConfirmationID::Generate(const char* installation_id_str, char confirmation_id[49], int mode, std::string productid)
int ConfirmationID::Generate(const char* installation_id_str, char confirmation_id[49], int mode, std::string productid, bool overrideVersion)
{
int version;
unsigned char hardwareID[8];
@ -870,8 +870,8 @@ int ConfirmationID::Generate(const char* installation_id_str, char confirmation_
iid_key[3] = 0xF3;
}
Unmix(installation_id, totalCount == 41 ? 17 : 19, iid_key, 4);
//if (installation_id[18] >= 0x10)
// return ERR_UNKNOWN_VERSION;
if (installation_id[18] >= 0x10 && overrideVersion == false)
return ERR_UNKNOWN_VERSION;
#pragma pack(push, 1)
struct {
@ -891,32 +891,38 @@ int ConfirmationID::Generate(const char* installation_id_str, char confirmation_
productID[2] = (parsed.ProductIDLow >> 27) & ((1 << 24) - 1);
version = (parsed.ProductIDLow >> 51) & 15;
productID[3] = (parsed.ProductIDLow >> 55) | (parsed.ProductIDHigh << 9);
//switch (activationMode) {
// case 0:
// if (version != (totalCount == 41 ? 9 : 10))
// return ERR_UNKNOWN_VERSION;
// break;
// case 1:
// if (version != 1)
// return ERR_UNKNOWN_VERSION;
// break;
// case 3:
// if (version != 4)
// return ERR_UNKNOWN_VERSION;
//}
if (overrideVersion == false) {
switch (activationMode) {
case 0:
if (version != (totalCount == 41 ? 9 : 10))
return ERR_UNKNOWN_VERSION;
break;
case 1:
if (version != 1)
return ERR_UNKNOWN_VERSION;
break;
case 3:
if (version != 4)
return ERR_UNKNOWN_VERSION;
}
}
break;
case 2:
case 3:
decode_iid_new_version(installation_id, hardwareID, &version);
//switch (activationMode) {
// case 2:
// if (version != 3)
// return ERR_UNKNOWN_VERSION;
// break;
// case 3:
// if (version != 4)
// return ERR_UNKNOWN_VERSION;
//}
if (overrideVersion == false) {
switch (activationMode) {
case 2:
if (version != 3)
return ERR_UNKNOWN_VERSION;
break;
case 3:
if (version != 4)
return ERR_UNKNOWN_VERSION;
break;
}
}
memcpy(&parsed, hardwareID, 8);
productID[0] = stoi(productid.substr(0,5));
std::string channelid = productid.substr(6,3);