ReactOS 0.4.16-dev-292-gbbdcc14
frontendctl.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Console Server DLL
4 * FILE: win32ss/user/winsrv/consrv/frontendctl.c
5 * PURPOSE: Terminal Front-Ends Control
6 * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca@sfr.fr)
7 */
8
9/* INCLUDES *******************************************************************/
10
11#include "consrv.h"
12
13#define NDEBUG
14#include <debug.h>
15
16/* PUBLIC SERVER APIS *********************************************************/
17
18/**********************************************************************
19 * HardwareStateProperty
20 *
21 * DESCRIPTION
22 * Set/Get the value of the HardwareState and switch
23 * between direct video buffer ouput and GDI windowed
24 * output.
25 * ARGUMENTS
26 * Client hands us a CONSOLE_GETSETHWSTATE object.
27 * We use the same object to Request.
28 * NOTE
29 * ConsoleHwState has the correct size to be compatible
30 * with NT's, but values are not.
31 */
32#if 0
33static NTSTATUS
35{
36 DPRINT1("Console Hardware State: %d\n", ConsoleHwState);
37
38 if ((CONSOLE_HARDWARE_STATE_GDI_MANAGED == ConsoleHwState)
39 ||(CONSOLE_HARDWARE_STATE_DIRECT == ConsoleHwState))
40 {
41 if (Console->HardwareState != ConsoleHwState)
42 {
43 /* TODO: implement switching from full screen to windowed mode */
44 /* TODO: or back; now simply store the hardware state */
45 Console->HardwareState = ConsoleHwState;
46 }
47
48 return STATUS_SUCCESS;
49 }
50
51 return STATUS_INVALID_PARAMETER_3; /* Client: (handle, set_get, [mode]) */
52}
53#endif
54
55/* API_NUMBER: ConsolepGetHardwareState */
56CON_API(SrvGetConsoleHardwareState,
57 CONSOLE_GETSETHWSTATE, HardwareStateRequest)
58{
59#if 0
62
63 Status = ConSrvGetTextModeBuffer(ProcessData,
64 HardwareStateRequest->OutputHandle,
65 &Buff,
67 TRUE);
68 if (!NT_SUCCESS(Status))
69 return Status;
70
72
73 HardwareStateRequest->State = Console->HardwareState;
74
76 return STATUS_SUCCESS;
77#else
80#endif
81}
82
83/* API_NUMBER: ConsolepSetHardwareState */
84CON_API(SrvSetConsoleHardwareState,
85 CONSOLE_GETSETHWSTATE, HardwareStateRequest)
86{
87#if 0
90
91 Status = ConSrvGetTextModeBuffer(ProcessData,
92 HardwareStateRequest->OutputHandle,
93 &Buff,
95 TRUE);
96 if (!NT_SUCCESS(Status))
97 return Status;
98
100
101 DPRINT("Setting console hardware state.\n");
102 Status = SetConsoleHardwareState(Console, HardwareStateRequest->State);
103
105 return STATUS_SUCCESS;
106#else
109#endif
110}
111
112/* API_NUMBER: ConsolepGetDisplayMode */
113CON_API(SrvGetConsoleDisplayMode,
114 CONSOLE_GETDISPLAYMODE, GetDisplayModeRequest)
115{
116 GetDisplayModeRequest->DisplayMode = TermGetDisplayMode(Console);
117 return STATUS_SUCCESS;
118}
119
120/* API_NUMBER: ConsolepSetDisplayMode */
121CON_API(SrvSetConsoleDisplayMode,
122 CONSOLE_SETDISPLAYMODE, SetDisplayModeRequest)
123{
126
127 Status = ConSrvGetScreenBuffer(ProcessData,
128 SetDisplayModeRequest->OutputHandle,
129 &Buff,
131 TRUE);
132 if (!NT_SUCCESS(Status))
133 return Status;
134
136
137 if (TermSetDisplayMode(Console, SetDisplayModeRequest->DisplayMode))
138 {
139 SetDisplayModeRequest->NewSBDim = Buff->ScreenBufferSize;
141 }
142 else
143 {
145 }
146
148 return Status;
149}
150
151/* API_NUMBER: ConsolepGetLargestWindowSize */
152CON_API(SrvGetLargestConsoleWindowSize,
153 CONSOLE_GETLARGESTWINDOWSIZE, GetLargestWindowSizeRequest)
154{
157
158 Status = ConSrvGetTextModeBuffer(ProcessData,
159 GetLargestWindowSizeRequest->OutputHandle,
160 &Buff,
162 TRUE);
163 if (!NT_SUCCESS(Status))
164 return Status;
165
167
168 /*
169 * Retrieve the largest possible console window size, without
170 * taking into account the size of the console screen buffer
171 * (thus differs from ConDrvGetConsoleScreenBufferInfo).
172 */
173 TermGetLargestConsoleWindowSize(Console, &GetLargestWindowSizeRequest->Size);
174
176 return STATUS_SUCCESS;
177}
178
179/* API_NUMBER: ConsolepShowCursor */
180CON_API(SrvShowConsoleCursor,
181 CONSOLE_SHOWCURSOR, ShowCursorRequest)
182{
185
186 Status = ConSrvGetScreenBuffer(ProcessData,
187 ShowCursorRequest->OutputHandle,
188 &Buff,
190 TRUE);
191 if (!NT_SUCCESS(Status))
192 return Status;
193
195
196 ShowCursorRequest->RefCount = TermShowMouseCursor(Console, ShowCursorRequest->Show);
197
199 return STATUS_SUCCESS;
200}
201
202/* API_NUMBER: ConsolepSetCursor */
203CON_API(SrvSetConsoleCursor,
204 CONSOLE_SETCURSOR, SetCursorRequest)
205{
209
210 // NOTE: Tests show that this function is used only for graphics screen buffers
211 // and otherwise it returns FALSE and sets last error to ERROR_INVALID_HANDLE.
212 // I find that behaviour is ridiculous but ok, let's accept it at the moment...
213 Status = ConSrvGetGraphicsBuffer(ProcessData,
214 SetCursorRequest->OutputHandle,
215 &Buff,
217 TRUE);
218 if (!NT_SUCCESS(Status))
219 return Status;
220
222
223 Success = TermSetMouseCursor(Console, SetCursorRequest->CursorHandle);
224
227}
228
229/* API_NUMBER: ConsolepMenuControl */
230CON_API(SrvConsoleMenuControl,
231 CONSOLE_MENUCONTROL, MenuControlRequest)
232{
235
236 Status = ConSrvGetScreenBuffer(ProcessData,
237 MenuControlRequest->OutputHandle,
238 &Buff,
240 TRUE);
241 if (!NT_SUCCESS(Status))
242 return Status;
243
245
246 MenuControlRequest->MenuHandle = TermMenuControl(Console,
247 MenuControlRequest->CmdIdLow,
248 MenuControlRequest->CmdIdHigh);
249
251 return STATUS_SUCCESS;
252}
253
254/* API_NUMBER: ConsolepSetMenuClose */
255CON_API(SrvSetConsoleMenuClose,
256 CONSOLE_SETMENUCLOSE, SetMenuCloseRequest)
257{
258 return (TermSetMenuClose(Console, SetMenuCloseRequest->Enable)
260}
261
262/* Used by USERSRV!SrvGetThreadConsoleDesktop() */
264NTAPI
266 IN ULONG_PTR ThreadId,
267 OUT HDESK* ConsoleDesktop)
268{
270 PCSR_THREAD CsrThread;
272
273 /* No console desktop handle by default */
274 *ConsoleDesktop = NULL;
275
276 /* Retrieve and lock the thread */
277 Status = CsrLockThreadByClientId(ULongToHandle(ThreadId), &CsrThread);
278 if (!NT_SUCCESS(Status))
279 return Status;
280
281 ASSERT(CsrThread->Process);
282
283 /* Retrieve the console to which the process is attached, and unlock the thread */
285 &Console, TRUE);
286 CsrUnlockThread(CsrThread);
287
288 if (!NT_SUCCESS(Status))
289 return Status;
290
291 /* Retrieve the console desktop handle, and release the console */
292 *ConsoleDesktop = TermGetThreadConsoleDesktop(Console);
294
295 return STATUS_SUCCESS;
296}
297
298/* API_NUMBER: ConsolepGetConsoleWindow */
299CON_API(SrvGetConsoleWindow,
300 CONSOLE_GETWINDOW, GetWindowRequest)
301{
302 GetWindowRequest->WindowHandle = TermGetConsoleWindowHandle(Console);
303 return STATUS_SUCCESS;
304}
305
306/* API_NUMBER: ConsolepSetIcon */
307CON_API(SrvSetConsoleIcon,
308 CONSOLE_SETICON, SetIconRequest)
309{
310 return (TermChangeIcon(Console, SetIconRequest->IconHandle)
312}
313
314/* API_NUMBER: ConsolepGetSelectionInfo */
315CON_API(SrvGetConsoleSelectionInfo,
316 CONSOLE_GETSELECTIONINFO, GetSelectionInfoRequest)
317{
318 return (TermGetSelectionInfo(Console, &GetSelectionInfoRequest->Info)
320}
321
322/* API_NUMBER: ConsolepGetNumberOfFonts */
323CON_API(SrvGetConsoleNumberOfFonts,
324 CONSOLE_GETNUMFONTS, GetNumFontsRequest)
325{
326 // FIXME!
327 // TermGetNumberOfFonts(Console, ...);
328 DPRINT1("%s not yet implemented\n", __FUNCTION__);
329 GetNumFontsRequest->NumFonts = 0;
330 return STATUS_SUCCESS;
331}
332
333/* API_NUMBER: ConsolepGetFontInfo */
334CON_API(SrvGetConsoleFontInfo,
335 CONSOLE_GETFONTINFO, GetFontInfoRequest)
336{
339
340 Status = ConSrvGetTextModeBuffer(ProcessData,
341 GetFontInfoRequest->OutputHandle,
342 &Buff,
344 TRUE);
345 if (!NT_SUCCESS(Status))
346 return Status;
347
349
350 // FIXME!
351 // TermGetFontInfo(Console, ...);
352 DPRINT1("%s not yet implemented\n", __FUNCTION__);
353 GetFontInfoRequest->NumFonts = 0;
354
356 return STATUS_SUCCESS;
357}
358
359/* API_NUMBER: ConsolepGetFontSize */
360CON_API(SrvGetConsoleFontSize,
361 CONSOLE_GETFONTSIZE, GetFontSizeRequest)
362{
365
366 Status = ConSrvGetTextModeBuffer(ProcessData,
367 GetFontSizeRequest->OutputHandle,
368 &Buff,
370 TRUE);
371 if (!NT_SUCCESS(Status))
372 return Status;
373
375
376 // FIXME!
377 // TermGetFontSize(Console, ...);
378 DPRINT1("%s not yet implemented\n", __FUNCTION__);
379
381 return STATUS_SUCCESS;
382}
383
384/* API_NUMBER: ConsolepGetCurrentFont */
385CON_API(SrvGetConsoleCurrentFont,
386 CONSOLE_GETCURRENTFONT, GetCurrentFontRequest)
387{
390
391 Status = ConSrvGetTextModeBuffer(ProcessData,
392 GetCurrentFontRequest->OutputHandle,
393 &Buff,
395 TRUE);
396 if (!NT_SUCCESS(Status))
397 return Status;
398
400
401 // FIXME!
402 // TermGetCurrentFont(Console, ...);
403 DPRINT1("%s not yet implemented\n", __FUNCTION__);
404 GetCurrentFontRequest->FontIndex = 0;
405
407 return STATUS_SUCCESS;
408}
409
410/* API_NUMBER: ConsolepSetFont */
411CON_API(SrvSetConsoleFont,
412 CONSOLE_SETFONT, SetFontRequest)
413{
416
417 Status = ConSrvGetTextModeBuffer(ProcessData,
418 SetFontRequest->OutputHandle,
419 &Buff,
421 TRUE);
422 if (!NT_SUCCESS(Status))
423 return Status;
424
426
427 // FIXME!
428 // TermSetFont(Console, ...);
429 DPRINT1("%s not yet implemented\n", __FUNCTION__);
430
432 return STATUS_SUCCESS;
433}
434
435/* EOF */
CConsole Console
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#define ULongToHandle(h)
Definition: basetsd.h:81
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
#define CONSOLE_HARDWARE_STATE_DIRECT
Definition: conmsg.h:392
#define CONSOLE_HARDWARE_STATE_GDI_MANAGED
Definition: conmsg.h:391
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define ConSrvGetScreenBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:26
#define ConSrvGetGraphicsBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:19
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
NTSTATUS NTAPI CsrLockThreadByClientId(IN HANDLE Tid, OUT PCSR_THREAD *CsrThread)
Definition: thredsup.c:965
NTSTATUS NTAPI CsrUnlockThread(IN PCSR_THREAD CsrThread)
Definition: thredsup.c:1075
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define GENERIC_READ
Definition: compat.h:135
BOOL WINAPI SetConsoleHardwareState(HANDLE hConsoleOutput, DWORD Flags, DWORD State)
Definition: console.c:944
#define __FUNCTION__
Definition: types.h:116
@ Success
Definition: eventcreate.c:712
unsigned int BOOL
Definition: ntddk_ex.h:94
NTSTATUS NTAPI GetThreadConsoleDesktop(IN ULONG_PTR ThreadId, OUT HDESK *ConsoleDesktop)
Definition: frontendctl.c:265
Status
Definition: gdiplustypes.h:25
#define ASSERT(a)
Definition: mode.c:44
#define GENERIC_WRITE
Definition: nt_native.h:90
#define STATUS_INVALID_PARAMETER_3
Definition: ntstatus.h:477
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
struct _CONSOLE * Console
Definition: conio.h:36
CONSOLE_IO_OBJECT Header
Definition: conio.h:58
COORD ScreenBufferSize
Definition: conio.h:62
PCSR_PROCESS Process
Definition: csrsrv.h:69
#define TermMenuControl(Console, CmdIdLow, CmdIdHigh)
Definition: term.h:64
#define TermGetConsoleWindowHandle(Console)
Definition: term.h:54
#define TermGetLargestConsoleWindowSize(Console, pSize)
Definition: term.h:34
#define TermShowMouseCursor(Console, Show)
Definition: term.h:40
#define TermChangeIcon(Console, IconHandle)
Definition: term.h:50
#define TermSetDisplayMode(Console, NewMode)
Definition: term.h:60
#define TermSetMouseCursor(Console, CursorHandle)
Definition: term.h:62
#define TermGetSelectionInfo(Console, pSelectionInfo)
Definition: term.h:56
#define TermSetMenuClose(Console, Enable)
Definition: term.h:66
#define TermGetThreadConsoleDesktop(Console)
Definition: term.h:52
#define TermGetDisplayMode(Console)
Definition: term.h:58
#define NTAPI
Definition: typedefs.h:36
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define CON_API(Name, TYPE, RequestName)
Definition: api.h:80
VOID ConSrvReleaseConsole(IN PCONSRV_CONSOLE Console, IN BOOLEAN IsConsoleLocked)
Definition: console.c:316
NTSTATUS ConSrvGetConsole(IN PCONSOLE_PROCESS_DATA ProcessData, OUT PCONSRV_CONSOLE *Console, IN BOOLEAN LockConsole)
Definition: console.c:291