2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: dll/win32/kernel32/client/console/readwrite.c
5 * PURPOSE: Win32 Console Client read-write functions
6 * PROGRAMMERS: Emanuele Aliberti
8 * Filip Navara (xnavara@volny.cz)
9 * Thomas Weidenmueller (w3seek@reactos.org)
13 /* INCLUDES *******************************************************************/
21 /* PRIVATE FUNCTIONS **********************************************************/
29 IntReadConsole(HANDLE hConsoleInput
,
31 DWORD nNumberOfCharsToRead
,
32 LPDWORD lpNumberOfCharsRead
,
33 PCONSOLE_READCONSOLE_CONTROL pInputControl
,
37 CONSOLE_API_MESSAGE ApiMessage
;
38 PCONSOLE_READCONSOLE ReadConsoleRequest
= &ApiMessage
.Data
.ReadConsoleRequest
;
39 PCSR_CAPTURE_BUFFER CaptureBuffer
;
42 /* Determine the needed size */
43 CharSize
= (bUnicode
? sizeof(WCHAR
) : sizeof(CHAR
));
44 ReadConsoleRequest
->BufferSize
= nNumberOfCharsToRead
* CharSize
;
46 /* Allocate a Capture Buffer */
47 CaptureBuffer
= CsrAllocateCaptureBuffer(1, ReadConsoleRequest
->BufferSize
);
48 if (CaptureBuffer
== NULL
)
50 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
51 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
55 /* Allocate space in the Buffer */
56 CsrAllocateMessagePointer(CaptureBuffer
,
57 ReadConsoleRequest
->BufferSize
,
58 (PVOID
*)&ReadConsoleRequest
->Buffer
);
60 /* Set up the data to send to the Console Server */
61 ReadConsoleRequest
->InputHandle
= hConsoleInput
;
62 ReadConsoleRequest
->Unicode
= bUnicode
;
63 ReadConsoleRequest
->NrCharactersToRead
= nNumberOfCharsToRead
;
64 ReadConsoleRequest
->NrCharactersRead
= 0;
65 ReadConsoleRequest
->CtrlWakeupMask
= 0;
66 if (pInputControl
&& pInputControl
->nLength
== sizeof(CONSOLE_READCONSOLE_CONTROL
))
69 * From MSDN (ReadConsole function), the description
70 * for pInputControl says:
71 * "This parameter requires Unicode input by default.
72 * For ANSI mode, set this parameter to NULL."
74 ReadConsoleRequest
->NrCharactersRead
= pInputControl
->nInitialChars
;
75 memcpy(ReadConsoleRequest
->Buffer
,
77 pInputControl
->nInitialChars
* sizeof(WCHAR
));
78 ReadConsoleRequest
->CtrlWakeupMask
= pInputControl
->dwCtrlWakeupMask
;
82 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
84 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepReadConsole
),
85 sizeof(CONSOLE_READCONSOLE
));
87 /* Check for success */
88 if (NT_SUCCESS(Status
))
91 ReadConsoleRequest
->Buffer
,
92 ReadConsoleRequest
->NrCharactersRead
* CharSize
);
94 if (lpNumberOfCharsRead
!= NULL
)
95 *lpNumberOfCharsRead
= ReadConsoleRequest
->NrCharactersRead
;
97 if (pInputControl
&& pInputControl
->nLength
== sizeof(CONSOLE_READCONSOLE_CONTROL
))
98 pInputControl
->dwControlKeyState
= ReadConsoleRequest
->ControlKeyState
;
102 DPRINT1("CSR returned error in ReadConsole\n");
104 if (lpNumberOfCharsRead
!= NULL
)
105 *lpNumberOfCharsRead
= 0;
108 BaseSetLastNTError(Status
);
111 CsrFreeCaptureBuffer(CaptureBuffer
);
113 /* Return TRUE or FALSE */
115 return (ReadConsoleRequest
->NrCharactersRead
> 0);
116 // return NT_SUCCESS(Status);
122 IntGetConsoleInput(HANDLE hConsoleInput
,
123 PINPUT_RECORD lpBuffer
,
125 LPDWORD lpNumberOfEventsRead
,
130 CONSOLE_API_MESSAGE ApiMessage
;
131 PCONSOLE_GETINPUT GetInputRequest
= &ApiMessage
.Data
.GetInputRequest
;
132 PCSR_CAPTURE_BUFFER CaptureBuffer
;
135 if (lpBuffer
== NULL
)
137 SetLastError(ERROR_INVALID_PARAMETER
);
141 Size
= nLength
* sizeof(INPUT_RECORD
);
143 DPRINT("IntGetConsoleInput: %lx %p\n", Size
, lpNumberOfEventsRead
);
145 /* Allocate a Capture Buffer */
146 CaptureBuffer
= CsrAllocateCaptureBuffer(1, Size
);
147 if (CaptureBuffer
== NULL
)
149 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
150 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
154 /* Allocate space in the Buffer */
155 CsrAllocateMessagePointer(CaptureBuffer
,
157 (PVOID
*)&GetInputRequest
->InputRecord
);
159 /* Set up the data to send to the Console Server */
160 GetInputRequest
->InputHandle
= hConsoleInput
;
161 GetInputRequest
->InputsRead
= 0;
162 GetInputRequest
->Length
= nLength
;
163 GetInputRequest
->wFlags
= wFlags
;
164 GetInputRequest
->Unicode
= bUnicode
;
166 /* Call the server */
167 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
169 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetConsoleInput
),
170 sizeof(CONSOLE_GETINPUT
));
171 DPRINT("Server returned: %x\n", Status
);
173 /* Check for success */
174 if (NT_SUCCESS(Status
))
176 /* Return the number of events read */
177 DPRINT("Events read: %lx\n", GetInputRequest
->InputsRead
);
179 if (lpNumberOfEventsRead
!= NULL
)
180 *lpNumberOfEventsRead
= GetInputRequest
->InputsRead
;
182 /* Copy into the buffer */
183 DPRINT("Copying to buffer\n");
184 RtlCopyMemory(lpBuffer
,
185 GetInputRequest
->InputRecord
,
186 sizeof(INPUT_RECORD
) * GetInputRequest
->InputsRead
);
190 if (lpNumberOfEventsRead
!= NULL
)
191 *lpNumberOfEventsRead
= 0;
194 BaseSetLastNTError(Status
);
197 /* Release the capture buffer */
198 CsrFreeCaptureBuffer(CaptureBuffer
);
200 /* Return TRUE or FALSE */
201 return (GetInputRequest
->InputsRead
> 0);
202 // return NT_SUCCESS(Status);
208 IntReadConsoleOutput(HANDLE hConsoleOutput
,
212 PSMALL_RECT lpReadRegion
,
215 CONSOLE_API_MESSAGE ApiMessage
;
216 PCONSOLE_READOUTPUT ReadOutputRequest
= &ApiMessage
.Data
.ReadOutputRequest
;
217 PCSR_CAPTURE_BUFFER CaptureBuffer
;
218 DWORD Size
, SizeX
, SizeY
;
220 if (lpBuffer
== NULL
)
222 SetLastError(ERROR_INVALID_PARAMETER
);
226 Size
= dwBufferSize
.X
* dwBufferSize
.Y
* sizeof(CHAR_INFO
);
228 DPRINT("IntReadConsoleOutput: %lx %p\n", Size
, lpReadRegion
);
230 /* Allocate a Capture Buffer */
231 CaptureBuffer
= CsrAllocateCaptureBuffer(1, Size
);
232 if (CaptureBuffer
== NULL
)
234 DPRINT1("CsrAllocateCaptureBuffer failed with size 0x%x!\n", Size
);
235 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
239 /* Allocate space in the Buffer */
240 CsrAllocateMessagePointer(CaptureBuffer
,
242 (PVOID
*)&ReadOutputRequest
->CharInfo
);
244 /* Set up the data to send to the Console Server */
245 ReadOutputRequest
->OutputHandle
= hConsoleOutput
;
246 ReadOutputRequest
->Unicode
= bUnicode
;
247 ReadOutputRequest
->BufferSize
= dwBufferSize
;
248 ReadOutputRequest
->BufferCoord
= dwBufferCoord
;
249 ReadOutputRequest
->ReadRegion
= *lpReadRegion
;
251 /* Call the server */
252 CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
254 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepReadConsoleOutput
),
255 sizeof(CONSOLE_READOUTPUT
));
256 DPRINT("Server returned: %x\n", ApiMessage
.Status
);
258 /* Check for success */
259 if (NT_SUCCESS(ApiMessage
.Status
))
261 /* Copy into the buffer */
262 DPRINT("Copying to buffer\n");
263 SizeX
= ReadOutputRequest
->ReadRegion
.Right
-
264 ReadOutputRequest
->ReadRegion
.Left
+ 1;
265 SizeY
= ReadOutputRequest
->ReadRegion
.Bottom
-
266 ReadOutputRequest
->ReadRegion
.Top
+ 1;
267 RtlCopyMemory(lpBuffer
,
268 ReadOutputRequest
->CharInfo
,
269 sizeof(CHAR_INFO
) * SizeX
* SizeY
);
274 BaseSetLastNTError(ApiMessage
.Status
);
277 /* Return the read region */
278 DPRINT("read region: %p\n", ReadOutputRequest
->ReadRegion
);
279 *lpReadRegion
= ReadOutputRequest
->ReadRegion
;
281 /* Release the capture buffer */
282 CsrFreeCaptureBuffer(CaptureBuffer
);
284 /* Return TRUE or FALSE */
285 return NT_SUCCESS(ApiMessage
.Status
);
291 IntReadConsoleOutputCode(HANDLE hConsoleOutput
,
296 LPDWORD lpNumberOfCodesRead
)
300 CONSOLE_API_MESSAGE ApiMessage
;
301 PCONSOLE_READOUTPUTCODE ReadOutputCodeRequest
= &ApiMessage
.Data
.ReadOutputCodeRequest
;
302 PCSR_CAPTURE_BUFFER CaptureBuffer
;
303 ULONG SizeBytes
, CodeSize
;
306 /* Determine the needed size */
310 CodeSize
= sizeof(CHAR
);
314 CodeSize
= sizeof(WCHAR
);
318 CodeSize
= sizeof(WORD
);
322 SetLastError(ERROR_INVALID_PARAMETER
);
325 SizeBytes
= nLength
* CodeSize
;
327 /* Allocate a Capture Buffer */
328 CaptureBuffer
= CsrAllocateCaptureBuffer(1, SizeBytes
);
329 if (CaptureBuffer
== NULL
)
331 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
332 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
336 /* Allocate space in the Buffer */
337 CsrAllocateMessagePointer(CaptureBuffer
,
339 (PVOID
*)&ReadOutputCodeRequest
->pCode
.pCode
);
342 ReadOutputCodeRequest
->OutputHandle
= hConsoleOutput
;
343 ReadOutputCodeRequest
->CodeType
= CodeType
;
344 ReadOutputCodeRequest
->ReadCoord
= dwReadCoord
;
346 ReadOutputCodeRequest
->NumCodesToRead
= nLength
;
348 /* Call the server */
349 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
351 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepReadConsoleOutputString
),
352 sizeof(CONSOLE_READOUTPUTCODE
));
354 /* Check for success */
355 if (NT_SUCCESS(Status
))
357 CodesRead
= ReadOutputCodeRequest
->CodesRead
;
358 memcpy(pCode
, ReadOutputCodeRequest
->pCode
.pCode
, CodesRead
* CodeSize
);
360 // ReadOutputCodeRequest->ReadCoord = ReadOutputCodeRequest->EndCoord;
362 if (lpNumberOfCodesRead
!= NULL
)
363 *lpNumberOfCodesRead
= CodesRead
;
369 if (lpNumberOfCodesRead
!= NULL
)
370 *lpNumberOfCodesRead
= 0;
373 BaseSetLastNTError(Status
);
377 CsrFreeCaptureBuffer(CaptureBuffer
);
389 IntWriteConsole(HANDLE hConsoleOutput
,
391 DWORD nNumberOfCharsToWrite
,
392 LPDWORD lpNumberOfCharsWritten
,
398 CONSOLE_API_MESSAGE ApiMessage
;
399 PCONSOLE_WRITECONSOLE WriteConsoleRequest
= &ApiMessage
.Data
.WriteConsoleRequest
;
400 PCSR_CAPTURE_BUFFER CaptureBuffer
;
403 /* Determine the needed size */
404 CharSize
= (bUnicode
? sizeof(WCHAR
) : sizeof(CHAR
));
405 WriteConsoleRequest
->BufferSize
= nNumberOfCharsToWrite
* CharSize
;
407 /* Allocate a Capture Buffer */
408 CaptureBuffer
= CsrAllocateCaptureBuffer(1, WriteConsoleRequest
->BufferSize
);
409 if (CaptureBuffer
== NULL
)
411 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
412 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
416 /* Capture the buffer to write */
417 CsrCaptureMessageBuffer(CaptureBuffer
,
419 WriteConsoleRequest
->BufferSize
,
420 (PVOID
*)&WriteConsoleRequest
->Buffer
);
423 WriteConsoleRequest
->NrCharactersToWrite
= nNumberOfCharsToWrite
;
424 WriteConsoleRequest
->OutputHandle
= hConsoleOutput
;
425 WriteConsoleRequest
->Unicode
= bUnicode
;
427 /* Call the server */
428 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
430 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepWriteConsole
),
431 sizeof(CONSOLE_WRITECONSOLE
));
433 /* Check for success */
434 if (NT_SUCCESS(Status
))
436 if (lpNumberOfCharsWritten
!= NULL
)
437 *lpNumberOfCharsWritten
= WriteConsoleRequest
->NrCharactersWritten
;
443 if (lpNumberOfCharsWritten
!= NULL
)
444 *lpNumberOfCharsWritten
= 0;
447 BaseSetLastNTError(Status
);
451 CsrFreeCaptureBuffer(CaptureBuffer
);
459 IntWriteConsoleInput(HANDLE hConsoleInput
,
460 PINPUT_RECORD lpBuffer
,
462 LPDWORD lpNumberOfEventsWritten
,
466 CONSOLE_API_MESSAGE ApiMessage
;
467 PCONSOLE_WRITEINPUT WriteInputRequest
= &ApiMessage
.Data
.WriteInputRequest
;
468 PCSR_CAPTURE_BUFFER CaptureBuffer
;
471 Size
= nLength
* sizeof(INPUT_RECORD
);
473 DPRINT("IntWriteConsoleInput: %lx %p\n", Size
, lpNumberOfEventsWritten
);
475 /* Allocate a Capture Buffer */
476 CaptureBuffer
= CsrAllocateCaptureBuffer(1, Size
);
477 if (CaptureBuffer
== NULL
)
479 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
480 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
484 /* Capture the user buffer */
485 CsrCaptureMessageBuffer(CaptureBuffer
,
488 (PVOID
*)&WriteInputRequest
->InputRecord
);
490 /* Set up the data to send to the Console Server */
491 WriteInputRequest
->InputHandle
= hConsoleInput
;
492 WriteInputRequest
->Length
= nLength
;
493 WriteInputRequest
->Unicode
= bUnicode
;
494 WriteInputRequest
->AppendToEnd
= bAppendToEnd
;
496 /* Call the server */
497 CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
499 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepWriteConsoleInput
),
500 sizeof(CONSOLE_WRITEINPUT
));
501 DPRINT("Server returned: %x\n", ApiMessage
.Status
);
503 /* Check for success */
504 if (NT_SUCCESS(ApiMessage
.Status
))
506 /* Return the number of events read */
507 DPRINT("Events read: %lx\n", WriteInputRequest
->Length
);
509 if (lpNumberOfEventsWritten
!= NULL
)
510 *lpNumberOfEventsWritten
= WriteInputRequest
->Length
;
514 if (lpNumberOfEventsWritten
!= NULL
)
515 *lpNumberOfEventsWritten
= 0;
518 BaseSetLastNTError(ApiMessage
.Status
);
521 /* Release the capture buffer */
522 CsrFreeCaptureBuffer(CaptureBuffer
);
524 /* Return TRUE or FALSE */
525 return NT_SUCCESS(ApiMessage
.Status
);
531 IntWriteConsoleOutput(HANDLE hConsoleOutput
,
532 CONST CHAR_INFO
*lpBuffer
,
535 PSMALL_RECT lpWriteRegion
,
538 CONSOLE_API_MESSAGE ApiMessage
;
539 PCONSOLE_WRITEOUTPUT WriteOutputRequest
= &ApiMessage
.Data
.WriteOutputRequest
;
540 PCSR_CAPTURE_BUFFER CaptureBuffer
;
543 if ((lpBuffer
== NULL
) || (lpWriteRegion
== NULL
))
545 SetLastError(ERROR_INVALID_PARAMETER
);
549 if (lpWriteRegion == NULL)
551 SetLastError(ERROR_INVALID_PARAMETER);
556 Size
= dwBufferSize
.Y
* dwBufferSize
.X
* sizeof(CHAR_INFO
);
558 DPRINT("IntWriteConsoleOutput: %lx %p\n", Size
, lpWriteRegion
);
560 /* Allocate a Capture Buffer */
561 CaptureBuffer
= CsrAllocateCaptureBuffer(1, Size
);
562 if (CaptureBuffer
== NULL
)
564 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
565 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
569 /* Capture the user buffer */
570 CsrCaptureMessageBuffer(CaptureBuffer
,
573 (PVOID
*)&WriteOutputRequest
->CharInfo
);
575 /* Set up the data to send to the Console Server */
576 WriteOutputRequest
->OutputHandle
= hConsoleOutput
;
577 WriteOutputRequest
->Unicode
= bUnicode
;
578 WriteOutputRequest
->BufferSize
= dwBufferSize
;
579 WriteOutputRequest
->BufferCoord
= dwBufferCoord
;
580 WriteOutputRequest
->WriteRegion
= *lpWriteRegion
;
582 /* Call the server */
583 CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
585 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepWriteConsoleOutput
),
586 sizeof(CONSOLE_WRITEOUTPUT
));
587 DPRINT("Server returned: %x\n", ApiMessage
.Status
);
589 /* Check for success */
590 if (!NT_SUCCESS(ApiMessage
.Status
))
593 BaseSetLastNTError(ApiMessage
.Status
);
596 /* Return the read region */
597 DPRINT("read region: %p\n", WriteOutputRequest
->WriteRegion
);
598 *lpWriteRegion
= WriteOutputRequest
->WriteRegion
;
600 /* Release the capture buffer */
601 CsrFreeCaptureBuffer(CaptureBuffer
);
603 /* Return TRUE or FALSE */
604 return NT_SUCCESS(ApiMessage
.Status
);
610 IntWriteConsoleOutputCode(HANDLE hConsoleOutput
,
615 LPDWORD lpNumberOfCodesWritten
)
619 CONSOLE_API_MESSAGE ApiMessage
;
620 PCONSOLE_WRITEOUTPUTCODE WriteOutputCodeRequest
= &ApiMessage
.Data
.WriteOutputCodeRequest
;
621 PCSR_CAPTURE_BUFFER CaptureBuffer
;
624 /* Determine the needed size */
628 CodeSize
= sizeof(CHAR
);
632 CodeSize
= sizeof(WCHAR
);
636 CodeSize
= sizeof(WORD
);
640 SetLastError(ERROR_INVALID_PARAMETER
);
643 WriteOutputCodeRequest
->BufferSize
= nLength
* CodeSize
;
645 /* Allocate a Capture Buffer */
646 CaptureBuffer
= CsrAllocateCaptureBuffer(1, WriteOutputCodeRequest
->BufferSize
);
647 if (CaptureBuffer
== NULL
)
649 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
650 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
654 /* Capture the buffer to write */
655 CsrCaptureMessageBuffer(CaptureBuffer
,
657 WriteOutputCodeRequest
->BufferSize
,
658 (PVOID
*)&WriteOutputCodeRequest
->pCode
.pCode
);
661 WriteOutputCodeRequest
->OutputHandle
= hConsoleOutput
;
662 WriteOutputCodeRequest
->CodeType
= CodeType
;
663 WriteOutputCodeRequest
->Coord
= dwWriteCoord
;
665 WriteOutputCodeRequest
->Length
= (USHORT
)nLength
;
667 /* Call the server */
668 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
670 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepWriteConsoleOutputString
),
671 sizeof(CONSOLE_WRITEOUTPUTCODE
));
673 /* Check for success */
674 if (NT_SUCCESS(Status
))
676 // WriteOutputCodeRequest->Coord = WriteOutputCodeRequest->EndCoord;
678 if (lpNumberOfCodesWritten
!= NULL
)
679 // *lpNumberOfCodesWritten = WriteOutputCodeRequest->NrCharactersWritten;
680 *lpNumberOfCodesWritten
= WriteOutputCodeRequest
->Length
;
686 if (lpNumberOfCodesWritten
!= NULL
)
687 *lpNumberOfCodesWritten
= 0;
690 BaseSetLastNTError(Status
);
694 CsrFreeCaptureBuffer(CaptureBuffer
);
702 IntFillConsoleOutputCode(HANDLE hConsoleOutput
,
707 LPDWORD lpNumberOfCodesWritten
)
710 CONSOLE_API_MESSAGE ApiMessage
;
711 PCONSOLE_FILLOUTPUTCODE FillOutputRequest
= &ApiMessage
.Data
.FillOutputRequest
;
713 FillOutputRequest
->OutputHandle
= hConsoleOutput
;
714 FillOutputRequest
->CodeType
= CodeType
;
719 FillOutputRequest
->Code
.AsciiChar
= *(PCHAR
)pCode
;
723 FillOutputRequest
->Code
.UnicodeChar
= *(PWCHAR
)pCode
;
727 FillOutputRequest
->Code
.Attribute
= *(PWORD
)pCode
;
731 SetLastError(ERROR_INVALID_PARAMETER
);
735 /* Set up the data to send to the Console Server */
736 FillOutputRequest
->Coord
= dwWriteCoord
;
737 FillOutputRequest
->Length
= nLength
;
739 /* Call the server */
740 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
742 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepFillConsoleOutput
),
743 sizeof(CONSOLE_FILLOUTPUTCODE
));
745 /* Check for success */
746 if (NT_SUCCESS(Status
))
748 if (lpNumberOfCodesWritten
!= NULL
)
749 *lpNumberOfCodesWritten
= FillOutputRequest
->Length
;
750 // *lpNumberOfCodesWritten = Request.Data.FillOutputRequest.NrCharactersWritten;
756 if (lpNumberOfCodesWritten
!= NULL
)
757 *lpNumberOfCodesWritten
= 0;
759 BaseSetLastNTError(Status
);
765 /* FUNCTIONS ******************************************************************/
771 /*--------------------------------------------------------------
778 ReadConsoleW(HANDLE hConsoleInput
,
780 DWORD nNumberOfCharsToRead
,
781 LPDWORD lpNumberOfCharsRead
,
782 PCONSOLE_READCONSOLE_CONTROL pInputControl
)
784 return IntReadConsole(hConsoleInput
,
786 nNumberOfCharsToRead
,
793 /*--------------------------------------------------------------
800 ReadConsoleA(HANDLE hConsoleInput
,
802 DWORD nNumberOfCharsToRead
,
803 LPDWORD lpNumberOfCharsRead
,
804 PCONSOLE_READCONSOLE_CONTROL pInputControl
)
806 return IntReadConsole(hConsoleInput
,
808 nNumberOfCharsToRead
,
815 /*--------------------------------------------------------------
822 PeekConsoleInputW(HANDLE hConsoleInput
,
823 PINPUT_RECORD lpBuffer
,
825 LPDWORD lpNumberOfEventsRead
)
827 return IntGetConsoleInput(hConsoleInput
,
830 lpNumberOfEventsRead
,
831 CONSOLE_READ_KEEPEVENT
| CONSOLE_READ_CONTINUE
,
836 /*--------------------------------------------------------------
843 PeekConsoleInputA(HANDLE hConsoleInput
,
844 PINPUT_RECORD lpBuffer
,
846 LPDWORD lpNumberOfEventsRead
)
848 return IntGetConsoleInput(hConsoleInput
,
851 lpNumberOfEventsRead
,
852 CONSOLE_READ_KEEPEVENT
| CONSOLE_READ_CONTINUE
,
857 /*--------------------------------------------------------------
864 ReadConsoleInputW(HANDLE hConsoleInput
,
865 PINPUT_RECORD lpBuffer
,
867 LPDWORD lpNumberOfEventsRead
)
869 return IntGetConsoleInput(hConsoleInput
,
872 lpNumberOfEventsRead
,
878 /*--------------------------------------------------------------
885 ReadConsoleInputA(HANDLE hConsoleInput
,
886 PINPUT_RECORD lpBuffer
,
888 LPDWORD lpNumberOfEventsRead
)
890 return IntGetConsoleInput(hConsoleInput
,
893 lpNumberOfEventsRead
,
899 /*--------------------------------------------------------------
900 * ReadConsoleInputExW
906 ReadConsoleInputExW(HANDLE hConsoleInput
,
907 PINPUT_RECORD lpBuffer
,
909 LPDWORD lpNumberOfEventsRead
,
912 return IntGetConsoleInput(hConsoleInput
,
915 lpNumberOfEventsRead
,
921 /*--------------------------------------------------------------
922 * ReadConsoleInputExA
928 ReadConsoleInputExA(HANDLE hConsoleInput
,
929 PINPUT_RECORD lpBuffer
,
931 LPDWORD lpNumberOfEventsRead
,
934 return IntGetConsoleInput(hConsoleInput
,
937 lpNumberOfEventsRead
,
943 /*--------------------------------------------------------------
950 ReadConsoleOutputW(HANDLE hConsoleOutput
,
954 PSMALL_RECT lpReadRegion
)
956 return IntReadConsoleOutput(hConsoleOutput
,
965 /*--------------------------------------------------------------
972 ReadConsoleOutputA(HANDLE hConsoleOutput
,
976 PSMALL_RECT lpReadRegion
)
978 return IntReadConsoleOutput(hConsoleOutput
,
987 /*--------------------------------------------------------------
988 * ReadConsoleOutputCharacterW
994 ReadConsoleOutputCharacterW(HANDLE hConsoleOutput
,
998 LPDWORD lpNumberOfCharsRead
)
1000 return IntReadConsoleOutputCode(hConsoleOutput
,
1005 lpNumberOfCharsRead
);
1009 /*--------------------------------------------------------------
1010 * ReadConsoleOutputCharacterA
1016 ReadConsoleOutputCharacterA(HANDLE hConsoleOutput
,
1020 LPDWORD lpNumberOfCharsRead
)
1022 return IntReadConsoleOutputCode(hConsoleOutput
,
1027 lpNumberOfCharsRead
);
1031 /*--------------------------------------------------------------
1032 * ReadConsoleOutputAttribute
1038 ReadConsoleOutputAttribute(HANDLE hConsoleOutput
,
1042 LPDWORD lpNumberOfAttrsRead
)
1044 return IntReadConsoleOutputCode(hConsoleOutput
,
1049 lpNumberOfAttrsRead
);
1053 /*******************
1055 *******************/
1057 /*--------------------------------------------------------------
1064 WriteConsoleW(HANDLE hConsoleOutput
,
1065 CONST VOID
*lpBuffer
,
1066 DWORD nNumberOfCharsToWrite
,
1067 LPDWORD lpNumberOfCharsWritten
,
1070 return IntWriteConsole(hConsoleOutput
,
1072 nNumberOfCharsToWrite
,
1073 lpNumberOfCharsWritten
,
1079 /*--------------------------------------------------------------
1086 WriteConsoleA(HANDLE hConsoleOutput
,
1087 CONST VOID
*lpBuffer
,
1088 DWORD nNumberOfCharsToWrite
,
1089 LPDWORD lpNumberOfCharsWritten
,
1092 return IntWriteConsole(hConsoleOutput
,
1094 nNumberOfCharsToWrite
,
1095 lpNumberOfCharsWritten
,
1101 /*--------------------------------------------------------------
1102 * WriteConsoleInputW
1108 WriteConsoleInputW(HANDLE hConsoleInput
,
1109 CONST INPUT_RECORD
*lpBuffer
,
1111 LPDWORD lpNumberOfEventsWritten
)
1113 return IntWriteConsoleInput(hConsoleInput
,
1114 (PINPUT_RECORD
)lpBuffer
,
1116 lpNumberOfEventsWritten
,
1122 /*--------------------------------------------------------------
1123 * WriteConsoleInputA
1129 WriteConsoleInputA(HANDLE hConsoleInput
,
1130 CONST INPUT_RECORD
*lpBuffer
,
1132 LPDWORD lpNumberOfEventsWritten
)
1134 return IntWriteConsoleInput(hConsoleInput
,
1135 (PINPUT_RECORD
)lpBuffer
,
1137 lpNumberOfEventsWritten
,
1143 /*--------------------------------------------------------------
1144 * WriteConsoleInputVDMW
1150 WriteConsoleInputVDMW(HANDLE hConsoleInput
,
1151 CONST INPUT_RECORD
*lpBuffer
,
1153 LPDWORD lpNumberOfEventsWritten
)
1155 return IntWriteConsoleInput(hConsoleInput
,
1156 (PINPUT_RECORD
)lpBuffer
,
1158 lpNumberOfEventsWritten
,
1164 /*--------------------------------------------------------------
1165 * WriteConsoleInputVDMA
1171 WriteConsoleInputVDMA(HANDLE hConsoleInput
,
1172 CONST INPUT_RECORD
*lpBuffer
,
1174 LPDWORD lpNumberOfEventsWritten
)
1176 return IntWriteConsoleInput(hConsoleInput
,
1177 (PINPUT_RECORD
)lpBuffer
,
1179 lpNumberOfEventsWritten
,
1185 /*--------------------------------------------------------------
1186 * WriteConsoleOutputW
1192 WriteConsoleOutputW(HANDLE hConsoleOutput
,
1193 CONST CHAR_INFO
*lpBuffer
,
1195 COORD dwBufferCoord
,
1196 PSMALL_RECT lpWriteRegion
)
1198 return IntWriteConsoleOutput(hConsoleOutput
,
1207 /*--------------------------------------------------------------
1208 * WriteConsoleOutputA
1214 WriteConsoleOutputA(HANDLE hConsoleOutput
,
1215 CONST CHAR_INFO
*lpBuffer
,
1217 COORD dwBufferCoord
,
1218 PSMALL_RECT lpWriteRegion
)
1220 return IntWriteConsoleOutput(hConsoleOutput
,
1229 /*--------------------------------------------------------------
1230 * WriteConsoleOutputCharacterW
1236 WriteConsoleOutputCharacterW(HANDLE hConsoleOutput
,
1237 LPCWSTR lpCharacter
,
1240 LPDWORD lpNumberOfCharsWritten
)
1242 return IntWriteConsoleOutputCode(hConsoleOutput
,
1247 lpNumberOfCharsWritten
);
1251 /*--------------------------------------------------------------
1252 * WriteConsoleOutputCharacterA
1258 WriteConsoleOutputCharacterA(HANDLE hConsoleOutput
,
1262 LPDWORD lpNumberOfCharsWritten
)
1264 return IntWriteConsoleOutputCode(hConsoleOutput
,
1269 lpNumberOfCharsWritten
);
1273 /*--------------------------------------------------------------
1274 * WriteConsoleOutputAttribute
1280 WriteConsoleOutputAttribute(HANDLE hConsoleOutput
,
1281 CONST WORD
*lpAttribute
,
1284 LPDWORD lpNumberOfAttrsWritten
)
1286 return IntWriteConsoleOutputCode(hConsoleOutput
,
1291 lpNumberOfAttrsWritten
);
1295 /*--------------------------------------------------------------
1296 * FillConsoleOutputCharacterW
1302 FillConsoleOutputCharacterW(HANDLE hConsoleOutput
,
1306 LPDWORD lpNumberOfCharsWritten
)
1308 return IntFillConsoleOutputCode(hConsoleOutput
,
1313 lpNumberOfCharsWritten
);
1317 /*--------------------------------------------------------------
1318 * FillConsoleOutputCharacterA
1324 FillConsoleOutputCharacterA(HANDLE hConsoleOutput
,
1328 LPDWORD lpNumberOfCharsWritten
)
1330 return IntFillConsoleOutputCode(hConsoleOutput
,
1335 lpNumberOfCharsWritten
);
1339 /*--------------------------------------------------------------
1340 * FillConsoleOutputAttribute
1346 FillConsoleOutputAttribute(HANDLE hConsoleOutput
,
1350 LPDWORD lpNumberOfAttrsWritten
)
1352 return IntFillConsoleOutputCode(hConsoleOutput
,
1357 lpNumberOfAttrsWritten
);