Kaxeli's Softice's DigitCheck's Checkdigit :-)

Soft-Ice setup uses DigitCheck function from utility.dll (part of the setup package) to validate the s/n. If s/n is invalid, DigitCheck will return 0 and cl register containing the corrected value for bad symbol in s/n. Following program demonstrates how to ask CheckDigit to conveniently generate serial numbers for us. For product ID list you can search into the nminst32.dll for 431. You will see huge table with old and even future product IDs. Intention or stupidity ?

#include <windows.h>
#include <stdio.h>

int main(int argc, char** argv)
{
HANDLE h;
char sn[128];
int (*check)(char*);
char c;
int i = 8, ok;

if ((h = LoadLibrary("utility.dll")) == 0 ||
(((void*&)check) = GetProcAddress(h, "DigitCheck")) == 0)
{
printf("can't load utility.dll\n");
return 1;
}
if (argc == 2)
{
strcpy(sn, argv[1]);
}
else
{
printf("enter serial number prefix, 8 hexadecimal digits, starting with valid 3 digit product code:\n");
scanf("%s", sn);
printf("generated s/n:\n");
}
strcpy(sn + i, "zzzz");
while (1)
{
ok = check(sn);
_asm mov c, cl
if (ok)
{
sn[i] = 0;
break;
}
sn[i++] = toupper(c);
}
printf("%.4s-%.6s-%.2s", sn, sn + 4, sn + 10);
FreeLibrary(h);
return 0;
}



kaxeli(at)yahoo.com