ReactOS 0.4.15-dev-7924-g5949c20
readwrite.c File Reference
#include <k32.h>
#include <debug.h>
Include dependency graph for readwrite.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define ConioRectHeight(Rect)    (((Rect)->Top > (Rect)->Bottom) ? 0 : ((Rect)->Bottom - (Rect)->Top + 1))
 
#define ConioRectWidth(Rect)    (((Rect)->Left > (Rect)->Right) ? 0 : ((Rect)->Right - (Rect)->Left + 1))
 

Functions

static BOOL IntReadConsole (IN HANDLE hConsoleInput, OUT PVOID lpBuffer, IN DWORD nNumberOfCharsToRead, OUT LPDWORD lpNumberOfCharsRead, IN PCONSOLE_READCONSOLE_CONTROL pInputControl OPTIONAL, IN BOOLEAN bUnicode)
 
static BOOL IntGetConsoleInput (IN HANDLE hConsoleInput, OUT PINPUT_RECORD lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsRead, IN WORD wFlags, IN BOOLEAN bUnicode)
 
static BOOL IntReadConsoleOutput (IN HANDLE hConsoleOutput, OUT PCHAR_INFO lpBuffer, IN COORD dwBufferSize, IN COORD dwBufferCoord, IN OUT PSMALL_RECT lpReadRegion, IN BOOLEAN bUnicode)
 
static BOOL IntReadConsoleOutputCode (IN HANDLE hConsoleOutput, IN CODE_TYPE CodeType, OUT PVOID pCode, IN DWORD nLength, IN COORD dwReadCoord, OUT LPDWORD lpNumberOfCodesRead)
 
static BOOL IntWriteConsole (IN HANDLE hConsoleOutput, IN PVOID lpBuffer, IN DWORD nNumberOfCharsToWrite, OUT LPDWORD lpNumberOfCharsWritten, LPVOID lpReserved, IN BOOLEAN bUnicode)
 
static BOOL IntWriteConsoleInput (IN HANDLE hConsoleInput, IN PINPUT_RECORD lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsWritten, IN BOOLEAN bUnicode, IN BOOLEAN bAppendToEnd)
 
static BOOL IntWriteConsoleOutput (IN HANDLE hConsoleOutput, IN CONST CHAR_INFO *lpBuffer, IN COORD dwBufferSize, IN COORD dwBufferCoord, IN OUT PSMALL_RECT lpWriteRegion, IN BOOLEAN bUnicode)
 
static BOOL IntWriteConsoleOutputCode (IN HANDLE hConsoleOutput, IN CODE_TYPE CodeType, IN CONST VOID *pCode, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCodesWritten)
 
static BOOL IntFillConsoleOutputCode (IN HANDLE hConsoleOutput, IN CODE_TYPE CodeType, IN CODE_ELEMENT Code, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCodesWritten)
 
BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleW (IN HANDLE hConsoleInput, OUT LPVOID lpBuffer, IN DWORD nNumberOfCharsToRead, OUT LPDWORD lpNumberOfCharsRead, IN PCONSOLE_READCONSOLE_CONTROL pInputControl OPTIONAL)
 
BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleA (IN HANDLE hConsoleInput, OUT LPVOID lpBuffer, IN DWORD nNumberOfCharsToRead, OUT LPDWORD lpNumberOfCharsRead, IN PCONSOLE_READCONSOLE_CONTROL pInputControl OPTIONAL)
 
BOOL WINAPI DECLSPEC_HOTPATCH PeekConsoleInputW (IN HANDLE hConsoleInput, OUT PINPUT_RECORD lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsRead)
 
BOOL WINAPI DECLSPEC_HOTPATCH PeekConsoleInputA (IN HANDLE hConsoleInput, OUT PINPUT_RECORD lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsRead)
 
BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleInputW (IN HANDLE hConsoleInput, OUT PINPUT_RECORD lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsRead)
 
BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleInputA (IN HANDLE hConsoleInput, OUT PINPUT_RECORD lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsRead)
 
BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleInputExW (IN HANDLE hConsoleInput, OUT PINPUT_RECORD lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsRead, IN WORD wFlags)
 
BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleInputExA (IN HANDLE hConsoleInput, OUT PINPUT_RECORD lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsRead, IN WORD wFlags)
 
BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleOutputW (IN HANDLE hConsoleOutput, OUT PCHAR_INFO lpBuffer, IN COORD dwBufferSize, IN COORD dwBufferCoord, IN OUT PSMALL_RECT lpReadRegion)
 
BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleOutputA (IN HANDLE hConsoleOutput, OUT PCHAR_INFO lpBuffer, IN COORD dwBufferSize, IN COORD dwBufferCoord, IN OUT PSMALL_RECT lpReadRegion)
 
BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleOutputCharacterW (IN HANDLE hConsoleOutput, OUT LPWSTR lpCharacter, IN DWORD nLength, IN COORD dwReadCoord, OUT LPDWORD lpNumberOfCharsRead)
 
BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleOutputCharacterA (IN HANDLE hConsoleOutput, OUT LPSTR lpCharacter, IN DWORD nLength, IN COORD dwReadCoord, OUT LPDWORD lpNumberOfCharsRead)
 
BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleOutputAttribute (IN HANDLE hConsoleOutput, OUT LPWORD lpAttribute, IN DWORD nLength, IN COORD dwReadCoord, OUT LPDWORD lpNumberOfAttrsRead)
 
BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleW (IN HANDLE hConsoleOutput, IN CONST VOID *lpBuffer, IN DWORD nNumberOfCharsToWrite, OUT LPDWORD lpNumberOfCharsWritten, LPVOID lpReserved)
 
BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleA (IN HANDLE hConsoleOutput, IN CONST VOID *lpBuffer, IN DWORD nNumberOfCharsToWrite, OUT LPDWORD lpNumberOfCharsWritten, LPVOID lpReserved)
 
BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleInputW (IN HANDLE hConsoleInput, IN CONST INPUT_RECORD *lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsWritten)
 
BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleInputA (IN HANDLE hConsoleInput, IN CONST INPUT_RECORD *lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsWritten)
 
BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleInputVDMW (IN HANDLE hConsoleInput, IN CONST INPUT_RECORD *lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsWritten)
 
BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleInputVDMA (IN HANDLE hConsoleInput, IN CONST INPUT_RECORD *lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsWritten)
 
BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleOutputW (IN HANDLE hConsoleOutput, IN CONST CHAR_INFO *lpBuffer, IN COORD dwBufferSize, IN COORD dwBufferCoord, IN OUT PSMALL_RECT lpWriteRegion)
 
BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleOutputA (IN HANDLE hConsoleOutput, IN CONST CHAR_INFO *lpBuffer, IN COORD dwBufferSize, IN COORD dwBufferCoord, IN OUT PSMALL_RECT lpWriteRegion)
 
BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleOutputCharacterW (IN HANDLE hConsoleOutput, IN LPCWSTR lpCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
 
BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleOutputCharacterA (IN HANDLE hConsoleOutput, IN LPCSTR lpCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
 
BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleOutputAttribute (IN HANDLE hConsoleOutput, IN CONST WORD *lpAttribute, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfAttrsWritten)
 
BOOL WINAPI DECLSPEC_HOTPATCH FillConsoleOutputCharacterW (IN HANDLE hConsoleOutput, IN WCHAR cCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
 
BOOL WINAPI DECLSPEC_HOTPATCH FillConsoleOutputCharacterA (IN HANDLE hConsoleOutput, IN CHAR cCharacter, IN DWORD nLength, IN COORD dwWriteCoord, LPDWORD lpNumberOfCharsWritten)
 
BOOL WINAPI DECLSPEC_HOTPATCH FillConsoleOutputAttribute (IN HANDLE hConsoleOutput, IN WORD wAttribute, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfAttrsWritten)
 

Macro Definition Documentation

◆ ConioRectHeight

#define ConioRectHeight (   Rect)     (((Rect)->Top > (Rect)->Bottom) ? 0 : ((Rect)->Bottom - (Rect)->Top + 1))

Definition at line 22 of file readwrite.c.

◆ ConioRectWidth

#define ConioRectWidth (   Rect)     (((Rect)->Left > (Rect)->Right) ? 0 : ((Rect)->Right - (Rect)->Left + 1))

Definition at line 24 of file readwrite.c.

◆ NDEBUG

#define NDEBUG

Definition at line 17 of file readwrite.c.

Function Documentation

◆ FillConsoleOutputAttribute()

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

Definition at line 1720 of file readwrite.c.

1725{
1727 Code.Attribute = wAttribute;
1728 return IntFillConsoleOutputCode(hConsoleOutput,
1730 Code,
1731 nLength,
1732 dwWriteCoord,
1733 lpNumberOfAttrsWritten);
1734}
@ CODE_ATTRIBUTE
Definition: conmsg.h:519
#define Code
Definition: deflate.h:80
static BOOL IntFillConsoleOutputCode(IN HANDLE hConsoleOutput, IN CODE_TYPE CodeType, IN CODE_ELEMENT Code, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCodesWritten)
Definition: readwrite.c:1104
_In_ UCHAR _In_ UCHAR _In_ ULONG Code
Definition: wdfdevice.h:1701
_In_ DWORD nLength
Definition: wincon.h:473

◆ FillConsoleOutputCharacterA()

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

Definition at line 1697 of file readwrite.c.

1702{
1704 Code.AsciiChar = cCharacter;
1705 return IntFillConsoleOutputCode(hConsoleOutput,
1706 CODE_ASCII,
1707 Code,
1708 nLength,
1709 dwWriteCoord,
1710 lpNumberOfCharsWritten);
1711}
@ CODE_ASCII
Definition: conmsg.h:517

◆ FillConsoleOutputCharacterW()

BOOL WINAPI DECLSPEC_HOTPATCH FillConsoleOutputCharacterW ( IN HANDLE  hConsoleOutput,
IN WCHAR  cCharacter,
IN DWORD  nLength,
IN COORD  dwWriteCoord,
OUT LPDWORD  lpNumberOfCharsWritten 
)

Definition at line 1674 of file readwrite.c.

1679{
1681 Code.UnicodeChar = cCharacter;
1682 return IntFillConsoleOutputCode(hConsoleOutput,
1684 Code,
1685 nLength,
1686 dwWriteCoord,
1687 lpNumberOfCharsWritten);
1688}
@ CODE_UNICODE
Definition: conmsg.h:518

Referenced by ClearScreen(), ConClearLine(), ConClearScreen(), test_cp855(), test_cp932(), and test_FillConsoleOutputCharacterW().

◆ IntFillConsoleOutputCode()

static BOOL IntFillConsoleOutputCode ( IN HANDLE  hConsoleOutput,
IN CODE_TYPE  CodeType,
IN CODE_ELEMENT  Code,
IN DWORD  nLength,
IN COORD  dwWriteCoord,
OUT LPDWORD  lpNumberOfCodesWritten 
)
static

Definition at line 1104 of file readwrite.c.

1110{
1111 BOOL Success;
1112 CONSOLE_API_MESSAGE ApiMessage;
1113 PCONSOLE_FILLOUTPUTCODE FillOutputRequest = &ApiMessage.Data.FillOutputRequest;
1114
1115 DPRINT("IntFillConsoleOutputCode\n");
1116
1117 if ( (CodeType != CODE_ASCII ) &&
1118 (CodeType != CODE_UNICODE ) &&
1119 (CodeType != CODE_ATTRIBUTE) )
1120 {
1122 return FALSE;
1123 }
1124
1125 /* Set up the data to send to the Console Server */
1126 FillOutputRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1127 FillOutputRequest->OutputHandle = hConsoleOutput;
1128 FillOutputRequest->WriteCoord = dwWriteCoord;
1129 FillOutputRequest->CodeType = CodeType;
1130 FillOutputRequest->Code = Code;
1131 FillOutputRequest->NumCodes = nLength;
1132
1133 /* Call the server */
1135 NULL,
1137 sizeof(*FillOutputRequest));
1138
1139 /* Check for success */
1140 Success = NT_SUCCESS(ApiMessage.Status);
1141
1142 /* Retrieve the results */
1143 _SEH2_TRY
1144 {
1145 *lpNumberOfCodesWritten = FillOutputRequest->NumCodes;
1146
1147 if (!Success)
1148 BaseSetLastNTError(ApiMessage.Status);
1149 }
1151 {
1153 Success = FALSE;
1154 }
1155 _SEH2_END;
1156
1157 /* Return success status */
1158 return Success;
1159}
#define NtCurrentPeb()
Definition: FLS.c:22
@ ConsolepFillConsoleOutput
Definition: conmsg.h:28
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
@ Success
Definition: eventcreate.c:712
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
unsigned int BOOL
Definition: ntddk_ex.h:94
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
NTSTATUS NTAPI CsrClientCallServer(_Inout_ PCSR_API_MESSAGE ApiMessage, _Inout_opt_ PCSR_CAPTURE_BUFFER CaptureBuffer, _In_ CSR_API_NUMBER ApiNumber, _In_ ULONG DataLength)
Definition: connect.c:366
#define DPRINT
Definition: sndvol32.h:71
CONSOLE_FILLOUTPUTCODE FillOutputRequest
Definition: conmsg.h:995
union _CONSOLE_API_MESSAGE::@3540 Data
CODE_TYPE CodeType
Definition: conmsg.h:556
CODE_ELEMENT Code
Definition: conmsg.h:557
NTSTATUS Status
Definition: csrmsg.h:110
#define ERROR_INVALID_ACCESS
Definition: winerror.h:115

Referenced by FillConsoleOutputAttribute(), FillConsoleOutputCharacterA(), and FillConsoleOutputCharacterW().

◆ IntGetConsoleInput()

static BOOL IntGetConsoleInput ( IN HANDLE  hConsoleInput,
OUT PINPUT_RECORD  lpBuffer,
IN DWORD  nLength,
OUT LPDWORD  lpNumberOfEventsRead,
IN WORD  wFlags,
IN BOOLEAN  bUnicode 
)
static

Definition at line 231 of file readwrite.c.

237{
239 CONSOLE_API_MESSAGE ApiMessage;
240 PCONSOLE_GETINPUT GetInputRequest = &ApiMessage.Data.GetInputRequest;
241 PCSR_CAPTURE_BUFFER CaptureBuffer = NULL;
242
243 if (!IsConsoleHandle(hConsoleInput))
244 {
246 {
249 }
251 {
253 }
254 _SEH2_END;
255
256 return FALSE;
257 }
258
259 DPRINT("IntGetConsoleInput: %lx %p\n", nLength, lpNumberOfEventsRead);
260
261 /* Set up the data to send to the Console Server */
262 GetInputRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
263 GetInputRequest->InputHandle = hConsoleInput;
264 GetInputRequest->NumRecords = nLength;
265 GetInputRequest->Flags = wFlags;
266 GetInputRequest->Unicode = bUnicode;
267
268 /*
269 * For optimization purposes, Windows (and hence ReactOS, too, for
270 * compatibility reasons) uses a static buffer if no more than five
271 * input records are read. Otherwise a new buffer is allocated.
272 * This behaviour is also expected in the server-side.
273 */
274 if (nLength <= sizeof(GetInputRequest->RecordStaticBuffer)/sizeof(INPUT_RECORD))
275 {
276 GetInputRequest->RecordBufPtr = GetInputRequest->RecordStaticBuffer;
277 // CaptureBuffer = NULL;
278 }
279 else
280 {
281 ULONG Size = nLength * sizeof(INPUT_RECORD);
282
283 /* Allocate a Capture Buffer */
284 CaptureBuffer = CsrAllocateCaptureBuffer(1, Size);
285 if (CaptureBuffer == NULL)
286 {
287 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
289 return FALSE;
290 }
291
292 /* Allocate space in the Buffer */
293 CsrAllocateMessagePointer(CaptureBuffer,
294 Size,
295 (PVOID*)&GetInputRequest->RecordBufPtr);
296 }
297
298 /* Call the server */
300 CaptureBuffer,
302 sizeof(*GetInputRequest));
303
304 /* Check for success */
305 Success = NT_SUCCESS(ApiMessage.Status);
306
307 /* Retrieve the results */
309 {
310 DPRINT("Events read: %lx\n", GetInputRequest->NumRecords);
311 *lpNumberOfEventsRead = GetInputRequest->NumRecords;
312
313 if (Success)
314 {
316 GetInputRequest->RecordBufPtr,
317 GetInputRequest->NumRecords * sizeof(INPUT_RECORD));
318 }
319 else
320 {
321 BaseSetLastNTError(ApiMessage.Status);
322 }
323 }
325 {
327 Success = FALSE;
328 }
329 _SEH2_END;
330
331 /* Release the capture buffer if needed */
332 if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
333
334 /* Return success status */
335 return Success;
336}
#define DPRINT1
Definition: precomp.h:8
@ ConsolepGetConsoleInput
Definition: conmsg.h:22
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
PCSR_CAPTURE_BUFFER NTAPI CsrAllocateCaptureBuffer(_In_ ULONG ArgumentCount, _In_ ULONG BufferSize)
Definition: capture.c:87
ULONG NTAPI CsrAllocateMessagePointer(_Inout_ PCSR_CAPTURE_BUFFER CaptureBuffer, _In_ ULONG MessageLength, _Out_ PVOID *CapturedData)
Definition: capture.c:152
VOID NTAPI CsrFreeCaptureBuffer(_In_ _Frees_ptr_ PCSR_CAPTURE_BUFFER CaptureBuffer)
Definition: capture.c:210
#define IsConsoleHandle(h)
Definition: console.h:14
CONSOLE_GETINPUT GetInputRequest
Definition: conmsg.h:984
ULONG NumRecords
Definition: conmsg.h:568
PINPUT_RECORD RecordBufPtr
Definition: conmsg.h:567
HANDLE ConsoleHandle
Definition: conmsg.h:564
BOOLEAN Unicode
Definition: conmsg.h:570
HANDLE InputHandle
Definition: conmsg.h:565
INPUT_RECORD RecordStaticBuffer[5]
Definition: conmsg.h:566
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_In_ DWORD _Out_ LPDWORD lpNumberOfEventsRead
Definition: wincon.h:474
struct _INPUT_RECORD INPUT_RECORD
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:531

Referenced by PeekConsoleInputA(), PeekConsoleInputW(), ReadConsoleInputA(), ReadConsoleInputExA(), ReadConsoleInputExW(), and ReadConsoleInputW().

◆ IntReadConsole()

static BOOL IntReadConsole ( IN HANDLE  hConsoleInput,
OUT PVOID  lpBuffer,
IN DWORD  nNumberOfCharsToRead,
OUT LPDWORD  lpNumberOfCharsRead,
IN PCONSOLE_READCONSOLE_CONTROL pInputControl  OPTIONAL,
IN BOOLEAN  bUnicode 
)
static

Definition at line 36 of file readwrite.c.

42{
44 CONSOLE_API_MESSAGE ApiMessage;
45 PCONSOLE_READCONSOLE ReadConsoleRequest = &ApiMessage.Data.ReadConsoleRequest;
46 PCSR_CAPTURE_BUFFER CaptureBuffer = NULL;
47 ULONG CharSize, SizeBytes;
48
49 DPRINT("IntReadConsole\n");
50
51 /* Set up the data to send to the Console Server */
52 ReadConsoleRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
53 ReadConsoleRequest->InputHandle = hConsoleInput;
54 ReadConsoleRequest->Unicode = bUnicode;
55
56 /*
57 * Retrieve the (current) Input EXE name string and length,
58 * not NULL-terminated (always in UNICODE format).
59 */
60 ReadConsoleRequest->ExeLength =
61 GetCurrentExeName((PWCHAR)ReadConsoleRequest->StaticBuffer,
62 sizeof(ReadConsoleRequest->StaticBuffer));
63
64 /*** For DEBUGGING purposes ***/
65 {
66 UNICODE_STRING ExeName;
67 ExeName.Length = ExeName.MaximumLength = ReadConsoleRequest->ExeLength;
68 ExeName.Buffer = (PWCHAR)ReadConsoleRequest->StaticBuffer;
69 DPRINT("IntReadConsole(ExeName = %wZ)\n", &ExeName);
70 }
71 /******************************/
72
73 /* Determine the needed size */
74 CharSize = (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
75 SizeBytes = nNumberOfCharsToRead * CharSize;
76
77 ReadConsoleRequest->CaptureBufferSize =
78 ReadConsoleRequest->NumBytes = SizeBytes;
79
80 /*
81 * For optimization purposes, Windows (and hence ReactOS, too, for
82 * compatibility reasons) uses a static buffer if no more than eighty
83 * bytes are read. Otherwise a new buffer is allocated.
84 * This behaviour is also expected in the server-side.
85 */
86 if (SizeBytes <= sizeof(ReadConsoleRequest->StaticBuffer))
87 {
88 ReadConsoleRequest->Buffer = ReadConsoleRequest->StaticBuffer;
89 // CaptureBuffer = NULL;
90 }
91 else
92 {
93 /* Allocate a Capture Buffer */
94 CaptureBuffer = CsrAllocateCaptureBuffer(1, SizeBytes);
95 if (CaptureBuffer == NULL)
96 {
97 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
99 return FALSE;
100 }
101
102 /* Allocate space in the Buffer */
103 CsrAllocateMessagePointer(CaptureBuffer,
104 SizeBytes,
105 (PVOID*)&ReadConsoleRequest->Buffer);
106 }
107
108 ReadConsoleRequest->InitialNumBytes = 0;
109 ReadConsoleRequest->CtrlWakeupMask = 0;
110 ReadConsoleRequest->ControlKeyState = 0;
111
112 /*
113 * From MSDN (ReadConsole function), the description
114 * for pInputControl says:
115 * "This parameter requires Unicode input by default.
116 * For ANSI mode, set this parameter to NULL."
117 */
119 {
120 if (bUnicode && pInputControl &&
122 {
123 /* Sanity check */
125 {
126 ReadConsoleRequest->InitialNumBytes =
127 pInputControl->nInitialChars * sizeof(WCHAR); // CharSize
128
130 {
131 /*
132 * It is possible here to overwrite the static buffer, in case
133 * the number of bytes to read was smaller than the static buffer.
134 * In this case, this means we are continuing a pending read,
135 * and we do not need in fact the executable name that was
136 * stored in the static buffer because it was first grabbed when
137 * we started the first read.
138 */
139 RtlCopyMemory(ReadConsoleRequest->Buffer,
140 lpBuffer,
141 ReadConsoleRequest->InitialNumBytes);
142 }
143
144 ReadConsoleRequest->CtrlWakeupMask = pInputControl->dwCtrlWakeupMask;
145 }
146 else
147 {
148 // Status = STATUS_INVALID_PARAMETER;
149 }
150 }
151 else
152 {
153 /* We are in a situation where pInputControl has no meaning */
155 }
156 }
158 {
159 // HACK
160 if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
162 _SEH2_YIELD(return FALSE);
163 }
164 _SEH2_END;
165
166 /* FIXME: Check for sanity */
167/*
168 if (!NT_SUCCESS(Status) && pInputControl)
169 {
170 // Free CaptureBuffer if needed
171 // Set last error to last status
172 // Return FALSE
173 }
174*/
175
176 /* Call the server */
178 CaptureBuffer,
180 sizeof(*ReadConsoleRequest));
181
182 /* Check for success */
183 Success = NT_SUCCESS(ApiMessage.Status);
184
185 /* Retrieve the results */
186 if (Success)
187 {
189 {
190 *lpNumberOfCharsRead = ReadConsoleRequest->NumBytes / CharSize;
191
192 if (bUnicode && pInputControl)
193 pInputControl->dwControlKeyState = ReadConsoleRequest->ControlKeyState;
194
196 ReadConsoleRequest->Buffer,
197 ReadConsoleRequest->NumBytes);
198 }
200 {
202 Success = FALSE;
203 }
204 _SEH2_END;
205 }
206 else
207 {
208 BaseSetLastNTError(ApiMessage.Status);
209 }
210
211 /* Release the capture buffer if needed */
212 if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
213
214 if (Success)
215 {
216 /* Yield execution to another thread if Ctrl-C or Ctrl-Break happened */
217 if (ApiMessage.Status == STATUS_ALERTED /* || ApiMessage.Status == STATUS_CANCELLED */)
218 {
220 SetLastError(ERROR_OPERATION_ABORTED); // STATUS_CANCELLED
221 }
222 }
223
224 /* Return success status */
225 return Success;
226}
@ ConsolepReadConsole
Definition: conmsg.h:50
USHORT GetCurrentExeName(OUT PWCHAR ExeName, IN USHORT BufferSize)
Definition: console.c:316
NTSYSAPI NTSTATUS WINAPI NtYieldExecution(void)
Definition: thrdschd.c:744
#define STATUS_ALERTED
Definition: ntstatus.h:80
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:162
CONSOLE_READCONSOLE ReadConsoleRequest
Definition: conmsg.h:983
ULONG CtrlWakeupMask
Definition: conmsg.h:267
HANDLE InputHandle
Definition: conmsg.h:256
ULONG ControlKeyState
Definition: conmsg.h:268
ULONG CaptureBufferSize
Definition: conmsg.h:264
HANDLE ConsoleHandle
Definition: conmsg.h:255
CHAR StaticBuffer[80]
Definition: conmsg.h:260
ULONG InitialNumBytes
Definition: conmsg.h:266
USHORT MaximumLength
Definition: env_spec_w32.h:370
uint16_t * PWCHAR
Definition: typedefs.h:56
_In_ DWORD nNumberOfCharsToRead
Definition: wincon.h:491
_In_ DWORD _Out_ _In_opt_ PCONSOLE_READCONSOLE_CONTROL pInputControl
Definition: wincon.h:493
#define ERROR_OPERATION_ABORTED
Definition: winerror.h:575
__wchar_t WCHAR
Definition: xmlstorage.h:180
char CHAR
Definition: xmlstorage.h:175

Referenced by ReadConsoleA(), and ReadConsoleW().

◆ IntReadConsoleOutput()

static BOOL IntReadConsoleOutput ( IN HANDLE  hConsoleOutput,
OUT PCHAR_INFO  lpBuffer,
IN COORD  dwBufferSize,
IN COORD  dwBufferCoord,
IN OUT PSMALL_RECT  lpReadRegion,
IN BOOLEAN  bUnicode 
)
static

Definition at line 341 of file readwrite.c.

347{
349 CONSOLE_API_MESSAGE ApiMessage;
350 PCONSOLE_READOUTPUT ReadOutputRequest = &ApiMessage.Data.ReadOutputRequest;
351 PCSR_CAPTURE_BUFFER CaptureBuffer = NULL;
352
353 SHORT SizeX, SizeY;
354 ULONG NumCells;
355
356 /* Set up the data to send to the Console Server */
357 ReadOutputRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
358 ReadOutputRequest->OutputHandle = hConsoleOutput;
359 ReadOutputRequest->Unicode = bUnicode;
360
361 /* Update lpReadRegion */
363 {
364 SizeX = min(dwBufferSize.X - dwBufferCoord.X, ConioRectWidth(lpReadRegion));
365 SizeY = min(dwBufferSize.Y - dwBufferCoord.Y, ConioRectHeight(lpReadRegion));
366 if (SizeX <= 0 || SizeY <= 0)
367 {
369 _SEH2_YIELD(return FALSE);
370 }
371 lpReadRegion->Right = lpReadRegion->Left + SizeX - 1;
372 lpReadRegion->Bottom = lpReadRegion->Top + SizeY - 1;
373
374 ReadOutputRequest->ReadRegion = *lpReadRegion;
375 }
377 {
379 _SEH2_YIELD(return FALSE);
380 }
381 _SEH2_END;
382
383 NumCells = SizeX * SizeY;
384 DPRINT("IntReadConsoleOutput: (%d x %d)\n", SizeX, SizeY);
385
386 /*
387 * For optimization purposes, Windows (and hence ReactOS, too, for
388 * compatibility reasons) uses a static buffer if no more than one
389 * cell is read. Otherwise a new buffer is allocated.
390 * This behaviour is also expected in the server-side.
391 */
392 if (NumCells <= 1)
393 {
394 ReadOutputRequest->CharInfo = &ReadOutputRequest->StaticBuffer;
395 // CaptureBuffer = NULL;
396 }
397 else
398 {
399 ULONG Size = NumCells * sizeof(CHAR_INFO);
400
401 /* Allocate a Capture Buffer */
402 CaptureBuffer = CsrAllocateCaptureBuffer(1, Size);
403 if (CaptureBuffer == NULL)
404 {
405 DPRINT1("CsrAllocateCaptureBuffer failed with size %ld!\n", Size);
407 return FALSE;
408 }
409
410 /* Allocate space in the Buffer */
411 CsrAllocateMessagePointer(CaptureBuffer,
412 Size,
413 (PVOID*)&ReadOutputRequest->CharInfo);
414 }
415
416 /* Call the server */
418 CaptureBuffer,
420 sizeof(*ReadOutputRequest));
421
422 /* Check for success */
423 Success = NT_SUCCESS(ApiMessage.Status);
424
425 /* Retrieve the results */
427 {
428 *lpReadRegion = ReadOutputRequest->ReadRegion;
429
430 if (Success)
431 {
432#if 0
433 SHORT x, X;
434#endif
435 SHORT y, Y;
436
437 /* Copy into the buffer */
438
439 SizeX = ConioRectWidth(&ReadOutputRequest->ReadRegion);
440
441 for (y = 0, Y = ReadOutputRequest->ReadRegion.Top; Y <= ReadOutputRequest->ReadRegion.Bottom; ++y, ++Y)
442 {
443 RtlCopyMemory(lpBuffer + (y + dwBufferCoord.Y) * dwBufferSize.X + dwBufferCoord.X,
444 ReadOutputRequest->CharInfo + y * SizeX,
445 SizeX * sizeof(CHAR_INFO));
446#if 0
447 for (x = 0, X = ReadOutputRequest->ReadRegion.Left; X <= ReadOutputRequest->ReadRegion.Right; ++x, ++X)
448 {
449 *(lpBuffer + (y + dwBufferCoord.Y) * dwBufferSize.X + (x + dwBufferCoord.X)) =
450 *(ReadOutputRequest->CharInfo + y * SizeX + x);
451 }
452#endif
453 }
454 }
455 else
456 {
457 BaseSetLastNTError(ApiMessage.Status);
458 }
459 }
461 {
463 Success = FALSE;
464 }
465 _SEH2_END;
466
467 /* Release the capture buffer if needed */
468 if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
469
470 /* Return success status */
471 return Success;
472}
@ ConsolepReadConsoleOutput
Definition: conmsg.h:24
#define Y(I)
#define ConioRectWidth(Rect)
Definition: readwrite.c:24
#define ConioRectHeight(Rect)
Definition: readwrite.c:22
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define X(b, s)
#define min(a, b)
Definition: monoChain.cc:55
short SHORT
Definition: pedump.c:59
CONSOLE_READOUTPUT ReadOutputRequest
Definition: conmsg.h:985
PCHAR_INFO CharInfo
Definition: conmsg.h:590
BOOLEAN Unicode
Definition: conmsg.h:593
HANDLE OutputHandle
Definition: conmsg.h:587
SMALL_RECT ReadRegion
Definition: conmsg.h:592
CHAR_INFO StaticBuffer
Definition: conmsg.h:589
HANDLE ConsoleHandle
Definition: conmsg.h:586
SHORT Top
Definition: tui.c:25
SHORT Left
Definition: tui.c:24
struct _CHAR_INFO CHAR_INFO

Referenced by ReadConsoleOutputA(), and ReadConsoleOutputW().

◆ IntReadConsoleOutputCode()

static BOOL IntReadConsoleOutputCode ( IN HANDLE  hConsoleOutput,
IN CODE_TYPE  CodeType,
OUT PVOID  pCode,
IN DWORD  nLength,
IN COORD  dwReadCoord,
OUT LPDWORD  lpNumberOfCodesRead 
)
static

Definition at line 477 of file readwrite.c.

483{
485 CONSOLE_API_MESSAGE ApiMessage;
486 PCONSOLE_READOUTPUTCODE ReadOutputCodeRequest = &ApiMessage.Data.ReadOutputCodeRequest;
487 PCSR_CAPTURE_BUFFER CaptureBuffer = NULL;
488 ULONG CodeSize, SizeBytes;
489
490 DPRINT("IntReadConsoleOutputCode\n");
491
492 if ( (CodeType != CODE_ASCII ) &&
493 (CodeType != CODE_UNICODE ) &&
494 (CodeType != CODE_ATTRIBUTE) )
495 {
497 return FALSE;
498 }
499
500 /* Set up the data to send to the Console Server */
501 ReadOutputCodeRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
502 ReadOutputCodeRequest->OutputHandle = hConsoleOutput;
503 ReadOutputCodeRequest->Coord = dwReadCoord;
504 ReadOutputCodeRequest->NumCodes = nLength;
505
506 /* Determine the needed size */
507 ReadOutputCodeRequest->CodeType = CodeType;
508 switch (CodeType)
509 {
510 case CODE_ASCII:
511 CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, AsciiChar);
512 break;
513
514 case CODE_UNICODE:
515 CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, UnicodeChar);
516 break;
517
518 case CODE_ATTRIBUTE:
519 CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, Attribute);
520 break;
521 }
522 SizeBytes = nLength * CodeSize;
523
524 /*
525 * For optimization purposes, Windows (and hence ReactOS, too, for
526 * compatibility reasons) uses a static buffer if no more than eighty
527 * bytes are read. Otherwise a new buffer is allocated.
528 * This behaviour is also expected in the server-side.
529 */
530 if (SizeBytes <= sizeof(ReadOutputCodeRequest->CodeStaticBuffer))
531 {
532 ReadOutputCodeRequest->pCode = ReadOutputCodeRequest->CodeStaticBuffer;
533 // CaptureBuffer = NULL;
534 }
535 else
536 {
537 /* Allocate a Capture Buffer */
538 CaptureBuffer = CsrAllocateCaptureBuffer(1, SizeBytes);
539 if (CaptureBuffer == NULL)
540 {
541 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
543 return FALSE;
544 }
545
546 /* Allocate space in the Buffer */
547 CsrAllocateMessagePointer(CaptureBuffer,
548 SizeBytes,
549 (PVOID*)&ReadOutputCodeRequest->pCode);
550 }
551
552 /* Call the server */
554 CaptureBuffer,
556 sizeof(*ReadOutputCodeRequest));
557
558 /* Check for success */
559 Success = NT_SUCCESS(ApiMessage.Status);
560
561 /* Retrieve the results */
563 {
564 *lpNumberOfCodesRead = ReadOutputCodeRequest->NumCodes;
565
566 if (Success)
567 {
568 RtlCopyMemory(pCode,
569 ReadOutputCodeRequest->pCode,
570 ReadOutputCodeRequest->NumCodes * CodeSize);
571 }
572 else
573 {
574 BaseSetLastNTError(ApiMessage.Status);
575 }
576 }
578 {
580 Success = FALSE;
581 }
582 _SEH2_END;
583
584 /* Release the capture buffer if needed */
585 if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
586
587 /* Return success status */
588 return Success;
589}
@ ConsolepReadConsoleOutputString
Definition: conmsg.h:26
#define RTL_FIELD_SIZE(type, field)
Definition: kdb_expr.c:86
CONSOLE_READOUTPUTCODE ReadOutputCodeRequest
Definition: conmsg.h:986
CODE_TYPE CodeType
Definition: conmsg.h:535
HANDLE ConsoleHandle
Definition: conmsg.h:531
CHAR CodeStaticBuffer[80]
Definition: conmsg.h:536
HANDLE OutputHandle
Definition: conmsg.h:532

Referenced by ReadConsoleOutputAttribute(), ReadConsoleOutputCharacterA(), and ReadConsoleOutputCharacterW().

◆ IntWriteConsole()

static BOOL IntWriteConsole ( IN HANDLE  hConsoleOutput,
IN PVOID  lpBuffer,
IN DWORD  nNumberOfCharsToWrite,
OUT LPDWORD  lpNumberOfCharsWritten,
LPVOID  lpReserved,
IN BOOLEAN  bUnicode 
)
static

Definition at line 598 of file readwrite.c.

604{
606 CONSOLE_API_MESSAGE ApiMessage;
607 PCONSOLE_WRITECONSOLE WriteConsoleRequest = &ApiMessage.Data.WriteConsoleRequest;
608 PCSR_CAPTURE_BUFFER CaptureBuffer = NULL;
609 ULONG CharSize, SizeBytes;
610
611 DPRINT("IntWriteConsole\n");
612
613 /* Set up the data to send to the Console Server */
614 WriteConsoleRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
615 WriteConsoleRequest->OutputHandle = hConsoleOutput;
616 WriteConsoleRequest->Unicode = bUnicode;
617
618 /* Those members are unused by the client, on Windows */
619 WriteConsoleRequest->Reserved1 = 0;
620 // WriteConsoleRequest->Reserved2 = {0};
621
622 /* Determine the needed size */
623 CharSize = (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
624 SizeBytes = nNumberOfCharsToWrite * CharSize;
625
626 WriteConsoleRequest->NumBytes = SizeBytes;
627
628 /*
629 * For optimization purposes, Windows (and hence ReactOS, too, for
630 * compatibility reasons) uses a static buffer if no more than eighty
631 * bytes are written. Otherwise a new buffer is allocated.
632 * This behaviour is also expected in the server-side.
633 */
634 if (SizeBytes <= sizeof(WriteConsoleRequest->StaticBuffer))
635 {
636 WriteConsoleRequest->Buffer = WriteConsoleRequest->StaticBuffer;
637 // CaptureBuffer = NULL;
638 WriteConsoleRequest->UsingStaticBuffer = TRUE;
639
641 {
642 RtlCopyMemory(WriteConsoleRequest->Buffer,
643 lpBuffer,
644 SizeBytes);
645 }
647 {
649 _SEH2_YIELD(return FALSE);
650 }
651 _SEH2_END;
652 }
653 else
654 {
655 /* Allocate a Capture Buffer */
656 CaptureBuffer = CsrAllocateCaptureBuffer(1, SizeBytes);
657 if (CaptureBuffer == NULL)
658 {
659 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
661 return FALSE;
662 }
663
664 /* Capture the buffer to write */
665 CsrCaptureMessageBuffer(CaptureBuffer,
667 SizeBytes,
668 (PVOID*)&WriteConsoleRequest->Buffer);
669 WriteConsoleRequest->UsingStaticBuffer = FALSE;
670 }
671
672 /* Call the server */
674 CaptureBuffer,
676 sizeof(*WriteConsoleRequest));
677
678 /* Check for success */
679 Success = NT_SUCCESS(ApiMessage.Status);
680
681 /* Release the capture buffer if needed */
682 if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
683
684 /* Retrieve the results. NOTE: lpNumberOfCharsWritten optional since Vista+ */
685 if (Success && lpNumberOfCharsWritten)
686 {
688 {
689 *lpNumberOfCharsWritten = WriteConsoleRequest->NumBytes / CharSize;
690 }
692 {
694 Success = FALSE;
695 }
696 _SEH2_END;
697 }
698 else if (!Success)
699 {
700 BaseSetLastNTError(ApiMessage.Status);
701 }
702
703 /* Return success status */
704 return Success;
705}
@ ConsolepWriteConsole
Definition: conmsg.h:51
#define TRUE
Definition: types.h:120
VOID NTAPI CsrCaptureMessageBuffer(_Inout_ PCSR_CAPTURE_BUFFER CaptureBuffer, _In_opt_ PVOID MessageBuffer, _In_ ULONG MessageLength, _Out_ PVOID *CapturedData)
Definition: capture.c:189
CONSOLE_WRITECONSOLE WriteConsoleRequest
Definition: conmsg.h:990
CHAR StaticBuffer[80]
Definition: conmsg.h:239
BOOLEAN UsingStaticBuffer
Definition: conmsg.h:246
HANDLE ConsoleHandle
Definition: conmsg.h:236

Referenced by WriteConsoleA(), and WriteConsoleW().

◆ IntWriteConsoleInput()

static BOOL IntWriteConsoleInput ( IN HANDLE  hConsoleInput,
IN PINPUT_RECORD  lpBuffer,
IN DWORD  nLength,
OUT LPDWORD  lpNumberOfEventsWritten,
IN BOOLEAN  bUnicode,
IN BOOLEAN  bAppendToEnd 
)
static

Definition at line 710 of file readwrite.c.

716{
718 CONSOLE_API_MESSAGE ApiMessage;
719 PCONSOLE_WRITEINPUT WriteInputRequest = &ApiMessage.Data.WriteInputRequest;
720 PCSR_CAPTURE_BUFFER CaptureBuffer = NULL;
721
722 DPRINT("IntWriteConsoleInput: %lx %p\n", nLength, lpNumberOfEventsWritten);
723
724 /* Set up the data to send to the Console Server */
725 WriteInputRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
726 WriteInputRequest->InputHandle = hConsoleInput;
727 WriteInputRequest->NumRecords = nLength;
728 WriteInputRequest->Unicode = bUnicode;
729 WriteInputRequest->AppendToEnd = bAppendToEnd;
730
731 /*
732 * For optimization purposes, Windows (and hence ReactOS, too, for
733 * compatibility reasons) uses a static buffer if no more than five
734 * input records are written. Otherwise a new buffer is allocated.
735 * This behaviour is also expected in the server-side.
736 */
737 if (nLength <= sizeof(WriteInputRequest->RecordStaticBuffer)/sizeof(INPUT_RECORD))
738 {
739 WriteInputRequest->RecordBufPtr = WriteInputRequest->RecordStaticBuffer;
740 // CaptureBuffer = NULL;
741
743 {
744 RtlCopyMemory(WriteInputRequest->RecordBufPtr,
745 lpBuffer,
746 nLength * sizeof(INPUT_RECORD));
747 }
749 {
751 _SEH2_YIELD(return FALSE);
752 }
753 _SEH2_END;
754 }
755 else
756 {
757 ULONG Size = nLength * sizeof(INPUT_RECORD);
758
759 /* Allocate a Capture Buffer */
760 CaptureBuffer = CsrAllocateCaptureBuffer(1, Size);
761 if (CaptureBuffer == NULL)
762 {
763 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
765 return FALSE;
766 }
767
768 /* Capture the user buffer */
769 CsrCaptureMessageBuffer(CaptureBuffer,
770 lpBuffer,
771 Size,
772 (PVOID*)&WriteInputRequest->RecordBufPtr);
773 }
774
775 /* Call the server */
777 CaptureBuffer,
779 sizeof(*WriteInputRequest));
780
781 /* Check for success */
782 Success = NT_SUCCESS(ApiMessage.Status);
783
784 /* Release the capture buffer if needed */
785 if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
786
787 /* Retrieve the results */
789 {
790 DPRINT("Events written: %lx\n", WriteInputRequest->NumRecords);
791 *lpNumberOfEventsWritten = WriteInputRequest->NumRecords;
792
793 if (!Success)
794 BaseSetLastNTError(ApiMessage.Status);
795 }
797 {
799 Success = FALSE;
800 }
801 _SEH2_END;
802
803 /* Return success status */
804 return Success;
805}
@ ConsolepWriteConsoleInput
Definition: conmsg.h:23
CONSOLE_WRITEINPUT WriteInputRequest
Definition: conmsg.h:991
BOOLEAN AppendToEnd
Definition: conmsg.h:581
PINPUT_RECORD RecordBufPtr
Definition: conmsg.h:578
HANDLE InputHandle
Definition: conmsg.h:576
BOOLEAN Unicode
Definition: conmsg.h:580
INPUT_RECORD RecordStaticBuffer[5]
Definition: conmsg.h:577
HANDLE ConsoleHandle
Definition: conmsg.h:575

Referenced by WriteConsoleInputA(), WriteConsoleInputVDMA(), WriteConsoleInputVDMW(), and WriteConsoleInputW().

◆ IntWriteConsoleOutput()

static BOOL IntWriteConsoleOutput ( IN HANDLE  hConsoleOutput,
IN CONST CHAR_INFO lpBuffer,
IN COORD  dwBufferSize,
IN COORD  dwBufferCoord,
IN OUT PSMALL_RECT  lpWriteRegion,
IN BOOLEAN  bUnicode 
)
static

Definition at line 810 of file readwrite.c.

816{
818 CONSOLE_API_MESSAGE ApiMessage;
819 PCONSOLE_WRITEOUTPUT WriteOutputRequest = &ApiMessage.Data.WriteOutputRequest;
820 PCSR_CAPTURE_BUFFER CaptureBuffer = NULL;
821
822 SHORT SizeX, SizeY;
823 ULONG NumCells;
824
825 /* Set up the data to send to the Console Server */
826 WriteOutputRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
827 WriteOutputRequest->OutputHandle = hConsoleOutput;
828 WriteOutputRequest->Unicode = bUnicode;
829
830 /* Update lpWriteRegion */
832 {
833 SizeX = min(dwBufferSize.X - dwBufferCoord.X, ConioRectWidth(lpWriteRegion));
834 SizeY = min(dwBufferSize.Y - dwBufferCoord.Y, ConioRectHeight(lpWriteRegion));
835 if (SizeX <= 0 || SizeY <= 0)
836 {
838 _SEH2_YIELD(return FALSE);
839 }
840 lpWriteRegion->Right = lpWriteRegion->Left + SizeX - 1;
841 lpWriteRegion->Bottom = lpWriteRegion->Top + SizeY - 1;
842
843 WriteOutputRequest->WriteRegion = *lpWriteRegion;
844 }
846 {
848 _SEH2_YIELD(return FALSE);
849 }
850 _SEH2_END;
851
852 NumCells = SizeX * SizeY;
853 DPRINT("IntWriteConsoleOutput: (%d x %d)\n", SizeX, SizeY);
854
855 /*
856 * For optimization purposes, Windows (and hence ReactOS, too, for
857 * compatibility reasons) uses a static buffer if no more than one
858 * cell is written. Otherwise a new buffer is allocated.
859 * This behaviour is also expected in the server-side.
860 */
861 if (NumCells <= 1)
862 {
863 WriteOutputRequest->CharInfo = &WriteOutputRequest->StaticBuffer;
864 // CaptureBuffer = NULL;
865 WriteOutputRequest->UseVirtualMemory = FALSE;
866 }
867 else
868 {
869 ULONG Size = NumCells * sizeof(CHAR_INFO);
870
871 /* Allocate a Capture Buffer */
872 CaptureBuffer = CsrAllocateCaptureBuffer(1, Size);
873 if (CaptureBuffer)
874 {
875 /* Allocate space in the Buffer */
876 CsrAllocateMessagePointer(CaptureBuffer,
877 Size,
878 (PVOID*)&WriteOutputRequest->CharInfo);
879 WriteOutputRequest->UseVirtualMemory = FALSE;
880 }
881 else
882 {
883 /*
884 * CsrAllocateCaptureBuffer failed because we tried to allocate
885 * a too large (>= 64 kB, size of the CSR heap) data buffer.
886 * To circumvent this, Windows uses a trick (that we reproduce for
887 * compatibility reasons): we allocate a heap buffer in the process'
888 * memory, and CSR will read it via NtReadVirtualMemory.
889 */
890 DPRINT1("CsrAllocateCaptureBuffer failed with size %ld, let's use local heap buffer...\n", Size);
891
892 WriteOutputRequest->CharInfo = RtlAllocateHeap(RtlGetProcessHeap(), 0, Size);
893 WriteOutputRequest->UseVirtualMemory = TRUE;
894
895 /* Bail out if we still cannot allocate memory */
896 if (WriteOutputRequest->CharInfo == NULL)
897 {
898 DPRINT1("Failed to allocate heap buffer with size %ld!\n", Size);
900 return FALSE;
901 }
902 }
903 }
904
905 /* Capture the user buffer contents */
907 {
908#if 0
909 SHORT x, X;
910#endif
911 SHORT y, Y;
912
913 /* Copy into the buffer */
914
915 SizeX = ConioRectWidth(&WriteOutputRequest->WriteRegion);
916
917 for (y = 0, Y = WriteOutputRequest->WriteRegion.Top; Y <= WriteOutputRequest->WriteRegion.Bottom; ++y, ++Y)
918 {
919 RtlCopyMemory(WriteOutputRequest->CharInfo + y * SizeX,
920 lpBuffer + (y + dwBufferCoord.Y) * dwBufferSize.X + dwBufferCoord.X,
921 SizeX * sizeof(CHAR_INFO));
922#if 0
923 for (x = 0, X = WriteOutputRequest->WriteRegion.Left; X <= WriteOutputRequest->WriteRegion.Right; ++x, ++X)
924 {
925 *(WriteOutputRequest->CharInfo + y * SizeX + x) =
926 *(lpBuffer + (y + dwBufferCoord.Y) * dwBufferSize.X + (x + dwBufferCoord.X));
927 }
928#endif
929 }
930 }
932 {
934 _SEH2_YIELD(return FALSE);
935 }
936 _SEH2_END;
937
938 /* Call the server */
940 CaptureBuffer,
942 sizeof(*WriteOutputRequest));
943
944 /* Check for success */
945 Success = NT_SUCCESS(ApiMessage.Status);
946
947 /* Release the capture buffer if needed */
948 if (CaptureBuffer)
949 {
950 CsrFreeCaptureBuffer(CaptureBuffer);
951 }
952 else
953 {
954 /* If we used a heap buffer, free it */
955 if (WriteOutputRequest->UseVirtualMemory)
956 RtlFreeHeap(RtlGetProcessHeap(), 0, WriteOutputRequest->CharInfo);
957 }
958
959 /* Retrieve the results */
961 {
962 *lpWriteRegion = WriteOutputRequest->WriteRegion;
963
964 if (!Success)
965 BaseSetLastNTError(ApiMessage.Status);
966 }
968 {
970 Success = FALSE;
971 }
972 _SEH2_END;
973
974 /* Return success status */
975 return Success;
976}
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
@ ConsolepWriteConsoleOutput
Definition: conmsg.h:25
CONSOLE_WRITEOUTPUT WriteOutputRequest
Definition: conmsg.h:992
HANDLE ConsoleHandle
Definition: conmsg.h:598
SMALL_RECT WriteRegion
Definition: conmsg.h:604
BOOLEAN UseVirtualMemory
Definition: conmsg.h:612
HANDLE OutputHandle
Definition: conmsg.h:599
CHAR_INFO StaticBuffer
Definition: conmsg.h:601
PCHAR_INFO CharInfo
Definition: conmsg.h:602

Referenced by WriteConsoleOutputA(), and WriteConsoleOutputW().

◆ IntWriteConsoleOutputCode()

static BOOL IntWriteConsoleOutputCode ( IN HANDLE  hConsoleOutput,
IN CODE_TYPE  CodeType,
IN CONST VOID pCode,
IN DWORD  nLength,
IN COORD  dwWriteCoord,
OUT LPDWORD  lpNumberOfCodesWritten 
)
static

Definition at line 981 of file readwrite.c.

987{
989 CONSOLE_API_MESSAGE ApiMessage;
990 PCONSOLE_WRITEOUTPUTCODE WriteOutputCodeRequest = &ApiMessage.Data.WriteOutputCodeRequest;
991 PCSR_CAPTURE_BUFFER CaptureBuffer = NULL;
992 ULONG CodeSize, SizeBytes;
993
994 if ( (CodeType != CODE_ASCII ) &&
995 (CodeType != CODE_UNICODE ) &&
996 (CodeType != CODE_ATTRIBUTE) )
997 {
999 return FALSE;
1000 }
1001
1002 DPRINT("IntWriteConsoleOutputCode\n");
1003
1004 /* Set up the data to send to the Console Server */
1005 WriteOutputCodeRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1006 WriteOutputCodeRequest->OutputHandle = hConsoleOutput;
1007 WriteOutputCodeRequest->Coord = dwWriteCoord;
1008 WriteOutputCodeRequest->NumCodes = nLength;
1009
1010 /* Determine the needed size */
1011 WriteOutputCodeRequest->CodeType = CodeType;
1012 switch (CodeType)
1013 {
1014 case CODE_ASCII:
1015 CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, AsciiChar);
1016 break;
1017
1018 case CODE_UNICODE:
1019 CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, UnicodeChar);
1020 break;
1021
1022 case CODE_ATTRIBUTE:
1023 CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, Attribute);
1024 break;
1025 }
1026 SizeBytes = nLength * CodeSize;
1027
1028 /*
1029 * For optimization purposes, Windows (and hence ReactOS, too, for
1030 * compatibility reasons) uses a static buffer if no more than eighty
1031 * bytes are written. Otherwise a new buffer is allocated.
1032 * This behaviour is also expected in the server-side.
1033 */
1034 if (SizeBytes <= sizeof(WriteOutputCodeRequest->CodeStaticBuffer))
1035 {
1036 WriteOutputCodeRequest->pCode = WriteOutputCodeRequest->CodeStaticBuffer;
1037 // CaptureBuffer = NULL;
1038
1039 _SEH2_TRY
1040 {
1041 RtlCopyMemory(WriteOutputCodeRequest->pCode,
1042 pCode,
1043 SizeBytes);
1044 }
1046 {
1048 _SEH2_YIELD(return FALSE);
1049 }
1050 _SEH2_END;
1051 }
1052 else
1053 {
1054 /* Allocate a Capture Buffer */
1055 CaptureBuffer = CsrAllocateCaptureBuffer(1, SizeBytes);
1056 if (CaptureBuffer == NULL)
1057 {
1058 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
1060 return FALSE;
1061 }
1062
1063 /* Capture the buffer to write */
1064 CsrCaptureMessageBuffer(CaptureBuffer,
1065 (PVOID)pCode,
1066 SizeBytes,
1067 (PVOID*)&WriteOutputCodeRequest->pCode);
1068 }
1069
1070 /* Call the server */
1072 CaptureBuffer,
1074 sizeof(*WriteOutputCodeRequest));
1075
1076 /* Check for success */
1077 Success = NT_SUCCESS(ApiMessage.Status);
1078
1079 /* Release the capture buffer if needed */
1080 if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
1081
1082 /* Retrieve the results */
1083 _SEH2_TRY
1084 {
1085 *lpNumberOfCodesWritten = WriteOutputCodeRequest->NumCodes;
1086
1087 if (!Success)
1088 BaseSetLastNTError(ApiMessage.Status);
1089 }
1091 {
1093 Success = FALSE;
1094 }
1095 _SEH2_END;
1096
1097 /* Return success status */
1098 return Success;
1099}
@ ConsolepWriteConsoleOutputString
Definition: conmsg.h:27
CONSOLE_WRITEOUTPUTCODE WriteOutputCodeRequest
Definition: conmsg.h:993

Referenced by WriteConsoleOutputAttribute(), WriteConsoleOutputCharacterA(), and WriteConsoleOutputCharacterW().

◆ PeekConsoleInputA()

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

Definition at line 1236 of file readwrite.c.

1240{
1241 return IntGetConsoleInput(hConsoleInput,
1242 lpBuffer,
1243 nLength,
1246 FALSE);
1247}
static BOOL IntGetConsoleInput(IN HANDLE hConsoleInput, OUT PINPUT_RECORD lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsRead, IN WORD wFlags, IN BOOLEAN bUnicode)
Definition: readwrite.c:231
#define CONSOLE_READ_NOREMOVE
Definition: wincon.h:122
#define CONSOLE_READ_NOWAIT
Definition: wincon.h:123

◆ PeekConsoleInputW()

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

Definition at line 1216 of file readwrite.c.

1220{
1221 return IntGetConsoleInput(hConsoleInput,
1222 lpBuffer,
1223 nLength,
1226 TRUE);
1227}

Referenced by InputWait().

◆ ReadConsoleA()

BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleA ( IN HANDLE  hConsoleInput,
OUT LPVOID  lpBuffer,
IN DWORD  nNumberOfCharsToRead,
OUT LPDWORD  lpNumberOfCharsRead,
IN PCONSOLE_READCONSOLE_CONTROL pInputControl  OPTIONAL 
)

Definition at line 1195 of file readwrite.c.

1200{
1201 return IntReadConsole(hConsoleInput,
1202 lpBuffer,
1204 lpNumberOfCharsRead,
1205 NULL,
1206 FALSE);
1207}
static BOOL IntReadConsole(IN HANDLE hConsoleInput, OUT PVOID lpBuffer, IN DWORD nNumberOfCharsToRead, OUT LPDWORD lpNumberOfCharsRead, IN PCONSOLE_READCONSOLE_CONTROL pInputControl OPTIONAL, IN BOOLEAN bUnicode)
Definition: readwrite.c:36

Referenced by _getch(), getinput(), GetInput(), main(), ReadFile(), test2(), test3(), and test_ReadConsole().

◆ ReadConsoleInputA()

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

Definition at line 1276 of file readwrite.c.

1280{
1281 return IntGetConsoleInput(hConsoleInput,
1282 lpBuffer,
1283 nLength,
1285 0,
1286 FALSE);
1287}

◆ ReadConsoleInputExA()

BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleInputExA ( IN HANDLE  hConsoleInput,
OUT PINPUT_RECORD  lpBuffer,
IN DWORD  nLength,
OUT LPDWORD  lpNumberOfEventsRead,
IN WORD  wFlags 
)

Definition at line 1317 of file readwrite.c.

1322{
1323 return IntGetConsoleInput(hConsoleInput,
1324 lpBuffer,
1325 nLength,
1327 wFlags,
1328 FALSE);
1329}

◆ ReadConsoleInputExW()

BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleInputExW ( IN HANDLE  hConsoleInput,
OUT PINPUT_RECORD  lpBuffer,
IN DWORD  nLength,
OUT LPDWORD  lpNumberOfEventsRead,
IN WORD  wFlags 
)

Definition at line 1296 of file readwrite.c.

1301{
1302 return IntGetConsoleInput(hConsoleInput,
1303 lpBuffer,
1304 nLength,
1306 wFlags,
1307 TRUE);
1308}

Referenced by ConsoleEventThread().

◆ ReadConsoleInputW()

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

Definition at line 1256 of file readwrite.c.

1260{
1261 return IntGetConsoleInput(hConsoleInput,
1262 lpBuffer,
1263 nLength,
1265 0,
1266 TRUE);
1267}

Referenced by InputWait().

◆ ReadConsoleOutputA()

BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleOutputA ( IN HANDLE  hConsoleOutput,
OUT PCHAR_INFO  lpBuffer,
IN COORD  dwBufferSize,
IN COORD  dwBufferCoord,
IN OUT PSMALL_RECT  lpReadRegion 
)

Definition at line 1359 of file readwrite.c.

1364{
1365 return IntReadConsoleOutput(hConsoleOutput,
1366 lpBuffer,
1367 dwBufferSize,
1368 dwBufferCoord,
1369 lpReadRegion,
1370 FALSE);
1371}
static BOOL IntReadConsoleOutput(IN HANDLE hConsoleOutput, OUT PCHAR_INFO lpBuffer, IN COORD dwBufferSize, IN COORD dwBufferCoord, IN OUT PSMALL_RECT lpReadRegion, IN BOOLEAN bUnicode)
Definition: readwrite.c:341

Referenced by AttachToConsoleInternal().

◆ ReadConsoleOutputAttribute()

BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleOutputAttribute ( IN HANDLE  hConsoleOutput,
OUT LPWORD  lpAttribute,
IN DWORD  nLength,
IN COORD  dwReadCoord,
OUT LPDWORD  lpNumberOfAttrsRead 
)

Definition at line 1422 of file readwrite.c.

1427{
1428 return IntReadConsoleOutputCode(hConsoleOutput,
1430 lpAttribute,
1431 nLength,
1432 dwReadCoord,
1433 lpNumberOfAttrsRead);
1434}
static BOOL IntReadConsoleOutputCode(IN HANDLE hConsoleOutput, IN CODE_TYPE CodeType, OUT PVOID pCode, IN DWORD nLength, IN COORD dwReadCoord, OUT LPDWORD lpNumberOfCodesRead)
Definition: readwrite.c:477

Referenced by TConsole::Darkbg(), TConsole::Lightbg(), test_cp855(), test_cp932(), test_ReadConsoleOutputAttribute(), testWriteNotWrappedProcessed(), and testWriteWrappedProcessed().

◆ ReadConsoleOutputCharacterA()

BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleOutputCharacterA ( IN HANDLE  hConsoleOutput,
OUT LPSTR  lpCharacter,
IN DWORD  nLength,
IN COORD  dwReadCoord,
OUT LPDWORD  lpNumberOfCharsRead 
)

Definition at line 1401 of file readwrite.c.

1406{
1407 return IntReadConsoleOutputCode(hConsoleOutput,
1408 CODE_ASCII,
1409 lpCharacter,
1410 nLength,
1411 dwReadCoord,
1412 lpNumberOfCharsRead);
1413}

Referenced by test_ReadConsoleOutputCharacterA(), and testScreenBuffer().

◆ ReadConsoleOutputCharacterW()

BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleOutputCharacterW ( IN HANDLE  hConsoleOutput,
OUT LPWSTR  lpCharacter,
IN DWORD  nLength,
IN COORD  dwReadCoord,
OUT LPDWORD  lpNumberOfCharsRead 
)

Definition at line 1380 of file readwrite.c.

1385{
1386 return IntReadConsoleOutputCode(hConsoleOutput,
1388 lpCharacter,
1389 nLength,
1390 dwReadCoord,
1391 lpNumberOfCharsRead);
1392}

Referenced by test_cp855(), test_cp932(), test_ReadConsoleOutputCharacterW(), and testScreenBuffer().

◆ ReadConsoleOutputW()

BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleOutputW ( IN HANDLE  hConsoleOutput,
OUT PCHAR_INFO  lpBuffer,
IN COORD  dwBufferSize,
IN COORD  dwBufferCoord,
IN OUT PSMALL_RECT  lpReadRegion 
)

Definition at line 1338 of file readwrite.c.

1343{
1344 return IntReadConsoleOutput(hConsoleOutput,
1345 lpBuffer,
1346 dwBufferSize,
1347 dwBufferCoord,
1348 lpReadRegion,
1349 TRUE);
1350}

Referenced by test_cp932().

◆ ReadConsoleW()

BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleW ( IN HANDLE  hConsoleInput,
OUT LPVOID  lpBuffer,
IN DWORD  nNumberOfCharsToRead,
OUT LPDWORD  lpNumberOfCharsRead,
IN PCONSOLE_READCONSOLE_CONTROL pInputControl  OPTIONAL 
)

Definition at line 1174 of file readwrite.c.

1179{
1180 return IntReadConsole(hConsoleInput,
1181 lpBuffer,
1183 lpNumberOfCharsRead,
1185 TRUE);
1186}

Referenced by ask_confirm(), ask_overwrite_value(), Confirm(), ReadString(), and test_ReadConsole().

◆ WriteConsoleA()

BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleA ( IN HANDLE  hConsoleOutput,
IN CONST VOID lpBuffer,
IN DWORD  nNumberOfCharsToWrite,
OUT LPDWORD  lpNumberOfCharsWritten,
LPVOID  lpReserved 
)

Definition at line 1468 of file readwrite.c.

1473{
1474 return IntWriteConsole(hConsoleOutput,
1475 (PVOID)lpBuffer,
1476 nNumberOfCharsToWrite,
1477 lpNumberOfCharsWritten,
1478 lpReserved,
1479 FALSE);
1480}
static BOOL IntWriteConsole(IN HANDLE hConsoleOutput, IN PVOID lpBuffer, IN DWORD nNumberOfCharsToWrite, OUT LPDWORD lpNumberOfCharsWritten, LPVOID lpReserved, IN BOOLEAN bUnicode)
Definition: readwrite.c:598

Referenced by _cputs(), debug_printf(), dprintf(), testEmptyWrite(), testScreenBuffer(), testWriteNotWrappedNotProcessed(), testWriteNotWrappedProcessed(), testWriteSimple(), testWriteWrappedNotProcessed(), testWriteWrappedProcessed(), and WriteFile().

◆ WriteConsoleInputA()

BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleInputA ( IN HANDLE  hConsoleInput,
IN CONST INPUT_RECORD lpBuffer,
IN DWORD  nLength,
OUT LPDWORD  lpNumberOfEventsWritten 
)

Definition at line 1509 of file readwrite.c.

1513{
1514 return IntWriteConsoleInput(hConsoleInput,
1516 nLength,
1517 lpNumberOfEventsWritten,
1518 FALSE,
1519 TRUE);
1520}
static BOOL IntWriteConsoleInput(IN HANDLE hConsoleInput, IN PINPUT_RECORD lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsWritten, IN BOOLEAN bUnicode, IN BOOLEAN bAppendToEnd)
Definition: readwrite.c:710

Referenced by test_WriteConsoleInputA().

◆ WriteConsoleInputVDMA()

BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleInputVDMA ( IN HANDLE  hConsoleInput,
IN CONST INPUT_RECORD lpBuffer,
IN DWORD  nLength,
OUT LPDWORD  lpNumberOfEventsWritten 
)

Definition at line 1549 of file readwrite.c.

1553{
1554 return IntWriteConsoleInput(hConsoleInput,
1556 nLength,
1557 lpNumberOfEventsWritten,
1558 FALSE,
1559 FALSE);
1560}

◆ WriteConsoleInputVDMW()

BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleInputVDMW ( IN HANDLE  hConsoleInput,
IN CONST INPUT_RECORD lpBuffer,
IN DWORD  nLength,
OUT LPDWORD  lpNumberOfEventsWritten 
)

Definition at line 1529 of file readwrite.c.

1533{
1534 return IntWriteConsoleInput(hConsoleInput,
1536 nLength,
1537 lpNumberOfEventsWritten,
1538 TRUE,
1539 FALSE);
1540}

◆ WriteConsoleInputW()

BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleInputW ( IN HANDLE  hConsoleInput,
IN CONST INPUT_RECORD lpBuffer,
IN DWORD  nLength,
OUT LPDWORD  lpNumberOfEventsWritten 
)

Definition at line 1489 of file readwrite.c.

1493{
1494 return IntWriteConsoleInput(hConsoleInput,
1496 nLength,
1497 lpNumberOfEventsWritten,
1498 TRUE,
1499 TRUE);
1500}

Referenced by test_WriteConsoleInputW(), and testWaitForConsoleInput().

◆ WriteConsoleOutputA()

BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleOutputA ( IN HANDLE  hConsoleOutput,
IN CONST CHAR_INFO lpBuffer,
IN COORD  dwBufferSize,
IN COORD  dwBufferCoord,
IN OUT PSMALL_RECT  lpWriteRegion 
)

Definition at line 1590 of file readwrite.c.

1595{
1596 return IntWriteConsoleOutput(hConsoleOutput,
1597 lpBuffer,
1598 dwBufferSize,
1599 dwBufferCoord,
1600 lpWriteRegion,
1601 FALSE);
1602}
static BOOL IntWriteConsoleOutput(IN HANDLE hConsoleOutput, IN CONST CHAR_INFO *lpBuffer, IN COORD dwBufferSize, IN COORD dwBufferCoord, IN OUT PSMALL_RECT lpWriteRegion, IN BOOLEAN bUnicode)
Definition: readwrite.c:810

Referenced by __InvalidateConsoleDIBits().

◆ WriteConsoleOutputAttribute()

BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleOutputAttribute ( IN HANDLE  hConsoleOutput,
IN CONST WORD lpAttribute,
IN DWORD  nLength,
IN COORD  dwWriteCoord,
OUT LPDWORD  lpNumberOfAttrsWritten 
)

Definition at line 1653 of file readwrite.c.

1658{
1659 return IntWriteConsoleOutputCode(hConsoleOutput,
1661 lpAttribute,
1662 nLength,
1663 dwWriteCoord,
1664 lpNumberOfAttrsWritten);
1665}
static BOOL IntWriteConsoleOutputCode(IN HANDLE hConsoleOutput, IN CODE_TYPE CodeType, IN CONST VOID *pCode, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCodesWritten)
Definition: readwrite.c:981

Referenced by TConsole::Darkbg(), TConsole::Lightbg(), resetContent(), test_cp932(), test_WriteConsoleOutputAttribute(), and WriteConsoleOutputCharAndAttribute().

◆ WriteConsoleOutputCharacterA()

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

Definition at line 1632 of file readwrite.c.

1637{
1638 return IntWriteConsoleOutputCode(hConsoleOutput,
1639 CODE_ASCII,
1640 lpCharacter,
1641 nLength,
1642 dwWriteCoord,
1643 lpNumberOfCharsWritten);
1644}

◆ WriteConsoleOutputCharacterW()

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

Definition at line 1611 of file readwrite.c.

1616{
1617 return IntWriteConsoleOutputCode(hConsoleOutput,
1619 lpCharacter,
1620 nLength,
1621 dwWriteCoord,
1622 lpNumberOfCharsWritten);
1623}

◆ WriteConsoleOutputW()

BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleOutputW ( IN HANDLE  hConsoleOutput,
IN CONST CHAR_INFO lpBuffer,
IN COORD  dwBufferSize,
IN COORD  dwBufferCoord,
IN OUT PSMALL_RECT  lpWriteRegion 
)

Definition at line 1569 of file readwrite.c.

1574{
1575 return IntWriteConsoleOutput(hConsoleOutput,
1576 lpBuffer,
1577 dwBufferSize,
1578 dwBufferCoord,
1579 lpWriteRegion,
1580 TRUE);
1581}

Referenced by test_cp932().

◆ WriteConsoleW()

BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleW ( IN HANDLE  hConsoleOutput,
IN CONST VOID lpBuffer,
IN DWORD  nNumberOfCharsToWrite,
OUT LPDWORD  lpNumberOfCharsWritten,
LPVOID  lpReserved 
)

Definition at line 1447 of file readwrite.c.

1452{
1453 return IntWriteConsole(hConsoleOutput,
1454 (PVOID)lpBuffer,
1455 nNumberOfCharsToWrite,
1456 lpNumberOfCharsWritten,
1457 lpReserved,
1458 TRUE);
1459}

Referenced by DisplayResourceText(), output_header(), output_string(), output_writeconsole(), print_string(), ReadString(), taskkill_vprintfW(), test_cp855(), test_cp932(), TUIDisplayStatusMessage(), and XCOPY_wprintf().