ReactOS  0.4.15-dev-313-g8fde48b
conoutput.c File Reference
#include "consrv.h"
#include <debug.h>
Include dependency graph for conoutput.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI ConDrvWriteConsoleOutputVDM (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN PCHAR_CELL CharInfo, IN COORD CharInfoSize, IN PSMALL_RECT WriteRegion)
 
NTSTATUS NTAPI ConDrvInvalidateBitMapRect (IN PCONSOLE Console, IN PCONSOLE_SCREEN_BUFFER Buffer, IN PSMALL_RECT Region)
 
 CON_API (SrvInvalidateBitMapRect, CONSOLE_INVALIDATEDIBITS, InvalidateDIBitsRequest)
 
NTSTATUS NTAPI ConDrvSetConsolePalette (IN PCONSOLE Console, IN PCONSOLE_SCREEN_BUFFER Buffer, IN HPALETTE PaletteHandle, IN UINT PaletteUsage)
 
 CON_API (SrvSetConsolePalette, CONSOLE_SETPALETTE, SetPaletteRequest)
 
NTSTATUS NTAPI ConDrvGetConsoleCursorInfo (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, OUT PCONSOLE_CURSOR_INFO CursorInfo)
 
 CON_API (SrvGetConsoleCursorInfo, CONSOLE_GETSETCURSORINFO, CursorInfoRequest)
 
NTSTATUS NTAPI ConDrvSetConsoleCursorInfo (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN PCONSOLE_CURSOR_INFO CursorInfo)
 
 CON_API (SrvSetConsoleCursorInfo, CONSOLE_GETSETCURSORINFO, CursorInfoRequest)
 
NTSTATUS NTAPI ConDrvSetConsoleCursorPosition (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN PCOORD Position)
 
 CON_API (SrvSetConsoleCursorPosition, CONSOLE_SETCURSORPOSITION, SetCursorPositionRequest)
 
 CON_API (SrvCreateConsoleScreenBuffer, CONSOLE_CREATESCREENBUFFER, CreateScreenBufferRequest)
 
NTSTATUS NTAPI ConDrvSetConsoleActiveScreenBuffer (IN PCONSOLE Console, IN PCONSOLE_SCREEN_BUFFER Buffer)
 
 CON_API (SrvSetConsoleActiveScreenBuffer, CONSOLE_SETACTIVESCREENBUFFER, SetScreenBufferRequest)
 
static NTSTATUS DoWriteConsole (IN PCSR_API_MESSAGE ApiMessage, IN PCSR_THREAD ClientThread, IN BOOLEAN CreateWaitBlock OPTIONAL)
 
static BOOLEAN NTAPI WriteConsoleThread (IN PLIST_ENTRY WaitList, IN PCSR_THREAD WaitThread, IN PCSR_API_MESSAGE WaitApiMessage, IN PVOID WaitContext, IN PVOID WaitArgument1, IN PVOID WaitArgument2, IN ULONG WaitFlags)
 
NTSTATUS NTAPI ConDrvWriteConsole (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER ScreenBuffer, IN BOOLEAN Unicode, IN PVOID StringBuffer, IN ULONG NumCharsToWrite, OUT PULONG NumCharsWritten OPTIONAL)
 
NTSTATUS NTAPI ConDrvReadConsoleOutput (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN BOOLEAN Unicode, OUT PCHAR_INFO CharInfo, IN OUT PSMALL_RECT ReadRegion)
 
 CON_API (SrvReadConsoleOutput, CONSOLE_READOUTPUT, ReadOutputRequest)
 
NTSTATUS NTAPI ConDrvWriteConsoleOutput (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN BOOLEAN Unicode, IN PCHAR_INFO CharInfo, IN OUT PSMALL_RECT WriteRegion)
 
 CON_API (SrvWriteConsoleOutput, CONSOLE_WRITEOUTPUT, WriteOutputRequest)
 
 CON_API (SrvWriteConsole, CONSOLE_WRITECONSOLE, WriteConsoleRequest)
 
NTSTATUS NTAPI ConDrvReadConsoleOutputString (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN CODE_TYPE CodeType, OUT PVOID StringBuffer, IN ULONG NumCodesToRead, IN PCOORD ReadCoord, OUT PULONG NumCodesRead OPTIONAL)
 
 CON_API (SrvReadConsoleOutputString, CONSOLE_READOUTPUTCODE, ReadOutputCodeRequest)
 
NTSTATUS NTAPI ConDrvWriteConsoleOutputString (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN CODE_TYPE CodeType, IN PVOID StringBuffer, IN ULONG NumCodesToWrite, IN PCOORD WriteCoord, OUT PULONG NumCodesWritten OPTIONAL)
 
 CON_API (SrvWriteConsoleOutputString, CONSOLE_WRITEOUTPUTCODE, WriteOutputCodeRequest)
 
NTSTATUS NTAPI ConDrvFillConsoleOutput (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN CODE_TYPE CodeType, IN CODE_ELEMENT Code, IN ULONG NumCodesToWrite, IN PCOORD WriteCoord, OUT PULONG NumCodesWritten OPTIONAL)
 
 CON_API (SrvFillConsoleOutput, CONSOLE_FILLOUTPUTCODE, FillOutputRequest)
 
NTSTATUS NTAPI ConDrvGetConsoleScreenBufferInfo (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, OUT PCOORD ScreenBufferSize, OUT PCOORD CursorPosition, OUT PCOORD ViewOrigin, OUT PCOORD ViewSize, OUT PCOORD MaximumViewSize, OUT PWORD Attributes)
 
 CON_API (SrvGetConsoleScreenBufferInfo, CONSOLE_GETSCREENBUFFERINFO, ScreenBufferInfoRequest)
 
NTSTATUS NTAPI ConDrvSetConsoleTextAttribute (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN WORD Attributes)
 
 CON_API (SrvSetConsoleTextAttribute, CONSOLE_SETTEXTATTRIB, SetTextAttribRequest)
 
NTSTATUS NTAPI ConDrvSetConsoleScreenBufferSize (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN PCOORD Size)
 
 CON_API (SrvSetConsoleScreenBufferSize, CONSOLE_SETSCREENBUFFERSIZE, SetScreenBufferSizeRequest)
 
NTSTATUS NTAPI ConDrvScrollConsoleScreenBuffer (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN BOOLEAN Unicode, IN PSMALL_RECT ScrollRectangle, IN BOOLEAN UseClipRectangle, IN PSMALL_RECT ClipRectangle OPTIONAL, IN PCOORD DestinationOrigin, IN CHAR_INFO FillChar)
 
 CON_API (SrvScrollConsoleScreenBuffer, CONSOLE_SCROLLSCREENBUFFER, ScrollScreenBufferRequest)
 
NTSTATUS NTAPI ConDrvSetConsoleWindowInfo (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN BOOLEAN Absolute, IN PSMALL_RECT WindowRect)
 
 CON_API (SrvSetConsoleWindowInfo, CONSOLE_SETWINDOWINFO, SetWindowInfoRequest)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file conoutput.c.

Function Documentation

◆ CON_API() [1/18]

CON_API ( SrvInvalidateBitMapRect  ,
CONSOLE_INVALIDATEDIBITS  ,
InvalidateDIBitsRequest   
)

Definition at line 34 of file conoutput.c.

36 {
39 
40  Status = ConSrvGetScreenBuffer(ProcessData,
41  InvalidateDIBitsRequest->OutputHandle,
43  if (!NT_SUCCESS(Status))
44  return Status;
45 
46  ASSERT((PCONSOLE)Console == Buffer->Header.Console);
47 
48  /* In text-mode only, draw the VDM buffer if present */
49  if (GetType(Buffer) == TEXTMODE_BUFFER && Console->VDMBuffer)
50  {
52 
54  TextBuffer,
55  Console->VDMBuffer,
56  Console->VDMBufferSize,
57  &InvalidateDIBitsRequest->Region);
58  }
59 
61  Buffer,
62  &InvalidateDIBitsRequest->Region);
63 
65  return Status;
66 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI ConDrvWriteConsoleOutputVDM(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN PCHAR_CELL CharInfo, IN COORD CharInfoSize, IN PSMALL_RECT WriteRegion)
Definition: text.c:708
Definition: bufpool.h:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
#define ConSrvGetScreenBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:26
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
INT GetType(BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102)
Definition: gettype.c:129
#define GENERIC_READ
Definition: compat.h:124
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI ConDrvInvalidateBitMapRect(IN PCONSOLE Console, IN PCONSOLE_SCREEN_BUFFER Buffer, IN PSMALL_RECT Region)
Definition: conoutput.c:209
CConsole Console
char TextBuffer[BUFFERLEN]
Definition: combotst.c:45
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
struct _TEXTMODE_SCREEN_BUFFER * PTEXTMODE_SCREEN_BUFFER

◆ CON_API() [2/18]

CON_API ( SrvSetConsolePalette  ,
CONSOLE_SETPALETTE  ,
SetPaletteRequest   
)

Definition at line 75 of file conoutput.c.

77 {
79  // PGRAPHICS_SCREEN_BUFFER Buffer;
81 
82  // NOTE: Tests show that this function is used only for graphics screen buffers
83  // and otherwise it returns FALSE + sets last error to invalid handle.
84  // I think it's ridiculous, because if you are in text mode, simulating
85  // a change of VGA palette via DAC registers (done by a call to SetConsolePalette)
86  // cannot be done... So I allow it in ReactOS !
87  /*
88  Status = ConSrvGetGraphicsBuffer(ProcessData,
89  SetPaletteRequest->OutputHandle,
90  &Buffer, GENERIC_WRITE, TRUE);
91  */
92  Status = ConSrvGetScreenBuffer(ProcessData,
93  SetPaletteRequest->OutputHandle,
95  if (!NT_SUCCESS(Status))
96  return Status;
97 
98  ASSERT((PCONSOLE)Console == Buffer->Header.Console);
99 
100  /*
101  * Make the palette handle public, so that it can be
102  * used by other threads calling GDI functions on it.
103  * Indeed, the palette handle comes from a console app
104  * calling ourselves, running in CSRSS.
105  */
107  &SetPaletteRequest->PaletteHandle,
108  sizeof(SetPaletteRequest->PaletteHandle));
109 
111  Buffer,
112  SetPaletteRequest->PaletteHandle,
113  SetPaletteRequest->Usage);
114 
116  return Status;
117 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define GENERIC_WRITE
Definition: nt_native.h:90
NTSTATUS APIENTRY NtUserConsoleControl(IN CONSOLECONTROL ConsoleCtrl, IN PVOID ConsoleCtrlInfo, IN ULONG ConsoleCtrlInfoLength)
Definition: console.c:14
Definition: bufpool.h:45
NTSTATUS NTAPI ConDrvSetConsolePalette(IN PCONSOLE Console, IN PCONSOLE_SCREEN_BUFFER Buffer, IN HPALETTE PaletteHandle, IN UINT PaletteUsage)
Definition: conoutput.c:226
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
#define ConSrvGetScreenBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:26
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
CConsole Console
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CON_API() [3/18]

CON_API ( SrvGetConsoleCursorInfo  ,
CONSOLE_GETSETCURSORINFO  ,
CursorInfoRequest   
)

Definition at line 124 of file conoutput.c.

126 {
129 
130  Status = ConSrvGetTextModeBuffer(ProcessData,
131  CursorInfoRequest->OutputHandle,
133  if (!NT_SUCCESS(Status))
134  return Status;
135 
136  ASSERT((PCONSOLE)Console == Buffer->Header.Console);
137 
139  Buffer,
140  &CursorInfoRequest->Info);
141 
143  return Status;
144 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI ConDrvGetConsoleCursorInfo(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, OUT PCONSOLE_CURSOR_INFO CursorInfo)
Definition: conoutput.c:270
Definition: bufpool.h:45
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define GENERIC_READ
Definition: compat.h:124
Status
Definition: gdiplustypes.h:24
CConsole Console
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CON_API() [4/18]

CON_API ( SrvSetConsoleCursorInfo  ,
CONSOLE_GETSETCURSORINFO  ,
CursorInfoRequest   
)

Definition at line 151 of file conoutput.c.

153 {
156 
157  Status = ConSrvGetTextModeBuffer(ProcessData,
158  CursorInfoRequest->OutputHandle,
160  if (!NT_SUCCESS(Status))
161  return Status;
162 
163  ASSERT((PCONSOLE)Console == Buffer->Header.Console);
164 
166  Buffer,
167  &CursorInfoRequest->Info);
168 
170  return Status;
171 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define GENERIC_WRITE
Definition: nt_native.h:90
Definition: bufpool.h:45
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
NTSTATUS NTAPI ConDrvSetConsoleCursorInfo(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN PCONSOLE_CURSOR_INFO CursorInfo)
Definition: conoutput.c:288
Status
Definition: gdiplustypes.h:24
CConsole Console
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CON_API() [5/18]

CON_API ( SrvSetConsoleCursorPosition  ,
CONSOLE_SETCURSORPOSITION  ,
SetCursorPositionRequest   
)

Definition at line 178 of file conoutput.c.

180 {
183 
184  Status = ConSrvGetTextModeBuffer(ProcessData,
185  SetCursorPositionRequest->OutputHandle,
187  if (!NT_SUCCESS(Status))
188  return Status;
189 
190  ASSERT((PCONSOLE)Console == Buffer->Header.Console);
191 
193  Buffer,
194  &SetCursorPositionRequest->Position);
195 
197  return Status;
198 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define GENERIC_WRITE
Definition: nt_native.h:90
Definition: bufpool.h:45
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI ConDrvSetConsoleCursorPosition(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN PCOORD Position)
Definition: conoutput.c:318
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
CConsole Console
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CON_API() [6/18]

CON_API ( SrvCreateConsoleScreenBuffer  ,
CONSOLE_CREATESCREENBUFFER  ,
CreateScreenBufferRequest   
)

Definition at line 201 of file conoutput.c.

203 {
206  // PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(Process);
208 
210  TEXTMODE_BUFFER_INFO TextModeInfo = {{80, 25},
211  {80, 25},
214  TRUE,
216  GRAPHICS_BUFFER_INFO GraphicsInfo;
217  GraphicsInfo.Info = CreateScreenBufferRequest->GraphicsBufferInfo; // HACK for MSVC
218 
219  if (CreateScreenBufferRequest->ScreenBufferType == CONSOLE_TEXTMODE_BUFFER)
220  {
221  ScreenBufferInfo = &TextModeInfo;
222 
223  /*
224  * This is Windows behaviour, as described by MSDN and verified manually:
225  *
226  * The newly created screen buffer will copy some properties from the
227  * active screen buffer at the time that this function is called.
228  * The behavior is as follows:
229  * Font - copied from active screen buffer.
230  * Display Window Size - copied from active screen buffer.
231  * Buffer Size - matched to Display Window Size (NOT copied).
232  * Default Attributes (colors) - copied from active screen buffer.
233  * Default Popup Attributes (colors) - copied from active screen buffer.
234  */
235 
236  /* If we have an active screen buffer, use its attributes as the new ones */
237  if (Console->ActiveBuffer && GetType(Console->ActiveBuffer) == TEXTMODE_BUFFER)
238  {
240 
241  TextModeInfo.ScreenAttrib = Buffer->ScreenDefaultAttrib;
242  TextModeInfo.PopupAttrib = Buffer->PopupDefaultAttrib;
243 
244  TextModeInfo.CursorSize = Buffer->CursorInfo.dwSize;
245  TextModeInfo.IsCursorVisible = Buffer->CursorInfo.bVisible;
246 
247  /* Use the current view size */
248  TextModeInfo.ScreenBufferSize = Buffer->ViewSize;
249  TextModeInfo.ViewSize = Buffer->ViewSize;
250  }
251  else
252  {
253  /* Use the current console size */
254  TextModeInfo.ScreenBufferSize = Console->ConsoleSize;
255  TextModeInfo.ViewSize = Console->ConsoleSize;
256  }
257 
258  /* Normalize the screen buffer size if needed */
259  if (TextModeInfo.ScreenBufferSize.X == 0) TextModeInfo.ScreenBufferSize.X = 1;
260  if (TextModeInfo.ScreenBufferSize.Y == 0) TextModeInfo.ScreenBufferSize.Y = 1;
261  }
262  else if (CreateScreenBufferRequest->ScreenBufferType == CONSOLE_GRAPHICS_BUFFER)
263  {
264  /* Get information from the graphics buffer information structure */
265  if (!CsrValidateMessageBuffer(ApiMessage,
266  (PVOID*)&CreateScreenBufferRequest->GraphicsBufferInfo.lpBitMapInfo,
267  CreateScreenBufferRequest->GraphicsBufferInfo.dwBitMapInfoLength,
268  sizeof(BYTE)))
269  {
271  }
272 
273  ScreenBufferInfo = &GraphicsInfo;
274 
275  /* Initialize shared variables */
276  // CreateScreenBufferRequest->GraphicsBufferInfo.hMutex
277  CreateScreenBufferRequest->hMutex = GraphicsInfo.Info.hMutex = INVALID_HANDLE_VALUE;
278  // CreateScreenBufferRequest->GraphicsBufferInfo.lpBitMap
279  CreateScreenBufferRequest->lpBitMap = GraphicsInfo.Info.lpBitMap = NULL;
280 
281  /* A graphics screen buffer is never inheritable */
282  CreateScreenBufferRequest->InheritHandle = FALSE;
283  }
284  else
285  {
286  DPRINT1("Invalid ScreenBuffer type %lu\n", CreateScreenBufferRequest->ScreenBufferType);
288  }
289 
291  (PCONSOLE)Console,
292  Process->ProcessHandle,
293  CreateScreenBufferRequest->ScreenBufferType,
295  if (!NT_SUCCESS(Status))
296  return Status;
297 
298  /* Insert the new handle inside the process handles table */
299  RtlEnterCriticalSection(&ProcessData->HandleTableLock);
300 
301  Status = ConSrvInsertObject(ProcessData,
302  &CreateScreenBufferRequest->OutputHandle,
303  &Buff->Header,
304  CreateScreenBufferRequest->DesiredAccess,
305  CreateScreenBufferRequest->InheritHandle,
306  CreateScreenBufferRequest->ShareMode);
307 
308  RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
309 
310  if (!NT_SUCCESS(Status))
311  {
313  return Status;
314  }
315 
316  if (CreateScreenBufferRequest->ScreenBufferType == CONSOLE_GRAPHICS_BUFFER)
317  {
319  /*
320  * Initialize the graphics buffer information structure
321  * and give it back to the client.
322  */
323  // CreateScreenBufferRequest->GraphicsBufferInfo.hMutex
324  CreateScreenBufferRequest->hMutex = Buffer->ClientMutex;
325  // CreateScreenBufferRequest->GraphicsBufferInfo.lpBitMap
326  CreateScreenBufferRequest->lpBitMap = Buffer->ClientBitMap;
327  }
328 
329  return Status;
330 }
CONSOLE_GRAPHICS_BUFFER_INFO Info
Definition: conio.h:142
#define DEFAULT_SCREEN_ATTRIB
Definition: settings.c:29
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
VOID NTAPI ConDrvDeleteScreenBuffer(PCONSOLE_SCREEN_BUFFER Buffer)
Definition: conoutput.c:130
CONSOLE_SCREEN_BUFFER_INFO ScreenBufferInfo
Definition: notevil.c:38
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1426
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define INVALID_HANDLE_VALUE
Definition: compat.h:400
BOOLEAN IsCursorVisible
Definition: conio.h:121
NTSTATUS ConDrvCreateScreenBuffer(OUT PCONSOLE_SCREEN_BUFFER *Buffer, IN PCONSOLE Console, IN HANDLE ProcessHandle OPTIONAL, IN ULONG BufferType, IN PVOID ScreenBufferInfo)
Definition: conoutput.c:85
CONSOLE_IO_OBJECT Header
Definition: conio.h:58
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
ULONG X
Definition: bl.h:1340
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define CSR_DEFAULT_CURSOR_SIZE
Definition: settings.c:26
struct _GRAPHICS_SCREEN_BUFFER * PGRAPHICS_SCREEN_BUFFER
INT GetType(BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102)
Definition: gettype.c:129
unsigned char BYTE
Definition: xxhash.c:193
USHORT PopupAttrib
Definition: conio.h:119
Status
Definition: gdiplustypes.h:24
#define DEFAULT_POPUP_ATTRIB
Definition: settings.c:30
#define CONSOLE_TEXTMODE_BUFFER
Definition: wincon.h:62
#define CONSOLE_GRAPHICS_BUFFER
Definition: wincon.h:63
CConsole Console
#define DPRINT1
Definition: precomp.h:8
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
NTSTATUS ConSrvInsertObject(IN PCONSOLE_PROCESS_DATA ProcessData, OUT PHANDLE Handle, IN PCONSOLE_IO_OBJECT Object, IN ULONG Access, IN BOOLEAN Inheritable, IN ULONG ShareMode)
Definition: handle.c:227
ULONG Y
Definition: bl.h:1341
struct _TEXTMODE_SCREEN_BUFFER * PTEXTMODE_SCREEN_BUFFER
COORD ScreenBufferSize
Definition: conio.h:116
USHORT ScreenAttrib
Definition: conio.h:118

◆ CON_API() [7/18]

CON_API ( SrvSetConsoleActiveScreenBuffer  ,
CONSOLE_SETACTIVESCREENBUFFER  ,
SetScreenBufferRequest   
)

Definition at line 336 of file conoutput.c.

338 {
341 
342  Status = ConSrvGetScreenBuffer(ProcessData,
343  SetScreenBufferRequest->OutputHandle,
345  if (!NT_SUCCESS(Status))
346  return Status;
347 
348  ASSERT((PCONSOLE)Console == Buffer->Header.Console);
349 
351 
353  return Status;
354 }
NTSTATUS NTAPI ConDrvSetConsoleActiveScreenBuffer(IN PCONSOLE Console, IN PCONSOLE_SCREEN_BUFFER Buffer)
Definition: conoutput.c:177
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define GENERIC_WRITE
Definition: nt_native.h:90
Definition: bufpool.h:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
#define ConSrvGetScreenBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:26
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
CConsole Console
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CON_API() [8/18]

CON_API ( SrvReadConsoleOutput  ,
CONSOLE_READOUTPUT  ,
ReadOutputRequest   
)

Definition at line 499 of file conoutput.c.

501 {
504  ULONG NumCells;
505  PCHAR_INFO CharInfo;
506 
507  NumCells = ConioRectWidth(&ReadOutputRequest->ReadRegion) *
508  ConioRectHeight(&ReadOutputRequest->ReadRegion);
509 
510  /*
511  * For optimization purposes, Windows (and hence ReactOS, too, for
512  * compatibility reasons) uses a static buffer if no more than one
513  * cell is read. Otherwise a new buffer is used.
514  * The client-side expects that we know this behaviour.
515  */
516  if (NumCells <= 1)
517  {
518  /*
519  * Adjust the internal pointer, because its old value points to
520  * the static buffer in the original ApiMessage structure.
521  */
522  // ReadOutputRequest->CharInfo = &ReadOutputRequest->StaticBuffer;
523  CharInfo = &ReadOutputRequest->StaticBuffer;
524  }
525  else
526  {
527  if (!CsrValidateMessageBuffer(ApiMessage,
528  (PVOID*)&ReadOutputRequest->CharInfo,
529  NumCells,
530  sizeof(CHAR_INFO)))
531  {
533  }
534 
535  CharInfo = ReadOutputRequest->CharInfo;
536  }
537 
538  Status = ConSrvGetTextModeBuffer(ProcessData,
539  ReadOutputRequest->OutputHandle,
541  if (!NT_SUCCESS(Status))
542  return Status;
543 
544  ASSERT((PCONSOLE)Console == Buffer->Header.Console);
545 
547  Buffer,
548  ReadOutputRequest->Unicode,
549  CharInfo,
550  &ReadOutputRequest->ReadRegion);
551 
553  return Status;
554 }
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1426
#define ConioRectWidth(Rect)
Definition: readwrite.c:24
#define ConioRectHeight(Rect)
Definition: readwrite.c:22
Definition: bufpool.h:45
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define GENERIC_READ
Definition: compat.h:124
Status
Definition: gdiplustypes.h:24
CConsole Console
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS NTAPI ConDrvReadConsoleOutput(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN BOOLEAN Unicode, OUT PCHAR_INFO CharInfo, IN OUT PSMALL_RECT ReadRegion)
Definition: text.c:569
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CON_API() [9/18]

CON_API ( SrvWriteConsoleOutput  ,
CONSOLE_WRITEOUTPUT  ,
WriteOutputRequest   
)

Definition at line 563 of file conoutput.c.

565 {
568  // PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(Process);
570  ULONG NumCells;
571  PCHAR_INFO CharInfo;
572 
573  NumCells = ConioRectWidth(&WriteOutputRequest->WriteRegion) *
574  ConioRectHeight(&WriteOutputRequest->WriteRegion);
575 
576  Status = ConSrvGetTextModeBuffer(ProcessData,
577  WriteOutputRequest->OutputHandle,
579  if (!NT_SUCCESS(Status))
580  return Status;
581 
582  ASSERT((PCONSOLE)Console == Buffer->Header.Console);
583 
584  /*
585  * Validate the message buffer if we do not use a process' heap buffer
586  * (CsrAllocateCaptureBuffer succeeded because we haven't allocated
587  * a too large (>= 64 kB, size of the CSR heap) data buffer).
588  */
589  if (!WriteOutputRequest->UseVirtualMemory)
590  {
591  /*
592  * For optimization purposes, Windows (and hence ReactOS, too, for
593  * compatibility reasons) uses a static buffer if no more than one
594  * cell is written. Otherwise a new buffer is used.
595  * The client-side expects that we know this behaviour.
596  */
597  if (NumCells <= 1)
598  {
599  /*
600  * Adjust the internal pointer, because its old value points to
601  * the static buffer in the original ApiMessage structure.
602  */
603  // WriteOutputRequest->CharInfo = &WriteOutputRequest->StaticBuffer;
604  CharInfo = &WriteOutputRequest->StaticBuffer;
605  }
606  else
607  {
608  if (!CsrValidateMessageBuffer(ApiMessage,
609  (PVOID*)&WriteOutputRequest->CharInfo,
610  NumCells,
611  sizeof(CHAR_INFO)))
612  {
614  goto Quit;
615  }
616 
617  CharInfo = WriteOutputRequest->CharInfo;
618  }
619  }
620  else
621  {
622  /*
623  * This was not the case: we use a heap buffer. Retrieve its contents.
624  */
625  ULONG Size = NumCells * sizeof(CHAR_INFO);
626 
628  if (CharInfo == NULL)
629  {
631  goto Quit;
632  }
633 
634  Status = NtReadVirtualMemory(Process->ProcessHandle,
635  WriteOutputRequest->CharInfo,
636  CharInfo,
637  Size,
638  NULL);
639  if (!NT_SUCCESS(Status))
640  {
641  ConsoleFreeHeap(CharInfo);
642  // Status = STATUS_NO_MEMORY;
643  goto Quit;
644  }
645  }
646 
648  Buffer,
649  WriteOutputRequest->Unicode,
650  CharInfo,
651  &WriteOutputRequest->WriteRegion);
652 
653  /* Free the temporary buffer if we used the process' heap buffer */
654  if (WriteOutputRequest->UseVirtualMemory && CharInfo)
655  ConsoleFreeHeap(CharInfo);
656 
657 Quit:
659  return Status;
660 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1426
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
#define ConioRectWidth(Rect)
Definition: readwrite.c:24
#define GENERIC_WRITE
Definition: nt_native.h:90
struct _CHAR_INFO CHAR_INFO
smooth NULL
Definition: ftsmooth.c:416
#define ConioRectHeight(Rect)
Definition: readwrite.c:22
Definition: bufpool.h:45
NTSTATUS NTAPI ConDrvWriteConsoleOutput(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN BOOLEAN Unicode, IN PCHAR_INFO CharInfo, IN OUT PSMALL_RECT WriteRegion)
Definition: text.c:638
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
NTSTATUS NTAPI NtReadVirtualMemory(IN HANDLE ProcessHandle, IN PVOID BaseAddress, OUT PVOID Buffer, IN SIZE_T NumberOfBytesToRead, OUT PSIZE_T NumberOfBytesRead OPTIONAL)
Definition: virtual.c:2691
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
Status
Definition: gdiplustypes.h:24
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
CConsole Console
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
unsigned int ULONG
Definition: retypes.h:1
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CON_API() [10/18]

CON_API ( SrvWriteConsole  ,
CONSOLE_WRITECONSOLE  ,
WriteConsoleRequest   
)

Definition at line 663 of file conoutput.c.

665 {
667 
668  DPRINT("SrvWriteConsole\n");
669 
670  /*
671  * For optimization purposes, Windows (and hence ReactOS, too, for
672  * compatibility reasons) uses a static buffer if no more than eighty
673  * bytes are written. Otherwise a new buffer is used.
674  * The client-side expects that we know this behaviour.
675  */
676  if (WriteConsoleRequest->UsingStaticBuffer &&
677  WriteConsoleRequest->NumBytes <= sizeof(WriteConsoleRequest->StaticBuffer))
678  {
679  /*
680  * Adjust the internal pointer, because its old value points to
681  * the static buffer in the original ApiMessage structure.
682  */
683  // WriteConsoleRequest->Buffer = WriteConsoleRequest->StaticBuffer;
684  }
685  else
686  {
687  if (!CsrValidateMessageBuffer(ApiMessage,
688  (PVOID)&WriteConsoleRequest->Buffer,
689  WriteConsoleRequest->NumBytes,
690  sizeof(BYTE)))
691  {
693  }
694  }
695 
696  Status = DoWriteConsole(ApiMessage, CsrGetClientThread(), TRUE);
697 
698  if (Status == STATUS_PENDING) *ReplyCode = CsrReplyPending;
699 
700  return Status;
701 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
static NTSTATUS DoWriteConsole(IN PCSR_API_MESSAGE ApiMessage, IN PCSR_THREAD ClientThread, IN BOOLEAN CreateWaitBlock OPTIONAL)
Definition: conoutput.c:409
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1426
void DPRINT(...)
Definition: polytest.cpp:61
#define STATUS_PENDING
Definition: ntstatus.h:82
unsigned char BYTE
Definition: xxhash.c:193
Status
Definition: gdiplustypes.h:24

◆ CON_API() [11/18]

CON_API ( SrvReadConsoleOutputString  ,
CONSOLE_READOUTPUTCODE  ,
ReadOutputCodeRequest   
)

Definition at line 713 of file conoutput.c.

715 {
718  ULONG CodeSize;
719  PVOID pCode;
720 
721  switch (ReadOutputCodeRequest->CodeType)
722  {
723  case CODE_ASCII:
724  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, AsciiChar);
725  break;
726 
727  case CODE_UNICODE:
728  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, UnicodeChar);
729  break;
730 
731  case CODE_ATTRIBUTE:
732  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, Attribute);
733  break;
734 
735  default:
737  }
738 
739  /*
740  * For optimization purposes, Windows (and hence ReactOS, too, for
741  * compatibility reasons) uses a static buffer if no more than eighty
742  * bytes are read. Otherwise a new buffer is used.
743  * The client-side expects that we know this behaviour.
744  */
745  if (ReadOutputCodeRequest->NumCodes * CodeSize <= sizeof(ReadOutputCodeRequest->CodeStaticBuffer))
746  {
747  /*
748  * Adjust the internal pointer, because its old value points to
749  * the static buffer in the original ApiMessage structure.
750  */
751  // ReadOutputCodeRequest->pCode = ReadOutputCodeRequest->CodeStaticBuffer;
752  pCode = ReadOutputCodeRequest->CodeStaticBuffer;
753  }
754  else
755  {
756  if (!CsrValidateMessageBuffer(ApiMessage,
757  (PVOID*)&ReadOutputCodeRequest->pCode,
758  ReadOutputCodeRequest->NumCodes,
759  CodeSize))
760  {
762  }
763 
764  pCode = ReadOutputCodeRequest->pCode;
765  }
766 
767  Status = ConSrvGetTextModeBuffer(ProcessData,
768  ReadOutputCodeRequest->OutputHandle,
770  if (!NT_SUCCESS(Status))
771  {
772  ReadOutputCodeRequest->NumCodes = 0;
773  return Status;
774  }
775 
776  ASSERT((PCONSOLE)Console == Buffer->Header.Console);
777 
779  Buffer,
780  ReadOutputCodeRequest->CodeType,
781  pCode,
782  ReadOutputCodeRequest->NumCodes,
783  &ReadOutputCodeRequest->Coord,
784  // &ReadOutputCodeRequest->EndCoord,
785  &ReadOutputCodeRequest->NumCodes);
786 
788  return Status;
789 }
#define RTL_FIELD_SIZE(type, field)
Definition: kdb_expr.c:84
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1426
Definition: bufpool.h:45
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define GENERIC_READ
Definition: compat.h:124
Status
Definition: gdiplustypes.h:24
CConsole Console
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS NTAPI ConDrvReadConsoleOutputString(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN CODE_TYPE CodeType, OUT PVOID StringBuffer, IN ULONG NumCodesToRead, IN PCOORD ReadCoord, OUT PULONG NumCodesRead OPTIONAL)
Definition: text.c:942
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CON_API() [12/18]

CON_API ( SrvWriteConsoleOutputString  ,
CONSOLE_WRITEOUTPUTCODE  ,
WriteOutputCodeRequest   
)

Definition at line 801 of file conoutput.c.

803 {
806  ULONG CodeSize;
807  PVOID pCode;
808 
809  switch (WriteOutputCodeRequest->CodeType)
810  {
811  case CODE_ASCII:
812  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, AsciiChar);
813  break;
814 
815  case CODE_UNICODE:
816  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, UnicodeChar);
817  break;
818 
819  case CODE_ATTRIBUTE:
820  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, Attribute);
821  break;
822 
823  default:
825  }
826 
827  /*
828  * For optimization purposes, Windows (and hence ReactOS, too, for
829  * compatibility reasons) uses a static buffer if no more than eighty
830  * bytes are written. Otherwise a new buffer is used.
831  * The client-side expects that we know this behaviour.
832  */
833  if (WriteOutputCodeRequest->NumCodes * CodeSize <= sizeof(WriteOutputCodeRequest->CodeStaticBuffer))
834  {
835  /*
836  * Adjust the internal pointer, because its old value points to
837  * the static buffer in the original ApiMessage structure.
838  */
839  // WriteOutputCodeRequest->pCode = WriteOutputCodeRequest->CodeStaticBuffer;
840  pCode = WriteOutputCodeRequest->CodeStaticBuffer;
841  }
842  else
843  {
844  if (!CsrValidateMessageBuffer(ApiMessage,
845  (PVOID*)&WriteOutputCodeRequest->pCode,
846  WriteOutputCodeRequest->NumCodes,
847  CodeSize))
848  {
850  }
851 
852  pCode = WriteOutputCodeRequest->pCode;
853  }
854 
855  Status = ConSrvGetTextModeBuffer(ProcessData,
856  WriteOutputCodeRequest->OutputHandle,
858  if (!NT_SUCCESS(Status))
859  {
860  WriteOutputCodeRequest->NumCodes = 0;
861  return Status;
862  }
863 
864  ASSERT((PCONSOLE)Console == Buffer->Header.Console);
865 
867  Buffer,
868  WriteOutputCodeRequest->CodeType,
869  pCode,
870  WriteOutputCodeRequest->NumCodes,
871  &WriteOutputCodeRequest->Coord,
872  // &WriteOutputCodeRequest->EndCoord,
873  &WriteOutputCodeRequest->NumCodes);
874 
876  return Status;
877 }
#define RTL_FIELD_SIZE(type, field)
Definition: kdb_expr.c:84
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1426
#define GENERIC_WRITE
Definition: nt_native.h:90
NTSTATUS NTAPI ConDrvWriteConsoleOutputString(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN CODE_TYPE CodeType, IN PVOID StringBuffer, IN ULONG NumCodesToWrite, IN PCOORD WriteCoord, OUT PULONG NumCodesWritten OPTIONAL)
Definition: text.c:1161
Definition: bufpool.h:45
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
CConsole Console
unsigned int ULONG
Definition: retypes.h:1
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CON_API() [13/18]

CON_API ( SrvFillConsoleOutput  ,
CONSOLE_FILLOUTPUTCODE  ,
FillOutputRequest   
)

Definition at line 888 of file conoutput.c.

890 {
893  CODE_TYPE CodeType = FillOutputRequest->CodeType;
894 
895  if ( (CodeType != CODE_ASCII ) &&
896  (CodeType != CODE_UNICODE ) &&
897  (CodeType != CODE_ATTRIBUTE) )
898  {
900  }
901 
902  Status = ConSrvGetTextModeBuffer(ProcessData,
903  FillOutputRequest->OutputHandle,
905  if (!NT_SUCCESS(Status))
906  {
907  FillOutputRequest->NumCodes = 0;
908  return Status;
909  }
910 
911  ASSERT((PCONSOLE)Console == Buffer->Header.Console);
912 
914  Buffer,
915  CodeType,
916  FillOutputRequest->Code,
917  FillOutputRequest->NumCodes,
918  &FillOutputRequest->WriteCoord,
919  &FillOutputRequest->NumCodes);
920 
922  return Status;
923 }
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define GENERIC_WRITE
Definition: nt_native.h:90
Definition: bufpool.h:45
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
CConsole Console
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
enum _CODE_TYPE CODE_TYPE
NTSTATUS NTAPI ConDrvFillConsoleOutput(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN CODE_TYPE CodeType, IN CODE_ELEMENT Code, IN ULONG NumCodesToWrite, IN PCOORD WriteCoord, OUT PULONG NumCodesWritten OPTIONAL)
Definition: text.c:1251

◆ CON_API() [14/18]

CON_API ( SrvGetConsoleScreenBufferInfo  ,
CONSOLE_GETSCREENBUFFERINFO  ,
ScreenBufferInfoRequest   
)

Definition at line 935 of file conoutput.c.

937 {
940 
941  Status = ConSrvGetTextModeBuffer(ProcessData,
942  ScreenBufferInfoRequest->OutputHandle,
944  if (!NT_SUCCESS(Status))
945  return Status;
946 
947  ASSERT((PCONSOLE)Console == Buffer->Header.Console);
948 
950  Buffer,
951  &ScreenBufferInfoRequest->ScreenBufferSize,
952  &ScreenBufferInfoRequest->CursorPosition,
953  &ScreenBufferInfoRequest->ViewOrigin,
954  &ScreenBufferInfoRequest->ViewSize,
955  &ScreenBufferInfoRequest->MaximumViewSize,
956  &ScreenBufferInfoRequest->Attributes);
957 
959  return Status;
960 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define GENERIC_READ
Definition: compat.h:124
Status
Definition: gdiplustypes.h:24
CConsole Console
NTSTATUS NTAPI ConDrvGetConsoleScreenBufferInfo(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, OUT PCOORD ScreenBufferSize, OUT PCOORD CursorPosition, OUT PCOORD ViewOrigin, OUT PCOORD ViewSize, OUT PCOORD MaximumViewSize, OUT PWORD Attributes)
Definition: text.c:1380
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CON_API() [15/18]

CON_API ( SrvSetConsoleTextAttribute  ,
CONSOLE_SETTEXTATTRIB  ,
SetTextAttribRequest   
)

Definition at line 967 of file conoutput.c.

969 {
972 
973  Status = ConSrvGetTextModeBuffer(ProcessData,
974  SetTextAttribRequest->OutputHandle,
976  if (!NT_SUCCESS(Status))
977  return Status;
978 
979  ASSERT((PCONSOLE)Console == Buffer->Header.Console);
980 
982  Buffer,
983  SetTextAttribRequest->Attributes);
984 
986  return Status;
987 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define GENERIC_WRITE
Definition: nt_native.h:90
Definition: bufpool.h:45
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI ConDrvSetConsoleTextAttribute(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN WORD Attributes)
Definition: text.c:1420
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
CConsole Console
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CON_API() [16/18]

CON_API ( SrvSetConsoleScreenBufferSize  ,
CONSOLE_SETSCREENBUFFERSIZE  ,
SetScreenBufferSizeRequest   
)

Definition at line 994 of file conoutput.c.

996 {
999 
1000  Status = ConSrvGetTextModeBuffer(ProcessData,
1001  SetScreenBufferSizeRequest->OutputHandle,
1003  if (!NT_SUCCESS(Status))
1004  return Status;
1005 
1006  ASSERT((PCONSOLE)Console == Buffer->Header.Console);
1007 
1009  Buffer,
1010  &SetScreenBufferSizeRequest->Size);
1011 
1013  return Status;
1014 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define GENERIC_WRITE
Definition: nt_native.h:90
Definition: bufpool.h:45
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
CConsole Console
NTSTATUS NTAPI ConDrvSetConsoleScreenBufferSize(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN PCOORD Size)
Definition: text.c:1435
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CON_API() [17/18]

CON_API ( SrvScrollConsoleScreenBuffer  ,
CONSOLE_SCROLLSCREENBUFFER  ,
ScrollScreenBufferRequest   
)

Definition at line 1026 of file conoutput.c.

1028 {
1029  NTSTATUS Status;
1031 
1032  Status = ConSrvGetTextModeBuffer(ProcessData,
1033  ScrollScreenBufferRequest->OutputHandle,
1035  if (!NT_SUCCESS(Status))
1036  return Status;
1037 
1038  ASSERT((PCONSOLE)Console == Buffer->Header.Console);
1039 
1041  Buffer,
1042  ScrollScreenBufferRequest->Unicode,
1043  &ScrollScreenBufferRequest->ScrollRectangle,
1044  ScrollScreenBufferRequest->UseClipRectangle,
1045  &ScrollScreenBufferRequest->ClipRectangle,
1046  &ScrollScreenBufferRequest->DestinationOrigin,
1047  ScrollScreenBufferRequest->Fill);
1048 
1050  return Status;
1051 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define GENERIC_WRITE
Definition: nt_native.h:90
Definition: bufpool.h:45
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
CConsole Console
NTSTATUS NTAPI ConDrvScrollConsoleScreenBuffer(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN BOOLEAN Unicode, IN PSMALL_RECT ScrollRectangle, IN BOOLEAN UseClipRectangle, IN PSMALL_RECT ClipRectangle OPTIONAL, IN PCOORD DestinationOrigin, IN CHAR_INFO FillChar)
Definition: text.c:1454
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CON_API() [18/18]

CON_API ( SrvSetConsoleWindowInfo  ,
CONSOLE_SETWINDOWINFO  ,
SetWindowInfoRequest   
)

Definition at line 1059 of file conoutput.c.

1061 {
1062  NTSTATUS Status;
1063  // PCONSOLE_SCREEN_BUFFER Buffer;
1065 
1066  DPRINT("SrvSetConsoleWindowInfo(0x%08x, %d, {L%d, T%d, R%d, B%d}) called\n",
1067  SetWindowInfoRequest->OutputHandle, SetWindowInfoRequest->Absolute,
1068  SetWindowInfoRequest->WindowRect.Left ,
1069  SetWindowInfoRequest->WindowRect.Top ,
1070  SetWindowInfoRequest->WindowRect.Right,
1071  SetWindowInfoRequest->WindowRect.Bottom);
1072 
1073  // ConSrvGetScreenBuffer
1074  Status = ConSrvGetTextModeBuffer(ProcessData,
1075  SetWindowInfoRequest->OutputHandle,
1076  &Buffer, GENERIC_READ, TRUE);
1077  if (!NT_SUCCESS(Status))
1078  return Status;
1079 
1080  ASSERT((PCONSOLE)Console == Buffer->Header.Console);
1081 
1083  Buffer,
1084  SetWindowInfoRequest->Absolute,
1085  &SetWindowInfoRequest->WindowRect);
1086 
1088  return Status;
1089 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define GENERIC_READ
Definition: compat.h:124
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI ConDrvSetConsoleWindowInfo(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN BOOLEAN Absolute, IN PSMALL_RECT WindowRect)
Definition: text.c:1579
CConsole Console
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ ConDrvFillConsoleOutput()

NTSTATUS NTAPI ConDrvFillConsoleOutput ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  Buffer,
IN CODE_TYPE  CodeType,
IN CODE_ELEMENT  Code,
IN ULONG  NumCodesToWrite,
IN PCOORD  WriteCoord,
OUT PULONG NumCodesWritten  OPTIONAL 
)

Definition at line 1251 of file text.c.

1258 {
1259  SHORT X, Y;
1260  SHORT XStart;
1261  ULONG nNumChars = 0;
1262  PCHAR_INFO Ptr;
1263  BOOLEAN bLead, bFullwidth;
1264 
1265  if (Console == NULL || Buffer == NULL || WriteCoord == NULL)
1266  {
1267  return STATUS_INVALID_PARAMETER;
1268  }
1269 
1270  /* Validity check */
1271  ASSERT(Console == Buffer->Header.Console);
1272 
1273  if (NumCodesWritten)
1274  *NumCodesWritten = 0;
1275 
1276  if (NumCodesToWrite == 0)
1277  return STATUS_SUCCESS; // Nothing to do!
1278 
1279  /* Do nothing if the writing starting point is outside of the screen buffer */
1280  if ( WriteCoord->X < 0 || WriteCoord->X >= Buffer->ScreenBufferSize.X ||
1281  WriteCoord->Y < 0 || WriteCoord->Y >= Buffer->ScreenBufferSize.Y )
1282  {
1283  return STATUS_SUCCESS;
1284  }
1285 
1286  NumCodesToWrite = min(NumCodesToWrite, (ULONG)Buffer->ScreenBufferSize.X * Buffer->ScreenBufferSize.Y);
1287 
1288  if (CodeType == CODE_ASCII)
1289  {
1290  /* Conversion from the ASCII char to the UNICODE char */
1291  CODE_ELEMENT tmp;
1293  Code = tmp;
1294  }
1295 
1296  XStart = WriteCoord->X;
1297 
1298  /* For Chinese, Japanese and Korean */
1299  X = XStart;
1300  Y = WriteCoord->Y;
1301  bLead = TRUE;
1302  bFullwidth = FALSE;
1303  if (Console->IsCJK)
1304  {
1305  bFullwidth = IS_FULL_WIDTH(Code.UnicodeChar);
1306  if (X > 0)
1307  {
1308  Ptr = ConioCoordToPointer(Buffer, X - 1, Y);
1309  if (Ptr->Attributes & COMMON_LVB_LEADING_BYTE)
1310  {
1311  Ptr->Char.UnicodeChar = L' ';
1312  Ptr->Attributes &= ~COMMON_LVB_SBCSDBCS;
1313  }
1314  }
1315  }
1316 
1317  for (Y = WriteCoord->Y; Y < Buffer->ScreenBufferSize.Y; ++Y)
1318  {
1319  Ptr = ConioCoordToPointer(Buffer, XStart, Y);
1320  for (X = XStart; X < Buffer->ScreenBufferSize.X; ++X)
1321  {
1322  if (nNumChars >= NumCodesToWrite)
1323  goto Quit;
1324 
1325  switch (CodeType)
1326  {
1327  case CODE_ASCII:
1328  case CODE_UNICODE:
1329  Ptr->Char.UnicodeChar = Code.UnicodeChar;
1330  Ptr->Attributes &= ~COMMON_LVB_SBCSDBCS;
1331  if (bFullwidth)
1332  {
1333  if (bLead)
1334  Ptr->Attributes |= COMMON_LVB_LEADING_BYTE;
1335  else
1336  Ptr->Attributes |= COMMON_LVB_TRAILING_BYTE;
1337  }
1338  bLead = !bLead;
1339  break;
1340 
1341  case CODE_ATTRIBUTE:
1342  Ptr->Attributes &= COMMON_LVB_SBCSDBCS;
1343  Ptr->Attributes |= (Code.Attribute & ~COMMON_LVB_SBCSDBCS);
1344  break;
1345  }
1346 
1347  ++Ptr;
1348 
1349  ++nNumChars;
1350  }
1351  /* Restart at the beginning of the next line */
1352  XStart = 0;
1353  }
1354 Quit:
1355 
1356  if ((nNumChars & 1) & bFullwidth)
1357  {
1358  if (X + Y * Buffer->ScreenBufferSize.X > 0)
1359  {
1360  Ptr = ConioCoordToPointer(Buffer, X - 1, Y);
1361  Ptr->Char.UnicodeChar = L' ';
1362  Ptr->Attributes &= ~COMMON_LVB_SBCSDBCS;
1363  }
1364  }
1365 
1366  if (NumCodesWritten)
1367  *NumCodesWritten = nNumChars;
1368 
1369  if ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer)
1370  {
1372  ConioComputeUpdateRect(Buffer, &UpdateRect, WriteCoord, nNumChars);
1374  }
1375 
1376  return STATUS_SUCCESS;
1377 }
#define TRUE
Definition: types.h:120
#define Y(I)
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y)
Definition: text.c:143
WCHAR UnicodeChar
Definition: conmsg.h:525
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
#define COMMON_LVB_SBCSDBCS
Definition: wincon.h:56
#define TermDrawRegion(Console, Region)
Definition: term.h:22
static VOID ConioComputeUpdateRect(IN PTEXTMODE_SCREEN_BUFFER Buff, IN OUT PSMALL_RECT UpdateRect, IN PCOORD Start, IN UINT Length)
Definition: text.c:165
#define ConsoleOutputAnsiToUnicodeChar(Console, dWChar, sChar)
Definition: text.c:31
short SHORT
Definition: pedump.c:59
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define Code
Definition: deflate.h:80
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const WCHAR L[]
Definition: oid.c:1250
#define min(a, b)
Definition: monoChain.cc:55
CConsole Console
#define COMMON_LVB_LEADING_BYTE
Definition: wincon.h:48
unsigned int ULONG
Definition: retypes.h:1
static int UpdateRect(TreeListData *pData, unsigned uItem, unsigned uSub)
Definition: treelist.c:1529
#define COMMON_LVB_TRAILING_BYTE
Definition: wincon.h:49
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define IS_FULL_WIDTH(wch)
Definition: conio.h:333
#define X(b, s)

Referenced by CON_API().

◆ ConDrvGetConsoleCursorInfo()

NTSTATUS NTAPI ConDrvGetConsoleCursorInfo ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  Buffer,
OUT PCONSOLE_CURSOR_INFO  CursorInfo 
)

Definition at line 270 of file conoutput.c.

273 {
274  if (Console == NULL || Buffer == NULL || CursorInfo == NULL)
276 
277  /* Validity check */
278  ASSERT(Console == Buffer->Header.Console);
279 
280  *CursorInfo = Buffer->CursorInfo;
281  // CursorInfo->bVisible = Buffer->CursorInfo.bVisible;
282  // CursorInfo->dwSize = Buffer->CursorInfo.dwSize;
283 
284  return STATUS_SUCCESS;
285 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
CConsole Console
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by CON_API().

◆ ConDrvGetConsoleScreenBufferInfo()

NTSTATUS NTAPI ConDrvGetConsoleScreenBufferInfo ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  Buffer,
OUT PCOORD  ScreenBufferSize,
OUT PCOORD  CursorPosition,
OUT PCOORD  ViewOrigin,
OUT PCOORD  ViewSize,
OUT PCOORD  MaximumViewSize,
OUT PWORD  Attributes 
)

Definition at line 1380 of file text.c.

1388 {
1389  COORD LargestWindowSize;
1390 
1391  if (Console == NULL || Buffer == NULL || ScreenBufferSize == NULL ||
1392  CursorPosition == NULL || ViewOrigin == NULL || ViewSize == NULL ||
1393  MaximumViewSize == NULL || Attributes == NULL)
1394  {
1395  return STATUS_INVALID_PARAMETER;
1396  }
1397 
1398  /* Validity check */
1399  ASSERT(Console == Buffer->Header.Console);
1400 
1401  *ScreenBufferSize = Buffer->ScreenBufferSize;
1402  *CursorPosition = Buffer->CursorPosition;
1403  *ViewOrigin = Buffer->ViewOrigin;
1404  *ViewSize = Buffer->ViewSize;
1405  *Attributes = Buffer->ScreenDefaultAttrib;
1406 
1407  /*
1408  * Retrieve the largest possible console window size, taking
1409  * into account the size of the console screen buffer.
1410  */
1411  TermGetLargestConsoleWindowSize(Console, &LargestWindowSize);
1412  LargestWindowSize.X = min(LargestWindowSize.X, Buffer->ScreenBufferSize.X);
1413  LargestWindowSize.Y = min(LargestWindowSize.Y, Buffer->ScreenBufferSize.Y);
1414  *MaximumViewSize = LargestWindowSize;
1415 
1416  return STATUS_SUCCESS;
1417 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
ULONG X
Definition: bl.h:1340
#define TermGetLargestConsoleWindowSize(Console, pSize)
Definition: term.h:34
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: bl.h:1338
_Must_inspect_result_ _In_ USHORT _In_ PHIDP_PREPARSED_DATA _Out_writes_to_ LengthAttributes PHIDP_EXTENDED_ATTRIBUTES Attributes
Definition: hidpi.h:348
#define min(a, b)
Definition: monoChain.cc:55
CConsole Console
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T ViewSize
Definition: mmfuncs.h:404
return STATUS_SUCCESS
Definition: btrfs.c:3014
ULONG Y
Definition: bl.h:1341
static USHORT CursorPosition
Definition: pc98cons.c:20

Referenced by CON_API().

◆ ConDrvInvalidateBitMapRect()

NTSTATUS NTAPI ConDrvInvalidateBitMapRect ( IN PCONSOLE  Console,
IN PCONSOLE_SCREEN_BUFFER  Buffer,
IN PSMALL_RECT  Region 
)

Definition at line 209 of file conoutput.c.

212 {
213  if (Console == NULL || Buffer == NULL || Region == NULL)
215 
216  /* Validity check */
217  ASSERT(Console == Buffer->Header.Console);
218 
219  /* If the output buffer is the current one, redraw the correct portion of the screen */
220  if (Buffer == Console->ActiveBuffer) TermDrawRegion(Console, Region);
221 
222  return STATUS_SUCCESS;
223 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define TermDrawRegion(Console, Region)
Definition: term.h:22
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
CConsole Console
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by CON_API().

◆ ConDrvReadConsoleOutput()

NTSTATUS NTAPI ConDrvReadConsoleOutput ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  Buffer,
IN BOOLEAN  Unicode,
OUT PCHAR_INFO  CharInfo,
IN OUT PSMALL_RECT  ReadRegion 
)

Definition at line 569 of file text.c.

574 {
575  SHORT X, Y;
577  PCHAR_INFO CurCharInfo;
578  SMALL_RECT CapturedReadRegion;
579  PCHAR_INFO Ptr;
580 
581  if (Console == NULL || Buffer == NULL || CharInfo == NULL || ReadRegion == NULL)
582  {
584  }
585 
586  /* Validity check */
587  ASSERT(Console == Buffer->Header.Console);
588 
589  CapturedReadRegion = *ReadRegion;
590 
591  /* Make sure ReadRegion is inside the screen buffer */
593  Buffer->ScreenBufferSize.Y - 1,
594  Buffer->ScreenBufferSize.X - 1);
595  if (!ConioGetIntersection(&CapturedReadRegion, &CapturedReadRegion, &ScreenBuffer))
596  {
597  /*
598  * It is okay to have a ReadRegion completely outside
599  * the screen buffer. No data is read then.
600  */
601  return STATUS_SUCCESS;
602  }
603 
604  CurCharInfo = CharInfo;
605 
606  for (Y = CapturedReadRegion.Top; Y <= CapturedReadRegion.Bottom; ++Y)
607  {
608  Ptr = ConioCoordToPointer(Buffer, CapturedReadRegion.Left, Y);
609  for (X = CapturedReadRegion.Left; X <= CapturedReadRegion.Right; ++X)
610  {
611  if (Unicode)
612  {
613  CurCharInfo->Char.UnicodeChar = Ptr->Char.UnicodeChar;
614  }
615  else
616  {
617  // ConsoleOutputUnicodeToAnsiChar(Console, &CurCharInfo->Char.AsciiChar, &Ptr->Char.UnicodeChar);
618  WideCharToMultiByte(Console->OutputCodePage, 0, &Ptr->Char.UnicodeChar, 1,
619  &CurCharInfo->Char.AsciiChar, 1, NULL, NULL);
620  }
621 #if (_WIN32_WINNT < _WIN32_WINNT_WIN8)
622  /* NOTE: Windows < 8 compatibility: DBCS flags are filtered out */
623  CurCharInfo->Attributes = (Ptr->Attributes & ~COMMON_LVB_SBCSDBCS);
624 #else
625  CurCharInfo->Attributes = Ptr->Attributes;
626 #endif
627  ++Ptr;
628  ++CurCharInfo;
629  }
630  }
631 
632  *ReadRegion = CapturedReadRegion;
633 
634  return STATUS_SUCCESS;
635 }
CHAR AsciiChar
Definition: wincon.h:185
#define WideCharToMultiByte
Definition: compat.h:101
#define Y(I)
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y)
Definition: text.c:143
WCHAR UnicodeChar
Definition: wincon.h:184
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
#define COMMON_LVB_SBCSDBCS
Definition: wincon.h:56
short SHORT
Definition: pedump.c:59
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
SHORT Left
Definition: blue.h:32
SHORT Bottom
Definition: blue.h:35
WORD Attributes
Definition: wincon.h:187
SHORT Top
Definition: blue.h:33
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
union _CHAR_INFO::@3201 Char
#define ConioInitRect(Rect, top, left, bottom, right)
Definition: rect.h:20
CConsole Console
HANDLE ScreenBuffer
Definition: notevil.c:37
static __inline BOOLEAN ConioGetIntersection(OUT PSMALL_RECT Intersection, IN PSMALL_RECT Rect1, IN PSMALL_RECT Rect2)
Definition: rect.h:38
SHORT Right
Definition: blue.h:34
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define X(b, s)

Referenced by CON_API().

◆ ConDrvReadConsoleOutputString()

NTSTATUS NTAPI ConDrvReadConsoleOutputString ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  Buffer,
IN CODE_TYPE  CodeType,
OUT PVOID  StringBuffer,
IN ULONG  NumCodesToRead,
IN PCOORD  ReadCoord,
OUT PULONG NumCodesRead  OPTIONAL 
)

Definition at line 942 of file text.c.

950 {
951  if (Console == NULL || Buffer == NULL || ReadCoord == NULL /* || EndCoord == NULL */)
952  {
954  }
955 
956  /* Validity checks */
957  ASSERT(Console == Buffer->Header.Console);
958  ASSERT((StringBuffer != NULL) || (StringBuffer == NULL && NumCodesToRead == 0));
959 
960  if (NumCodesRead)
961  *NumCodesRead = 0;
962 
963  if (!StringBuffer || (NumCodesToRead == 0))
964  return STATUS_SUCCESS; // Nothing to do!
965 
966  /* Do nothing if the reading starting point is outside of the screen buffer */
967  if ( ReadCoord->X < 0 || ReadCoord->X >= Buffer->ScreenBufferSize.X ||
968  ReadCoord->Y < 0 || ReadCoord->Y >= Buffer->ScreenBufferSize.Y )
969  {
970  return STATUS_SUCCESS;
971  }
972 
973  NumCodesToRead = min(NumCodesToRead, (ULONG)Buffer->ScreenBufferSize.X * Buffer->ScreenBufferSize.Y);
974 
975  switch (CodeType)
976  {
977  case CODE_ASCII:
978  {
980  Buffer,
981  StringBuffer,
982  FALSE,
983  NumCodesToRead,
984  ReadCoord,
985  NumCodesRead);
986  }
987 
988  case CODE_UNICODE:
989  {
991  Buffer,
992  StringBuffer,
993  TRUE,
994  NumCodesToRead,
995  ReadCoord,
996  NumCodesRead);
997  }
998 
999  case CODE_ATTRIBUTE:
1000  {
1001  C_ASSERT(RTL_FIELD_SIZE(CODE_ELEMENT, Attribute) == sizeof(WORD));
1003  Buffer,
1005  NumCodesToRead,
1006  ReadCoord,
1007  NumCodesRead);
1008  }
1009 
1010  default:
1011  return STATUS_INVALID_PARAMETER;
1012  }
1013 }
#define RTL_FIELD_SIZE(type, field)
Definition: kdb_expr.c:84
static NTSTATUS IntReadConsoleOutputStringChars(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, OUT PVOID StringBuffer, IN BOOLEAN Unicode, IN ULONG NumCodesToRead, IN PCOORD ReadCoord, OUT PULONG NumCodesRead OPTIONAL)
Definition: text.c:835
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
static NTSTATUS IntReadConsoleOutputStringAttributes(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, OUT PWORD StringBuffer, IN ULONG NumCodesToRead, IN PCOORD ReadCoord, OUT PULONG NumCodesRead OPTIONAL)
Definition: text.c:903
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define C_ASSERT(e)
Definition: intsafe.h:79
WORD * PWORD
Definition: pedump.c:67
unsigned short WORD
Definition: ntddk_ex.h:93
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define min(a, b)
Definition: monoChain.cc:55
CConsole Console
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:3014
WCHAR StringBuffer[156]
Definition: ldrinit.c:41

Referenced by CON_API().

◆ ConDrvScrollConsoleScreenBuffer()

NTSTATUS NTAPI ConDrvScrollConsoleScreenBuffer ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  Buffer,
IN BOOLEAN  Unicode,
IN PSMALL_RECT  ScrollRectangle,
IN BOOLEAN  UseClipRectangle,
IN PSMALL_RECT ClipRectangle  OPTIONAL,
IN PCOORD  DestinationOrigin,
IN CHAR_INFO  FillChar 
)

Definition at line 1454 of file text.c.

1463 {
1464  COORD CapturedDestinationOrigin;
1466  SMALL_RECT CapturedClipRectangle;
1467  SMALL_RECT SrcRegion;
1468  SMALL_RECT DstRegion;
1469  SMALL_RECT UpdateRegion;
1470 
1471  if (Console == NULL || Buffer == NULL || ScrollRectangle == NULL ||
1472  (UseClipRectangle && (ClipRectangle == NULL)) || DestinationOrigin == NULL)
1473  {
1474  return STATUS_INVALID_PARAMETER;
1475  }
1476 
1477  /* Validity check */
1478  ASSERT(Console == Buffer->Header.Console);
1479 
1480  CapturedDestinationOrigin = *DestinationOrigin;
1481 
1482  /* Make sure the source rectangle is inside the screen buffer */
1483  ConioInitRect(&ScreenBuffer, 0, 0,
1484  Buffer->ScreenBufferSize.Y - 1,
1485  Buffer->ScreenBufferSize.X - 1);
1486  if (!ConioGetIntersection(&SrcRegion, ScrollRectangle, &ScreenBuffer))
1487  {
1488  return STATUS_SUCCESS;
1489  }
1490 
1491  /* If the source was clipped on the left or top, adjust the destination accordingly */
1492  if (ScrollRectangle->Left < 0)
1493  CapturedDestinationOrigin.X -= ScrollRectangle->Left;
1494  if (ScrollRectangle->Top < 0)
1495  CapturedDestinationOrigin.Y -= ScrollRectangle->Top;
1496 
1497  /*
1498  * If a clip rectangle is provided, clip it to the screen buffer,
1499  * otherwise use the latter one as the clip rectangle.
1500  */
1501  if (UseClipRectangle)
1502  {
1503  CapturedClipRectangle = *ClipRectangle;
1504  if (!ConioGetIntersection(&CapturedClipRectangle, &CapturedClipRectangle, &ScreenBuffer))
1505  {
1506  return STATUS_SUCCESS;
1507  }
1508  }
1509  else
1510  {
1511  CapturedClipRectangle = ScreenBuffer;
1512  }
1513 
1514  /*
1515  * Windows compatibility: Do nothing if the intersection of the source region
1516  * with the clip rectangle is empty, even if the intersection of destination
1517  * region with the clip rectangle is NOT empty and therefore it would have
1518  * been possible to copy contents to it...
1519  */
1520  if (!ConioGetIntersection(&UpdateRegion, &SrcRegion, &CapturedClipRectangle))
1521  {
1522  return STATUS_SUCCESS;
1523  }
1524 
1525  /* Initialize the destination rectangle, of same size as the source rectangle */
1526  ConioInitRect(&DstRegion,
1527  CapturedDestinationOrigin.Y,
1528  CapturedDestinationOrigin.X,
1529  CapturedDestinationOrigin.Y + ConioRectHeight(&SrcRegion) - 1,
1530  CapturedDestinationOrigin.X + ConioRectWidth(&SrcRegion ) - 1);
1531 
1532  if (ConioGetIntersection(&DstRegion, &DstRegion, &CapturedClipRectangle))
1533  {
1534  /*
1535  * Build the region image, within the source region,
1536  * of the destination region we should copy into.
1537  */
1538  SrcRegion.Left += DstRegion.Left - CapturedDestinationOrigin.X;
1539  SrcRegion.Top += DstRegion.Top - CapturedDestinationOrigin.Y;
1540  SrcRegion.Right = SrcRegion.Left + (DstRegion.Right - DstRegion.Left);
1541  SrcRegion.Bottom = SrcRegion.Top + (DstRegion.Bottom - DstRegion.Top);
1542 
1543  /* Do the copy */
1544  CapturedDestinationOrigin.X = DstRegion.Left;
1545  CapturedDestinationOrigin.Y = DstRegion.Top;
1546  ConioCopyRegion(Buffer, &SrcRegion, &CapturedDestinationOrigin);
1547  }
1548 
1549  if (!Unicode)
1550  {
1551  /* Conversion from the ASCII char to the UNICODE char */
1552  WCHAR tmp;
1553  ConsoleOutputAnsiToUnicodeChar(Console, &tmp, &FillChar.Char.AsciiChar);
1554  FillChar.Char.UnicodeChar = tmp;
1555  }
1556  /* Sanitize the attribute */
1557  FillChar.Attributes &= ~COMMON_LVB_SBCSDBCS;
1558 
1559  /*
1560  * Fill the intersection (== UpdateRegion) of the source region with the
1561  * clip rectangle, excluding the destination region.
1562  */
1563  ConioFillRegion(Buffer, &UpdateRegion, &DstRegion, FillChar);
1564 
1565  if ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer)
1566  {
1567  ConioGetUnion(&UpdateRegion, &UpdateRegion, &DstRegion);
1568  if (ConioGetIntersection(&UpdateRegion, &UpdateRegion, &CapturedClipRectangle))
1569  {
1570  /* Draw update region */
1571  TermDrawRegion(Console, &UpdateRegion);
1572  }
1573  }
1574 
1575  return STATUS_SUCCESS;
1576 }
static VOID ConioFillRegion(IN PTEXTMODE_SCREEN_BUFFER ScreenBuffer, IN PSMALL_RECT Region, IN PSMALL_RECT ExcludeRegion OPTIONAL, IN CHAR_INFO FillChar)
Definition: text.c:290
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define COMMON_LVB_SBCSDBCS
Definition: wincon.h:56
#define TermDrawRegion(Console, Region)
Definition: term.h:22
#define ConsoleOutputAnsiToUnicodeChar(Console, dWChar, sChar)
Definition: text.c:31
#define ConioRectWidth(Rect)
Definition: readwrite.c:24
smooth NULL
Definition: ftsmooth.c:416
#define ConioRectHeight(Rect)
Definition: readwrite.c:22
Definition: bufpool.h:45
static VOID ConioCopyRegion(IN PTEXTMODE_SCREEN_BUFFER ScreenBuffer, IN PSMALL_RECT SrcRegion, IN PCOORD DstOrigin)
Definition: text.c:193
SHORT Left
Definition: blue.h:32
ULONG X
Definition: bl.h:1340
SHORT Bottom
Definition: blue.h:35
__wchar_t WCHAR
Definition: xmlstorage.h:180
SHORT Top
Definition: blue.h:33
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static __inline BOOLEAN ConioGetUnion(OUT PSMALL_RECT Union, IN PSMALL_RECT Rect1, IN PSMALL_RECT Rect2)
Definition: rect.h:64
Definition: bl.h:1338
#define ConioInitRect(Rect, top, left, bottom, right)
Definition: rect.h:20
CConsole Console
HANDLE ScreenBuffer
Definition: notevil.c:37
static __inline BOOLEAN ConioGetIntersection(OUT PSMALL_RECT Intersection, IN PSMALL_RECT Rect1, IN PSMALL_RECT Rect2)
Definition: rect.h:38
SHORT Right
Definition: blue.h:34
return STATUS_SUCCESS
Definition: btrfs.c:3014
ULONG Y
Definition: bl.h:1341

Referenced by CON_API().

◆ ConDrvSetConsoleActiveScreenBuffer()

NTSTATUS NTAPI ConDrvSetConsoleActiveScreenBuffer ( IN PCONSOLE  Console,
IN PCONSOLE_SCREEN_BUFFER  Buffer 
)

Definition at line 177 of file conoutput.c.

179 {
180  if (Console == NULL || Buffer == NULL)
182 
183  /* Validity check */
184  ASSERT(Console == Buffer->Header.Console);
185 
186  if (Buffer == Console->ActiveBuffer) return STATUS_SUCCESS;
187 
188  /* If old buffer has no handles, it's now unreferenced */
189  if (Console->ActiveBuffer->Header.ReferenceCount == 0)
190  {
191  ConDrvDeleteScreenBuffer(Console->ActiveBuffer);
192  }
193 
194  /* Tie console to new buffer and signal the change to the frontend */
196 
197  return STATUS_SUCCESS;
198 }
VOID NTAPI ConDrvDeleteScreenBuffer(PCONSOLE_SCREEN_BUFFER Buffer)
Definition: conoutput.c:130
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
static VOID ConioSetActiveScreenBuffer(PCONSOLE_SCREEN_BUFFER Buffer)
Definition: conoutput.c:168
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
CConsole Console
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by CON_API().

◆ ConDrvSetConsoleCursorInfo()

NTSTATUS NTAPI ConDrvSetConsoleCursorInfo ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  Buffer,
IN PCONSOLE_CURSOR_INFO  CursorInfo 
)

Definition at line 288 of file conoutput.c.

291 {
292  ULONG Size;
293  BOOLEAN Visible, Success = TRUE;
294 
295  if (Console == NULL || Buffer == NULL || CursorInfo == NULL)
297 
298  /* Validity check */
299  ASSERT(Console == Buffer->Header.Console);
300 
301  Size = min(max(CursorInfo->dwSize, 1), 100);
302  Visible = CursorInfo->bVisible;
303 
304  if ( (Size != Buffer->CursorInfo.dwSize) ||
305  (Visible && !Buffer->CursorInfo.bVisible) ||
306  (!Visible && Buffer->CursorInfo.bVisible) )
307  {
308  Buffer->CursorInfo.dwSize = Size;
309  Buffer->CursorInfo.bVisible = Visible;
310 
312  }
313 
315 }
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
#define TermSetCursorInfo(Console, ScreenBuffer)
Definition: term.h:24
#define min(a, b)
Definition: monoChain.cc:55
CConsole Console
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by CON_API().

◆ ConDrvSetConsoleCursorPosition()

NTSTATUS NTAPI ConDrvSetConsoleCursorPosition ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  Buffer,
IN PCOORD  Position 
)

Definition at line 318 of file conoutput.c.

321 {
322  SHORT OldCursorX, OldCursorY;
323 
324  if (Console == NULL || Buffer == NULL || Position == NULL)
326 
327  /* Validity check */
328  ASSERT(Console == Buffer->Header.Console);
329 
330  if ( Position->X < 0 || Position->X >= Buffer->ScreenBufferSize.X ||
331  Position->Y < 0 || Position->Y >= Buffer->ScreenBufferSize.Y )
332  {
334  }
335 
336  OldCursorX = Buffer->CursorPosition.X;
337  OldCursorY = Buffer->CursorPosition.Y;
338  Buffer->CursorPosition = *Position;
339 
340  if ( ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer) &&
341  (!TermSetScreenInfo(Console, (PCONSOLE_SCREEN_BUFFER)Buffer, OldCursorX, OldCursorY)) )
342  {
343  return STATUS_UNSUCCESSFUL;
344  }
345 
346  return STATUS_SUCCESS;
347 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
static COORD Position
Definition: mouse.c:34
#define TermSetScreenInfo(Console, ScreenBuffer, OldCursorX, OldCursorY)
Definition: term.h:26
short SHORT
Definition: pedump.c:59
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
ULONG X
Definition: bl.h:1340
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
CConsole Console
return STATUS_SUCCESS
Definition: btrfs.c:3014
ULONG Y
Definition: bl.h:1341

Referenced by CON_API().

◆ ConDrvSetConsolePalette()

NTSTATUS NTAPI ConDrvSetConsolePalette ( IN PCONSOLE  Console,
IN PCONSOLE_SCREEN_BUFFER  Buffer,
IN HPALETTE  PaletteHandle,
IN UINT  PaletteUsage 
)

Definition at line 226 of file conoutput.c.

231 {
232  BOOL Success;
233 
234  /*
235  * Parameters validation
236  */
237  if (Console == NULL || Buffer == NULL)
239 
240  if ( PaletteUsage != SYSPAL_STATIC &&
241  PaletteUsage != SYSPAL_NOSTATIC &&
242  PaletteUsage != SYSPAL_NOSTATIC256 )
243  {
245  }
246 
247  /* Validity check */
248  ASSERT(Console == Buffer->Header.Console);
249 
250  /* Change the palette */
251  Success = TermSetPalette(Console, PaletteHandle, PaletteUsage);
252  if (Success)
253  {
254  /* Free the old palette handle if there was already one set */
255  if ( Buffer->PaletteHandle != NULL &&
256  Buffer->PaletteHandle != PaletteHandle )
257  {
258  DeleteObject(Buffer->PaletteHandle);
259  }
260 
261  /* Save the new palette in the screen buffer */
262  Buffer->PaletteHandle = PaletteHandle;
263  Buffer->PaletteUsage = PaletteUsage;
264  }
265 
267 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
static HPALETTE PaletteHandle
Definition: svga.c:215
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define SYSPAL_NOSTATIC256
Definition: wingdi.h:21
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define SYSPAL_STATIC
Definition: wingdi.h:925
#define TermSetPalette(Console, PaletteHandle, PaletteUsage)
Definition: term.h:36
#define SYSPAL_NOSTATIC
Definition: wingdi.h:924
CConsole Console
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by CON_API().

◆ ConDrvSetConsoleScreenBufferSize()

NTSTATUS NTAPI ConDrvSetConsoleScreenBufferSize ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  Buffer,
IN PCOORD  Size 
)

Definition at line 1435 of file text.c.

1438 {
1439  NTSTATUS Status;
1440 
1441  if (Console == NULL || Buffer == NULL || Size == NULL)
1442  return STATUS_INVALID_PARAMETER;
1443 
1444  /* Validity check */
1445  ASSERT(Console == Buffer->Header.Console);
1446 
1449 
1450  return Status;
1451 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define TermResizeTerminal(Console)
Definition: term.h:28
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
Status
Definition: gdiplustypes.h:24
NTSTATUS ConioResizeBuffer(PCONSOLE Console, PTEXTMODE_SCREEN_BUFFER ScreenBuffer, COORD Size)
Definition: text.c:359
CConsole Console

Referenced by CON_API().

◆ ConDrvSetConsoleTextAttribute()

NTSTATUS NTAPI ConDrvSetConsoleTextAttribute ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  Buffer,
IN WORD  Attributes 
)

Definition at line 1420 of file text.c.

1423 {
1424  if (Console == NULL || Buffer == NULL)
1425  return STATUS_INVALID_PARAMETER;
1426 
1427  /* Validity check */
1428  ASSERT(Console == Buffer->Header.Console);
1429 
1430  Buffer->ScreenDefaultAttrib = (Attributes & ~COMMON_LVB_SBCSDBCS);
1431  return STATUS_SUCCESS;
1432 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define COMMON_LVB_SBCSDBCS
Definition: wincon.h:56
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_Must_inspect_result_ _In_ USHORT _In_ PHIDP_PREPARSED_DATA _Out_writes_to_ LengthAttributes PHIDP_EXTENDED_ATTRIBUTES Attributes
Definition: hidpi.h:348
CConsole Console
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by CON_API().

◆ ConDrvSetConsoleWindowInfo()

NTSTATUS NTAPI ConDrvSetConsoleWindowInfo ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  Buffer,
IN BOOLEAN  Absolute,
IN PSMALL_RECT  WindowRect 
)

Definition at line 1579 of file text.c.

1583 {
1584  SMALL_RECT CapturedWindowRect;
1585  COORD LargestWindowSize;
1586 
1587  if (Console == NULL || Buffer == NULL || WindowRect == NULL)
1588  return STATUS_INVALID_PARAMETER;
1589 
1590  /* Validity check */
1591  ASSERT(Console == Buffer->Header.Console);
1592 
1593  CapturedWindowRect = *WindowRect;
1594 
1595  if (!Absolute)
1596  {
1597  /* Relative positions are given, transform them to absolute ones */
1598  CapturedWindowRect.Left += Buffer->ViewOrigin.X;
1599  CapturedWindowRect.Top += Buffer->ViewOrigin.Y;
1600  CapturedWindowRect.Right += Buffer->ViewOrigin.X + Buffer->ViewSize.X - 1;
1601  CapturedWindowRect.Bottom += Buffer->ViewOrigin.Y + Buffer->ViewSize.Y - 1;
1602  }
1603 
1604  /*
1605  * The MSDN documentation on SetConsoleWindowInfo() is partially wrong about
1606  * the performed checks this API performs. While it is correct that the
1607  * 'Right'/'Bottom' members cannot be strictly smaller than the 'Left'/'Top'
1608  * members (the rectangle cannot be empty), they can be equal (describe one cell).
1609  * Also, if the 'Left' or 'Top' members are negative, this is automatically
1610  * corrected for, and the window rectangle coordinates are shifted accordingly.
1611  */
1612  if (ConioIsRectEmpty(&CapturedWindowRect))
1613  {
1614  return STATUS_INVALID_PARAMETER;
1615  }
1616 
1617  /*
1618  * Forbid window sizes larger than the largest allowed console window size,
1619  * taking into account the size of the console screen buffer.
1620  */
1621  TermGetLargestConsoleWindowSize(Console, &LargestWindowSize);
1622  LargestWindowSize.X = min(LargestWindowSize.X, Buffer->ScreenBufferSize.X);
1623  LargestWindowSize.Y = min(LargestWindowSize.Y, Buffer->ScreenBufferSize.Y);
1624  if ((ConioRectWidth(&CapturedWindowRect) > LargestWindowSize.X) ||
1625  (ConioRectHeight(&CapturedWindowRect) > LargestWindowSize.Y))
1626  {
1627  return STATUS_INVALID_PARAMETER;
1628  }
1629 
1630  /* Shift the window rectangle coordinates if 'Left' or 'Top' are negative */
1631  if (CapturedWindowRect.Left < 0)
1632  {
1633  CapturedWindowRect.Right -= CapturedWindowRect.Left;
1634  CapturedWindowRect.Left = 0;
1635  }
1636  if (CapturedWindowRect.Top < 0)
1637  {
1638  CapturedWindowRect.Bottom -= CapturedWindowRect.Top;
1639  CapturedWindowRect.Top = 0;
1640  }
1641 
1642  /* Clip the window rectangle to the screen buffer */
1643  CapturedWindowRect.Right = min(CapturedWindowRect.Right , Buffer->ScreenBufferSize.X);
1644  CapturedWindowRect.Bottom = min(CapturedWindowRect.Bottom, Buffer->ScreenBufferSize.Y);
1645 
1646  Buffer->ViewOrigin.X = CapturedWindowRect.Left;
1647  Buffer->ViewOrigin.Y = CapturedWindowRect.Top;
1648 
1649  Buffer->ViewSize.X = ConioRectWidth(&CapturedWindowRect);
1650  Buffer->ViewSize.Y = ConioRectHeight(&CapturedWindowRect);
1651 
1653 
1654  return STATUS_SUCCESS;
1655 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define TermResizeTerminal(Console)
Definition: term.h:28
#define ConioRectWidth(Rect)
Definition: readwrite.c:24
smooth NULL
Definition: ftsmooth.c:416
#define ConioRectHeight(Rect)
Definition: readwrite.c:22
Definition: bufpool.h:45
SHORT Left
Definition: blue.h:32
ULONG X
Definition: bl.h:1340
SHORT Bottom
Definition: blue.h:35
#define TermGetLargestConsoleWindowSize(Console, pSize)
Definition: term.h:34
SHORT Top
Definition: blue.h:33
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: bl.h:1338
#define min(a, b)
Definition: monoChain.cc:55
CConsole Console
#define ConioIsRectEmpty(Rect)
Definition: rect.h:28
SHORT Right
Definition: blue.h:34
return STATUS_SUCCESS
Definition: btrfs.c:3014
ULONG Y
Definition: bl.h:1341

Referenced by CON_API().

◆ ConDrvWriteConsole()

NTSTATUS NTAPI ConDrvWriteConsole ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  ScreenBuffer,
IN BOOLEAN  Unicode,
IN PVOID  StringBuffer,
IN ULONG  NumCharsToWrite,
OUT PULONG NumCharsWritten  OPTIONAL 
)

Definition at line 763 of file text.c.

769 {
771  PWCHAR Buffer = NULL;
772  ULONG Written = 0;
773  ULONG Length;
774 
775  if (Console == NULL || ScreenBuffer == NULL /* || StringBuffer == NULL */)
777 
778  /* Validity checks */
779  ASSERT(Console == ScreenBuffer->Header.Console);
780  ASSERT((StringBuffer != NULL) || (StringBuffer == NULL && NumCharsToWrite == 0));
781 
782  /* Stop here if the console is paused */
783  if (Console->ConsolePaused) return STATUS_PENDING;
784 
785  /* Convert the string to UNICODE */
786  if (Unicode)
787  {
789  }
790  else
791  {
792  Length = MultiByteToWideChar(Console->OutputCodePage, 0,
794  NumCharsToWrite,
795  NULL, 0);
796  Buffer = ConsoleAllocHeap(0, Length * sizeof(WCHAR));
797  if (Buffer)
798  {
799  MultiByteToWideChar(Console->OutputCodePage, 0,
801  NumCharsToWrite,
802  (PWCHAR)Buffer, Length);
803  }
804  else
805  {
807  }
808  }
809 
810  /* Send it */
811  if (Buffer)
812  {
813  if (NT_SUCCESS(Status))
814  {
816  ScreenBuffer,
817  Buffer,
818  NumCharsToWrite,
819  TRUE);
820  if (NT_SUCCESS(Status))
821  {
822  Written = NumCharsToWrite;
823  }
824  }
825 
826  if (!Unicode) ConsoleFreeHeap(Buffer);
827  }
828 
829  if (NumCharsWritten) *NumCharsWritten = Written;
830 
831  return Status;
832 }
signed char * PCHAR
Definition: retypes.h:7
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
uint16_t * PWCHAR
Definition: typedefs.h:55
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define MultiByteToWideChar
Definition: compat.h:100
CConsole Console
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
HANDLE ScreenBuffer
Definition: notevil.c:37
unsigned int ULONG
Definition: retypes.h:1
#define TermWriteStream(Console, ScreenBuffer, Buffer, Length, Attrib)
Definition: term.h:17
return STATUS_SUCCESS
Definition: btrfs.c:3014
WCHAR StringBuffer[156]
Definition: ldrinit.c:41

Referenced by DoWriteConsole().

◆ ConDrvWriteConsoleOutput()

NTSTATUS NTAPI ConDrvWriteConsoleOutput ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  Buffer,
IN BOOLEAN  Unicode,
IN PCHAR_INFO  CharInfo,
IN OUT PSMALL_RECT  WriteRegion 
)

Definition at line 638 of file text.c.

643 {
644  SHORT X, Y;
646  PCHAR_INFO CurCharInfo;
647  SMALL_RECT CapturedWriteRegion;
648  PCHAR_INFO Ptr;
649 
650  if (Console == NULL || Buffer == NULL || CharInfo == NULL || WriteRegion == NULL)
651  {
653  }
654 
655  /* Validity check */
656  ASSERT(Console == Buffer->Header.Console);
657 
658  CapturedWriteRegion = *WriteRegion;
659 
660  /* Make sure WriteRegion is inside the screen buffer */
662  Buffer->ScreenBufferSize.Y - 1,
663  Buffer->ScreenBufferSize.X - 1);
664  if (!ConioGetIntersection(&CapturedWriteRegion, &CapturedWriteRegion, &ScreenBuffer))
665  {
666  /*
667  * It is okay to have a WriteRegion completely outside
668  * the screen buffer. No data is written then.
669  */
670  return STATUS_SUCCESS;
671  }
672 
673  CurCharInfo = CharInfo;
674 
675  for (Y = CapturedWriteRegion.Top; Y <= CapturedWriteRegion.Bottom; ++Y)
676  {
677  Ptr = ConioCoordToPointer(Buffer, CapturedWriteRegion.Left, Y);
678  for (X = CapturedWriteRegion.Left; X <= CapturedWriteRegion.Right; ++X)
679  {
680  if (Unicode)
681  {
682  Ptr->Char.UnicodeChar = CurCharInfo->Char.UnicodeChar;
683  }
684  else
685  {
686  ConsoleOutputAnsiToUnicodeChar(Console, &Ptr->Char.UnicodeChar, &CurCharInfo->Char.AsciiChar);
687  }
688  // TODO: Sanitize DBCS attributes?
689  Ptr->Attributes = CurCharInfo->Attributes;
690  ++Ptr;
691  ++CurCharInfo;
692  }
693  }
694 
695  TermDrawRegion(Console, &CapturedWriteRegion);
696 
697  *WriteRegion = CapturedWriteRegion;
698 
699  return STATUS_SUCCESS;
700 }
CHAR AsciiChar
Definition: wincon.h:185
#define Y(I)
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y)
Definition: text.c:143
WCHAR UnicodeChar
Definition: wincon.h:184
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
#define TermDrawRegion(Console, Region)
Definition: term.h:22
#define ConsoleOutputAnsiToUnicodeChar(Console, dWChar, sChar)
Definition: text.c:31
short SHORT
Definition: pedump.c:59
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
SHORT Left
Definition: blue.h:32
SHORT Bottom
Definition: blue.h:35
WORD Attributes
Definition: wincon.h:187
SHORT Top
Definition: blue.h:33
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
union _CHAR_INFO::@3201 Char
#define ConioInitRect(Rect, top, left, bottom, right)
Definition: rect.h:20
CConsole Console
HANDLE ScreenBuffer
Definition: notevil.c:37
static __inline BOOLEAN ConioGetIntersection(OUT PSMALL_RECT Intersection, IN PSMALL_RECT Rect1, IN PSMALL_RECT Rect2)
Definition: rect.h:38
SHORT Right
Definition: blue.h:34
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define X(b, s)

Referenced by CON_API().

◆ ConDrvWriteConsoleOutputString()

NTSTATUS NTAPI ConDrvWriteConsoleOutputString ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  Buffer,
IN CODE_TYPE  CodeType,
IN PVOID  StringBuffer,
IN ULONG  NumCodesToWrite,
IN PCOORD  WriteCoord,
OUT PULONG NumCodesWritten  OPTIONAL 
)

Definition at line 1161 of file text.c.

1169 {
1170  NTSTATUS Status;
1171 
1172  if (Console == NULL || Buffer == NULL || WriteCoord == NULL /* || EndCoord == NULL */)
1173  {
1174  return STATUS_INVALID_PARAMETER;
1175  }
1176 
1177  /* Validity checks */
1178  ASSERT(Console == Buffer->Header.Console);
1179  ASSERT((StringBuffer != NULL) || (StringBuffer == NULL && NumCodesToWrite == 0));
1180 
1181  if (NumCodesWritten)
1182  *NumCodesWritten = 0;
1183 
1184  if (!StringBuffer || (NumCodesToWrite == 0))
1185  return STATUS_SUCCESS; // Nothing to do!
1186 
1187  /* Do nothing if the writing starting point is outside of the screen buffer */
1188  if ( WriteCoord->X < 0 || WriteCoord->X >= Buffer->ScreenBufferSize.X ||
1189  WriteCoord->Y < 0 || WriteCoord->Y >= Buffer->ScreenBufferSize.Y )
1190  {
1191  return STATUS_SUCCESS;
1192  }
1193 
1194  NumCodesToWrite = min(NumCodesToWrite, (ULONG)Buffer->ScreenBufferSize.X * Buffer->ScreenBufferSize.Y);
1195 
1196  switch (CodeType)
1197  {
1198  case CODE_ASCII:
1199  {
1200  C_ASSERT(RTL_FIELD_SIZE(CODE_ELEMENT, AsciiChar) == sizeof(CHAR));
1202  Buffer,
1203  StringBuffer,
1204  FALSE,
1205  NumCodesToWrite,
1206  WriteCoord,
1207  NumCodesWritten);
1208  break;
1209  }
1210 
1211  case CODE_UNICODE:
1212  {
1213  C_ASSERT(RTL_FIELD_SIZE(CODE_ELEMENT, UnicodeChar) == sizeof(WCHAR));
1215  Buffer,
1216  StringBuffer,
1217  TRUE,
1218  NumCodesToWrite,
1219  WriteCoord,
1220  NumCodesWritten);
1221  break;
1222  }
1223 
1224  case CODE_ATTRIBUTE:
1225  {
1226  C_ASSERT(RTL_FIELD_SIZE(CODE_ELEMENT, Attribute) == sizeof(WORD));
1228  Buffer,
1230  NumCodesToWrite,
1231  WriteCoord,
1232  NumCodesWritten);
1233  break;
1234  }
1235 
1236  default:
1237  return STATUS_INVALID_PARAMETER;
1238  }
1239 
1240  if ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer)
1241  {
1243  ConioComputeUpdateRect(Buffer, &UpdateRect, WriteCoord, NumCodesToWrite);
1245  }
1246 
1247  return Status;
1248 }
#define RTL_FIELD_SIZE(type, field)
Definition: kdb_expr.c:84
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
#define TermDrawRegion(Console, Region)
Definition: term.h:22
static VOID ConioComputeUpdateRect(IN PTEXTMODE_SCREEN_BUFFER Buff, IN OUT PSMALL_RECT UpdateRect, IN PCOORD Start, IN UINT Length)
Definition: text.c:165
static NTSTATUS IntWriteConsoleOutputStringChars(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN PVOID StringBuffer, IN BOOLEAN Unicode, IN ULONG NumCodesToWrite, IN PCOORD WriteCoord, OUT PULONG NumCodesWritten OPTIONAL)
Definition: text.c:1016
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define C_ASSERT(e)
Definition: intsafe.h:79
WORD * PWORD
Definition: pedump.c:67
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned short WORD
Definition: ntddk_ex.h:93
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static NTSTATUS IntWriteConsoleOutputStringAttribute(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN PWORD StringBuffer, IN ULONG NumCodesToWrite, IN PCOORD WriteCoord, OUT PULONG NumCodesWritten OPTIONAL)
Definition: text.c:1120
Status
Definition: gdiplustypes.h:24
#define min(a, b)
Definition: monoChain.cc:55
CConsole Console
unsigned int ULONG
Definition: retypes.h:1
static int UpdateRect(TreeListData *pData, unsigned uItem, unsigned uSub)
Definition: treelist.c:1529
return STATUS_SUCCESS
Definition: btrfs.c:3014
WCHAR StringBuffer[156]
Definition: ldrinit.c:41

Referenced by CON_API().

◆ ConDrvWriteConsoleOutputVDM()

NTSTATUS NTAPI ConDrvWriteConsoleOutputVDM ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  Buffer,
IN PCHAR_CELL  CharInfo,
IN COORD  CharInfoSize,
IN PSMALL_RECT  WriteRegion 
)

Definition at line 708 of file text.c.

713 {
714  SHORT X, Y;
716  PCHAR_CELL CurCharInfo;
717  SMALL_RECT CapturedWriteRegion;
718  PCHAR_INFO Ptr;
719 
720  if (Console == NULL || Buffer == NULL || CharInfo == NULL || WriteRegion == NULL)
721  {
723  }
724 
725  /* Validity check */
726  ASSERT(Console == Buffer->Header.Console);
727 
728  CapturedWriteRegion = *WriteRegion;
729 
730  /* Make sure WriteRegion is inside the screen buffer */
732  Buffer->ScreenBufferSize.Y - 1,
733  Buffer->ScreenBufferSize.X - 1);
734  if (!ConioGetIntersection(&CapturedWriteRegion, &CapturedWriteRegion, &ScreenBuffer))
735  {
736  /*
737  * It is okay to have a WriteRegion completely outside
738  * the screen buffer. No data is written then.
739  */
740  return STATUS_SUCCESS;
741  }
742 
743  // CurCharInfo = CharInfo;
744 
745  for (Y = CapturedWriteRegion.Top; Y <= CapturedWriteRegion.Bottom; ++Y)
746  {
747  CurCharInfo = CharInfo + Y * CharInfoSize.X + CapturedWriteRegion.Left;
748 
749  Ptr = ConioCoordToPointer(Buffer, CapturedWriteRegion.Left, Y);
750  for (X = CapturedWriteRegion.Left; X <= CapturedWriteRegion.Right; ++X)
751  {
752  ConsoleOutputAnsiToUnicodeChar(Console, &Ptr->Char.UnicodeChar, &CurCharInfo->Char);
753  Ptr->Attributes = CurCharInfo->Attributes;
754  ++Ptr;
755  ++CurCharInfo;
756  }
757  }
758 
759  return STATUS_SUCCESS;
760 }
#define Y(I)
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y)
Definition: text.c:143
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
#define ConsoleOutputAnsiToUnicodeChar(Console, dWChar, sChar)
Definition: text.c:31
BYTE Attributes
Definition: svga.h:393
short SHORT
Definition: pedump.c:59
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
SHORT Left
Definition: blue.h:32
CHAR Char
Definition: svga.h:392
SHORT Bottom
Definition: blue.h:35
SHORT Top
Definition: blue.h:33
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ConioInitRect(Rect, top, left, bottom, right)
Definition: rect.h:20
CConsole Console
HANDLE ScreenBuffer
Definition: notevil.c:37
static __inline BOOLEAN ConioGetIntersection(OUT PSMALL_RECT Intersection, IN PSMALL_RECT Rect1, IN PSMALL_RECT Rect2)
Definition: rect.h:38
SHORT Right
Definition: blue.h:34
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define X(b, s)

Referenced by CON_API().

◆ DoWriteConsole()

static NTSTATUS DoWriteConsole ( IN PCSR_API_MESSAGE  ApiMessage,
IN PCSR_THREAD  ClientThread,
IN BOOLEAN CreateWaitBlock  OPTIONAL 
)
static

Definition at line 409 of file conoutput.c.

412 {
414  PCONSOLE_WRITECONSOLE WriteConsoleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.WriteConsoleRequest;
416 
417  PVOID Buffer;
418  ULONG NrCharactersWritten = 0;
419  ULONG CharSize = (WriteConsoleRequest->Unicode ? sizeof(WCHAR) : sizeof(CHAR));
420 
422  WriteConsoleRequest->OutputHandle,
424  if (!NT_SUCCESS(Status)) return Status;
425 
426  /*
427  * For optimization purposes, Windows (and hence ReactOS, too, for
428  * compatibility reasons) uses a static buffer if no more than eighty
429  * bytes are written. Otherwise a new buffer is used.
430  * The client-side expects that we know this behaviour.
431  */
432  if (WriteConsoleRequest->UsingStaticBuffer &&
433  WriteConsoleRequest->NumBytes <= sizeof(WriteConsoleRequest->StaticBuffer))
434  {
435  /*
436  * Adjust the internal pointer, because its old value points to
437  * the static buffer in the original ApiMessage structure.
438  */
439  // WriteConsoleRequest->Buffer = WriteConsoleRequest->StaticBuffer;
440  Buffer = WriteConsoleRequest->StaticBuffer;
441  }
442  else
443  {
444  Buffer = WriteConsoleRequest->Buffer;
445  }
446 
447  DPRINT("Calling ConDrvWriteConsole\n");
448  Status = ConDrvWriteConsole(ScreenBuffer->Header.Console,
449  ScreenBuffer,
450  WriteConsoleRequest->Unicode,
451  Buffer,
452  WriteConsoleRequest->NumBytes / CharSize, // NrCharactersToWrite
453  &NrCharactersWritten);
454  DPRINT("ConDrvWriteConsole returned (%d ; Status = 0x%08x)\n",
455  NrCharactersWritten, Status);
456 
457  if (Status == STATUS_PENDING)
458  {
459  if (CreateWaitBlock)
460  {
462 
463  if (!CsrCreateWait(&Console->WriteWaitQueue,
465  ClientThread,
466  ApiMessage,
467  NULL))
468  {
469  /* Fail */
471  goto Quit;
472  }
473  }
474 
475  /* Wait until we un-pause the console */
476  // Status = STATUS_PENDING;
477  }
478  else
479  {
480  /* We read all what we wanted. Set the number of bytes written. */
481  WriteConsoleRequest->NumBytes = NrCharactersWritten * CharSize;
482  }
483 
484 Quit:
486  return Status;
487 }
static BOOLEAN NTAPI WriteConsoleThread(IN PLIST_ENTRY WaitList, IN PCSR_THREAD WaitThread, IN PCSR_API_MESSAGE WaitApiMessage, IN PVOID WaitContext, IN PVOID WaitArgument1, IN PVOID WaitArgument2, IN ULONG WaitFlags)
Definition: conoutput.c:367
char CHAR
Definition: xmlstorage.h:175
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
UINT CALLBACK ClientThread(_Inout_ PVOID Parameter)
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
if(!(yy_init))
Definition: macro.lex.yy.c:714
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
struct _CONSRV_CONSOLE * PCONSRV_CONSOLE
Status
Definition: gdiplustypes.h:24
BOOLEAN UsingStaticBuffer
Definition: conmsg.h:246
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
CConsole Console
HANDLE ScreenBuffer
Definition: notevil.c:37
CHAR StaticBuffer[80]
Definition: conmsg.h:239
unsigned int ULONG
Definition: retypes.h:1
BOOLEAN NTAPI CsrCreateWait(IN PLIST_ENTRY WaitList, IN CSR_WAIT_FUNCTION WaitFunction, IN PCSR_THREAD CsrWaitThread, IN OUT PCSR_API_MESSAGE WaitApiMessage, IN PVOID WaitContext)
Definition: wait.c:209
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
NTSTATUS NTAPI ConDrvWriteConsole(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER ScreenBuffer, IN BOOLEAN Unicode, IN PVOID StringBuffer, IN ULONG NumCharsToWrite, OUT PULONG NumCharsWritten OPTIONAL)
Definition: text.c:763

Referenced by CON_API(), and WriteConsoleThread().

◆ WriteConsoleThread()

static BOOLEAN NTAPI WriteConsoleThread ( IN PLIST_ENTRY  WaitList,
IN PCSR_THREAD  WaitThread,
IN PCSR_API_MESSAGE  WaitApiMessage,
IN PVOID  WaitContext,
IN PVOID  WaitArgument1,
IN PVOID  WaitArgument2,
IN ULONG  WaitFlags 
)
static

Definition at line 367 of file conoutput.c.

374 {
376 
377  DPRINT("WriteConsoleThread - WaitContext = 0x%p, WaitArgument1 = 0x%p, WaitArgument2 = 0x%p, WaitFlags = %lu\n", WaitContext, WaitArgument1, WaitArgument2, WaitFlags);
378 
379  /*
380  * If we are notified of the process termination via a call
381  * to CsrNotifyWaitBlock triggered by CsrDestroyProcess or
382  * CsrDestroyThread, just return.
383  */
384  if (WaitFlags & CsrProcessTerminating)
385  {
387  goto Quit;
388  }
389 
390  Status = DoWriteConsole(WaitApiMessage, WaitThread, FALSE);
391 
392 Quit:
393  if (Status != STATUS_PENDING)
394  {
395  WaitApiMessage->Status = Status;
396  }
397 
398  return (Status == STATUS_PENDING ? FALSE : TRUE);
399 }
#define TRUE
Definition: types.h:120
static NTSTATUS DoWriteConsole(IN PCSR_API_MESSAGE ApiMessage, IN PCSR_THREAD ClientThread, IN BOOLEAN CreateWaitBlock OPTIONAL)
Definition: conoutput.c:409
#define STATUS_THREAD_IS_TERMINATING
Definition: ntstatus.h:297
LONG NTSTATUS
Definition: precomp.h:26
void DPRINT(...)
Definition: polytest.cpp:61
#define STATUS_PENDING
Definition: ntstatus.h:82
Status
Definition: gdiplustypes.h:24

Referenced by DoWriteConsole().