From 25db955b615efe2cba35070655a1533a4d820f86 Mon Sep 17 00:00:00 2001
From: pottzman <pottzman@hotmail.com>
Date: Wed, 6 Sep 2023 22:56:28 +1000
Subject: [PATCH] Update confid.cpp

---
 src/libumskt/confid/confid.cpp | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/libumskt/confid/confid.cpp b/src/libumskt/confid/confid.cpp
index 64bbd65..e460aee 100644
--- a/src/libumskt/confid/confid.cpp
+++ b/src/libumskt/confid/confid.cpp
@@ -924,13 +924,6 @@ int ConfirmationID::Generate(const char* installation_id_str, char confirmation_
 		case 2:
 		case 3:
 			decode_iid_new_version(installation_id, hardwareID, &version);
-			productID[0] = stoi(productid.substr(0,5));
-			int channelID = stoi(productid.substr(6,3));
-			if (channelID == 0) {
-				productID[3] = ((stoi(productid.substr(10,2))) * 1000) + productID[3];
-			} else {
-				productID[3] = ((stoi(productid.substr(18,2))) * 1000) + productID[3];
-			}
 			switch (activationMode) {
 				case 2:
 					if (version != 3)
@@ -941,7 +934,18 @@ int ConfirmationID::Generate(const char* installation_id_str, char confirmation_
 						return ERR_UNKNOWN_VERSION;
 			}
 			memcpy(&parsed, hardwareID, 8);
-			break;
+			productID[0] = stoi(productid.substr(0,5));
+			std::string channelid = productid.substr(6,3);
+			char *p = &channelid[0];
+			for (; *p; p++) {
+				*p = toupper((unsigned char)*p);
+			}
+			p = &channelid[0];
+			if (strcmp(p, "OEM") == 0) {
+				productID[3] = ((stoi(productid.substr(10,2))) * 1000) + productID[3];
+			} else {
+				productID[3] = ((stoi(productid.substr(18,2))) * 1000) + productID[3];
+			}
 	}
 	
 	unsigned char keybuf[16];