-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPassword.cpp
72 lines (65 loc) · 2.03 KB
/
Password.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//==========================================================================
//
// File: Password.cpp
//
//==========================================================================
#include "Password.h"
#include "Debug.h"
//******************************************************************************************
BOOL
VerifyPassword(HWND hwnd)
{
// Under NT, we return TRUE immediately. This lets the saver quit,
// and the system manages passwords.
// Under '95, we call VerifyScreenSavePwd.
// This checks the appropriate registry key and, if necessary,
// pops up a verify dialog
OSVERSIONINFO osv;
osv.dwOSVersionInfoSize = sizeof(osv);
GetVersionEx(&osv);
if (osv.dwPlatformId == VER_PLATFORM_WIN32_NT)
return TRUE;
HINSTANCE hpwdcpl = ::LoadLibrary("PASSWORD.CPL");
if (hpwdcpl == NULL)
{
Debug("Unable to load PASSWORD.CPL. Aborting");
return TRUE;
}
typedef BOOL (WINAPI *VERIFYSCREENSAVEPWD)(HWND hwnd);
VERIFYSCREENSAVEPWD VerifyScreenSavePwd;
VerifyScreenSavePwd =
(VERIFYSCREENSAVEPWD)GetProcAddress(hpwdcpl, "VerifyScreenSavePwd");
if (VerifyScreenSavePwd == NULL)
{
Debug("Unable to get VerifyPwProc address. Aborting");
FreeLibrary(hpwdcpl);
return TRUE;
}
Debug("About to call VerifyPwProc");
BOOL bres = VerifyScreenSavePwd(hwnd);
FreeLibrary(hpwdcpl);
return bres;
}
//******************************************************************************************
void
ChangePassword(HWND hwnd)
{
// This only ever gets called under '95, when started with the /a option.
HINSTANCE hmpr = ::LoadLibrary("MPR.DLL");
if (hmpr == NULL)
{
Debug("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);
Debug("PwdChangeProc not found: cannot change password");
return;
}
PwdChangePassword("SCRSAVE", hwnd, 0, 0);
FreeLibrary(hmpr);
}