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)
10 typedef struct _DISPLAYSTATUSMSG
12 PGINA_CONTEXT Context
;
18 } DISPLAYSTATUSMSG
, *PDISPLAYSTATUSMSG
;
22 IN OUT PGINA_CONTEXT pgContext
)
24 TRACE("GUIInitialize(%p)\n", pgContext
);
28 static INT_PTR CALLBACK
29 StatusMessageWindowProc(
35 UNREFERENCED_PARAMETER(wParam
);
41 PDISPLAYSTATUSMSG msg
= (PDISPLAYSTATUSMSG
)lParam
;
45 msg
->Context
->hStatusWindow
= hwndDlg
;
48 SetWindowTextW(hwndDlg
, msg
->pTitle
);
49 SetDlgItemTextW(hwndDlg
, IDC_STATUSLABEL
, msg
->pMessage
);
50 SetEvent(msg
->StartupEvent
);
58 StartupWindowThread(LPVOID lpParam
)
61 PDISPLAYSTATUSMSG msg
= (PDISPLAYSTATUSMSG
)lpParam
;
63 /* When SetThreadDesktop is called the system closes the desktop handle when needed
64 so we have to create a new handle because this handle may still be in use by winlogon */
65 if (!DuplicateHandle ( GetCurrentProcess(),
71 DUPLICATE_SAME_ACCESS
))
73 HeapFree(GetProcessHeap(), 0, lpParam
);
77 if(!SetThreadDesktop(hDesk
))
79 HeapFree(GetProcessHeap(), 0, lpParam
);
85 MAKEINTRESOURCE(IDD_STATUSWINDOW_DLG
),
87 StatusMessageWindowProc
,
90 HeapFree(GetProcessHeap(), 0, lpParam
);
95 GUIDisplayStatusMessage(
96 IN PGINA_CONTEXT pgContext
,
102 PDISPLAYSTATUSMSG msg
;
106 TRACE("GUIDisplayStatusMessage(%ws)\n", pMessage
);
108 if (!pgContext
->hStatusWindow
)
110 msg
= (PDISPLAYSTATUSMSG
)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(DISPLAYSTATUSMSG
));
114 msg
->Context
= pgContext
;
115 msg
->dwOptions
= dwOptions
;
116 msg
->pTitle
= pTitle
;
117 msg
->pMessage
= pMessage
;
118 msg
->hDesktop
= hDesktop
;
120 msg
->StartupEvent
= CreateEventW(
126 if (!msg
->StartupEvent
)
129 Thread
= CreateThread(
139 WaitForSingleObject(msg
->StartupEvent
, INFINITE
);
140 CloseHandle(msg
->StartupEvent
);
148 SetWindowTextW(pgContext
->hStatusWindow
, pTitle
);
150 SetDlgItemTextW(pgContext
->hStatusWindow
, IDC_STATUSLABEL
, pMessage
);
156 GUIRemoveStatusMessage(
157 IN PGINA_CONTEXT pgContext
)
159 if (pgContext
->hStatusWindow
)
161 EndDialog(pgContext
->hStatusWindow
, 0);
162 pgContext
->hStatusWindow
= NULL
;
168 static INT_PTR CALLBACK
175 UNREFERENCED_PARAMETER(hwndDlg
);
176 UNREFERENCED_PARAMETER(uMsg
);
177 UNREFERENCED_PARAMETER(wParam
);
178 UNREFERENCED_PARAMETER(lParam
);
185 IN OUT PGINA_CONTEXT pgContext
)
187 TRACE("GUIDisplaySASNotice()\n");
189 /* Display the notice window */
190 pgContext
->pWlxFuncs
->WlxDialogBoxParam(pgContext
->hWlx
,
191 pgContext
->hDllInstance
,
192 MAKEINTRESOURCEW(IDD_NOTICE_DLG
),
198 /* Get the text contained in a textbox. Allocates memory in pText
199 * to contain the text. Returns TRUE in case of success */
209 Count
= GetWindowTextLength(GetDlgItem(hwndDlg
, TextboxId
));
210 Text
= HeapAlloc(GetProcessHeap(), 0, (Count
+ 1) * sizeof(WCHAR
));
213 if (Count
!= GetWindowTextW(GetDlgItem(hwndDlg
, TextboxId
), Text
, Count
+ 1))
215 HeapFree(GetProcessHeap(), 0, Text
);
223 static INT_PTR CALLBACK
224 ChangePasswordDialogProc(
233 FIXME("ChangePasswordDialogProc: WM_INITDLG\n");
237 switch (LOWORD(wParam
))
240 EndDialog(hwndDlg
, TRUE
);
244 EndDialog(hwndDlg
, FALSE
);
250 EndDialog(hwndDlg
, FALSE
);
259 OnInitSecurityDlg(HWND hwnd
,
260 PGINA_CONTEXT pgContext
)
267 LoadStringW(pgContext
->hDllInstance
, IDS_LOGONMSG
, Buffer1
, 256);
269 wsprintfW(Buffer2
, L
"%s\\%s", pgContext
->Domain
, pgContext
->UserName
);
270 wsprintfW(Buffer4
, Buffer1
, Buffer2
);
272 SetDlgItemTextW(hwnd
, IDC_LOGONMSG
, Buffer4
);
274 LoadStringW(pgContext
->hDllInstance
, IDS_LOGONDATE
, Buffer1
, 256);
276 GetDateFormatW(LOCALE_USER_DEFAULT
, DATE_SHORTDATE
,
277 (SYSTEMTIME
*)&pgContext
->LogonTime
, NULL
, Buffer2
, 256);
279 GetTimeFormatW(LOCALE_USER_DEFAULT
, 0,
280 (SYSTEMTIME
*)&pgContext
->LogonTime
, NULL
, Buffer3
, 256);
282 wsprintfW(Buffer4
, Buffer1
, Buffer2
, Buffer3
);
284 SetDlgItemTextW(hwnd
, IDC_LOGONDATE
, Buffer4
);
291 IN PGINA_CONTEXT pgContext
)
295 FIXME("OnChangePassword()\n");
297 res
= pgContext
->pWlxFuncs
->WlxDialogBoxParam(
299 pgContext
->hDllInstance
,
300 MAKEINTRESOURCEW(IDD_CHANGE_PASSWORD
),
302 ChangePasswordDialogProc
,
305 FIXME("Result: %x\n", res
);
311 static INT_PTR CALLBACK
318 PGINA_CONTEXT pgContext
;
320 pgContext
= (PGINA_CONTEXT
)GetWindowLongPtr(hwndDlg
, GWL_USERDATA
);
326 pgContext
= (PGINA_CONTEXT
)lParam
;
327 SetWindowLongPtr(hwndDlg
, GWL_USERDATA
, (DWORD_PTR
)pgContext
);
329 OnInitSecurityDlg(hwndDlg
, (PGINA_CONTEXT
)lParam
);
330 SetFocus(GetDlgItem(hwndDlg
, IDNO
));
336 switch (LOWORD(wParam
))
339 EndDialog(hwndDlg
, WLX_SAS_ACTION_LOCK_WKSTA
);
342 EndDialog(hwndDlg
, WLX_SAS_ACTION_LOGOFF
);
345 EndDialog(hwndDlg
, WLX_SAS_ACTION_SHUTDOWN_POWER_OFF
);
348 if (OnChangePassword(hwndDlg
, pgContext
))
349 EndDialog(hwndDlg
, WLX_SAS_ACTION_PWD_CHANGED
);
352 EndDialog(hwndDlg
, WLX_SAS_ACTION_TASKLIST
);
355 EndDialog(hwndDlg
, WLX_SAS_ACTION_NONE
);
362 EndDialog(hwndDlg
, WLX_SAS_ACTION_NONE
);
372 IN OUT PGINA_CONTEXT pgContext
,
377 TRACE("GUILoggedOnSAS()\n");
379 if (dwSasType
!= WLX_SAS_TYPE_CTRL_ALT_DEL
)
381 /* Nothing to do for WLX_SAS_TYPE_TIMEOUT ; the dialog will
382 * close itself thanks to the use of WlxDialogBoxParam */
383 return WLX_SAS_ACTION_NONE
;
386 pgContext
->pWlxFuncs
->WlxSwitchDesktopToWinlogon(
389 result
= pgContext
->pWlxFuncs
->WlxDialogBoxParam(
391 pgContext
->hDllInstance
,
392 MAKEINTRESOURCEW(IDD_LOGGEDON_DLG
),
397 if (result
< WLX_SAS_ACTION_LOGON
||
398 result
> WLX_SAS_ACTION_SWITCH_CONSOLE
)
400 result
= WLX_SAS_ACTION_NONE
;
403 if (result
== WLX_SAS_ACTION_NONE
)
405 pgContext
->pWlxFuncs
->WlxSwitchDesktopToUser(
412 static INT_PTR CALLBACK
419 PGINA_CONTEXT pgContext
;
421 pgContext
= (PGINA_CONTEXT
)GetWindowLongPtr(hwndDlg
, GWL_USERDATA
);
427 /* FIXME: take care of DontDisplayLastUserName, NoDomainUI, ShutdownWithoutLogon */
428 pgContext
= (PGINA_CONTEXT
)lParam
;
429 SetWindowLongPtr(hwndDlg
, GWL_USERDATA
, (DWORD_PTR
)pgContext
);
431 if (pgContext
->bDisableCAD
== TRUE
)
432 EnableWindow(GetDlgItem(hwndDlg
, IDCANCEL
), FALSE
);
434 SetFocus(GetDlgItem(hwndDlg
, IDC_USERNAME
));
436 pgContext
->hBitmap
= LoadImage(hDllInstance
, MAKEINTRESOURCE(IDI_ROSLOGO
), IMAGE_BITMAP
, 0, 0, LR_DEFAULTCOLOR
);
443 if (pgContext
->hBitmap
)
445 hdc
= BeginPaint(hwndDlg
, &ps
);
446 DrawStateW(hdc
, NULL
, NULL
, (LPARAM
)pgContext
->hBitmap
, (WPARAM
)0, 0, 0, 0, 0, DST_BITMAP
);
447 EndPaint(hwndDlg
, &ps
);
453 DeleteObject(pgContext
->hBitmap
);
458 switch (LOWORD(wParam
))
462 LPWSTR UserName
= NULL
, Password
= NULL
;
463 INT result
= WLX_SAS_ACTION_NONE
;
465 if (GetTextboxText(hwndDlg
, IDC_USERNAME
, &UserName
) && *UserName
== '\0')
467 if (GetTextboxText(hwndDlg
, IDC_PASSWORD
, &Password
) &&
468 DoLoginTasks(pgContext
, UserName
, NULL
, Password
))
470 result
= WLX_SAS_ACTION_LOGON
;
472 HeapFree(GetProcessHeap(), 0, UserName
);
473 HeapFree(GetProcessHeap(), 0, Password
);
474 EndDialog(hwndDlg
, result
);
479 EndDialog(hwndDlg
, WLX_SAS_ACTION_NONE
);
484 EndDialog(hwndDlg
, WLX_SAS_ACTION_SHUTDOWN
);
497 IN OUT PGINA_CONTEXT pgContext
)
501 TRACE("GUILoggedOutSAS()\n");
503 result
= pgContext
->pWlxFuncs
->WlxDialogBoxParam(
505 pgContext
->hDllInstance
,
506 MAKEINTRESOURCEW(IDD_LOGGEDOUT_DLG
),
510 if (result
>= WLX_SAS_ACTION_LOGON
&&
511 result
<= WLX_SAS_ACTION_SWITCH_CONSOLE
)
513 WARN("WlxLoggedOutSAS() returns 0x%x\n", result
);
517 WARN("WlxDialogBoxParam() failed (0x%x)\n", result
);
518 return WLX_SAS_ACTION_NONE
;
523 IN OUT PGINA_CONTEXT pgContext
)
525 TRACE("GUILockedSAS()\n");
527 UNREFERENCED_PARAMETER(pgContext
);
530 return WLX_SAS_ACTION_UNLOCK_WKSTA
;
535 OnInitLockedDlg(HWND hwnd
,
536 PGINA_CONTEXT pgContext
)
542 LoadStringW(pgContext
->hDllInstance
, IDS_LOCKMSG
, Buffer1
, 256);
544 wsprintfW(Buffer2
, L
"%s\\%s", pgContext
->Domain
, pgContext
->UserName
);
545 wsprintfW(Buffer3
, Buffer1
, Buffer2
);
547 SetDlgItemTextW(hwnd
, IDC_LOCKMSG
, Buffer3
);
551 static INT_PTR CALLBACK
558 PGINA_CONTEXT pgContext
;
560 pgContext
= (PGINA_CONTEXT
)GetWindowLongPtr(hwndDlg
, GWL_USERDATA
);
566 pgContext
= (PGINA_CONTEXT
)lParam
;
567 SetWindowLongPtr(hwndDlg
, GWL_USERDATA
, (DWORD_PTR
)pgContext
);
569 pgContext
->hBitmap
= LoadImage(hDllInstance
, MAKEINTRESOURCE(IDI_ROSLOGO
), IMAGE_BITMAP
, 0, 0, LR_DEFAULTCOLOR
);
570 OnInitLockedDlg(hwndDlg
, pgContext
);
577 if (pgContext
->hBitmap
)
579 hdc
= BeginPaint(hwndDlg
, &ps
);
580 DrawStateW(hdc
, NULL
, NULL
, (LPARAM
)pgContext
->hBitmap
, (WPARAM
)0, 0, 0, 0, 0, DST_BITMAP
);
581 EndPaint(hwndDlg
, &ps
);
587 DeleteObject(pgContext
->hBitmap
);
597 GUIDisplayLockedNotice(
598 IN OUT PGINA_CONTEXT pgContext
)
600 TRACE("GUIdisplayLockedNotice()\n");
602 pgContext
->pWlxFuncs
->WlxDialogBoxParam(
604 pgContext
->hDllInstance
,
605 MAKEINTRESOURCEW(IDD_LOCKED_DLG
),
611 GINA_UI GinaGraphicalUI
= {
613 GUIDisplayStatusMessage
,
614 GUIRemoveStatusMessage
,
619 GUIDisplayLockedNotice
,