ReactOS 0.4.16-dev-1946-g52006dd
gui.c File Reference
#include "msgina.h"
#include <wingdi.h>
#include <winnls.h>
#include <ndk/exfuncs.h>
Include dependency graph for gui.c:

Go to the source code of this file.

Classes

struct  _DISPLAYSTATUSMSG
 
struct  _LEGALNOTICEDATA
 
struct  _DLG_DATA
 

Macros

#define IDT_BAR   1
 
#define ISKEYDOWN(x)   (GetKeyState(x) & 0x8000)
 

Typedefs

typedef struct _DISPLAYSTATUSMSG DISPLAYSTATUSMSG
 
typedef struct _DISPLAYSTATUSMSGPDISPLAYSTATUSMSG
 
typedef struct _LEGALNOTICEDATA LEGALNOTICEDATA
 
typedef struct _LEGALNOTICEDATAPLEGALNOTICEDATA
 
typedef struct _DLG_DATA DLG_DATA
 
typedef struct _DLG_DATAPDLG_DATA
 

Functions

static PDLG_DATA DlgData_Create (HWND hwndDlg, PGINA_CONTEXT pgContext)
 
static VOID DlgData_LoadBitmaps (_Inout_ PDLG_DATA pDlgData)
 
static VOID DlgData_Destroy (_Inout_ HWND hwndDlg)
 
static BOOL GUIInitialize (IN OUT PGINA_CONTEXT pgContext)
 
static VOID SetWelcomeText (HWND hWnd)
 
static VOID AdjustStatusMessageWindow (HWND hwndDlg, PDLG_DATA pDlgData)
 
static INT_PTR CALLBACK StatusDialogProc (IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
 
static DWORD WINAPI StartupWindowThread (LPVOID lpParam)
 
static BOOL GUIDisplayStatusMessage (IN PGINA_CONTEXT pgContext, IN HDESK hDesktop, IN DWORD dwOptions, IN PWSTR pTitle, IN PWSTR pMessage)
 
static BOOL GUIRemoveStatusMessage (IN PGINA_CONTEXT pgContext)
 
static INT_PTR CALLBACK WelcomeDialogProc (IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
 
static VOID GUIDisplaySASNotice (IN OUT PGINA_CONTEXT pgContext)
 
static BOOL GetTextboxText (IN HWND hwndDlg, IN INT TextboxId, OUT LPWSTR *pText)
 
static INT ResourceMessageBox (IN PGINA_CONTEXT pgContext, IN HWND hwnd, IN UINT uType, IN UINT uCaption, IN UINT uText)
 
static BOOL DoChangePassword (IN PGINA_CONTEXT pgContext, IN HWND hwndDlg)
 
static INT_PTR CALLBACK ChangePasswordDialogProc (IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
 
static VOID OnInitSecurityDlg (_In_ HWND hwnd, _In_ PGINA_CONTEXT pgContext)
 
static BOOL OnChangePassword (IN HWND hwnd, IN PGINA_CONTEXT pgContext)
 
static INT_PTR CALLBACK LogOffDialogProc (IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
 
static INT OnLogOff (IN HWND hwndDlg, IN PGINA_CONTEXT pgContext)
 
static INT OnShutDown (_In_ HWND hwndDlg, _In_ PGINA_CONTEXT pgContext, _In_ DWORD dwExcludeOptions)
 
static INT_PTR CALLBACK SecurityDialogProc (IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
 
static INT GUILoggedOnSAS (IN OUT PGINA_CONTEXT pgContext, IN DWORD dwSasType)
 
static BOOL DoLogon (IN HWND hwndDlg, IN OUT PGINA_CONTEXT pgContext)
 
static VOID SetDomainComboBox (HWND hwndDomainComboBox, PGINA_CONTEXT pgContext)
 
static INT_PTR CALLBACK LogonDialogProc (IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
 
static INT_PTR CALLBACK LegalNoticeDialogProc (IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
 
static INT GUILoggedOutSAS (IN OUT PGINA_CONTEXT pgContext)
 
static VOID SetLockMessage (HWND hwnd, INT nDlgItem, PGINA_CONTEXT pgContext)
 
static BOOL DoUnlock (IN HWND hwndDlg, IN PGINA_CONTEXT pgContext, OUT LPINT Action)
 
static INT_PTR CALLBACK UnlockDialogProc (IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
 
static INT GUILockedSAS (IN OUT PGINA_CONTEXT pgContext)
 
static INT_PTR CALLBACK LockedDialogProc (IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
 
static VOID GUIDisplayLockedNotice (IN OUT PGINA_CONTEXT pgContext)
 

Variables

GINA_UI GinaGraphicalUI
 

Macro Definition Documentation

◆ IDT_BAR

#define IDT_BAR   1

Definition at line 32 of file gui.c.

◆ ISKEYDOWN

#define ISKEYDOWN (   x)    (GetKeyState(x) & 0x8000)

Definition at line 34 of file gui.c.

Typedef Documentation

◆ DISPLAYSTATUSMSG

◆ DLG_DATA

◆ LEGALNOTICEDATA

◆ PDISPLAYSTATUSMSG

◆ PDLG_DATA

◆ PLEGALNOTICEDATA

Function Documentation

◆ AdjustStatusMessageWindow()

static VOID AdjustStatusMessageWindow ( HWND  hwndDlg,
PDLG_DATA  pDlgData 
)
static

Definition at line 185 of file gui.c.

186{
187 INT xOld, yOld, cxOld, cyOld;
188 INT xNew, yNew, cxNew, cyNew;
189 INT cxLabel, cyLabel, dyLabel;
190 RECT rc, rcBar, rcLabel, rcWnd;
191 BITMAP bmLogo, bmBar;
192 DWORD style, exstyle;
193 HWND hwndLogo = GetDlgItem(hwndDlg, IDC_ROSLOGO);
194 HWND hwndBar = GetDlgItem(hwndDlg, IDC_BAR);
195 HWND hwndLabel = GetDlgItem(hwndDlg, IDC_STATUS_MESSAGE);
196
197 /* This adjustment is for CJK only */
199 {
200 case LANG_CHINESE:
201 case LANG_JAPANESE:
202 case LANG_KOREAN:
203 break;
204
205 default:
206 return;
207 }
208
209 if (!GetObjectW(pDlgData->hLogoBitmap, sizeof(BITMAP), &bmLogo) ||
210 !GetObjectW(pDlgData->hBarBitmap, sizeof(BITMAP), &bmBar))
211 {
212 return;
213 }
214
215 GetWindowRect(hwndBar, &rcBar);
216 MapWindowPoints(NULL, hwndDlg, (LPPOINT)&rcBar, 2);
217 dyLabel = bmLogo.bmHeight - rcBar.top;
218
219 GetWindowRect(hwndLabel, &rcLabel);
220 MapWindowPoints(NULL, hwndDlg, (LPPOINT)&rcLabel, 2);
221 cxLabel = rcLabel.right - rcLabel.left;
222 cyLabel = rcLabel.bottom - rcLabel.top;
223
224 MoveWindow(hwndLogo, 0, 0, bmLogo.bmWidth, bmLogo.bmHeight, TRUE);
225 MoveWindow(hwndBar, 0, bmLogo.bmHeight, bmLogo.bmWidth, bmBar.bmHeight, TRUE);
226 MoveWindow(hwndLabel, rcLabel.left, rcLabel.top + dyLabel, cxLabel, cyLabel, TRUE);
227
228 GetWindowRect(hwndDlg, &rcWnd);
229 xOld = rcWnd.left;
230 yOld = rcWnd.top;
231 cxOld = rcWnd.right - rcWnd.left;
232 cyOld = rcWnd.bottom - rcWnd.top;
233
234 GetClientRect(hwndDlg, &rc);
235 SetRect(&rc, 0, 0, bmLogo.bmWidth, rc.bottom - rc.top); /* new client size */
236
238 exstyle = (DWORD)GetWindowLongPtrW(hwndDlg, GWL_EXSTYLE);
239 AdjustWindowRectEx(&rc, style, FALSE, exstyle);
240
241 cxNew = rc.right - rc.left;
242 cyNew = (rc.bottom - rc.top) + dyLabel;
243 xNew = xOld - (cxNew - cxOld) / 2;
244 yNew = yOld - (cyNew - cyOld) / 2;
245 MoveWindow(hwndDlg, xNew, yNew, cxNew, cyNew, TRUE);
246}
Arabic default style
Definition: afstyles.h:94
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LANGID WINAPI GetUserDefaultLangID(void)
Definition: locale.c:1182
#define IDC_ROSLOGO
Definition: resource.h:69
#define IDC_STATUS_MESSAGE
Definition: resource.h:6
#define IDC_BAR
Definition: resource.h:70
static INT cxOld
Definition: eventvwr.c:4341
static INT cyOld
Definition: eventvwr.c:4341
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DWORD
Definition: nt_native.h:44
#define LANG_CHINESE
Definition: nls.h:42
#define LANG_JAPANESE
Definition: nls.h:76
#define PRIMARYLANGID(l)
Definition: nls.h:16
#define LANG_KOREAN
Definition: nls.h:84
Definition: bl.h:1331
HBITMAP hLogoBitmap
Definition: gui.c:39
HBITMAP hBarBitmap
Definition: gui.c:40
Definition: windef.h:99
LONG right
Definition: windef.h:102
LONG bottom
Definition: windef.h:103
LONG top
Definition: windef.h:101
LONG left
Definition: windef.h:100
int32_t INT
Definition: typedefs.h:58
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
#define GetWindowLongPtrW
Definition: winuser.h:4931
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI AdjustWindowRectEx(_Inout_ LPRECT, _In_ DWORD, _In_ BOOL, _In_ DWORD)
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define GWL_STYLE
Definition: winuser.h:863
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
#define GWL_EXSTYLE
Definition: winuser.h:862

Referenced by StatusDialogProc().

◆ ChangePasswordDialogProc()

static INT_PTR CALLBACK ChangePasswordDialogProc ( IN HWND  hwndDlg,
IN UINT  uMsg,
IN WPARAM  wParam,
IN LPARAM  lParam 
)
static

Definition at line 756 of file gui.c.

761{
762 PGINA_CONTEXT pgContext;
763
764 pgContext = (PGINA_CONTEXT)GetWindowLongPtrW(hwndDlg, GWLP_USERDATA);
765
766 switch (uMsg)
767 {
768 case WM_INITDIALOG:
769 {
770 pgContext = (PGINA_CONTEXT)lParam;
771 SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (LONG_PTR)pgContext);
772
773 SetDlgItemTextW(hwndDlg, IDC_CHANGEPWD_USERNAME, pgContext->UserName);
777 return FALSE; // Default focus is changed.
778 }
779
780 case WM_COMMAND:
781 switch (LOWORD(wParam))
782 {
783 case IDOK:
784 if (DoChangePassword(pgContext, hwndDlg))
785 {
786 EndDialog(hwndDlg, TRUE);
787 }
788 else
789 {
794 }
795 return TRUE;
796
797 case IDCANCEL:
798 EndDialog(hwndDlg, FALSE);
799 return TRUE;
800 }
801 break;
802
803 case WM_CLOSE:
804 EndDialog(hwndDlg, FALSE);
805 return TRUE;
806 }
807
808 return FALSE;
809}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
static BOOL DoChangePassword(IN PGINA_CONTEXT pgContext, IN HWND hwndDlg)
Definition: gui.c:587
#define IDC_CHANGEPWD_USERNAME
Definition: resource.h:35
#define IDC_CHANGEPWD_OLDPWD
Definition: resource.h:37
#define IDC_CHANGEPWD_DOMAIN
Definition: resource.h:36
#define IDC_CHANGEPWD_NEWPWD2
Definition: resource.h:39
#define IDC_CHANGEPWD_NEWPWD1
Definition: resource.h:38
LONG_PTR LPARAM
Definition: minwindef.h:175
UINT_PTR WPARAM
Definition: minwindef.h:174
struct GINA_CONTEXT * PGINA_CONTEXT
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define LOWORD(l)
Definition: pedump.c:82
WCHAR DomainName[256]
Definition: msgina.h:52
WCHAR UserName[256]
Definition: msgina.h:51
#define GWLP_USERDATA
Definition: treelist.c:63
#define WM_CLOSE
Definition: winuser.h:1649
#define IDCANCEL
Definition: winuser.h:842
#define WM_COMMAND
Definition: winuser.h:1768
#define CB_SETCURSEL
Definition: winuser.h:1990
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define WM_INITDIALOG
Definition: winuser.h:1767
#define IDOK
Definition: winuser.h:841
#define WM_NEXTDLGCTL
Definition: winuser.h:1671
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HWND WINAPI SetFocus(_In_opt_ HWND)
#define CB_ADDSTRING
Definition: winuser.h:1965
#define SetWindowLongPtrW
Definition: winuser.h:5457
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by OnChangePassword().

◆ DlgData_Create()

static PDLG_DATA DlgData_Create ( HWND  hwndDlg,
PGINA_CONTEXT  pgContext 
)
static

Definition at line 50 of file gui.c.

51{
52 PDLG_DATA pDlgData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pDlgData));
53 if (pDlgData)
54 {
55 pDlgData->pgContext = pgContext;
56 SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (LONG_PTR)pDlgData);
57 }
58 return pDlgData;
59}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
Definition: gui.c:37
PGINA_CONTEXT pgContext
Definition: gui.c:38

Referenced by LockedDialogProc(), LogonDialogProc(), StatusDialogProc(), UnlockDialogProc(), and WelcomeDialogProc().

◆ DlgData_Destroy()

static VOID DlgData_Destroy ( _Inout_ HWND  hwndDlg)
static

Definition at line 92 of file gui.c.

93{
94 PDLG_DATA pDlgData;
95
96 pDlgData = (PDLG_DATA)GetWindowLongPtrW(hwndDlg, GWLP_USERDATA);
97 if (!pDlgData)
98 {
99 return;
100 }
101
103
104 if (pDlgData->hBarBitmap)
105 {
106 DeleteObject(pDlgData->hBarBitmap);
107 }
108
109 if (pDlgData->hLogoBitmap)
110 {
111 DeleteObject(pDlgData->hLogoBitmap);
112 }
113
114 HeapFree(GetProcessHeap(), 0, pDlgData);
115}
#define HeapFree(x, y, z)
Definition: compat.h:735
struct _DLG_DATA * PDLG_DATA
pKey DeleteObject()

Referenced by LockedDialogProc(), LogonDialogProc(), StatusDialogProc(), UnlockDialogProc(), and WelcomeDialogProc().

◆ DlgData_LoadBitmaps()

static VOID DlgData_LoadBitmaps ( _Inout_ PDLG_DATA  pDlgData)
static

Definition at line 62 of file gui.c.

63{
64 BITMAP bm;
65
66 if (!pDlgData)
67 {
68 return;
69 }
70
71 pDlgData->hLogoBitmap = LoadImageW(pDlgData->pgContext->hDllInstance,
73 0, 0, LR_DEFAULTCOLOR);
74 if (pDlgData->hLogoBitmap)
75 {
76 GetObject(pDlgData->hLogoBitmap, sizeof(bm), &bm);
77 pDlgData->LogoWidth = bm.bmWidth;
78 pDlgData->LogoHeight = bm.bmHeight;
79 }
80
81 pDlgData->hBarBitmap = LoadImageW(hDllInstance, MAKEINTRESOURCEW(IDI_BAR),
83 if (pDlgData->hBarBitmap)
84 {
85 GetObject(pDlgData->hBarBitmap, sizeof(bm), &bm);
86 pDlgData->BarWidth = bm.bmWidth;
87 pDlgData->BarHeight = bm.bmHeight;
88 }
89}
#define IDI_ROSLOGO
Definition: resource.h:42
static HINSTANCE hDllInstance
Definition: clb.c:9
#define IDI_BAR
Definition: resource.h:76
#define GetObject
Definition: wingdi.h:4914
#define IMAGE_BITMAP
Definition: winuser.h:211
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE hInst, _In_ LPCWSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2555
#define LR_DEFAULTCOLOR
Definition: winuser.h:1098
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

Referenced by LockedDialogProc(), LogonDialogProc(), StatusDialogProc(), UnlockDialogProc(), and WelcomeDialogProc().

◆ DoChangePassword()

static BOOL DoChangePassword ( IN PGINA_CONTEXT  pgContext,
IN HWND  hwndDlg 
)
static

Definition at line 587 of file gui.c.

590{
591 WCHAR UserName[256];
592 WCHAR Domain[256];
593 WCHAR OldPassword[256];
594 WCHAR NewPassword1[256];
595 WCHAR NewPassword2[256];
596 PMSV1_0_CHANGEPASSWORD_REQUEST RequestBuffer = NULL;
597 PMSV1_0_CHANGEPASSWORD_RESPONSE ResponseBuffer = NULL;
598 ULONG RequestBufferSize;
599 ULONG ResponseBufferSize = 0;
600 LPWSTR Ptr;
601 BOOL res = FALSE;
604
605 GetDlgItemTextW(hwndDlg, IDC_CHANGEPWD_USERNAME, UserName, _countof(UserName));
606 GetDlgItemTextW(hwndDlg, IDC_CHANGEPWD_DOMAIN, Domain, _countof(Domain));
607 GetDlgItemTextW(hwndDlg, IDC_CHANGEPWD_OLDPWD, OldPassword, _countof(OldPassword));
608 GetDlgItemTextW(hwndDlg, IDC_CHANGEPWD_NEWPWD1, NewPassword1, _countof(NewPassword1));
609 GetDlgItemTextW(hwndDlg, IDC_CHANGEPWD_NEWPWD2, NewPassword2, _countof(NewPassword2));
610
611 /* Compare the two passwords and fail if they do not match */
612 if (wcscmp(NewPassword1, NewPassword2) != 0)
613 {
614 ResourceMessageBox(pgContext,
615 hwndDlg,
619 goto done;
620 }
621
622 /* Calculate the request buffer size */
623 RequestBufferSize = sizeof(MSV1_0_CHANGEPASSWORD_REQUEST) +
624 ((wcslen(Domain) + 1) * sizeof(WCHAR)) +
625 ((wcslen(UserName) + 1) * sizeof(WCHAR)) +
626 ((wcslen(OldPassword) + 1) * sizeof(WCHAR)) +
627 ((wcslen(NewPassword1) + 1) * sizeof(WCHAR));
628
629 /* Allocate the request buffer */
630 RequestBuffer = HeapAlloc(GetProcessHeap(),
632 RequestBufferSize);
633 if (RequestBuffer == NULL)
634 {
635 ERR("HeapAlloc failed\n");
636 goto done;
637 }
638
639 /* Initialize the request buffer */
640 RequestBuffer->MessageType = MsV1_0ChangePassword;
641 RequestBuffer->Impersonating = TRUE;
642
643 Ptr = (LPWSTR)((ULONG_PTR)RequestBuffer + sizeof(MSV1_0_CHANGEPASSWORD_REQUEST));
644
645 /* Pack the domain name */
646 RequestBuffer->DomainName.Length = (USHORT)wcslen(Domain) * sizeof(WCHAR);
647 RequestBuffer->DomainName.MaximumLength = RequestBuffer->DomainName.Length + sizeof(WCHAR);
648 RequestBuffer->DomainName.Buffer = Ptr;
649
650 RtlCopyMemory(RequestBuffer->DomainName.Buffer,
651 Domain,
652 RequestBuffer->DomainName.MaximumLength);
653
654 Ptr = (LPWSTR)((ULONG_PTR)Ptr + RequestBuffer->DomainName.MaximumLength);
655
656 /* Pack the user name */
657 RequestBuffer->AccountName.Length = (USHORT)wcslen(UserName) * sizeof(WCHAR);
658 RequestBuffer->AccountName.MaximumLength = RequestBuffer->AccountName.Length + sizeof(WCHAR);
659 RequestBuffer->AccountName.Buffer = Ptr;
660
661 RtlCopyMemory(RequestBuffer->AccountName.Buffer,
662 UserName,
663 RequestBuffer->AccountName.MaximumLength);
664
665 Ptr = (LPWSTR)((ULONG_PTR)Ptr + RequestBuffer->AccountName.MaximumLength);
666
667 /* Pack the old password */
668 RequestBuffer->OldPassword.Length = (USHORT)wcslen(OldPassword) * sizeof(WCHAR);
669 RequestBuffer->OldPassword.MaximumLength = RequestBuffer->OldPassword.Length + sizeof(WCHAR);
670 RequestBuffer->OldPassword.Buffer = Ptr;
671
672 RtlCopyMemory(RequestBuffer->OldPassword.Buffer,
673 OldPassword,
674 RequestBuffer->OldPassword.MaximumLength);
675
676 Ptr = (LPWSTR)((ULONG_PTR)Ptr + RequestBuffer->OldPassword.MaximumLength);
677
678 /* Pack the new password */
679 RequestBuffer->NewPassword.Length = (USHORT)wcslen(NewPassword1) * sizeof(WCHAR);
680 RequestBuffer->NewPassword.MaximumLength = RequestBuffer->NewPassword.Length + sizeof(WCHAR);
681 RequestBuffer->NewPassword.Buffer = Ptr;
682
683 RtlCopyMemory(RequestBuffer->NewPassword.Buffer,
684 NewPassword1,
685 RequestBuffer->NewPassword.MaximumLength);
686
687 /* Connect to the LSA server */
688 if (ConnectToLsa(pgContext) != ERROR_SUCCESS)
689 {
690 ERR("ConnectToLsa() failed\n");
691 goto done;
692 }
693
694 /* Call the authentication package */
695 Status = LsaCallAuthenticationPackage(pgContext->LsaHandle,
696 pgContext->AuthenticationPackage,
697 RequestBuffer,
698 RequestBufferSize,
699 (PVOID*)&ResponseBuffer,
700 &ResponseBufferSize,
702 if (!NT_SUCCESS(Status))
703 {
704 ERR("LsaCallAuthenticationPackage failed (Status 0x%08lx)\n", Status);
705 goto done;
706 }
707
709 {
710 TRACE("LsaCallAuthenticationPackage failed (ProtocolStatus 0x%08lx)\n", ProtocolStatus);
711 goto done;
712 }
713
714 res = TRUE;
715
716 ResourceMessageBox(pgContext,
717 hwndDlg,
721
722 if ((wcscmp(UserName, pgContext->UserName) == 0) &&
723 (wcscmp(Domain, pgContext->DomainName) == 0) &&
724 (wcscmp(OldPassword, pgContext->Password) == 0))
725 {
726 SecureZeroMemory(pgContext->Password, sizeof(pgContext->Password));
727 wcscpy(pgContext->Password, NewPassword1);
728 }
729
730done:
731 /* Zero out the password buffers */
732 SecureZeroMemory(&OldPassword, sizeof(OldPassword));
733 SecureZeroMemory(&NewPassword1, sizeof(NewPassword1));
734 SecureZeroMemory(&NewPassword2, sizeof(NewPassword2));
735
736 if (RequestBuffer != NULL)
737 {
738 /* Zero out the password buffers before freeing them */
739 SecureZeroMemory(RequestBuffer->OldPassword.Buffer,
740 RequestBuffer->OldPassword.MaximumLength);
741 SecureZeroMemory(&RequestBuffer->OldPassword, sizeof(RequestBuffer->OldPassword));
742 SecureZeroMemory(RequestBuffer->NewPassword.Buffer,
743 RequestBuffer->NewPassword.MaximumLength);
744 SecureZeroMemory(&RequestBuffer->NewPassword, sizeof(RequestBuffer->NewPassword));
745 HeapFree(GetProcessHeap(), 0, RequestBuffer);
746 }
747
748 if (ResponseBuffer != NULL)
749 LsaFreeReturnBuffer(ResponseBuffer);
750
751 return res;
752}
LONG NTSTATUS
Definition: precomp.h:26
#define ERR(fmt,...)
Definition: precomp.h:57
wcscpy
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
static INT ResourceMessageBox(IN PGINA_CONTEXT pgContext, IN HWND hwnd, IN UINT uType, IN UINT uCaption, IN UINT uText)
Definition: gui.c:564
NTSTATUS ConnectToLsa(PGINA_CONTEXT pgContext)
Definition: lsa.c:11
#define IDS_CHANGEPWDTITLE
Definition: resource.h:100
#define IDS_NONMATCHINGPASSWORDS
Definition: resource.h:101
#define IDS_PASSWORDCHANGED
Definition: resource.h:102
unsigned int BOOL
Definition: ntddk_ex.h:94
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
Status
Definition: gdiplustypes.h:25
GLuint res
Definition: glext.h:9613
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
VOID NTAPI ProtocolStatus(NDIS_HANDLE BindingContext, NDIS_STATUS GenerelStatus, PVOID StatusBuffer, UINT StatusBufferSize)
Called by NDIS when the underlying driver has changed state.
Definition: lan.c:461
struct _MSV1_0_CHANGEPASSWORD_REQUEST MSV1_0_CHANGEPASSWORD_REQUEST
@ MsV1_0ChangePassword
Definition: ntsecapi.h:223
NTSTATUS NTAPI LsaCallAuthenticationPackage(HANDLE, ULONG, PVOID, ULONG, PVOID *, PULONG, PNTSTATUS)
NTSTATUS NTAPI LsaFreeReturnBuffer(PVOID)
unsigned short USHORT
Definition: pedump.c:61
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define _countof(array)
Definition: sndvol32.h:70
#define TRACE(s)
Definition: solgame.cpp:4
USHORT MaximumLength
Definition: ntsecapi.h:164
MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType
Definition: ntsecapi.h:511
UNICODE_STRING AccountName
Definition: ntsecapi.h:513
UNICODE_STRING NewPassword
Definition: ntsecapi.h:515
UNICODE_STRING OldPassword
Definition: ntsecapi.h:514
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2263
#define SecureZeroMemory
Definition: winbase.h:1465
#define MB_ICONEXCLAMATION
Definition: winuser.h:796
#define MB_OK
Definition: winuser.h:801
#define MB_ICONINFORMATION
Definition: winuser.h:813
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by ChangePasswordDialogProc().

◆ DoLogon()

static BOOL DoLogon ( IN HWND  hwndDlg,
IN OUT PGINA_CONTEXT  pgContext 
)
static

Definition at line 1151 of file gui.c.

1154{
1155 LPWSTR UserName = NULL;
1157 LPWSTR Domain = NULL;
1158 BOOL result = FALSE;
1160
1161 if (GetTextboxText(hwndDlg, IDC_LOGON_USERNAME, &UserName) && *UserName == '\0')
1162 goto done;
1163
1164 if (GetTextboxText(hwndDlg, IDC_LOGON_DOMAIN, &Domain) && *Domain == '\0')
1165 goto done;
1166
1168 goto done;
1169
1170 Status = DoLoginTasks(pgContext, UserName, Domain, Password, &SubStatus);
1172 {
1173 ResourceMessageBox(pgContext,
1174 hwndDlg,
1178 goto done;
1179 }
1181 {
1182 TRACE("DoLoginTasks failed! Status 0x%08lx SubStatus 0x%08lx\n", Status, SubStatus);
1183
1185 {
1186 ResourceMessageBox(pgContext,
1187 hwndDlg,
1191 goto done;
1192 }
1194 {
1195 TRACE("Account locked!\n");
1196 ResourceMessageBox(pgContext,
1197 hwndDlg,
1201 goto done;
1202 }
1203 else if ((SubStatus == STATUS_PASSWORD_MUST_CHANGE) ||
1205 {
1207 {
1208 ResourceMessageBox(pgContext,
1209 hwndDlg,
1213 }
1214 else
1215 {
1216 ResourceMessageBox(pgContext,
1217 hwndDlg,
1221 }
1222
1223 if (!OnChangePassword(hwndDlg, pgContext))
1224 goto done;
1225
1226 Status = DoLoginTasks(pgContext,
1227 pgContext->UserName,
1228 pgContext->DomainName,
1229 pgContext->Password,
1230 &SubStatus);
1231 if (!NT_SUCCESS(Status))
1232 {
1233 TRACE("Login after password change failed! (Status 0x%08lx)\n", Status);
1234 goto done;
1235 }
1236 }
1238 {
1239 ResourceMessageBox(pgContext,
1240 hwndDlg,
1244 }
1246 {
1247 ResourceMessageBox(pgContext,
1248 hwndDlg,
1252 goto done;
1253 }
1255 {
1256 ResourceMessageBox(pgContext,
1257 hwndDlg,
1261 goto done;
1262 }
1263 else
1264 {
1265 TRACE("Other error!\n");
1266 ResourceMessageBox(pgContext,
1267 hwndDlg,
1271 goto done;
1272 }
1273 }
1274 else if (!NT_SUCCESS(Status))
1275 {
1276 TRACE("DoLoginTasks failed! Status 0x%08lx\n", Status);
1277 goto done;
1278 }
1279
1280 if (!CreateProfile(pgContext, UserName, Domain, Password))
1281 {
1282 ERR("Failed to create the profile!\n");
1283 goto done;
1284 }
1285
1286 SecureZeroMemory(pgContext->Password, sizeof(pgContext->Password));
1287 wcscpy(pgContext->Password, Password);
1288
1289 result = TRUE;
1290
1291done:
1292 pgContext->bAutoAdminLogon = FALSE;
1293
1294 if (UserName != NULL)
1295 HeapFree(GetProcessHeap(), 0, UserName);
1296
1297 if (Password != NULL)
1298 {
1299 /* Zero out the password buffer before freeing it */
1300 SIZE_T pwdLen = (wcslen(Password) + 1) * sizeof(WCHAR);
1301 SecureZeroMemory(Password, pwdLen);
1303 }
1304
1305 if (Domain != NULL)
1306 HeapFree(GetProcessHeap(), 0, Domain);
1307
1308 return result;
1309}
static BOOL GetTextboxText(IN HWND hwndDlg, IN INT TextboxId, OUT LPWSTR *pText)
Definition: gui.c:540
static BOOL OnChangePassword(IN HWND hwnd, IN PGINA_CONTEXT pgContext)
Definition: gui.c:916
#define IDS_ACCOUNTLOCKED
Definition: resource.h:109
#define IDS_INVALIDLOGONHOURS
Definition: resource.h:110
#define IDS_LOGONWRONGUSERORPWD
Definition: resource.h:104
#define IDS_PASSWORDMUSTCHANGE
Definition: resource.h:106
#define IDS_LOGONTITLE
Definition: resource.h:103
#define IDS_INVALIDWORKSTATION
Definition: resource.h:111
#define IDC_LOGON_DOMAIN
Definition: resource.h:14
#define IDS_PASSWORDEXPIRED
Definition: resource.h:107
#define IDC_LOGON_PASSWORD
Definition: resource.h:13
#define IDS_LOGONUSERDISABLED
Definition: resource.h:105
#define IDS_ACCOUNTEXPIRED
Definition: resource.h:108
#define IDC_LOGON_USERNAME
Definition: resource.h:12
#define IDS_ACCOUNTRESTRICTION
Definition: resource.h:112
GLuint64EXT * result
Definition: glext.h:11304
BOOL CreateProfile(IN OUT PGINA_CONTEXT pgContext, IN PWSTR UserName, IN PWSTR Domain, IN PWSTR Password)
Definition: msgina.c:759
NTSTATUS DoLoginTasks(IN OUT PGINA_CONTEXT pgContext, IN PWSTR UserName, IN PWSTR Domain, IN PWSTR Password, OUT PNTSTATUS SubStatus)
Definition: msgina.c:726
_IRQL_requires_same_ _In_ PLSA_STRING _In_ SECURITY_LOGON_TYPE _In_ ULONG _In_ ULONG _In_opt_ PTOKEN_GROUPS _In_ PTOKEN_SOURCE _Out_ PVOID _Out_ PULONG _Inout_ PLUID _Out_ PHANDLE _Out_ PQUOTA_LIMITS _Out_ PNTSTATUS SubStatus
#define STATUS_INVALID_LOGON_HOURS
Definition: ntstatus.h:441
#define STATUS_ACCOUNT_DISABLED
Definition: ntstatus.h:444
#define STATUS_PASSWORD_MUST_CHANGE
Definition: ntstatus.h:802
#define STATUS_PASSWORD_EXPIRED
Definition: ntstatus.h:443
#define STATUS_INVALID_WORKSTATION
Definition: ntstatus.h:442
#define STATUS_ACCOUNT_EXPIRED
Definition: ntstatus.h:730
#define STATUS_ACCOUNT_LOCKED_OUT
Definition: ntstatus.h:818
#define STATUS_LOGON_FAILURE
Definition: ntstatus.h:439
#define STATUS_ACCOUNT_RESTRICTION
Definition: ntstatus.h:440
#define STATUS_SUCCESS
Definition: shellext.h:65
@ Password
Definition: telnetd.h:67
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define MB_ICONERROR
Definition: winuser.h:798
#define MB_ICONSTOP
Definition: winuser.h:814

Referenced by LogonDialogProc().

◆ DoUnlock()

static BOOL DoUnlock ( IN HWND  hwndDlg,
IN PGINA_CONTEXT  pgContext,
OUT LPINT  Action 
)
static

Definition at line 1566 of file gui.c.

1570{
1571 WCHAR Buffer1[256];
1572 WCHAR Buffer2[256];
1573 LPWSTR UserName = NULL;
1575 BOOL res = FALSE;
1576
1577 if (GetTextboxText(hwndDlg, IDC_UNLOCK_USERNAME, &UserName) && *UserName == '\0')
1578 {
1579 HeapFree(GetProcessHeap(), 0, UserName);
1580 return FALSE;
1581 }
1582
1584 {
1585 if (UserName != NULL && Password != NULL &&
1586 wcscmp(UserName, pgContext->UserName) == 0 &&
1587 wcscmp(Password, pgContext->Password) == 0)
1588 {
1590 res = TRUE;
1591 }
1592 else if (wcscmp(UserName, pgContext->UserName) == 0 &&
1593 wcscmp(Password, pgContext->Password) != 0)
1594 {
1595 /* Wrong Password */
1596 LoadStringW(pgContext->hDllInstance, IDS_LOCKEDWRONGPASSWORD, Buffer2, _countof(Buffer2));
1597 LoadStringW(pgContext->hDllInstance, IDS_COMPUTERLOCKED, Buffer1, _countof(Buffer1));
1598 MessageBoxW(hwndDlg, Buffer2, Buffer1, MB_OK | MB_ICONERROR);
1599 }
1600 else
1601 {
1602 /* Wrong user name */
1603 if (DoAdminUnlock(pgContext, UserName, NULL, Password))
1604 {
1606 res = TRUE;
1607 }
1608 else
1609 {
1610 LoadStringW(pgContext->hDllInstance, IDS_LOCKEDWRONGUSER, Buffer1, _countof(Buffer1));
1611 wsprintfW(Buffer2, Buffer1, pgContext->DomainName, pgContext->UserName);
1612 LoadStringW(pgContext->hDllInstance, IDS_COMPUTERLOCKED, Buffer1, _countof(Buffer1));
1613 MessageBoxW(hwndDlg, Buffer2, Buffer1, MB_OK | MB_ICONERROR);
1614 }
1615 }
1616 }
1617
1618 if (UserName != NULL)
1619 HeapFree(GetProcessHeap(), 0, UserName);
1620
1621 if (Password != NULL)
1622 {
1623 /* Zero out the password buffer before freeing it */
1624 SIZE_T pwdLen = (wcslen(Password) + 1) * sizeof(WCHAR);
1625 SecureZeroMemory(Password, pwdLen);
1627 }
1628
1629 return res;
1630}
INT WINAPI DECLSPEC_HOTPATCH LoadStringW(HINSTANCE instance, UINT resource_id, LPWSTR buffer, INT buflen)
Definition: string.c:1220
#define IDS_COMPUTERLOCKED
Definition: resource.h:97
#define IDS_LOCKEDWRONGUSER
Definition: resource.h:99
#define IDC_UNLOCK_USERNAME
Definition: resource.h:31
#define IDS_LOCKEDWRONGPASSWORD
Definition: resource.h:98
#define IDC_UNLOCK_PASSWORD
Definition: resource.h:32
BOOL DoAdminUnlock(IN PGINA_CONTEXT pgContext, IN PWSTR UserName, IN PWSTR Domain, IN PWSTR Password)
Definition: msgina.c:639
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:510
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define WLX_SAS_ACTION_UNLOCK_WKSTA
Definition: winwlx.h:60

Referenced by UnlockDialogProc().

◆ GetTextboxText()

static BOOL GetTextboxText ( IN HWND  hwndDlg,
IN INT  TextboxId,
OUT LPWSTR pText 
)
static

Definition at line 540 of file gui.c.

544{
545 LPWSTR Text;
546 int Count;
547
548 Count = GetWindowTextLength(GetDlgItem(hwndDlg, TextboxId));
549 Text = HeapAlloc(GetProcessHeap(), 0, (Count + 1) * sizeof(WCHAR));
550 if (!Text)
551 return FALSE;
552 if (Count != GetWindowTextW(GetDlgItem(hwndDlg, TextboxId), Text, Count + 1))
553 {
555 return FALSE;
556 }
557 *pText = Text;
558 return TRUE;
559}
char * Text
Definition: combotst.c:136
int Count
Definition: noreturn.cpp:7
LPCSTR pText
Definition: txtscale.cpp:79
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1382
#define GetWindowTextLength
Definition: winuser.h:5910

Referenced by DoLogon(), and DoUnlock().

◆ GUIDisplayLockedNotice()

static VOID GUIDisplayLockedNotice ( IN OUT PGINA_CONTEXT  pgContext)
static

Definition at line 1786 of file gui.c.

1788{
1789 pgContext->pWlxFuncs->WlxDialogBoxParam(
1790 pgContext->hWlx,
1791 pgContext->hDllInstance,
1795 (LPARAM)pgContext);
1796}
static INT_PTR CALLBACK LockedDialogProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: gui.c:1738
#define IDD_LOCKED
Definition: resource.h:26
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:628

◆ GUIDisplaySASNotice()

static VOID GUIDisplaySASNotice ( IN OUT PGINA_CONTEXT  pgContext)
static

Definition at line 525 of file gui.c.

527{
528 /* Display the notice window */
529 pgContext->pWlxFuncs->WlxDialogBoxParam(pgContext->hWlx,
530 pgContext->hDllInstance,
534 (LPARAM)pgContext);
535}
static INT_PTR CALLBACK WelcomeDialogProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: gui.c:482
#define IDD_WELCOME
Definition: resource.h:8

◆ GUIDisplayStatusMessage()

static BOOL GUIDisplayStatusMessage ( IN PGINA_CONTEXT  pgContext,
IN HDESK  hDesktop,
IN DWORD  dwOptions,
IN PWSTR  pTitle,
IN PWSTR  pMessage 
)
static

Definition at line 394 of file gui.c.

400{
403 DWORD ThreadId;
404
405 TRACE("GUIDisplayStatusMessage(%ws)\n", pMessage);
406
407 if (!pgContext->hStatusWindow)
408 {
409 /*
410 * If everything goes correctly, 'msg' is freed
411 * by the 'StartupWindowThread' thread.
412 */
415 sizeof(*msg));
416 if(!msg)
417 return FALSE;
418
419 msg->Context = pgContext;
420 msg->dwOptions = dwOptions;
421 msg->pTitle = pTitle;
422 msg->pMessage = pMessage;
423 msg->hDesktop = hDesktop;
424
425 msg->StartupEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
426
427 if (!msg->StartupEvent)
428 {
430 return FALSE;
431 }
432
434 0,
436 (PVOID)msg,
437 0,
438 &ThreadId);
439 if (Thread)
440 {
441 /* 'msg' will be freed by 'StartupWindowThread' */
442
444 WaitForSingleObject(msg->StartupEvent, INFINITE);
445 CloseHandle(msg->StartupEvent);
446 return TRUE;
447 }
448 else
449 {
450 /*
451 * The 'StartupWindowThread' thread couldn't be created,
452 * so we need to free the allocated 'msg'.
453 */
455 }
456
457 return FALSE;
458 }
459
460 if (pTitle)
461 SetWindowTextW(pgContext->hStatusWindow, pTitle);
462
463 SetDlgItemTextW(pgContext->hStatusWindow, IDC_STATUS_MESSAGE, pMessage);
464
465 return TRUE;
466}
#define msg(x)
Definition: auth_time.c:54
#define CloseHandle
Definition: compat.h:739
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
static DWORD WINAPI StartupWindowThread(LPVOID lpParam)
Definition: gui.c:355
struct _DISPLAYSTATUSMSG * PDISPLAYSTATUSMSG
#define INFINITE
Definition: serial.h:102
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
DWORD dwOptions
Definition: solitaire.cpp:25
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)

◆ GUIInitialize()

static BOOL GUIInitialize ( IN OUT PGINA_CONTEXT  pgContext)
static

Definition at line 118 of file gui.c.

120{
121 TRACE("GUIInitialize(%p)\n", pgContext);
122 return TRUE;
123}

◆ GUILockedSAS()

static INT GUILockedSAS ( IN OUT PGINA_CONTEXT  pgContext)
static

Definition at line 1711 of file gui.c.

1713{
1714 int result;
1715
1716 TRACE("GUILockedSAS()\n");
1717
1718 result = pgContext->pWlxFuncs->WlxDialogBoxParam(
1719 pgContext->hWlx,
1720 pgContext->hDllInstance,
1724 (LPARAM)pgContext);
1727 {
1728 WARN("GUILockedSAS() returns 0x%x\n", result);
1729 return result;
1730 }
1731
1732 WARN("GUILockedSAS() failed (0x%x)\n", result);
1733 return WLX_SAS_ACTION_NONE;
1734}
#define WARN(fmt,...)
Definition: precomp.h:61
static INT_PTR CALLBACK UnlockDialogProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: gui.c:1636
#define IDD_UNLOCK
Definition: resource.h:29
#define WLX_SAS_ACTION_NONE
Definition: winwlx.h:54
#define WLX_SAS_ACTION_SWITCH_CONSOLE
Definition: winwlx.h:69
#define WLX_SAS_ACTION_LOGON
Definition: winwlx.h:53

◆ GUILoggedOnSAS()

static INT GUILoggedOnSAS ( IN OUT PGINA_CONTEXT  pgContext,
IN DWORD  dwSasType 
)
static

Definition at line 1118 of file gui.c.

1121{
1122 INT result;
1123
1124 if (dwSasType != WLX_SAS_TYPE_CTRL_ALT_DEL)
1125 {
1126 /* Nothing to do for WLX_SAS_TYPE_TIMEOUT; the dialog will
1127 * close itself thanks to the use of WlxDialogBoxParam */
1128 return WLX_SAS_ACTION_NONE;
1129 }
1130
1131 result = pgContext->pWlxFuncs->WlxDialogBoxParam(
1132 pgContext->hWlx,
1133 pgContext->hDllInstance,
1137 (LPARAM)pgContext);
1138
1141 {
1143 }
1144
1145 return result;
1146}
static INT_PTR CALLBACK SecurityDialogProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: gui.c:1024
#define IDD_SECURITY
Definition: inetcpl.h:83
#define WLX_SAS_TYPE_CTRL_ALT_DEL
Definition: winwlx.h:36

◆ GUILoggedOutSAS()

static INT GUILoggedOutSAS ( IN OUT PGINA_CONTEXT  pgContext)
static

Definition at line 1482 of file gui.c.

1484{
1485 LEGALNOTICEDATA LegalNotice = {NULL, NULL};
1486 HKEY hKey = NULL;
1487 LONG rc;
1488 int result;
1489
1490 TRACE("GUILoggedOutSAS()\n");
1491
1493 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
1494 0,
1496 &hKey);
1497 if (rc == ERROR_SUCCESS)
1498 {
1500 L"LegalNoticeCaption",
1501 &LegalNotice.pszCaption);
1502
1504 L"LegalNoticeText",
1505 &LegalNotice.pszText);
1506
1508 }
1509
1510 if (LegalNotice.pszCaption != NULL && LegalNotice.pszCaption[0] &&
1511 LegalNotice.pszText != NULL && LegalNotice.pszText[0])
1512 {
1513 pgContext->pWlxFuncs->WlxDialogBoxParam(pgContext->hWlx,
1514 pgContext->hDllInstance,
1518 (LPARAM)&LegalNotice);
1519 }
1520
1521 if (LegalNotice.pszCaption != NULL)
1522 HeapFree(GetProcessHeap(), 0, LegalNotice.pszCaption);
1523
1524 if (LegalNotice.pszText != NULL)
1525 HeapFree(GetProcessHeap(), 0, LegalNotice.pszText);
1526
1527 result = pgContext->pWlxFuncs->WlxDialogBoxParam(
1528 pgContext->hWlx,
1529 pgContext->hDllInstance,
1533 (LPARAM)pgContext);
1536 {
1537 WARN("WlxLoggedOutSAS() returns 0x%x\n", result);
1538 return result;
1539 }
1540
1541 WARN("WlxDialogBoxParam() failed (0x%x)\n", result);
1542 return WLX_SAS_ACTION_NONE;
1543}
#define IDD_LOGON
Definition: resource.h:141
#define RegCloseKey(hKey)
Definition: registry.h:49
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
static INT_PTR CALLBACK LogonDialogProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: gui.c:1349
static INT_PTR CALLBACK LegalNoticeDialogProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: gui.c:1450
#define IDD_LEGALNOTICE
Definition: resource.h:66
#define L(x)
Definition: resources.c:13
FxAutoRegKey hKey
LONG ReadRegSzValue(_In_ HKEY hKey, _In_ PCWSTR pszValue, _Out_ PWSTR *pValue)
Definition: utils.c:57
#define KEY_QUERY_VALUE
Definition: nt_native.h:1019
long LONG
Definition: pedump.c:60
LPWSTR pszText
Definition: gui.c:28
LPWSTR pszCaption
Definition: gui.c:27
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

◆ GUIRemoveStatusMessage()

static BOOL GUIRemoveStatusMessage ( IN PGINA_CONTEXT  pgContext)
static

Definition at line 469 of file gui.c.

471{
472 if (pgContext->hStatusWindow)
473 {
474 EndDialog(pgContext->hStatusWindow, 0);
475 pgContext->hStatusWindow = NULL;
476 }
477
478 return TRUE;
479}

◆ LegalNoticeDialogProc()

static INT_PTR CALLBACK LegalNoticeDialogProc ( IN HWND  hwndDlg,
IN UINT  uMsg,
IN WPARAM  wParam,
IN LPARAM  lParam 
)
static

Definition at line 1450 of file gui.c.

1455{
1456 PLEGALNOTICEDATA pLegalNotice;
1457
1458 switch (uMsg)
1459 {
1460 case WM_INITDIALOG:
1461 pLegalNotice = (PLEGALNOTICEDATA)lParam;
1462 SetWindowTextW(hwndDlg, pLegalNotice->pszCaption);
1463 SetDlgItemTextW(hwndDlg, IDC_LEGALNOTICE_TEXT, pLegalNotice->pszText);
1464 return TRUE;
1465
1466 case WM_COMMAND:
1467 switch (LOWORD(wParam))
1468 {
1469 case IDOK:
1470 case IDCANCEL:
1471 EndDialog(hwndDlg, 0);
1472 return TRUE;
1473 }
1474 break;
1475 }
1476
1477 return FALSE;
1478}
struct _LEGALNOTICEDATA * PLEGALNOTICEDATA
#define IDC_LEGALNOTICE_TEXT
Definition: resource.h:67

Referenced by GUILoggedOutSAS().

◆ LockedDialogProc()

static INT_PTR CALLBACK LockedDialogProc ( IN HWND  hwndDlg,
IN UINT  uMsg,
IN WPARAM  wParam,
IN LPARAM  lParam 
)
static

Definition at line 1738 of file gui.c.

1743{
1744 PDLG_DATA pDlgData;
1745
1746 pDlgData = (PDLG_DATA)GetWindowLongPtrW(hwndDlg, GWLP_USERDATA);
1747
1748 switch (uMsg)
1749 {
1750 case WM_INITDIALOG:
1751 {
1752 pDlgData = DlgData_Create(hwndDlg, (PGINA_CONTEXT)lParam);
1753 if (pDlgData == NULL)
1754 return FALSE;
1755
1756 DlgData_LoadBitmaps(pDlgData);
1757
1758 SetWelcomeText(hwndDlg);
1759
1760 SetLockMessage(hwndDlg, IDC_LOCKED_MESSAGE, pDlgData->pgContext);
1761 return TRUE;
1762 }
1763 case WM_PAINT:
1764 {
1765 PAINTSTRUCT ps;
1766 if (pDlgData && pDlgData->hLogoBitmap)
1767 {
1768 BeginPaint(hwndDlg, &ps);
1769 DrawStateW(ps.hdc, NULL, NULL, (LPARAM)pDlgData->hLogoBitmap, (WPARAM)0, 0, 0, 0, 0, DST_BITMAP);
1770 EndPaint(hwndDlg, &ps);
1771 }
1772 return TRUE;
1773 }
1774 case WM_DESTROY:
1775 {
1776 DlgData_Destroy(hwndDlg);
1777 return TRUE;
1778 }
1779 }
1780
1781 return FALSE;
1782}
static PDLG_DATA DlgData_Create(HWND hwndDlg, PGINA_CONTEXT pgContext)
Definition: gui.c:50
static VOID DlgData_Destroy(_Inout_ HWND hwndDlg)
Definition: gui.c:92
static VOID SetWelcomeText(HWND hWnd)
Definition: gui.c:127
static VOID SetLockMessage(HWND hwnd, INT nDlgItem, PGINA_CONTEXT pgContext)
Definition: gui.c:1547
static VOID DlgData_LoadBitmaps(_Inout_ PDLG_DATA pDlgData)
Definition: gui.c:62
#define IDC_LOCKED_MESSAGE
Definition: resource.h:27
#define WM_PAINT
Definition: winuser.h:1648
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define DST_BITMAP
Definition: winuser.h:516
#define WM_DESTROY
Definition: winuser.h:1637
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
BOOL WINAPI DrawStateW(_In_ HDC, _In_opt_ HBRUSH, _In_opt_ DRAWSTATEPROC, _In_ LPARAM, _In_ WPARAM, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)

Referenced by GUIDisplayLockedNotice().

◆ LogOffDialogProc()

static INT_PTR CALLBACK LogOffDialogProc ( IN HWND  hwndDlg,
IN UINT  uMsg,
IN WPARAM  wParam,
IN LPARAM  lParam 
)
static

Definition at line 939 of file gui.c.

944{
945 switch (uMsg)
946 {
947 case WM_INITDIALOG:
948 return TRUE;
949
950 case WM_COMMAND:
951 switch (LOWORD(wParam))
952 {
953 case IDOK:
954 case IDCANCEL:
955 EndDialog(hwndDlg, LOWORD(wParam));
956 return TRUE;
957 }
958 break;
959
960 case WM_CLOSE:
961 EndDialog(hwndDlg, IDCANCEL);
962 return TRUE;
963 }
964
965 return FALSE;
966}

Referenced by OnLogOff().

◆ LogonDialogProc()

static INT_PTR CALLBACK LogonDialogProc ( IN HWND  hwndDlg,
IN UINT  uMsg,
IN WPARAM  wParam,
IN LPARAM  lParam 
)
static

Definition at line 1349 of file gui.c.

1354{
1355 PDLG_DATA pDlgData;
1356
1357 pDlgData = (PDLG_DATA)GetWindowLongPtrW(hwndDlg, GWLP_USERDATA);
1358
1359 switch (uMsg)
1360 {
1361 case WM_INITDIALOG:
1362 {
1363 /* FIXME: take care of NoDomainUI */
1364 pDlgData = DlgData_Create(hwndDlg, (PGINA_CONTEXT)lParam);
1365 if (pDlgData == NULL)
1366 return FALSE;
1367
1368 DlgData_LoadBitmaps(pDlgData);
1369
1370 SetWelcomeText(hwndDlg);
1371
1372 if (pDlgData->pgContext->bAutoAdminLogon ||
1374 {
1376 }
1377
1378 if (pDlgData->pgContext->bAutoAdminLogon)
1380
1382
1383 if (pDlgData->pgContext->bDisableCAD)
1385
1386 if (!pDlgData->pgContext->bShutdownWithoutLogon)
1388
1390
1391 if (pDlgData->pgContext->bAutoAdminLogon)
1392 PostMessage(GetDlgItem(hwndDlg, IDOK), BM_CLICK, 0, 0);
1393
1394 return FALSE; // Default focus is changed.
1395 }
1396
1397 case WM_PAINT:
1398 {
1399 PAINTSTRUCT ps;
1400 if (pDlgData && pDlgData->hLogoBitmap)
1401 {
1402 BeginPaint(hwndDlg, &ps);
1403 DrawStateW(ps.hdc, NULL, NULL, (LPARAM)pDlgData->hLogoBitmap, (WPARAM)0, 0, 0, 0, 0, DST_BITMAP);
1404 EndPaint(hwndDlg, &ps);
1405 }
1406 return TRUE;
1407 }
1408
1409 case WM_DESTROY:
1410 DlgData_Destroy(hwndDlg);
1411 return TRUE;
1412
1413 case WM_COMMAND:
1414 switch (LOWORD(wParam))
1415 {
1416 case IDOK:
1417 if (DoLogon(hwndDlg, pDlgData->pgContext))
1418 {
1420 }
1421 else
1422 {
1425 }
1426 return TRUE;
1427
1428 case IDCANCEL:
1430 return TRUE;
1431
1432 case IDC_LOGON_SHUTDOWN:
1433 if (OnShutDown(hwndDlg, pDlgData->pgContext,
1435 {
1436 EndDialog(hwndDlg, pDlgData->pgContext->nShutdownAction);
1437 }
1438 return TRUE;
1439 }
1440 break;
1441 }
1442
1443 return FALSE;
1444}
static VOID SetDomainComboBox(HWND hwndDomainComboBox, PGINA_CONTEXT pgContext)
Definition: gui.c:1314
static BOOL DoLogon(IN HWND hwndDlg, IN OUT PGINA_CONTEXT pgContext)
Definition: gui.c:1151
static INT OnShutDown(_In_ HWND hwndDlg, _In_ PGINA_CONTEXT pgContext, _In_ DWORD dwExcludeOptions)
Definition: gui.c:987
#define IDC_LOGON_SHUTDOWN
Definition: resource.h:15
#define WLX_SHUTDOWN_STATE_LOGOFF
Shutdown state flags.
Definition: msgina.h:133
#define WLX_SHUTDOWN_STATE_DISCONNECT
"Disconnect" (only available in Terminal Services sessions)
Definition: msgina.h:140
BOOL bAutoAdminLogon
Definition: msgina.h:43
BOOL bDontDisplayLastUserName
Definition: msgina.h:44
BOOL bShutdownWithoutLogon
Definition: msgina.h:45
BOOL bDisableCAD
Definition: msgina.h:42
ULONG nShutdownAction
Definition: msgina.h:48
WCHAR Password[256]
Definition: msgina.h:53
#define BM_CLICK
Definition: winuser.h:1946
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define PostMessage
Definition: winuser.h:5943

Referenced by GUILoggedOutSAS().

◆ OnChangePassword()

static BOOL OnChangePassword ( IN HWND  hwnd,
IN PGINA_CONTEXT  pgContext 
)
static

Definition at line 916 of file gui.c.

919{
920 INT res;
921
922 TRACE("OnChangePassword()\n");
923
924 res = pgContext->pWlxFuncs->WlxDialogBoxParam(
925 pgContext->hWlx,
926 pgContext->hDllInstance,
928 hwnd,
930 (LPARAM)pgContext);
931
932 TRACE("Result: %x\n", res);
933
934 return FALSE;
935}
static INT_PTR CALLBACK ChangePasswordDialogProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: gui.c:756
#define IDD_CHANGEPWD
Definition: resource.h:34
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

Referenced by DoLogon(), and SecurityDialogProc().

◆ OnInitSecurityDlg()

static VOID OnInitSecurityDlg ( _In_ HWND  hwnd,
_In_ PGINA_CONTEXT  pgContext 
)
static

Definition at line 813 of file gui.c.

816{
817 HKEY hKeyCurrentUser, hKey;
818 DWORD dwValue;
819 LONG lRet;
820
821 WCHAR Buffer1[256];
822 WCHAR Buffer2[256];
823 WCHAR Buffer3[256];
824 WCHAR Buffer4[512];
825
826 LoadStringW(pgContext->hDllInstance, IDS_LOGONMSG, Buffer1, _countof(Buffer1));
827
828 wsprintfW(Buffer2, L"%s\\%s", pgContext->DomainName, pgContext->UserName);
829 wsprintfW(Buffer4, Buffer1, Buffer2);
830
832
833 LoadStringW(pgContext->hDllInstance, IDS_LOGONDATE, Buffer1, _countof(Buffer1));
834
836 (SYSTEMTIME*)&pgContext->LogonTime, NULL, Buffer2, _countof(Buffer2));
837
839 (SYSTEMTIME*)&pgContext->LogonTime, NULL, Buffer3, _countof(Buffer3));
840
841 wsprintfW(Buffer4, Buffer1, Buffer2, Buffer3);
842
844
846 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
847 0,
849 if (lRet == ERROR_SUCCESS)
850 {
851 lRet = ReadRegDwordValue(hKey, L"DisableLockWorkstation", &dwValue);
852 if ((lRet == ERROR_SUCCESS) && !!dwValue)
854
856 }
857
858 /* Open the per-user registry key */
859 lRet = RegOpenLoggedOnHKCU(pgContext->UserToken,
861 &hKeyCurrentUser);
862 if (lRet != ERROR_SUCCESS)
863 {
864 /* We couldn't, bail out */
865 return;
866 }
867
868 lRet = RegOpenKeyExW(hKeyCurrentUser,
869 L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",
870 0,
872 if (lRet == ERROR_SUCCESS)
873 {
874 lRet = ReadRegDwordValue(hKey, L"DisableLockWorkstation", &dwValue);
875 if ((lRet == ERROR_SUCCESS) && !!dwValue)
877
878 lRet = ReadRegDwordValue(hKey, L"DisableChangePassword", &dwValue);
879 if ((lRet == ERROR_SUCCESS) && !!dwValue)
881
882 lRet = ReadRegDwordValue(hKey, L"DisableTaskMgr", &dwValue);
883 if ((lRet == ERROR_SUCCESS) && !!dwValue)
885
887 }
888
889 lRet = RegOpenKeyExW(hKeyCurrentUser,
890 L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
891 0,
893 if (lRet == ERROR_SUCCESS)
894 {
895 lRet = ReadRegDwordValue(hKey, L"NoLogoff", &dwValue);
896 if ((lRet == ERROR_SUCCESS) && !!dwValue)
898
899 // TODO: Disable also if "NoDisconnect" on Terminal Services
900 /* Disable the "Shutdown" button if the user doesn't have shutdown privilege */
901 lRet = ReadRegDwordValue(hKey, L"NoClose", &dwValue);
902 if (((lRet == ERROR_SUCCESS) && !!dwValue) ||
903 !TestTokenPrivilege(pgContext->UserToken, SE_SHUTDOWN_PRIVILEGE))
904 {
906 }
907
909 }
910
911 RegCloseKey(hKeyCurrentUser);
912}
#define IDC_SECURITY_TASKMGR
Definition: resource.h:24
#define IDC_SECURITY_CHANGEPWD
Definition: resource.h:23
#define IDC_SECURITY_SHUTDOWN
Definition: resource.h:22
#define IDC_SECURITY_MESSAGE
Definition: resource.h:18
#define IDC_SECURITY_LOGOFF
Definition: resource.h:21
#define IDC_SECURITY_LOGONDATE
Definition: resource.h:19
#define IDC_SECURITY_LOCK
Definition: resource.h:20
#define IDS_LOGONMSG
Definition: resource.h:95
#define IDS_LOGONDATE
Definition: resource.h:96
INT WINAPI GetTimeFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpTimeStr, INT cchOut)
Definition: lcformat.c:1089
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:989
#define SE_SHUTDOWN_PRIVILEGE
Definition: security.c:673
BOOL TestTokenPrivilege(_In_opt_ HANDLE hToken, _In_ ULONG Privilege)
Verifies whether the specified token has the given privilege.
Definition: utils.c:140
LONG ReadRegDwordValue(_In_ HKEY hKey, _In_ PCWSTR pszValue, _Out_ PDWORD pValue)
Definition: utils.c:90
LONG RegOpenLoggedOnHKCU(_In_opt_ HANDLE hUserToken, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Opens and retrieves a handle to the HKEY_CURRENT_USER corresponding to the specified logged-on user.
Definition: utils.c:31
#define LOCALE_USER_DEFAULT
#define DATE_SHORTDATE
Definition: winnls.h:209

Referenced by SecurityDialogProc().

◆ OnLogOff()

static INT OnLogOff ( IN HWND  hwndDlg,
IN PGINA_CONTEXT  pgContext 
)
static

Definition at line 971 of file gui.c.

974{
975 return pgContext->pWlxFuncs->WlxDialogBoxParam(
976 pgContext->hWlx,
977 pgContext->hDllInstance,
979 hwndDlg,
981 (LPARAM)pgContext);
982}
static INT_PTR CALLBACK LogOffDialogProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: gui.c:939
#define IDD_LOGOFF
Definition: resource.h:41

Referenced by SecurityDialogProc().

◆ OnShutDown()

static INT OnShutDown ( _In_ HWND  hwndDlg,
_In_ PGINA_CONTEXT  pgContext,
_In_ DWORD  dwExcludeOptions 
)
static

Definition at line 987 of file gui.c.

991{
992 HKEY hKeyCurrentUser = NULL;
993 DWORD ShutdownOptions = 0;
994 INT ret;
995
996 /* Open the per-user registry key */
997 if (RegOpenLoggedOnHKCU(pgContext->UserToken,
999 &hKeyCurrentUser) != ERROR_SUCCESS)
1000 {
1001 ERR("RegOpenLoggedOnHKCU() failed with error %ld\n", GetLastError());
1002 }
1003 pgContext->nShutdownAction = 0;
1004 if (hKeyCurrentUser)
1005 {
1006 ShutdownOptions = GetAllowedShutdownOptions(hKeyCurrentUser, pgContext->UserToken);
1007 pgContext->nShutdownAction = LoadShutdownSelState(hKeyCurrentUser);
1008 }
1009 ShutdownOptions &= ~dwExcludeOptions;
1010
1011 ret = ShutdownDialog(hwndDlg, ShutdownOptions, pgContext);
1012
1013 if ((ret == IDOK) && hKeyCurrentUser)
1014 SaveShutdownSelState(hKeyCurrentUser, pgContext->nShutdownAction);
1015
1016 if (hKeyCurrentUser)
1017 RegCloseKey(hKeyCurrentUser);
1018
1019 return ret;
1020}
return ret
Definition: mutex.c:146
DWORD GetAllowedShutdownOptions(_In_opt_ HKEY hKeyCurrentUser, _In_opt_ HANDLE hUserToken)
Definition: shutdown.c:808
DWORD LoadShutdownSelState(_In_ HKEY hKeyCurrentUser)
Definition: shutdown.c:696
VOID SaveShutdownSelState(_In_ HKEY hKeyCurrentUser, _In_ DWORD ShutdownCode)
Definition: shutdown.c:759
INT_PTR ShutdownDialog(IN HWND hwndDlg, IN DWORD ShutdownOptions, IN PGINA_CONTEXT pgContext)
Definition: shutdown.c:1252
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1021
#define KEY_SET_VALUE
Definition: nt_native.h:1020
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by LogonDialogProc(), and SecurityDialogProc().

◆ ResourceMessageBox()

static INT ResourceMessageBox ( IN PGINA_CONTEXT  pgContext,
IN HWND  hwnd,
IN UINT  uType,
IN UINT  uCaption,
IN UINT  uText 
)
static

Definition at line 564 of file gui.c.

570{
571 WCHAR szCaption[256];
572 WCHAR szText[256];
573
574 LoadStringW(pgContext->hDllInstance, uCaption, szCaption, _countof(szCaption));
575 LoadStringW(pgContext->hDllInstance, uText, szText, _countof(szText));
576
577 return pgContext->pWlxFuncs->WlxMessageBox(pgContext->hWlx,
578 hwnd,
579 szText,
580 szCaption,
581 uType);
582}

Referenced by DoChangePassword(), DoLogon(), and SecurityDialogProc().

◆ SecurityDialogProc()

static INT_PTR CALLBACK SecurityDialogProc ( IN HWND  hwndDlg,
IN UINT  uMsg,
IN WPARAM  wParam,
IN LPARAM  lParam 
)
static

Definition at line 1024 of file gui.c.

1029{
1030 PGINA_CONTEXT pgContext;
1031
1032 pgContext = (PGINA_CONTEXT)GetWindowLongPtrW(hwndDlg, GWLP_USERDATA);
1033
1034 switch (uMsg)
1035 {
1036 case WM_INITDIALOG:
1037 {
1038 pgContext = (PGINA_CONTEXT)lParam;
1039 SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (LONG_PTR)pgContext);
1040
1041 SetWelcomeText(hwndDlg);
1042
1044 return TRUE;
1045 }
1046
1047 case WM_COMMAND:
1048 {
1049 switch (LOWORD(wParam))
1050 {
1051 case IDC_SECURITY_LOCK:
1053 return TRUE;
1055 if (ISKEYDOWN(VK_CONTROL))
1056 {
1057 if (ResourceMessageBox(pgContext,
1058 hwndDlg,
1062 {
1064 }
1065 }
1066 else if (OnLogOff(hwndDlg, pgContext) == IDOK)
1067 {
1069 }
1070 return TRUE;
1072 /* Emergency restart feature */
1073 if (ISKEYDOWN(VK_CONTROL))
1074 {
1075 if (ResourceMessageBox(pgContext,
1076 hwndDlg,
1080 {
1081 BOOLEAN Old;
1082
1083 ERR("Emergency restarting NT...\n");
1087 }
1088 }
1089 else if (OnShutDown(hwndDlg, pgContext, 0) == IDOK)
1090 {
1091 EndDialog(hwndDlg, pgContext->nShutdownAction);
1092 }
1093 return TRUE;
1095 if (OnChangePassword(hwndDlg, pgContext))
1097 return TRUE;
1100 return TRUE;
1101 case IDCANCEL:
1103 return TRUE;
1104 }
1105 break;
1106 }
1107 case WM_CLOSE:
1108 {
1110 return TRUE;
1111 }
1112 }
1113
1114 return FALSE;
1115}
unsigned char BOOLEAN
#define ISKEYDOWN(x)
Definition: gui.c:34
static VOID OnInitSecurityDlg(_In_ HWND hwnd, _In_ PGINA_CONTEXT pgContext)
Definition: gui.c:813
static INT OnLogOff(IN HWND hwndDlg, IN PGINA_CONTEXT pgContext)
Definition: gui.c:971
#define IDS_EMERGENCYRESTARTTITLE
Definition: resource.h:129
#define IDS_EMERGENCYLOGOFFTITLE
Definition: resource.h:127
#define IDS_EMERGENCYRESTART
Definition: resource.h:130
#define IDS_EMERGENCYLOGOFF
Definition: resource.h:128
@ ShutdownReboot
Definition: extypes.h:177
NTSYSAPI NTSTATUS NTAPI RtlAdjustPrivilege(_In_ ULONG Privilege, _In_ BOOLEAN NewValue, _In_ BOOLEAN ForThread, _Out_ PBOOLEAN OldValue)
NTSTATUS NTAPI NtShutdownSystem(IN SHUTDOWN_ACTION Action)
Definition: shutdown.c:43
#define VK_CONTROL
Definition: winuser.h:2239
#define MB_OKCANCEL
Definition: winuser.h:815
#define WLX_SAS_ACTION_FORCE_LOGOFF
Definition: winwlx.h:61
#define WLX_SAS_ACTION_PWD_CHANGED
Definition: winwlx.h:58
#define WLX_SAS_ACTION_TASKLIST
Definition: winwlx.h:59
#define WLX_SAS_ACTION_LOCK_WKSTA
Definition: winwlx.h:55
#define WLX_SAS_ACTION_LOGOFF
Definition: winwlx.h:56

Referenced by GUILoggedOnSAS().

◆ SetDomainComboBox()

static VOID SetDomainComboBox ( HWND  hwndDomainComboBox,
PGINA_CONTEXT  pgContext 
)
static

Definition at line 1314 of file gui.c.

1317{
1318 WCHAR szComputerName[MAX_COMPUTERNAME_LENGTH + 1];
1319 DWORD dwComputerNameLength;
1320 LONG lIndex = 0;
1321 LONG lFindIndex;
1322
1323 SendMessageW(hwndDomainComboBox, CB_RESETCONTENT, 0, 0);
1324
1325 dwComputerNameLength = _countof(szComputerName);
1326 if (GetComputerNameW(szComputerName, &dwComputerNameLength))
1327 {
1328 lIndex = SendMessageW(hwndDomainComboBox, CB_ADDSTRING, 0, (LPARAM)szComputerName);
1329 }
1330
1331 if (pgContext->DomainName[0])
1332 {
1333 lFindIndex = SendMessageW(hwndDomainComboBox, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)pgContext->DomainName);
1334 if (lFindIndex == CB_ERR)
1335 {
1336 lIndex = SendMessageW(hwndDomainComboBox, CB_ADDSTRING, 0, (LPARAM)pgContext->DomainName);
1337 }
1338 else
1339 {
1340 lIndex = lFindIndex;
1341 }
1342 }
1343
1344 SendMessageW(hwndDomainComboBox, CB_SETCURSEL, lIndex, 0);
1345}
BOOL WINAPI GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize)
Definition: compname.c:446
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:267
#define CB_ERR
Definition: winuser.h:2471
#define CB_RESETCONTENT
Definition: winuser.h:1988
#define CB_FINDSTRINGEXACT
Definition: winuser.h:1969

Referenced by LogonDialogProc().

◆ SetLockMessage()

static VOID SetLockMessage ( HWND  hwnd,
INT  nDlgItem,
PGINA_CONTEXT  pgContext 
)
static

Definition at line 1547 of file gui.c.

1550{
1551 WCHAR Buffer1[256];
1552 WCHAR Buffer2[256];
1553 WCHAR Buffer3[512];
1554
1555 LoadStringW(pgContext->hDllInstance, IDS_LOCKMSG, Buffer1, _countof(Buffer1));
1556
1557 wsprintfW(Buffer2, L"%s\\%s", pgContext->DomainName, pgContext->UserName);
1558 wsprintfW(Buffer3, Buffer1, Buffer2);
1559
1560 SetDlgItemTextW(hwnd, nDlgItem, Buffer3);
1561}
#define IDS_LOCKMSG
Definition: resource.h:94
HANDLE hDllInstance
Definition: msgina.h:38

Referenced by LockedDialogProc(), and UnlockDialogProc().

◆ SetWelcomeText()

static VOID SetWelcomeText ( HWND  hWnd)
static

Definition at line 127 of file gui.c.

128{
129 PWCHAR pBuffer = NULL, p;
130 HKEY hKey;
131 DWORD BufSize, dwType, dwWelcomeSize, dwTitleLength;
132 LONG rc;
133
134 /* Open the Winlogon key */
136 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
137 0,
139 &hKey);
140 if (rc != ERROR_SUCCESS)
141 {
142 WARN("RegOpenKeyExW() failed with error %lu\n", rc);
143 return;
144 }
145
146 /* Get the size of the Welcome value */
147 dwWelcomeSize = 0;
149 L"Welcome",
150 NULL,
151 &dwType,
152 NULL,
153 &dwWelcomeSize);
154 if (rc == ERROR_FILE_NOT_FOUND || dwWelcomeSize == 0 || dwType != REG_SZ)
155 goto done;
156
157 dwTitleLength = GetWindowTextLengthW(hWnd);
158 BufSize = dwWelcomeSize + ((dwTitleLength + 1) * sizeof(WCHAR));
159
161 if (pBuffer == NULL)
162 goto done;
163
165 wcscat(pBuffer, L" ");
166 p = &pBuffer[dwTitleLength + 1];
167
169 L"Welcome",
170 NULL,
171 &dwType,
172 (PBYTE)p,
173 &dwWelcomeSize);
174
176
177done:
178 if (pBuffer != NULL)
180
182}
#define BufSize
Definition: FsRtlTunnel.c:28
HWND hWnd
Definition: settings.c:17
wcscat
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
GLfloat GLfloat p
Definition: glext.h:8902
#define REG_SZ
Definition: layer.c:22
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
BYTE * PBYTE
Definition: pedump.c:66
PVOID pBuffer
uint16_t * PWCHAR
Definition: typedefs.h:56
int WINAPI GetWindowTextLengthW(_In_ HWND)
#define SetWindowText
Definition: winuser.h:5968

Referenced by LockedDialogProc(), LogonDialogProc(), SecurityDialogProc(), and UnlockDialogProc().

◆ StartupWindowThread()

static DWORD WINAPI StartupWindowThread ( LPVOID  lpParam)
static

Definition at line 355 of file gui.c.

356{
357 HDESK hDesk;
359
360 /* When SetThreadDesktop is called the system closes the desktop handle when needed
361 so we have to create a new handle because this handle may still be in use by winlogon */
363 msg->hDesktop,
365 (HANDLE*)&hDesk,
366 0,
367 FALSE,
369 {
370 ERR("Duplicating handle failed!\n");
371 HeapFree(GetProcessHeap(), 0, lpParam);
372 return FALSE;
373 }
374
375 if(!SetThreadDesktop(hDesk))
376 {
377 ERR("Setting thread desktop failed!\n");
378 HeapFree(GetProcessHeap(), 0, lpParam);
379 return FALSE;
380 }
381
387 (LPARAM)lpParam);
388
389 HeapFree(GetProcessHeap(), 0, lpParam);
390 return TRUE;
391}
#define IDD_STATUS
Definition: resource.h:22
#define GetCurrentProcess()
Definition: compat.h:759
BOOL WINAPI DuplicateHandle(IN HANDLE hSourceProcessHandle, IN HANDLE hSourceHandle, IN HANDLE hTargetProcessHandle, OUT LPHANDLE lpTargetHandle, IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwOptions)
Definition: handle.c:149
static INT_PTR CALLBACK StatusDialogProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: gui.c:249
BOOL WINAPI SetThreadDesktop(_In_ HDESK)
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define DUPLICATE_SAME_ACCESS

Referenced by GUIDisplayStatusMessage().

◆ StatusDialogProc()

static INT_PTR CALLBACK StatusDialogProc ( IN HWND  hwndDlg,
IN UINT  uMsg,
IN WPARAM  wParam,
IN LPARAM  lParam 
)
static

Definition at line 249 of file gui.c.

254{
255 PDLG_DATA pDlgData;
257
258 pDlgData = (PDLG_DATA)GetWindowLongPtrW(hwndDlg, GWLP_USERDATA);
259
260 switch (uMsg)
261 {
262 case WM_INITDIALOG:
263 {
265 if (!msg)
266 return FALSE;
267
268 msg->Context->hStatusWindow = hwndDlg;
269
270 if (msg->pTitle)
271 SetWindowTextW(hwndDlg, msg->pTitle);
272 SetDlgItemTextW(hwndDlg, IDC_STATUS_MESSAGE, msg->pMessage);
273 SetEvent(msg->StartupEvent);
274
275 pDlgData = DlgData_Create(hwndDlg, msg->Context);
276 if (pDlgData == NULL)
277 return FALSE;
278
279 DlgData_LoadBitmaps(pDlgData);
280 if (pDlgData->hBarBitmap)
281 {
282 if (SetTimer(hwndDlg, IDT_BAR, 20, NULL) == 0)
283 {
284 ERR("SetTimer(IDT_BAR) failed: %d\n", GetLastError());
285 }
286 else
287 {
288 /* Get the animation bar control */
289 pDlgData->hWndBarCtrl = GetDlgItem(hwndDlg, IDC_BAR);
290 }
291 }
292
293 AdjustStatusMessageWindow(hwndDlg, pDlgData);
294 return TRUE;
295 }
296
297 case WM_TIMER:
298 {
299 if (pDlgData && pDlgData->hBarBitmap)
300 {
301 /*
302 * Default rotation bar image width is 413 (same as logo)
303 * We can divide 413 by 7 without remainder
304 */
305 pDlgData->BarCounter = (pDlgData->BarCounter + 7) % pDlgData->BarWidth;
307 UpdateWindow(pDlgData->hWndBarCtrl);
308 }
309 return TRUE;
310 }
311
312 case WM_DRAWITEM:
313 {
315
316 if (lpDis->CtlID != IDC_BAR)
317 {
318 return FALSE;
319 }
320
321 if (pDlgData && pDlgData->hBarBitmap)
322 {
323 HDC hdcMem;
324 HGDIOBJ hOld;
325 DWORD off = pDlgData->BarCounter;
326 DWORD iw = pDlgData->BarWidth;
327 DWORD ih = pDlgData->BarHeight;
328
329 hdcMem = CreateCompatibleDC(lpDis->hDC);
330 hOld = SelectObject(hdcMem, pDlgData->hBarBitmap);
331 BitBlt(lpDis->hDC, off, 0, iw - off, ih, hdcMem, 0, 0, SRCCOPY);
332 BitBlt(lpDis->hDC, 0, 0, off, ih, hdcMem, iw - off, 0, SRCCOPY);
333 SelectObject(hdcMem, hOld);
335
336 return TRUE;
337 }
338 return FALSE;
339 }
340
341 case WM_DESTROY:
342 {
343 if (pDlgData && pDlgData->hBarBitmap)
344 {
345 KillTimer(hwndDlg, IDT_BAR);
346 }
347 DlgData_Destroy(hwndDlg);
348 return TRUE;
349 }
350 }
351 return FALSE;
352}
static VOID AdjustStatusMessageWindow(HWND hwndDlg, PDLG_DATA pDlgData)
Definition: gui.c:185
#define IDT_BAR
Definition: gui.c:32
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:57
static HDC
Definition: imagelist.c:88
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
DWORD BarHeight
Definition: gui.c:46
DWORD BarWidth
Definition: gui.c:45
HWND hWndBarCtrl
Definition: gui.c:41
DWORD BarCounter
Definition: gui.c:42
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
HDC hdcMem
Definition: welcome.c:104
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define SRCCOPY
Definition: wingdi.h:333
BOOL WINAPI DeleteDC(_In_ HDC)
struct tagDRAWITEMSTRUCT * LPDRAWITEMSTRUCT
#define WM_DRAWITEM
Definition: winuser.h:1673
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define WM_TIMER
Definition: winuser.h:1770
BOOL WINAPI UpdateWindow(_In_ HWND)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)

Referenced by StartupWindowThread().

◆ UnlockDialogProc()

static INT_PTR CALLBACK UnlockDialogProc ( IN HWND  hwndDlg,
IN UINT  uMsg,
IN WPARAM  wParam,
IN LPARAM  lParam 
)
static

Definition at line 1636 of file gui.c.

1641{
1642 PDLG_DATA pDlgData;
1644
1645 pDlgData = (PDLG_DATA)GetWindowLongPtrW(hwndDlg, GWLP_USERDATA);
1646
1647 switch (uMsg)
1648 {
1649 case WM_INITDIALOG:
1650 {
1651 pDlgData = DlgData_Create(hwndDlg, (PGINA_CONTEXT)lParam);
1652 if (pDlgData == NULL)
1653 return FALSE;
1654
1655 DlgData_LoadBitmaps(pDlgData);
1656
1657 SetWelcomeText(hwndDlg);
1658
1659 SetLockMessage(hwndDlg, IDC_UNLOCK_MESSAGE, pDlgData->pgContext);
1661
1662 if (pDlgData->pgContext->bDisableCAD)
1664
1666 return FALSE; // Default focus is changed.
1667 }
1668
1669 case WM_PAINT:
1670 {
1671 PAINTSTRUCT ps;
1672 if (pDlgData && pDlgData->hLogoBitmap)
1673 {
1674 BeginPaint(hwndDlg, &ps);
1675 DrawStateW(ps.hdc, NULL, NULL, (LPARAM)pDlgData->hLogoBitmap, (WPARAM)0, 0, 0, 0, 0, DST_BITMAP);
1676 EndPaint(hwndDlg, &ps);
1677 }
1678 return TRUE;
1679 }
1680 case WM_DESTROY:
1681 DlgData_Destroy(hwndDlg);
1682 return TRUE;
1683
1684 case WM_COMMAND:
1685 switch (LOWORD(wParam))
1686 {
1687 case IDOK:
1688 if (DoUnlock(hwndDlg, pDlgData->pgContext, &result))
1689 {
1690 EndDialog(hwndDlg, result);
1691 }
1692 else
1693 {
1696 }
1697 return TRUE;
1698
1699 case IDCANCEL:
1701 return TRUE;
1702 }
1703 break;
1704 }
1705
1706 return FALSE;
1707}
static BOOL DoUnlock(IN HWND hwndDlg, IN PGINA_CONTEXT pgContext, OUT LPINT Action)
Definition: gui.c:1566
#define IDC_UNLOCK_MESSAGE
Definition: resource.h:30

Referenced by GUILockedSAS().

◆ WelcomeDialogProc()

static INT_PTR CALLBACK WelcomeDialogProc ( IN HWND  hwndDlg,
IN UINT  uMsg,
IN WPARAM  wParam,
IN LPARAM  lParam 
)
static

Definition at line 482 of file gui.c.

487{
488 PDLG_DATA pDlgData;
489
490 pDlgData = (PDLG_DATA)GetWindowLongPtrW(hwndDlg, GWLP_USERDATA);
491
492 switch (uMsg)
493 {
494 case WM_INITDIALOG:
495 {
496 pDlgData = DlgData_Create(hwndDlg, (PGINA_CONTEXT)lParam);
497 if (pDlgData == NULL)
498 return FALSE;
499
500 DlgData_LoadBitmaps(pDlgData);
501 return TRUE;
502 }
503
504 case WM_PAINT:
505 {
506 PAINTSTRUCT ps;
507 if (pDlgData && pDlgData->hLogoBitmap)
508 {
509 BeginPaint(hwndDlg, &ps);
510 DrawStateW(ps.hdc, NULL, NULL, (LPARAM)pDlgData->hLogoBitmap, (WPARAM)0, 0, 0, 0, 0, DST_BITMAP);
511 EndPaint(hwndDlg, &ps);
512 }
513 return TRUE;
514 }
515 case WM_DESTROY:
516 {
517 DlgData_Destroy(hwndDlg);
518 return TRUE;
519 }
520 }
521 return FALSE;
522}

Referenced by GUIDisplaySASNotice().

Variable Documentation

◆ GinaGraphicalUI

GINA_UI GinaGraphicalUI
Initial value:
= {
}
static INT GUILoggedOnSAS(IN OUT PGINA_CONTEXT pgContext, IN DWORD dwSasType)
Definition: gui.c:1118
static BOOL GUIInitialize(IN OUT PGINA_CONTEXT pgContext)
Definition: gui.c:118
static INT GUILockedSAS(IN OUT PGINA_CONTEXT pgContext)
Definition: gui.c:1711
static INT GUILoggedOutSAS(IN OUT PGINA_CONTEXT pgContext)
Definition: gui.c:1482
static BOOL GUIDisplayStatusMessage(IN PGINA_CONTEXT pgContext, IN HDESK hDesktop, IN DWORD dwOptions, IN PWSTR pTitle, IN PWSTR pMessage)
Definition: gui.c:394
static VOID GUIDisplayLockedNotice(IN OUT PGINA_CONTEXT pgContext)
Definition: gui.c:1786
static BOOL GUIRemoveStatusMessage(IN PGINA_CONTEXT pgContext)
Definition: gui.c:469
static VOID GUIDisplaySASNotice(IN OUT PGINA_CONTEXT pgContext)
Definition: gui.c:525

Definition at line 1798 of file gui.c.

Referenced by ChooseGinaUI().