Writing Windows Secure Screensavers

Windows for Workgroups and Windows 3.1

If you are not using the C library then you have to implement your own password security, encrypting the password and placing it in the CONTROL.INI

e.g.

[Screen Saver.Ships]
PWProtected=0
Password=F-/EkoF
Windows 95/98
To access the values in the .PWL files, you will need to dynamically link to the WIN32 Network Interface DLL. and call the PwdChangePasswordA function.

	
 // This only ever gets called under '95, when started with the /a option.
  HINSTANCE hmpr=::LoadLibrary("MPR.DLL");
  if (hmpr==NULL)
	{
	  TRACE("MPR.DLL not found: cannot change password.");
	  return;
	}
  typedef VOID (WINAPI *PWDCHANGEPASSWORD)
      (LPCSTR lpcRegkeyname,HWND hwnd,UINT uiReserved1,UINT uiReserved2);
  PWDCHANGEPASSWORD PwdChangePassword=(PWDCHANGEPASSWORD)::GetProcAddress(hmpr,"PwdChangePasswordA");
  if (PwdChangePassword==NULL)
	{
	  FreeLibrary(hmpr);
      TRACE("PwdChangeProc not found: cannot change password");
	  return;
  }
  PwdChangePassword("SCRSAVE",m_hWnd,0,0);
  FreeLibrary(hmpr);

To verify the password, the password control pannel applet is used. Strangely enough you cannot manually change your password from the control pannel. This should only be done if you are not running on NT hence the version check.

  OSVERSIONINFO osv;
  osv.dwOSVersionInfoSize=sizeof(osv);
  GetVersionEx(&osv);
  if (osv.dwPlatformId==VER_PLATFORM_WIN32_NT)
		return;
  HINSTANCE hpwdcpl=::LoadLibrary("PASSWORD.CPL");
  if (hpwdcpl==NULL)
	{
	  TRACE("Unable to load PASSWORD.CPL. Aborting\n");
	  return;
	}
  typedef BOOL (WINAPI *VERIFYSCREENSAVEPWD)(HWND hwnd);
  TRACE("DLL loaded\n");
  VERIFYSCREENSAVEPWD VerifyScreenSavePwd;
  VerifyScreenSavePwd=
      (VERIFYSCREENSAVEPWD)GetProcAddress(hpwdcpl,"VerifyScreenSavePwd");
  if (VerifyScreenSavePwd==NULL)
	{
	  TRACE("Unable to get VerifyPwProc address. Aborting\n");
      FreeLibrary(hpwdcpl);
	  return;
	}
  TRACE("About to call VerifyPwProc\n");
  BOOL bres=VerifyScreenSavePwd(m_hWnd);
  FreeLibrary(hpwdcpl);
  return;
You do not need to independantly check that the screensaver password is being used, the VerifyScreenSavePWD does this for you.

Windows NT
Windows NT can handle it's own security so any security code that you specifically add needs to make allowances for this. See above for details. Take care if you write interactive screensavers for deployment on NT as there are a lot of differences from Win9x.


Home Education Employment Hobbies Screen Savers
Email : Andy.Clark@Dial.Pipex.Com - Last Updated : 23rd Mar 1999