2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Console Server DLL
4 * FILE: win32ss/user/winsrv/consrv/frontends/tui/tuiterm.c
5 * PURPOSE: TUI Terminal Front-End - Virtual Consoles...
6 * PROGRAMMERS: David Welch
9 * Hermes Belusca-Maito (hermes.belusca@sfr.fr)
12 #ifdef TUITERM_COMPILE
15 #include "include/conio.h"
16 #include "include/console.h"
17 #include "include/settings.h"
19 #include <drivers/blue/ntddblue.h>
25 /* GLOBALS ********************************************************************/
27 #define GetNextConsole(Console) \
28 CONTAINING_RECORD(Console->Entry.Flink, TUI_CONSOLE_DATA, Entry)
30 #define GetPrevConsole(Console) \
31 CONTAINING_RECORD(Console->Entry.Blink, TUI_CONSOLE_DATA, Entry)
34 /* TUI Console Window Class name */
35 #define TUI_CONSOLE_WINDOW_CLASS L"TuiConsoleWindowClass"
37 typedef struct _TUI_CONSOLE_DATA
39 CRITICAL_SECTION Lock
;
40 LIST_ENTRY Entry
; /* Entry in the list of virtual consoles */
41 // HANDLE hTuiInitEvent;
43 HWND hWindow
; /* Handle to the console's window (used for the window's procedure */
45 PCONSOLE Console
; /* Pointer to the owned console */
46 // TUI_CONSOLE_INFO TuiInfo; /* TUI terminal settings */
47 } TUI_CONSOLE_DATA
, *PTUI_CONSOLE_DATA
;
49 /* List of the maintained virtual consoles and its lock */
50 static LIST_ENTRY VirtConsList
;
51 static PTUI_CONSOLE_DATA ActiveConsole
; /* The active console on screen */
52 static CRITICAL_SECTION ActiveVirtConsLock
;
54 static COORD PhysicalConsoleSize
;
55 static HANDLE ConsoleDeviceHandle
;
57 static BOOL ConsInitialized
= FALSE
;
59 /******************************************************************************\
60 |** BlueScreen Driver management **|
62 /* Code taken and adapted from base/system/services/driver.c */
64 ScmLoadDriver(LPCWSTR lpServiceName
)
66 NTSTATUS Status
= STATUS_SUCCESS
;
67 BOOLEAN WasPrivilegeEnabled
= FALSE
;
69 UNICODE_STRING DriverPath
;
71 /* Build the driver path */
72 /* 52 = wcslen(L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\") */
73 pszDriverPath
= ConsoleAllocHeap(HEAP_ZERO_MEMORY
,
74 (52 + wcslen(lpServiceName
) + 1) * sizeof(WCHAR
));
75 if (pszDriverPath
== NULL
)
76 return ERROR_NOT_ENOUGH_MEMORY
;
79 L
"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\");
83 RtlInitUnicodeString(&DriverPath
,
86 DPRINT(" Path: %wZ\n", &DriverPath
);
88 /* Acquire driver-loading privilege */
89 Status
= RtlAdjustPrivilege(SE_LOAD_DRIVER_PRIVILEGE
,
92 &WasPrivilegeEnabled
);
93 if (!NT_SUCCESS(Status
))
95 /* We encountered a failure, exit properly */
96 DPRINT1("CONSRV: Cannot acquire driver-loading privilege, Status = 0x%08lx\n", Status
);
100 Status
= NtLoadDriver(&DriverPath
);
102 /* Release driver-loading privilege */
103 RtlAdjustPrivilege(SE_LOAD_DRIVER_PRIVILEGE
,
106 &WasPrivilegeEnabled
);
109 ConsoleFreeHeap(pszDriverPath
);
110 return RtlNtStatusToDosError(Status
);
113 #ifdef BLUESCREEN_DRIVER_UNLOADING
115 ScmUnloadDriver(LPCWSTR lpServiceName
)
117 NTSTATUS Status
= STATUS_SUCCESS
;
118 BOOLEAN WasPrivilegeEnabled
= FALSE
;
120 UNICODE_STRING DriverPath
;
122 /* Build the driver path */
123 /* 52 = wcslen(L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\") */
124 pszDriverPath
= ConsoleAllocHeap(HEAP_ZERO_MEMORY
,
125 (52 + wcslen(lpServiceName
) + 1) * sizeof(WCHAR
));
126 if (pszDriverPath
== NULL
)
127 return ERROR_NOT_ENOUGH_MEMORY
;
129 wcscpy(pszDriverPath
,
130 L
"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\");
131 wcscat(pszDriverPath
,
134 RtlInitUnicodeString(&DriverPath
,
137 DPRINT(" Path: %wZ\n", &DriverPath
);
139 /* Acquire driver-unloading privilege */
140 Status
= RtlAdjustPrivilege(SE_LOAD_DRIVER_PRIVILEGE
,
143 &WasPrivilegeEnabled
);
144 if (!NT_SUCCESS(Status
))
146 /* We encountered a failure, exit properly */
147 DPRINT1("CONSRV: Cannot acquire driver-unloading privilege, Status = 0x%08lx\n", Status
);
151 Status
= NtUnloadDriver(&DriverPath
);
153 /* Release driver-unloading privilege */
154 RtlAdjustPrivilege(SE_LOAD_DRIVER_PRIVILEGE
,
157 &WasPrivilegeEnabled
);
160 ConsoleFreeHeap(pszDriverPath
);
161 return RtlNtStatusToDosError(Status
);
165 \******************************************************************************/
168 TuiSwapConsole(INT Next
)
170 static PTUI_CONSOLE_DATA SwapConsole
= NULL
; /* Console we are thinking about swapping with */
179 * Alt-Tab, swap consoles.
180 * move SwapConsole to next console, and print its title.
182 EnterCriticalSection(&ActiveVirtConsLock
);
183 if (!SwapConsole
) SwapConsole
= ActiveConsole
;
185 SwapConsole
= (0 < Next
? GetNextConsole(SwapConsole
) : GetPrevConsole(SwapConsole
));
186 Title
.MaximumLength
= RtlUnicodeStringToAnsiSize(&SwapConsole
->Console
->Title
);
188 Buffer
= ConsoleAllocHeap(0, sizeof(COORD
) + Title
.MaximumLength
);
189 pos
= (PCOORD
)Buffer
;
190 Title
.Buffer
= (PVOID
)((ULONG_PTR
)Buffer
+ sizeof(COORD
));
192 RtlUnicodeStringToAnsiString(&Title
, &SwapConsole
->Console
->Title
, FALSE
);
193 pos
->X
= (PhysicalConsoleSize
.X
- Title
.Length
) / 2;
194 pos
->Y
= PhysicalConsoleSize
.Y
/ 2;
195 /* Redraw the console to clear off old title */
196 ConioDrawConsole(ActiveConsole
->Console
);
197 if (!DeviceIoControl(ConsoleDeviceHandle
, IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER
,
198 NULL
, 0, Buffer
, sizeof(COORD
) + Title
.Length
,
199 &BytesReturned
, NULL
))
201 DPRINT1( "Error writing to console\n" );
203 ConsoleFreeHeap(Buffer
);
204 LeaveCriticalSection(&ActiveVirtConsLock
);
208 else if (NULL
!= SwapConsole
)
210 EnterCriticalSection(&ActiveVirtConsLock
);
211 if (SwapConsole
!= ActiveConsole
)
213 /* First remove swapconsole from the list */
214 SwapConsole
->Entry
.Blink
->Flink
= SwapConsole
->Entry
.Flink
;
215 SwapConsole
->Entry
.Flink
->Blink
= SwapConsole
->Entry
.Blink
;
216 /* Now insert before activeconsole */
217 SwapConsole
->Entry
.Flink
= &ActiveConsole
->Entry
;
218 SwapConsole
->Entry
.Blink
= ActiveConsole
->Entry
.Blink
;
219 ActiveConsole
->Entry
.Blink
->Flink
= &SwapConsole
->Entry
;
220 ActiveConsole
->Entry
.Blink
= &SwapConsole
->Entry
;
222 ActiveConsole
= SwapConsole
;
224 ConioDrawConsole(ActiveConsole
->Console
);
225 LeaveCriticalSection(&ActiveVirtConsLock
);
235 TuiCopyRect(PCHAR Dest
, PTEXTMODE_SCREEN_BUFFER Buff
, SMALL_RECT
* Region
)
237 UINT SrcDelta
, DestDelta
;
239 PCHAR_INFO Src
, SrcEnd
;
241 Src
= ConioCoordToPointer(Buff
, Region
->Left
, Region
->Top
);
242 SrcDelta
= Buff
->ScreenBufferSize
.X
* sizeof(CHAR_INFO
);
243 SrcEnd
= Buff
->Buffer
+ Buff
->ScreenBufferSize
.Y
* Buff
->ScreenBufferSize
.X
* sizeof(CHAR_INFO
);
244 DestDelta
= ConioRectWidth(Region
) * 2 /* 2 == sizeof(CHAR) + sizeof(BYTE) */;
245 for (i
= Region
->Top
; i
<= Region
->Bottom
; i
++)
247 ConsoleUnicodeCharToAnsiChar(Buff
->Header
.Console
, (PCHAR
)Dest
, &Src
->Char
.UnicodeChar
);
248 *(PBYTE
)(Dest
+ 1) = (BYTE
)Src
->Attributes
;
253 Src
-= Buff
->ScreenBufferSize
.Y
* Buff
->ScreenBufferSize
.X
* sizeof(CHAR_INFO
);
259 static LRESULT CALLBACK
260 TuiConsoleWndProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
263 PTUI_CONSOLE_DATA TuiData = NULL;
264 PCONSOLE Console = NULL;
266 TuiData = TuiGetGuiData(hWnd);
267 if (TuiData == NULL) return 0;
279 if (ConDrvValidateConsoleUnsafe(ActiveConsole
->Console
, CONSOLE_RUNNING
, TRUE
))
283 Message
.message
= msg
;
284 Message
.wParam
= wParam
;
285 Message
.lParam
= lParam
;
287 ConioProcessKey(ActiveConsole
->Console
, &Message
);
288 LeaveCriticalSection(&ActiveConsole
->Console
->Lock
);
295 if (ConDrvValidateConsoleUnsafe(ActiveConsole
->Console
, CONSOLE_RUNNING
, TRUE
))
297 if (LOWORD(wParam
) != WA_INACTIVE
)
300 ConioDrawConsole(ActiveConsole
->Console
);
302 LeaveCriticalSection(&ActiveConsole
->Console
->Lock
);
311 return DefWindowProcW(hWnd
, msg
, wParam
, lParam
);
315 TuiConsoleThread(PVOID Data
)
317 PTUI_CONSOLE_DATA TuiData
= (PTUI_CONSOLE_DATA
)Data
;
318 PCONSOLE Console
= TuiData
->Console
;
322 NewWindow
= CreateWindowW(TUI_CONSOLE_WINDOW_CLASS
,
323 Console
->Title
.Buffer
,
325 -32000, -32000, 0, 0,
329 if (NULL
== NewWindow
)
331 DPRINT1("CONSRV: Unable to create console window\n");
334 TuiData
->hWindow
= NewWindow
;
336 SetForegroundWindow(TuiData
->hWindow
);
337 NtUserConsoleControl(ConsoleAcquireDisplayOwnership
, NULL
, 0);
339 while (GetMessageW(&msg
, NULL
, 0, 0))
341 TranslateMessage(&msg
);
342 DispatchMessageW(&msg
);
352 CONSOLE_SCREEN_BUFFER_INFO ScrInfo
;
355 ATOM ConsoleClassAtom
;
356 USHORT TextAttribute
= FOREGROUND_BLUE
| FOREGROUND_GREEN
| FOREGROUND_RED
;
358 /* Exit if we were already initialized */
359 if (ConsInitialized
) return TRUE
;
362 * Initialize the TUI front-end:
363 * - load the console driver,
364 * - set default screen attributes,
365 * - grab the console size.
367 ScmLoadDriver(L
"Blue");
369 ConsoleDeviceHandle
= CreateFileW(L
"\\\\.\\BlueScreen",
374 if (INVALID_HANDLE_VALUE
== ConsoleDeviceHandle
)
376 DPRINT1("Failed to open BlueScreen.\n");
380 if (!DeviceIoControl(ConsoleDeviceHandle
, IOCTL_CONSOLE_LOADFONT
,
381 &OemCP
, sizeof(OemCP
), NULL
, 0,
382 &BytesReturned
, NULL
))
384 DPRINT1("Failed to load the font for codepage %d\n", OemCP
);
385 /* Let's suppose the font is good enough to continue */
388 if (!DeviceIoControl(ConsoleDeviceHandle
, IOCTL_CONSOLE_SET_TEXT_ATTRIBUTE
,
389 &TextAttribute
, sizeof(TextAttribute
), NULL
, 0,
390 &BytesReturned
, NULL
))
392 DPRINT1("Failed to set text attribute\n");
395 ActiveConsole
= NULL
;
396 InitializeListHead(&VirtConsList
);
397 InitializeCriticalSection(&ActiveVirtConsLock
);
399 if (!DeviceIoControl(ConsoleDeviceHandle
, IOCTL_CONSOLE_GET_SCREEN_BUFFER_INFO
,
400 NULL
, 0, &ScrInfo
, sizeof(ScrInfo
), &BytesReturned
, NULL
))
402 DPRINT1("Failed to get console info\n");
406 PhysicalConsoleSize
= ScrInfo
.dwSize
;
408 /* Register the TUI notification window class */
409 RtlZeroMemory(&wc
, sizeof(WNDCLASSEXW
));
410 wc
.cbSize
= sizeof(WNDCLASSEXW
);
411 wc
.lpszClassName
= TUI_CONSOLE_WINDOW_CLASS
;
412 wc
.lpfnWndProc
= TuiConsoleWndProc
;
414 wc
.hInstance
= ConSrvDllInstance
;
416 ConsoleClassAtom
= RegisterClassExW(&wc
);
417 if (ConsoleClassAtom
== 0)
419 DPRINT1("Failed to register TUI console wndproc\n");
430 DeleteCriticalSection(&ActiveVirtConsLock
);
431 CloseHandle(ConsoleDeviceHandle
);
434 ConsInitialized
= Ret
;
440 /******************************************************************************
441 * TUI Console Driver *
442 ******************************************************************************/
445 TuiDeinitFrontEnd(IN OUT PFRONTEND This
/*,
446 IN PCONSOLE Console */);
449 TuiInitFrontEnd(IN OUT PFRONTEND This
,
452 PTUI_CONSOLE_DATA TuiData
;
455 if (This
== NULL
|| Console
== NULL
)
456 return STATUS_INVALID_PARAMETER
;
458 // if (GetType(Console->ActiveBuffer) != TEXTMODE_BUFFER)
459 // return STATUS_INVALID_PARAMETER;
461 // /* Initialize the console */
462 // Console->FrontEndIFace.Vtbl = &TuiVtbl;
464 TuiData
= ConsoleAllocHeap(HEAP_ZERO_MEMORY
, sizeof(TUI_CONSOLE_DATA
));
467 DPRINT1("CONSRV: Failed to create TUI_CONSOLE_DATA\n");
468 return STATUS_UNSUCCESSFUL
;
470 // Console->FrontEndIFace.Data = (PVOID)TuiData;
471 TuiData
->Console
= Console
;
472 TuiData
->hWindow
= NULL
;
474 InitializeCriticalSection(&TuiData
->Lock
);
477 * HACK: Resize the console since we don't support for now changing
478 * the console size when we display it with the hardware.
480 // Console->ConsoleSize = PhysicalConsoleSize;
481 // ConioResizeBuffer(Console, (PTEXTMODE_SCREEN_BUFFER)(Console->ActiveBuffer), PhysicalConsoleSize);
483 // /* The console cannot be resized anymore */
484 // Console->FixedSize = TRUE; // MUST be placed AFTER the call to ConioResizeBuffer !!
485 // // TermResizeTerminal(Console);
488 * Contrary to what we do in the GUI front-end, here we create
489 * an input thread for each console. It will dispatch all the
490 * input messages to the proper console (on the GUI it is done
491 * via the default GUI dispatch thread).
493 ThreadHandle
= CreateThread(NULL
,
499 if (NULL
== ThreadHandle
)
501 DPRINT1("CONSRV: Unable to create console thread\n");
502 // TuiDeinitFrontEnd(Console);
503 TuiDeinitFrontEnd(This
);
504 return STATUS_UNSUCCESSFUL
;
506 CloseHandle(ThreadHandle
);
509 * Insert the newly created console in the list of virtual consoles
510 * and activate it (give it the focus).
512 EnterCriticalSection(&ActiveVirtConsLock
);
513 InsertTailList(&VirtConsList
, &TuiData
->Entry
);
514 ActiveConsole
= TuiData
;
515 LeaveCriticalSection(&ActiveVirtConsLock
);
517 /* Finally, initialize the frontend structure */
518 This
->Data
= TuiData
;
519 This
->OldData
= NULL
;
521 return STATUS_SUCCESS
;
525 TuiDeinitFrontEnd(IN OUT PFRONTEND This
)
527 // PCONSOLE Console = This->Console;
528 PTUI_CONSOLE_DATA TuiData
= This
->Data
; // Console->FrontEndIFace.Data;
530 /* Close the notification window */
531 DestroyWindow(TuiData
->hWindow
);
534 * Set the active console to the next one
535 * and remove the console from the list.
537 EnterCriticalSection(&ActiveVirtConsLock
);
538 ActiveConsole
= GetNextConsole(TuiData
);
539 RemoveEntryList(&TuiData
->Entry
);
541 // /* Switch to next console */
542 // if (ActiveConsole == TuiData)
543 // if (ActiveConsole->Console == Console)
545 // ActiveConsole = (TuiData->Entry.Flink != TuiData->Entry ? GetNextConsole(TuiData) : NULL);
548 // if (GetNextConsole(TuiData) != TuiData)
550 // TuiData->Entry.Blink->Flink = TuiData->Entry.Flink;
551 // TuiData->Entry.Flink->Blink = TuiData->Entry.Blink;
554 LeaveCriticalSection(&ActiveVirtConsLock
);
556 /* Switch to the next console */
557 if (NULL
!= ActiveConsole
) ConioDrawConsole(ActiveConsole
->Console
);
559 // Console->FrontEndIFace.Data = NULL;
561 DeleteCriticalSection(&TuiData
->Lock
);
562 ConsoleFreeHeap(TuiData
);
566 TuiDrawRegion(IN OUT PFRONTEND This
,
570 PCONSOLE_SCREEN_BUFFER Buff
= Console
->ActiveBuffer
;
571 PCONSOLE_DRAW ConsoleDraw
;
572 UINT ConsoleDrawSize
;
574 if (ActiveConsole
->Console
!= Console
|| GetType(Buff
) != TEXTMODE_BUFFER
) return;
576 ConsoleDrawSize
= sizeof(CONSOLE_DRAW
) +
577 (ConioRectWidth(Region
) * ConioRectHeight(Region
)) * 2;
578 ConsoleDraw
= ConsoleAllocHeap(0, ConsoleDrawSize
);
579 if (NULL
== ConsoleDraw
)
581 DPRINT1("ConsoleAllocHeap failed\n");
584 ConsoleDraw
->X
= Region
->Left
;
585 ConsoleDraw
->Y
= Region
->Top
;
586 ConsoleDraw
->SizeX
= ConioRectWidth(Region
);
587 ConsoleDraw
->SizeY
= ConioRectHeight(Region
);
588 ConsoleDraw
->CursorX
= Buff
->CursorPosition
.X
;
589 ConsoleDraw
->CursorY
= Buff
->CursorPosition
.Y
;
591 TuiCopyRect((PCHAR
)(ConsoleDraw
+ 1), (PTEXTMODE_SCREEN_BUFFER
)Buff
, Region
);
593 if (!DeviceIoControl(ConsoleDeviceHandle
, IOCTL_CONSOLE_DRAW
,
594 NULL
, 0, ConsoleDraw
, ConsoleDrawSize
, &BytesReturned
, NULL
))
596 DPRINT1("Failed to draw console\n");
597 ConsoleFreeHeap(ConsoleDraw
);
601 ConsoleFreeHeap(ConsoleDraw
);
605 TuiWriteStream(IN OUT PFRONTEND This
,
613 PCONSOLE_SCREEN_BUFFER Buff
= Console
->ActiveBuffer
;
618 if (ActiveConsole
->Console
->ActiveBuffer
!= Buff
) return;
620 NewLength
= WideCharToMultiByte(Console
->OutputCodePage
, 0,
622 NULL
, 0, NULL
, NULL
);
623 NewBuffer
= RtlAllocateHeap(RtlGetProcessHeap(), 0, NewLength
* sizeof(CHAR
));
624 if (!NewBuffer
) return;
626 WideCharToMultiByte(Console
->OutputCodePage
, 0,
628 NewBuffer
, NewLength
, NULL
, NULL
);
630 if (!WriteFile(ConsoleDeviceHandle
, NewBuffer
, NewLength
* sizeof(CHAR
), &BytesWritten
, NULL
))
632 DPRINT1("Error writing to BlueScreen\n");
635 RtlFreeHeap(RtlGetProcessHeap(), 0, NewBuffer
);
639 TuiSetCursorInfo(IN OUT PFRONTEND This
,
640 PCONSOLE_SCREEN_BUFFER Buff
)
642 CONSOLE_CURSOR_INFO Info
;
645 if (ActiveConsole
->Console
->ActiveBuffer
!= Buff
) return TRUE
;
647 Info
.dwSize
= ConioEffectiveCursorSize(Console
, 100);
648 Info
.bVisible
= Buff
->CursorInfo
.bVisible
;
650 if (!DeviceIoControl(ConsoleDeviceHandle
, IOCTL_CONSOLE_SET_CURSOR_INFO
,
651 &Info
, sizeof(Info
), NULL
, 0, &BytesReturned
, NULL
))
653 DPRINT1( "Failed to set cursor info\n" );
661 TuiSetScreenInfo(IN OUT PFRONTEND This
,
662 PCONSOLE_SCREEN_BUFFER Buff
,
666 CONSOLE_SCREEN_BUFFER_INFO Info
;
669 if (ActiveConsole
->Console
->ActiveBuffer
!= Buff
) return TRUE
;
670 if (GetType(Buff
) != TEXTMODE_BUFFER
) return FALSE
;
672 Info
.dwCursorPosition
= Buff
->CursorPosition
;
673 Info
.wAttributes
= ((PTEXTMODE_SCREEN_BUFFER
)Buff
)->ScreenDefaultAttrib
;
675 if (!DeviceIoControl(ConsoleDeviceHandle
, IOCTL_CONSOLE_SET_SCREEN_BUFFER_INFO
,
676 &Info
, sizeof(CONSOLE_SCREEN_BUFFER_INFO
), NULL
, 0,
677 &BytesReturned
, NULL
))
679 DPRINT1( "Failed to set cursor position\n" );
687 TuiResizeTerminal(IN OUT PFRONTEND This
)
692 TuiProcessKeyCallback(IN OUT PFRONTEND This
,
699 if (0 != (ShiftState
& (RIGHT_ALT_PRESSED
| LEFT_ALT_PRESSED
)) &&
700 VK_TAB
== VirtualKeyCode
)
704 TuiSwapConsole(ShiftState
& SHIFT_PRESSED
? -1 : 1);
709 else if (VK_MENU
== VirtualKeyCode
&& !Down
)
711 return TuiSwapConsole(0);
718 TuiRefreshInternalInfo(IN OUT PFRONTEND This
)
723 TuiChangeTitle(IN OUT PFRONTEND This
)
728 TuiChangeIcon(IN OUT PFRONTEND This
,
735 TuiGetConsoleWindowHandle(IN OUT PFRONTEND This
)
737 PTUI_CONSOLE_DATA TuiData
= This
->Data
;
738 return TuiData
->hWindow
;
742 TuiGetLargestConsoleWindowSize(IN OUT PFRONTEND This
,
746 *pSize
= PhysicalConsoleSize
;
750 TuiGetSelectionInfo(IN OUT PFRONTEND This
,
751 PCONSOLE_SELECTION_INFO pSelectionInfo
)
757 TuiSetPalette(IN OUT PFRONTEND This
,
758 HPALETTE PaletteHandle
,
765 TuiGetDisplayMode(IN OUT PFRONTEND This
)
767 return CONSOLE_FULLSCREEN_HARDWARE
; // CONSOLE_FULLSCREEN;
771 TuiSetDisplayMode(IN OUT PFRONTEND This
,
774 // if (NewMode & ~(CONSOLE_FULLSCREEN_MODE | CONSOLE_WINDOWED_MODE))
780 TuiShowMouseCursor(IN OUT PFRONTEND This
,
787 TuiSetMouseCursor(IN OUT PFRONTEND This
,
788 HCURSOR CursorHandle
)
794 TuiMenuControl(IN OUT PFRONTEND This
,
802 TuiSetMenuClose(IN OUT PFRONTEND This
,
808 static FRONTEND_VTBL TuiVtbl
=
817 TuiProcessKeyCallback
,
818 TuiRefreshInternalInfo
,
821 TuiGetConsoleWindowHandle
,
822 TuiGetLargestConsoleWindowSize
,
834 // DtbgIsDesktopVisible(VOID)
836 // return !((BOOL)NtUserCallNoParam(NOPARAM_ROUTINE_ISCONSOLEMODE));
841 return (BOOLEAN
)NtUserCallNoParam(NOPARAM_ROUTINE_ISCONSOLEMODE
);
845 TuiLoadFrontEnd(IN OUT PFRONTEND FrontEnd
,
846 IN OUT PCONSOLE_INFO ConsoleInfo
,
847 IN OUT PVOID ExtraConsoleInfo
,
850 if (FrontEnd
== NULL
|| ConsoleInfo
== NULL
)
851 return STATUS_INVALID_PARAMETER
;
853 /* We must be in console mode already */
854 if (!IsConsoleMode()) return STATUS_UNSUCCESSFUL
;
856 /* Initialize the TUI terminal emulator */
857 if (!TuiInit(ConsoleInfo
->CodePage
)) return STATUS_UNSUCCESSFUL
;
859 /* Finally, initialize the frontend structure */
860 FrontEnd
->Vtbl
= &TuiVtbl
;
861 FrontEnd
->Data
= NULL
;
862 FrontEnd
->OldData
= NULL
;
864 return STATUS_SUCCESS
;
868 TuiUnloadFrontEnd(IN OUT PFRONTEND FrontEnd
)
870 if (FrontEnd
== NULL
) return STATUS_INVALID_PARAMETER
;
871 if (FrontEnd
->Data
) TuiDeinitFrontEnd(FrontEnd
);
873 return STATUS_SUCCESS
;