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
,
124 PINPUT_RECORD lpBuffer
,
126 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
->Unicode
= bUnicode
;
162 GetInputRequest
->bRead
= bRead
;
163 GetInputRequest
->InputsRead
= 0;
164 GetInputRequest
->Length
= nLength
;
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
,
465 CONSOLE_API_MESSAGE ApiMessage
;
466 PCONSOLE_WRITEINPUT WriteInputRequest
= &ApiMessage
.Data
.WriteInputRequest
;
467 PCSR_CAPTURE_BUFFER CaptureBuffer
;
470 Size
= nLength
* sizeof(INPUT_RECORD
);
472 DPRINT("IntWriteConsoleInput: %lx %p\n", Size
, lpNumberOfEventsWritten
);
474 /* Allocate a Capture Buffer */
475 CaptureBuffer
= CsrAllocateCaptureBuffer(1, Size
);
476 if (CaptureBuffer
== NULL
)
478 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
479 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
483 /* Capture the user buffer */
484 CsrCaptureMessageBuffer(CaptureBuffer
,
487 (PVOID
*)&WriteInputRequest
->InputRecord
);
489 /* Set up the data to send to the Console Server */
490 WriteInputRequest
->InputHandle
= hConsoleInput
;
491 WriteInputRequest
->Unicode
= bUnicode
;
492 WriteInputRequest
->Length
= nLength
;
494 /* Call the server */
495 CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
497 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepWriteConsoleInput
),
498 sizeof(CONSOLE_WRITEINPUT
));
499 DPRINT("Server returned: %x\n", ApiMessage
.Status
);
501 /* Check for success */
502 if (NT_SUCCESS(ApiMessage
.Status
))
504 /* Return the number of events read */
505 DPRINT("Events read: %lx\n", WriteInputRequest
->Length
);
507 if (lpNumberOfEventsWritten
!= NULL
)
508 *lpNumberOfEventsWritten
= WriteInputRequest
->Length
;
512 if (lpNumberOfEventsWritten
!= NULL
)
513 *lpNumberOfEventsWritten
= 0;
516 BaseSetLastNTError(ApiMessage
.Status
);
519 /* Release the capture buffer */
520 CsrFreeCaptureBuffer(CaptureBuffer
);
522 /* Return TRUE or FALSE */
523 return NT_SUCCESS(ApiMessage
.Status
);
529 IntWriteConsoleOutput(HANDLE hConsoleOutput
,
530 CONST CHAR_INFO
*lpBuffer
,
533 PSMALL_RECT lpWriteRegion
,
536 CONSOLE_API_MESSAGE ApiMessage
;
537 PCONSOLE_WRITEOUTPUT WriteOutputRequest
= &ApiMessage
.Data
.WriteOutputRequest
;
538 PCSR_CAPTURE_BUFFER CaptureBuffer
;
541 if ((lpBuffer
== NULL
) || (lpWriteRegion
== NULL
))
543 SetLastError(ERROR_INVALID_PARAMETER
);
547 if (lpWriteRegion == NULL)
549 SetLastError(ERROR_INVALID_PARAMETER);
554 Size
= dwBufferSize
.Y
* dwBufferSize
.X
* sizeof(CHAR_INFO
);
556 DPRINT("IntWriteConsoleOutput: %lx %p\n", Size
, lpWriteRegion
);
558 /* Allocate a Capture Buffer */
559 CaptureBuffer
= CsrAllocateCaptureBuffer(1, Size
);
560 if (CaptureBuffer
== NULL
)
562 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
563 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
567 /* Capture the user buffer */
568 CsrCaptureMessageBuffer(CaptureBuffer
,
571 (PVOID
*)&WriteOutputRequest
->CharInfo
);
573 /* Set up the data to send to the Console Server */
574 WriteOutputRequest
->OutputHandle
= hConsoleOutput
;
575 WriteOutputRequest
->Unicode
= bUnicode
;
576 WriteOutputRequest
->BufferSize
= dwBufferSize
;
577 WriteOutputRequest
->BufferCoord
= dwBufferCoord
;
578 WriteOutputRequest
->WriteRegion
= *lpWriteRegion
;
580 /* Call the server */
581 CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
583 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepWriteConsoleOutput
),
584 sizeof(CONSOLE_WRITEOUTPUT
));
585 DPRINT("Server returned: %x\n", ApiMessage
.Status
);
587 /* Check for success */
588 if (!NT_SUCCESS(ApiMessage
.Status
))
591 BaseSetLastNTError(ApiMessage
.Status
);
594 /* Return the read region */
595 DPRINT("read region: %p\n", WriteOutputRequest
->WriteRegion
);
596 *lpWriteRegion
= WriteOutputRequest
->WriteRegion
;
598 /* Release the capture buffer */
599 CsrFreeCaptureBuffer(CaptureBuffer
);
601 /* Return TRUE or FALSE */
602 return NT_SUCCESS(ApiMessage
.Status
);
608 IntWriteConsoleOutputCode(HANDLE hConsoleOutput
,
613 LPDWORD lpNumberOfCodesWritten
)
617 CONSOLE_API_MESSAGE ApiMessage
;
618 PCONSOLE_WRITEOUTPUTCODE WriteOutputCodeRequest
= &ApiMessage
.Data
.WriteOutputCodeRequest
;
619 PCSR_CAPTURE_BUFFER CaptureBuffer
;
622 /* Determine the needed size */
626 CodeSize
= sizeof(CHAR
);
630 CodeSize
= sizeof(WCHAR
);
634 CodeSize
= sizeof(WORD
);
638 SetLastError(ERROR_INVALID_PARAMETER
);
641 WriteOutputCodeRequest
->BufferSize
= nLength
* CodeSize
;
643 /* Allocate a Capture Buffer */
644 CaptureBuffer
= CsrAllocateCaptureBuffer(1, WriteOutputCodeRequest
->BufferSize
);
645 if (CaptureBuffer
== NULL
)
647 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
648 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
652 /* Capture the buffer to write */
653 CsrCaptureMessageBuffer(CaptureBuffer
,
655 WriteOutputCodeRequest
->BufferSize
,
656 (PVOID
*)&WriteOutputCodeRequest
->pCode
.pCode
);
659 WriteOutputCodeRequest
->OutputHandle
= hConsoleOutput
;
660 WriteOutputCodeRequest
->CodeType
= CodeType
;
661 WriteOutputCodeRequest
->Coord
= dwWriteCoord
;
663 WriteOutputCodeRequest
->Length
= (USHORT
)nLength
;
665 /* Call the server */
666 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
668 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepWriteConsoleOutputString
),
669 sizeof(CONSOLE_WRITEOUTPUTCODE
));
671 /* Check for success */
672 if (NT_SUCCESS(Status
))
674 // WriteOutputCodeRequest->Coord = WriteOutputCodeRequest->EndCoord;
676 if (lpNumberOfCodesWritten
!= NULL
)
677 // *lpNumberOfCodesWritten = WriteOutputCodeRequest->NrCharactersWritten;
678 *lpNumberOfCodesWritten
= WriteOutputCodeRequest
->Length
;
684 if (lpNumberOfCodesWritten
!= NULL
)
685 *lpNumberOfCodesWritten
= 0;
688 BaseSetLastNTError(Status
);
692 CsrFreeCaptureBuffer(CaptureBuffer
);
700 IntFillConsoleOutputCode(HANDLE hConsoleOutput
,
705 LPDWORD lpNumberOfCodesWritten
)
708 CONSOLE_API_MESSAGE ApiMessage
;
709 PCONSOLE_FILLOUTPUTCODE FillOutputRequest
= &ApiMessage
.Data
.FillOutputRequest
;
711 FillOutputRequest
->OutputHandle
= hConsoleOutput
;
712 FillOutputRequest
->CodeType
= CodeType
;
717 FillOutputRequest
->Code
.AsciiChar
= *(PCHAR
)pCode
;
721 FillOutputRequest
->Code
.UnicodeChar
= *(PWCHAR
)pCode
;
725 FillOutputRequest
->Code
.Attribute
= *(PWORD
)pCode
;
729 SetLastError(ERROR_INVALID_PARAMETER
);
733 /* Set up the data to send to the Console Server */
734 FillOutputRequest
->Coord
= dwWriteCoord
;
735 FillOutputRequest
->Length
= nLength
;
737 /* Call the server */
738 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
740 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepFillConsoleOutput
),
741 sizeof(CONSOLE_FILLOUTPUTCODE
));
743 /* Check for success */
744 if (NT_SUCCESS(Status
))
746 if (lpNumberOfCodesWritten
!= NULL
)
747 *lpNumberOfCodesWritten
= FillOutputRequest
->Length
;
748 // *lpNumberOfCodesWritten = Request.Data.FillOutputRequest.NrCharactersWritten;
754 if (lpNumberOfCodesWritten
!= NULL
)
755 *lpNumberOfCodesWritten
= 0;
757 BaseSetLastNTError(Status
);
763 /* FUNCTIONS ******************************************************************/
769 /*--------------------------------------------------------------
776 ReadConsoleW(HANDLE hConsoleInput
,
778 DWORD nNumberOfCharsToRead
,
779 LPDWORD lpNumberOfCharsRead
,
780 PCONSOLE_READCONSOLE_CONTROL pInputControl
)
782 return IntReadConsole(hConsoleInput
,
784 nNumberOfCharsToRead
,
791 /*--------------------------------------------------------------
798 ReadConsoleA(HANDLE hConsoleInput
,
800 DWORD nNumberOfCharsToRead
,
801 LPDWORD lpNumberOfCharsRead
,
802 PCONSOLE_READCONSOLE_CONTROL pInputControl
)
804 return IntReadConsole(hConsoleInput
,
806 nNumberOfCharsToRead
,
813 /*--------------------------------------------------------------
820 PeekConsoleInputW(HANDLE hConsoleInput
,
821 PINPUT_RECORD lpBuffer
,
823 LPDWORD lpNumberOfEventsRead
)
825 return IntGetConsoleInput(hConsoleInput
,
829 lpNumberOfEventsRead
,
834 /*--------------------------------------------------------------
841 PeekConsoleInputA(HANDLE hConsoleInput
,
842 PINPUT_RECORD lpBuffer
,
844 LPDWORD lpNumberOfEventsRead
)
846 return IntGetConsoleInput(hConsoleInput
,
850 lpNumberOfEventsRead
,
855 /*--------------------------------------------------------------
862 ReadConsoleInputW(HANDLE hConsoleInput
,
863 PINPUT_RECORD lpBuffer
,
865 LPDWORD lpNumberOfEventsRead
)
867 return IntGetConsoleInput(hConsoleInput
,
871 lpNumberOfEventsRead
,
876 /*--------------------------------------------------------------
883 ReadConsoleInputA(HANDLE hConsoleInput
,
884 PINPUT_RECORD lpBuffer
,
886 LPDWORD lpNumberOfEventsRead
)
888 return IntGetConsoleInput(hConsoleInput
,
892 lpNumberOfEventsRead
,
899 ReadConsoleInputExW(HANDLE hConsole
, LPVOID lpBuffer
, DWORD dwLen
, LPDWORD Unknown1
, DWORD Unknown2
)
908 ReadConsoleInputExA(HANDLE hConsole
, LPVOID lpBuffer
, DWORD dwLen
, LPDWORD Unknown1
, DWORD Unknown2
)
915 /*--------------------------------------------------------------
922 ReadConsoleOutputW(HANDLE hConsoleOutput
,
926 PSMALL_RECT lpReadRegion
)
928 return IntReadConsoleOutput(hConsoleOutput
,
937 /*--------------------------------------------------------------
944 ReadConsoleOutputA(HANDLE hConsoleOutput
,
948 PSMALL_RECT lpReadRegion
)
950 return IntReadConsoleOutput(hConsoleOutput
,
959 /*--------------------------------------------------------------
960 * ReadConsoleOutputCharacterW
966 ReadConsoleOutputCharacterW(HANDLE hConsoleOutput
,
970 LPDWORD lpNumberOfCharsRead
)
972 return IntReadConsoleOutputCode(hConsoleOutput
,
977 lpNumberOfCharsRead
);
981 /*--------------------------------------------------------------
982 * ReadConsoleOutputCharacterA
988 ReadConsoleOutputCharacterA(HANDLE hConsoleOutput
,
992 LPDWORD lpNumberOfCharsRead
)
994 return IntReadConsoleOutputCode(hConsoleOutput
,
999 lpNumberOfCharsRead
);
1003 /*--------------------------------------------------------------
1004 * ReadConsoleOutputAttribute
1010 ReadConsoleOutputAttribute(HANDLE hConsoleOutput
,
1014 LPDWORD lpNumberOfAttrsRead
)
1016 return IntReadConsoleOutputCode(hConsoleOutput
,
1021 lpNumberOfAttrsRead
);
1025 /*******************
1027 *******************/
1029 /*--------------------------------------------------------------
1036 WriteConsoleW(HANDLE hConsoleOutput
,
1037 CONST VOID
*lpBuffer
,
1038 DWORD nNumberOfCharsToWrite
,
1039 LPDWORD lpNumberOfCharsWritten
,
1042 return IntWriteConsole(hConsoleOutput
,
1044 nNumberOfCharsToWrite
,
1045 lpNumberOfCharsWritten
,
1051 /*--------------------------------------------------------------
1058 WriteConsoleA(HANDLE hConsoleOutput
,
1059 CONST VOID
*lpBuffer
,
1060 DWORD nNumberOfCharsToWrite
,
1061 LPDWORD lpNumberOfCharsWritten
,
1064 return IntWriteConsole(hConsoleOutput
,
1066 nNumberOfCharsToWrite
,
1067 lpNumberOfCharsWritten
,
1073 /*--------------------------------------------------------------
1074 * WriteConsoleInputW
1080 WriteConsoleInputW(HANDLE hConsoleInput
,
1081 CONST INPUT_RECORD
*lpBuffer
,
1083 LPDWORD lpNumberOfEventsWritten
)
1085 return IntWriteConsoleInput(hConsoleInput
,
1086 (PINPUT_RECORD
)lpBuffer
,
1088 lpNumberOfEventsWritten
,
1093 /*--------------------------------------------------------------
1094 * WriteConsoleInputA
1100 WriteConsoleInputA(HANDLE hConsoleInput
,
1101 CONST INPUT_RECORD
*lpBuffer
,
1103 LPDWORD lpNumberOfEventsWritten
)
1105 return IntWriteConsoleInput(hConsoleInput
,
1106 (PINPUT_RECORD
)lpBuffer
,
1108 lpNumberOfEventsWritten
,
1113 /*--------------------------------------------------------------
1114 * WriteConsoleOutputW
1120 WriteConsoleOutputW(HANDLE hConsoleOutput
,
1121 CONST CHAR_INFO
*lpBuffer
,
1123 COORD dwBufferCoord
,
1124 PSMALL_RECT lpWriteRegion
)
1126 return IntWriteConsoleOutput(hConsoleOutput
,
1135 /*--------------------------------------------------------------
1136 * WriteConsoleOutputA
1142 WriteConsoleOutputA(HANDLE hConsoleOutput
,
1143 CONST CHAR_INFO
*lpBuffer
,
1145 COORD dwBufferCoord
,
1146 PSMALL_RECT lpWriteRegion
)
1148 return IntWriteConsoleOutput(hConsoleOutput
,
1157 /*--------------------------------------------------------------
1158 * WriteConsoleOutputCharacterW
1164 WriteConsoleOutputCharacterW(HANDLE hConsoleOutput
,
1165 LPCWSTR lpCharacter
,
1168 LPDWORD lpNumberOfCharsWritten
)
1170 return IntWriteConsoleOutputCode(hConsoleOutput
,
1175 lpNumberOfCharsWritten
);
1179 /*--------------------------------------------------------------
1180 * WriteConsoleOutputCharacterA
1186 WriteConsoleOutputCharacterA(HANDLE hConsoleOutput
,
1190 LPDWORD lpNumberOfCharsWritten
)
1192 return IntWriteConsoleOutputCode(hConsoleOutput
,
1197 lpNumberOfCharsWritten
);
1201 /*--------------------------------------------------------------
1202 * WriteConsoleOutputAttribute
1208 WriteConsoleOutputAttribute(HANDLE hConsoleOutput
,
1209 CONST WORD
*lpAttribute
,
1212 LPDWORD lpNumberOfAttrsWritten
)
1214 return IntWriteConsoleOutputCode(hConsoleOutput
,
1219 lpNumberOfAttrsWritten
);
1223 /*--------------------------------------------------------------
1224 * FillConsoleOutputCharacterW
1230 FillConsoleOutputCharacterW(HANDLE hConsoleOutput
,
1234 LPDWORD lpNumberOfCharsWritten
)
1236 return IntFillConsoleOutputCode(hConsoleOutput
,
1241 lpNumberOfCharsWritten
);
1245 /*--------------------------------------------------------------
1246 * FillConsoleOutputCharacterA
1252 FillConsoleOutputCharacterA(HANDLE hConsoleOutput
,
1256 LPDWORD lpNumberOfCharsWritten
)
1258 return IntFillConsoleOutputCode(hConsoleOutput
,
1263 lpNumberOfCharsWritten
);
1267 /*--------------------------------------------------------------
1268 * FillConsoleOutputAttribute
1274 FillConsoleOutputAttribute(HANDLE hConsoleOutput
,
1278 LPDWORD lpNumberOfAttrsWritten
)
1280 return IntFillConsoleOutputCode(hConsoleOutput
,
1285 lpNumberOfAttrsWritten
);