Skip to content

Instantly share code, notes, and snippets.

@nezza
Created January 29, 2021 18:47
Show Gist options
  • Star 29 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save nezza/a25bee13f25a1733a4c7a1d3d1cf5882 to your computer and use it in GitHub Desktop.
Save nezza/a25bee13f25a1733a4c7a1d3d1cf5882 to your computer and use it in GitHub Desktop.
Windows 95 OEM Key check
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;
}
@gogowitsch
Copy link

Will the gist link remain intact if you change the file extension to .c? Then we would have syntax highlighting.

@TrialMedusa64
Copy link

Nice! :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment