Windows Console

Last updated

Other namesWin32 console
Developer(s) Microsoft
Repository github.com/microsoft/terminal/tree/main/src/host
Written in C++
Operating system Microsoft Windows
Platform IA-32, x86-64, ARM64
Type Terminal emulator
License MIT License
Website docs.microsoft.com/en-us/windows/console/

Windows Console is the infrastructure for console applications in Microsoft Windows. An instance of a Windows Console has a screen buffer and an input buffer. It allows console apps to run inside a window or in hardware text mode (so as to occupy the entire screen). The user can switch between the two using the Alt+↵ Enter key combination. The text mode is unavailable in Windows Vista and later. Starting with Windows 10, however, a native full-screen mode is available.

Contents

Windows Console instances are typically used for apps that do not need to display images but might use color. Examples include cmd.exe, Windows PowerShell, Far Manager, and Midnight Commander.

In 2019, the console host was open-sourced under the MIT License, alongside Windows Terminal. [1]

Window and full screen modes

Windows PowerShell on Windows Vista Windows PowerShell 1.0 PD.png
Windows PowerShell on Windows Vista
Midnight Commander using box-drawing characters GNU Midnight Commander 4.1.36 Windows Vista.png
Midnight Commander using box-drawing characters

In Windows, a console application may run in two modes.

One mode places the text in a window and uses an operating system's font rendering. In this mode, an application's interaction with user is controlled by the windowing system. This is analogous to X Window System applications such as xterm.

The second is the full-screen mode. In Windows XP and earlier, the full-screen console uses a hardware text mode and uploads a raster font to the video adapter. This is analogous to a text system console. This early full-screen mode only supports VGA-compatible text modes, giving it a maximum character resolution of 80 columns by 28 rows. [2] This mode was deprecated in Windows Vista. [3] It was possible to circumvent this issue by installing a Windows XP display driver; [3] however, Windows 8 and later do not accept them. [4] Windows 10 features a full-screen mode once again, but this implementation uses the native Windows rendering subsystem, instead of the text mode. It can have as many columns and rows as fits on the screen. [5]

Apps can be made to switch between the two modes using the Alt+↵ Enter key combination.

Details

The input buffer is a queue where events are stored (from keyboard, mouse etc.). The output buffer is a rectangular grid where characters are stored, together with their attributes. A console window may have several output buffers, only one of which is active (i.e. displayed) for a given moment. Apps may programmatically interact with Windows Console through Windows API, which exposes both high-level functions (such as ReadConsole and WriteConsole) and low-level functions (e.g. ReadConsoleInput and WriteConsoleOutput). [6]

Users can change the color palette or font, either on the system-wide level or app-level. Each instance of a console app themselves, however, cannot change its color palette or font on the fly.

Windows Console apps are distinct from MS-DOS apps, even though on Windows (especially on Windows 9x), they may not look different. Windows Console apps have access to entire Windows API and do not run on MS-DOS or compatible operating systems. DOS apps, however, cannot access Windows API and may only run on 32-bit versions of Windows with the aid of Virtual DOS machine (VDM).

Implementations

Prior to Windows 95, there is no native support for consoles. Because Windows 3.1 and earlier are merely a graphical interface for MS-DOS, most text programs that ran on earlier Windows versions were actually MS-DOS programs running in a window. To simplify the task of porting applications to Windows, early versions of Visual C++ are supplied with QuickWin, a library that implements basic console functionality inside a regular window. A similar library for Borland C++ was called EasyWin.

Windows 9x

Command.com running in a Windows console on Windows 95 Microsoft Windows 95 Version 4.00.1111 command.com MS-DOS Prompt 492x259.png
Command.com running in a Windows console on Windows 95

Windows 9x support is relatively poor compared to Windows NT, because the console window runs in the system virtual DOS machine and so keyboard input to a Win32 console application had to be directed to it by conagent.exe running in a DOS VM that are also used for real DOS applications by hooking the keyboard interrupt. conagent.exe then calls Vcond (which is a VxD). Vcond then had to pass the keyboard input to the System VM, and then finally to the Win32 console application. Besides performance, another problem with this implementation is that drives that are local to a DOS VM are not visible to a Win32 console application. This can cause confusion.

Under Windows 9x, the screen buffer mirrors the structure of VGA text buffer, with two bytes per character cell: one byte for character code, one byte for attributes (the character must be in OEM character set, the attribute is with high-intensity background/no blinking). This speeds up operation considerably if the actual VGA text mode is used.

Windows NT and Windows CE

The Windows Subsystem for Linux running Bash on Windows 10 Ubuntu on Windows 10 - bash.png
The Windows Subsystem for Linux running Bash on Windows 10
Cmd.exe running on Windows CE 3.0 Microsoft Windows CE Version 3.0 (Build 126) cmd.exe Command Prompt 800x574.png
Cmd.exe running on Windows CE 3.0

Traditionally, the Client/Server Runtime Subsystem (CSRSS) has been responsible for managing console windows on the Windows NT family of operating systems. [7] In Windows 7, CSRSS spawns one conhost.exe for each console window, to manage it. In Windows 8 and later, the console apps spawn their conhost.exe processes directly. This change has both security and usability implications. While CSRSS runs in a highly privileged security context, each conhost.exe runs in the same security context as the console app. In addition, in Windows 7, this change enabled console windows to have the features of the Aero Glass theme. [8]

On Windows NT and Windows CE, the screen buffer uses four bytes per character cell: two bytes for character code, two bytes for attributes. The character is then encoded in a 16-bit subset of Unicode (UCS-2). [9] For backward compatibility, the console APIs exist in two versions: Unicode and non-Unicode. The non-Unicode versions of APIs can use code page switching to extend the range of displayed characters (but only if TrueType fonts are used for the console window, thereby extending the range of codes available). Even UTF-8 is available as "code page 65001" [10] (displaying only from the UCS-2 subset of full Unicode[ citation needed ]).

As of the Windows 10 October 2018 update, the Windows Console has full Unicode support. [11]

See also

Related Research Articles

<span class="mw-page-title-main">Scroll Lock</span> Computer key

Scroll Lock is a lock key on most IBM-compatible computer keyboards.

<span class="mw-page-title-main">ANSI escape code</span> Method used for display options on video text terminals

ANSI escape sequences are a standard for in-band signaling to control cursor location, color, font styling, and other options on video text terminals and terminal emulators. Certain sequences of bytes, most starting with an ASCII escape character and a bracket character, are embedded into text. The terminal interprets these sequences as commands, rather than text to display verbatim.

<span class="mw-page-title-main">Windows API</span> Microsofts core set of application programming interfaces on Windows

The Windows API, informally WinAPI, is Microsoft's core set of application programming interfaces (APIs) available in the Microsoft Windows operating systems. The name Windows API collectively refers to several different platform implementations that are often referred to by their own names. Almost all Windows programs interact with the Windows API. On the Windows NT line of operating systems, a small number use the Native API.

<span class="mw-page-title-main">Windows Notepad</span> Simple text editor included with Microsoft Windows

Windows Notepad is a simple text editor for Windows; it creates and edits plain text documents. First released in 1983 to commercialize the computer mouse in MS-DOS, Notepad has been part of every version of Windows ever since.

<span class="mw-page-title-main">Text-based user interface</span> Type of interface based on outputting to or controlling a text display

In computing, text-based user interfaces (TUI), is a retronym describing a type of user interface (UI) common as an early form of human–computer interaction, before the advent of bitmapped displays and modern conventional graphical user interfaces (GUIs). Like modern GUIs, they can use the entire screen area and may accept mouse and other inputs. They may also use color and often structure the display using box-drawing characters such as ┌ and ╣. The modern context of use is usually a terminal emulator.

Text mode is a computer display mode in which content is internally represented on a computer screen in terms of characters rather than individual pixels. Typically, the screen consists of a uniform rectangular grid of character cells, each of which contains one of the characters of a character set; at the same time, contrasted to graphics mode or other kinds of computer graphics modes.

<span class="mw-page-title-main">DOS/V</span> Variant of PC DOS/MS-DOS developed for Japan

DOS/V is a Japanese computing initiative starting in 1990 to allow DOS on IBM PC compatibles with VGA cards to handle double-byte (DBCS) Japanese text via software alone. It was initially developed from PC DOS by IBM for its PS/55 machines, but IBM gave the driver source code to Microsoft, who then licensed a DOS/V-compatible version of MS-DOS to other companies. Kanji fonts and other locale information are stored on the hard disk rather than on special chips as in the preceding AX architecture. As with AX, its great value for the Japanese computing industry is in allowing compatibility with foreign software. This had not been possible under NEC's proprietary PC-98 system, which was the market leader before DOS/V emerged. DOS/V stands for "Disk Operating System/VGA". In Japan, IBM compatible PCs became popular along with DOS/V, so they are often referred to as "DOS/V machine" or "DOS/V pasocom" even though DOS/V operating systems are no longer common.

ANSI.SYS is a device driver in the DOS family of operating systems that provides extra console functions through ANSI escape sequences. It is partially based upon a subset of the text terminal control standard proposed by the ANSI X3L2 Technical Committee on Codes and Character Sets.

The Native API is a lightweight application programming interface (API) used by Windows NT and user mode applications. This API is used in the early stages of Windows NT startup process, when other components and APIs are still unavailable. Therefore, a few Windows components, such as the Client/Server Runtime Subsystem (CSRSS), are implemented using the Native API. The Native API is also used by subroutines such as those in kernel32.dll that implement the Windows API, the API based on which most of the Windows components are created.

<span class="mw-page-title-main">Character Map (Windows)</span> Windows utility displaying characters in a font

Character Map is a utility included with Microsoft Windows operating systems and is used to view the characters in any installed font, to check what keyboard input is used to enter those characters, and to copy characters to the clipboard in lieu of typing them. Other operating systems have apps which do the same things that Character Map does; for example, Apple MacOS Character Viewer.

The Session Manager Subsystem, or smss.exe, is a component of the Microsoft Windows NT family of operating systems, starting in Windows NT 3.1. It is executed during the startup process of those operating systems.

The Microsoft Windows operating system supports a form of shared libraries known as "dynamic-link libraries", which are code libraries that can be used by multiple processes while only one copy is loaded into memory. This article provides an overview of the core libraries that are included with every modern Windows installation, on top of which most Windows applications are built.

Client Server Runtime Subsystem, or csrss.exe, is a component of the Windows NT family of operating systems that provides the user mode side of the Win32 subsystem and is included in Windows NT 3.1 and later. Because most of the Win32 subsystem operations have been moved to kernel mode drivers in Windows NT 4 and later, CSRSS is mainly responsible for Win32 console handling and GUI shutdown. It is critical to system operation; therefore, terminating this process will result in system failure. Under normal circumstances, CSRSS cannot be terminated with the taskkill command or with Windows Task Manager, although it is possible in Windows Vista if the Task Manager is run in Administrator mode. On Windows 7 and later, Task Manager will inform the user that terminating the process may result in system failure, and prompt if they want to continue. In Windows NT 4.0 however, terminating CSRSS without the Session Manager Subsystem (SMSS) watching will not crash the system. However, in Windows XP, terminating CSRSS without SMSS watching will crash the system due to the critical bit being set in RAM for csrss.exe.

The SemWare Editor (TSE) is a text editor computer program for MS-DOS, OS/2, Windows and Linux.

A batch file is a script file in DOS, OS/2 and Microsoft Windows. It consists of a series of commands to be executed by the command-line interpreter, stored in a plain text file. A batch file may contain any command the interpreter accepts interactively and use constructs that enable conditional branching and looping within the batch file, such as IF, FOR, and GOTO labels. The term "batch" is from batch processing, meaning "non-interactive execution", though a batch file might not process a batch of multiple data.

<span class="mw-page-title-main">Linux console</span> Console of the Linux kernel

The Linux console is a system console internal to the Linux kernel. A system console is the device which receives all kernel messages and warnings and which allows logins in single user mode. The Linux console provides a way for the kernel and other processes to send text output to the user, and to receive text input from the user. The user typically enters text with a computer keyboard and reads the output text on a computer monitor. The Linux kernel supports virtual consoles – consoles that are logically separate, but which access the same physical keyboard and display. The Linux console are implemented by the VT subsystem of the Linux kernel, and do not rely on any user space software. This is in contrast to a terminal emulator, which is a user space process that emulates a terminal, and is typically used in a graphical display environment.

<span class="mw-page-title-main">VGA text mode</span> Computer graphics standard from 1987

VGA text mode was introduced in 1987 by IBM as part of the VGA standard for its IBM PS/2 computers. Its use on IBM PC compatibles was widespread through the 1990s and persists today for some applications on modern computers. The main features of VGA text mode are colored characters and their background, blinking, various shapes of the cursor, and loadable fonts. The Linux console traditionally uses hardware VGA text modes, and the Win32 console environment has an ability to switch the screen to text mode for some text window sizes.

<span class="mw-page-title-main">Architecture of Windows 9x</span>

The Windows 9x series of operating systems refers to the monolithic kernel which powers these operating systems. The basic code is similar in function to MS-DOS. As a 16-/32-bit hybrid, it requires support from MS-DOS to operate.

Microsoft was one of the first companies to implement Unicode in their products. Windows NT was the first operating system that used "wide characters" in system calls. Using the UCS-2 encoding scheme at first, it was upgraded to the variable-width encoding UTF-16 starting with Windows 2000, allowing a representation of additional planes with surrogate pairs. However Microsoft did not support UTF-8 in its API until May 2019.

References

  1. Cinnamon, Kayla (May 6, 2019). "Introducing Windows Terminal". Windows Command Line Tools For Developers. Microsoft . Retrieved May 10, 2019.
  2. Julio Sanchez; Maria P. Canton (2003), "VGA Fundamentals, Part II: DOS Graphics", The PC Graphics Handbook (for C++ Programmers) (Book), CRC Press, p. 125, ISBN   0849316782
  3. 1 2 "Some 16-bit DOS-based Programs and the Command Prompt will not run in full-screen mode in Windows Vista and in Windows 7". Support. Microsoft. September 23, 2011.
  4. "Roadmap for Developing Drivers for the Windows 2000 Display Driver Model (XDDM)". Windows Dev Center - Hardware. Microsoft. November 16, 2013. Retrieved December 16, 2013. XDDM and VGA drivers will not compile on Windows 8 and later versions
  5. Tkachenko, Sergey (November 24, 2014). "Open command prompt fullscreen in Windows 10". Winaero. Retrieved July 31, 2019.
  6. "Console Modes". Windows Console documentation. Microsoft . Retrieved October 13, 2020 via Microsoft Docs.
  7. Microsoft Security Advisory (930181): Exploit Code Published Affecting Windows Client Server Run-Time Subsystem
  8. Yosifovich, Pavel; Ionescu, Alex; Russinovich, Mark E.; Solomon, David A. (May 15, 2017). Windows Internals, Part 1: System architecture, processes, threads, memory management, and more (7th ed.). Redmond, Washington: Microsoft Press. p. 67. ISBN   9780735684188.
  9. "Console Reference". Microsoft. 2009. Retrieved January 1, 2010.
  10. "Release Notes". docs.microsoft.com. Console: Fix for no output text being displayed in codepage 65001 (utf8)
  11. Turner, Rich (November 15, 2018). "Windows Command-Line: Unicode and UTF-8 Output Text Buffer". Windows Command Line Tools For Developers. Microsoft. Retrieved June 14, 2019.