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 WINE_DEFAULT_DEBUG_CHANNEL(msgina
);
12 typedef struct _DISPLAYSTATUSMSG
14 PGINA_CONTEXT Context
;
20 } DISPLAYSTATUSMSG
, *PDISPLAYSTATUSMSG
;
24 IN OUT PGINA_CONTEXT pgContext
)
26 TRACE("GUIInitialize(%p)\n", pgContext
);
30 static INT_PTR CALLBACK
31 StatusMessageWindowProc(
37 UNREFERENCED_PARAMETER(wParam
);
43 PDISPLAYSTATUSMSG msg
= (PDISPLAYSTATUSMSG
)lParam
;
47 msg
->Context
->hStatusWindow
= hwndDlg
;
50 SetWindowTextW(hwndDlg
, msg
->pTitle
);
51 SetDlgItemTextW(hwndDlg
, IDC_STATUSLABEL
, msg
->pMessage
);
52 SetEvent(msg
->StartupEvent
);
60 StartupWindowThread(LPVOID lpParam
)
63 PDISPLAYSTATUSMSG msg
= (PDISPLAYSTATUSMSG
)lpParam
;
65 /* When SetThreadDesktop is called the system closes the desktop handle when needed
66 so we have to create a new handle because this handle may still be in use by winlogon */
67 if (!DuplicateHandle ( GetCurrentProcess(),
73 DUPLICATE_SAME_ACCESS
))
75 HeapFree(GetProcessHeap(), 0, lpParam
);
79 if(!SetThreadDesktop(hDesk
))
81 HeapFree(GetProcessHeap(), 0, lpParam
);
87 MAKEINTRESOURCE(IDD_STATUSWINDOW_DLG
),
89 StatusMessageWindowProc
,
92 HeapFree(GetProcessHeap(), 0, lpParam
);
97 GUIDisplayStatusMessage(
98 IN PGINA_CONTEXT pgContext
,
104 PDISPLAYSTATUSMSG msg
;
108 TRACE("GUIDisplayStatusMessage(%ws)\n", pMessage
);
110 if (!pgContext
->hStatusWindow
)
112 msg
= (PDISPLAYSTATUSMSG
)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(DISPLAYSTATUSMSG
));
116 msg
->Context
= pgContext
;
117 msg
->dwOptions
= dwOptions
;
118 msg
->pTitle
= pTitle
;
119 msg
->pMessage
= pMessage
;
120 msg
->hDesktop
= hDesktop
;
122 msg
->StartupEvent
= CreateEventW(
128 if (!msg
->StartupEvent
)
131 Thread
= CreateThread(
141 WaitForSingleObject(msg
->StartupEvent
, INFINITE
);
142 CloseHandle(msg
->StartupEvent
);
150 SetWindowTextW(pgContext
->hStatusWindow
, pTitle
);
152 SetDlgItemTextW(pgContext
->hStatusWindow
, IDC_STATUSLABEL
, pMessage
);
158 GUIRemoveStatusMessage(
159 IN PGINA_CONTEXT pgContext
)
161 if (pgContext
->hStatusWindow
)
163 EndDialog(pgContext
->hStatusWindow
, 0);
164 pgContext
->hStatusWindow
= NULL
;
170 static INT_PTR CALLBACK
177 UNREFERENCED_PARAMETER(hwndDlg
);
178 UNREFERENCED_PARAMETER(uMsg
);
179 UNREFERENCED_PARAMETER(wParam
);
180 UNREFERENCED_PARAMETER(lParam
);
187 IN OUT PGINA_CONTEXT pgContext
)
191 TRACE("GUIDisplaySASNotice()\n");
193 /* Display the notice window */
194 result
= DialogBoxParam(
195 pgContext
->hDllInstance
,
196 MAKEINTRESOURCE(IDD_NOTICE_DLG
),
202 /* Failed to display the window. Do as if the user
203 * already has pressed CTRL+ALT+DELETE */
204 pgContext
->pWlxFuncs
->WlxSasNotify(pgContext
->hWlx
, WLX_SAS_TYPE_CTRL_ALT_DEL
);
208 /* Get the text contained in a textbox. Allocates memory in pText
209 * to contain the text. Returns TRUE in case of success */
219 Count
= GetWindowTextLength(GetDlgItem(hwndDlg
, TextboxId
));
220 Text
= HeapAlloc(GetProcessHeap(), 0, (Count
+ 1) * sizeof(WCHAR
));
223 if (Count
!= GetWindowTextW(GetDlgItem(hwndDlg
, TextboxId
), Text
, Count
+ 1))
225 HeapFree(GetProcessHeap(), 0, Text
);
233 OnInitSecurityDlg(HWND hwnd
,
234 PGINA_CONTEXT pgContext
)
241 LoadStringW(pgContext
->hDllInstance
, IDS_LOGONMSG
, Buffer1
, 256);
243 wsprintfW(Buffer2
, L
"%s\\%s", pgContext
->Domain
, pgContext
->UserName
);
244 wsprintfW(Buffer4
, Buffer1
, Buffer2
);
246 SetDlgItemTextW(hwnd
, IDC_LOGONMSG
, Buffer4
);
248 LoadStringW(pgContext
->hDllInstance
, IDS_LOGONDATE
, Buffer1
, 256);
250 GetDateFormatW(LOCALE_USER_DEFAULT
, DATE_SHORTDATE
,
251 (SYSTEMTIME
*)&pgContext
->LogonTime
, NULL
, Buffer2
, 256);
253 GetTimeFormatW(LOCALE_USER_DEFAULT
, 0,
254 (SYSTEMTIME
*)&pgContext
->LogonTime
, NULL
, Buffer3
, 256);
256 wsprintfW(Buffer4
, Buffer1
, Buffer2
, Buffer3
);
258 SetDlgItemTextW(hwnd
, IDC_LOGONDATE
, Buffer4
);
261 static INT_PTR CALLBACK
272 OnInitSecurityDlg(hwndDlg
, (PGINA_CONTEXT
)lParam
);
273 SetFocus(GetDlgItem(hwndDlg
, IDNO
));
279 switch (LOWORD(wParam
))
282 EndDialog(hwndDlg
, WLX_SAS_ACTION_LOCK_WKSTA
);
285 EndDialog(hwndDlg
, WLX_SAS_ACTION_LOGOFF
);
288 EndDialog(hwndDlg
, WLX_SAS_ACTION_SHUTDOWN_POWER_OFF
);
291 EndDialog(hwndDlg
, WLX_SAS_ACTION_TASKLIST
);
294 EndDialog(hwndDlg
, WLX_SAS_ACTION_NONE
);
301 EndDialog(hwndDlg
, WLX_SAS_ACTION_NONE
);
311 IN OUT PGINA_CONTEXT pgContext
,
316 TRACE("GUILoggedOnSAS()\n");
318 if (dwSasType
!= WLX_SAS_TYPE_CTRL_ALT_DEL
)
320 /* Nothing to do for WLX_SAS_TYPE_TIMEOUT ; the dialog will
321 * close itself thanks to the use of WlxDialogBoxParam */
322 return WLX_SAS_ACTION_NONE
;
325 result
= pgContext
->pWlxFuncs
->WlxSwitchDesktopToWinlogon(
328 result
= pgContext
->pWlxFuncs
->WlxDialogBoxParam(
330 pgContext
->hDllInstance
,
331 MAKEINTRESOURCEW(IDD_LOGGEDON_DLG
),
336 if (result
< WLX_SAS_ACTION_LOGON
||
337 result
> WLX_SAS_ACTION_SWITCH_CONSOLE
)
339 result
= WLX_SAS_ACTION_NONE
;
342 if (result
== WLX_SAS_ACTION_NONE
)
344 result
= pgContext
->pWlxFuncs
->WlxSwitchDesktopToUser(
351 static INT_PTR CALLBACK
358 PGINA_CONTEXT pgContext
;
360 pgContext
= (PGINA_CONTEXT
)GetWindowLongPtr(hwndDlg
, GWL_USERDATA
);
366 /* FIXME: take care of DontDisplayLastUserName, NoDomainUI, ShutdownWithoutLogon */
367 pgContext
= (PGINA_CONTEXT
)lParam
;
368 SetWindowLongPtr(hwndDlg
, GWL_USERDATA
, (DWORD_PTR
)pgContext
);
369 SetFocus(GetDlgItem(hwndDlg
, IDC_USERNAME
));
371 pgContext
->hBitmap
= LoadImage(hDllInstance
, MAKEINTRESOURCE(IDI_ROSLOGO
), IMAGE_BITMAP
, 0, 0, LR_DEFAULTCOLOR
);
378 if (pgContext
->hBitmap
)
380 hdc
= BeginPaint(hwndDlg
, &ps
);
381 DrawStateW(hdc
, NULL
, NULL
, (LPARAM
)pgContext
->hBitmap
, (WPARAM
)0, 0, 0, 0, 0, DST_BITMAP
);
382 EndPaint(hwndDlg
, &ps
);
388 DeleteObject(pgContext
->hBitmap
);
393 switch (LOWORD(wParam
))
397 LPWSTR UserName
= NULL
, Password
= NULL
;
398 INT result
= WLX_SAS_ACTION_NONE
;
400 if (GetTextboxText(hwndDlg
, IDC_USERNAME
, &UserName
) && *UserName
== '\0')
402 if (GetTextboxText(hwndDlg
, IDC_PASSWORD
, &Password
) &&
403 DoLoginTasks(pgContext
, UserName
, NULL
, Password
))
405 result
= WLX_SAS_ACTION_LOGON
;
407 HeapFree(GetProcessHeap(), 0, UserName
);
408 HeapFree(GetProcessHeap(), 0, Password
);
409 EndDialog(hwndDlg
, result
);
414 EndDialog(hwndDlg
, WLX_SAS_ACTION_NONE
);
419 EndDialog(hwndDlg
, WLX_SAS_ACTION_SHUTDOWN
);
432 IN OUT PGINA_CONTEXT pgContext
)
436 TRACE("GUILoggedOutSAS()\n");
438 result
= pgContext
->pWlxFuncs
->WlxDialogBoxParam(
440 pgContext
->hDllInstance
,
441 MAKEINTRESOURCEW(IDD_LOGGEDOUT_DLG
),
445 if (result
>= WLX_SAS_ACTION_LOGON
&&
446 result
<= WLX_SAS_ACTION_SWITCH_CONSOLE
)
448 WARN("WlxLoggedOutSAS() returns 0x%x\n", result
);
452 WARN("WlxDialogBoxParam() failed (0x%x)\n", result
);
453 return WLX_SAS_ACTION_NONE
;
458 IN OUT PGINA_CONTEXT pgContext
)
460 TRACE("GUILockedSAS()\n");
462 UNREFERENCED_PARAMETER(pgContext
);
465 return WLX_SAS_ACTION_UNLOCK_WKSTA
;
470 OnInitLockedDlg(HWND hwnd
,
471 PGINA_CONTEXT pgContext
)
477 LoadStringW(pgContext
->hDllInstance
, IDS_LOCKMSG
, Buffer1
, 256);
479 wsprintfW(Buffer2
, L
"%s\\%s", pgContext
->Domain
, pgContext
->UserName
);
480 wsprintfW(Buffer3
, Buffer1
, Buffer2
);
482 SetDlgItemTextW(hwnd
, IDC_LOCKMSG
, Buffer3
);
486 static INT_PTR CALLBACK
493 PGINA_CONTEXT pgContext
;
495 pgContext
= (PGINA_CONTEXT
)GetWindowLongPtr(hwndDlg
, GWL_USERDATA
);
501 pgContext
= (PGINA_CONTEXT
)lParam
;
502 SetWindowLongPtr(hwndDlg
, GWL_USERDATA
, (DWORD_PTR
)pgContext
);
504 pgContext
->hBitmap
= LoadImage(hDllInstance
, MAKEINTRESOURCE(IDI_ROSLOGO
), IMAGE_BITMAP
, 0, 0, LR_DEFAULTCOLOR
);
505 OnInitLockedDlg(hwndDlg
, pgContext
);
512 if (pgContext
->hBitmap
)
514 hdc
= BeginPaint(hwndDlg
, &ps
);
515 DrawStateW(hdc
, NULL
, NULL
, (LPARAM
)pgContext
->hBitmap
, (WPARAM
)0, 0, 0, 0, 0, DST_BITMAP
);
516 EndPaint(hwndDlg
, &ps
);
522 DeleteObject(pgContext
->hBitmap
);
532 GUIDisplayLockedNotice(
533 IN OUT PGINA_CONTEXT pgContext
)
535 TRACE("GUIdisplayLockedNotice()\n");
537 pgContext
->pWlxFuncs
->WlxDialogBoxParam(
539 pgContext
->hDllInstance
,
540 MAKEINTRESOURCEW(IDD_LOCKED_DLG
),
546 GINA_UI GinaGraphicalUI
= {
548 GUIDisplayStatusMessage
,
549 GUIRemoveStatusMessage
,
554 GUIDisplayLockedNotice
,