Validating Win95 Screen Saver Password
Ed Milczarek -- emilczar@Matrox.COM Thursday, January 09, 1997 Environment : Win95,VC++ 4.2-flat Validating Win95 Screen Saver Password In the screen saver example (saver.scr) that comes with MSDEV the author decided to write a screen saver without using the standard screen saver library (scrnsave.lib). Instead, he replaced most of the DefScreenSaverProc using his own handles. Unfortunately he left out the most important one - dealing with the case of the SCRM_VERIFYPW message. This message is set when password protection is enabled and the user is trying to close the screen saver. The header file (scrnsave.h) makes reference to the Master Password Router but I haven't found any info on that. To complete this example, how would one go about validating the password that the user enters. I haven't seen any functions that would help in doing this. Any ideas? Ed
P.J. Tezza -- pj@exemplarsoftware.com Sunday, January 12, 1997 I seem to remember that this is the algorithm used by the Windows 3.x screen saver library to encrypt and decrypt passwords. The encrypted password was saved in a .ini file. This may have been changed in Windows 95. I just thought the algorithm was kind of amusing. BYTE Xor(BYTE x1, BYTE x2) { BYTE xor = (BYTE)(x1 ^ x2); if(xor <= 0x20 || (xor >= 0x7f && xor <= 0x90) || (xor >=0x93 && xor <= 0x9f) || xor == '=' || xor == '[' || xor == ']') return x2; return xor; } void EncryptString(char *szString) { ASSERT(strlen(szString) < UCHAR_MAX); BYTE nLen = (BYTE)strlen(szString); if(nLen == 0) return; AnsiUpper(szString); // Go forward for(BYTE nPtr = 0; nPtr < nLen; nPtr++) { BYTE c = (BYTE)szString[nPtr]; c = Xor(nLen, c); // Xor with string length if(nPtr == 0) c = Xor(0x2a, c); // Xor first byte with constant else { c = Xor(nPtr, c); // Xor with position c = Xor((BYTE)szString[nPtr - 1], c); // Xor with previous BYTE } szString[nPtr] = (char)c; } // Go backward if(nLen == 1) return; for(nPtr = (BYTE)(nLen - 1); nPtr >= 0; nPtr--) { BYTE c = (BYTE)szString[nPtr]; c = Xor(nLen, c); if(nPtr == nLen - 1) c = Xor(0x2a, c); else { c = Xor(nPtr, c); c = Xor((BYTE)szString[nPtr + 1], c); } szString[nPtr] = (char)c; if(nPtr == 0) break; // watch out - nPtr is unsiged so for loop won't exit } }
| Вернуться в корень Архива |