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)
13 typedef struct _DISPLAYSTATUSMSG
15 PGINA_CONTEXT Context
;
21 } DISPLAYSTATUSMSG
, *PDISPLAYSTATUSMSG
;
25 IN OUT PGINA_CONTEXT pgContext
)
27 TRACE("GUIInitialize(%p)\n", pgContext
);
31 static INT_PTR CALLBACK
32 StatusMessageWindowProc(
38 UNREFERENCED_PARAMETER(wParam
);
44 PDISPLAYSTATUSMSG msg
= (PDISPLAYSTATUSMSG
)lParam
;
48 msg
->Context
->hStatusWindow
= hwndDlg
;
51 SetWindowTextW(hwndDlg
, msg
->pTitle
);
52 SetDlgItemTextW(hwndDlg
, IDC_STATUSLABEL
, msg
->pMessage
);
53 SetEvent(msg
->StartupEvent
);
61 StartupWindowThread(LPVOID lpParam
)
64 PDISPLAYSTATUSMSG msg
= (PDISPLAYSTATUSMSG
)lpParam
;
66 /* When SetThreadDesktop is called the system closes the desktop handle when needed
67 so we have to create a new handle because this handle may still be in use by winlogon */
68 if (!DuplicateHandle ( GetCurrentProcess(),
74 DUPLICATE_SAME_ACCESS
))
76 HeapFree(GetProcessHeap(), 0, lpParam
);
80 if(!SetThreadDesktop(hDesk
))
82 HeapFree(GetProcessHeap(), 0, lpParam
);
88 MAKEINTRESOURCE(IDD_STATUSWINDOW_DLG
),
90 StatusMessageWindowProc
,
93 HeapFree(GetProcessHeap(), 0, lpParam
);
98 GUIDisplayStatusMessage(
99 IN PGINA_CONTEXT pgContext
,
105 PDISPLAYSTATUSMSG msg
;
109 TRACE("GUIDisplayStatusMessage(%ws)\n", pMessage
);
111 if (!pgContext
->hStatusWindow
)
114 * If everything goes correctly, 'msg' is freed
115 * by the 'StartupWindowThread' thread.
117 msg
= (PDISPLAYSTATUSMSG
)HeapAlloc(GetProcessHeap(),
119 sizeof(DISPLAYSTATUSMSG
));
123 msg
->Context
= pgContext
;
124 msg
->dwOptions
= dwOptions
;
125 msg
->pTitle
= pTitle
;
126 msg
->pMessage
= pMessage
;
127 msg
->hDesktop
= hDesktop
;
129 msg
->StartupEvent
= CreateEventW(NULL
,
134 if (!msg
->StartupEvent
)
136 HeapFree(GetProcessHeap(), 0, msg
);
140 Thread
= CreateThread(NULL
,
148 /* 'msg' will be freed by 'StartupWindowThread' */
151 WaitForSingleObject(msg
->StartupEvent
, INFINITE
);
152 CloseHandle(msg
->StartupEvent
);
158 * The 'StartupWindowThread' thread couldn't be created,
159 * so we need to free the allocated 'msg'.
161 HeapFree(GetProcessHeap(), 0, msg
);
168 SetWindowTextW(pgContext
->hStatusWindow
, pTitle
);
170 SetDlgItemTextW(pgContext
->hStatusWindow
, IDC_STATUSLABEL
, pMessage
);
176 GUIRemoveStatusMessage(
177 IN PGINA_CONTEXT pgContext
)
179 if (pgContext
->hStatusWindow
)
181 EndDialog(pgContext
->hStatusWindow
, 0);
182 pgContext
->hStatusWindow
= NULL
;
188 static INT_PTR CALLBACK
195 PGINA_CONTEXT pgContext
;
197 pgContext
= (PGINA_CONTEXT
)GetWindowLongPtr(hwndDlg
, GWL_USERDATA
);
203 pgContext
->hBitmap
= LoadImage(hDllInstance
, MAKEINTRESOURCE(IDI_ROSLOGO
), IMAGE_BITMAP
, 0, 0, LR_DEFAULTCOLOR
);
209 if (pgContext
->hBitmap
)
211 hdc
= BeginPaint(hwndDlg
, &ps
);
212 DrawStateW(hdc
, NULL
, NULL
, (LPARAM
)pgContext
->hBitmap
, (WPARAM
)0, 0, 0, 0, 0, DST_BITMAP
);
213 EndPaint(hwndDlg
, &ps
);
219 DeleteObject(pgContext
->hBitmap
);
228 IN OUT PGINA_CONTEXT pgContext
)
230 TRACE("GUIDisplaySASNotice()\n");
232 /* Display the notice window */
233 pgContext
->pWlxFuncs
->WlxDialogBoxParam(pgContext
->hWlx
,
234 pgContext
->hDllInstance
,
235 MAKEINTRESOURCEW(IDD_NOTICE_DLG
),
241 /* Get the text contained in a textbox. Allocates memory in pText
242 * to contain the text. Returns TRUE in case of success */
252 Count
= GetWindowTextLength(GetDlgItem(hwndDlg
, TextboxId
));
253 Text
= HeapAlloc(GetProcessHeap(), 0, (Count
+ 1) * sizeof(WCHAR
));
256 if (Count
!= GetWindowTextW(GetDlgItem(hwndDlg
, TextboxId
), Text
, Count
+ 1))
258 HeapFree(GetProcessHeap(), 0, Text
);
269 IN PGINA_CONTEXT pgContext
,
275 WCHAR szCaption
[256];
278 LoadStringW(pgContext
->hDllInstance
, uCaption
, szCaption
, 256);
279 LoadStringW(pgContext
->hDllInstance
, uText
, szText
, 256);
281 return pgContext
->pWlxFuncs
->WlxMessageBox(pgContext
->hWlx
,
292 IN PGINA_CONTEXT pgContext
,
297 WCHAR OldPassword
[256];
298 WCHAR NewPassword1
[256];
299 WCHAR NewPassword2
[256];
300 PMSV1_0_CHANGEPASSWORD_REQUEST RequestBuffer
= NULL
;
301 PMSV1_0_CHANGEPASSWORD_RESPONSE ResponseBuffer
= NULL
;
302 ULONG RequestBufferSize
;
303 ULONG ResponseBufferSize
= 0;
306 NTSTATUS ProtocolStatus
;
309 GetDlgItemTextW(hwndDlg
, IDC_CHANGEPWD_USERNAME
, UserName
, 256);
310 GetDlgItemTextW(hwndDlg
, IDC_CHANGEPWD_DOMAIN
, Domain
, 256);
311 GetDlgItemTextW(hwndDlg
, IDC_CHANGEPWD_OLDPWD
, OldPassword
, 256);
312 GetDlgItemTextW(hwndDlg
, IDC_CHANGEPWD_NEWPWD1
, NewPassword1
, 256);
313 GetDlgItemTextW(hwndDlg
, IDC_CHANGEPWD_NEWPWD2
, NewPassword2
, 256);
315 /* Compare the two passwords and fail if they do not match */
316 if (wcscmp(NewPassword1
, NewPassword2
) != 0)
318 ResourceMessageBox(pgContext
,
320 MB_OK
| MB_ICONEXCLAMATION
,
322 IDS_NONMATCHINGPASSWORDS
);
326 /* Calculate the request buffer size */
327 RequestBufferSize
= sizeof(MSV1_0_CHANGEPASSWORD_REQUEST
) +
328 ((wcslen(Domain
) + 1) * sizeof(WCHAR
)) +
329 ((wcslen(UserName
) + 1) * sizeof(WCHAR
)) +
330 ((wcslen(OldPassword
) + 1) * sizeof(WCHAR
)) +
331 ((wcslen(NewPassword1
) + 1) * sizeof(WCHAR
));
333 /* Allocate the request buffer */
334 RequestBuffer
= HeapAlloc(GetProcessHeap(),
337 if (RequestBuffer
== NULL
)
339 ERR("HeapAlloc failed\n");
343 /* Initialize the request buffer */
344 RequestBuffer
->MessageType
= MsV1_0ChangePassword
;
345 RequestBuffer
->Impersonating
= TRUE
;
347 Ptr
= (LPWSTR
)((ULONG_PTR
)RequestBuffer
+ sizeof(MSV1_0_CHANGEPASSWORD_REQUEST
));
349 /* Pack the domain name */
350 RequestBuffer
->DomainName
.Length
= wcslen(Domain
) * sizeof(WCHAR
);
351 RequestBuffer
->DomainName
.MaximumLength
= RequestBuffer
->DomainName
.Length
+ sizeof(WCHAR
);
352 RequestBuffer
->DomainName
.Buffer
= Ptr
;
354 RtlCopyMemory(RequestBuffer
->DomainName
.Buffer
,
356 RequestBuffer
->DomainName
.MaximumLength
);
358 Ptr
= (LPWSTR
)((ULONG_PTR
)Ptr
+ RequestBuffer
->DomainName
.MaximumLength
);
360 /* Pack the user name */
361 RequestBuffer
->AccountName
.Length
= wcslen(UserName
) * sizeof(WCHAR
);
362 RequestBuffer
->AccountName
.MaximumLength
= RequestBuffer
->AccountName
.Length
+ sizeof(WCHAR
);
363 RequestBuffer
->AccountName
.Buffer
= Ptr
;
365 RtlCopyMemory(RequestBuffer
->AccountName
.Buffer
,
367 RequestBuffer
->AccountName
.MaximumLength
);
369 Ptr
= (LPWSTR
)((ULONG_PTR
)Ptr
+ RequestBuffer
->AccountName
.MaximumLength
);
371 /* Pack the old password */
372 RequestBuffer
->OldPassword
.Length
= wcslen(OldPassword
) * sizeof(WCHAR
);
373 RequestBuffer
->OldPassword
.MaximumLength
= RequestBuffer
->OldPassword
.Length
+ sizeof(WCHAR
);
374 RequestBuffer
->OldPassword
.Buffer
= Ptr
;
376 RtlCopyMemory(RequestBuffer
->OldPassword
.Buffer
,
378 RequestBuffer
->OldPassword
.MaximumLength
);
380 Ptr
= (LPWSTR
)((ULONG_PTR
)Ptr
+ RequestBuffer
->OldPassword
.MaximumLength
);
382 /* Pack the new password */
383 RequestBuffer
->NewPassword
.Length
= wcslen(NewPassword1
) * sizeof(WCHAR
);
384 RequestBuffer
->NewPassword
.MaximumLength
= RequestBuffer
->NewPassword
.Length
+ sizeof(WCHAR
);
385 RequestBuffer
->NewPassword
.Buffer
= Ptr
;
387 RtlCopyMemory(RequestBuffer
->NewPassword
.Buffer
,
389 RequestBuffer
->NewPassword
.MaximumLength
);
391 /* Connect to the LSA server */
392 if (!ConnectToLsa(pgContext
))
394 ERR("ConnectToLsa() failed\n");
398 /* Call the authentication package */
399 Status
= LsaCallAuthenticationPackage(pgContext
->LsaHandle
,
400 pgContext
->AuthenticationPackage
,
403 (PVOID
*)&ResponseBuffer
,
406 if (!NT_SUCCESS(Status
))
408 ERR("LsaCallAuthenticationPackage failed (Status 0x%08lx)\n", Status
);
412 if (!NT_SUCCESS(ProtocolStatus
))
414 TRACE("LsaCallAuthenticationPackage failed (ProtocolStatus 0x%08lx)\n", ProtocolStatus
);
420 ResourceMessageBox(pgContext
,
422 MB_OK
| MB_ICONINFORMATION
,
424 IDS_PASSWORDCHANGED
);
426 if ((wcscmp(UserName
, pgContext
->UserName
) == 0) &&
427 (wcscmp(Domain
, pgContext
->Domain
) == 0) &&
428 (wcscmp(OldPassword
, pgContext
->Password
) == 0))
430 ZeroMemory(pgContext
->Password
, 256 * sizeof(WCHAR
));
431 wcscpy(pgContext
->Password
, NewPassword1
);
435 if (RequestBuffer
!= NULL
)
436 HeapFree(GetProcessHeap(), 0, RequestBuffer
);
438 if (ResponseBuffer
!= NULL
)
439 LsaFreeReturnBuffer(ResponseBuffer
);
445 static INT_PTR CALLBACK
446 ChangePasswordDialogProc(
452 PGINA_CONTEXT pgContext
;
454 pgContext
= (PGINA_CONTEXT
)GetWindowLongPtr(hwndDlg
, GWL_USERDATA
);
459 pgContext
= (PGINA_CONTEXT
)lParam
;
460 SetWindowLongPtr(hwndDlg
, GWL_USERDATA
, (DWORD_PTR
)pgContext
);
462 SetDlgItemTextW(hwndDlg
, IDC_CHANGEPWD_USERNAME
, pgContext
->UserName
);
463 SendDlgItemMessageW(hwndDlg
, IDC_CHANGEPWD_DOMAIN
, CB_ADDSTRING
, 0, (LPARAM
)pgContext
->Domain
);
464 SendDlgItemMessageW(hwndDlg
, IDC_CHANGEPWD_DOMAIN
, CB_SETCURSEL
, 0, 0);
465 SetFocus(GetDlgItem(hwndDlg
, IDC_CHANGEPWD_OLDPWD
));
469 switch (LOWORD(wParam
))
472 if (DoChangePassword(pgContext
, hwndDlg
))
474 EndDialog(hwndDlg
, TRUE
);
478 SetDlgItemTextW(hwndDlg
, IDC_CHANGEPWD_NEWPWD1
, NULL
);
479 SetDlgItemTextW(hwndDlg
, IDC_CHANGEPWD_NEWPWD2
, NULL
);
480 SetFocus(GetDlgItem(hwndDlg
, IDC_CHANGEPWD_OLDPWD
));
485 EndDialog(hwndDlg
, FALSE
);
491 EndDialog(hwndDlg
, FALSE
);
500 OnInitSecurityDlg(HWND hwnd
,
501 PGINA_CONTEXT pgContext
)
508 LoadStringW(pgContext
->hDllInstance
, IDS_LOGONMSG
, Buffer1
, 256);
510 wsprintfW(Buffer2
, L
"%s\\%s", pgContext
->Domain
, pgContext
->UserName
);
511 wsprintfW(Buffer4
, Buffer1
, Buffer2
);
513 SetDlgItemTextW(hwnd
, IDC_LOGONMSG
, Buffer4
);
515 LoadStringW(pgContext
->hDllInstance
, IDS_LOGONDATE
, Buffer1
, 256);
517 GetDateFormatW(LOCALE_USER_DEFAULT
, DATE_SHORTDATE
,
518 (SYSTEMTIME
*)&pgContext
->LogonTime
, NULL
, Buffer2
, 256);
520 GetTimeFormatW(LOCALE_USER_DEFAULT
, 0,
521 (SYSTEMTIME
*)&pgContext
->LogonTime
, NULL
, Buffer3
, 256);
523 wsprintfW(Buffer4
, Buffer1
, Buffer2
, Buffer3
);
525 SetDlgItemTextW(hwnd
, IDC_LOGONDATE
, Buffer4
);
527 if (pgContext
->bAutoAdminLogon
== TRUE
)
528 EnableWindow(GetDlgItem(hwnd
, IDC_LOGOFF
), FALSE
);
535 IN PGINA_CONTEXT pgContext
)
539 TRACE("OnChangePassword()\n");
541 res
= pgContext
->pWlxFuncs
->WlxDialogBoxParam(
543 pgContext
->hDllInstance
,
544 MAKEINTRESOURCEW(IDD_CHANGE_PASSWORD
),
546 ChangePasswordDialogProc
,
549 TRACE("Result: %x\n", res
);
555 static INT_PTR CALLBACK
568 switch (LOWORD(wParam
))
571 EndDialog(hwndDlg
, IDYES
);
575 EndDialog(hwndDlg
, IDNO
);
581 EndDialog(hwndDlg
, IDNO
);
593 IN PGINA_CONTEXT pgContext
)
595 return pgContext
->pWlxFuncs
->WlxDialogBoxParam(
597 pgContext
->hDllInstance
,
598 MAKEINTRESOURCEW(IDD_LOGOFF_DLG
),
611 UINT shutdownDescId
= 0;
612 int shutdownCode
= 0;
614 shutdownCode
= SendDlgItemMessageW(hwnd
, IDC_SHUTDOWN_LIST
, CB_GETCURSEL
, 0, 0);
616 switch (shutdownCode
)
618 case 0: /* Log off */
619 shutdownDescId
= IDS_SHUTDOWN_LOGOFF_DESC
;
622 case 1: /* Shut down */
623 shutdownDescId
= IDS_SHUTDOWN_SHUTDOWN_DESC
;
626 case 2: /* Restart */
627 shutdownDescId
= IDS_SHUTDOWN_RESTART_DESC
;
631 shutdownDescId
= IDS_SHUTDOWN_SLEEP_DESC
;
634 case 4: /* Hibernate */
635 shutdownDescId
= IDS_SHUTDOWN_HIBERNATE_DESC
;
642 LoadStringW(hDllInstance
, shutdownDescId
, szBuffer
, sizeof(szBuffer
));
643 SetDlgItemTextW(hwnd
, IDC_SHUTDOWN_DESCRIPTION
, szBuffer
);
651 IN PGINA_CONTEXT pgContext
)
654 WCHAR szBuffer2
[256];
658 hwndList
= GetDlgItem(hwndDlg
, IDC_SHUTDOWN_LIST
);
660 /* Clears the content before it's used */
661 SendMessageW(hwndList
, CB_RESETCONTENT
, 0, 0);
664 LoadStringW(hDllInstance
, IDS_SHUTDOWN_LOGOFF
, szBuffer
, sizeof(szBuffer
) / sizeof(WCHAR
));
665 wsprintfW(szBuffer2
, szBuffer
, pgContext
->UserName
);
666 idx
= SendMessageW(hwndList
, CB_ADDSTRING
, 0, (LPARAM
)szBuffer2
);
668 SendMessageW(hwndList
, CB_SETITEMDATA
, idx
, WLX_SAS_ACTION_LOGOFF
);
671 LoadStringW(hDllInstance
, IDS_SHUTDOWN_SHUTDOWN
, szBuffer
, sizeof(szBuffer
) / sizeof(WCHAR
));
672 idx
= SendMessageW(hwndList
, CB_ADDSTRING
, 0, (LPARAM
)szBuffer
);
674 SendMessageW(hwndList
, CB_SETITEMDATA
, idx
, WLX_SAS_ACTION_SHUTDOWN_POWER_OFF
);
677 LoadStringW(hDllInstance
, IDS_SHUTDOWN_RESTART
, szBuffer
, sizeof(szBuffer
) / sizeof(WCHAR
));
678 idx
= SendMessageW(hwndList
, CB_ADDSTRING
, 0, (LPARAM
)szBuffer
);
680 SendMessageW(hwndList
, CB_SETITEMDATA
, idx
, WLX_SAS_ACTION_SHUTDOWN_REBOOT
);
684 LoadStringW(hDllInstance
, IDS_SHUTDOWN_SLEEP
, szBuffer
, sizeof(szBuffer
) / sizeof(WCHAR
));
685 idx
= SendMessageW(hwndList
, CB_ADDSTRING
, 0, (LPARAM
)szBuffer
);
687 SendMessageW(hwndList
, CB_SETITEMDATA
, idx
, WLX_SAS_ACTION_SHUTDOWN_SLEEP
);
692 LoadStringW(hDllInstance
, IDS_SHUTDOWN_HIBERNATE
, szBuffer
, sizeof(szBuffer
) / sizeof(WCHAR
));
693 idx
= SendMessageW(hwndList
, CB_ADDSTRING
, 0, (LPARAM
)szBuffer
);
695 SendMessageW(hwndList
, CB_SETITEMDATA
, idx
, WLX_SAS_ACTION_SHUTDOWN_HIBERNATE
);
698 /* Sets the default shut down selection */
699 count
= SendMessageW(hwndList
, CB_GETCOUNT
, 0, 0);
700 for (i
= 0; i
< count
; i
++)
702 if (pgContext
->nShutdownAction
== SendMessageW(hwndList
, CB_GETITEMDATA
, i
, 0))
704 SendMessageW(hwndList
, CB_SETCURSEL
, i
, 0);
709 /* Updates the choice description based on the current selection */
710 UpdateShutdownDesc(hwndDlg
);
718 IN PGINA_CONTEXT pgContext
)
722 idx
= SendDlgItemMessageW(hwndDlg
,
729 pgContext
->nShutdownAction
= SendDlgItemMessageW(hwndDlg
,
746 PGINA_CONTEXT pgContext
;
748 pgContext
= (PGINA_CONTEXT
)GetWindowLongPtr(hwnd
, GWL_USERDATA
);
753 pgContext
= (PGINA_CONTEXT
)lParam
;
754 SetWindowLongPtr(hwnd
, GWL_USERDATA
, (INT_PTR
)pgContext
);
756 ShutDownOnInit(hwnd
, pgContext
);
758 /* Draw the logo graphic */
759 pgContext
->hBitmap
= LoadImage(hDllInstance
, MAKEINTRESOURCE(IDI_ROSLOGO
), IMAGE_BITMAP
, 0, 0, LR_DEFAULTCOLOR
);
766 if (pgContext
->hBitmap
)
768 hdc
= BeginPaint(hwnd
, &ps
);
769 DrawStateW(hdc
, NULL
, NULL
, (LPARAM
)pgContext
->hBitmap
, (WPARAM
)0, 0, 0, 0, 0, DST_BITMAP
);
776 DeleteObject(pgContext
->hBitmap
);
780 switch(LOWORD(wParam
))
783 ShutDownOnOk(hwnd
, pgContext
);
784 EndDialog(hwnd
, IDOK
);
788 EndDialog(hwnd
, IDCANCEL
);
791 case IDC_SHUTDOWN_LIST
:
792 UpdateShutdownDesc(hwnd
);
808 IN PGINA_CONTEXT pgContext
)
810 return pgContext
->pWlxFuncs
->WlxDialogBoxParam(
812 pgContext
->hDllInstance
,
813 MAKEINTRESOURCEW(IDD_SHUTDOWN_DLG
),
820 static INT_PTR CALLBACK
827 PGINA_CONTEXT pgContext
;
829 pgContext
= (PGINA_CONTEXT
)GetWindowLongPtr(hwndDlg
, GWL_USERDATA
);
835 pgContext
= (PGINA_CONTEXT
)lParam
;
836 SetWindowLongPtr(hwndDlg
, GWL_USERDATA
, (DWORD_PTR
)pgContext
);
838 OnInitSecurityDlg(hwndDlg
, (PGINA_CONTEXT
)lParam
);
839 SetFocus(GetDlgItem(hwndDlg
, IDNO
));
845 switch (LOWORD(wParam
))
848 EndDialog(hwndDlg
, WLX_SAS_ACTION_LOCK_WKSTA
);
851 if (OnLogOff(hwndDlg
, pgContext
) == IDYES
)
852 EndDialog(hwndDlg
, WLX_SAS_ACTION_LOGOFF
);
855 if (OnShutDown(hwndDlg
, pgContext
) == IDOK
)
856 EndDialog(hwndDlg
, pgContext
->nShutdownAction
);
859 if (OnChangePassword(hwndDlg
, pgContext
))
860 EndDialog(hwndDlg
, WLX_SAS_ACTION_PWD_CHANGED
);
863 EndDialog(hwndDlg
, WLX_SAS_ACTION_TASKLIST
);
866 EndDialog(hwndDlg
, WLX_SAS_ACTION_NONE
);
873 EndDialog(hwndDlg
, WLX_SAS_ACTION_NONE
);
883 IN OUT PGINA_CONTEXT pgContext
,
888 TRACE("GUILoggedOnSAS()\n");
890 if (dwSasType
!= WLX_SAS_TYPE_CTRL_ALT_DEL
)
892 /* Nothing to do for WLX_SAS_TYPE_TIMEOUT ; the dialog will
893 * close itself thanks to the use of WlxDialogBoxParam */
894 return WLX_SAS_ACTION_NONE
;
897 pgContext
->pWlxFuncs
->WlxSwitchDesktopToWinlogon(
900 result
= pgContext
->pWlxFuncs
->WlxDialogBoxParam(
902 pgContext
->hDllInstance
,
903 MAKEINTRESOURCEW(IDD_LOGGEDON_DLG
),
908 if (result
< WLX_SAS_ACTION_LOGON
||
909 result
> WLX_SAS_ACTION_SWITCH_CONSOLE
)
911 result
= WLX_SAS_ACTION_NONE
;
914 if (result
== WLX_SAS_ACTION_NONE
)
916 pgContext
->pWlxFuncs
->WlxSwitchDesktopToUser(
928 IN OUT PGINA_CONTEXT pgContext
)
930 LPWSTR UserName
= NULL
;
931 LPWSTR Password
= NULL
;
932 LPWSTR Domain
= NULL
;
934 NTSTATUS Status
, SubStatus
= STATUS_SUCCESS
;
936 if (GetTextboxText(hwndDlg
, IDC_USERNAME
, &UserName
) && *UserName
== '\0')
939 if (GetTextboxText(hwndDlg
, IDC_LOGON_TO
, &Domain
) && *Domain
== '\0')
942 if (!GetTextboxText(hwndDlg
, IDC_PASSWORD
, &Password
))
945 Status
= DoLoginTasks(pgContext
, UserName
, Domain
, Password
, &SubStatus
);
946 if (Status
== STATUS_LOGON_FAILURE
)
948 ResourceMessageBox(pgContext
,
950 MB_OK
| MB_ICONEXCLAMATION
,
952 IDS_LOGONWRONGUSERORPWD
);
955 else if (Status
== STATUS_ACCOUNT_RESTRICTION
)
957 TRACE("DoLoginTasks failed! Status 0x%08lx SubStatus 0x%08lx\n", Status
, SubStatus
);
959 if (SubStatus
== STATUS_ACCOUNT_DISABLED
)
961 ResourceMessageBox(pgContext
,
963 MB_OK
| MB_ICONEXCLAMATION
,
965 IDS_LOGONUSERDISABLED
);
968 else if (SubStatus
== STATUS_ACCOUNT_LOCKED_OUT
)
970 TRACE("Account locked!\n");
971 pgContext
->pWlxFuncs
->WlxMessageBox(pgContext
->hWlx
,
975 MB_OK
| MB_ICONERROR
);
980 TRACE("Other error!\n");
981 pgContext
->pWlxFuncs
->WlxMessageBox(pgContext
->hWlx
,
985 MB_OK
| MB_ICONERROR
);
989 else if (!NT_SUCCESS(Status
))
991 TRACE("DoLoginTasks failed! Status 0x%08lx\n", Status
);
997 if (!CreateProfile(pgContext
, UserName
, Domain
, Password
))
999 ERR("Failed to create the profile!\n");
1003 ZeroMemory(pgContext
->Password
, 256 * sizeof(WCHAR
));
1004 wcscpy(pgContext
->Password
, Password
);
1009 if (UserName
!= NULL
)
1010 HeapFree(GetProcessHeap(), 0, UserName
);
1012 if (Password
!= NULL
)
1013 HeapFree(GetProcessHeap(), 0, Password
);
1016 HeapFree(GetProcessHeap(), 0, Domain
);
1021 static INT_PTR CALLBACK
1022 LoggedOutWindowProc(
1028 PGINA_CONTEXT pgContext
;
1030 pgContext
= (PGINA_CONTEXT
)GetWindowLongPtr(hwndDlg
, GWL_USERDATA
);
1035 /* FIXME: take care of NoDomainUI */
1036 pgContext
= (PGINA_CONTEXT
)lParam
;
1037 SetWindowLongPtr(hwndDlg
, GWL_USERDATA
, (DWORD_PTR
)pgContext
);
1039 if (pgContext
->bDontDisplayLastUserName
== FALSE
)
1040 SetDlgItemTextW(hwndDlg
, IDC_USERNAME
, pgContext
->UserName
);
1042 if (pgContext
->bDisableCAD
== TRUE
)
1043 EnableWindow(GetDlgItem(hwndDlg
, IDCANCEL
), FALSE
);
1045 if (pgContext
->bShutdownWithoutLogon
== FALSE
)
1046 EnableWindow(GetDlgItem(hwndDlg
, IDC_SHUTDOWN
), FALSE
);
1048 SendDlgItemMessageW(hwndDlg
, IDC_LOGON_TO
, CB_ADDSTRING
, 0, (LPARAM
)pgContext
->Domain
);
1049 SendDlgItemMessageW(hwndDlg
, IDC_LOGON_TO
, CB_SETCURSEL
, 0, 0);
1051 SetFocus(GetDlgItem(hwndDlg
, pgContext
->bDontDisplayLastUserName
? IDC_USERNAME
: IDC_PASSWORD
));
1053 pgContext
->hBitmap
= LoadImage(hDllInstance
, MAKEINTRESOURCE(IDI_ROSLOGO
), IMAGE_BITMAP
, 0, 0, LR_DEFAULTCOLOR
);
1060 if (pgContext
->hBitmap
)
1062 hdc
= BeginPaint(hwndDlg
, &ps
);
1063 DrawStateW(hdc
, NULL
, NULL
, (LPARAM
)pgContext
->hBitmap
, (WPARAM
)0, 0, 0, 0, 0, DST_BITMAP
);
1064 EndPaint(hwndDlg
, &ps
);
1070 DeleteObject(pgContext
->hBitmap
);
1074 switch (LOWORD(wParam
))
1077 if (DoLogon(hwndDlg
, pgContext
))
1078 EndDialog(hwndDlg
, WLX_SAS_ACTION_LOGON
);
1082 EndDialog(hwndDlg
, WLX_SAS_ACTION_NONE
);
1086 EndDialog(hwndDlg
, WLX_SAS_ACTION_SHUTDOWN
);
1097 IN OUT PGINA_CONTEXT pgContext
)
1101 TRACE("GUILoggedOutSAS()\n");
1103 result
= pgContext
->pWlxFuncs
->WlxDialogBoxParam(
1105 pgContext
->hDllInstance
,
1106 MAKEINTRESOURCEW(IDD_LOGGEDOUT_DLG
),
1108 LoggedOutWindowProc
,
1110 if (result
>= WLX_SAS_ACTION_LOGON
&&
1111 result
<= WLX_SAS_ACTION_SWITCH_CONSOLE
)
1113 WARN("WlxLoggedOutSAS() returns 0x%x\n", result
);
1117 WARN("WlxDialogBoxParam() failed (0x%x)\n", result
);
1118 return WLX_SAS_ACTION_NONE
;
1123 SetLockMessage(HWND hwnd
,
1125 PGINA_CONTEXT pgContext
)
1131 LoadStringW(pgContext
->hDllInstance
, IDS_LOCKMSG
, Buffer1
, 256);
1133 wsprintfW(Buffer2
, L
"%s\\%s", pgContext
->Domain
, pgContext
->UserName
);
1134 wsprintfW(Buffer3
, Buffer1
, Buffer2
);
1136 SetDlgItemTextW(hwnd
, nDlgItem
, Buffer3
);
1144 IN PGINA_CONTEXT pgContext
,
1149 LPWSTR UserName
= NULL
;
1150 LPWSTR Password
= NULL
;
1153 if (GetTextboxText(hwndDlg
, IDC_USERNAME
, &UserName
) && *UserName
== '\0')
1156 if (GetTextboxText(hwndDlg
, IDC_PASSWORD
, &Password
))
1158 if (UserName
!= NULL
&& Password
!= NULL
&&
1159 wcscmp(UserName
, pgContext
->UserName
) == 0 &&
1160 wcscmp(Password
, pgContext
->Password
) == 0)
1162 *Action
= WLX_SAS_ACTION_UNLOCK_WKSTA
;
1165 else if (wcscmp(UserName
, pgContext
->UserName
) == 0 &&
1166 wcscmp(Password
, pgContext
->Password
) != 0)
1168 /* Wrong Password */
1169 LoadStringW(pgContext
->hDllInstance
, IDS_LOCKEDWRONGPASSWORD
, Buffer2
, 256);
1170 LoadStringW(pgContext
->hDllInstance
, IDS_COMPUTERLOCKED
, Buffer1
, 256);
1171 MessageBoxW(hwndDlg
, Buffer2
, Buffer1
, MB_OK
| MB_ICONERROR
);
1175 /* Wrong user name */
1176 if (DoAdminUnlock(pgContext
, UserName
, NULL
, Password
))
1178 *Action
= WLX_SAS_ACTION_UNLOCK_WKSTA
;
1183 LoadStringW(pgContext
->hDllInstance
, IDS_LOCKEDWRONGUSER
, Buffer1
, 256);
1184 wsprintfW(Buffer2
, Buffer1
, pgContext
->Domain
, pgContext
->UserName
);
1185 LoadStringW(pgContext
->hDllInstance
, IDS_COMPUTERLOCKED
, Buffer1
, 256);
1186 MessageBoxW(hwndDlg
, Buffer2
, Buffer1
, MB_OK
| MB_ICONERROR
);
1191 if (UserName
!= NULL
)
1192 HeapFree(GetProcessHeap(), 0, UserName
);
1194 if (Password
!= NULL
)
1195 HeapFree(GetProcessHeap(), 0, Password
);
1210 PGINA_CONTEXT pgContext
;
1211 INT result
= WLX_SAS_ACTION_NONE
;
1213 pgContext
= (PGINA_CONTEXT
)GetWindowLongPtr(hwndDlg
, GWL_USERDATA
);
1218 pgContext
= (PGINA_CONTEXT
)lParam
;
1219 SetWindowLongPtr(hwndDlg
, GWL_USERDATA
, (DWORD_PTR
)pgContext
);
1221 SetLockMessage(hwndDlg
, IDC_LOCKMSG
, pgContext
);
1223 SetDlgItemTextW(hwndDlg
, IDC_USERNAME
, pgContext
->UserName
);
1224 SetFocus(GetDlgItem(hwndDlg
, IDC_PASSWORD
));
1226 if (pgContext
->bDisableCAD
== TRUE
)
1227 EnableWindow(GetDlgItem(hwndDlg
, IDCANCEL
), FALSE
);
1229 pgContext
->hBitmap
= LoadImage(hDllInstance
, MAKEINTRESOURCE(IDI_ROSLOGO
), IMAGE_BITMAP
, 0, 0, LR_DEFAULTCOLOR
);
1236 if (pgContext
->hBitmap
)
1238 hdc
= BeginPaint(hwndDlg
, &ps
);
1239 DrawStateW(hdc
, NULL
, NULL
, (LPARAM
)pgContext
->hBitmap
, (WPARAM
)0, 0, 0, 0, 0, DST_BITMAP
);
1240 EndPaint(hwndDlg
, &ps
);
1245 DeleteObject(pgContext
->hBitmap
);
1249 switch (LOWORD(wParam
))
1252 if (DoUnlock(hwndDlg
, pgContext
, &result
))
1253 EndDialog(hwndDlg
, result
);
1257 EndDialog(hwndDlg
, WLX_SAS_ACTION_NONE
);
1269 IN OUT PGINA_CONTEXT pgContext
)
1273 TRACE("GUILockedSAS()\n");
1275 result
= pgContext
->pWlxFuncs
->WlxDialogBoxParam(
1277 pgContext
->hDllInstance
,
1278 MAKEINTRESOURCEW(IDD_UNLOCK_DLG
),
1282 if (result
>= WLX_SAS_ACTION_LOGON
&&
1283 result
<= WLX_SAS_ACTION_SWITCH_CONSOLE
)
1285 WARN("GUILockedSAS() returns 0x%x\n", result
);
1289 WARN("GUILockedSAS() failed (0x%x)\n", result
);
1290 return WLX_SAS_ACTION_NONE
;
1294 static INT_PTR CALLBACK
1301 PGINA_CONTEXT pgContext
;
1303 pgContext
= (PGINA_CONTEXT
)GetWindowLongPtr(hwndDlg
, GWL_USERDATA
);
1309 pgContext
= (PGINA_CONTEXT
)lParam
;
1310 SetWindowLongPtr(hwndDlg
, GWL_USERDATA
, (DWORD_PTR
)pgContext
);
1312 pgContext
->hBitmap
= LoadImage(hDllInstance
, MAKEINTRESOURCE(IDI_ROSLOGO
), IMAGE_BITMAP
, 0, 0, LR_DEFAULTCOLOR
);
1313 SetLockMessage(hwndDlg
, IDC_LOCKMSG
, pgContext
);
1320 if (pgContext
->hBitmap
)
1322 hdc
= BeginPaint(hwndDlg
, &ps
);
1323 DrawStateW(hdc
, NULL
, NULL
, (LPARAM
)pgContext
->hBitmap
, (WPARAM
)0, 0, 0, 0, 0, DST_BITMAP
);
1324 EndPaint(hwndDlg
, &ps
);
1330 DeleteObject(pgContext
->hBitmap
);
1340 GUIDisplayLockedNotice(
1341 IN OUT PGINA_CONTEXT pgContext
)
1343 TRACE("GUIdisplayLockedNotice()\n");
1345 pgContext
->pWlxFuncs
->WlxDialogBoxParam(
1347 pgContext
->hDllInstance
,
1348 MAKEINTRESOURCEW(IDD_LOCKED_DLG
),
1354 GINA_UI GinaGraphicalUI
= {
1356 GUIDisplayStatusMessage
,
1357 GUIRemoveStatusMessage
,
1358 GUIDisplaySASNotice
,
1362 GUIDisplayLockedNotice
,