ReactOS 0.4.15-dev-7942-gd23573b
tuiterm.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/frontends/tui/tuiterm.c
5 * PURPOSE: TUI Terminal Front-End - Virtual Consoles...
6 * PROGRAMMERS: David Welch
7 * Gé van Geldorp
8 * Jeffrey Morlan
9 * Hermes Belusca-Maito (hermes.belusca@sfr.fr)
10 */
11
12#ifdef TUITERM_COMPILE
13
14#include <consrv.h>
15
16// #include "include/conio.h"
17#include "include/console.h"
18#include "include/settings.h"
19#include "tuiterm.h"
20
21#include <ndk/iofuncs.h>
22#include <ndk/setypes.h>
24
25#define NDEBUG
26#include <debug.h>
27
28
29/* CAB FILE STRUCTURES ******************************************************/
30
31typedef struct _CFHEADER
32{
33 ULONG Signature; // File signature 'MSCF' (CAB_SIGNATURE)
34 ULONG Reserved1; // Reserved field
35 ULONG CabinetSize; // Cabinet file size
36 ULONG Reserved2; // Reserved field
37 ULONG FileTableOffset; // Offset of first CFFILE
38 ULONG Reserved3; // Reserved field
39 USHORT Version; // Cabinet version (CAB_VERSION)
40 USHORT FolderCount; // Number of folders
41 USHORT FileCount; // Number of files
42 USHORT Flags; // Cabinet flags (CAB_FLAG_*)
43 USHORT SetID; // Cabinet set id
44 USHORT CabinetNumber; // Zero-based cabinet number
46
47typedef struct _CFFILE
48{
49 ULONG FileSize; // Uncompressed file size in bytes
50 ULONG FileOffset; // Uncompressed offset of file in the folder
51 USHORT FileControlID; // File control ID (CAB_FILE_*)
52 USHORT FileDate; // File date stamp, as used by DOS
53 USHORT FileTime; // File time stamp, as used by DOS
54 USHORT Attributes; // File attributes (CAB_ATTRIB_*)
55 /* After this is the NULL terminated filename */
56 // CHAR FileName[ANYSIZE_ARRAY];
57} CFFILE, *PCFFILE;
58
59#define CAB_SIGNATURE 0x4643534D // "MSCF"
60#define CAB_VERSION 0x0103
61
62
63/* GLOBALS ******************************************************************/
64
65#define ConsoleOutputUnicodeToAnsiChar(Console, dChar, sWChar) \
66do { \
67 ASSERT((ULONG_PTR)(dChar) != (ULONG_PTR)(sWChar)); \
68 WideCharToMultiByte((Console)->OutputCodePage, 0, (sWChar), 1, (dChar), 1, NULL, NULL); \
69} while (0)
70
71/* TUI Console Window Class name */
72#define TUI_CONSOLE_WINDOW_CLASS L"TuiConsoleWindowClass"
73
74typedef struct _TUI_CONSOLE_DATA
75{
77 LIST_ENTRY Entry; /* Entry in the list of virtual consoles */
78 // HANDLE hTuiInitEvent;
79 // HANDLE hTuiTermEvent;
80
81 HWND hWindow; /* Handle to the console's window (used for the window's procedure) */
82
83 PCONSRV_CONSOLE Console; /* Pointer to the owned console */
84 PCONSOLE_SCREEN_BUFFER ActiveBuffer; /* Pointer to the active screen buffer (then maybe the previous Console member is redundant?? Or not...) */
85 // TUI_CONSOLE_INFO TuiInfo; /* TUI terminal settings */
86} TUI_CONSOLE_DATA, *PTUI_CONSOLE_DATA;
87
88#define GetNextConsole(Console) \
89 CONTAINING_RECORD(Console->Entry.Flink, TUI_CONSOLE_DATA, Entry)
90
91#define GetPrevConsole(Console) \
92 CONTAINING_RECORD(Console->Entry.Blink, TUI_CONSOLE_DATA, Entry)
93
94
95/* List of the maintained virtual consoles and its lock */
96static LIST_ENTRY VirtConsList;
97static PTUI_CONSOLE_DATA ActiveConsole; /* The active console on screen */
98static CRITICAL_SECTION ActiveVirtConsLock;
99
100static COORD PhysicalConsoleSize;
101static HANDLE ConsoleDeviceHandle;
102
103static BOOL ConsInitialized = FALSE;
104
105/******************************************************************************\
106|** BlueScreen Driver management **|
107\**/
108/* Code taken and adapted from base/system/services/driver.c */
109static DWORD
110ScmLoadDriver(LPCWSTR lpServiceName)
111{
113 BOOLEAN WasPrivilegeEnabled = FALSE;
114 PWSTR pszDriverPath;
115 UNICODE_STRING DriverPath;
116
117 /* Build the driver path */
118 /* 52 = wcslen(L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\") */
119 pszDriverPath = ConsoleAllocHeap(HEAP_ZERO_MEMORY,
120 (52 + wcslen(lpServiceName) + 1) * sizeof(WCHAR));
121 if (pszDriverPath == NULL)
123
124 wcscpy(pszDriverPath,
125 L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\");
126 wcscat(pszDriverPath,
127 lpServiceName);
128
129 RtlInitUnicodeString(&DriverPath,
130 pszDriverPath);
131
132 DPRINT(" Path: %wZ\n", &DriverPath);
133
134 /* Acquire driver-loading privilege */
136 TRUE,
137 FALSE,
138 &WasPrivilegeEnabled);
139 if (!NT_SUCCESS(Status))
140 {
141 /* We encountered a failure, exit properly */
142 DPRINT1("CONSRV: Cannot acquire driver-loading privilege, Status = 0x%08lx\n", Status);
143 goto done;
144 }
145
146 Status = NtLoadDriver(&DriverPath);
147
148 /* Release driver-loading privilege */
150 WasPrivilegeEnabled,
151 FALSE,
152 &WasPrivilegeEnabled);
153
154done:
155 ConsoleFreeHeap(pszDriverPath);
157}
158
159#ifdef BLUESCREEN_DRIVER_UNLOADING
160static DWORD
161ScmUnloadDriver(LPCWSTR lpServiceName)
162{
164 BOOLEAN WasPrivilegeEnabled = FALSE;
165 PWSTR pszDriverPath;
166 UNICODE_STRING DriverPath;
167
168 /* Build the driver path */
169 /* 52 = wcslen(L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\") */
170 pszDriverPath = ConsoleAllocHeap(HEAP_ZERO_MEMORY,
171 (52 + wcslen(lpServiceName) + 1) * sizeof(WCHAR));
172 if (pszDriverPath == NULL)
174
175 wcscpy(pszDriverPath,
176 L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\");
177 wcscat(pszDriverPath,
178 lpServiceName);
179
180 RtlInitUnicodeString(&DriverPath,
181 pszDriverPath);
182
183 DPRINT(" Path: %wZ\n", &DriverPath);
184
185 /* Acquire driver-unloading privilege */
187 TRUE,
188 FALSE,
189 &WasPrivilegeEnabled);
190 if (!NT_SUCCESS(Status))
191 {
192 /* We encountered a failure, exit properly */
193 DPRINT1("CONSRV: Cannot acquire driver-unloading privilege, Status = 0x%08lx\n", Status);
194 goto done;
195 }
196
197 Status = NtUnloadDriver(&DriverPath);
198
199 /* Release driver-unloading privilege */
201 WasPrivilegeEnabled,
202 FALSE,
203 &WasPrivilegeEnabled);
204
205done:
206 ConsoleFreeHeap(pszDriverPath);
208}
209#endif
213#if 0
214static BOOL
215TuiSwapConsole(INT Next)
216{
217 static PTUI_CONSOLE_DATA SwapConsole = NULL; /* Console we are thinking about swapping with */
221 PCOORD pos;
222
223 if (0 != Next)
224 {
225 /*
226 * Alt-Tab, swap consoles.
227 * move SwapConsole to next console, and print its title.
228 */
229 EnterCriticalSection(&ActiveVirtConsLock);
230 if (!SwapConsole) SwapConsole = ActiveConsole;
231
232 SwapConsole = (0 < Next ? GetNextConsole(SwapConsole) : GetPrevConsole(SwapConsole));
233 Title.MaximumLength = RtlUnicodeStringToAnsiSize(&SwapConsole->Console->Title);
234 Title.Length = 0;
235 Buffer = ConsoleAllocHeap(0, sizeof(COORD) + Title.MaximumLength);
236 pos = (PCOORD)Buffer;
237 Title.Buffer = (PVOID)((ULONG_PTR)Buffer + sizeof(COORD));
238
239 RtlUnicodeStringToAnsiString(&Title, &SwapConsole->Console->Title, FALSE);
240 pos->X = (PhysicalConsoleSize.X - Title.Length) / 2;
241 pos->Y = PhysicalConsoleSize.Y / 2;
242 /* Redraw the console to clear off old title */
243 ConioDrawConsole(ActiveConsole->Console);
245 NULL, 0, Buffer, sizeof(COORD) + Title.Length,
247 {
248 DPRINT1( "Error writing to console\n" );
249 }
251 LeaveCriticalSection(&ActiveVirtConsLock);
252
253 return TRUE;
254 }
255 else if (NULL != SwapConsole)
256 {
257 EnterCriticalSection(&ActiveVirtConsLock);
258 if (SwapConsole != ActiveConsole)
259 {
260 /* First remove swapconsole from the list */
261 SwapConsole->Entry.Blink->Flink = SwapConsole->Entry.Flink;
262 SwapConsole->Entry.Flink->Blink = SwapConsole->Entry.Blink;
263 /* Now insert before activeconsole */
264 SwapConsole->Entry.Flink = &ActiveConsole->Entry;
265 SwapConsole->Entry.Blink = ActiveConsole->Entry.Blink;
266 ActiveConsole->Entry.Blink->Flink = &SwapConsole->Entry;
267 ActiveConsole->Entry.Blink = &SwapConsole->Entry;
268 }
269 ActiveConsole = SwapConsole;
270 SwapConsole = NULL;
271 ConioDrawConsole(ActiveConsole->Console);
272 LeaveCriticalSection(&ActiveVirtConsLock);
273 return TRUE;
274 }
275 else
276 {
277 return FALSE;
278 }
279}
280#endif
281
282static VOID
283TuiCopyRect(PCHAR Dest, PTEXTMODE_SCREEN_BUFFER Buff, SMALL_RECT* Region)
284{
285 UINT SrcDelta, DestDelta;
286 LONG i;
287 PCHAR_INFO Src, SrcEnd;
288
289 Src = ConioCoordToPointer(Buff, Region->Left, Region->Top);
290 SrcDelta = Buff->ScreenBufferSize.X * sizeof(CHAR_INFO);
291 SrcEnd = Buff->Buffer + Buff->ScreenBufferSize.Y * Buff->ScreenBufferSize.X * sizeof(CHAR_INFO);
292 DestDelta = ConioRectWidth(Region) * 2 /* 2 == sizeof(CHAR) + sizeof(BYTE) */;
293 for (i = Region->Top; i <= Region->Bottom; i++)
294 {
295 ConsoleOutputUnicodeToAnsiChar(Buff->Header.Console, (PCHAR)Dest, &Src->Char.UnicodeChar);
296 *(PBYTE)(Dest + 1) = (BYTE)Src->Attributes;
297
298 Src += SrcDelta;
299 if (SrcEnd <= Src)
300 {
301 Src -= Buff->ScreenBufferSize.Y * Buff->ScreenBufferSize.X * sizeof(CHAR_INFO);
302 }
303 Dest += DestDelta;
304 }
305}
306
307static LRESULT CALLBACK
308TuiConsoleWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
309{
310/*
311 PTUI_CONSOLE_DATA TuiData = NULL;
312 PCONSRV_CONSOLE Console = NULL;
313
314 TuiData = TuiGetGuiData(hWnd);
315 if (TuiData == NULL) return 0;
316*/
317
318 switch (msg)
319 {
320 case WM_CHAR:
321 case WM_SYSCHAR:
322 case WM_KEYDOWN:
323 case WM_SYSKEYDOWN:
324 case WM_KEYUP:
325 case WM_SYSKEYUP:
326 {
327#if 0
328 if ((HIWORD(lParam) & KF_ALTDOWN) && wParam == VK_TAB)
329 {
330 // if ((HIWORD(lParam) & (KF_UP | KF_REPEAT)) != KF_REPEAT)
331 TuiSwapConsole(ShiftState & SHIFT_PRESSED ? -1 : 1);
332
333 break;
334 }
335 else if (wParam == VK_MENU /* && !Down */)
336 {
337 TuiSwapConsole(0);
338 break;
339 }
340#endif
341
342 if (ConDrvValidateConsoleUnsafe((PCONSOLE)ActiveConsole->Console, CONSOLE_RUNNING, TRUE))
343 {
344 MSG Message;
345 Message.hwnd = hWnd;
346 Message.message = msg;
347 Message.wParam = wParam;
348 Message.lParam = lParam;
349
350 ConioProcessKey(ActiveConsole->Console, &Message);
351 LeaveCriticalSection(&ActiveConsole->Console->Lock);
352 }
353 break;
354 }
355
356 case WM_ACTIVATE:
357 {
358 if (ConDrvValidateConsoleUnsafe((PCONSOLE)ActiveConsole->Console, CONSOLE_RUNNING, TRUE))
359 {
360 if (LOWORD(wParam) != WA_INACTIVE)
361 {
362 SetFocus(hWnd);
363 ConioDrawConsole(ActiveConsole->Console);
364 }
365 LeaveCriticalSection(&ActiveConsole->Console->Lock);
366 }
367 break;
368 }
369
370 default:
371 break;
372 }
373
375}
376
377static DWORD NTAPI
378TuiConsoleThread(PVOID Param)
379{
380 PTUI_CONSOLE_DATA TuiData = (PTUI_CONSOLE_DATA)Param;
381 PCONSRV_CONSOLE Console = TuiData->Console;
382 HWND NewWindow;
383 MSG msg;
384
385 NewWindow = CreateWindowW(TUI_CONSOLE_WINDOW_CLASS,
386 Console->Title.Buffer,
387 0,
388 -32000, -32000, 0, 0,
389 NULL, NULL,
391 (PVOID)Console);
392 if (NULL == NewWindow)
393 {
394 DPRINT1("CONSRV: Unable to create console window\n");
395 return 1;
396 }
397 TuiData->hWindow = NewWindow;
398
399 SetForegroundWindow(TuiData->hWindow);
401
402 while (GetMessageW(&msg, NULL, 0, 0))
403 {
406 }
407
408 return 0;
409}
410
411static BOOLEAN
412TuiSetConsoleOutputCP(
413 IN HANDLE hNtConddHandle,
414 IN UINT CodePage)
415{
416 static UINT LastLoadedCodepage = 0;
417 UNICODE_STRING FontFile = RTL_CONSTANT_STRING(L"\\SystemRoot\\vgafonts.cab");
418 CHAR FontName[20];
419
424 // ULONG ReadCP;
425 PUCHAR FontBitField = NULL;
426
427 /* CAB-specific data */
428 HANDLE FileSectionHandle;
429 PUCHAR FileBuffer = NULL;
430 SIZE_T FileSize = 0;
431 PCFHEADER CabFileHeader;
432 union
433 {
434 PCFFILE CabFile;
436 } Data;
437 PCFFILE FoundFile = NULL;
440
441 if (CodePage == LastLoadedCodepage)
442 return TRUE;
443
444 /*
445 * Open the *uncompressed* fonts archive file.
446 */
448 &FontFile,
450 NULL,
451 NULL);
452
459 if (!NT_SUCCESS(Status))
460 {
461 DPRINT1("Error: Cannot open '%wZ' (0x%lx)\n", &FontFile, Status);
462 return FALSE;
463 }
464
465 /*
466 * Load it.
467 */
468 Status = NtCreateSection(&FileSectionHandle,
470 0, 0,
473 FileHandle);
474 if (!NT_SUCCESS(Status))
475 {
476 DPRINT1("NtCreateSection failed (0x%lx)\n", Status);
477 goto Exit;
478 }
479
480 Status = NtMapViewOfSection(FileSectionHandle,
482 (PVOID*)&FileBuffer,
483 0, 0, NULL,
484 &FileSize,
485 ViewUnmap,
486 0,
488 if (!NT_SUCCESS(Status))
489 {
490 DPRINT1("NtMapViewOfSection failed (0x%lx)\n", Status);
491 goto Exit;
492 }
493
494 /* Wrap in SEH to protect against ill-formed file */
496 {
497 DPRINT("Cabinet file '%wZ' opened and mapped to 0x%p\n",
498 &FontFile, FileBuffer);
499
500 CabFileHeader = (PCFHEADER)FileBuffer;
501
502 /* Validate the CAB file */
503 if (FileSize <= sizeof(CFHEADER) ||
504 CabFileHeader->Signature != CAB_SIGNATURE ||
505 CabFileHeader->Version != CAB_VERSION ||
506 CabFileHeader->FolderCount == 0 ||
507 CabFileHeader->FileCount == 0 ||
508 CabFileHeader->FileTableOffset < sizeof(CFHEADER))
509 {
510 DPRINT1("Cabinet file '%wZ' has an invalid header\n", &FontFile);
512 _SEH2_YIELD(goto Exit);
513 }
514
515 /*
516 * Find the font file within the archive.
517 */
518 RtlStringCbPrintfA(FontName, sizeof(FontName),
519 "%u-8x8.bin", CodePage);
520
521 /* Read the file table, find the file of interest and the end of the table */
522 Data.CabFile = (PCFFILE)(FileBuffer + CabFileHeader->FileTableOffset);
523 for (Index = 0; Index < CabFileHeader->FileCount; ++Index)
524 {
525 FileName = (PSTR)(Data.CabFile + 1);
526
527 if (!FoundFile)
528 {
529 // Status = RtlCharToInteger(FileName, 0, &ReadCP);
530 // if (NT_SUCCESS(Status) && (ReadCP == CodePage))
531 if (_stricmp(FontName, FileName) == 0)
532 {
533 /* We've got the correct file. Save the offset and
534 * loop through the rest of the file table to find
535 * the position, where the actual data starts. */
536 FoundFile = Data.CabFile;
537 }
538 }
539
540 /* Move to the next file (go past the filename NULL terminator) */
541 Data.CabFile = (PCFFILE)(strchr(FileName, 0) + 1);
542 }
543
544 if (!FoundFile)
545 {
546 DPRINT("File '%S' not found in cabinet '%wZ'\n",
547 FontName, &FontFile);
549 _SEH2_YIELD(goto Exit);
550 }
551
552 /*
553 * Extract the font file.
554 */
555 /* Verify the font file size; we only support a fixed 256-char 8-bit font */
556 if (FoundFile->FileSize != 256 * 8)
557 {
558 DPRINT1("File of size %lu is not of the expected size %lu\n",
559 FoundFile->FileSize, 256 * 8);
561 _SEH2_YIELD(goto Exit);
562 }
563
564 FontBitField = RtlAllocateHeap(RtlGetProcessHeap(), 0, FoundFile->FileSize);
565 if (!FontBitField)
566 {
567 DPRINT1("ExAllocatePoolWithTag(%lu) failed\n", FoundFile->FileSize);
569 _SEH2_YIELD(goto Exit);
570 }
571
572 /* 8 = Size of a CFFOLDER structure (see cabman). As we don't need
573 * the values of that structure, just increase the offset here. */
574 Data.Buffer = (PVOID)((ULONG_PTR)Data.Buffer + 8); // sizeof(CFFOLDER);
575 Data.Buffer = (PVOID)((ULONG_PTR)Data.Buffer + FoundFile->FileOffset);
576
577 /* Data.Buffer now points to the actual data of the RAW font */
578 RtlCopyMemory(FontBitField, Data.Buffer, FoundFile->FileSize);
580 }
582 {
584 DPRINT1("TuiSetConsoleOutputCP - Caught an exception, Status = 0x%08lx\n", Status);
585 }
586 _SEH2_END;
587
588 /*
589 * Load the font.
590 */
591 if (NT_SUCCESS(Status))
592 {
593 ASSERT(FoundFile);
594 ASSERT(FontBitField);
595 Status = NtDeviceIoControlFile(hNtConddHandle,
596 NULL,
597 NULL,
598 NULL,
601 FontBitField,
602 FoundFile->FileSize,
603 NULL,
604 0);
605 }
606
607 if (FontBitField)
608 RtlFreeHeap(RtlGetProcessHeap(), 0, FontBitField);
609
610Exit:
611 if (FileBuffer)
613
614 if (FileSectionHandle)
615 NtClose(FileSectionHandle);
616
618
619 if (NT_SUCCESS(Status))
620 LastLoadedCodepage = CodePage;
621
622 return NT_SUCCESS(Status);
623}
624
625static BOOL
626TuiInit(IN UINT OemCP)
627{
631 WNDCLASSEXW wc;
632 ATOM ConsoleClassAtom;
634
635 /* Exit if we were already initialized */
636 if (ConsInitialized) return TRUE;
637
638 /*
639 * Initialize the TUI front-end:
640 * - load the console driver,
641 * - open BlueScreen device and enable it,
642 * - set default screen attributes,
643 * - grab the console size.
644 */
645 ScmLoadDriver(L"Blue");
646
647 ConsoleDeviceHandle = CreateFileW(L"\\\\.\\BlueScreen",
649 0, NULL,
651 0, NULL);
652 if (ConsoleDeviceHandle == INVALID_HANDLE_VALUE)
653 {
654 DPRINT1("Failed to open BlueScreen.\n");
655 return FALSE;
656 }
657
658 Success = TRUE;
659 if (!DeviceIoControl(ConsoleDeviceHandle, IOCTL_CONSOLE_RESET_SCREEN,
660 &Success, sizeof(Success), NULL, 0,
662 {
663 DPRINT1("Failed to enable the screen.\n");
664 CloseHandle(ConsoleDeviceHandle);
665 return FALSE;
666 }
667
668 if (!TuiSetConsoleOutputCP(ConsoleDeviceHandle, OemCP))
669 {
670 DPRINT1("Failed to load the font for codepage %d\n", OemCP);
671 /* Let's suppose the font is good enough to continue */
672 }
673
674 if (!DeviceIoControl(ConsoleDeviceHandle, IOCTL_CONSOLE_SET_TEXT_ATTRIBUTE,
675 &TextAttribute, sizeof(TextAttribute), NULL, 0,
677 {
678 DPRINT1("Failed to set text attribute.\n");
679 }
680
681 ActiveConsole = NULL;
682 InitializeListHead(&VirtConsList);
683 InitializeCriticalSection(&ActiveVirtConsLock);
684
686 NULL, 0, &ScrInfo, sizeof(ScrInfo), &BytesReturned, NULL))
687 {
688 DPRINT1("Failed to get console info.\n");
689 Success = FALSE;
690 goto Quit;
691 }
692 PhysicalConsoleSize = ScrInfo.dwSize;
693
694 /* Register the TUI notification window class */
695 RtlZeroMemory(&wc, sizeof(WNDCLASSEXW));
696 wc.cbSize = sizeof(WNDCLASSEXW);
697 wc.lpszClassName = TUI_CONSOLE_WINDOW_CLASS;
698 wc.lpfnWndProc = TuiConsoleWndProc;
699 wc.cbWndExtra = 0;
701
702 ConsoleClassAtom = RegisterClassExW(&wc);
703 if (ConsoleClassAtom == 0)
704 {
705 DPRINT1("Failed to register TUI console wndproc.\n");
706 Success = FALSE;
707 }
708 else
709 {
710 Success = TRUE;
711 }
712
713Quit:
714 if (!Success)
715 {
716 DeleteCriticalSection(&ActiveVirtConsLock);
717 CloseHandle(ConsoleDeviceHandle);
718 }
719
721 return Success;
722}
723
724
725
726/******************************************************************************
727 * TUI Console Driver *
728 ******************************************************************************/
729
730static VOID NTAPI
731TuiDeinitFrontEnd(IN OUT PFRONTEND This /*,
732 IN PCONSRV_CONSOLE Console */);
733
734static NTSTATUS NTAPI
735TuiInitFrontEnd(IN OUT PFRONTEND This,
737{
738 PTUI_CONSOLE_DATA TuiData;
739 HANDLE ThreadHandle;
740
741 if (This == NULL || Console == NULL)
743
744 if (GetType(Console->ActiveBuffer) != TEXTMODE_BUFFER)
746
747 TuiData = ConsoleAllocHeap(HEAP_ZERO_MEMORY, sizeof(TUI_CONSOLE_DATA));
748 if (!TuiData)
749 {
750 DPRINT1("CONSRV: Failed to create TUI_CONSOLE_DATA\n");
751 return STATUS_UNSUCCESSFUL;
752 }
753 // Console->FrontEndIFace.Context = (PVOID)TuiData;
754 TuiData->Console = Console;
755 TuiData->ActiveBuffer = Console->ActiveBuffer;
756 TuiData->hWindow = NULL;
757
758 InitializeCriticalSection(&TuiData->Lock);
759
760 /*
761 * HACK: Resize the console since we don't support for now changing
762 * the console size when we display it with the hardware.
763 */
764 // Console->ConsoleSize = PhysicalConsoleSize;
765 // ConioResizeBuffer(Console, (PTEXTMODE_SCREEN_BUFFER)(Console->ActiveBuffer), PhysicalConsoleSize);
766
767 // /* The console cannot be resized anymore */
768 // Console->FixedSize = TRUE; // MUST be placed AFTER the call to ConioResizeBuffer !!
769 // // TermResizeTerminal(Console);
770
771 /*
772 * Contrary to what we do in the GUI front-end, here we create
773 * an input thread for each console. It will dispatch all the
774 * input messages to the proper console (on the GUI it is done
775 * via the default GUI dispatch thread).
776 */
777 ThreadHandle = CreateThread(NULL,
778 0,
779 TuiConsoleThread,
780 (PVOID)TuiData,
781 0,
782 NULL);
783 if (NULL == ThreadHandle)
784 {
785 DPRINT1("CONSRV: Unable to create console thread\n");
786 // TuiDeinitFrontEnd(Console);
787 TuiDeinitFrontEnd(This);
788 return STATUS_UNSUCCESSFUL;
789 }
790 CloseHandle(ThreadHandle);
791
792 /*
793 * Insert the newly created console in the list of virtual consoles
794 * and activate it (give it the focus).
795 */
796 EnterCriticalSection(&ActiveVirtConsLock);
797 InsertTailList(&VirtConsList, &TuiData->Entry);
798 ActiveConsole = TuiData;
799 LeaveCriticalSection(&ActiveVirtConsLock);
800
801 /* Finally, initialize the frontend structure */
802 This->Context = TuiData;
803 This->Context2 = NULL;
804
805 return STATUS_SUCCESS;
806}
807
808static VOID NTAPI
809TuiDeinitFrontEnd(IN OUT PFRONTEND This)
810{
811 // PCONSRV_CONSOLE Console = This->Console;
812 PTUI_CONSOLE_DATA TuiData = This->Context;
813
814 /* Close the notification window */
815 DestroyWindow(TuiData->hWindow);
816
817 /*
818 * Set the active console to the next one
819 * and remove the console from the list.
820 */
821 EnterCriticalSection(&ActiveVirtConsLock);
822 ActiveConsole = GetNextConsole(TuiData);
823 RemoveEntryList(&TuiData->Entry);
824
825 // /* Switch to next console */
826 // if (ActiveConsole == TuiData)
827 // if (ActiveConsole->Console == Console)
828 // {
829 // ActiveConsole = (TuiData->Entry.Flink != TuiData->Entry ? GetNextConsole(TuiData) : NULL);
830 // }
831
832 // if (GetNextConsole(TuiData) != TuiData)
833 // {
834 // TuiData->Entry.Blink->Flink = TuiData->Entry.Flink;
835 // TuiData->Entry.Flink->Blink = TuiData->Entry.Blink;
836 // }
837
838 LeaveCriticalSection(&ActiveVirtConsLock);
839
840 /* Switch to the next console */
841 if (NULL != ActiveConsole) ConioDrawConsole(ActiveConsole->Console);
842
843 This->Context = NULL;
844 DeleteCriticalSection(&TuiData->Lock);
845 ConsoleFreeHeap(TuiData);
846}
847
848static VOID NTAPI
849TuiDrawRegion(IN OUT PFRONTEND This,
851{
852 PTUI_CONSOLE_DATA TuiData = This->Context;
853 PCONSOLE_SCREEN_BUFFER Buff = TuiData->Console->ActiveBuffer;
854 PCONSOLE_DRAW ConsoleDraw;
856 UINT ConsoleDrawSize;
857
858 if (TuiData != ActiveConsole) return;
859 if (GetType(Buff) != TEXTMODE_BUFFER) return;
860
861 ConsoleDrawSize = sizeof(CONSOLE_DRAW) +
863 ConsoleDraw = ConsoleAllocHeap(0, ConsoleDrawSize);
864 if (NULL == ConsoleDraw)
865 {
866 DPRINT1("ConsoleAllocHeap failed\n");
867 return;
868 }
869 ConsoleDraw->X = Region->Left;
870 ConsoleDraw->Y = Region->Top;
871 ConsoleDraw->SizeX = ConioRectWidth(Region);
872 ConsoleDraw->SizeY = ConioRectHeight(Region);
873 ConsoleDraw->CursorX = Buff->CursorPosition.X;
874 ConsoleDraw->CursorY = Buff->CursorPosition.Y;
875
876 TuiCopyRect((PCHAR)(ConsoleDraw + 1), (PTEXTMODE_SCREEN_BUFFER)Buff, Region);
877
878 if (!DeviceIoControl(ConsoleDeviceHandle, IOCTL_CONSOLE_DRAW,
879 NULL, 0, ConsoleDraw, ConsoleDrawSize, &BytesReturned, NULL))
880 {
881 DPRINT1("Failed to draw console\n");
882 ConsoleFreeHeap(ConsoleDraw);
883 return;
884 }
885
886 ConsoleFreeHeap(ConsoleDraw);
887}
888
889static VOID NTAPI
890TuiWriteStream(IN OUT PFRONTEND This,
892 SHORT CursorStartX,
893 SHORT CursorStartY,
894 UINT ScrolledLines,
896 UINT Length)
897{
898 PTUI_CONSOLE_DATA TuiData = This->Context;
899 PCONSOLE_SCREEN_BUFFER Buff = TuiData->Console->ActiveBuffer;
900 PCHAR NewBuffer;
903
904 if (TuiData != ActiveConsole) return;
905 if (GetType(Buff) != TEXTMODE_BUFFER) return;
906
907 NewLength = WideCharToMultiByte(TuiData->Console->OutputCodePage, 0,
908 Buffer, Length,
909 NULL, 0, NULL, NULL);
910 NewBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, NewLength * sizeof(CHAR));
911 if (!NewBuffer) return;
912
913 WideCharToMultiByte(TuiData->Console->OutputCodePage, 0,
914 Buffer, Length,
915 NewBuffer, NewLength, NULL, NULL);
916
917 if (!WriteFile(ConsoleDeviceHandle, NewBuffer, NewLength * sizeof(CHAR), &BytesWritten, NULL))
918 {
919 DPRINT1("Error writing to BlueScreen\n");
920 }
921
922 RtlFreeHeap(RtlGetProcessHeap(), 0, NewBuffer);
923}
924
925static VOID NTAPI
926TuiRingBell(IN OUT PFRONTEND This)
927{
928 Beep(800, 200);
929}
930
931static BOOL NTAPI
932TuiSetCursorInfo(IN OUT PFRONTEND This,
934{
935 PTUI_CONSOLE_DATA TuiData = This->Context;
938
939 if (TuiData != ActiveConsole) return TRUE;
940 if (TuiData->Console->ActiveBuffer != Buff) return TRUE;
941 if (GetType(Buff) != TEXTMODE_BUFFER) return FALSE;
942
943 Info.dwSize = ConioEffectiveCursorSize(TuiData->Console, 100);
944 Info.bVisible = Buff->CursorInfo.bVisible;
945
946 if (!DeviceIoControl(ConsoleDeviceHandle, IOCTL_CONSOLE_SET_CURSOR_INFO,
947 &Info, sizeof(Info), NULL, 0, &BytesReturned, NULL))
948 {
949 DPRINT1( "Failed to set cursor info\n" );
950 return FALSE;
951 }
952
953 return TRUE;
954}
955
956static BOOL NTAPI
957TuiSetScreenInfo(IN OUT PFRONTEND This,
959 SHORT OldCursorX,
960 SHORT OldCursorY)
961{
962 PTUI_CONSOLE_DATA TuiData = This->Context;
965
966 if (TuiData != ActiveConsole) return TRUE;
967 if (TuiData->Console->ActiveBuffer != Buff) return TRUE;
968 if (GetType(Buff) != TEXTMODE_BUFFER) return FALSE;
969
970 Info.dwCursorPosition = Buff->CursorPosition;
971 Info.wAttributes = ((PTEXTMODE_SCREEN_BUFFER)Buff)->ScreenDefaultAttrib;
972
976 {
977 DPRINT1( "Failed to set cursor position\n" );
978 return FALSE;
979 }
980
981 return TRUE;
982}
983
984static VOID NTAPI
985TuiResizeTerminal(IN OUT PFRONTEND This)
986{
987}
988
989static VOID NTAPI
990TuiSetActiveScreenBuffer(IN OUT PFRONTEND This)
991{
992 // PGUI_CONSOLE_DATA GuiData = This->Context;
993 // PCONSOLE_SCREEN_BUFFER ActiveBuffer;
994 // HPALETTE hPalette;
995
996 // EnterCriticalSection(&GuiData->Lock);
997 // GuiData->WindowSizeLock = TRUE;
998
999 // InterlockedExchangePointer(&GuiData->ActiveBuffer,
1000 // ConDrvGetActiveScreenBuffer(GuiData->Console));
1001
1002 // GuiData->WindowSizeLock = FALSE;
1003 // LeaveCriticalSection(&GuiData->Lock);
1004
1005 // ActiveBuffer = GuiData->ActiveBuffer;
1006
1007 // /* Change the current palette */
1008 // if (ActiveBuffer->PaletteHandle == NULL)
1009 // {
1010 // hPalette = GuiData->hSysPalette;
1011 // }
1012 // else
1013 // {
1014 // hPalette = ActiveBuffer->PaletteHandle;
1015 // }
1016
1017 // DPRINT("GuiSetActiveScreenBuffer using palette 0x%p\n", hPalette);
1018
1019 // /* Set the new palette for the framebuffer */
1020 // SelectPalette(GuiData->hMemDC, hPalette, FALSE);
1021
1022 // /* Specify the use of the system palette for the framebuffer */
1023 // SetSystemPaletteUse(GuiData->hMemDC, ActiveBuffer->PaletteUsage);
1024
1025 // /* Realize the (logical) palette */
1026 // RealizePalette(GuiData->hMemDC);
1027
1028 // GuiResizeTerminal(This);
1029 // // ConioDrawConsole(Console);
1030}
1031
1032static VOID NTAPI
1033TuiReleaseScreenBuffer(IN OUT PFRONTEND This,
1035{
1036 // PGUI_CONSOLE_DATA GuiData = This->Context;
1037
1038 // /*
1039 // * If we were notified to release a screen buffer that is not actually
1040 // * ours, then just ignore the notification...
1041 // */
1042 // if (ScreenBuffer != GuiData->ActiveBuffer) return;
1043
1044 // /*
1045 // * ... else, we must release our active buffer. Two cases are present:
1046 // * - If ScreenBuffer (== GuiData->ActiveBuffer) IS NOT the console
1047 // * active screen buffer, then we can safely switch to it.
1048 // * - If ScreenBuffer IS the console active screen buffer, we must release
1049 // * it ONLY.
1050 // */
1051
1052 // /* Release the old active palette and set the default one */
1053 // if (GetCurrentObject(GuiData->hMemDC, OBJ_PAL) == ScreenBuffer->PaletteHandle)
1054 // {
1055 // /* Set the new palette */
1056 // SelectPalette(GuiData->hMemDC, GuiData->hSysPalette, FALSE);
1057 // }
1058
1059 // /* Set the adequate active screen buffer */
1060 // if (ScreenBuffer != GuiData->Console->ActiveBuffer)
1061 // {
1062 // GuiSetActiveScreenBuffer(This);
1063 // }
1064 // else
1065 // {
1066 // EnterCriticalSection(&GuiData->Lock);
1067 // GuiData->WindowSizeLock = TRUE;
1068
1069 // InterlockedExchangePointer(&GuiData->ActiveBuffer, NULL);
1070
1071 // GuiData->WindowSizeLock = FALSE;
1072 // LeaveCriticalSection(&GuiData->Lock);
1073 // }
1074}
1075
1076static VOID NTAPI
1077TuiRefreshInternalInfo(IN OUT PFRONTEND This)
1078{
1079}
1080
1081static VOID NTAPI
1082TuiChangeTitle(IN OUT PFRONTEND This)
1083{
1084}
1085
1086static BOOL NTAPI
1087TuiChangeIcon(IN OUT PFRONTEND This,
1088 HICON IconHandle)
1089{
1090 return TRUE;
1091}
1092
1093static HDESK NTAPI
1094TuiGetThreadConsoleDesktop(IN OUT PFRONTEND This)
1095{
1096 // PTUI_CONSOLE_DATA TuiData = This->Context;
1097 return NULL;
1098}
1099
1100static HWND NTAPI
1101TuiGetConsoleWindowHandle(IN OUT PFRONTEND This)
1102{
1103 PTUI_CONSOLE_DATA TuiData = This->Context;
1104 return TuiData->hWindow;
1105}
1106
1107static VOID NTAPI
1108TuiGetLargestConsoleWindowSize(IN OUT PFRONTEND This,
1109 PCOORD pSize)
1110{
1111 if (!pSize) return;
1112 *pSize = PhysicalConsoleSize;
1113}
1114
1115static BOOL NTAPI
1116TuiGetSelectionInfo(IN OUT PFRONTEND This,
1117 PCONSOLE_SELECTION_INFO pSelectionInfo)
1118{
1119 return TRUE;
1120}
1121
1122static BOOL NTAPI
1123TuiSetPalette(IN OUT PFRONTEND This,
1124 HPALETTE PaletteHandle,
1125 UINT PaletteUsage)
1126{
1127 return TRUE;
1128}
1129
1130static BOOL NTAPI
1131TuiSetCodePage(IN OUT PFRONTEND This,
1132 UINT CodePage)
1133{
1134 // PTUI_CONSOLE_DATA TuiData = This->Context;
1135
1136 // TODO: Verify that the console is the visible one.
1137 // Only then can we change the output code page font.
1138
1139 if (!TuiSetConsoleOutputCP(ConsoleDeviceHandle, CodePage))
1140 {
1141 DPRINT1("Failed to load the font for codepage %d\n", CodePage);
1142 /* Let's suppose the font is good enough to continue */
1143 return FALSE;
1144 }
1145
1146 return TRUE;
1147}
1148
1149static ULONG NTAPI
1150TuiGetDisplayMode(IN OUT PFRONTEND This)
1151{
1152 return CONSOLE_FULLSCREEN_HARDWARE; // CONSOLE_FULLSCREEN;
1153}
1154
1155static BOOL NTAPI
1156TuiSetDisplayMode(IN OUT PFRONTEND This,
1157 ULONG NewMode)
1158{
1159 // if (NewMode & ~(CONSOLE_FULLSCREEN_MODE | CONSOLE_WINDOWED_MODE))
1160 // return FALSE;
1161 return TRUE;
1162}
1163
1164static INT NTAPI
1165TuiShowMouseCursor(IN OUT PFRONTEND This,
1166 BOOL Show)
1167{
1168 return 0;
1169}
1170
1171static BOOL NTAPI
1172TuiSetMouseCursor(IN OUT PFRONTEND This,
1173 HCURSOR CursorHandle)
1174{
1175 return TRUE;
1176}
1177
1178static HMENU NTAPI
1179TuiMenuControl(IN OUT PFRONTEND This,
1180 UINT CmdIdLow,
1181 UINT CmdIdHigh)
1182{
1183 return NULL;
1184}
1185
1186static BOOL NTAPI
1187TuiSetMenuClose(IN OUT PFRONTEND This,
1188 BOOL Enable)
1189{
1190 return TRUE;
1191}
1192
1193static FRONTEND_VTBL TuiVtbl =
1194{
1195 TuiInitFrontEnd,
1196 TuiDeinitFrontEnd,
1197 TuiDrawRegion,
1198 TuiWriteStream,
1199 TuiRingBell,
1200 TuiSetCursorInfo,
1201 TuiSetScreenInfo,
1202 TuiResizeTerminal,
1203 TuiSetActiveScreenBuffer,
1204 TuiReleaseScreenBuffer,
1205 TuiRefreshInternalInfo,
1206 TuiChangeTitle,
1207 TuiChangeIcon,
1208 TuiGetThreadConsoleDesktop,
1209 TuiGetConsoleWindowHandle,
1210 TuiGetLargestConsoleWindowSize,
1211 TuiGetSelectionInfo,
1212 TuiSetPalette,
1213 TuiSetCodePage,
1214 TuiGetDisplayMode,
1215 TuiSetDisplayMode,
1216 TuiShowMouseCursor,
1217 TuiSetMouseCursor,
1218 TuiMenuControl,
1219 TuiSetMenuClose,
1220};
1221
1222static BOOLEAN
1224{
1226}
1227
1229TuiLoadFrontEnd(IN OUT PFRONTEND FrontEnd,
1231 IN OUT PCONSOLE_INIT_INFO ConsoleInitInfo,
1232 IN HANDLE ConsoleLeaderProcessHandle)
1233{
1234 if (FrontEnd == NULL || ConsoleInfo == NULL)
1236
1237 /* We must be in console mode already */
1238 if (!IsConsoleMode()) return STATUS_UNSUCCESSFUL;
1239
1240 /* Initialize the TUI terminal emulator */
1241 if (!TuiInit(ConsoleInfo->CodePage)) return STATUS_UNSUCCESSFUL;
1242
1243 /* Finally, initialize the frontend structure */
1244 FrontEnd->Vtbl = &TuiVtbl;
1245 FrontEnd->Context = NULL;
1246 FrontEnd->Context2 = NULL;
1247
1248 return STATUS_SUCCESS;
1249}
1250
1252TuiUnloadFrontEnd(IN OUT PFRONTEND FrontEnd)
1253{
1254 if (FrontEnd == NULL) return STATUS_INVALID_PARAMETER;
1255 if (FrontEnd->Context) TuiDeinitFrontEnd(FrontEnd);
1256
1257 return STATUS_SUCCESS;
1258}
1259
1260#endif
1261
1262/* EOF */
NTSTATUS NTAPI NtUnmapViewOfSection(IN HANDLE ProcessHandle, IN PVOID BaseAddress)
Definition: section.c:3848
NTSTATUS NTAPI NtCreateSection(OUT PHANDLE SectionHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN PLARGE_INTEGER MaximumSize OPTIONAL, IN ULONG SectionPageProtection OPTIONAL, IN ULONG AllocationAttributes, IN HANDLE FileHandle OPTIONAL)
Definition: section.c:3441
NTSTATUS NTAPI NtMapViewOfSection(IN HANDLE SectionHandle, IN HANDLE ProcessHandle, IN OUT PVOID *BaseAddress, IN ULONG_PTR ZeroBits, IN SIZE_T CommitSize, IN OUT PLARGE_INTEGER SectionOffset OPTIONAL, IN OUT PSIZE_T ViewSize, IN SECTION_INHERIT InheritDisposition, IN ULONG AllocationType, IN ULONG Protect)
Definition: section.c:3622
NTSTATUS NtUnloadDriver(IN PUNICODE_STRING DriverServiceName)
Definition: driver.c:2208
static USHORT USHORT * NewLength
unsigned char BOOLEAN
CConsole Console
char * strchr(const char *String, int ch)
Definition: utclib.c:501
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
static UINT LastLoadedCodepage
Definition: console.c:43
static LPHIST_ENTRY Bottom
Definition: history.c:54
static DWORD ScmUnloadDriver(PSERVICE lpService)
Definition: driver.c:77
static DWORD ScmLoadDriver(PSERVICE lpService)
Definition: driver.c:24
struct _COORD * PCOORD
struct _COORD COORD
#define FOREGROUND_GREEN
Definition: blue.h:62
#define FOREGROUND_BLUE
Definition: blue.h:61
#define FOREGROUND_RED
Definition: blue.h:63
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
#define CAB_VERSION
Definition: cabinet.c:50
#define CAB_SIGNATURE
Definition: cabinet.c:49
struct _CFHEADER * PCFHEADER
struct _CFFILE * PCFFILE
#define _stricmp
Definition: cat.c:22
Definition: bufpool.h:45
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
HINSTANCE ConSrvDllInstance
Definition: init.c:21
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
BOOL WINAPI Beep(IN DWORD dwFreq, IN DWORD dwDuration)
Definition: deviceio.c:48
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
WORD ATOM
Definition: dimm.idl:113
#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
static const WCHAR Title[]
Definition: oid.c:1259
#define CloseHandle
Definition: compat.h:739
#define PAGE_READONLY
Definition: compat.h:138
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
#define CALLBACK
Definition: compat.h:35
#define WideCharToMultiByte
Definition: compat.h:111
#define FILE_SHARE_READ
Definition: compat.h:136
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define ConioRectWidth(Rect)
Definition: readwrite.c:24
#define ConioRectHeight(Rect)
Definition: readwrite.c:22
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
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 const WCHAR Message[]
Definition: register.c:74
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define InsertTailList(ListHead, Entry)
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
@ Success
Definition: eventcreate.c:712
struct _FileName FileName
Definition: fatprocs.h:896
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
Status
Definition: gdiplustypes.h:25
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
static BOOL ConsInitialized
Definition: guiterm.c:45
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
@ ConsoleAcquireDisplayOwnership
Definition: ntuser.h:1801
DWORD_PTR NTAPI NtUserCallNoParam(DWORD Routine)
Definition: simplecall.c:59
#define NOPARAM_ROUTINE_ISCONSOLEMODE
Definition: ntuser.h:3574
NTSTATUS APIENTRY NtUserConsoleControl(IN CONSOLECONTROL ConsoleCtrl, IN PVOID ConsoleCtrlInfo, IN ULONG ConsoleCtrlInfoLength)
Definition: console.c:14
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
if(dx< 0)
Definition: linetemp.h:194
#define ASSERT(a)
Definition: mode.c:44
#define SE_LOAD_DRIVER_PRIVILEGE
Definition: security.c:664
static HICON
Definition: imagelist.c:84
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
unsigned int UINT
Definition: ndis.h:50
#define SEC_COMMIT
Definition: mmtypes.h:100
NTSYSAPI NTSTATUS NTAPI RtlAdjustPrivilege(_In_ ULONG Privilege, _In_ BOOLEAN NewValue, _In_ BOOLEAN ForThread, _Out_ PBOOLEAN OldValue)
HANDLE ScreenBuffer
Definition: notevil.c:37
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3952
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
#define SYNCHRONIZE
Definition: nt_native.h:61
#define SECTION_ALL_ACCESS
Definition: nt_native.h:1293
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define NtCurrentProcess()
Definition: nt_native.h:1657
NTSYSAPI NTSTATUS NTAPI NtDeviceIoControlFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG DeviceIoControlCode, IN PVOID InBuffer OPTIONAL, IN ULONG InBufferLength, OUT PVOID OutBuffer OPTIONAL, IN ULONG OutBufferLength)
@ ViewUnmap
Definition: nt_native.h:1279
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define FILE_ALL_ACCESS
Definition: nt_native.h:651
#define IOCTL_CONSOLE_DRAW
Definition: ntddblue.h:22
struct tagCONSOLE_DRAW CONSOLE_DRAW
#define IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER
Definition: ntddblue.h:20
#define IOCTL_CONSOLE_LOADFONT
Definition: ntddblue.h:24
#define IOCTL_CONSOLE_RESET_SCREEN
Definition: ntddblue.h:4
#define IOCTL_CONSOLE_SET_TEXT_ATTRIBUTE
Definition: ntddblue.h:16
#define IOCTL_CONSOLE_SET_SCREEN_BUFFER_INFO
Definition: ntddblue.h:7
#define IOCTL_CONSOLE_GET_SCREEN_BUFFER_INFO
Definition: ntddblue.h:6
#define IOCTL_CONSOLE_SET_CURSOR_INFO
Definition: ntddblue.h:9
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:142
NTSTATUS NTAPI NtLoadDriver(IN PUNICODE_STRING DriverServiceName)
Definition: driver.c:2147
#define STATUS_INVALID_BUFFER_SIZE
Definition: ntstatus.h:650
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
NTSTRSAFEVAPI RtlStringCbPrintfA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
Definition: ntstrsafe.h:1148
#define L(x)
Definition: ntvdm.h:50
#define TEXTMODE_BUFFER
Definition: pccons.c:21
#define LOWORD(l)
Definition: pedump.c:82
BYTE * PBYTE
Definition: pedump.c:66
short SHORT
Definition: pedump.c:59
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:159
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:162
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
static void Exit(void)
Definition: sock.c:1330
Definition: fci.c:89
Definition: fci.c:65
base of all file and directory entries
Definition: entries.h:83
USHORT FileControlID
Definition: cabinet.h:183
ULONG FileSize
Definition: cabinet.c:118
USHORT FileTime
Definition: cabinet.c:122
ULONG FileOffset
Definition: cabinet.c:119
USHORT FileDate
Definition: cabinet.c:121
USHORT Attributes
Definition: cabinet.c:123
USHORT Version
Definition: cabinet.c:88
USHORT SetID
Definition: cabinet.c:92
ULONG Reserved3
Definition: cabinet.c:87
ULONG Reserved1
Definition: cabinet.c:83
ULONG CabinetSize
Definition: cabinet.c:84
ULONG FileTableOffset
Definition: cabinet.c:86
USHORT FileCount
Definition: cabinet.c:90
USHORT FolderCount
Definition: cabinet.c:89
USHORT Flags
Definition: cabinet.c:91
USHORT CabinetNumber
Definition: cabinet.c:93
ULONG Signature
Definition: cabinet.c:82
ULONG Reserved2
Definition: cabinet.c:85
WCHAR UnicodeChar
Definition: wincon.h:184
WORD Attributes
Definition: wincon.h:187
union _CHAR_INFO::@3290 Char
COORD CursorPosition
Definition: conio.h:71
CONSOLE_CURSOR_INFO CursorInfo
Definition: conio.h:75
Definition: bl.h:1338
ULONG Y
Definition: bl.h:1340
ULONG X
Definition: bl.h:1339
Definition: typedefs.h:120
PCHAR_INFO Buffer
Definition: conio.h:129
LPCWSTR lpszClassName
Definition: winuser.h:3226
WNDPROC lpfnWndProc
Definition: winuser.h:3218
UINT cbSize
Definition: winuser.h:3216
int cbWndExtra
Definition: winuser.h:3220
HINSTANCE hInstance
Definition: winuser.h:3221
USHORT CursorY
Definition: ntddblue.h:56
USHORT SizeX
Definition: ntddblue.h:53
USHORT SizeY
Definition: ntddblue.h:54
USHORT CursorX
Definition: ntddblue.h:55
static CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo
Definition: video.c:47
static HPALETTE PaletteHandle
Definition: svga.c:215
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
VOID ConioDrawConsole(PCONSRV_CONSOLE Console)
Definition: terminal.c:860
const UIVTBL TuiVtbl
Definition: tui.c:1219
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
uint16_t * PWSTR
Definition: typedefs.h:56
char * PSTR
Definition: typedefs.h:51
#define NTAPI
Definition: typedefs.h:36
void * PVOID
Definition: typedefs.h:50
ULONG_PTR SIZE_T
Definition: typedefs.h:80
int32_t INT
Definition: typedefs.h:58
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
uint16_t * PWCHAR
Definition: typedefs.h:56
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define HIWORD(l)
Definition: typedefs.h:247
#define OUT
Definition: typedefs.h:40
char * PCHAR
Definition: typedefs.h:51
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_ ULONG _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesReturned
Definition: wdfiotarget.h:1052
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesWritten
Definition: wdfiotarget.h:960
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:127
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:36
#define ConsoleOutputUnicodeToAnsiChar(Console, dChar, sWChar)
Definition: text.c:25
PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y)
Definition: text.c:143
VOID NTAPI ConioProcessKey(PCONSRV_CONSOLE Console, MSG *msg)
Definition: input.c:60
DWORD ConioEffectiveCursorSize(PCONSRV_CONSOLE Console, DWORD Scale)
Definition: input.c:182
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
struct _TEXTMODE_SCREEN_BUFFER * PTEXTMODE_SCREEN_BUFFER
@ CONSOLE_RUNNING
Definition: conio.h:283
#define GetType(This)
Definition: conio.h:54
static BOOLEAN IsConsoleMode(VOID)
Definition: shutdown.c:392
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
struct _CHAR_INFO CHAR_INFO
#define CONSOLE_FULLSCREEN_HARDWARE
Definition: wincon.h:30
#define SHIFT_PRESSED
Definition: wincon.h:141
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
HICON HCURSOR
Definition: windef.h:299
#define VK_TAB
Definition: winuser.h:2199
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define WM_KEYUP
Definition: winuser.h:1716
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
#define KF_ALTDOWN
Definition: winuser.h:2449
BOOL WINAPI SetForegroundWindow(_In_ HWND)
#define WA_INACTIVE
Definition: winuser.h:2622
#define WM_ACTIVATE
Definition: winuser.h:1612
#define WM_SYSCHAR
Definition: winuser.h:1721
HWND WINAPI SetFocus(_In_opt_ HWND)
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
#define WM_SYSKEYUP
Definition: winuser.h:1720
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4316
#define WM_CHAR
Definition: winuser.h:1717
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
struct _WNDCLASSEXW WNDCLASSEXW
#define WM_KEYDOWN
Definition: winuser.h:1715
BOOL WINAPI DestroyWindow(_In_ HWND)
#define WM_SYSKEYDOWN
Definition: winuser.h:1719
#define VK_MENU
Definition: winuser.h:2204
#define RtlUnicodeStringToAnsiSize(String)
Definition: rtlfuncs.h:1005
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
char CHAR
Definition: xmlstorage.h:175
unsigned char BYTE
Definition: xxhash.c:193