2 * PROJECT: ReactOS msgina.dll
3 * FILE: dll/win32/msgina/gui.c
4 * PURPOSE: ReactOS Logon GINA DLL
5 * PROGRAMMER: Hervé Poussineau (hpoussin@reactos.org)
14 typedef struct _DISPLAYSTATUSMSG
16 PGINA_CONTEXT Context
;
22 } DISPLAYSTATUSMSG
, *PDISPLAYSTATUSMSG
;
24 typedef struct _LEGALNOTICEDATA
28 } LEGALNOTICEDATA
, *PLEGALNOTICEDATA
;
33 IN OUT PGINA_CONTEXT pgContext
)
35 TRACE("GUIInitialize(%p)\n", pgContext
);
39 static INT_PTR CALLBACK
40 StatusMessageWindowProc(
46 UNREFERENCED_PARAMETER(wParam
);
52 PDISPLAYSTATUSMSG msg
= (PDISPLAYSTATUSMSG
)lParam
;
56 msg
->Context
->hStatusWindow
= hwndDlg
;
59 SetWindowTextW(hwndDlg
, msg
->pTitle
);
60 SetDlgItemTextW(hwndDlg
, IDC_STATUSLABEL
, msg
->pMessage
);
61 SetEvent(msg
->StartupEvent
);
69 StartupWindowThread(LPVOID lpParam
)
72 PDISPLAYSTATUSMSG msg
= (PDISPLAYSTATUSMSG
)lpParam
;
74 /* When SetThreadDesktop is called the system closes the desktop handle when needed
75 so we have to create a new handle because this handle may still be in use by winlogon */
76 if (!DuplicateHandle ( GetCurrentProcess(),
82 DUPLICATE_SAME_ACCESS
))
84 ERR("Duplicating handle failed!\n");
85 HeapFree(GetProcessHeap(), 0, lpParam
);
89 if(!SetThreadDesktop(hDesk
))
91 ERR("Setting thread desktop failed!\n");
92 HeapFree(GetProcessHeap(), 0, lpParam
);
98 MAKEINTRESOURCEW(IDD_STATUSWINDOW_DLG
),
100 StatusMessageWindowProc
,
103 HeapFree(GetProcessHeap(), 0, lpParam
);
108 GUIDisplayStatusMessage(
109 IN PGINA_CONTEXT pgContext
,
115 PDISPLAYSTATUSMSG msg
;
119 TRACE("GUIDisplayStatusMessage(%ws)\n", pMessage
);
121 if (!pgContext
->hStatusWindow
)
124 * If everything goes correctly, 'msg' is freed
125 * by the 'StartupWindowThread' thread.
127 msg
= (PDISPLAYSTATUSMSG
)HeapAlloc(GetProcessHeap(),
133 msg
->Context
= pgContext
;
134 msg
->dwOptions
= dwOptions
;
135 msg
->pTitle
= pTitle
;
136 msg
->pMessage
= pMessage
;
137 msg
->hDesktop
= hDesktop
;
139 msg
->StartupEvent
= CreateEventW(NULL
, TRUE
, FALSE
, NULL
);
141 if (!msg
->StartupEvent
)
143 HeapFree(GetProcessHeap(), 0, msg
);
147 Thread
= CreateThread(NULL
,
155 /* 'msg' will be freed by 'StartupWindowThread' */
158 WaitForSingleObject(msg
->StartupEvent
, INFINITE
);
159 CloseHandle(msg
->StartupEvent
);
165 * The 'StartupWindowThread' thread couldn't be created,
166 * so we need to free the allocated 'msg'.
168 HeapFree(GetProcessHeap(), 0, msg
);
175 SetWindowTextW(pgContext
->hStatusWindow
, pTitle
);
177 SetDlgItemTextW(pgContext
->hStatusWindow
, IDC_STATUSLABEL
, pMessage
);
183 GUIRemoveStatusMessage(
184 IN PGINA_CONTEXT pgContext
)
186 if (pgContext
->hStatusWindow
)
188 EndDialog(pgContext
->hStatusWindow
, 0);
189 pgContext
->hStatusWindow
= NULL
;
195 static INT_PTR CALLBACK
202 PGINA_CONTEXT pgContext
;
204 pgContext
= (PGINA_CONTEXT
)GetWindowLongPtrW(hwndDlg
, GWLP_USERDATA
);
210 pgContext
= (PGINA_CONTEXT
)lParam
;
211 SetWindowLongPtrW(hwndDlg
, GWLP_USERDATA
, (LONG_PTR
)pgContext
);
213 /* Draw the logo bitmap */
214 pgContext
->hBitmap
= LoadImageW(pgContext
->hDllInstance
, MAKEINTRESOURCEW(IDI_ROSLOGO
), IMAGE_BITMAP
, 0, 0, LR_DEFAULTCOLOR
);
220 if (pgContext
->hBitmap
)
222 BeginPaint(hwndDlg
, &ps
);
223 DrawStateW(ps
.hdc
, NULL
, NULL
, (LPARAM
)pgContext
->hBitmap
, (WPARAM
)0, 0, 0, 0, 0, DST_BITMAP
);
224 EndPaint(hwndDlg
, &ps
);
230 DeleteObject(pgContext
->hBitmap
);
239 IN OUT PGINA_CONTEXT pgContext
)
241 TRACE("GUIDisplaySASNotice()\n");
243 /* Display the notice window */
244 pgContext
->pWlxFuncs
->WlxDialogBoxParam(pgContext
->hWlx
,
245 pgContext
->hDllInstance
,
246 MAKEINTRESOURCEW(IDD_NOTICE_DLG
),
252 /* Get the text contained in a textbox. Allocates memory in pText
253 * to contain the text. Returns TRUE in case of success */
263 Count
= GetWindowTextLength(GetDlgItem(hwndDlg
, TextboxId
));
264 Text
= HeapAlloc(GetProcessHeap(), 0, (Count
+ 1) * sizeof(WCHAR
));
267 if (Count
!= GetWindowTextW(GetDlgItem(hwndDlg
, TextboxId
), Text
, Count
+ 1))
269 HeapFree(GetProcessHeap(), 0, Text
);
280 IN PGINA_CONTEXT pgContext
,
286 WCHAR szCaption
[256];
289 LoadStringW(pgContext
->hDllInstance
, uCaption
, szCaption
, _countof(szCaption
));
290 LoadStringW(pgContext
->hDllInstance
, uText
, szText
, _countof(szText
));
292 return pgContext
->pWlxFuncs
->WlxMessageBox(pgContext
->hWlx
,
303 IN PGINA_CONTEXT pgContext
,
308 WCHAR OldPassword
[256];
309 WCHAR NewPassword1
[256];
310 WCHAR NewPassword2
[256];
311 PMSV1_0_CHANGEPASSWORD_REQUEST RequestBuffer
= NULL
;
312 PMSV1_0_CHANGEPASSWORD_RESPONSE ResponseBuffer
= NULL
;
313 ULONG RequestBufferSize
;
314 ULONG ResponseBufferSize
= 0;
317 NTSTATUS ProtocolStatus
;
320 GetDlgItemTextW(hwndDlg
, IDC_CHANGEPWD_USERNAME
, UserName
, _countof(UserName
));
321 GetDlgItemTextW(hwndDlg
, IDC_CHANGEPWD_DOMAIN
, Domain
, _countof(Domain
));
322 GetDlgItemTextW(hwndDlg
, IDC_CHANGEPWD_OLDPWD
, OldPassword
, _countof(OldPassword
));
323 GetDlgItemTextW(hwndDlg
, IDC_CHANGEPWD_NEWPWD1
, NewPassword1
, _countof(NewPassword1
));
324 GetDlgItemTextW(hwndDlg
, IDC_CHANGEPWD_NEWPWD2
, NewPassword2
, _countof(NewPassword2
));
326 /* Compare the two passwords and fail if they do not match */
327 if (wcscmp(NewPassword1
, NewPassword2
) != 0)
329 ResourceMessageBox(pgContext
,
331 MB_OK
| MB_ICONEXCLAMATION
,
333 IDS_NONMATCHINGPASSWORDS
);
337 /* Calculate the request buffer size */
338 RequestBufferSize
= sizeof(MSV1_0_CHANGEPASSWORD_REQUEST
) +
339 ((wcslen(Domain
) + 1) * sizeof(WCHAR
)) +
340 ((wcslen(UserName
) + 1) * sizeof(WCHAR
)) +
341 ((wcslen(OldPassword
) + 1) * sizeof(WCHAR
)) +
342 ((wcslen(NewPassword1
) + 1) * sizeof(WCHAR
));
344 /* Allocate the request buffer */
345 RequestBuffer
= HeapAlloc(GetProcessHeap(),
348 if (RequestBuffer
== NULL
)
350 ERR("HeapAlloc failed\n");
354 /* Initialize the request buffer */
355 RequestBuffer
->MessageType
= MsV1_0ChangePassword
;
356 RequestBuffer
->Impersonating
= TRUE
;
358 Ptr
= (LPWSTR
)((ULONG_PTR
)RequestBuffer
+ sizeof(MSV1_0_CHANGEPASSWORD_REQUEST
));
360 /* Pack the domain name */
361 RequestBuffer
->DomainName
.Length
= wcslen(Domain
) * sizeof(WCHAR
);
362 RequestBuffer
->DomainName
.MaximumLength
= RequestBuffer
->DomainName
.Length
+ sizeof(WCHAR
);
363 RequestBuffer
->DomainName
.Buffer
= Ptr
;
365 RtlCopyMemory(RequestBuffer
->DomainName
.Buffer
,
367 RequestBuffer
->DomainName
.MaximumLength
);
369 Ptr
= (LPWSTR
)((ULONG_PTR
)Ptr
+ RequestBuffer
->DomainName
.MaximumLength
);
371 /* Pack the user name */
372 RequestBuffer
->AccountName
.Length
= wcslen(UserName
) * sizeof(WCHAR
);
373 RequestBuffer
->AccountName
.MaximumLength
= RequestBuffer
->AccountName
.Length
+ sizeof(WCHAR
);
374 RequestBuffer
->AccountName
.Buffer
= Ptr
;
376 RtlCopyMemory(RequestBuffer
->AccountName
.Buffer
,
378 RequestBuffer
->AccountName
.MaximumLength
);
380 Ptr
= (LPWSTR
)((ULONG_PTR
)Ptr
+ RequestBuffer
->AccountName
.MaximumLength
);
382 /* Pack the old password */
383 RequestBuffer
->OldPassword
.Length
= wcslen(OldPassword
) * sizeof(WCHAR
);
384 RequestBuffer
->OldPassword
.MaximumLength
= RequestBuffer
->OldPassword
.Length
+ sizeof(WCHAR
);
385 RequestBuffer
->OldPassword
.Buffer
= Ptr
;
387 RtlCopyMemory(RequestBuffer
->OldPassword
.Buffer
,
389 RequestBuffer
->OldPassword
.MaximumLength
);
391 Ptr
= (LPWSTR
)((ULONG_PTR
)Ptr
+ RequestBuffer
->OldPassword
.MaximumLength
);
393 /* Pack the new password */
394 RequestBuffer
->NewPassword
.Length
= wcslen(NewPassword1
) * sizeof(WCHAR
);
395 RequestBuffer
->NewPassword
.MaximumLength
= RequestBuffer
->NewPassword
.Length
+ sizeof(WCHAR
);
396 RequestBuffer
->NewPassword
.Buffer
= Ptr
;
398 RtlCopyMemory(RequestBuffer
->NewPassword
.Buffer
,
400 RequestBuffer
->NewPassword
.MaximumLength
);
402 /* Connect to the LSA server */
403 if (ConnectToLsa(pgContext
) != ERROR_SUCCESS
)
405 ERR("ConnectToLsa() failed\n");
409 /* Call the authentication package */
410 Status
= LsaCallAuthenticationPackage(pgContext
->LsaHandle
,
411 pgContext
->AuthenticationPackage
,
414 (PVOID
*)&ResponseBuffer
,
417 if (!NT_SUCCESS(Status
))
419 ERR("LsaCallAuthenticationPackage failed (Status 0x%08lx)\n", Status
);
423 if (!NT_SUCCESS(ProtocolStatus
))
425 TRACE("LsaCallAuthenticationPackage failed (ProtocolStatus 0x%08lx)\n", ProtocolStatus
);
431 ResourceMessageBox(pgContext
,
433 MB_OK
| MB_ICONINFORMATION
,
435 IDS_PASSWORDCHANGED
);
437 if ((wcscmp(UserName
, pgContext
->UserName
) == 0) &&
438 (wcscmp(Domain
, pgContext
->DomainName
) == 0) &&
439 (wcscmp(OldPassword
, pgContext
->Password
) == 0))
441 ZeroMemory(pgContext
->Password
, sizeof(pgContext
->Password
));
442 wcscpy(pgContext
->Password
, NewPassword1
);
446 if (RequestBuffer
!= NULL
)
447 HeapFree(GetProcessHeap(), 0, RequestBuffer
);
449 if (ResponseBuffer
!= NULL
)
450 LsaFreeReturnBuffer(ResponseBuffer
);
456 static INT_PTR CALLBACK
457 ChangePasswordDialogProc(
463 PGINA_CONTEXT pgContext
;
465 pgContext
= (PGINA_CONTEXT
)GetWindowLongPtrW(hwndDlg
, GWLP_USERDATA
);
471 pgContext
= (PGINA_CONTEXT
)lParam
;
472 SetWindowLongPtrW(hwndDlg
, GWLP_USERDATA
, (LONG_PTR
)pgContext
);
474 SetDlgItemTextW(hwndDlg
, IDC_CHANGEPWD_USERNAME
, pgContext
->UserName
);
475 SendDlgItemMessageW(hwndDlg
, IDC_CHANGEPWD_DOMAIN
, CB_ADDSTRING
, 0, (LPARAM
)pgContext
->DomainName
);
476 SendDlgItemMessageW(hwndDlg
, IDC_CHANGEPWD_DOMAIN
, CB_SETCURSEL
, 0, 0);
477 SetFocus(GetDlgItem(hwndDlg
, IDC_CHANGEPWD_OLDPWD
));
482 switch (LOWORD(wParam
))
485 if (DoChangePassword(pgContext
, hwndDlg
))
487 EndDialog(hwndDlg
, TRUE
);
491 SetDlgItemTextW(hwndDlg
, IDC_CHANGEPWD_NEWPWD1
, NULL
);
492 SetDlgItemTextW(hwndDlg
, IDC_CHANGEPWD_NEWPWD2
, NULL
);
493 SetFocus(GetDlgItem(hwndDlg
, IDC_CHANGEPWD_OLDPWD
));
498 EndDialog(hwndDlg
, FALSE
);
504 EndDialog(hwndDlg
, FALSE
);
513 OnInitSecurityDlg(HWND hwnd
,
514 PGINA_CONTEXT pgContext
)
521 LoadStringW(pgContext
->hDllInstance
, IDS_LOGONMSG
, Buffer1
, _countof(Buffer1
));
523 wsprintfW(Buffer2
, L
"%s\\%s", pgContext
->DomainName
, pgContext
->UserName
);
524 wsprintfW(Buffer4
, Buffer1
, Buffer2
);
526 SetDlgItemTextW(hwnd
, IDC_LOGONMSG
, Buffer4
);
528 LoadStringW(pgContext
->hDllInstance
, IDS_LOGONDATE
, Buffer1
, _countof(Buffer1
));
530 GetDateFormatW(LOCALE_USER_DEFAULT
, DATE_SHORTDATE
,
531 (SYSTEMTIME
*)&pgContext
->LogonTime
, NULL
, Buffer2
, _countof(Buffer2
));
533 GetTimeFormatW(LOCALE_USER_DEFAULT
, 0,
534 (SYSTEMTIME
*)&pgContext
->LogonTime
, NULL
, Buffer3
, _countof(Buffer3
));
536 wsprintfW(Buffer4
, Buffer1
, Buffer2
, Buffer3
);
538 SetDlgItemTextW(hwnd
, IDC_LOGONDATE
, Buffer4
);
540 if (pgContext
->bAutoAdminLogon
)
541 EnableWindow(GetDlgItem(hwnd
, IDC_LOGOFF
), FALSE
);
548 IN PGINA_CONTEXT pgContext
)
552 TRACE("OnChangePassword()\n");
554 res
= pgContext
->pWlxFuncs
->WlxDialogBoxParam(
556 pgContext
->hDllInstance
,
557 MAKEINTRESOURCEW(IDD_CHANGE_PASSWORD
),
559 ChangePasswordDialogProc
,
562 TRACE("Result: %x\n", res
);
568 static INT_PTR CALLBACK
581 switch (LOWORD(wParam
))
584 EndDialog(hwndDlg
, IDYES
);
588 EndDialog(hwndDlg
, IDNO
);
594 EndDialog(hwndDlg
, IDNO
);
606 IN PGINA_CONTEXT pgContext
)
608 return pgContext
->pWlxFuncs
->WlxDialogBoxParam(
610 pgContext
->hDllInstance
,
611 MAKEINTRESOURCEW(IDD_LOGOFF_DLG
),
622 IN PGINA_CONTEXT pgContext
)
625 DWORD ShutdownOptions
;
627 TRACE("OnShutDown(%p %p)\n", hwndDlg
, pgContext
);
629 pgContext
->nShutdownAction
= GetDefaultShutdownSelState();
630 ShutdownOptions
= GetDefaultShutdownOptions();
632 if (pgContext
->UserToken
!= NULL
)
634 if (ImpersonateLoggedOnUser(pgContext
->UserToken
))
636 pgContext
->nShutdownAction
= LoadShutdownSelState();
637 ShutdownOptions
= GetAllowedShutdownOptions();
642 ERR("WL: ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError());
646 ret
= ShutdownDialog(hwndDlg
, ShutdownOptions
, pgContext
);
650 if (pgContext
->UserToken
!= NULL
)
652 if (ImpersonateLoggedOnUser(pgContext
->UserToken
))
654 SaveShutdownSelState(pgContext
->nShutdownAction
);
659 ERR("WL: ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError());
668 static INT_PTR CALLBACK
675 PGINA_CONTEXT pgContext
;
677 pgContext
= (PGINA_CONTEXT
)GetWindowLongPtrW(hwndDlg
, GWLP_USERDATA
);
683 pgContext
= (PGINA_CONTEXT
)lParam
;
684 SetWindowLongPtrW(hwndDlg
, GWLP_USERDATA
, (LONG_PTR
)pgContext
);
686 OnInitSecurityDlg(hwndDlg
, (PGINA_CONTEXT
)lParam
);
687 SetFocus(GetDlgItem(hwndDlg
, IDNO
));
693 switch (LOWORD(wParam
))
696 EndDialog(hwndDlg
, WLX_SAS_ACTION_LOCK_WKSTA
);
699 if (OnLogOff(hwndDlg
, pgContext
) == IDYES
)
700 EndDialog(hwndDlg
, WLX_SAS_ACTION_LOGOFF
);
703 if (OnShutDown(hwndDlg
, pgContext
) == IDOK
)
704 EndDialog(hwndDlg
, pgContext
->nShutdownAction
);
707 if (OnChangePassword(hwndDlg
, pgContext
))
708 EndDialog(hwndDlg
, WLX_SAS_ACTION_PWD_CHANGED
);
711 EndDialog(hwndDlg
, WLX_SAS_ACTION_TASKLIST
);
714 EndDialog(hwndDlg
, WLX_SAS_ACTION_NONE
);
721 EndDialog(hwndDlg
, WLX_SAS_ACTION_NONE
);
731 IN OUT PGINA_CONTEXT pgContext
,
736 TRACE("GUILoggedOnSAS()\n");
738 if (dwSasType
!= WLX_SAS_TYPE_CTRL_ALT_DEL
)
740 /* Nothing to do for WLX_SAS_TYPE_TIMEOUT ; the dialog will
741 * close itself thanks to the use of WlxDialogBoxParam */
742 return WLX_SAS_ACTION_NONE
;
745 pgContext
->pWlxFuncs
->WlxSwitchDesktopToWinlogon(
748 result
= pgContext
->pWlxFuncs
->WlxDialogBoxParam(
750 pgContext
->hDllInstance
,
751 MAKEINTRESOURCEW(IDD_LOGGEDON_DLG
),
756 if (result
< WLX_SAS_ACTION_LOGON
||
757 result
> WLX_SAS_ACTION_SWITCH_CONSOLE
)
759 result
= WLX_SAS_ACTION_NONE
;
762 if (result
== WLX_SAS_ACTION_NONE
)
764 pgContext
->pWlxFuncs
->WlxSwitchDesktopToUser(
776 IN OUT PGINA_CONTEXT pgContext
)
778 LPWSTR UserName
= NULL
;
779 LPWSTR Password
= NULL
;
780 LPWSTR Domain
= NULL
;
782 NTSTATUS Status
, SubStatus
= STATUS_SUCCESS
;
784 if (GetTextboxText(hwndDlg
, IDC_USERNAME
, &UserName
) && *UserName
== '\0')
787 if (GetTextboxText(hwndDlg
, IDC_LOGON_TO
, &Domain
) && *Domain
== '\0')
790 if (!GetTextboxText(hwndDlg
, IDC_PASSWORD
, &Password
))
793 Status
= DoLoginTasks(pgContext
, UserName
, Domain
, Password
, &SubStatus
);
794 if (Status
== STATUS_LOGON_FAILURE
)
796 ResourceMessageBox(pgContext
,
798 MB_OK
| MB_ICONEXCLAMATION
,
800 IDS_LOGONWRONGUSERORPWD
);
803 else if (Status
== STATUS_ACCOUNT_RESTRICTION
)
805 TRACE("DoLoginTasks failed! Status 0x%08lx SubStatus 0x%08lx\n", Status
, SubStatus
);
807 if (SubStatus
== STATUS_ACCOUNT_DISABLED
)
809 ResourceMessageBox(pgContext
,
811 MB_OK
| MB_ICONEXCLAMATION
,
813 IDS_LOGONUSERDISABLED
);
816 else if (SubStatus
== STATUS_ACCOUNT_LOCKED_OUT
)
818 TRACE("Account locked!\n");
819 pgContext
->pWlxFuncs
->WlxMessageBox(pgContext
->hWlx
,
823 MB_OK
| MB_ICONERROR
);
826 else if ((SubStatus
== STATUS_PASSWORD_MUST_CHANGE
) ||
827 (SubStatus
== STATUS_PASSWORD_EXPIRED
))
829 if (SubStatus
== STATUS_PASSWORD_MUST_CHANGE
)
830 ResourceMessageBox(pgContext
,
834 IDS_PASSWORDMUSTCHANGE
);
836 ResourceMessageBox(pgContext
,
840 IDS_PASSWORDEXPIRED
);
842 if (!OnChangePassword(hwndDlg
,
846 Status
= DoLoginTasks(pgContext
,
848 pgContext
->DomainName
,
851 if (!NT_SUCCESS(Status
))
853 TRACE("Login after password change failed! (Status 0x%08lx)\n", Status
);
860 TRACE("Other error!\n");
861 pgContext
->pWlxFuncs
->WlxMessageBox(pgContext
->hWlx
,
865 MB_OK
| MB_ICONERROR
);
869 else if (!NT_SUCCESS(Status
))
871 TRACE("DoLoginTasks failed! Status 0x%08lx\n", Status
);
876 if (!CreateProfile(pgContext
, UserName
, Domain
, Password
))
878 ERR("Failed to create the profile!\n");
882 ZeroMemory(pgContext
->Password
, sizeof(pgContext
->Password
));
883 wcscpy(pgContext
->Password
, Password
);
888 pgContext
->bAutoAdminLogon
= FALSE
;
890 if (UserName
!= NULL
)
891 HeapFree(GetProcessHeap(), 0, UserName
);
893 if (Password
!= NULL
)
894 HeapFree(GetProcessHeap(), 0, Password
);
897 HeapFree(GetProcessHeap(), 0, Domain
);
906 HWND hwndDomainComboBox
,
907 PGINA_CONTEXT pgContext
)
909 WCHAR szComputerName
[MAX_COMPUTERNAME_LENGTH
+ 1];
910 DWORD dwComputerNameLength
;
914 SendMessageW(hwndDomainComboBox
, CB_RESETCONTENT
, 0, 0);
916 dwComputerNameLength
= _countof(szComputerName
);
917 if (GetComputerNameW(szComputerName
, &dwComputerNameLength
))
919 lIndex
= SendMessageW(hwndDomainComboBox
, CB_ADDSTRING
, 0, (LPARAM
)szComputerName
);
922 if (wcslen(pgContext
->DomainName
) != 0)
924 lFindIndex
= SendMessageW(hwndDomainComboBox
, CB_FINDSTRINGEXACT
, (WPARAM
)-1, (LPARAM
)pgContext
->DomainName
);
925 if (lFindIndex
== CB_ERR
)
927 lIndex
= SendMessageW(hwndDomainComboBox
, CB_ADDSTRING
, 0, (LPARAM
)pgContext
->DomainName
);
935 SendMessageW(hwndDomainComboBox
, CB_SETCURSEL
, lIndex
, 0);
939 static INT_PTR CALLBACK
946 PGINA_CONTEXT pgContext
;
948 pgContext
= (PGINA_CONTEXT
)GetWindowLongPtrW(hwndDlg
, GWLP_USERDATA
);
954 /* FIXME: take care of NoDomainUI */
955 pgContext
= (PGINA_CONTEXT
)lParam
;
956 SetWindowLongPtrW(hwndDlg
, GWLP_USERDATA
, (LONG_PTR
)pgContext
);
958 if (pgContext
->bAutoAdminLogon
||
959 !pgContext
->bDontDisplayLastUserName
)
960 SetDlgItemTextW(hwndDlg
, IDC_USERNAME
, pgContext
->UserName
);
962 if (pgContext
->bAutoAdminLogon
)
963 SetDlgItemTextW(hwndDlg
, IDC_PASSWORD
, pgContext
->Password
);
965 SetDomainComboBox(GetDlgItem(hwndDlg
, IDC_LOGON_TO
), pgContext
);
967 if (pgContext
->bDisableCAD
)
968 EnableWindow(GetDlgItem(hwndDlg
, IDCANCEL
), FALSE
);
970 if (!pgContext
->bShutdownWithoutLogon
)
971 EnableWindow(GetDlgItem(hwndDlg
, IDC_SHUTDOWN
), FALSE
);
973 SetFocus(GetDlgItem(hwndDlg
, pgContext
->bDontDisplayLastUserName
? IDC_USERNAME
: IDC_PASSWORD
));
975 /* Draw the logo bitmap */
976 pgContext
->hBitmap
= LoadImageW(pgContext
->hDllInstance
, MAKEINTRESOURCEW(IDI_ROSLOGO
), IMAGE_BITMAP
, 0, 0, LR_DEFAULTCOLOR
);
978 if (pgContext
->bAutoAdminLogon
)
979 PostMessage(GetDlgItem(hwndDlg
, IDOK
), BM_CLICK
, 0, 0);
987 if (pgContext
->hBitmap
)
989 BeginPaint(hwndDlg
, &ps
);
990 DrawStateW(ps
.hdc
, NULL
, NULL
, (LPARAM
)pgContext
->hBitmap
, (WPARAM
)0, 0, 0, 0, 0, DST_BITMAP
);
991 EndPaint(hwndDlg
, &ps
);
997 DeleteObject(pgContext
->hBitmap
);
1001 switch (LOWORD(wParam
))
1004 if (DoLogon(hwndDlg
, pgContext
))
1005 EndDialog(hwndDlg
, WLX_SAS_ACTION_LOGON
);
1009 EndDialog(hwndDlg
, WLX_SAS_ACTION_NONE
);
1013 if (OnShutDown(hwndDlg
, pgContext
) == IDOK
)
1014 EndDialog(hwndDlg
, pgContext
->nShutdownAction
);
1027 LegalNoticeDialogProc(
1033 PLEGALNOTICEDATA pLegalNotice
;
1038 pLegalNotice
= (PLEGALNOTICEDATA
)lParam
;
1039 SetWindowTextW(hwndDlg
, pLegalNotice
->pszCaption
);
1040 SetDlgItemTextW(hwndDlg
, IDC_LEGALNOTICE_TEXT
, pLegalNotice
->pszText
);
1044 switch (LOWORD(wParam
))
1047 EndDialog(hwndDlg
, 0);
1051 EndDialog(hwndDlg
, 0);
1063 IN OUT PGINA_CONTEXT pgContext
)
1065 LEGALNOTICEDATA LegalNotice
= {NULL
, NULL
};
1070 TRACE("GUILoggedOutSAS()\n");
1072 rc
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
1073 L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
1077 if (rc
== ERROR_SUCCESS
)
1079 ReadRegSzValue(hKey
,
1080 L
"LegalNoticeCaption",
1081 &LegalNotice
.pszCaption
);
1083 ReadRegSzValue(hKey
,
1085 &LegalNotice
.pszText
);
1090 if (LegalNotice
.pszCaption
!= NULL
&& wcslen(LegalNotice
.pszCaption
) != 0 &&
1091 LegalNotice
.pszText
!= NULL
&& wcslen(LegalNotice
.pszText
) != 0)
1093 pgContext
->pWlxFuncs
->WlxDialogBoxParam(pgContext
->hWlx
,
1094 pgContext
->hDllInstance
,
1095 MAKEINTRESOURCEW(IDD_LEGALNOTICE_DLG
),
1097 LegalNoticeDialogProc
,
1098 (LPARAM
)&LegalNotice
);
1101 if (LegalNotice
.pszCaption
!= NULL
)
1102 HeapFree(GetProcessHeap(), 0, LegalNotice
.pszCaption
);
1104 if (LegalNotice
.pszText
!= NULL
)
1105 HeapFree(GetProcessHeap(), 0, LegalNotice
.pszText
);
1107 result
= pgContext
->pWlxFuncs
->WlxDialogBoxParam(
1109 pgContext
->hDllInstance
,
1110 MAKEINTRESOURCEW(IDD_LOGGEDOUT_DLG
),
1112 LoggedOutWindowProc
,
1114 if (result
>= WLX_SAS_ACTION_LOGON
&&
1115 result
<= WLX_SAS_ACTION_SWITCH_CONSOLE
)
1117 WARN("WlxLoggedOutSAS() returns 0x%x\n", result
);
1121 WARN("WlxDialogBoxParam() failed (0x%x)\n", result
);
1122 return WLX_SAS_ACTION_NONE
;
1127 SetLockMessage(HWND hwnd
,
1129 PGINA_CONTEXT pgContext
)
1135 LoadStringW(pgContext
->hDllInstance
, IDS_LOCKMSG
, Buffer1
, _countof(Buffer1
));
1137 wsprintfW(Buffer2
, L
"%s\\%s", pgContext
->DomainName
, pgContext
->UserName
);
1138 wsprintfW(Buffer3
, Buffer1
, Buffer2
);
1140 SetDlgItemTextW(hwnd
, nDlgItem
, Buffer3
);
1148 IN PGINA_CONTEXT pgContext
,
1153 LPWSTR UserName
= NULL
;
1154 LPWSTR Password
= NULL
;
1157 if (GetTextboxText(hwndDlg
, IDC_USERNAME
, &UserName
) && *UserName
== '\0')
1159 HeapFree(GetProcessHeap(), 0, UserName
);
1163 if (GetTextboxText(hwndDlg
, IDC_PASSWORD
, &Password
))
1165 if (UserName
!= NULL
&& Password
!= NULL
&&
1166 wcscmp(UserName
, pgContext
->UserName
) == 0 &&
1167 wcscmp(Password
, pgContext
->Password
) == 0)
1169 *Action
= WLX_SAS_ACTION_UNLOCK_WKSTA
;
1172 else if (wcscmp(UserName
, pgContext
->UserName
) == 0 &&
1173 wcscmp(Password
, pgContext
->Password
) != 0)
1175 /* Wrong Password */
1176 LoadStringW(pgContext
->hDllInstance
, IDS_LOCKEDWRONGPASSWORD
, Buffer2
, _countof(Buffer2
));
1177 LoadStringW(pgContext
->hDllInstance
, IDS_COMPUTERLOCKED
, Buffer1
, _countof(Buffer1
));
1178 MessageBoxW(hwndDlg
, Buffer2
, Buffer1
, MB_OK
| MB_ICONERROR
);
1182 /* Wrong user name */
1183 if (DoAdminUnlock(pgContext
, UserName
, NULL
, Password
))
1185 *Action
= WLX_SAS_ACTION_UNLOCK_WKSTA
;
1190 LoadStringW(pgContext
->hDllInstance
, IDS_LOCKEDWRONGUSER
, Buffer1
, _countof(Buffer1
));
1191 wsprintfW(Buffer2
, Buffer1
, pgContext
->DomainName
, pgContext
->UserName
);
1192 LoadStringW(pgContext
->hDllInstance
, IDS_COMPUTERLOCKED
, Buffer1
, _countof(Buffer1
));
1193 MessageBoxW(hwndDlg
, Buffer2
, Buffer1
, MB_OK
| MB_ICONERROR
);
1198 if (UserName
!= NULL
)
1199 HeapFree(GetProcessHeap(), 0, UserName
);
1201 if (Password
!= NULL
)
1202 HeapFree(GetProcessHeap(), 0, Password
);
1217 PGINA_CONTEXT pgContext
;
1218 INT result
= WLX_SAS_ACTION_NONE
;
1220 pgContext
= (PGINA_CONTEXT
)GetWindowLongPtrW(hwndDlg
, GWLP_USERDATA
);
1226 pgContext
= (PGINA_CONTEXT
)lParam
;
1227 SetWindowLongPtrW(hwndDlg
, GWLP_USERDATA
, (LONG_PTR
)pgContext
);
1229 SetLockMessage(hwndDlg
, IDC_LOCKMSG
, pgContext
);
1231 SetDlgItemTextW(hwndDlg
, IDC_USERNAME
, pgContext
->UserName
);
1232 SetFocus(GetDlgItem(hwndDlg
, IDC_PASSWORD
));
1234 if (pgContext
->bDisableCAD
)
1235 EnableWindow(GetDlgItem(hwndDlg
, IDCANCEL
), FALSE
);
1237 /* Draw the logo bitmap */
1238 pgContext
->hBitmap
= LoadImageW(pgContext
->hDllInstance
, MAKEINTRESOURCEW(IDI_ROSLOGO
), IMAGE_BITMAP
, 0, 0, LR_DEFAULTCOLOR
);
1245 if (pgContext
->hBitmap
)
1247 BeginPaint(hwndDlg
, &ps
);
1248 DrawStateW(ps
.hdc
, NULL
, NULL
, (LPARAM
)pgContext
->hBitmap
, (WPARAM
)0, 0, 0, 0, 0, DST_BITMAP
);
1249 EndPaint(hwndDlg
, &ps
);
1254 DeleteObject(pgContext
->hBitmap
);
1258 switch (LOWORD(wParam
))
1261 if (DoUnlock(hwndDlg
, pgContext
, &result
))
1262 EndDialog(hwndDlg
, result
);
1266 EndDialog(hwndDlg
, WLX_SAS_ACTION_NONE
);
1278 IN OUT PGINA_CONTEXT pgContext
)
1282 TRACE("GUILockedSAS()\n");
1284 result
= pgContext
->pWlxFuncs
->WlxDialogBoxParam(
1286 pgContext
->hDllInstance
,
1287 MAKEINTRESOURCEW(IDD_UNLOCK_DLG
),
1291 if (result
>= WLX_SAS_ACTION_LOGON
&&
1292 result
<= WLX_SAS_ACTION_SWITCH_CONSOLE
)
1294 WARN("GUILockedSAS() returns 0x%x\n", result
);
1298 WARN("GUILockedSAS() failed (0x%x)\n", result
);
1299 return WLX_SAS_ACTION_NONE
;
1303 static INT_PTR CALLBACK
1310 PGINA_CONTEXT pgContext
;
1312 pgContext
= (PGINA_CONTEXT
)GetWindowLongPtrW(hwndDlg
, GWLP_USERDATA
);
1318 pgContext
= (PGINA_CONTEXT
)lParam
;
1319 SetWindowLongPtrW(hwndDlg
, GWLP_USERDATA
, (LONG_PTR
)pgContext
);
1321 /* Draw the logo bitmap */
1322 pgContext
->hBitmap
= LoadImageW(pgContext
->hDllInstance
, MAKEINTRESOURCEW(IDI_ROSLOGO
), IMAGE_BITMAP
, 0, 0, LR_DEFAULTCOLOR
);
1323 SetLockMessage(hwndDlg
, IDC_LOCKMSG
, pgContext
);
1329 if (pgContext
->hBitmap
)
1331 BeginPaint(hwndDlg
, &ps
);
1332 DrawStateW(ps
.hdc
, NULL
, NULL
, (LPARAM
)pgContext
->hBitmap
, (WPARAM
)0, 0, 0, 0, 0, DST_BITMAP
);
1333 EndPaint(hwndDlg
, &ps
);
1339 DeleteObject(pgContext
->hBitmap
);
1349 GUIDisplayLockedNotice(
1350 IN OUT PGINA_CONTEXT pgContext
)
1352 TRACE("GUIdisplayLockedNotice()\n");
1354 pgContext
->pWlxFuncs
->WlxDialogBoxParam(
1356 pgContext
->hDllInstance
,
1357 MAKEINTRESOURCEW(IDD_LOCKED_DLG
),
1363 GINA_UI GinaGraphicalUI
= {
1365 GUIDisplayStatusMessage
,
1366 GUIRemoveStatusMessage
,
1367 GUIDisplaySASNotice
,
1371 GUIDisplayLockedNotice
,