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
= (WORD
)nNumberOfCharsToRead
;
64 ReadConsoleRequest
->NrCharactersRead
= 0;
65 ReadConsoleRequest
->CtrlWakeupMask
= 0;
66 if (pInputControl
&& pInputControl
->nLength
== sizeof(CONSOLE_READCONSOLE_CONTROL
))
68 ReadConsoleRequest
->NrCharactersRead
= pInputControl
->nInitialChars
;
69 memcpy(ReadConsoleRequest
->Buffer
,
71 pInputControl
->nInitialChars
* sizeof(WCHAR
));
72 ReadConsoleRequest
->CtrlWakeupMask
= pInputControl
->dwCtrlWakeupMask
;
76 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
78 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepReadConsole
),
79 sizeof(CONSOLE_READCONSOLE
));
81 /* Check for success */
82 if (NT_SUCCESS(Status
))
85 ReadConsoleRequest
->Buffer
,
86 ReadConsoleRequest
->NrCharactersRead
* CharSize
);
88 if (lpNumberOfCharsRead
!= NULL
)
89 *lpNumberOfCharsRead
= ReadConsoleRequest
->NrCharactersRead
;
91 if (pInputControl
&& pInputControl
->nLength
== sizeof(CONSOLE_READCONSOLE_CONTROL
))
92 pInputControl
->dwControlKeyState
= ReadConsoleRequest
->ControlKeyState
;
96 DPRINT1("CSR returned error in ReadConsole\n");
98 if (lpNumberOfCharsRead
!= NULL
)
99 *lpNumberOfCharsRead
= 0;
102 BaseSetLastNTError(Status
);
105 CsrFreeCaptureBuffer(CaptureBuffer
);
107 /* Return TRUE or FALSE */
109 return (ReadConsoleRequest
->NrCharactersRead
> 0);
110 // return NT_SUCCESS(Status);
116 IntGetConsoleInput(HANDLE hConsoleInput
,
118 PINPUT_RECORD lpBuffer
,
120 LPDWORD lpNumberOfEventsRead
,
124 CONSOLE_API_MESSAGE ApiMessage
;
125 PCONSOLE_GETINPUT GetInputRequest
= &ApiMessage
.Data
.GetInputRequest
;
126 PCSR_CAPTURE_BUFFER CaptureBuffer
;
129 if (lpBuffer
== NULL
)
131 SetLastError(ERROR_INVALID_PARAMETER
);
135 Size
= nLength
* sizeof(INPUT_RECORD
);
137 DPRINT("IntGetConsoleInput: %lx %p\n", Size
, lpNumberOfEventsRead
);
139 /* Allocate a Capture Buffer */
140 CaptureBuffer
= CsrAllocateCaptureBuffer(1, Size
);
141 if (CaptureBuffer
== NULL
)
143 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
144 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
148 /* Allocate space in the Buffer */
149 CsrAllocateMessagePointer(CaptureBuffer
,
151 (PVOID
*)&GetInputRequest
->InputRecord
);
153 /* Set up the data to send to the Console Server */
154 GetInputRequest
->InputHandle
= hConsoleInput
;
155 GetInputRequest
->Unicode
= bUnicode
;
156 GetInputRequest
->bRead
= bRead
;
157 GetInputRequest
->InputsRead
= 0;
158 GetInputRequest
->Length
= nLength
;
160 /* Call the server */
161 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
163 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetConsoleInput
),
164 sizeof(CONSOLE_GETINPUT
));
165 DPRINT("Server returned: %x\n", Status
);
167 /* Check for success */
168 if (NT_SUCCESS(Status
))
170 /* Return the number of events read */
171 DPRINT("Events read: %lx\n", GetInputRequest
->InputsRead
);
173 if (lpNumberOfEventsRead
!= NULL
)
174 *lpNumberOfEventsRead
= GetInputRequest
->InputsRead
;
176 /* Copy into the buffer */
177 DPRINT("Copying to buffer\n");
178 RtlCopyMemory(lpBuffer
,
179 GetInputRequest
->InputRecord
,
180 sizeof(INPUT_RECORD
) * GetInputRequest
->InputsRead
);
184 if (lpNumberOfEventsRead
!= NULL
)
185 *lpNumberOfEventsRead
= 0;
188 BaseSetLastNTError(Status
);
191 /* Release the capture buffer */
192 CsrFreeCaptureBuffer(CaptureBuffer
);
194 /* Return TRUE or FALSE */
195 return (GetInputRequest
->InputsRead
> 0);
196 // return NT_SUCCESS(Status);
202 IntReadConsoleOutput(HANDLE hConsoleOutput
,
206 PSMALL_RECT lpReadRegion
,
209 CONSOLE_API_MESSAGE ApiMessage
;
210 PCONSOLE_READOUTPUT ReadOutputRequest
= &ApiMessage
.Data
.ReadOutputRequest
;
211 PCSR_CAPTURE_BUFFER CaptureBuffer
;
212 DWORD Size
, SizeX
, SizeY
;
214 if (lpBuffer
== NULL
)
216 SetLastError(ERROR_INVALID_PARAMETER
);
220 Size
= dwBufferSize
.X
* dwBufferSize
.Y
* sizeof(CHAR_INFO
);
222 DPRINT("IntReadConsoleOutput: %lx %p\n", Size
, lpReadRegion
);
224 /* Allocate a Capture Buffer */
225 CaptureBuffer
= CsrAllocateCaptureBuffer(1, Size
);
226 if (CaptureBuffer
== NULL
)
228 DPRINT1("CsrAllocateCaptureBuffer failed with size 0x%x!\n", Size
);
229 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
233 /* Allocate space in the Buffer */
234 CsrAllocateMessagePointer(CaptureBuffer
,
236 (PVOID
*)&ReadOutputRequest
->CharInfo
);
238 /* Set up the data to send to the Console Server */
239 ReadOutputRequest
->OutputHandle
= hConsoleOutput
;
240 ReadOutputRequest
->Unicode
= bUnicode
;
241 ReadOutputRequest
->BufferSize
= dwBufferSize
;
242 ReadOutputRequest
->BufferCoord
= dwBufferCoord
;
243 ReadOutputRequest
->ReadRegion
= *lpReadRegion
;
245 /* Call the server */
246 CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
248 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepReadConsoleOutput
),
249 sizeof(CONSOLE_READOUTPUT
));
250 DPRINT("Server returned: %x\n", ApiMessage
.Status
);
252 /* Check for success */
253 if (NT_SUCCESS(ApiMessage
.Status
))
255 /* Copy into the buffer */
256 DPRINT("Copying to buffer\n");
257 SizeX
= ReadOutputRequest
->ReadRegion
.Right
-
258 ReadOutputRequest
->ReadRegion
.Left
+ 1;
259 SizeY
= ReadOutputRequest
->ReadRegion
.Bottom
-
260 ReadOutputRequest
->ReadRegion
.Top
+ 1;
261 RtlCopyMemory(lpBuffer
,
262 ReadOutputRequest
->CharInfo
,
263 sizeof(CHAR_INFO
) * SizeX
* SizeY
);
268 BaseSetLastNTError(ApiMessage
.Status
);
271 /* Return the read region */
272 DPRINT("read region: %lx\n", ReadOutputRequest
->ReadRegion
);
273 *lpReadRegion
= ReadOutputRequest
->ReadRegion
;
275 /* Release the capture buffer */
276 CsrFreeCaptureBuffer(CaptureBuffer
);
278 /* Return TRUE or FALSE */
279 return NT_SUCCESS(ApiMessage
.Status
);
285 IntReadConsoleOutputCode(HANDLE hConsoleOutput
,
290 LPDWORD lpNumberOfCodesRead
)
294 CONSOLE_API_MESSAGE ApiMessage
;
295 PCONSOLE_READOUTPUTCODE ReadOutputCodeRequest
= &ApiMessage
.Data
.ReadOutputCodeRequest
;
296 PCSR_CAPTURE_BUFFER CaptureBuffer
;
297 ULONG SizeBytes
, CodeSize
;
300 /* Determine the needed size */
304 CodeSize
= sizeof(CHAR
);
308 CodeSize
= sizeof(WCHAR
);
312 CodeSize
= sizeof(WORD
);
316 SetLastError(ERROR_INVALID_PARAMETER
);
319 SizeBytes
= nLength
* CodeSize
;
321 /* Allocate a Capture Buffer */
322 CaptureBuffer
= CsrAllocateCaptureBuffer(1, SizeBytes
);
323 if (CaptureBuffer
== NULL
)
325 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
326 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
330 /* Allocate space in the Buffer */
331 CsrAllocateMessagePointer(CaptureBuffer
,
333 (PVOID
*)&ReadOutputCodeRequest
->pCode
.pCode
);
336 ReadOutputCodeRequest
->OutputHandle
= hConsoleOutput
;
337 ReadOutputCodeRequest
->CodeType
= CodeType
;
338 ReadOutputCodeRequest
->ReadCoord
= dwReadCoord
;
340 ReadOutputCodeRequest
->NumCodesToRead
= nLength
;
342 /* Call the server */
343 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
345 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepReadConsoleOutputString
),
346 sizeof(CONSOLE_READOUTPUTCODE
));
348 /* Check for success */
349 if (NT_SUCCESS(Status
))
351 CodesRead
= ReadOutputCodeRequest
->CodesRead
;
352 memcpy(pCode
, ReadOutputCodeRequest
->pCode
.pCode
, CodesRead
* CodeSize
);
354 // ReadOutputCodeRequest->ReadCoord = ReadOutputCodeRequest->EndCoord;
356 if (lpNumberOfCodesRead
!= NULL
)
357 *lpNumberOfCodesRead
= CodesRead
;
363 if (lpNumberOfCodesRead
!= NULL
)
364 *lpNumberOfCodesRead
= 0;
367 BaseSetLastNTError(Status
);
371 CsrFreeCaptureBuffer(CaptureBuffer
);
383 IntWriteConsole(HANDLE hConsoleOutput
,
385 DWORD nNumberOfCharsToWrite
,
386 LPDWORD lpNumberOfCharsWritten
,
392 CONSOLE_API_MESSAGE ApiMessage
;
393 PCONSOLE_WRITECONSOLE WriteConsoleRequest
= &ApiMessage
.Data
.WriteConsoleRequest
;
394 PCSR_CAPTURE_BUFFER CaptureBuffer
;
397 /* Determine the needed size */
398 CharSize
= (bUnicode
? sizeof(WCHAR
) : sizeof(CHAR
));
399 WriteConsoleRequest
->BufferSize
= nNumberOfCharsToWrite
* CharSize
;
401 /* Allocate a Capture Buffer */
402 CaptureBuffer
= CsrAllocateCaptureBuffer(1, WriteConsoleRequest
->BufferSize
);
403 if (CaptureBuffer
== NULL
)
405 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
406 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
410 /* Capture the buffer to write */
411 CsrCaptureMessageBuffer(CaptureBuffer
,
413 WriteConsoleRequest
->BufferSize
,
414 (PVOID
*)&WriteConsoleRequest
->Buffer
);
417 WriteConsoleRequest
->NrCharactersToWrite
= nNumberOfCharsToWrite
;
418 WriteConsoleRequest
->OutputHandle
= hConsoleOutput
;
419 WriteConsoleRequest
->Unicode
= bUnicode
;
421 /* Call the server */
422 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
424 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepWriteConsole
),
425 sizeof(CONSOLE_WRITECONSOLE
));
427 /* Check for success */
428 if (NT_SUCCESS(Status
))
430 if (lpNumberOfCharsWritten
!= NULL
)
431 *lpNumberOfCharsWritten
= WriteConsoleRequest
->NrCharactersWritten
;
437 if (lpNumberOfCharsWritten
!= NULL
)
438 *lpNumberOfCharsWritten
= 0;
441 BaseSetLastNTError(Status
);
445 CsrFreeCaptureBuffer(CaptureBuffer
);
453 IntWriteConsoleInput(HANDLE hConsoleInput
,
454 PINPUT_RECORD lpBuffer
,
456 LPDWORD lpNumberOfEventsWritten
,
459 CONSOLE_API_MESSAGE ApiMessage
;
460 PCONSOLE_WRITEINPUT WriteInputRequest
= &ApiMessage
.Data
.WriteInputRequest
;
461 PCSR_CAPTURE_BUFFER CaptureBuffer
;
464 Size
= nLength
* sizeof(INPUT_RECORD
);
466 DPRINT("IntWriteConsoleInput: %lx %p\n", Size
, lpNumberOfEventsWritten
);
468 /* Allocate a Capture Buffer */
469 CaptureBuffer
= CsrAllocateCaptureBuffer(1, Size
);
470 if (CaptureBuffer
== NULL
)
472 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
473 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
477 /* Capture the user buffer */
478 CsrCaptureMessageBuffer(CaptureBuffer
,
481 (PVOID
*)&WriteInputRequest
->InputRecord
);
483 /* Set up the data to send to the Console Server */
484 WriteInputRequest
->InputHandle
= hConsoleInput
;
485 WriteInputRequest
->Unicode
= bUnicode
;
486 WriteInputRequest
->Length
= nLength
;
488 /* Call the server */
489 CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
491 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepWriteConsoleInput
),
492 sizeof(CONSOLE_WRITEINPUT
));
493 DPRINT("Server returned: %x\n", ApiMessage
.Status
);
495 /* Check for success */
496 if (NT_SUCCESS(ApiMessage
.Status
))
498 /* Return the number of events read */
499 DPRINT("Events read: %lx\n", WriteInputRequest
->Length
);
501 if (lpNumberOfEventsWritten
!= NULL
)
502 *lpNumberOfEventsWritten
= WriteInputRequest
->Length
;
506 if (lpNumberOfEventsWritten
!= NULL
)
507 *lpNumberOfEventsWritten
= 0;
510 BaseSetLastNTError(ApiMessage
.Status
);
513 /* Release the capture buffer */
514 CsrFreeCaptureBuffer(CaptureBuffer
);
516 /* Return TRUE or FALSE */
517 return NT_SUCCESS(ApiMessage
.Status
);
523 IntWriteConsoleOutput(HANDLE hConsoleOutput
,
524 CONST CHAR_INFO
*lpBuffer
,
527 PSMALL_RECT lpWriteRegion
,
530 CONSOLE_API_MESSAGE ApiMessage
;
531 PCONSOLE_WRITEOUTPUT WriteOutputRequest
= &ApiMessage
.Data
.WriteOutputRequest
;
532 PCSR_CAPTURE_BUFFER CaptureBuffer
;
535 if ((lpBuffer
== NULL
) || (lpWriteRegion
== NULL
))
537 SetLastError(ERROR_INVALID_PARAMETER
);
541 if (lpWriteRegion == NULL)
543 SetLastError(ERROR_INVALID_PARAMETER);
548 Size
= dwBufferSize
.Y
* dwBufferSize
.X
* sizeof(CHAR_INFO
);
550 DPRINT("IntWriteConsoleOutput: %lx %p\n", Size
, lpWriteRegion
);
552 /* Allocate a Capture Buffer */
553 CaptureBuffer
= CsrAllocateCaptureBuffer(1, Size
);
554 if (CaptureBuffer
== NULL
)
556 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
557 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
561 /* Capture the user buffer */
562 CsrCaptureMessageBuffer(CaptureBuffer
,
565 (PVOID
*)&WriteOutputRequest
->CharInfo
);
567 /* Set up the data to send to the Console Server */
568 WriteOutputRequest
->OutputHandle
= hConsoleOutput
;
569 WriteOutputRequest
->Unicode
= bUnicode
;
570 WriteOutputRequest
->BufferSize
= dwBufferSize
;
571 WriteOutputRequest
->BufferCoord
= dwBufferCoord
;
572 WriteOutputRequest
->WriteRegion
= *lpWriteRegion
;
574 /* Call the server */
575 CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
577 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepWriteConsoleOutput
),
578 sizeof(CONSOLE_WRITEOUTPUT
));
579 DPRINT("Server returned: %x\n", ApiMessage
.Status
);
581 /* Check for success */
582 if (!NT_SUCCESS(ApiMessage
.Status
))
585 BaseSetLastNTError(ApiMessage
.Status
);
588 /* Return the read region */
589 DPRINT("read region: %lx\n", WriteOutputRequest
->WriteRegion
);
590 *lpWriteRegion
= WriteOutputRequest
->WriteRegion
;
592 /* Release the capture buffer */
593 CsrFreeCaptureBuffer(CaptureBuffer
);
595 /* Return TRUE or FALSE */
596 return NT_SUCCESS(ApiMessage
.Status
);
602 IntWriteConsoleOutputCode(HANDLE hConsoleOutput
,
607 LPDWORD lpNumberOfCodesWritten
)
611 CONSOLE_API_MESSAGE ApiMessage
;
612 PCONSOLE_WRITEOUTPUTCODE WriteOutputCodeRequest
= &ApiMessage
.Data
.WriteOutputCodeRequest
;
613 PCSR_CAPTURE_BUFFER CaptureBuffer
;
616 /* Determine the needed size */
620 CodeSize
= sizeof(CHAR
);
624 CodeSize
= sizeof(WCHAR
);
628 CodeSize
= sizeof(WORD
);
632 SetLastError(ERROR_INVALID_PARAMETER
);
635 WriteOutputCodeRequest
->BufferSize
= nLength
* CodeSize
;
637 /* Allocate a Capture Buffer */
638 CaptureBuffer
= CsrAllocateCaptureBuffer(1, WriteOutputCodeRequest
->BufferSize
);
639 if (CaptureBuffer
== NULL
)
641 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
642 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
646 /* Capture the buffer to write */
647 CsrCaptureMessageBuffer(CaptureBuffer
,
649 WriteOutputCodeRequest
->BufferSize
,
650 (PVOID
*)&WriteOutputCodeRequest
->pCode
.pCode
);
653 WriteOutputCodeRequest
->OutputHandle
= hConsoleOutput
;
654 WriteOutputCodeRequest
->CodeType
= CodeType
;
655 WriteOutputCodeRequest
->Coord
= dwWriteCoord
;
657 WriteOutputCodeRequest
->Length
= nLength
;
659 /* Call the server */
660 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
662 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepWriteConsoleOutputString
),
663 sizeof(CONSOLE_WRITEOUTPUTCODE
));
665 /* Check for success */
666 if (NT_SUCCESS(Status
))
668 // WriteOutputCodeRequest->Coord = WriteOutputCodeRequest->EndCoord;
670 if (lpNumberOfCodesWritten
!= NULL
)
671 // *lpNumberOfCodesWritten = WriteOutputCodeRequest->NrCharactersWritten;
672 *lpNumberOfCodesWritten
= WriteOutputCodeRequest
->Length
;
678 if (lpNumberOfCodesWritten
!= NULL
)
679 *lpNumberOfCodesWritten
= 0;
682 BaseSetLastNTError(Status
);
686 CsrFreeCaptureBuffer(CaptureBuffer
);
694 IntFillConsoleOutputCode(HANDLE hConsoleOutput
,
699 LPDWORD lpNumberOfCodesWritten
)
702 CONSOLE_API_MESSAGE ApiMessage
;
703 PCONSOLE_FILLOUTPUTCODE FillOutputRequest
= &ApiMessage
.Data
.FillOutputRequest
;
705 FillOutputRequest
->OutputHandle
= hConsoleOutput
;
706 FillOutputRequest
->CodeType
= CodeType
;
711 FillOutputRequest
->Code
.AsciiChar
= *(PCHAR
)pCode
;
715 FillOutputRequest
->Code
.UnicodeChar
= *(PWCHAR
)pCode
;
719 FillOutputRequest
->Code
.Attribute
= *(PWORD
)pCode
;
723 SetLastError(ERROR_INVALID_PARAMETER
);
727 /* Set up the data to send to the Console Server */
728 FillOutputRequest
->Coord
= dwWriteCoord
;
729 FillOutputRequest
->Length
= nLength
;
731 /* Call the server */
732 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
734 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepFillConsoleOutput
),
735 sizeof(CONSOLE_FILLOUTPUTCODE
));
737 /* Check for success */
738 if (NT_SUCCESS(Status
))
740 if (lpNumberOfCodesWritten
!= NULL
)
741 *lpNumberOfCodesWritten
= FillOutputRequest
->Length
;
742 // *lpNumberOfCodesWritten = Request.Data.FillOutputRequest.NrCharactersWritten;
748 if (lpNumberOfCodesWritten
!= NULL
)
749 *lpNumberOfCodesWritten
= 0;
751 BaseSetLastNTError(Status
);
757 /* FUNCTIONS ******************************************************************/
763 /*--------------------------------------------------------------
770 ReadConsoleW(HANDLE hConsoleInput
,
772 DWORD nNumberOfCharsToRead
,
773 LPDWORD lpNumberOfCharsRead
,
774 PCONSOLE_READCONSOLE_CONTROL pInputControl
)
776 return IntReadConsole(hConsoleInput
,
778 nNumberOfCharsToRead
,
785 /*--------------------------------------------------------------
792 ReadConsoleA(HANDLE hConsoleInput
,
794 DWORD nNumberOfCharsToRead
,
795 LPDWORD lpNumberOfCharsRead
,
796 PCONSOLE_READCONSOLE_CONTROL pInputControl
)
798 return IntReadConsole(hConsoleInput
,
800 nNumberOfCharsToRead
,
807 /*--------------------------------------------------------------
814 PeekConsoleInputW(HANDLE hConsoleInput
,
815 PINPUT_RECORD lpBuffer
,
817 LPDWORD lpNumberOfEventsRead
)
819 return IntGetConsoleInput(hConsoleInput
,
823 lpNumberOfEventsRead
,
828 /*--------------------------------------------------------------
835 PeekConsoleInputA(HANDLE hConsoleInput
,
836 PINPUT_RECORD lpBuffer
,
838 LPDWORD lpNumberOfEventsRead
)
840 return IntGetConsoleInput(hConsoleInput
,
844 lpNumberOfEventsRead
,
849 /*--------------------------------------------------------------
856 ReadConsoleInputW(HANDLE hConsoleInput
,
857 PINPUT_RECORD lpBuffer
,
859 LPDWORD lpNumberOfEventsRead
)
861 return IntGetConsoleInput(hConsoleInput
,
865 lpNumberOfEventsRead
,
870 /*--------------------------------------------------------------
877 ReadConsoleInputA(HANDLE hConsoleInput
,
878 PINPUT_RECORD lpBuffer
,
880 LPDWORD lpNumberOfEventsRead
)
882 return IntGetConsoleInput(hConsoleInput
,
886 lpNumberOfEventsRead
,
893 ReadConsoleInputExW(HANDLE hConsole
, LPVOID lpBuffer
, DWORD dwLen
, LPDWORD Unknown1
, DWORD Unknown2
)
902 ReadConsoleInputExA(HANDLE hConsole
, LPVOID lpBuffer
, DWORD dwLen
, LPDWORD Unknown1
, DWORD Unknown2
)
909 /*--------------------------------------------------------------
916 ReadConsoleOutputW(HANDLE hConsoleOutput
,
920 PSMALL_RECT lpReadRegion
)
922 return IntReadConsoleOutput(hConsoleOutput
,
931 /*--------------------------------------------------------------
938 ReadConsoleOutputA(HANDLE hConsoleOutput
,
942 PSMALL_RECT lpReadRegion
)
944 return IntReadConsoleOutput(hConsoleOutput
,
953 /*--------------------------------------------------------------
954 * ReadConsoleOutputCharacterW
960 ReadConsoleOutputCharacterW(HANDLE hConsoleOutput
,
964 LPDWORD lpNumberOfCharsRead
)
966 return IntReadConsoleOutputCode(hConsoleOutput
,
971 lpNumberOfCharsRead
);
975 /*--------------------------------------------------------------
976 * ReadConsoleOutputCharacterA
982 ReadConsoleOutputCharacterA(HANDLE hConsoleOutput
,
986 LPDWORD lpNumberOfCharsRead
)
988 return IntReadConsoleOutputCode(hConsoleOutput
,
993 lpNumberOfCharsRead
);
997 /*--------------------------------------------------------------
998 * ReadConsoleOutputAttribute
1004 ReadConsoleOutputAttribute(HANDLE hConsoleOutput
,
1008 LPDWORD lpNumberOfAttrsRead
)
1010 return IntReadConsoleOutputCode(hConsoleOutput
,
1015 lpNumberOfAttrsRead
);
1019 /*******************
1021 *******************/
1023 /*--------------------------------------------------------------
1030 WriteConsoleW(HANDLE hConsoleOutput
,
1031 CONST VOID
*lpBuffer
,
1032 DWORD nNumberOfCharsToWrite
,
1033 LPDWORD lpNumberOfCharsWritten
,
1036 return IntWriteConsole(hConsoleOutput
,
1038 nNumberOfCharsToWrite
,
1039 lpNumberOfCharsWritten
,
1045 /*--------------------------------------------------------------
1052 WriteConsoleA(HANDLE hConsoleOutput
,
1053 CONST VOID
*lpBuffer
,
1054 DWORD nNumberOfCharsToWrite
,
1055 LPDWORD lpNumberOfCharsWritten
,
1058 return IntWriteConsole(hConsoleOutput
,
1060 nNumberOfCharsToWrite
,
1061 lpNumberOfCharsWritten
,
1067 /*--------------------------------------------------------------
1068 * WriteConsoleInputW
1074 WriteConsoleInputW(HANDLE hConsoleInput
,
1075 CONST INPUT_RECORD
*lpBuffer
,
1077 LPDWORD lpNumberOfEventsWritten
)
1079 return IntWriteConsoleInput(hConsoleInput
,
1080 (PINPUT_RECORD
)lpBuffer
,
1082 lpNumberOfEventsWritten
,
1087 /*--------------------------------------------------------------
1088 * WriteConsoleInputA
1094 WriteConsoleInputA(HANDLE hConsoleInput
,
1095 CONST INPUT_RECORD
*lpBuffer
,
1097 LPDWORD lpNumberOfEventsWritten
)
1099 return IntWriteConsoleInput(hConsoleInput
,
1100 (PINPUT_RECORD
)lpBuffer
,
1102 lpNumberOfEventsWritten
,
1107 /*--------------------------------------------------------------
1108 * WriteConsoleOutputW
1114 WriteConsoleOutputW(HANDLE hConsoleOutput
,
1115 CONST CHAR_INFO
*lpBuffer
,
1117 COORD dwBufferCoord
,
1118 PSMALL_RECT lpWriteRegion
)
1120 return IntWriteConsoleOutput(hConsoleOutput
,
1129 /*--------------------------------------------------------------
1130 * WriteConsoleOutputA
1136 WriteConsoleOutputA(HANDLE hConsoleOutput
,
1137 CONST CHAR_INFO
*lpBuffer
,
1139 COORD dwBufferCoord
,
1140 PSMALL_RECT lpWriteRegion
)
1142 return IntWriteConsoleOutput(hConsoleOutput
,
1151 /*--------------------------------------------------------------
1152 * WriteConsoleOutputCharacterW
1158 WriteConsoleOutputCharacterW(HANDLE hConsoleOutput
,
1159 LPCWSTR lpCharacter
,
1162 LPDWORD lpNumberOfCharsWritten
)
1164 return IntWriteConsoleOutputCode(hConsoleOutput
,
1169 lpNumberOfCharsWritten
);
1173 /*--------------------------------------------------------------
1174 * WriteConsoleOutputCharacterA
1180 WriteConsoleOutputCharacterA(HANDLE hConsoleOutput
,
1184 LPDWORD lpNumberOfCharsWritten
)
1186 return IntWriteConsoleOutputCode(hConsoleOutput
,
1191 lpNumberOfCharsWritten
);
1195 /*--------------------------------------------------------------
1196 * WriteConsoleOutputAttribute
1202 WriteConsoleOutputAttribute(HANDLE hConsoleOutput
,
1203 CONST WORD
*lpAttribute
,
1206 LPDWORD lpNumberOfAttrsWritten
)
1208 return IntWriteConsoleOutputCode(hConsoleOutput
,
1213 lpNumberOfAttrsWritten
);
1217 /*--------------------------------------------------------------
1218 * FillConsoleOutputCharacterW
1224 FillConsoleOutputCharacterW(HANDLE hConsoleOutput
,
1228 LPDWORD lpNumberOfCharsWritten
)
1230 return IntFillConsoleOutputCode(hConsoleOutput
,
1235 lpNumberOfCharsWritten
);
1239 /*--------------------------------------------------------------
1240 * FillConsoleOutputCharacterA
1246 FillConsoleOutputCharacterA(HANDLE hConsoleOutput
,
1250 LPDWORD lpNumberOfCharsWritten
)
1252 return IntFillConsoleOutputCode(hConsoleOutput
,
1257 lpNumberOfCharsWritten
);
1261 /*--------------------------------------------------------------
1262 * FillConsoleOutputAttribute
1268 FillConsoleOutputAttribute(HANDLE hConsoleOutput
,
1272 LPDWORD lpNumberOfAttrsWritten
)
1274 return IntFillConsoleOutputCode(hConsoleOutput
,
1279 lpNumberOfAttrsWritten
);