Download presentation
Presentation is loading. Please wait.
Published byAurelia Bello Modified over 5 years ago
1
Console A presentation by Inti Vincenzo Pizzoni
2
What is a Console? Traditionally: computer terminal where a user may input commands and view output (i.e. results of inputted commands or status messages from the computer) Often connected to a remote computer or computer system that is controlled from the console A console traditionally refers to a computer terminal where a user may input commands and view output such as the results of inputted commands or status messages from the computer. It is often connected to a remote computer or computer system that is controlled from the console.
3
What was a Console? Early days of computers: usually only a few consoles available for computer systems such as a mainframe → the term "console" actually referred to the terminal from which the computer could be controlled. Now: computer screen and input devices of computers are referred to as separate objects, namely, the monitor and input devices, and not as a single console. The console no longer refers strictly to the monitor, but to a piece of software, such as a command prompt, where a user can input advanced commands. → Called a console because it is similar in function to the hardware console, which allows users advance use of the computer system it is attached to. In the early days of computers, there were usually only a few consoles available for a computer system such as a mainframe, meaning that the term "console" actually referred to the terminal from which the computer could be controlled. This term has since lost its original meaning, and people now refer to the computer screen and input devices of computers as separate objects, namely, the monitor and input devices, and not as a single console. In PC terms, the console no longer refers strictly to the monitor but to a piece of software, such as a command prompt, where a user can input advanced commands. This type of software is called a console because it is similar in function to the hardware console, which allows users advance use of the computer system it is attached to.
4
Components of a Console
Console: input buffer + one or more screen buffers. The input buffer contains a queue of input records, each of which contains information about an input event. The input queue always includes key-press and key-release events. It can also include mouse events (pointer movements and button presses and releases) and events during which user actions affect the size of the active screen buffer. A screen buffer is a two-dimensional array of character and color data for output in a console window. Any number of processes can share a console. A console consists of an input buffer and one or more screen buffers. The input buffer contains a queue of input records, each of which contains information about an input event. The input queue always includes key-press and key-release events. It can also include mouse events (pointer movements and button presses and releases) and events during which user actions affect the size of the active screen buffer. A screen buffer is a two-dimensional array of character and color data for output in a console window. Any number of processes can share a console.
5
Creating a Console The system creates a new console when it starts a console process, a character-mode process whose entry point is the main function. A process can create a console by using one of the following methods: A graphical user interface (GUI) or console process can use the CreateProcess function with CREATE_NEW_CONSOLE to create a console process with a new console. A GUI or console process that is not currently attached to a console can use the AllocConsole function to create a new console. Usually by default a console process inherits its parent's console, while GUI processes are not attached to a console when they are created.
6
Creating a New Console C BOOL CreateProcessA (
LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation ); The function CreateProcess Creates a new process and its primary thread. The new process runs in the security context of the calling process. Here we have to specify the CREATE_NEW_CONSOLE flag When a process uses CreateProcess, it can specify a STARTUPINFO structure, whose members control the characteristics of the first new console created for the child process.
7
Creating a New Console C typedef struct _STARTUPINFOA { DWORD cb; LPSTR lpReserved; LPSTR lpDesktop; LPSTR lpTitle; DWORD dwX; DWORD dwY; DWORD dwXSize; DWORD dwYSize; DWORD dwXCountChars; DWORD dwYCountChars; DWORD dwFillAttribute; DWORD dwFlags; WORD wShowWindow; WORD cbReserved2; LPBYTE lpReserved2; HANDLE hStdInput; HANDLE hStdOutput; HANDLE hStdError; } STARTUPINFOA, *LPSTARTUPINFOA; The STARTUPINFO structure specified in the call to CreateProcess affects a console created if the CREATE_NEW_CONSOLE flag is specified. It also affects a console created if the child process subsequently uses AllocConsole. The following console characteristics can be specified: Size of the new console window, in character cells. Location of the new console window, in screen pixel coordinates. Size of the new console's screen buffer, in character cells. Text and background color attributes of the new console's screen buffer. Display name for the title bar of the new console's window.
8
Attaching to a Console A process can use the AttachConsole function to attach to a console. A process can be attached to one console. C BOOL WINAPI AttachConsole( _In_ DWORD dwProcessId ); This function has one parameter: dwProcessId [in] which is the identifier of the process whose console is to be used. This parameter can be the pid to use the console of the specified process or ATTACH_PARENT_PROCESS (DWORD)-1 to use the console of the parent of the current process. If the function succeeds, the return value is nonzero, otherwise If the function fails, the return value is zero. A console can have many processes attached to it. To retrieve a list of the processes attached to a console, call the GetConsoleProcessList function.
9
Closing a Console A process can use the FreeConsole function to detach itself from its console. C BOOL WINAPI FreeConsole(void); This function has no parameters and succeeds, the return value is nonzero, otherwise If the function fails, the return value is zero. If other processes share the console, the console is not destroyed, but the process that called FreeConsole cannot refer to it. After calling FreeConsole, the process can use AllocConsole to create a new console or AttachConsole to attach to another console. A console is closed when the last process attached to it terminates or calls FreeConsole.
10
Thank you for your attention!
11
Sources https://docs.microsoft.com/en-us/windows/console
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.