24#define CONGUI_UPDATE_TIME 0
25#define CONGUI_UPDATE_TIMER 1
27#define PM_CREATE_CONSOLE (WM_APP + 1)
28#define PM_DESTROY_CONSOLE (WM_APP + 2)
125 DesktopConsoleThreadInfo.
ThreadId = InputThreadId;
127 &DesktopConsoleThreadInfo,
128 sizeof(DesktopConsoleThreadInfo));
133 if (pcsrt ==
NULL)
goto Quit;
154 DPRINT(
"PM_CREATE_CONSOLE -- creating window\n");
168 if (NewWindow ==
NULL)
170 DPRINT1(
"Failed to create a new console window\n");
205 DPRINT(
"PM_CREATE_CONSOLE -- showing window\n");
210 DPRINT(
"PM_CREATE_CONSOLE -- hidden window\n");
243 DPRINT(
"CONSRV: Going to quit the Input Thread 0x%p\n", InputThreadId);
256 DPRINT(
"CONSRV: Quit the Input Thread 0x%p, Status = 0x%08lx\n", InputThreadId,
Status);
260 DesktopConsoleThreadInfo.
ThreadId = 0;
262 &DesktopConsoleThreadInfo,
263 sizeof(DesktopConsoleThreadInfo));
272 DPRINT1(
"WARNING!! hThread (0x%p) != pcsrt->ThreadHandle (0x%p), you may expect crashes soon!!\n",
hThread, pcsrt->
ThreadHandle);
285 IN HANDLE ConsoleLeaderProcessHandle,
319 if (ConsoleInitInfo->DesktopLength)
323 DesktopPath.
Buffer = ConsoleInitInfo->Desktop;
334 DPRINT(
"NtUserResolveDesktop(DesktopPath = '%wZ') returned hDesk = 0x%p; hWinSta = 0x%p\n",
335 &DesktopPath, hDesk, hWinSta);
348 &DesktopConsoleThreadInfo,
349 sizeof(DesktopConsoleThreadInfo));
350 DPRINT(
"NtUserConsoleControl returned ThreadId = 0x%p\n", DesktopConsoleThreadInfo.
ThreadId);
356 GuiInitInfo->WinSta = hWinSta;
357 GuiInitInfo->Desktop = hDesk;
362 if (DesktopConsoleThreadInfo.
ThreadId != 0)
365 DPRINT(
"Using input thread InputThreadId = 0x%p\n", DesktopConsoleThreadInfo.
ThreadId);
366 GuiInitInfo->InputThreadId = DesktopConsoleThreadInfo.
ThreadId;
395 (
PHANDLE)&GuiInitInfo->Desktop,
421 DPRINT(
"Thread creation hInputThread = 0x%p, InputThreadId = 0x%p, Status = 0x%08lx\n",
427 if (hInputThread)
NtClose(hInputThread);
433 NtClose(GuiInitInfo->GuiThreadStartupEvent);
435 DPRINT1(
"CONSRV: Failed to create graphics console thread.\n");
444 NtClose(GuiInitInfo->GuiThreadStartupEvent);
451 GuiInitInfo->WinSta = hWinSta;
452 GuiInitInfo->Desktop = hDesk;
491 GuiInitInfo =
This->Context2;
497 DPRINT1(
"CONSRV: Failed to create GUI_CONSOLE_DATA\n");
556 This->Context = GuiData;
571 DPRINT(
"GUI - Checkpoint\n");
578 DPRINT(
"OK we created the console window\n");
585 DPRINT(
"GuiInitConsole - We failed at creating a new terminal window\n");
598 DPRINT(
"Send PM_DESTROY_CONSOLE message and wait on hGuiTermEvent...\n");
601 DPRINT(
"hGuiTermEvent set\n");
608 DPRINT(
"Destroying icons !! - GuiData->hIcon = 0x%p ; ghDefaultIcon = 0x%p ; GuiData->hIconSm = 0x%p ; ghDefaultIconSm = 0x%p\n",
612 DPRINT(
"Destroy hIcon\n");
617 DPRINT(
"Destroy hIconSm\n");
625 DPRINT(
"Quit GuiDeinitFrontEnd\n");
651 SHORT CursorEndX, CursorEndY;
662 if (0 != ScrolledLines)
681 if (CursorStartX < Region->Left ||
Region->Right < CursorStartX
682 || CursorStartY < Region->
Top ||
Region->Bottom < CursorStartY)
689 if ((CursorEndX < Region->Left ||
Region->Right < CursorEndX
690 || CursorEndY < Region->
Top ||
Region->Bottom < CursorEndY)
691 && (CursorEndX != CursorStartX || CursorEndY != CursorStartY))
784 DPRINT(
"GuiSetActiveScreenBuffer using palette 0x%p\n", hPalette);
883 if (IconHandle ==
NULL)
911 DPRINT(
"Set icons in GuiChangeIcon\n");
942 UINT WidthUnit, HeightUnit;
950 MonitorInfo.
cbSize =
sizeof(MonitorInfo);
982 WidthUnit = HeightUnit = 1;
1001 if (pSelectionInfo ==
NULL)
return FALSE;
1003 ZeroMemory(pSelectionInfo,
sizeof(*pSelectionInfo));
1016 HPALETTE OldPalette;
1059 DPRINT1(
"Failed to initialize font '%S' for code page %d - Refuse CP change\n",
1211 IN HANDLE ConsoleLeaderProcessHandle)
1220 ConsoleStartInfo = ConsoleInitInfo->ConsoleStartInfo;
1230 if (!
GuiInit(ConsoleInitInfo, ConsoleLeaderProcessHandle, GuiInitInfo))
1243 sizeof(UserObjectFlags),
1269 if ((ConsoleStartInfo->dwStartupFlags & STARTF_TITLEISLINKNAME) == 0)
1289 ConsoleInfo->WindowPosition.x = ConsoleStartInfo->dwWindowOrigin.X;
1290 ConsoleInfo->WindowPosition.y = ConsoleStartInfo->dwWindowOrigin.Y;
1318 GuiInitInfo->
hIcon = ConsoleStartInfo->hIcon;
1323 GuiInitInfo->
hIconSm = ConsoleStartInfo->hIconSm;
1331 FrontEnd->Context =
NULL;
1332 FrontEnd->Context2 = GuiInitInfo;
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))
PCONSOLE_SCREEN_BUFFER ConDrvGetActiveScreenBuffer(IN PCONSOLE Console)
HINSTANCE ConSrvDllInstance
BOOL InitFonts(_Inout_ PGUI_CONSOLE_DATA GuiData, _In_reads_or_z_(LF_FACESIZE) PCWSTR FaceName, _In_ ULONG FontWeight, _In_ ULONG FontFamily, _In_ COORD FontSize, _In_opt_ UINT CodePage, _In_ BOOL UseDefaultFallback)
#define PM_RESIZE_TERMINAL
struct _GUI_CONSOLE_DATA * PGUI_CONSOLE_DATA
#define PM_CONSOLE_SET_TITLE
BOOLEAN NTAPI CsrImpersonateClient(IN PCSR_THREAD CsrThread)
BOOLEAN NTAPI CsrRevertToSelf(VOID)
VOID NTAPI CsrDereferenceThread(IN PCSR_THREAD CsrThread)
PCSR_THREAD NTAPI CsrAddStaticServerThread(IN HANDLE hThread, IN PCLIENT_ID ClientId, IN ULONG ThreadFlags)
PCSR_THREAD NTAPI CsrConnectToUser(VOID)
#define NT_SUCCESS(StatCode)
#define INVALID_HANDLE_VALUE
#define InterlockedExchangePointer(Target, Value)
VOID SwitchFullScreen(PGUI_CONSOLE_DATA GuiData, BOOL FullScreen)
GLint GLint GLint GLint GLint x
GLint GLint GLint GLint GLint GLint y
BOOL GuiConsoleReadUserSettings(IN OUT PGUI_CONSOLE_INFO TermInfo)
VOID GuiConsoleGetDefaultSettings(IN OUT PGUI_CONSOLE_INFO TermInfo)
static VOID NTAPI GuiReleaseScreenBuffer(IN OUT PFRONTEND This, IN PCONSOLE_SCREEN_BUFFER ScreenBuffer)
VOID NTAPI GuiRingBell(IN OUT PFRONTEND This)
VOID CreateSysMenu(HWND hWnd)
static BOOL NTAPI GuiSetCodePage(IN OUT PFRONTEND This, UINT CodePage)
BOOLEAN UnRegisterConWndClass(HINSTANCE hInstance)
static VOID NTAPI GuiResizeTerminal(IN OUT PFRONTEND This)
static BOOL NTAPI GuiSetMouseCursor(IN OUT PFRONTEND This, HCURSOR CursorHandle)
static ULONG NTAPI GuiGetDisplayMode(IN OUT PFRONTEND This)
#define CONGUI_UPDATE_TIME
static VOID NTAPI GuiWriteStream(IN OUT PFRONTEND This, SMALL_RECT *Region, SHORT CursorStartX, SHORT CursorStartY, UINT ScrolledLines, PWCHAR Buffer, UINT Length)
static HDESK NTAPI GuiGetThreadConsoleDesktop(IN OUT PFRONTEND This)
NTSTATUS NTAPI GuiLoadFrontEnd(IN OUT PFRONTEND FrontEnd, IN OUT PCONSOLE_STATE_INFO ConsoleInfo, IN OUT PCONSOLE_INIT_INFO ConsoleInitInfo, IN HANDLE ConsoleLeaderProcessHandle)
VOID InvalidateCell(PGUI_CONSOLE_DATA GuiData, SHORT x, SHORT y)
static BOOL NTAPI GuiChangeIcon(IN OUT PFRONTEND This, HICON IconHandle)
static ULONG NTAPI GuiConsoleInputThread(PVOID Param)
static VOID NTAPI GuiDrawRegion(IN OUT PFRONTEND This, SMALL_RECT *Region)
static BOOL ConsInitialized
static FRONTEND_VTBL GuiVtbl
static VOID DrawRegion(PGUI_CONSOLE_DATA GuiData, SMALL_RECT *Region)
static HMENU NTAPI GuiMenuControl(IN OUT PFRONTEND This, UINT CmdIdLow, UINT CmdIdHigh)
NTSTATUS NTAPI GuiUnloadFrontEnd(IN OUT PFRONTEND FrontEnd)
VOID SetConWndConsoleLeaderCID(IN PGUI_CONSOLE_DATA GuiData)
static VOID NTAPI GuiSetActiveScreenBuffer(IN OUT PFRONTEND This)
struct _GUI_INIT_INFO * PGUI_INIT_INFO
static INT NTAPI GuiShowMouseCursor(IN OUT PFRONTEND This, BOOL Show)
struct _GUI_INIT_INFO GUI_INIT_INFO
static BOOL NTAPI GuiSetMenuClose(IN OUT PFRONTEND This, BOOL Enable)
static NTSTATUS NTAPI GuiInitFrontEnd(IN OUT PFRONTEND This, IN PCONSRV_CONSOLE Console)
static BOOL GuiInit(IN PCONSOLE_INIT_INFO ConsoleInitInfo, IN HANDLE ConsoleLeaderProcessHandle, IN OUT PGUI_INIT_INFO GuiInitInfo)
static BOOL NTAPI GuiSetPalette(IN OUT PFRONTEND This, HPALETTE PaletteHandle, UINT PaletteUsage)
VOID GuiConsoleMoveWindow(PGUI_CONSOLE_DATA GuiData)
static VOID NTAPI GuiDeinitFrontEnd(IN OUT PFRONTEND This)
static BOOL NTAPI GuiSetDisplayMode(IN OUT PFRONTEND This, ULONG NewMode)
static BOOL NTAPI GuiGetSelectionInfo(IN OUT PFRONTEND This, PCONSOLE_SELECTION_INFO pSelectionInfo)
static VOID NTAPI GuiGetLargestConsoleWindowSize(IN OUT PFRONTEND This, PCOORD pSize)
static BOOL NTAPI GuiSetScreenInfo(IN OUT PFRONTEND This, PCONSOLE_SCREEN_BUFFER Buff, SHORT OldCursorX, SHORT OldCursorY)
static BOOL NTAPI GuiSetCursorInfo(IN OUT PFRONTEND This, PCONSOLE_SCREEN_BUFFER Buff)
static VOID NTAPI GuiChangeTitle(IN OUT PFRONTEND This)
BOOLEAN RegisterConWndClass(IN HINSTANCE hInstance)
static HWND NTAPI GuiGetConsoleWindowHandle(IN OUT PFRONTEND This)
#define PM_DESTROY_CONSOLE
static VOID NTAPI GuiRefreshInternalInfo(IN OUT PFRONTEND This)
#define PM_CREATE_CONSOLE
#define CONGUI_UPDATE_TIMER
FORCEINLINE VOID SmallRectToRect(PGUI_CONSOLE_DATA GuiData, PRECT Rect, PSMALL_RECT SmallRect)
FORCEINLINE VOID GetScreenBufferSizeUnits(IN PCONSOLE_SCREEN_BUFFER Buffer, IN PGUI_CONSOLE_DATA GuiData, OUT PUINT WidthUnit, OUT PUINT HeightUnit)
@ ConsoleCtrlDesktopConsoleThread
NTSTATUS APIENTRY NtUserConsoleControl(IN CONSOLECONTROL ConsoleCtrl, IN PVOID ConsoleCtrlInfo, IN ULONG ConsoleCtrlInfoLength)
HDESK NTAPI NtUserResolveDesktop(IN HANDLE ProcessHandle, IN PUNICODE_STRING DesktopPath, IN BOOL bInherit, OUT HWINSTA *phWinSta)
long __cdecl _InterlockedIncrement(_Interlocked_operand_ long volatile *_Addend)
long __cdecl _InterlockedDecrement(_Interlocked_operand_ long volatile *_Addend)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
HMONITOR WINAPI MonitorFromWindow(HWND, DWORD)
NTSYSAPI VOID NTAPI RtlExitUserThread(_In_ NTSTATUS Status)
NTSYSAPI NTSTATUS NTAPI RtlCreateUserThread(_In_ PVOID ThreadContext, _Out_ HANDLE *OutThreadHandle, _Reserved_ PVOID Reserved1, _Reserved_ PVOID Reserved2, _Reserved_ PVOID Reserved3, _Reserved_ PVOID Reserved4, _Reserved_ PVOID Reserved5, _Reserved_ PVOID Reserved6, _Reserved_ PVOID Reserved7, _Reserved_ PVOID Reserved8)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define NtCurrentProcess()
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
NTSYSAPI NTSTATUS NTAPI NtWaitForSingleObject(IN HANDLE hObject, IN BOOLEAN bAlertable, IN PLARGE_INTEGER Timeout)
_In_ ULONG _In_ ULONG _In_ ULONG Length
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
NTSTATUS NTAPI NtSetEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL)
NTSTATUS NTAPI NtCreateEvent(OUT PHANDLE EventHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN EVENT_TYPE EventType, IN BOOLEAN InitialState)
NTSTATUS NTAPI NtResumeThread(IN HANDLE ThreadHandle, OUT PULONG SuspendCount OPTIONAL)
NTSTATUS NTAPI NtDuplicateObject(IN HANDLE SourceProcessHandle, IN HANDLE SourceHandle, IN HANDLE TargetProcessHandle OPTIONAL, OUT PHANDLE TargetHandle OPTIONAL, IN ACCESS_MASK DesiredAccess, IN ULONG HandleAttributes, IN ULONG Options)
static VIDEODISPLAYMODE DisplayMode
#define WS_OVERLAPPEDWINDOW
STRSAFEAPI StringCchCopyNW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, size_t cchToCopy)
PCONSOLE_SCREEN_BUFFER ActiveBuffer
CONSOLE_SELECTION_INFO Selection
BOOL IsCloseButtonEnabled
BOOL HackCORE8394IgnoreNextMove
BOOL IgnoreNextMouseEvent
WCHAR FaceName[LF_FACESIZE]
GUI_CONSOLE_INFO TermInfo
HANDLE GuiThreadStartupEvent
static CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo
static HPALETTE PaletteHandle
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
TW_UINT32 TW_UINT16 TW_UINT16 MSG
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define STATUS_INVALID_PARAMETER
#define STATUS_UNSUCCESSFUL
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
_In_ HFONT _Out_ PUINT Height
VOID InitTTFontCache(VOID)
Initializes the console TrueType font cache.
#define ConsoleAllocHeap(Flags, Size)
#define ConsoleFreeHeap(HeapBase)
#define STARTF_USEPOSITION
#define STARTF_USESHOWWINDOW
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
#define STARTF_RUNFULLSCREEN
#define CONSOLE_NO_SELECTION
#define CONSOLE_FULLSCREEN_MODE
#define CONSOLE_FULLSCREEN_HARDWARE
#define CONSOLE_WINDOWED_MODE
UINT WINAPI RealizePalette(_In_ HDC)
HPALETTE WINAPI SelectPalette(_In_ HDC, _In_ HPALETTE, _In_ BOOL)
HGDIOBJ WINAPI GetCurrentObject(_In_ HDC, _In_ UINT)
UINT WINAPI SetSystemPaletteUse(_In_ HDC, _In_ UINT)
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI SetThreadDesktop(_In_ HDESK)
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
HICON WINAPI CopyIcon(_In_ HICON)
BOOL WINAPI CloseWindowStation(_In_ HWINSTA)
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
BOOL WINAPI ShowWindowAsync(_In_ HWND, _In_ int)
BOOL WINAPI PeekMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
BOOL WINAPI PostThreadMessageW(_In_ DWORD, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
BOOL WINAPI GetUserObjectInformationW(_In_ HANDLE hObj, _In_ int nIndex, _Out_writes_bytes_opt_(nLength) PVOID pvInfo, _In_ DWORD nLength, _Out_opt_ LPDWORD lpnLengthNeeded)
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
BOOL WINAPI GetMonitorInfoW(_In_ HMONITOR, _Inout_ LPMONITORINFO)
BOOL WINAPI CloseDesktop(_In_ HDESK)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define SendNotifyMessage
BOOL WINAPI DestroyWindow(_In_ HWND)
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
int WINAPI ScrollWindowEx(_In_ HWND, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT, _In_opt_ HRGN, _Out_opt_ LPRECT, _In_ UINT)
int WINAPI GetSystemMetrics(_In_ int)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI DestroyIcon(_In_ HICON)
_Out_ PCLIENT_ID ClientId
#define DUPLICATE_SAME_ACCESS