Skip to content

Instantly share code, notes, and snippets.

@Saket-Upadhyay
Last active May 13, 2021 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Saket-Upadhyay/3ec965db88efcdee089990d7818381e6 to your computer and use it in GitHub Desktop.
Save Saket-Upadhyay/3ec965db88efcdee089990d7818381e6 to your computer and use it in GitHub Desktop.
Windows95 OEM key check code.
// Credits and Thanks to Thomas Roth (https://github.com/nezza)
undefined2 __stdcall16far check_oem_key(char *key,int len)
{
int key_length;
int is_oem;
int first_3_digits_int;
int second_2_digits_int;
undefined2 check_result;
int i;
int i_;
char first_three_digits [4];
char second_two_digits [3];
char kc;
key_length = LSTRLEN(key);
if ((((key_length == 0x17) && (key[5] == '-')) && (key[9] == '-')) &&
((key[0x11] == '-' && (is_oem = check_oem_str(3,0x11704f9d,key + 6,len), is_oem == 0)))) {
/* Check first 5 digits, must be numeric */
i = 0;
do {
kc = key[i];
if (kc < '0') {
return 0;
}
if ('9' < kc) {
return 0;
}
i = i + 1;
} while (i < 5);
/* */
copy_partial(3,key,len,first_three_digits);
first_three_digits[3] = '\0';
first_3_digits_int = atoi(first_three_digits);
if ((first_3_digits_int != 0) &&
(first_3_digits_int < 367
/* check if between 1 and 366 */)) {
copy_partial(2,key + 3,len,second_two_digits);
second_two_digits[2] = '\0';
second_2_digits_int = atoi(second_two_digits);
if (((second_2_digits_int < 3) || (94 < second_2_digits_int)) &&
(((key[10] == '0' && ('0' < key[0x10])) && (key[0x10] < '8')))) {
i_ = 0x12;
while ((kc = key[i_], '/' < kc && (kc < ':'))) {
i_ = i_ + 1;
if (0x16 < i_) {
/* jump to part after oem- */
check_result = mod7_check(key + 10,len);
return check_result;
}
}
}
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment