ReactOS  0.4.15-dev-321-g2d9b385
password.c
Go to the documentation of this file.
1 //
2 // password.c
3 //
4 // Password support for Win9x
5 //
6 #include <windows.h>
7 #include <tchar.h>
8 
10 typedef VOID (WINAPI *PWDCHANGEPASSWORD)(LPCTSTR lpcRegkeyname, HWND hwnd,UINT uiReserved1,UINT uiReserved2);
11 
13 {
14  // Under NT, we return TRUE immediately. This lets the saver quit,
15  // and the system manages passwords. Under '95, we call VerifyScreenSavePwd.
16  // This checks the appropriate registry key and, if necessary,
17  // pops up a verify dialog
18 
19  HINSTANCE hpwdcpl;
20  VERIFYSCREENSAVEPWD VerifyScreenSavePwd;
21  BOOL fResult;
22 
23  if(GetVersion() < 0x80000000)
24  return TRUE;
25 
26  hpwdcpl = LoadLibrary(_T("PASSWORD.CPL"));
27 
28  if(hpwdcpl == NULL)
29  {
30  return FALSE;
31  }
32 
33 
34  VerifyScreenSavePwd = (VERIFYSCREENSAVEPWD)GetProcAddress(hpwdcpl, "VerifyScreenSavePwd");
35 
36  if(VerifyScreenSavePwd == NULL)
37  {
38  FreeLibrary(hpwdcpl);
39  return FALSE;
40  }
41 
42  fResult = VerifyScreenSavePwd(hwnd);
43  FreeLibrary(hpwdcpl);
44 
45  return fResult;
46 }
47 
49 {
50  // This only ever gets called under '95, when started with the /a option.
51  HINSTANCE hmpr = LoadLibrary(_T("MPR.DLL"));
52  PWDCHANGEPASSWORD PwdChangePassword;
53 
54  if(hmpr == NULL)
55  return FALSE;
56 
57  PwdChangePassword = (PWDCHANGEPASSWORD)GetProcAddress(hmpr, "PwdChangePasswordA");
58 
59  if(PwdChangePassword == NULL)
60  {
61  FreeLibrary(hmpr);
62  return FALSE;
63  }
64 
65  PwdChangePassword(_T("SCRSAVE"), hwnd, 0, 0);
66  FreeLibrary(hmpr);
67 
68  return TRUE;
69 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#define LoadLibrary
Definition: winbase.h:3702
#define BOOL
Definition: nt_native.h:43
DWORD WINAPI GetVersion(VOID)
Definition: version.c:22
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define _T(x)
Definition: vfdio.h:22
#define FreeLibrary(x)
Definition: compat.h:414
#define WINAPI
Definition: msvc.h:6
VOID(WINAPI * PWDCHANGEPASSWORD)(LPCTSTR lpcRegkeyname, HWND hwnd, UINT uiReserved1, UINT uiReserved2)
Definition: password.c:10
BOOL ChangePassword(HWND hwnd)
Definition: password.c:48
#define VOID
Definition: acefi.h:82
BOOL(WINAPI * VERIFYSCREENSAVEPWD)(HWND hwnd)
Definition: password.c:9
unsigned int UINT
Definition: ndis.h:50
#define GetProcAddress(x, y)
Definition: compat.h:419
BOOL VerifyPassword(HWND hwnd)
Definition: password.c:12