mirror of
https://github.com/Neo-Desktop/WindowsXPKg
synced 2026-11-02 14:53:19 +02:00
* windows 98/nt4, slopped openssl away * one (1) roadblock that it can't figure out * fixed maybe * fix dos? * fix dos? (2) * ts is gonna be slow * No need to compress anymore * No need to compress anymore (2) * deslop The main problem with AI models, even today, is that they're very shortsighted. They're too focused on the thing working now than thinking about how maintainable it will be later. As such, you get duplicated code, as well as comments that are geared towards what it's doing right then and there (as if it's an advertisement of it's services) rather than improving the readability of the code. Always check your diffs. * Update workflows * Update freebsd.yml * Update README.md
154 lines
3.4 KiB
C++
154 lines
3.4 KiB
C++
/**
|
|
* This file is a part of the UMSKT Project
|
|
*
|
|
* Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
* @FileCreated by Neo on 06/17/2023
|
|
* @Maintainer Neo
|
|
*/
|
|
|
|
#include "PIDGEN2.h"
|
|
|
|
static int parse_i(const char *text) {
|
|
int value = 0;
|
|
if (!text) {
|
|
return 0;
|
|
}
|
|
while (*text >= '0' && *text <= '9') {
|
|
value = value * 10 + (*text - '0');
|
|
text++;
|
|
}
|
|
return value;
|
|
}
|
|
|
|
const char* channelIDBlacklist [7] = {"333", "444", "555", "666", "777", "888", "999"};
|
|
const char* validYears[8] = { "95", "96", "97", "98", "99", "00", "01", "02"};
|
|
|
|
bool PIDGEN2::isNumericString(char* input) {
|
|
for(int i = 0; i < strlen(input); i++) {
|
|
if (input[i] < '0' || input[i] > '9') {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
int PIDGEN2::addDigits(char* input) {
|
|
int output = 0;
|
|
|
|
if (!isNumericString(input)) {
|
|
return -1;
|
|
}
|
|
|
|
for(int i = 0; i < strlen(input); i++) {
|
|
output += input[i] - '0';
|
|
}
|
|
|
|
return output;
|
|
}
|
|
|
|
bool PIDGEN2::isValidChannelID(char* channelID) {
|
|
if (strlen(channelID) > 3) {
|
|
return false;
|
|
}
|
|
|
|
for (int i = 0; i <= 6; i++) {
|
|
if (strcmp(channelID, channelIDBlacklist[i]) != 0) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
bool PIDGEN2::isValidOEMID(char* OEMID) {
|
|
if (!isNumericString(OEMID)) {
|
|
return false;
|
|
}
|
|
|
|
if (strlen(OEMID) > 5) {
|
|
if (OEMID[0] != '0' || OEMID[1] != '0') {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
int mod = addDigits(OEMID);
|
|
|
|
return (mod % 21 == 0);
|
|
}
|
|
|
|
bool PIDGEN2::isValidYear(char* year) {
|
|
for (int i = 0; i <= 7; i++) {
|
|
if (year == validYears[i]) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool PIDGEN2::isValidDay(char* day) {
|
|
if (!isNumericString(day)) {
|
|
return false;
|
|
}
|
|
|
|
int iDay = parse_i(day);
|
|
if (iDay == 0 || iDay >= 365) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool PIDGEN2::isValidRetailProductID(char* productID) {
|
|
return true;
|
|
}
|
|
|
|
int PIDGEN2::GenerateRetail(char* channelID, char* &keyout) {
|
|
if (!isValidChannelID(channelID)) {
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int PIDGEN2::GenerateOEM(char* year, char* day, char* oem, char* &keyout) {
|
|
if (!isValidOEMID(oem)) {
|
|
int mod = addDigits(oem);
|
|
mod += mod % 21;
|
|
|
|
char formatted[16];
|
|
snprintf(formatted, sizeof(formatted), "%07d", mod);
|
|
strcpy(oem, formatted);
|
|
}
|
|
|
|
if (!isValidYear(year)) {
|
|
strcpy(year, validYears[0]);
|
|
}
|
|
|
|
if (!isValidDay(day)) {
|
|
int iday = parse_i(day);
|
|
iday = (iday + 1) % 365;
|
|
(void)iday;
|
|
}
|
|
|
|
{
|
|
char formatted[64];
|
|
snprintf(formatted, sizeof(formatted), "%s%s-OEM-%s-%s", year, day, oem, oem);
|
|
strcpy(keyout, formatted);
|
|
}
|
|
|
|
return 0;
|
|
} |