ReactOS  0.4.15-dev-425-gc40b086
console.c File Reference
#include <usetup.h>
#include <blue/ntddblue.h>
#include "keytrans.h"
#include <debug.h>
Include dependency graph for console.c:

Go to the source code of this file.

Classes

struct  _CONSOLE_CABINET_CONTEXT
 

Macros

#define NDEBUG
 

Typedefs

typedef struct _CONSOLE_CABINET_CONTEXT CONSOLE_CABINET_CONTEXT
 
typedef struct _CONSOLE_CABINET_CONTEXTPCONSOLE_CABINET_CONTEXT
 

Functions

static PVOID ConsoleCreateFileHandler (IN PCABINET_CONTEXT CabinetContext, IN ULONG FileSize)
 
BOOL WINAPI AllocConsole (VOID)
 
BOOL WINAPI AttachConsole (IN DWORD dwProcessId)
 
BOOL WINAPI FreeConsole (VOID)
 
BOOL WINAPI WriteConsole (IN HANDLE hConsoleOutput, IN const VOID *lpBuffer, IN DWORD nNumberOfCharsToWrite, OUT LPDWORD lpNumberOfCharsWritten, IN LPVOID lpReserved)
 
HANDLE WINAPI GetStdHandle (IN DWORD nStdHandle)
 
BOOL WINAPI FlushConsoleInputBuffer (IN HANDLE hConsoleInput)
 
BOOL WINAPI PeekConsoleInput (IN HANDLE hConsoleInput, OUT PINPUT_RECORD lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsRead)
 
BOOL WINAPI ReadConsoleInput (IN HANDLE hConsoleInput, OUT PINPUT_RECORD lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsRead)
 
BOOL WINAPI WriteConsoleOutputCharacterA (HANDLE hConsoleOutput, IN LPCSTR lpCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
 
BOOL WINAPI WriteConsoleOutputCharacterW (HANDLE hConsoleOutput, IN LPCWSTR lpCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
 
BOOL WINAPI FillConsoleOutputAttribute (IN HANDLE hConsoleOutput, IN WORD wAttribute, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfAttrsWritten)
 
BOOL WINAPI FillConsoleOutputCharacterA (IN HANDLE hConsoleOutput, IN CHAR cCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
 
BOOL WINAPI GetConsoleScreenBufferInfo (IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
 
BOOL WINAPI SetConsoleCursorInfo (IN HANDLE hConsoleOutput, IN const CONSOLE_CURSOR_INFO *lpConsoleCursorInfo)
 
BOOL WINAPI SetConsoleCursorPosition (IN HANDLE hConsoleOutput, IN COORD dwCursorPosition)
 
BOOL WINAPI SetConsoleTextAttribute (IN HANDLE hConsoleOutput, IN WORD wAttributes)
 
BOOL WINAPI SetConsoleOutputCP (IN UINT wCodepage)
 

Variables

static BOOLEAN InputQueueEmpty
 
static BOOLEAN WaitForInput
 
static KEYBOARD_INPUT_DATA InputDataQueue
 
static IO_STATUS_BLOCK InputIosb
 
static UINT LastLoadedCodepage
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 34 of file console.c.

Typedef Documentation

◆ CONSOLE_CABINET_CONTEXT

◆ PCONSOLE_CABINET_CONTEXT

Function Documentation

◆ AllocConsole()

BOOL WINAPI AllocConsole ( VOID  )

Definition at line 74 of file console.c.

75 {
77  UNICODE_STRING ScreenName = RTL_CONSTANT_STRING(L"\\??\\BlueScreen");
78  UNICODE_STRING KeyboardName = RTL_CONSTANT_STRING(L"\\Device\\KeyboardClass0");
81  ULONG Enable;
82 
83  /* Open the screen */
85  &ScreenName,
86  0,
87  NULL,
88  NULL);
93  FILE_OPEN,
95  if (!NT_SUCCESS(Status))
96  return FALSE;
97 
98  /* Enable it */
99  Enable = TRUE;
101  NULL,
102  NULL,
103  NULL,
104  &IoStatusBlock,
106  &Enable,
107  sizeof(Enable),
108  NULL,
109  0);
110  if (!NT_SUCCESS(Status))
111  {
113  return FALSE;
114  }
115 
116  /* Open the keyboard */
118  &KeyboardName,
119  0,
120  NULL,
121  NULL);
125  &IoStatusBlock,
126  FILE_OPEN,
127  0);
128  if (!NT_SUCCESS(Status))
129  {
131  return FALSE;
132  }
133 
134  /* Reset the queue state */
137 
138  return TRUE;
139 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define TRUE
Definition: types.h:120
#define FILE_ALL_ACCESS
Definition: nt_native.h:651
LONG NTSTATUS
Definition: precomp.h:26
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:140
HANDLE StdInput
Definition: consup.c:36
static BOOLEAN WaitForInput
Definition: console.c:40
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)
#define FILE_SYNCHRONOUS_IO_ALERT
Definition: from_kernel.h:30
HANDLE StdOutput
Definition: consup.c:37
smooth NULL
Definition: ftsmooth.c:416
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:3951
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
static BOOLEAN InputQueueEmpty
Definition: console.c:39
static const WCHAR L[]
Definition: oid.c:1250
#define IOCTL_CONSOLE_RESET_SCREEN
Definition: ntddblue.h:4
Status
Definition: gdiplustypes.h:24
#define FILE_OPEN
Definition: from_kernel.h:54
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
unsigned int ULONG
Definition: retypes.h:1
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

Referenced by _tWinMain(), cmd_ctty(), CONSOLE_Init(), DoTest(), main(), START_TEST(), test_Console(), TUIInitialize(), and wWinMain().

◆ AttachConsole()

BOOL WINAPI AttachConsole ( IN DWORD  dwProcessId)

Definition at line 144 of file console.c.

146 {
147  return FALSE;
148 }

◆ ConsoleCreateFileHandler()

static PVOID ConsoleCreateFileHandler ( IN PCABINET_CONTEXT  CabinetContext,
IN ULONG  FileSize 
)
static

Definition at line 55 of file console.c.

58 {
59  PCONSOLE_CABINET_CONTEXT ConsoleCabinetContext;
60 
61  ConsoleCabinetContext = (PCONSOLE_CABINET_CONTEXT)CabinetContext;
62  ConsoleCabinetContext->Data = RtlAllocateHeap(ProcessHeap, 0, FileSize);
63  if (!ConsoleCabinetContext->Data)
64  {
65  DPRINT("Failed to allocate %d bytes\n", FileSize);
66  return NULL;
67  }
68  ConsoleCabinetContext->Size = FileSize;
69  return ConsoleCabinetContext->Data;
70 }
struct _CONSOLE_CABINET_CONTEXT * PCONSOLE_CABINET_CONTEXT
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
HANDLE ProcessHeap
Definition: servman.c:15

Referenced by SetConsoleOutputCP().

◆ FillConsoleOutputAttribute()

BOOL WINAPI FillConsoleOutputAttribute ( IN HANDLE  hConsoleOutput,
IN WORD  wAttribute,
IN DWORD  nLength,
IN COORD  dwWriteCoord,
OUT LPDWORD  lpNumberOfAttrsWritten 
)

Definition at line 522 of file console.c.

528 {
532 
533  Buffer.wAttribute = wAttribute;
534  Buffer.nLength = nLength;
535  Buffer.dwCoord = dwWriteCoord;
536 
537  Status = NtDeviceIoControlFile(hConsoleOutput,
538  NULL,
539  NULL,
540  NULL,
541  &IoStatusBlock,
543  &Buffer,
544  sizeof(OUTPUT_ATTRIBUTE),
545  &Buffer,
546  sizeof(OUTPUT_ATTRIBUTE));
547  if (!NT_SUCCESS(Status))
548  return FALSE;
549 
550  *lpNumberOfAttrsWritten = Buffer.dwTransfered;
551  return TRUE;
552 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
_In_ DWORD nLength
Definition: wincon.h:476
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)
#define IOCTL_CONSOLE_FILL_OUTPUT_ATTRIBUTE
Definition: ntddblue.h:13
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:24
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

Referenced by TConsole::ClearBOLine(), TConsole::ClearBOScreen(), TConsole::ClearEOLine(), TConsole::ClearEOScreen(), TConsole::ClearLine(), TConsole::ClearScreen(), ClearScreen(), TConsole::ClearWindow(), ConClearScreen(), ConSetScreenColor(), CONSOLE_ClearScreen(), CONSOLE_InvertTextXY(), CONSOLE_NormalTextXY(), CONSOLE_SetHighlightedTextXY(), CONSOLE_SetInputTextXY(), CONSOLE_SetInvertedTextXY(), CONSOLE_SetStatusTextXV(), ConsolePager(), DisplayScreen(), TMouse::doMouse(), DrawFileSystemList(), DrawListEntries(), DrawProgressBar(), TMouse::move_mouse(), PopupError(), PrintDiskData(), PrintEmptyLine(), PrintInfoLine(), PrintPartitionData(), test_cp932(), test_FillConsoleOutputAttribute(), wmain(), WriteStringAt(), and TConsole::WriteText().

◆ FillConsoleOutputCharacterA()

BOOL WINAPI FillConsoleOutputCharacterA ( IN HANDLE  hConsoleOutput,
IN CHAR  cCharacter,
IN DWORD  nLength,
IN COORD  dwWriteCoord,
OUT LPDWORD  lpNumberOfCharsWritten 
)

Definition at line 557 of file console.c.

563 {
567 
568  Buffer.cCharacter = cCharacter;
569  Buffer.nLength = nLength;
570  Buffer.dwCoord = dwWriteCoord;
571 
572  Status = NtDeviceIoControlFile(hConsoleOutput,
573  NULL,
574  NULL,
575  NULL,
576  &IoStatusBlock,
578  &Buffer,
579  sizeof(OUTPUT_CHARACTER),
580  &Buffer,
581  sizeof(OUTPUT_CHARACTER));
582  if (!NT_SUCCESS(Status))
583  return FALSE;
584 
585  *lpNumberOfCharsWritten = Buffer.dwTransfered;
586  return TRUE;
587 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
_In_ DWORD nLength
Definition: wincon.h:476
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)
#define IOCTL_CONSOLE_FILL_OUTPUT_CHARACTER
Definition: ntddblue.h:18
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:24
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

Referenced by CONSOLE_ClearScreen(), CONSOLE_ClearStatusTextX(), CONSOLE_ClearTextXY(), CONSOLE_PrintTextXYN(), CONSOLE_SetInputTextXY(), CONSOLE_SetStatusTextXV(), CONSOLE_SetUnderlinedTextXY(), DrawBorder(), DrawBox(), DrawFileSystemList(), DrawListEntries(), DrawListFrame(), DrawPartitionList(), DrawProgressBar(), DrawScrollBarGenericList(), DrawThickBorder(), PopupError(), PrintDiskData(), PrintEmptyLine(), PrintPartitionData(), ProgressSetStep(), and test_FillConsoleOutputCharacterA().

◆ FlushConsoleInputBuffer()

BOOL WINAPI FlushConsoleInputBuffer ( IN HANDLE  hConsoleInput)

Definition at line 217 of file console.c.

219 {
223  KEYBOARD_INPUT_DATA InputData;
224 
225  /* Cancel any pending read */
226  if (WaitForInput)
227  NtCancelIoFile(hConsoleInput, &IoStatusBlock);
228 
229  /* Reset the queue state */
232 
233  /* Flush the keyboard buffer */
234  do
235  {
236  Offset.QuadPart = 0;
237  Status = NtReadFile(hConsoleInput,
238  NULL,
239  NULL,
240  NULL,
241  &IoStatusBlock,
242  &InputData,
243  sizeof(InputData),
244  &Offset,
245  NULL);
246  if (Status == STATUS_PENDING)
247  {
248  Timeout.QuadPart = -100;
249  Status = NtWaitForSingleObject(hConsoleInput, FALSE, &Timeout);
250  if (Status == STATUS_TIMEOUT)
251  {
252  NtCancelIoFile(hConsoleInput, &IoStatusBlock);
253  return TRUE;
254  }
255  }
256  } while (NT_SUCCESS(Status));
257  return FALSE;
258 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
static BOOLEAN WaitForInput
Definition: console.c:40
#define STATUS_TIMEOUT
Definition: ntstatus.h:81
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
static BOOLEAN InputQueueEmpty
Definition: console.c:39
Status
Definition: gdiplustypes.h:24
static ULONG Timeout
Definition: ping.c:61
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
NTSTATUS NTAPI NtCancelIoFile(IN HANDLE FileHandle, OUT PIO_STATUS_BLOCK IoStatusBlock)
Definition: file.c:4018
NTSTATUS NTAPI NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key)
NTSYSAPI NTSTATUS NTAPI NtWaitForSingleObject(IN HANDLE hObject, IN BOOLEAN bAlertable, IN PLARGE_INTEGER Timeout)

Referenced by ConInFlush(), CONSOLE_Flush(), ConsolePager(), FlushFileBuffers(), CConsole::FlushInputBuffer(), getline(), gl_cleanup(), gl_getpass(), InputChar(), InputWait(), CConsole::ReadLine(), ReadString(), test_WriteConsoleInputA(), test_WriteConsoleInputW(), testWaitForConsoleInput(), and wmain().

◆ FreeConsole()

BOOL WINAPI FreeConsole ( VOID  )

Definition at line 153 of file console.c.

154 {
155  /* Reset the queue state */
158 
160  NtClose(StdInput);
161 
164 
165  return TRUE;
166 }
#define TRUE
Definition: types.h:120
HANDLE StdInput
Definition: consup.c:36
#define INVALID_HANDLE_VALUE
Definition: compat.h:400
static BOOLEAN WaitForInput
Definition: console.c:40
HANDLE StdOutput
Definition: consup.c:37
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
static BOOLEAN InputQueueEmpty
Definition: console.c:39

Referenced by cmd_ctty(), RunUSetup(), and START_TEST().

◆ GetConsoleScreenBufferInfo()

BOOL WINAPI GetConsoleScreenBufferInfo ( IN HANDLE  hConsoleOutput,
OUT PCONSOLE_SCREEN_BUFFER_INFO  lpConsoleScreenBufferInfo 
)

Definition at line 592 of file console.c.

595 {
598 
599  Status = NtDeviceIoControlFile(hConsoleOutput,
600  NULL,
601  NULL,
602  NULL,
603  &IoStatusBlock,
605  NULL,
606  0,
607  lpConsoleScreenBufferInfo,
609  return NT_SUCCESS(Status);
610 }
LONG NTSTATUS
Definition: precomp.h:26
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)
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:24
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define IOCTL_CONSOLE_GET_SCREEN_BUFFER_INFO
Definition: ntddblue.h:6

Referenced by AttachToConsoleInternal(), TConsole::ClearBOLine(), TConsole::ClearEOLine(), TConsole::ClearLine(), ConClearLine(), ConClearScreen(), ConGetDefaultAttributes(), ConGetScreenInfo(), ConSetScreenColor(), CONSOLE_GetCursorX(), CONSOLE_GetCursorXY(), CONSOLE_GetCursorY(), CONSOLE_Init(), ConsolePager(), DisplayScreen(), doChild(), TMouse::doMouse_init(), GetCursorX(), GetCursorXY(), GetCursorY(), GetScreenColumns(), GetScreenSize(), CConsole::Init(), main(), newBuffer(), PrintInfoLine(), ReadCommand(), RecoveryConsole(), ResizeTextConsole(), restoreScreen(), saveScreen(), TScroller::ScrollBack(), SetConsoleCursorPosition(), SetConsoleState(), SetConsoleStateOld(), ShowConsoleStatus(), START_TEST(), TConsole::sync(), TConsole::TConsole(), test_Console(), test_cp855(), test_cp932(), test_GetConsoleFontInfo(), test_GetConsoleFontSize(), test_GetCurrentConsoleFont(), test_GetLargestConsoleWindowSize(), VgaConsoleInitialize(), wmain(), and write_status().

◆ GetStdHandle()

HANDLE WINAPI GetStdHandle ( IN DWORD  nStdHandle)

Definition at line 200 of file console.c.

202 {
203  switch (nStdHandle)
204  {
205  case STD_INPUT_HANDLE:
206  return StdInput;
207  case STD_OUTPUT_HANDLE:
208  return StdOutput;
209  default:
210  return INVALID_HANDLE_VALUE;
211  }
212 }
HANDLE StdInput
Definition: consup.c:36
#define INVALID_HANDLE_VALUE
Definition: compat.h:400
HANDLE StdOutput
Definition: consup.c:37
#define STD_INPUT_HANDLE
Definition: winbase.h:264
#define STD_OUTPUT_HANDLE
Definition: winbase.h:265

Referenced by __report_error(), _cputs(), _kbhit(), _putch(), _tmain(), _tpopen(), _tWinMain(), ask_confirm(), ata_open_file(), cfgets(), cgetchar(), cmd_type(), ConErrPrintf(), Confirm(), ConInDisable(), ConInEnable(), ConInFlush(), ConInKey(), ConInString(), ConOutPuts(), CONSOLE_GetCursorXY(), CONSOLE_Init(), ConsolePager(), CreateClientProcess(), DisplayError(), DisplayResourceText(), doChild(), DosCopyHandleTable(), EnumThreadProc(), ExecutePipeline(), ExtCabCallback(), GetCharacterTimeout(), GetCursorX(), GetCursorXY(), GetCursorY(), GetInputOutputHandles(), getline(), getpass(), GetScreenColumns(), GetScreenSize(), gl_cleanup(), gl_getpass(), CConsole::Init(), CPipedProcess::InitStartupInfo(), InputChar(), main(), msvcrt_init_io(), myprintf(), newBuffer(), output_error(), output_header(), output_line(), output_writeconsole(), OutputResult(), TANSIParser::ParseBuffer(), print_string(), PrintInfoLine(), printit(), ReadAndHandleOutput(), ReadCommand(), ReadFromConsole(), ReadString(), RecoveryConsole(), RestoreConsole(), restoreScreen(), saveScreen(), TScroller::ScrollBack(), scrollkeys(), SetCl(), SetConsoleOutputCP(), SetConsoleState(), SetConsoleStateOld(), SetCursorType(), SetCursorXY(), SetInsert(), ShowAppList(), ShowConsoleStatus(), start_server(), taskkill_vprintfW(), telProcessConsole(), test_DetachConsoleHandles(), test_DetachStdHandles(), test_file_inherit(), test_GetConsoleFontInfo(), test_GetConsoleFontSize(), test_GetConsoleScreenBufferInfoEx(), test_GetCurrentConsoleFont(), test_GetFileType(), test_GetLargestConsoleWindowSize(), test_GetSetStdHandle(), test_Handles(), test_invalid_stdin(), test_ReadConsole(), test_SetConsoleFont(), test_stdin(), test_stdio(), test_stdout_handle(), TMouse::TMouse(), TUIDisplayStatusMessage(), waitforkey(), wmain(), write_status(), XCOPY_DoCopy(), XCOPY_ProcessDestParm(), and XCOPY_wprintf().

◆ PeekConsoleInput()

BOOL WINAPI PeekConsoleInput ( IN HANDLE  hConsoleInput,
OUT PINPUT_RECORD  lpBuffer,
IN DWORD  nLength,
OUT LPDWORD  lpNumberOfEventsRead 
)

Definition at line 263 of file console.c.

268 {
271  KEYBOARD_INPUT_DATA InputData;
272 
273  if (InputQueueEmpty)
274  {
275  /* Read the keyboard for an event, without waiting */
276  if (!WaitForInput)
277  {
278  Offset.QuadPart = 0;
279  Status = NtReadFile(hConsoleInput,
280  NULL,
281  NULL,
282  NULL,
283  &InputIosb,
285  sizeof(InputDataQueue),
286  &Offset,
287  NULL);
288  if (!NT_SUCCESS(Status))
289  return FALSE;
290  if (Status == STATUS_PENDING)
291  {
292  /* No input yet, we will have to wait next time */
294  WaitForInput = TRUE;
295  return TRUE;
296  }
297  }
298  else
299  {
300  /*
301  * We already tried to read from the keyboard and are
302  * waiting for data, check whether something showed up.
303  */
304  Timeout.QuadPart = -100; // Wait just a little bit.
305  Status = NtWaitForSingleObject(hConsoleInput, FALSE, &Timeout);
306  if (Status == STATUS_TIMEOUT)
307  {
308  /* Nothing yet, continue waiting next time */
310  WaitForInput = TRUE;
311  return TRUE;
312  }
314  if (!NT_SUCCESS(Status))
315  return FALSE;
316  }
317 
318  /* We got something in the queue */
321  }
322 
323  /* Fetch from the queue but keep it inside */
324  InputData = InputDataQueue;
325 
326  lpBuffer->EventType = KEY_EVENT;
327  Status = IntTranslateKey(hConsoleInput, &InputData, &lpBuffer->Event.KeyEvent);
328  if (!NT_SUCCESS(Status))
329  return FALSE;
330 
332  return TRUE;
333 }
static KEYBOARD_INPUT_DATA InputDataQueue
Definition: console.c:41
#define TRUE
Definition: types.h:120
static IO_STATUS_BLOCK InputIosb
Definition: console.c:42
_In_ DWORD _Out_ LPDWORD lpNumberOfEventsRead
Definition: wincon.h:476
LONG NTSTATUS
Definition: precomp.h:26
static BOOLEAN WaitForInput
Definition: console.c:40
#define STATUS_TIMEOUT
Definition: ntstatus.h:81
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
NTSTATUS IntTranslateKey(HANDLE hConsoleInput, PKEYBOARD_INPUT_DATA InputData, KEY_EVENT_RECORD *Event)
Definition: keytrans.c:417
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
#define KEY_EVENT
Definition: wincon.h:128
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
static BOOLEAN InputQueueEmpty
Definition: console.c:39
Status
Definition: gdiplustypes.h:24
static ULONG Timeout
Definition: ping.c:61
NTSTATUS NTAPI NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key)
NTSYSAPI NTSTATUS NTAPI NtWaitForSingleObject(IN HANDLE hObject, IN BOOLEAN bAlertable, IN PLARGE_INTEGER Timeout)

Referenced by _kbhit(), and CONSOLE_ConInKeyPeek().

◆ ReadConsoleInput()

BOOL WINAPI ReadConsoleInput ( IN HANDLE  hConsoleInput,
OUT PINPUT_RECORD  lpBuffer,
IN DWORD  nLength,
OUT LPDWORD  lpNumberOfEventsRead 
)

Definition at line 338 of file console.c.

343 {
346  KEYBOARD_INPUT_DATA InputData;
347 
348  if (InputQueueEmpty)
349  {
350  /* Read the keyboard and wait for an event, skipping the queue */
351  if (!WaitForInput)
352  {
353  Offset.QuadPart = 0;
354  Status = NtReadFile(hConsoleInput,
355  NULL,
356  NULL,
357  NULL,
358  &InputIosb,
360  sizeof(InputDataQueue),
361  &Offset,
362  NULL);
363  if (Status == STATUS_PENDING)
364  {
365  /* Block and wait for input */
366  WaitForInput = TRUE;
367  Status = NtWaitForSingleObject(hConsoleInput, FALSE, NULL);
370  }
371  if (!NT_SUCCESS(Status))
372  return FALSE;
373  }
374  else
375  {
376  /*
377  * We already tried to read from the keyboard and are
378  * waiting for data, block and wait for input.
379  */
380  Status = NtWaitForSingleObject(hConsoleInput, FALSE, NULL);
383  if (!NT_SUCCESS(Status))
384  return FALSE;
385  }
386  }
387 
388  /* Fetch from the queue and empty it */
389  InputData = InputDataQueue;
391 
392  lpBuffer->EventType = KEY_EVENT;
393  Status = IntTranslateKey(hConsoleInput, &InputData, &lpBuffer->Event.KeyEvent);
394  if (!NT_SUCCESS(Status))
395  return FALSE;
396 
398  return TRUE;
399 }
static KEYBOARD_INPUT_DATA InputDataQueue
Definition: console.c:41
#define TRUE
Definition: types.h:120
static IO_STATUS_BLOCK InputIosb
Definition: console.c:42
_In_ DWORD _Out_ LPDWORD lpNumberOfEventsRead
Definition: wincon.h:476
LONG NTSTATUS
Definition: precomp.h:26
static BOOLEAN WaitForInput
Definition: console.c:40
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
NTSTATUS IntTranslateKey(HANDLE hConsoleInput, PKEYBOARD_INPUT_DATA InputData, KEY_EVENT_RECORD *Event)
Definition: keytrans.c:417
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
#define KEY_EVENT
Definition: wincon.h:128
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
static BOOLEAN InputQueueEmpty
Definition: console.c:39
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key)
NTSYSAPI NTSTATUS NTAPI NtWaitForSingleObject(IN HANDLE hObject, IN BOOLEAN bAlertable, IN PLARGE_INTEGER Timeout)

Referenced by ConInKey().

◆ SetConsoleCursorInfo()

BOOL WINAPI SetConsoleCursorInfo ( IN HANDLE  hConsoleOutput,
IN const CONSOLE_CURSOR_INFO lpConsoleCursorInfo 
)

Definition at line 615 of file console.c.

618 {
621 
622  Status = NtDeviceIoControlFile(hConsoleOutput,
623  NULL,
624  NULL,
625  NULL,
626  &IoStatusBlock,
628  (PCONSOLE_CURSOR_INFO)lpConsoleCursorInfo,
629  sizeof(CONSOLE_CURSOR_INFO),
630  NULL,
631  0);
632  return NT_SUCCESS(Status);
633 }
LONG NTSTATUS
Definition: precomp.h:26
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)
#define IOCTL_CONSOLE_SET_CURSOR_INFO
Definition: ntddblue.h:9
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:24
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75

Referenced by CONSOLE_SetCursorType(), CConsole::Init(), TConsole::SetCursorSize(), SetCursorType(), CConsole::SetInsertMode(), VgaConsoleUpdateTextCursor(), VgaDetachFromConsole(), and CConsole::Write().

◆ SetConsoleCursorPosition()

BOOL WINAPI SetConsoleCursorPosition ( IN HANDLE  hConsoleOutput,
IN COORD  dwCursorPosition 
)

Definition at line 638 of file console.c.

641 {
642  CONSOLE_SCREEN_BUFFER_INFO ConsoleScreenBufferInfo;
645 
646  Status = GetConsoleScreenBufferInfo(hConsoleOutput, &ConsoleScreenBufferInfo);
647  if (!NT_SUCCESS(Status))
648  return FALSE;
649 
650  ConsoleScreenBufferInfo.dwCursorPosition.X = dwCursorPosition.X;
651  ConsoleScreenBufferInfo.dwCursorPosition.Y = dwCursorPosition.Y;
652 
653  Status = NtDeviceIoControlFile(hConsoleOutput,
654  NULL,
655  NULL,
656  NULL,
657  &IoStatusBlock,
659  &ConsoleScreenBufferInfo,
661  NULL,
662  0);
663  return NT_SUCCESS(Status);
664 }
#define IOCTL_CONSOLE_SET_SCREEN_BUFFER_INFO
Definition: ntddblue.h:7
LONG NTSTATUS
Definition: precomp.h:26
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)
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI GetConsoleScreenBufferInfo(IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
Definition: console.c:592
ULONG X
Definition: bl.h:1340
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:24
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
ULONG Y
Definition: bl.h:1341

Referenced by ClearScreen(), ConClearLine(), ConClearScreen(), CONSOLE_SetCursorXY(), ConsolePager(), doChild(), CConsole::ReadLine(), TConsole::SetCursorPosition(), SetCursorXY(), TConsole::SetRawCursorPosition(), test_cp855(), test_cp932(), testCursor(), testEmptyWrite(), testScreenBuffer(), testWriteNotWrappedNotProcessed(), testWriteNotWrappedProcessed(), testWriteSimple(), testWriteWrappedNotProcessed(), testWriteWrappedProcessed(), VgaConsoleUpdateTextCursor(), CConsole::Write(), and TConsole::WriteString().

◆ SetConsoleOutputCP()

BOOL WINAPI SetConsoleOutputCP ( IN UINT  wCodepage)

Definition at line 692 of file console.c.

694 {
695  WCHAR FontName[100];
696  WCHAR FontFile[] = L"\\SystemRoot\\vgafonts.cab";
697  CONSOLE_CABINET_CONTEXT ConsoleCabinetContext;
698  PCABINET_CONTEXT CabinetContext = &ConsoleCabinetContext.CabinetContext;
699  CAB_SEARCH Search;
700  ULONG CabStatus;
701  HANDLE hConsoleOutput;
704 
705  if (wCodepage == LastLoadedCodepage)
706  return TRUE;
707 
708  hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
709 
710  CabinetInitialize(CabinetContext);
711  CabinetSetEventHandlers(CabinetContext,
713  CabinetSetCabinetName(CabinetContext, FontFile);
714 
715  CabStatus = CabinetOpen(CabinetContext);
716  if (CabStatus != CAB_STATUS_SUCCESS)
717  {
718  DPRINT("CabinetOpen('%S') returned 0x%08x\n", FontFile, CabStatus);
719  return FALSE;
720  }
721 
722  swprintf(FontName, L"%u-8x8.bin", wCodepage);
723  CabStatus = CabinetFindFirst(CabinetContext, FontName, &Search);
724  if (CabStatus != CAB_STATUS_SUCCESS)
725  {
726  DPRINT("CabinetFindFirst('%S', '%S') returned 0x%08x\n", FontFile, FontName, CabStatus);
727  CabinetClose(CabinetContext);
728  return FALSE;
729  }
730 
731  CabStatus = CabinetExtractFile(CabinetContext, &Search);
732  CabinetClose(CabinetContext);
733  if (CabStatus != CAB_STATUS_SUCCESS)
734  {
735  DPRINT("CabinetLoadFile('%S', '%S') returned 0x%08x\n", FontFile, FontName, CabStatus);
736  return FALSE;
737  }
738 
739  Status = NtDeviceIoControlFile(hConsoleOutput,
740  NULL,
741  NULL,
742  NULL,
743  &IoStatusBlock,
745  ConsoleCabinetContext.Data,
746  ConsoleCabinetContext.Size,
747  NULL,
748  0);
749  if (!NT_SUCCESS(Status))
750  return FALSE;
751 
752  LastLoadedCodepage = wCodepage;
753  return TRUE;
754 }
VOID CabinetInitialize(IN OUT PCABINET_CONTEXT CabinetContext)
Definition: cabinet.c:501
ULONG CabinetExtractFile(IN PCABINET_CONTEXT CabinetContext, IN PCAB_SEARCH Search)
Definition: cabinet.c:952
#define TRUE
Definition: types.h:120
#define IOCTL_CONSOLE_SETFONT
Definition: ntddblue.h:25
VOID CabinetClose(IN OUT PCABINET_CONTEXT CabinetContext)
Definition: cabinet.c:794
LONG NTSTATUS
Definition: precomp.h:26
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:200
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)
VOID CabinetSetCabinetName(IN PCABINET_CONTEXT CabinetContext, IN PCWSTR FileName)
Definition: cabinet.c:580
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define swprintf(buf, format,...)
Definition: sprintf.c:56
VOID CabinetSetEventHandlers(IN PCABINET_CONTEXT CabinetContext, IN PCABINET_OVERWRITE Overwrite, IN PCABINET_EXTRACT Extract, IN PCABINET_DISK_CHANGE DiskChange, IN PCABINET_CREATE_FILE CreateFile)
Definition: cabinet.c:1331
#define CAB_STATUS_SUCCESS
Definition: cabinet.h:23
static const WCHAR L[]
Definition: oid.c:1250
#define STD_OUTPUT_HANDLE
Definition: winbase.h:265
ULONG CabinetOpen(IN OUT PCABINET_CONTEXT CabinetContext)
Definition: cabinet.c:621
Status
Definition: gdiplustypes.h:24
static PVOID ConsoleCreateFileHandler(IN PCABINET_CONTEXT CabinetContext, IN ULONG FileSize)
Definition: console.c:55
CABINET_CONTEXT CabinetContext
Definition: console.c:49
ULONG CabinetFindFirst(IN PCABINET_CONTEXT CabinetContext, IN PCWSTR FileName, IN OUT PCAB_SEARCH Search)
Definition: cabinet.c:813
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
static UINT LastLoadedCodepage
Definition: console.c:43
unsigned int ULONG
Definition: retypes.h:1

Referenced by doChild(), SetConsoleCodePage(), SetConsoleCPState(), test_Console(), test_cp855(), test_cp932(), testScreenBuffer(), and wmain().

◆ SetConsoleTextAttribute()

BOOL WINAPI SetConsoleTextAttribute ( IN HANDLE  hConsoleOutput,
IN WORD  wAttributes 
)

Definition at line 669 of file console.c.

672 {
675 
676  Status = NtDeviceIoControlFile(hConsoleOutput,
677  NULL,
678  NULL,
679  NULL,
680  &IoStatusBlock,
682  &wAttributes,
683  sizeof(USHORT),
684  NULL,
685  0);
686  return NT_SUCCESS(Status);
687 }
#define IOCTL_CONSOLE_SET_TEXT_ATTRIBUTE
Definition: ntddblue.h:16
LONG NTSTATUS
Definition: precomp.h:26
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)
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:24
unsigned short USHORT
Definition: pedump.c:61
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75

Referenced by ConSetScreenColor(), main(), SetCl(), ShowAppList(), TConsole::TConsole(), testWrite(), TConsole::WriteString(), TConsole::WriteStringFast(), and TConsole::~TConsole().

◆ WriteConsole()

BOOL WINAPI WriteConsole ( IN HANDLE  hConsoleOutput,
IN const VOID lpBuffer,
IN DWORD  nNumberOfCharsToWrite,
OUT LPDWORD  lpNumberOfCharsWritten,
IN LPVOID  lpReserved 
)

Definition at line 171 of file console.c.

177 {
180 
181  Status = NtWriteFile(hConsoleOutput,
182  NULL,
183  NULL,
184  NULL,
185  &IoStatusBlock,
186  (PVOID)lpBuffer,
187  nNumberOfCharsToWrite,
188  NULL,
189  NULL);
190  if (!NT_SUCCESS(Status))
191  return FALSE;
192 
193  *lpNumberOfCharsWritten = IoStatusBlock.Information;
194  return TRUE;
195 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSYSAPI NTSTATUS NTAPI NtWriteFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID WriteBuffer, IN ULONG WriteBufferLength, IN PLARGE_INTEGER FileOffset OPTIONAL, IN PULONG LockOperationKey OPTIONAL)
Status
Definition: gdiplustypes.h:24
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75

◆ WriteConsoleOutputCharacterA()

BOOL WINAPI WriteConsoleOutputCharacterA ( HANDLE  hConsoleOutput,
IN LPCSTR  lpCharacter,
IN DWORD  nLength,
IN COORD  dwWriteCoord,
OUT LPDWORD  lpNumberOfCharsWritten 
)

Definition at line 404 of file console.c.

410 {
412  PCHAR Buffer;
413  COORD *pCoord;
414  PCHAR pText;
416 
418  0,
419  nLength + sizeof(COORD));
420  pCoord = (COORD *)Buffer;
421  pText = (PCHAR)(pCoord + 1);
422 
423  *pCoord = dwWriteCoord;
424  memcpy(pText, lpCharacter, nLength);
425 
426  Status = NtDeviceIoControlFile(hConsoleOutput,
427  NULL,
428  NULL,
429  NULL,
430  &IoStatusBlock,
432  NULL,
433  0,
434  Buffer,
435  nLength + sizeof(COORD));
436 
438  if (!NT_SUCCESS(Status))
439  return FALSE;
440 
441  *lpNumberOfCharsWritten = IoStatusBlock.Information;
442  return TRUE;
443 }
signed char * PCHAR
Definition: retypes.h:7
#define TRUE
Definition: types.h:120
LPCSTR pText
Definition: txtscale.cpp:79
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
_In_ DWORD nLength
Definition: wincon.h:476
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)
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define PCHAR
Definition: match.c:90
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: bl.h:1338
HANDLE ProcessHeap
Definition: servman.c:15
Status
Definition: gdiplustypes.h:24
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER
Definition: ntddblue.h:20
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

Referenced by CONSOLE_PrintTextXY(), CONSOLE_PrintTextXYN(), CONSOLE_SetHighlightedTextXY(), CONSOLE_SetInvertedTextXY(), CONSOLE_SetStatusTextXV(), CONSOLE_SetTextXY(), CONSOLE_SetUnderlinedTextXY(), DrawListEntries(), DrawPartitionList(), DrawProgressBar(), PopupError(), PrintDiskData(), PrintPartitionData(), ProgressSetStep(), resetContent(), ShowPartitionSizeInputBox(), and test_WriteConsoleOutputCharacterA().

◆ WriteConsoleOutputCharacterW()

BOOL WINAPI WriteConsoleOutputCharacterW ( HANDLE  hConsoleOutput,
IN LPCWSTR  lpCharacter,
IN DWORD  nLength,
IN COORD  dwWriteCoord,
OUT LPDWORD  lpNumberOfCharsWritten 
)

Definition at line 448 of file console.c.

454 {
456  PCHAR Buffer;
457  COORD *pCoord;
458  PCHAR pText;
460 // ULONG i;
461 
464  ULONG OemLength;
465 
466  UnicodeString.Length = nLength * sizeof(WCHAR);
467  UnicodeString.MaximumLength = nLength * sizeof(WCHAR);
468  UnicodeString.Buffer = (PWSTR)lpCharacter;
469 
471 
472 
474  0,
475  OemLength + sizeof(COORD));
476 // nLength + sizeof(COORD));
477  if (Buffer== NULL)
478  return FALSE;
479 
480  pCoord = (COORD *)Buffer;
481  pText = (PCHAR)(pCoord + 1);
482 
483  *pCoord = dwWriteCoord;
484 
485  OemString.Length = 0;
486  OemString.MaximumLength = OemLength;
487  OemString.Buffer = pText;
488 
490  &UnicodeString,
491  FALSE);
492  if (!NT_SUCCESS(Status))
493  goto done;
494 
495  /* FIXME: use real unicode->oem conversion */
496 // for (i = 0; i < nLength; i++)
497 // pText[i] = (CHAR)lpCharacter[i];
498 
499  Status = NtDeviceIoControlFile(hConsoleOutput,
500  NULL,
501  NULL,
502  NULL,
503  &IoStatusBlock,
505  NULL,
506  0,
507  Buffer,
508  nLength + sizeof(COORD));
509 
510 done:
512  if (!NT_SUCCESS(Status))
513  return FALSE;
514 
515  *lpNumberOfCharsWritten = IoStatusBlock.Information;
516  return TRUE;
517 }
signed char * PCHAR
Definition: retypes.h:7
*BytesInOemString PCHAR OemString
Definition: rtlfuncs.h:1561
#define TRUE
Definition: types.h:120
*BytesInUnicodeString PWCH UnicodeString
Definition: rtlfuncs.h:1979
LPCSTR pText
Definition: txtscale.cpp:79
uint16_t * PWSTR
Definition: typedefs.h:55
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
_In_ DWORD nLength
Definition: wincon.h:476
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)
STRING OEM_STRING
Definition: umtypes.h:203
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define PCHAR
Definition: match.c:90
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToOemString(POEM_STRING DestinationString, PCUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
Definition: bl.h:1338
HANDLE ProcessHeap
Definition: servman.c:15
Status
Definition: gdiplustypes.h:24
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
NTSYSAPI DWORD WINAPI RtlUnicodeStringToOemSize(const UNICODE_STRING *)
unsigned int ULONG
Definition: retypes.h:1
#define IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER
Definition: ntddblue.h:20
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

Referenced by CONSOLE_SetInputTextXY(), test_cp932(), test_WriteConsoleOutputCharacterW(), and WriteStringAt().

Variable Documentation

◆ InputDataQueue

KEYBOARD_INPUT_DATA InputDataQueue
static

Definition at line 41 of file console.c.

Referenced by PeekConsoleInput(), and ReadConsoleInput().

◆ InputIosb

IO_STATUS_BLOCK InputIosb
static

Definition at line 42 of file console.c.

Referenced by PeekConsoleInput(), and ReadConsoleInput().

◆ InputQueueEmpty

BOOLEAN InputQueueEmpty
static

◆ LastLoadedCodepage

UINT LastLoadedCodepage
static

Definition at line 43 of file console.c.

Referenced by SetConsoleOutputCP().

◆ WaitForInput

BOOLEAN WaitForInput
static