ReactOS  0.4.14-dev-52-g6116262
conio.h File Reference
#include "rect.h"
#include "conio_winsrv.h"
Include dependency graph for conio.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _CONSOLE_IO_OBJECT
 
struct  _CONSOLE_SCREEN_BUFFER_VTBL
 
struct  _CONSOLE_SCREEN_BUFFER
 
struct  _TEXTMODE_BUFFER_INFO
 
struct  _TEXTMODE_SCREEN_BUFFER
 
struct  _GRAPHICS_BUFFER_INFO
 
struct  _GRAPHICS_SCREEN_BUFFER
 
struct  _CONSOLE_INPUT_BUFFER
 
struct  _CONSOLE_INFO
 
struct  _TERMINAL_VTBL
 
struct  _TERMINAL
 
struct  _CONSOLE
 

Macros

#define _CONSRV_CONSOLE   _CONSOLE
 
#define CONSRV_CONSOLE   CONSOLE
 
#define PCONSRV_CONSOLE   PCONSOLE
 
#define DEFAULT_SCREEN_ATTRIB   (FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED)
 
#define DEFAULT_POPUP_ATTRIB
 
#define GetType(This)   (This)->Vtbl->GetType(This)
 
#define GetConsoleInputBufferMode(Console)   (Console)->InputBuffer.Mode
 

Typedefs

typedef enum _CONSOLE_IO_OBJECT_TYPE CONSOLE_IO_OBJECT_TYPE
 
typedef struct _CONSOLE_IO_OBJECT CONSOLE_IO_OBJECT
 
typedef struct _CONSOLE_IO_OBJECTPCONSOLE_IO_OBJECT
 
typedef struct _CONSOLE_SCREEN_BUFFER CONSOLE_SCREEN_BUFFER
 
typedef struct _CONSOLE_SCREEN_BUFFERPCONSOLE_SCREEN_BUFFER
 
typedef struct _CONSOLE_SCREEN_BUFFER_VTBL CONSOLE_SCREEN_BUFFER_VTBL
 
typedef struct _CONSOLE_SCREEN_BUFFER_VTBLPCONSOLE_SCREEN_BUFFER_VTBL
 
typedef struct _TEXTMODE_BUFFER_INFO TEXTMODE_BUFFER_INFO
 
typedef struct _TEXTMODE_BUFFER_INFOPTEXTMODE_BUFFER_INFO
 
typedef struct _TEXTMODE_SCREEN_BUFFER TEXTMODE_SCREEN_BUFFER
 
typedef struct _TEXTMODE_SCREEN_BUFFERPTEXTMODE_SCREEN_BUFFER
 
typedef struct _GRAPHICS_BUFFER_INFO GRAPHICS_BUFFER_INFO
 
typedef struct _GRAPHICS_BUFFER_INFOPGRAPHICS_BUFFER_INFO
 
typedef struct _GRAPHICS_SCREEN_BUFFER GRAPHICS_SCREEN_BUFFER
 
typedef struct _GRAPHICS_SCREEN_BUFFERPGRAPHICS_SCREEN_BUFFER
 
typedef struct _CONSOLE_INPUT_BUFFER CONSOLE_INPUT_BUFFER
 
typedef struct _CONSOLE_INPUT_BUFFERPCONSOLE_INPUT_BUFFER
 
typedef struct _TERMINAL TERMINAL
 
typedef struct _TERMINALPTERMINAL
 
typedef struct _CONSOLE_INFO CONSOLE_INFO
 
typedef struct _CONSOLE_INFOPCONSOLE_INFO
 
typedef struct _TERMINAL_VTBL TERMINAL_VTBL
 
typedef struct _TERMINAL_VTBLPTERMINAL_VTBL
 
typedef enum _CONSOLE_STATE CONSOLE_STATE
 
typedef enum _CONSOLE_STATEPCONSOLE_STATE
 
typedef struct _CONSOLEPCONSOLE
 
typedef struct _CONSOLE CONSOLE
 

Enumerations

enum  _CONSOLE_IO_OBJECT_TYPE {
  UNKNOWN = 0x00, TEXTMODE_BUFFER = 0x01, GRAPHICS_BUFFER = 0x02, SCREEN_BUFFER = 0x03,
  INPUT_BUFFER = 0x04, ANY_TYPE_BUFFER = 0x07, TEXTMODE_BUFFER = 0x01, GRAPHICS_BUFFER = 0x02,
  SCREEN_BUFFER = 0x03, INPUT_BUFFER = 0x04
}
 
enum  _CONSOLE_STATE {
  CONSOLE_INITIALIZING, CONSOLE_RUNNING, CONSOLE_TERMINATING, CONSOLE_IN_DESTRUCTION,
  CONSOLE_INITIALIZING, CONSOLE_RUNNING, CONSOLE_TERMINATING, CONSOLE_IN_DESTRUCTION
}
 

Functions

VOID NTAPI ConDrvPause (PCONSOLE Console)
 
VOID NTAPI ConDrvUnpause (PCONSOLE Console)
 
NTSTATUS ConSrvConsoleCtrlEvent (IN ULONG CtrlEvent, IN PCONSOLE_PROCESS_DATA ProcessData)
 
PCHAR_INFO ConioCoordToPointer (PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y)
 
NTSTATUS ConioResizeBuffer (PCONSOLE Console, PTEXTMODE_SCREEN_BUFFER ScreenBuffer, COORD Size)
 

Macro Definition Documentation

◆ _CONSRV_CONSOLE

#define _CONSRV_CONSOLE   _CONSOLE

Definition at line 25 of file conio.h.

◆ CONSRV_CONSOLE

#define CONSRV_CONSOLE   CONSOLE

Definition at line 26 of file conio.h.

◆ DEFAULT_POPUP_ATTRIB

#define DEFAULT_POPUP_ATTRIB
Value:
#define BACKGROUND_GREEN
Definition: wincon.h:44
#define FOREGROUND_RED
Definition: wincon.h:41
#define BACKGROUND_RED
Definition: wincon.h:45
#define FOREGROUND_BLUE
Definition: wincon.h:39
#define BACKGROUND_INTENSITY
Definition: wincon.h:46

Definition at line 33 of file conio.h.

◆ DEFAULT_SCREEN_ATTRIB

#define DEFAULT_SCREEN_ATTRIB   (FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED)

Definition at line 32 of file conio.h.

◆ GetConsoleInputBufferMode

#define GetConsoleInputBufferMode (   Console)    (Console)->InputBuffer.Mode

Definition at line 362 of file conio.h.

◆ GetType

#define GetType (   This)    (This)->Vtbl->GetType(This)

Definition at line 78 of file conio.h.

◆ PCONSRV_CONSOLE

#define PCONSRV_CONSOLE   PCONSOLE

Definition at line 27 of file conio.h.

Typedef Documentation

◆ CONSOLE

◆ CONSOLE_INFO

◆ CONSOLE_INPUT_BUFFER

◆ CONSOLE_IO_OBJECT

◆ CONSOLE_IO_OBJECT_TYPE

◆ CONSOLE_SCREEN_BUFFER

Definition at line 70 of file conio.h.

◆ CONSOLE_SCREEN_BUFFER_VTBL

◆ CONSOLE_STATE

◆ GRAPHICS_BUFFER_INFO

◆ GRAPHICS_SCREEN_BUFFER

◆ PCONSOLE

Definition at line 312 of file conio.h.

◆ PCONSOLE_INFO

◆ PCONSOLE_INPUT_BUFFER

◆ PCONSOLE_IO_OBJECT

◆ PCONSOLE_SCREEN_BUFFER

Definition at line 70 of file conio.h.

◆ PCONSOLE_SCREEN_BUFFER_VTBL

◆ PCONSOLE_STATE

◆ PGRAPHICS_BUFFER_INFO

◆ PGRAPHICS_SCREEN_BUFFER

◆ PTERMINAL

Definition at line 200 of file conio.h.

◆ PTERMINAL_VTBL

◆ PTEXTMODE_BUFFER_INFO

◆ PTEXTMODE_SCREEN_BUFFER

◆ TERMINAL

Definition at line 200 of file conio.h.

◆ TERMINAL_VTBL

◆ TEXTMODE_BUFFER_INFO

◆ TEXTMODE_SCREEN_BUFFER

Enumeration Type Documentation

◆ _CONSOLE_IO_OBJECT_TYPE

Enumerator
UNKNOWN 
TEXTMODE_BUFFER 
GRAPHICS_BUFFER 
SCREEN_BUFFER 
INPUT_BUFFER 
ANY_TYPE_BUFFER 
TEXTMODE_BUFFER 
GRAPHICS_BUFFER 
SCREEN_BUFFER 
INPUT_BUFFER 

Definition at line 38 of file conio.h.

39 {
40  UNKNOWN = 0x00, // --> Unknown object
41  TEXTMODE_BUFFER = 0x01, // --> Output-type object for text SBs
42  GRAPHICS_BUFFER = 0x02, // --> Output-type object for graphics SBs
43  SCREEN_BUFFER = 0x03, // --> Any SB type
44  INPUT_BUFFER = 0x04, // --> Input-type object
45  ANY_TYPE_BUFFER = 0x07, // --> Any IO object
enum _CONSOLE_IO_OBJECT_TYPE CONSOLE_IO_OBJECT_TYPE

◆ _CONSOLE_STATE

Enumerator
CONSOLE_INITIALIZING 
CONSOLE_RUNNING 
CONSOLE_TERMINATING 
CONSOLE_IN_DESTRUCTION 
CONSOLE_INITIALIZING 
CONSOLE_RUNNING 
CONSOLE_TERMINATING 
CONSOLE_IN_DESTRUCTION 

Definition at line 302 of file conio.h.

303 {
304  CONSOLE_INITIALIZING, /* Console is initializing */
305  CONSOLE_RUNNING , /* Console running */
306  CONSOLE_TERMINATING , /* Console about to be destroyed (but still not) */
307  CONSOLE_IN_DESTRUCTION /* Console in destruction */
enum _CONSOLE_STATE * PCONSOLE_STATE
enum _CONSOLE_STATE CONSOLE_STATE

Function Documentation

◆ ConDrvPause()

VOID NTAPI ConDrvPause ( PCONSOLE  Console)

Definition at line 80 of file console.c.

81 {
82  /* In case we already have a pause event, just exit... */
83  if (Console->UnpauseEvent) return;
84 
85  /* ... otherwise create it */
86  NtCreateEvent(&Console->UnpauseEvent, EVENT_ALL_ACCESS,
88 }
NTSTATUS NTAPI NtCreateEvent(OUT PHANDLE EventHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN EVENT_TYPE EventType, IN BOOLEAN InitialState)
Definition: event.c:100
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
smooth NULL
Definition: ftsmooth.c:416
CConsole Console

Referenced by ConioPause().

◆ ConDrvUnpause()

VOID NTAPI ConDrvUnpause ( PCONSOLE  Console)

Definition at line 91 of file console.c.

92 {
93  /* In case we already freed the event, just exit... */
94  if (!Console->UnpauseEvent) return;
95 
96  /* ... otherwise set and free it */
97  NtSetEvent(Console->UnpauseEvent, NULL);
98  NtClose(Console->UnpauseEvent);
99  Console->UnpauseEvent = NULL;
100 }
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI NtSetEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL)
Definition: event.c:458
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
CConsole Console

Referenced by ConioUnpause().

◆ ConioCoordToPointer()

PCHAR_INFO ConioCoordToPointer ( PTEXTMODE_SCREEN_BUFFER  Buff,
ULONG  X,
ULONG  Y 
)

Definition at line 140 of file text.c.

141 {
142  return &Buff->Buffer[((Y + Buff->VirtualY) % Buff->ScreenBufferSize.Y) * Buff->ScreenBufferSize.X + X];
143 }
#define Y(I)
PCHAR_INFO Buffer
Definition: conio.h:154
#define X(b, s)

◆ ConioResizeBuffer()

NTSTATUS ConioResizeBuffer ( PCONSOLE  Console,
PTEXTMODE_SCREEN_BUFFER  ScreenBuffer,
COORD  Size 
)

Definition at line 257 of file text.c.

260 {
262  DWORD Offset = 0;
263  PCHAR_INFO ptr;
264  WORD CurrentAttribute;
265  USHORT CurrentY;
266  PCHAR_INFO OldBuffer;
267  DWORD i;
268  DWORD diff;
269 
270  /* Buffer size is not allowed to be smaller than the view size */
271  if (Size.X < ScreenBuffer->ViewSize.X || Size.Y < ScreenBuffer->ViewSize.Y)
273 
274  if (Size.X == ScreenBuffer->ScreenBufferSize.X && Size.Y == ScreenBuffer->ScreenBufferSize.Y)
275  {
276  // FIXME: Trigger a buffer resize event ??
277  return STATUS_SUCCESS;
278  }
279 
280  if (Console->FixedSize)
281  {
282  /*
283  * The console is in fixed-size mode, so we cannot resize anything
284  * at the moment. However, keep those settings somewhere so that
285  * we can try to set them up when we will be allowed to do so.
286  */
287  ScreenBuffer->OldScreenBufferSize = Size;
288  return STATUS_NOT_SUPPORTED; // STATUS_SUCCESS
289  }
290 
292  if (!Buffer) return STATUS_NO_MEMORY;
293 
294  DPRINT("Resizing (%d,%d) to (%d,%d)\n", ScreenBuffer->ScreenBufferSize.X, ScreenBuffer->ScreenBufferSize.Y, Size.X, Size.Y);
295  OldBuffer = ScreenBuffer->Buffer;
296 
297  for (CurrentY = 0; CurrentY < ScreenBuffer->ScreenBufferSize.Y && CurrentY < Size.Y; CurrentY++)
298  {
299  ptr = ConioCoordToPointer(ScreenBuffer, 0, CurrentY);
300  if (Size.X <= ScreenBuffer->ScreenBufferSize.X)
301  {
302  /* Reduce size */
303  RtlCopyMemory(Buffer + Offset, ptr, Size.X * sizeof(CHAR_INFO));
304  Offset += Size.X;
305  }
306  else
307  {
308  /* Enlarge size */
309  RtlCopyMemory(Buffer + Offset, ptr, ScreenBuffer->ScreenBufferSize.X * sizeof(CHAR_INFO));
310  Offset += ScreenBuffer->ScreenBufferSize.X;
311 
312  /* The attribute to be used is the one of the last cell of the current line */
313  CurrentAttribute = ConioCoordToPointer(ScreenBuffer,
314  ScreenBuffer->ScreenBufferSize.X - 1,
315  CurrentY)->Attributes;
316 
317  diff = Size.X - ScreenBuffer->ScreenBufferSize.X;
318 
319  /* Zero-out the new part of the buffer */
320  for (i = 0; i < diff; i++)
321  {
322  ptr = Buffer + Offset;
323  ptr->Char.UnicodeChar = L' ';
324  ptr->Attributes = CurrentAttribute;
325  ++Offset;
326  }
327  }
328  }
329 
330  if (Size.Y > ScreenBuffer->ScreenBufferSize.Y)
331  {
332  diff = Size.X * (Size.Y - ScreenBuffer->ScreenBufferSize.Y);
333 
334  /* Zero-out the new part of the buffer */
335  for (i = 0; i < diff; i++)
336  {
337  ptr = Buffer + Offset;
338  ptr->Char.UnicodeChar = L' ';
339  ptr->Attributes = ScreenBuffer->ScreenDefaultAttrib;
340  ++Offset;
341  }
342  }
343 
345  ConsoleFreeHeap(OldBuffer);
346  ScreenBuffer->ScreenBufferSize = ScreenBuffer->OldScreenBufferSize = Size;
347  ScreenBuffer->VirtualY = 0;
348 
349  /* Ensure cursor and window are within buffer */
350  if (ScreenBuffer->CursorPosition.X >= Size.X)
351  ScreenBuffer->CursorPosition.X = Size.X - 1;
352  if (ScreenBuffer->CursorPosition.Y >= Size.Y)
353  ScreenBuffer->CursorPosition.Y = Size.Y - 1;
354  if (ScreenBuffer->ViewOrigin.X > Size.X - ScreenBuffer->ViewSize.X)
355  ScreenBuffer->ViewOrigin.X = Size.X - ScreenBuffer->ViewSize.X;
356  if (ScreenBuffer->ViewOrigin.Y > Size.Y - ScreenBuffer->ViewSize.Y)
357  ScreenBuffer->ViewOrigin.Y = Size.Y - ScreenBuffer->ViewSize.Y;
358 
359  /*
360  * Trigger a buffer resize event
361  */
362  if (Console->InputBuffer.Mode & ENABLE_WINDOW_INPUT)
363  {
364  ULONG NumEventsWritten;
365  INPUT_RECORD er;
366 
368  er.Event.WindowBufferSizeEvent.dwSize = ScreenBuffer->ScreenBufferSize;
369 
370  // ConioProcessInputEvent(Console, &er);
372  &Console->InputBuffer,
373  TRUE,
374  &er,
375  1,
376  &NumEventsWritten);
377  }
378 
379  return STATUS_SUCCESS;
380 }
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y)
Definition: text.c:140
#define WINDOW_BUFFER_SIZE_EVENT
Definition: wincon.h:124
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
WINDOW_BUFFER_SIZE_RECORD WindowBufferSizeEvent
Definition: wincon.h:265
union _INPUT_RECORD::@3154 Event
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
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
static PVOID ptr
Definition: dispmode.c:27
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
WORD Attributes
Definition: wincon.h:172
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define ENABLE_WINDOW_INPUT
Definition: wincon.h:78
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
NTSTATUS NTAPI ConDrvWriteConsoleInput(IN PCONSOLE Console, IN PCONSOLE_INPUT_BUFFER InputBuffer, IN BOOLEAN AppendToEnd, IN PINPUT_RECORD InputRecord, IN ULONG NumEventsToWrite, OUT PULONG NumEventsWritten OPTIONAL)
Definition: coninput.c:325
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
CConsole Console
WORD EventType
Definition: wincon.h:261
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
HANDLE ScreenBuffer
Definition: notevil.c:37
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
unsigned int ULONG
Definition: retypes.h:1
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ ConSrvConsoleCtrlEvent()

NTSTATUS ConSrvConsoleCtrlEvent ( IN ULONG  CtrlEvent,
IN PCONSOLE_PROCESS_DATA  ProcessData 
)

Definition at line 860 of file console.c.

862 {
863  return ConSrvConsoleCtrlEventTimeout(CtrlEvent, ProcessData, 0);
864 }
NTSTATUS ConSrvConsoleCtrlEventTimeout(IN ULONG CtrlEvent, IN PCONSOLE_PROCESS_DATA ProcessData, IN ULONG Timeout)
Definition: console.c:809