ReactOS 0.4.16-dev-91-g764881a
tui.c File Reference
#include "msgina.h"
#include <wincon.h>
Include dependency graph for tui.c:

Go to the source code of this file.

Functions

static BOOL TUIInitialize (IN OUT PGINA_CONTEXT pgContext)
 
static BOOL TUIDisplayStatusMessage (IN PGINA_CONTEXT pgContext, IN HDESK hDesktop, IN DWORD dwOptions, IN PWSTR pTitle, IN PWSTR pMessage)
 
static BOOL TUIRemoveStatusMessage (IN PGINA_CONTEXT pgContext)
 
static BOOL DisplayResourceText (IN UINT uIdResourceText, IN BOOL AddNewLine)
 
static VOID TUIDisplaySASNotice (IN OUT PGINA_CONTEXT pgContext)
 
static INT TUILoggedOnSAS (IN OUT PGINA_CONTEXT pgContext, IN DWORD dwSasType)
 
static BOOL ReadString (IN UINT uIdResourcePrompt, IN OUT PWSTR Buffer, IN DWORD BufferLength, IN BOOL ShowString)
 
static INT TUILoggedOutSAS (IN OUT PGINA_CONTEXT pgContext)
 
static INT TUILockedSAS (IN OUT PGINA_CONTEXT pgContext)
 
static VOID TUIDisplayLockedNotice (IN OUT PGINA_CONTEXT pgContext)
 

Variables

GINA_UI GinaTextUI
 

Function Documentation

◆ DisplayResourceText()

static BOOL DisplayResourceText ( IN UINT  uIdResourceText,
IN BOOL  AddNewLine 
)
static

Definition at line 65 of file tui.c.

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}
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:203
static HINSTANCE hDllInstance
Definition: clb.c:9
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleW(IN HANDLE hConsoleOutput, IN CONST VOID *lpBuffer, IN DWORD nNumberOfCharsToWrite, OUT LPDWORD lpNumberOfCharsWritten, LPVOID lpReserved)
Definition: readwrite.c:1447
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei count
Definition: gl.h:1545
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define L(x)
Definition: ntvdm.h:50
#define _countof(array)
Definition: sndvol32.h:70
#define STD_OUTPUT_HANDLE
Definition: winbase.h:268
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by ReadString(), TUIDisplaySASNotice(), and TUILockedSAS().

◆ ReadString()

static BOOL ReadString ( IN UINT  uIdResourcePrompt,
IN OUT PWSTR  Buffer,
IN DWORD  BufferLength,
IN BOOL  ShowString 
)
static

Definition at line 127 of file tui.c.

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}
BOOL WINAPI FlushConsoleInputBuffer(IN HANDLE hConsoleInput)
Definition: console.c:220
Definition: bufpool.h:45
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleMode(HANDLE hConsoleHandle, DWORD dwMode)
Definition: console.c:1606
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
static BOOL DisplayResourceText(IN UINT uIdResourceText, IN BOOL AddNewLine)
Definition: tui.c:65
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
#define UNICODE_NULL
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771
#define STD_INPUT_HANDLE
Definition: winbase.h:267

Referenced by TUILockedSAS(), and TUILoggedOutSAS().

◆ TUIDisplayLockedNotice()

static VOID TUIDisplayLockedNotice ( IN OUT PGINA_CONTEXT  pgContext)
static

Definition at line 271 of file tui.c.

273{
274}

◆ TUIDisplaySASNotice()

static VOID TUIDisplaySASNotice ( IN OUT PGINA_CONTEXT  pgContext)
static

Definition at line 96 of file tui.c.

98{
99 TRACE("TUIDisplaySASNotice()\n");
100
101 UNREFERENCED_PARAMETER(pgContext);
102
105}
#define IDS_PRESSCTRLALTDELETE
Definition: resource.h:90
#define IDS_LOGGEDOUTSAS
Definition: resource.h:88
#define TRACE(s)
Definition: solgame.cpp:4

◆ TUIDisplayStatusMessage()

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

Definition at line 22 of file tui.c.

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}
DWORD dwOptions
Definition: solitaire.cpp:25

◆ TUIInitialize()

static BOOL TUIInitialize ( IN OUT PGINA_CONTEXT  pgContext)
static

Definition at line 13 of file tui.c.

15{
16 TRACE("TUIInitialize(%p)\n", pgContext);
17
18 return AllocConsole();
19}
BOOL WINAPI AllocConsole(VOID)
Definition: console.c:74

◆ TUILockedSAS()

static INT TUILockedSAS ( IN OUT PGINA_CONTEXT  pgContext)
static

Definition at line 224 of file tui.c.

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}
LONG NTSTATUS
Definition: precomp.h:26
#define WARN(fmt,...)
Definition: precomp.h:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define CloseHandle
Definition: compat.h:739
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_ASKFORPASSWORD
Definition: resource.h:92
#define IDS_ASKFORUSER
Definition: resource.h:91
static BOOL ReadString(IN UINT uIdResourcePrompt, IN OUT PWSTR Buffer, IN DWORD BufferLength, IN BOOL ShowString)
Definition: tui.c:127
Status
Definition: gdiplustypes.h:25
_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
@ Password
Definition: telnetd.h:65
#define WLX_SAS_ACTION_NONE
Definition: winwlx.h:54
#define WLX_SAS_ACTION_UNLOCK_WKSTA
Definition: winwlx.h:60

◆ TUILoggedOnSAS()

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

Definition at line 108 of file tui.c.

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}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WLX_SAS_TYPE_CTRL_ALT_DEL
Definition: winwlx.h:36
#define WLX_SAS_ACTION_LOGOFF
Definition: winwlx.h:56

◆ TUILoggedOutSAS()

static INT TUILoggedOutSAS ( IN OUT PGINA_CONTEXT  pgContext)
static

Definition at line 197 of file tui.c.

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}
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
#define STATUS_SUCCESS
Definition: shellext.h:65
#define WLX_SAS_ACTION_LOGON
Definition: winwlx.h:53

◆ TUIRemoveStatusMessage()

static BOOL TUIRemoveStatusMessage ( IN PGINA_CONTEXT  pgContext)
static

Definition at line 55 of file tui.c.

57{
58 UNREFERENCED_PARAMETER(pgContext);
59
60 /* Nothing to do */
61 return TRUE;
62}

Variable Documentation

◆ GinaTextUI

GINA_UI GinaTextUI
Initial value:
= {
}
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 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
static BOOL TUIRemoveStatusMessage(IN PGINA_CONTEXT pgContext)
Definition: tui.c:55

Definition at line 276 of file tui.c.

Referenced by ChooseGinaUI().