ReactOS  0.4.15-dev-5459-gb85f005
console.h File Reference

Go to the source code of this file.

Functions

BOOL WINAPI AllocConsole (VOID)
 
BOOL WINAPI AttachConsole (IN DWORD dwProcessId)
 
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 FreeConsole (VOID)
 
BOOL WINAPI GetConsoleScreenBufferInfo (IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
 
HANDLE WINAPI GetStdHandle (IN DWORD nStdHandle)
 
BOOL WINAPI ReadConsoleInput (IN HANDLE hConsoleInput, OUT PINPUT_RECORD lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsRead)
 
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 WriteConsole (IN HANDLE hConsoleOutput, IN const VOID *lpBuffer, IN DWORD nNumberOfCharsToWrite, OUT LPDWORD lpNumberOfCharsWritten, IN LPVOID lpReserved)
 
BOOL WINAPI WriteConsoleOutputCharacterA (HANDLE hConsoleOutput, IN LPCSTR lpCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
 
BOOL WINAPI WriteConsoleOutputCharacterW (HANDLE hConsoleOutput, IN LPCSTR lpCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
 
BOOL WINAPI SetConsoleOutputCP (IN UINT wCodePageID)
 

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  /* Default to en-US output codepage */
117  SetConsoleOutputCP(437);
118 
119  /* Open the keyboard */
121  &KeyboardName,
122  0,
123  NULL,
124  NULL);
128  &IoStatusBlock,
129  FILE_OPEN,
130  0);
131  if (!NT_SUCCESS(Status))
132  {
134  return FALSE;
135  }
136 
137  /* Reset the queue state */
140 
141  return TRUE;
142 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
BOOL WINAPI SetConsoleOutputCP(IN UINT wCodepage)
Definition: console.c:695
#define FILE_ALL_ACCESS
Definition: nt_native.h:651
#define TRUE
Definition: types.h:120
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
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
HANDLE StdOutput
Definition: consup.c:37
Status
Definition: gdiplustypes.h:24
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:3402
static BOOLEAN InputQueueEmpty
Definition: console.c:39
#define IOCTL_CONSOLE_RESET_SCREEN
Definition: ntddblue.h:4
#define FILE_OPEN
Definition: from_kernel.h:54
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define NULL
Definition: types.h:112
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

◆ AttachConsole()

BOOL WINAPI AttachConsole ( IN DWORD  dwProcessId)

Definition at line 147 of file console.c.

149 {
150  return FALSE;
151 }
#define FALSE
Definition: types.h:117

Referenced by InitRappsConsole().

◆ FillConsoleOutputAttribute()

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

Definition at line 525 of file console.c.

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

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 560 of file console.c.

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

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().

◆ FreeConsole()

BOOL WINAPI FreeConsole ( VOID  )

Definition at line 156 of file console.c.

157 {
158  /* Reset the queue state */
161 
163  NtClose(StdInput);
164 
167 
168  return TRUE;
169 }
#define TRUE
Definition: types.h:120
HANDLE StdInput
Definition: consup.c:36
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
static BOOLEAN WaitForInput
Definition: console.c:40
#define FALSE
Definition: types.h:117
HANDLE StdOutput
Definition: consup.c:37
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
static BOOLEAN InputQueueEmpty
Definition: console.c:39

◆ GetConsoleScreenBufferInfo()

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

Definition at line 595 of file console.c.

598 {
601 
602  Status = NtDeviceIoControlFile(hConsoleOutput,
603  NULL,
604  NULL,
605  NULL,
606  &IoStatusBlock,
608  NULL,
609  0,
610  lpConsoleScreenBufferInfo,
612  return NT_SUCCESS(Status);
613 }
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)
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define NULL
Definition: types.h:112
#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 203 of file console.c.

205 {
206  switch (nStdHandle)
207  {
208  case STD_INPUT_HANDLE:
209  return StdInput;
210  case STD_OUTPUT_HANDLE:
211  return StdOutput;
212  default:
213  return INVALID_HANDLE_VALUE;
214  }
215 }
HANDLE StdInput
Definition: consup.c:36
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
HANDLE StdOutput
Definition: consup.c:37
#define STD_INPUT_HANDLE
Definition: winbase.h:267
#define STD_OUTPUT_HANDLE
Definition: winbase.h:268

Referenced by __report_error(), _cputs(), _kbhit(), _putch(), _tmain(), _tpopen(), _tWinMain(), ask_confirm(), ask_overwrite_value(), ata_open_file(), cfgets(), cgetchar(), cmd_type(), ConErrPrintf(), Confirm(), ConInDisable(), ConInEnable(), ConInFlush(), ConInKey(), ConInString(), ConOutPuts(), CONSOLE_Init(), ConsolePager(), CreateClientProcess(), DisplayError(), DisplayResourceText(), doChild(), DosCopyHandleTable(), DoTestEntry(), 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(), 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().

◆ ReadConsoleInput()

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

Definition at line 341 of file console.c.

346 {
349  KEYBOARD_INPUT_DATA InputData;
350 
351  if (InputQueueEmpty)
352  {
353  /* Read the keyboard and wait for an event, skipping the queue */
354  if (!WaitForInput)
355  {
356  Offset.QuadPart = 0;
357  Status = NtReadFile(hConsoleInput,
358  NULL,
359  NULL,
360  NULL,
361  &InputIosb,
363  sizeof(InputDataQueue),
364  &Offset,
365  NULL);
366  if (Status == STATUS_PENDING)
367  {
368  /* Block and wait for input */
369  WaitForInput = TRUE;
370  Status = NtWaitForSingleObject(hConsoleInput, FALSE, NULL);
373  }
374  if (!NT_SUCCESS(Status))
375  return FALSE;
376  }
377  else
378  {
379  /*
380  * We already tried to read from the keyboard and are
381  * waiting for data, block and wait for input.
382  */
383  Status = NtWaitForSingleObject(hConsoleInput, FALSE, NULL);
386  if (!NT_SUCCESS(Status))
387  return FALSE;
388  }
389  }
390 
391  /* Fetch from the queue and empty it */
392  InputData = InputDataQueue;
394 
395  lpBuffer->EventType = KEY_EVENT;
396  Status = IntTranslateKey(hConsoleInput, &InputData, &lpBuffer->Event.KeyEvent);
397  if (!NT_SUCCESS(Status))
398  return FALSE;
399 
401  return TRUE;
402 }
static KEYBOARD_INPUT_DATA InputDataQueue
Definition: console.c:41
static IO_STATUS_BLOCK InputIosb
Definition: console.c:42
_In_ DWORD _Out_ LPDWORD lpNumberOfEventsRead
Definition: wincon.h:473
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
static BOOLEAN WaitForInput
Definition: console.c:40
#define FALSE
Definition: types.h:117
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:175
#define KEY_EVENT
Definition: wincon.h:128
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
static BOOLEAN InputQueueEmpty
Definition: console.c:39
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define NULL
Definition: types.h:112
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 618 of file console.c.

621 {
624 
625  Status = NtDeviceIoControlFile(hConsoleOutput,
626  NULL,
627  NULL,
628  NULL,
629  &IoStatusBlock,
631  (PCONSOLE_CURSOR_INFO)lpConsoleCursorInfo,
632  sizeof(CONSOLE_CURSOR_INFO),
633  NULL,
634  0);
635  return NT_SUCCESS(Status);
636 }
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
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define NULL
Definition: types.h:112

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 641 of file console.c.

644 {
645  CONSOLE_SCREEN_BUFFER_INFO ConsoleScreenBufferInfo;
648 
649  Status = GetConsoleScreenBufferInfo(hConsoleOutput, &ConsoleScreenBufferInfo);
650  if (!NT_SUCCESS(Status))
651  return FALSE;
652 
653  ConsoleScreenBufferInfo.dwCursorPosition.X = dwCursorPosition.X;
654  ConsoleScreenBufferInfo.dwCursorPosition.Y = dwCursorPosition.Y;
655 
656  Status = NtDeviceIoControlFile(hConsoleOutput,
657  NULL,
658  NULL,
659  NULL,
660  &IoStatusBlock,
662  &ConsoleScreenBufferInfo,
664  NULL,
665  0);
666  return NT_SUCCESS(Status);
667 }
#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)
#define FALSE
Definition: types.h:117
BOOL WINAPI GetConsoleScreenBufferInfo(IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
Definition: console.c:595
ULONG X
Definition: bl.h:1339
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define NULL
Definition: types.h:112
ULONG Y
Definition: bl.h:1340

Referenced by ClearScreen(), ConClearLine(), ConClearScreen(), CONSOLE_SetCursorXY(), ConsolePager(), doChild(), PagePrompt(), 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  wCodePageID)

Definition at line 695 of file console.c.

697 {
698  static PCWSTR FontFile = L"\\SystemRoot\\vgafonts.cab";
699  WCHAR FontName[20];
700  CONSOLE_CABINET_CONTEXT ConsoleCabinetContext;
701  PCABINET_CONTEXT CabinetContext = &ConsoleCabinetContext.CabinetContext;
702  CAB_SEARCH Search;
703  ULONG CabStatus;
704  HANDLE hConsoleOutput;
707 
708  if (wCodepage == LastLoadedCodepage)
709  return TRUE;
710 
711  hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
712 
713  CabinetInitialize(CabinetContext);
714  CabinetSetEventHandlers(CabinetContext,
716  CabinetSetCabinetName(CabinetContext, FontFile);
717 
718  CabStatus = CabinetOpen(CabinetContext);
719  if (CabStatus != CAB_STATUS_SUCCESS)
720  {
721  DPRINT("CabinetOpen('%S') returned 0x%08x\n", FontFile, CabStatus);
722  return FALSE;
723  }
724 
725  RtlStringCbPrintfW(FontName, sizeof(FontName),
726  L"%u-8x8.bin", wCodepage);
727  CabStatus = CabinetFindFirst(CabinetContext, FontName, &Search);
728  if (CabStatus != CAB_STATUS_SUCCESS)
729  {
730  DPRINT("CabinetFindFirst('%S', '%S') returned 0x%08x\n", FontFile, FontName, CabStatus);
731  CabinetClose(CabinetContext);
732  return FALSE;
733  }
734 
735  CabStatus = CabinetExtractFile(CabinetContext, &Search);
736  CabinetClose(CabinetContext);
737  if (CabStatus != CAB_STATUS_SUCCESS)
738  {
739  DPRINT("CabinetExtractFile('%S', '%S') returned 0x%08x\n", FontFile, FontName, CabStatus);
740  if (ConsoleCabinetContext.Data)
741  RtlFreeHeap(ProcessHeap, 0, ConsoleCabinetContext.Data);
742  return FALSE;
743  }
744  ASSERT(ConsoleCabinetContext.Data);
745 
746  Status = NtDeviceIoControlFile(hConsoleOutput,
747  NULL,
748  NULL,
749  NULL,
750  &IoStatusBlock,
752  ConsoleCabinetContext.Data,
753  ConsoleCabinetContext.Size,
754  NULL,
755  0);
756 
757  RtlFreeHeap(ProcessHeap, 0, ConsoleCabinetContext.Data);
758 
759  if (!NT_SUCCESS(Status))
760  return FALSE;
761 
762  LastLoadedCodepage = wCodepage;
763  return TRUE;
764 }
VOID CabinetInitialize(IN OUT PCABINET_CONTEXT CabinetContext)
Definition: cabinet.c:501
const uint16_t * PCWSTR
Definition: typedefs.h:57
ULONG CabinetExtractFile(IN PCABINET_CONTEXT CabinetContext, IN PCAB_SEARCH Search)
Definition: cabinet.c:959
#define TRUE
Definition: types.h:120
VOID CabinetClose(IN OUT PCABINET_CONTEXT CabinetContext)
Definition: cabinet.c:801
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:203
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
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:44
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTRSAFEVAPI RtlStringCbPrintfW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1173
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:1340
#define CAB_STATUS_SUCCESS
Definition: cabinet.h:23
#define STD_OUTPUT_HANDLE
Definition: winbase.h:268
ULONG CabinetOpen(IN OUT PCABINET_CONTEXT CabinetContext)
Definition: cabinet.c:621
HANDLE ProcessHeap
Definition: servman.c:15
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:820
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
static UINT LastLoadedCodepage
Definition: console.c:43
#define NULL
Definition: types.h:112
#define IOCTL_CONSOLE_LOADFONT
Definition: ntddblue.h:24
unsigned int ULONG
Definition: retypes.h:1
#define DPRINT
Definition: sndvol32.h:71

Referenced by AllocConsole(), ChangeOutputCP_(), doChild(), SetConsoleCodePage(), SetConsoleCPState(), START_TEST(), test_Console(), test_cp855(), test_cp932(), test_CP_ThreadLang(), testScreenBuffer(), and wmain().

◆ SetConsoleTextAttribute()

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

Definition at line 672 of file console.c.

675 {
678 
679  Status = NtDeviceIoControlFile(hConsoleOutput,
680  NULL,
681  NULL,
682  NULL,
683  &IoStatusBlock,
685  &wAttributes,
686  sizeof(USHORT),
687  NULL,
688  0);
689  return NT_SUCCESS(Status);
690 }
#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)
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
unsigned short USHORT
Definition: pedump.c:61
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define NULL
Definition: types.h:112

Referenced by ConSetScreenColor(), main(), 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 174 of file console.c.

180 {
183 
184  Status = NtWriteFile(hConsoleOutput,
185  NULL,
186  NULL,
187  NULL,
188  &IoStatusBlock,
189  (PVOID)lpBuffer,
190  nNumberOfCharsToWrite,
191  NULL,
192  NULL);
193  if (!NT_SUCCESS(Status))
194  return FALSE;
195 
196  *lpNumberOfCharsWritten = IoStatusBlock.Information;
197  return TRUE;
198 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define FALSE
Definition: types.h:117
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
Status
Definition: gdiplustypes.h:24
#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)
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define NULL
Definition: types.h:112

◆ WriteConsoleOutputCharacterA()

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

Definition at line 407 of file console.c.

413 {
415  PCHAR Buffer;
416  COORD *pCoord;
417  PCHAR pText;
419 
421  0,
422  nLength + sizeof(COORD));
423  pCoord = (COORD *)Buffer;
424  pText = (PCHAR)(pCoord + 1);
425 
426  *pCoord = dwWriteCoord;
427  memcpy(pText, lpCharacter, nLength);
428 
429  Status = NtDeviceIoControlFile(hConsoleOutput,
430  NULL,
431  NULL,
432  NULL,
433  &IoStatusBlock,
435  NULL,
436  0,
437  Buffer,
438  nLength + sizeof(COORD));
439 
441  if (!NT_SUCCESS(Status))
442  return FALSE;
443 
444  *lpNumberOfCharsWritten = IoStatusBlock.Information;
445  return TRUE;
446 }
signed char * PCHAR
Definition: retypes.h:7
LPCSTR pText
Definition: txtscale.cpp:79
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define TRUE
Definition: types.h:120
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:473
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 FALSE
Definition: types.h:117
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
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: bl.h:1337
HANDLE ProcessHeap
Definition: servman.c:15
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define NULL
Definition: types.h:112
#define IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER
Definition: ntddblue.h:20

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 LPCSTR  lpCharacter,
IN DWORD  nLength,
IN COORD  dwWriteCoord,
OUT LPDWORD  lpNumberOfCharsWritten 
)