ReactOS 0.4.15-dev-8131-g4988de4
tui.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS msgina.dll
3 * FILE: dll/win32/msgina/tui.c
4 * PURPOSE: ReactOS Logon GINA DLL
5 * PROGRAMMER: Hervé Poussineau (hpoussin@reactos.org)
6 */
7
8#include "msgina.h"
9
10#include <wincon.h>
11
12static BOOL
14 IN OUT PGINA_CONTEXT pgContext)
15{
16 TRACE("TUIInitialize(%p)\n", pgContext);
17
18 return AllocConsole();
19}
20
21static BOOL
23 IN PGINA_CONTEXT pgContext,
24 IN HDESK hDesktop,
26 IN PWSTR pTitle,
27 IN PWSTR pMessage)
28{
29 static LPCWSTR newLine = L"\n";
31
32 TRACE("TUIDisplayStatusMessage(%ws)\n", pMessage);
33
34 UNREFERENCED_PARAMETER(pgContext);
35 UNREFERENCED_PARAMETER(hDesktop);
38
39 return
42 pMessage,
43 wcslen(pMessage),
44 &result,
45 NULL) &&
48 newLine,
49 wcslen(newLine),
50 &result,
51 NULL);
52}
53
54static BOOL
56 IN PGINA_CONTEXT pgContext)
57{
58 UNREFERENCED_PARAMETER(pgContext);
59
60 /* Nothing to do */
61 return TRUE;
62}
63
64static BOOL
66 IN UINT uIdResourceText,
67 IN BOOL AddNewLine)
68{
69 WCHAR Prompt[256];
70 static LPCWSTR newLine = L"\n";
72
73 if (0 == LoadStringW(hDllInstance, uIdResourceText, Prompt, _countof(Prompt)))
74 return FALSE;
75 if (!WriteConsoleW(
77 Prompt, wcslen(Prompt),
78 &count, NULL))
79 {
80 return FALSE;
81 }
82 if (AddNewLine)
83 {
84 if (!WriteConsoleW(
86 newLine, wcslen(newLine),
87 &count, NULL))
88 {
89 return FALSE;
90 }
91 }
92 return TRUE;
93}
94
95static VOID
97 IN OUT PGINA_CONTEXT pgContext)
98{
99 TRACE("TUIDisplaySASNotice()\n");
100
101 UNREFERENCED_PARAMETER(pgContext);
102
105}
106
107static INT
109 IN OUT PGINA_CONTEXT pgContext,
110 IN DWORD dwSasType)
111{
112 TRACE("TUILoggedOnSAS()\n");
113
114 UNREFERENCED_PARAMETER(pgContext);
115
116 if (dwSasType != WLX_SAS_TYPE_CTRL_ALT_DEL)
117 {
118 /* Nothing to do for WLX_SAS_TYPE_TIMEOUT */
119 return WLX_SAS_ACTION_NONE;
120 }
121
122 FIXME("FIXME: TUILoggedOnSAS(): Let's suppose the user wants to log off...\n");
124}
125
126static BOOL
128 IN UINT uIdResourcePrompt,
131 IN BOOL ShowString)
132{
133 DWORD count, i;
134 WCHAR charToDisplay[] = { 0, UNICODE_NULL };
135
137 return FALSE;
138
140 return FALSE;
141
142 if (!DisplayResourceText(uIdResourcePrompt, FALSE))
143 return FALSE;
144
145 i = 0;
146 for (;;)
147 {
148 WCHAR readChar;
149 if (!ReadConsoleW(GetStdHandle(STD_INPUT_HANDLE), &readChar, 1, &count, NULL))
150 return FALSE;
151 if (readChar == '\r' || readChar == '\n')
152 {
153 /* End of string */
154 charToDisplay[0] = L'\n';
157 charToDisplay,
158 wcslen(charToDisplay),
159 &count,
160 NULL);
161 break;
162 }
163 if (ShowString)
164 {
165 /* Display the char */
166 charToDisplay[0] = readChar;
169 charToDisplay,
170 wcslen(charToDisplay),
171 &count,
172 NULL);
173 }
174 Buffer[i++] = readChar;
175 /* FIXME: buffer overflow if the user writes too many chars! */
177 /* FIXME: handle backspace */
178 }
180
181 if (!ShowString)
182 {
183 /* Still display the \n */
184 static LPCWSTR newLine = L"\n";
188 newLine,
189 wcslen(newLine),
190 &result,
191 NULL);
192 }
193 return TRUE;
194}
195
196static INT
198 IN OUT PGINA_CONTEXT pgContext)
199{
200 WCHAR UserName[256];
201 WCHAR Password[256];
204
205 TRACE("TUILoggedOutSAS()\n");
206
207 /* Ask the user for credentials */
208 if (!ReadString(IDS_ASKFORUSER, UserName, _countof(UserName), TRUE))
209 return WLX_SAS_ACTION_NONE;
211 return WLX_SAS_ACTION_NONE;
212
213 Status = DoLoginTasks(pgContext, UserName, NULL, Password, &SubStatus);
214 if (Status == STATUS_SUCCESS)
215 {
216 if (CreateProfile(pgContext, UserName, NULL, Password))
218 }
219
220 return WLX_SAS_ACTION_NONE;
221}
222
223static INT
225 IN OUT PGINA_CONTEXT pgContext)
226{
227 HANDLE hToken;
228 WCHAR UserName[256];
229 WCHAR Password[256];
232
233 TRACE("TUILockedSAS()\n");
234
235 UNREFERENCED_PARAMETER(pgContext);
236
239
240 /* Ask the user for credentials */
241 if (!ReadString(IDS_ASKFORUSER, UserName, _countof(UserName), TRUE))
242 return WLX_SAS_ACTION_NONE;
244 return WLX_SAS_ACTION_NONE;
245
246 Status = ConnectToLsa(pgContext);
247 if (!NT_SUCCESS(Status))
248 {
249 WARN("ConnectToLsa() failed\n");
250 return WLX_SAS_ACTION_NONE;
251 }
252
253 Status = MyLogonUser(pgContext->LsaHandle,
254 pgContext->AuthenticationPackage,
255 UserName,
256 NULL,
257 Password,
258 &hToken,
259 &SubStatus);
260 if (!NT_SUCCESS(Status))
261 {
262 WARN("MyLogonUser() failed\n");
263 return WLX_SAS_ACTION_NONE;
264 }
265
266 CloseHandle(hToken);
268}
269
270static VOID
272 IN OUT PGINA_CONTEXT pgContext)
273{
274}
275
285};
LONG NTSTATUS
Definition: precomp.h:26
BOOL WINAPI FlushConsoleInputBuffer(IN HANDLE hConsoleInput)
Definition: console.c:220
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:203
BOOL WINAPI AllocConsole(VOID)
Definition: console.c:74
#define FIXME(fmt,...)
Definition: debug.h:114
#define WARN(fmt,...)
Definition: debug.h:115
Definition: bufpool.h:45
static HINSTANCE hDllInstance
Definition: clb.c:30
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define CloseHandle
Definition: compat.h:739
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleMode(HANDLE hConsoleHandle, DWORD dwMode)
Definition: console.c:1606
BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleW(IN HANDLE hConsoleOutput, IN CONST VOID *lpBuffer, IN DWORD nNumberOfCharsToWrite, OUT LPDWORD lpNumberOfCharsWritten, LPVOID lpReserved)
Definition: readwrite.c:1447
BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleW(IN HANDLE hConsoleInput, OUT LPVOID lpBuffer, IN DWORD nNumberOfCharsToRead, OUT LPDWORD lpNumberOfCharsRead, IN PCONSOLE_READCONSOLE_CONTROL pInputControl OPTIONAL)
Definition: readwrite.c:1174
NTSTATUS MyLogonUser(HANDLE LsaHandle, ULONG AuthenticationPackage, LPWSTR lpszUsername, LPWSTR lpszDomain, LPWSTR lpszPassword, PHANDLE phToken, PNTSTATUS SubStatus)
Definition: lsa.c:55
NTSTATUS ConnectToLsa(PGINA_CONTEXT pgContext)
Definition: lsa.c:11
#define IDS_PRESSCTRLALTDELETE
Definition: resource.h:90
#define IDS_ASKFORPASSWORD
Definition: resource.h:92
#define IDS_ASKFORUSER
Definition: resource.h:91
#define IDS_LOGGEDOUTSAS
Definition: resource.h:88
static BOOL TUIDisplayStatusMessage(IN PGINA_CONTEXT pgContext, IN HDESK hDesktop, IN DWORD dwOptions, IN PWSTR pTitle, IN PWSTR pMessage)
Definition: tui.c:22
static INT TUILoggedOutSAS(IN OUT PGINA_CONTEXT pgContext)
Definition: tui.c:197
static VOID TUIDisplaySASNotice(IN OUT PGINA_CONTEXT pgContext)
Definition: tui.c:96
static VOID TUIDisplayLockedNotice(IN OUT PGINA_CONTEXT pgContext)
Definition: tui.c:271
static INT TUILockedSAS(IN OUT PGINA_CONTEXT pgContext)
Definition: tui.c:224
static BOOL ReadString(IN UINT uIdResourcePrompt, IN OUT PWSTR Buffer, IN DWORD BufferLength, IN BOOL ShowString)
Definition: tui.c:127
static INT TUILoggedOnSAS(IN OUT PGINA_CONTEXT pgContext, IN DWORD dwSasType)
Definition: tui.c:108
static BOOL TUIInitialize(IN OUT PGINA_CONTEXT pgContext)
Definition: tui.c:13
GINA_UI GinaTextUI
Definition: tui.c:276
static BOOL TUIRemoveStatusMessage(IN PGINA_CONTEXT pgContext)
Definition: tui.c:55
static BOOL DisplayResourceText(IN UINT uIdResourceText, IN BOOL AddNewLine)
Definition: tui.c:65
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
Status
Definition: gdiplustypes.h:25
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint64EXT * result
Definition: glext.h:11304
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
BOOL CreateProfile(IN OUT PGINA_CONTEXT pgContext, IN PWSTR UserName, IN PWSTR Domain, IN PWSTR Password)
Definition: msgina.c:785
NTSTATUS DoLoginTasks(IN OUT PGINA_CONTEXT pgContext, IN PWSTR UserName, IN PWSTR Domain, IN PWSTR Password, OUT PNTSTATUS SubStatus)
Definition: msgina.c:752
unsigned int UINT
Definition: ndis.h:50
#define UNICODE_NULL
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_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 L(x)
Definition: ntvdm.h:50
#define STATUS_SUCCESS
Definition: shellext.h:65
#define _countof(array)
Definition: sndvol32.h:70
#define TRACE(s)
Definition: solgame.cpp:4
DWORD dwOptions
Definition: solitaire.cpp:25
@ Password
Definition: telnetd.h:65
uint16_t * PWSTR
Definition: typedefs.h:56
int32_t INT
Definition: typedefs.h:58
#define IN
Definition: typedefs.h:39
#define OUT
Definition: typedefs.h:40
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771
#define STD_OUTPUT_HANDLE
Definition: winbase.h:268
#define STD_INPUT_HANDLE
Definition: winbase.h:267
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define WLX_SAS_ACTION_NONE
Definition: winwlx.h:54
#define WLX_SAS_ACTION_UNLOCK_WKSTA
Definition: winwlx.h:60
#define WLX_SAS_TYPE_CTRL_ALT_DEL
Definition: winwlx.h:36
#define WLX_SAS_ACTION_LOGON
Definition: winwlx.h:53
#define WLX_SAS_ACTION_LOGOFF
Definition: winwlx.h:56
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185