1 /* $Id: console.c,v 1.36 2001/11/20 02:29:44 dwelch Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS system libraries
5 * FILE: lib/kernel32/misc/console.c
6 * PURPOSE: Win32 server console functions
10 * 19990204 EA SetConsoleTitleA
14 /* INCLUDES ******************************************************************/
16 #include <ddk/ntddk.h>
17 #include <ddk/ntddblue.h>
22 #include <csrss/csrss.h>
23 #include <ntdll/csr.h>
26 #include <kernel32/kernel32.h>
27 #include <kernel32/error.h>
29 /* GLOBALS *******************************************************************/
31 static BOOL IgnoreCtrlEvents
= FALSE
;
32 static ULONG NrCtrlHandlers
= 0;
33 static PHANDLER_ROUTINE
* CtrlHandlers
= NULL
;
35 /* FUNCTIONS *****************************************************************/
38 AddConsoleAliasA (DWORD a0
,
45 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
50 AddConsoleAliasW (DWORD a0
,
57 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
62 ConsoleMenuControl (HANDLE hConsole
,
69 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
74 DuplicateConsoleHandle (HANDLE hConsole
,
82 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
87 ExpungeConsoleCommandHistoryW (DWORD Unknown0
)
92 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
98 ExpungeConsoleCommandHistoryA (DWORD Unknown0
)
103 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
108 GetConsoleAliasW (DWORD Unknown0
,
116 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
122 GetConsoleAliasA (DWORD Unknown0
,
130 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
135 GetConsoleAliasExesW (DWORD Unknown0
,
141 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
148 GetConsoleAliasExesA (DWORD Unknown0
,
154 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
161 GetConsoleAliasExesLengthA (VOID
)
166 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
171 GetConsoleAliasExesLengthW (VOID
)
176 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
181 GetConsoleAliasesW (DWORD Unknown0
,
188 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
193 GetConsoleAliasesA (DWORD Unknown0
,
200 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
205 GetConsoleAliasesLengthW (DWORD Unknown0
)
210 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
215 GetConsoleAliasesLengthA (DWORD Unknown0
)
220 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
225 GetConsoleCommandHistoryW (DWORD Unknown0
,
232 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
237 GetConsoleCommandHistoryA (DWORD Unknown0
,
244 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
249 GetConsoleCommandHistoryLengthW (DWORD Unknown0
)
254 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
259 GetConsoleCommandHistoryLengthA (DWORD Unknown0
)
264 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
269 GetConsoleDisplayMode (LPDWORD lpdwMode
)
271 * FUNCTION: Get the console display mode
273 * lpdwMode - Address of variable that receives the current value
275 * STATUS: Undocumented
278 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
283 GetConsoleFontInfo (DWORD Unknown0
,
291 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
296 GetConsoleFontSize (DWORD Unknown0
,
302 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
307 GetConsoleHardwareState (DWORD Unknown0
,
314 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
319 GetConsoleInputWaitHandle (VOID
)
324 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
329 GetCurrentConsoleFont (DWORD Unknown0
,
336 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
341 GetNumberOfConsoleFonts (VOID
)
346 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
347 return 1; /* FIXME: call csrss.exe */
351 InvalidateConsoleDIBits (DWORD Unknown0
,
357 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
362 OpenConsoleW (DWORD Unknown0
,
370 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
375 SetConsoleCommandHistoryMode (DWORD dwMode
)
380 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
385 SetConsoleCursor (DWORD Unknown0
,
391 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
396 SetConsoleDisplayMode (HANDLE hOut
,
400 * FUNCTION: Set the console display mode.
402 * hOut - Standard output handle.
403 * dwNewMode - New mode.
404 * lpdwOldMode - Address of a variable that receives the old mode.
407 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
412 SetConsoleFont (DWORD Unknown0
,
418 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
423 SetConsoleHardwareState (DWORD Unknown0
,
430 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
435 SetConsoleKeyShortcuts (DWORD Unknown0
,
443 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
448 SetConsoleMaximumWindowSize (DWORD Unknown0
,
454 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
459 SetConsoleMenuClose (DWORD Unknown0
)
464 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
469 SetConsoleNumberOfCommandsA (DWORD Unknown0
,
475 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
480 SetConsoleNumberOfCommandsW (DWORD Unknown0
,
486 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
491 SetConsolePalette (DWORD Unknown0
,
498 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
503 SetLastConsoleEventActive (VOID
)
508 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
513 ShowConsoleCursor (DWORD Unknown0
,
519 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
524 VerifyConsoleIoHandle (DWORD Unknown0
)
529 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
534 WriteConsoleInputVDMA (DWORD Unknown0
,
539 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
544 WriteConsoleInputVDMW (DWORD Unknown0
,
549 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
554 CloseConsoleHandle(HANDLE Handle
)
559 if (IsConsoleHandle (Handle
) == FALSE
)
561 SetLastError (ERROR_INVALID_PARAMETER
);
564 /* FIXME: call CSRSS */
569 IsConsoleHandle(HANDLE Handle
)
571 if ((((ULONG
)Handle
) & 0x10000003) == 0x3)
579 GetStdHandle(DWORD nStdHandle
)
581 * FUNCTION: Get a handle for the standard input, standard output
582 * and a standard error device.
584 * nStdHandle - Specifies the device for which to return the handle.
585 * RETURNS: If the function succeeds, the return value is the handle
586 * of the specified device. Otherwise the value is INVALID_HANDLE_VALUE.
589 PRTL_USER_PROCESS_PARAMETERS Ppb
;
591 Ppb
= NtCurrentPeb()->ProcessParameters
;
594 case STD_INPUT_HANDLE
: return Ppb
->InputHandle
;
595 case STD_OUTPUT_HANDLE
: return Ppb
->OutputHandle
;
596 case STD_ERROR_HANDLE
: return Ppb
->ErrorHandle
;
598 SetLastError (ERROR_INVALID_PARAMETER
);
599 return INVALID_HANDLE_VALUE
;
602 WINBASEAPI BOOL WINAPI
603 SetStdHandle(DWORD nStdHandle
,
606 * FUNCTION: Set the handle for the standard input, standard output or
607 * the standard error device.
609 * nStdHandle - Specifies the handle to be set.
610 * hHandle - The handle to set.
611 * RETURNS: TRUE if the function succeeds, FALSE otherwise.
614 PRTL_USER_PROCESS_PARAMETERS Ppb
;
616 Ppb
= NtCurrentPeb()->ProcessParameters
;
618 /* More checking needed? */
619 if (hHandle
== INVALID_HANDLE_VALUE
)
621 SetLastError (ERROR_INVALID_HANDLE
);
625 SetLastError(ERROR_SUCCESS
); /* OK */
628 case STD_INPUT_HANDLE
:
629 Ppb
->InputHandle
= hHandle
;
631 case STD_OUTPUT_HANDLE
:
632 Ppb
->OutputHandle
= hHandle
;
634 case STD_ERROR_HANDLE
:
635 Ppb
->ErrorHandle
= hHandle
;
638 SetLastError (ERROR_INVALID_PARAMETER
);
643 /*--------------------------------------------------------------
646 WINBOOL STDCALL
WriteConsoleA(HANDLE hConsoleOutput
,
647 CONST VOID
*lpBuffer
,
648 DWORD nNumberOfCharsToWrite
,
649 LPDWORD lpNumberOfCharsWritten
,
652 PCSRSS_API_REQUEST Request
;
653 CSRSS_API_REPLY Reply
;
657 Request
= RtlAllocateHeap(GetProcessHeap(),
659 sizeof(CSRSS_API_REQUEST
) + CSRSS_MAX_WRITE_CONSOLE_REQUEST
);
665 Request
->Type
= CSRSS_WRITE_CONSOLE
;
666 Request
->Data
.WriteConsoleRequest
.ConsoleHandle
= hConsoleOutput
;
667 if (lpNumberOfCharsWritten
!= NULL
)
668 *lpNumberOfCharsWritten
= nNumberOfCharsToWrite
;
669 while( nNumberOfCharsToWrite
)
671 Size
= nNumberOfCharsToWrite
> CSRSS_MAX_WRITE_CONSOLE_REQUEST
? CSRSS_MAX_WRITE_CONSOLE_REQUEST
: nNumberOfCharsToWrite
;
673 Request
->Data
.WriteConsoleRequest
.NrCharactersToWrite
= Size
;
675 // DbgPrint("nNumberOfCharsToWrite %d\n", nNumberOfCharsToWrite);
676 // DbgPrint("Buffer %s\n", Request->Data.WriteConsoleRequest.Buffer);
678 memcpy( Request
->Data
.WriteConsoleRequest
.Buffer
, lpBuffer
, Size
);
680 Status
= CsrClientCallServer(Request
,
682 sizeof(CSRSS_WRITE_CONSOLE_REQUEST
) +
684 sizeof(CSRSS_API_REPLY
));
686 if (!NT_SUCCESS(Status
) || !NT_SUCCESS( Status
= Reply
.Status
) )
688 RtlFreeHeap( GetProcessHeap(), 0, Request
);
689 SetLastErrorByStatus (Status
);
692 nNumberOfCharsToWrite
-= Size
;
695 RtlFreeHeap( GetProcessHeap(), 0, Request
);
700 /*--------------------------------------------------------------
703 WINBOOL STDCALL
ReadConsoleA(HANDLE hConsoleInput
,
705 DWORD nNumberOfCharsToRead
,
706 LPDWORD lpNumberOfCharsRead
,
709 CSRSS_API_REQUEST Request
;
710 PCSRSS_API_REPLY Reply
;
714 Reply
= RtlAllocateHeap(GetProcessHeap(),
716 sizeof(CSRSS_API_REPLY
) + nNumberOfCharsToRead
);
722 Request
.Type
= CSRSS_READ_CONSOLE
;
723 Request
.Data
.ReadConsoleRequest
.ConsoleHandle
= hConsoleInput
;
724 Request
.Data
.ReadConsoleRequest
.NrCharactersToRead
= nNumberOfCharsToRead
> CSRSS_MAX_READ_CONSOLE_REQUEST
? CSRSS_MAX_READ_CONSOLE_REQUEST
: nNumberOfCharsToRead
;
725 Request
.Data
.ReadConsoleRequest
.nCharsCanBeDeleted
= 0;
726 Status
= CsrClientCallServer(&Request
,
728 sizeof(CSRSS_API_REQUEST
),
729 sizeof(CSRSS_API_REPLY
) +
730 Request
.Data
.ReadConsoleRequest
.NrCharactersToRead
);
731 if (!NT_SUCCESS(Status
) || !NT_SUCCESS( Status
= Reply
->Status
))
733 DbgPrint( "CSR returned error in ReadConsole\n" );
734 SetLastErrorByStatus ( Status
);
735 RtlFreeHeap( GetProcessHeap(), 0, Reply
);
738 if( Reply
->Status
== STATUS_NOTIFY_CLEANUP
)
739 Reply
->Status
= STATUS_PENDING
; // ignore backspace because we have no chars to backspace
740 /* There may not be any chars or lines to read yet, so wait */
741 while( Reply
->Status
== STATUS_PENDING
)
743 /* some chars may have been returned, but not a whole line yet, so recompute buffer and try again */
744 nNumberOfCharsToRead
-= Reply
->Data
.ReadConsoleReply
.NrCharactersRead
;
745 /* don't overflow caller's buffer, even if you still don't have a complete line */
746 if( !nNumberOfCharsToRead
)
748 Request
.Data
.ReadConsoleRequest
.NrCharactersToRead
= nNumberOfCharsToRead
> CSRSS_MAX_READ_CONSOLE_REQUEST
? CSRSS_MAX_READ_CONSOLE_REQUEST
: nNumberOfCharsToRead
;
749 /* copy any chars already read to buffer */
750 memcpy( lpBuffer
+ CharsRead
, Reply
->Data
.ReadConsoleReply
.Buffer
, Reply
->Data
.ReadConsoleReply
.NrCharactersRead
);
751 CharsRead
+= Reply
->Data
.ReadConsoleReply
.NrCharactersRead
;
752 /* wait for csrss to signal there is more data to read, but not if we got STATUS_NOTIFY_CLEANUP for backspace */
753 Status
= NtWaitForSingleObject( Reply
->Data
.ReadConsoleReply
.EventHandle
, FALSE
, 0 );
754 if( !NT_SUCCESS( Status
) )
756 DbgPrint( "Wait for console input failed!\n" );
757 RtlFreeHeap( GetProcessHeap(), 0, Reply
);
760 Request
.Data
.ReadConsoleRequest
.nCharsCanBeDeleted
= CharsRead
;
761 Status
= CsrClientCallServer( &Request
, Reply
, sizeof( CSRSS_API_REQUEST
), sizeof( CSRSS_API_REPLY
) + Request
.Data
.ReadConsoleRequest
.NrCharactersToRead
);
762 if( !NT_SUCCESS( Status
) || !NT_SUCCESS( Status
= Reply
->Status
) )
764 SetLastErrorByStatus ( Status
);
765 RtlFreeHeap( GetProcessHeap(), 0, Reply
);
768 if( Reply
->Status
== STATUS_NOTIFY_CLEANUP
)
774 nNumberOfCharsToRead
++;
776 Reply
->Status
= STATUS_PENDING
; // retry
779 /* copy data to buffer, count total returned, and return */
780 memcpy( lpBuffer
+ CharsRead
, Reply
->Data
.ReadConsoleReply
.Buffer
, Reply
->Data
.ReadConsoleReply
.NrCharactersRead
);
781 CharsRead
+= Reply
->Data
.ReadConsoleReply
.NrCharactersRead
;
782 if (lpNumberOfCharsRead
!= NULL
)
783 *lpNumberOfCharsRead
= CharsRead
;
784 RtlFreeHeap(GetProcessHeap(),
792 /*--------------------------------------------------------------
795 WINBOOL STDCALL
AllocConsole(VOID
)
797 CSRSS_API_REQUEST Request
;
798 CSRSS_API_REPLY Reply
;
801 Request
.Type
= CSRSS_ALLOC_CONSOLE
;
802 Status
= CsrClientCallServer( &Request
, &Reply
, sizeof( CSRSS_API_REQUEST
), sizeof( CSRSS_API_REPLY
) );
803 if( !NT_SUCCESS( Status
) || !NT_SUCCESS( Status
= Reply
.Status
) )
805 SetLastErrorByStatus ( Status
);
808 SetStdHandle( STD_INPUT_HANDLE
, Reply
.Data
.AllocConsoleReply
.InputHandle
);
809 SetStdHandle( STD_OUTPUT_HANDLE
, Reply
.Data
.AllocConsoleReply
.OutputHandle
);
810 SetStdHandle( STD_ERROR_HANDLE
, Reply
.Data
.AllocConsoleReply
.OutputHandle
);
815 /*--------------------------------------------------------------
818 WINBOOL STDCALL
FreeConsole(VOID
)
820 DbgPrint("FreeConsole() is unimplemented");
825 /*--------------------------------------------------------------
826 * GetConsoleScreenBufferInfo
830 GetConsoleScreenBufferInfo(
831 HANDLE hConsoleOutput
,
832 PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo
835 CSRSS_API_REQUEST Request
;
836 CSRSS_API_REPLY Reply
;
839 Request
.Type
= CSRSS_SCREEN_BUFFER_INFO
;
840 Request
.Data
.ScreenBufferInfoRequest
.ConsoleHandle
= hConsoleOutput
;
841 Status
= CsrClientCallServer( &Request
, &Reply
, sizeof( CSRSS_API_REQUEST
), sizeof( CSRSS_API_REPLY
) );
842 if( !NT_SUCCESS( Status
) || !NT_SUCCESS( Status
= Reply
.Status
) )
844 SetLastErrorByStatus ( Status
);
847 *lpConsoleScreenBufferInfo
= Reply
.Data
.ScreenBufferInfoReply
.Info
;
852 /*--------------------------------------------------------------
853 * SetConsoleCursorPosition
857 SetConsoleCursorPosition(
858 HANDLE hConsoleOutput
,
859 COORD dwCursorPosition
862 CSRSS_API_REQUEST Request
;
863 CSRSS_API_REPLY Reply
;
866 Request
.Type
= CSRSS_SET_CURSOR
;
867 Request
.Data
.SetCursorRequest
.ConsoleHandle
= hConsoleOutput
;
868 Request
.Data
.SetCursorRequest
.Position
= dwCursorPosition
;
869 Status
= CsrClientCallServer( &Request
, &Reply
, sizeof( CSRSS_API_REQUEST
), sizeof( CSRSS_API_REPLY
) );
870 if( !NT_SUCCESS( Status
) || !NT_SUCCESS( Status
= Reply
.Status
) )
872 SetLastErrorByStatus ( Status
);
879 /*--------------------------------------------------------------
880 * FillConsoleOutputCharacterA
884 FillConsoleOutputCharacterA(
885 HANDLE hConsoleOutput
,
889 LPDWORD lpNumberOfCharsWritten
892 CSRSS_API_REQUEST Request
;
893 CSRSS_API_REPLY Reply
;
896 Request
.Type
= CSRSS_FILL_OUTPUT
;
897 Request
.Data
.FillOutputRequest
.ConsoleHandle
= hConsoleOutput
;
898 Request
.Data
.FillOutputRequest
.Char
= cCharacter
;
899 Request
.Data
.FillOutputRequest
.Position
= dwWriteCoord
;
900 Request
.Data
.FillOutputRequest
.Length
= nLength
;
901 Status
= CsrClientCallServer( &Request
, &Reply
, sizeof( CSRSS_API_REQUEST
), sizeof( CSRSS_API_REPLY
) );
902 if( !NT_SUCCESS( Status
) || !NT_SUCCESS( Status
= Reply
.Status
) )
904 SetLastErrorByStatus ( Status
);
907 *lpNumberOfCharsWritten
= nLength
;
912 /*--------------------------------------------------------------
913 * FillConsoleOutputCharacterW
917 FillConsoleOutputCharacterW(
918 HANDLE hConsoleOutput
,
922 LPDWORD lpNumberOfCharsWritten
930 /*--------------------------------------------------------------
937 HANDLE hConsoleInput
,
938 PINPUT_RECORD lpBuffer
,
940 LPDWORD lpNumberOfEventsRead
948 /*--------------------------------------------------------------
955 HANDLE hConsoleInput
,
956 PINPUT_RECORD lpBuffer
,
958 LPDWORD lpNumberOfEventsRead
966 /*--------------------------------------------------------------
969 WINBASEAPI BOOL WINAPI
970 ReadConsoleInputA(HANDLE hConsoleInput
,
971 PINPUT_RECORD lpBuffer
,
973 LPDWORD lpNumberOfEventsRead
)
975 CSRSS_API_REQUEST Request
;
976 CSRSS_API_REPLY Reply
;
980 Request
.Type
= CSRSS_READ_INPUT
;
981 Request
.Data
.ReadInputRequest
.ConsoleHandle
= hConsoleInput
;
982 Status
= CsrClientCallServer(&Request
, &Reply
, sizeof(CSRSS_API_REQUEST
),
983 sizeof(CSRSS_API_REPLY
));
984 if (!NT_SUCCESS(Status
) || !NT_SUCCESS(Status
= Reply
.Status
))
986 SetLastErrorByStatus(Status
);
990 while (Status
== STATUS_PENDING
)
992 Status
= NtWaitForSingleObject(Reply
.Data
.ReadInputReply
.Event
, FALSE
,
994 if(!NT_SUCCESS(Status
))
996 SetLastErrorByStatus(Status
);
1000 Request
.Type
= CSRSS_READ_INPUT
;
1001 Request
.Data
.ReadInputRequest
.ConsoleHandle
= hConsoleInput
;
1002 Status
= CsrClientCallServer(&Request
, &Reply
, sizeof(CSRSS_API_REQUEST
),
1003 sizeof(CSRSS_API_REPLY
));
1004 if (!NT_SUCCESS(Status
) || !NT_SUCCESS(Status
= Reply
.Status
))
1006 SetLastErrorByStatus(Status
);
1012 *lpBuffer
= Reply
.Data
.ReadInputReply
.Input
;
1016 while ((NumEventsRead
< nLength
) && (Reply
.Data
.ReadInputReply
.MoreEvents
))
1018 Status
= CsrClientCallServer(&Request
, &Reply
, sizeof(CSRSS_API_REQUEST
),
1019 sizeof(CSRSS_API_REPLY
));
1020 if (!NT_SUCCESS(Status
) || !NT_SUCCESS(Status
= Reply
.Status
))
1022 SetLastErrorByStatus(Status
);
1026 if (Status
== STATUS_PENDING
)
1031 *lpBuffer
= Reply
.Data
.ReadInputReply
.Input
;
1036 *lpNumberOfEventsRead
= NumEventsRead
;
1042 /*--------------------------------------------------------------
1049 HANDLE hConsoleInput
,
1050 PINPUT_RECORD lpBuffer
,
1052 LPDWORD lpNumberOfEventsRead
1060 /*--------------------------------------------------------------
1061 * WriteConsoleInputA
1067 HANDLE hConsoleInput
,
1068 CONST INPUT_RECORD
*lpBuffer
,
1070 LPDWORD lpNumberOfEventsWritten
1078 /*--------------------------------------------------------------
1079 * WriteConsoleInputW
1085 HANDLE hConsoleInput
,
1086 CONST INPUT_RECORD
*lpBuffer
,
1088 LPDWORD lpNumberOfEventsWritten
1096 /*--------------------------------------------------------------
1097 * ReadConsoleOutputA
1103 HANDLE hConsoleOutput
,
1104 PCHAR_INFO lpBuffer
,
1106 COORD dwBufferCoord
,
1107 PSMALL_RECT lpReadRegion
1115 /*--------------------------------------------------------------
1116 * ReadConsoleOutputW
1122 HANDLE hConsoleOutput
,
1123 PCHAR_INFO lpBuffer
,
1125 COORD dwBufferCoord
,
1126 PSMALL_RECT lpReadRegion
1133 /*--------------------------------------------------------------
1134 * WriteConsoleOutputA
1139 WriteConsoleOutputA(
1140 HANDLE hConsoleOutput
,
1141 CONST CHAR_INFO
*lpBuffer
,
1143 COORD dwBufferCoord
,
1144 PSMALL_RECT lpWriteRegion
1147 PCSRSS_API_REQUEST Request
;
1148 CSRSS_API_REPLY Reply
;
1152 Size
= dwBufferSize
.Y
* dwBufferSize
.X
* sizeof(CHAR_INFO
);
1154 Request
= RtlAllocateHeap(GetProcessHeap(), 0, sizeof(CSRSS_API_REQUEST
) + Size
);
1157 SetLastError( ERROR_OUTOFMEMORY
);
1160 Request
->Type
= CSRSS_WRITE_CONSOLE_OUTPUT
;
1161 Request
->Data
.WriteConsoleOutputRequest
.ConsoleHandle
= hConsoleOutput
;
1162 Request
->Data
.WriteConsoleOutputRequest
.BufferSize
= dwBufferSize
;
1163 Request
->Data
.WriteConsoleOutputRequest
.BufferCoord
= dwBufferCoord
;
1164 Request
->Data
.WriteConsoleOutputRequest
.WriteRegion
= *lpWriteRegion
;
1165 RtlCopyMemory(&Request
->Data
.WriteConsoleOutputRequest
.CharInfo
, lpBuffer
, Size
);
1167 Status
= CsrClientCallServer( Request
, &Reply
, sizeof( CSRSS_API_REQUEST
) + Size
, sizeof( CSRSS_API_REPLY
) );
1168 if( !NT_SUCCESS( Status
) || !NT_SUCCESS( Status
= Reply
.Status
) )
1170 RtlFreeHeap( GetProcessHeap(), 0, Request
);
1171 SetLastErrorByStatus ( Status
);
1175 *lpWriteRegion
= Reply
.Data
.WriteConsoleOutputReply
.WriteRegion
;
1181 /*--------------------------------------------------------------
1182 * WriteConsoleOutputW
1187 WriteConsoleOutputW(
1188 HANDLE hConsoleOutput
,
1189 CONST CHAR_INFO
*lpBuffer
,
1191 COORD dwBufferCoord
,
1192 PSMALL_RECT lpWriteRegion
1200 /*--------------------------------------------------------------
1201 * ReadConsoleOutputCharacterA
1206 ReadConsoleOutputCharacterA(
1207 HANDLE hConsoleOutput
,
1211 LPDWORD lpNumberOfCharsRead
1214 SetLastError( ERROR_CALL_NOT_IMPLEMENTED
);
1219 /*--------------------------------------------------------------
1220 * ReadConsoleOutputCharacterW
1225 ReadConsoleOutputCharacterW(
1226 HANDLE hConsoleOutput
,
1230 LPDWORD lpNumberOfCharsRead
1238 /*--------------------------------------------------------------
1239 * ReadConsoleOutputAttribute
1244 ReadConsoleOutputAttribute(
1245 HANDLE hConsoleOutput
,
1249 LPDWORD lpNumberOfAttrsRead
1252 SetLastError( ERROR_CALL_NOT_IMPLEMENTED
);
1257 /*--------------------------------------------------------------
1258 * WriteConsoleOutputCharacterA
1263 WriteConsoleOutputCharacterA(
1264 HANDLE hConsoleOutput
,
1268 LPDWORD lpNumberOfCharsWritten
1271 PCSRSS_API_REQUEST Request
;
1272 CSRSS_API_REPLY Reply
;
1276 Request
= RtlAllocateHeap(GetProcessHeap(),
1278 sizeof(CSRSS_API_REQUEST
) + CSRSS_MAX_WRITE_CONSOLE_OUTPUT_CHAR
);
1281 SetLastError( ERROR_OUTOFMEMORY
);
1284 Request
->Type
= CSRSS_WRITE_CONSOLE_OUTPUT_CHAR
;
1285 Request
->Data
.WriteConsoleOutputCharRequest
.ConsoleHandle
= hConsoleOutput
;
1286 Request
->Data
.WriteConsoleOutputCharRequest
.Coord
= dwWriteCoord
;
1287 if( lpNumberOfCharsWritten
)
1288 *lpNumberOfCharsWritten
= nLength
;
1291 Size
= nLength
> CSRSS_MAX_WRITE_CONSOLE_OUTPUT_CHAR
? CSRSS_MAX_WRITE_CONSOLE_OUTPUT_CHAR
: nLength
;
1292 Request
->Data
.WriteConsoleOutputCharRequest
.Length
= Size
;
1293 memcpy( &Request
->Data
.WriteConsoleOutputCharRequest
.String
[0],
1296 Status
= CsrClientCallServer( Request
, &Reply
, sizeof( CSRSS_API_REQUEST
) + Size
, sizeof( CSRSS_API_REPLY
) );
1297 if( !NT_SUCCESS( Status
) || !NT_SUCCESS( Status
= Reply
.Status
) )
1299 RtlFreeHeap( GetProcessHeap(), 0, Request
);
1300 SetLastErrorByStatus ( Status
);
1304 lpCharacter
+= Size
;
1305 Request
->Data
.WriteConsoleOutputCharRequest
.Coord
= Reply
.Data
.WriteConsoleOutputCharReply
.EndCoord
;
1311 /*--------------------------------------------------------------
1312 * WriteConsoleOutputCharacterW
1317 WriteConsoleOutputCharacterW(
1318 HANDLE hConsoleOutput
,
1319 LPCWSTR lpCharacter
,
1322 LPDWORD lpNumberOfCharsWritten
1331 /*--------------------------------------------------------------
1332 * WriteConsoleOutputAttribute
1337 WriteConsoleOutputAttribute(
1338 HANDLE hConsoleOutput
,
1339 CONST WORD
*lpAttribute
,
1342 LPDWORD lpNumberOfAttrsWritten
1345 PCSRSS_API_REQUEST Request
;
1346 CSRSS_API_REPLY Reply
;
1351 Request
= RtlAllocateHeap(GetProcessHeap(),
1353 sizeof(CSRSS_API_REQUEST
) + CSRSS_MAX_WRITE_CONSOLE_OUTPUT_ATTRIB
);
1356 SetLastError( ERROR_OUTOFMEMORY
);
1359 Request
->Type
= CSRSS_WRITE_CONSOLE_OUTPUT_ATTRIB
;
1360 Request
->Data
.WriteConsoleOutputAttribRequest
.ConsoleHandle
= hConsoleOutput
;
1361 Request
->Data
.WriteConsoleOutputAttribRequest
.Coord
= dwWriteCoord
;
1362 if( lpNumberOfAttrsWritten
)
1363 *lpNumberOfAttrsWritten
= nLength
;
1366 Size
= nLength
> CSRSS_MAX_WRITE_CONSOLE_OUTPUT_ATTRIB
? CSRSS_MAX_WRITE_CONSOLE_OUTPUT_ATTRIB
: nLength
;
1367 Request
->Data
.WriteConsoleOutputAttribRequest
.Length
= Size
;
1368 for( c
= 0; c
< ( Size
* 2 ); c
++ )
1369 Request
->Data
.WriteConsoleOutputAttribRequest
.String
[c
] = (char)lpAttribute
[c
];
1370 Status
= CsrClientCallServer( Request
, &Reply
, sizeof( CSRSS_API_REQUEST
) + (Size
* 2), sizeof( CSRSS_API_REPLY
) );
1371 if( !NT_SUCCESS( Status
) || !NT_SUCCESS( Status
= Reply
.Status
) )
1373 RtlFreeHeap( GetProcessHeap(), 0, Request
);
1374 SetLastErrorByStatus ( Status
);
1378 lpAttribute
+= Size
;
1379 Request
->Data
.WriteConsoleOutputAttribRequest
.Coord
= Reply
.Data
.WriteConsoleOutputAttribReply
.EndCoord
;
1385 /*--------------------------------------------------------------
1386 * FillConsoleOutputAttribute
1391 FillConsoleOutputAttribute(
1392 HANDLE hConsoleOutput
,
1396 LPDWORD lpNumberOfAttrsWritten
1399 CSRSS_API_REQUEST Request
;
1400 CSRSS_API_REPLY Reply
;
1403 Request
.Type
= CSRSS_FILL_OUTPUT_ATTRIB
;
1404 Request
.Data
.FillOutputAttribRequest
.ConsoleHandle
= hConsoleOutput
;
1405 Request
.Data
.FillOutputAttribRequest
.Attribute
= wAttribute
;
1406 Request
.Data
.FillOutputAttribRequest
.Coord
= dwWriteCoord
;
1407 Request
.Data
.FillOutputAttribRequest
.Length
= nLength
;
1408 Status
= CsrClientCallServer( &Request
, &Reply
, sizeof( CSRSS_API_REQUEST
), sizeof( CSRSS_API_REPLY
) );
1409 if( !NT_SUCCESS( Status
) || !NT_SUCCESS( Status
= Reply
.Status
) )
1411 SetLastErrorByStatus ( Status
);
1414 if( lpNumberOfAttrsWritten
)
1415 *lpNumberOfAttrsWritten
= nLength
;
1420 /*--------------------------------------------------------------
1427 HANDLE hConsoleHandle
,
1431 CSRSS_API_REQUEST Request
;
1432 CSRSS_API_REPLY Reply
;
1435 Request
.Type
= CSRSS_GET_MODE
;
1436 Request
.Data
.GetConsoleModeRequest
.ConsoleHandle
= hConsoleHandle
;
1437 Status
= CsrClientCallServer( &Request
, &Reply
, sizeof( CSRSS_API_REQUEST
), sizeof( CSRSS_API_REPLY
) );
1438 if( !NT_SUCCESS( Status
) || !NT_SUCCESS( Status
= Reply
.Status
) )
1440 SetLastErrorByStatus ( Status
);
1443 *lpMode
= Reply
.Data
.GetConsoleModeReply
.ConsoleMode
;
1448 /*--------------------------------------------------------------
1449 * GetNumberOfConsoleInputEvents
1454 GetNumberOfConsoleInputEvents(
1455 HANDLE hConsoleInput
,
1456 LPDWORD lpNumberOfEvents
1464 /*--------------------------------------------------------------
1465 * GetLargestConsoleWindowSize
1470 GetLargestConsoleWindowSize(
1471 HANDLE hConsoleOutput
1475 COORD Coord
= {80,25};
1483 /*--------------------------------------------------------------
1484 * GetConsoleCursorInfo
1489 GetConsoleCursorInfo(
1490 HANDLE hConsoleOutput
,
1491 PCONSOLE_CURSOR_INFO lpConsoleCursorInfo
1494 CSRSS_API_REQUEST Request
;
1495 CSRSS_API_REPLY Reply
;
1498 Request
.Type
= CSRSS_GET_CURSOR_INFO
;
1499 Request
.Data
.GetCursorInfoRequest
.ConsoleHandle
= hConsoleOutput
;
1500 Status
= CsrClientCallServer( &Request
, &Reply
, sizeof( CSRSS_API_REQUEST
), sizeof( CSRSS_API_REPLY
) );
1502 if( !NT_SUCCESS( Status
) || !NT_SUCCESS( Status
= Reply
.Status
) )
1504 SetLastErrorByStatus ( Status
);
1507 *lpConsoleCursorInfo
= Reply
.Data
.GetCursorInfoReply
.Info
;
1512 /*--------------------------------------------------------------
1513 * GetNumberOfConsoleMouseButtons
1518 GetNumberOfConsoleMouseButtons(
1519 LPDWORD lpNumberOfMouseButtons
1527 /*--------------------------------------------------------------
1534 HANDLE hConsoleHandle
,
1538 CSRSS_API_REQUEST Request
;
1539 CSRSS_API_REPLY Reply
;
1542 Request
.Type
= CSRSS_SET_MODE
;
1543 Request
.Data
.SetConsoleModeRequest
.ConsoleHandle
= hConsoleHandle
;
1544 Request
.Data
.SetConsoleModeRequest
.Mode
= dwMode
;
1545 Status
= CsrClientCallServer( &Request
, &Reply
, sizeof( CSRSS_API_REQUEST
), sizeof( CSRSS_API_REPLY
) );
1546 if( !NT_SUCCESS( Status
) || !NT_SUCCESS( Status
= Reply
.Status
) )
1548 SetLastErrorByStatus ( Status
);
1555 /*--------------------------------------------------------------
1556 * SetConsoleActiveScreenBuffer
1561 SetConsoleActiveScreenBuffer(
1562 HANDLE hConsoleOutput
1565 CSRSS_API_REQUEST Request
;
1566 CSRSS_API_REPLY Reply
;
1569 Request
.Type
= CSRSS_SET_SCREEN_BUFFER
;
1570 Request
.Data
.SetActiveScreenBufferRequest
.OutputHandle
= hConsoleOutput
;
1571 Status
= CsrClientCallServer( &Request
, &Reply
, sizeof( CSRSS_API_REQUEST
), sizeof( CSRSS_API_REPLY
) );
1572 if( !NT_SUCCESS( Status
) || !NT_SUCCESS( Status
= Reply
.Status
) )
1574 SetLastErrorByStatus ( Status
);
1581 /*--------------------------------------------------------------
1582 * FlushConsoleInputBuffer
1587 FlushConsoleInputBuffer(
1588 HANDLE hConsoleInput
1591 CSRSS_API_REQUEST Request
;
1592 CSRSS_API_REPLY Reply
;
1595 Request
.Type
= CSRSS_FLUSH_INPUT_BUFFER
;
1596 Request
.Data
.FlushInputBufferRequest
.ConsoleInput
= hConsoleInput
;
1597 Status
= CsrClientCallServer( &Request
, &Reply
, sizeof( CSRSS_API_REQUEST
), sizeof( CSRSS_API_REPLY
) );
1598 if( !NT_SUCCESS( Status
) || !NT_SUCCESS( Status
= Reply
.Status
) )
1600 SetLastErrorByStatus ( Status
);
1607 /*--------------------------------------------------------------
1608 * SetConsoleScreenBufferSize
1613 SetConsoleScreenBufferSize(
1614 HANDLE hConsoleOutput
,
1622 /*--------------------------------------------------------------
1623 * SetConsoleCursorInfo
1628 SetConsoleCursorInfo(
1629 HANDLE hConsoleOutput
,
1630 CONST CONSOLE_CURSOR_INFO
*lpConsoleCursorInfo
1633 CSRSS_API_REQUEST Request
;
1634 CSRSS_API_REPLY Reply
;
1637 Request
.Type
= CSRSS_SET_CURSOR_INFO
;
1638 Request
.Data
.SetCursorInfoRequest
.ConsoleHandle
= hConsoleOutput
;
1639 Request
.Data
.SetCursorInfoRequest
.Info
= *lpConsoleCursorInfo
;
1640 Status
= CsrClientCallServer( &Request
, &Reply
, sizeof( CSRSS_API_REQUEST
), sizeof( CSRSS_API_REPLY
) );
1642 if( !NT_SUCCESS( Status
) || !NT_SUCCESS( Status
= Reply
.Status
) )
1644 SetLastErrorByStatus ( Status
);
1651 /*--------------------------------------------------------------
1652 * ScrollConsoleScreenBufferA
1657 ScrollConsoleScreenBufferA(
1658 HANDLE hConsoleOutput
,
1659 CONST SMALL_RECT
*lpScrollRectangle
,
1660 CONST SMALL_RECT
*lpClipRectangle
,
1661 COORD dwDestinationOrigin
,
1662 CONST CHAR_INFO
*lpFill
1665 CSRSS_API_REQUEST Request
;
1666 CSRSS_API_REPLY Reply
;
1669 Request
.Type
= CSRSS_SCROLL_CONSOLE_SCREEN_BUFFER
;
1670 Request
.Data
.ScrollConsoleScreenBufferRequest
.ConsoleHandle
= hConsoleOutput
;
1671 Request
.Data
.ScrollConsoleScreenBufferRequest
.ScrollRectangle
= *lpScrollRectangle
;
1673 if (lpClipRectangle
!= NULL
)
1675 Request
.Data
.ScrollConsoleScreenBufferRequest
.UseClipRectangle
= TRUE
;
1676 Request
.Data
.ScrollConsoleScreenBufferRequest
.ClipRectangle
= *lpClipRectangle
;
1680 Request
.Data
.ScrollConsoleScreenBufferRequest
.UseClipRectangle
= FALSE
;
1683 Request
.Data
.ScrollConsoleScreenBufferRequest
.DestinationOrigin
= dwDestinationOrigin
;
1684 Request
.Data
.ScrollConsoleScreenBufferRequest
.Fill
= *lpFill
;
1685 Status
= CsrClientCallServer( &Request
, &Reply
, sizeof( CSRSS_API_REQUEST
), sizeof( CSRSS_API_REPLY
) );
1687 if( !NT_SUCCESS( Status
) || !NT_SUCCESS( Status
= Reply
.Status
) )
1689 SetLastErrorByStatus ( Status
);
1696 /*--------------------------------------------------------------
1697 * ScrollConsoleScreenBufferW
1702 ScrollConsoleScreenBufferW(
1703 HANDLE hConsoleOutput
,
1704 CONST SMALL_RECT
*lpScrollRectangle
,
1705 CONST SMALL_RECT
*lpClipRectangle
,
1706 COORD dwDestinationOrigin
,
1707 CONST CHAR_INFO
*lpFill
1715 /*--------------------------------------------------------------
1716 * SetConsoleWindowInfo
1721 SetConsoleWindowInfo(
1722 HANDLE hConsoleOutput
,
1724 CONST SMALL_RECT
*lpConsoleWindow
1732 /*--------------------------------------------------------------
1733 * SetConsoleTextAttribute
1738 SetConsoleTextAttribute(
1739 HANDLE hConsoleOutput
,
1743 CSRSS_API_REQUEST Request
;
1744 CSRSS_API_REPLY Reply
;
1747 Request
.Type
= CSRSS_SET_ATTRIB
;
1748 Request
.Data
.SetAttribRequest
.ConsoleHandle
= hConsoleOutput
;
1749 Request
.Data
.SetAttribRequest
.Attrib
= wAttributes
;
1750 Status
= CsrClientCallServer( &Request
, &Reply
, sizeof( CSRSS_API_REQUEST
), sizeof( CSRSS_API_REPLY
) );
1751 if( !NT_SUCCESS( Status
) || !NT_SUCCESS( Status
= Reply
.Status
) )
1753 SetLastErrorByStatus ( Status
);
1760 AddConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine
)
1762 if (HandlerRoutine
== NULL
)
1764 IgnoreCtrlEvents
= TRUE
;
1771 RtlReAllocateHeap(RtlGetProcessHeap(),
1773 (PVOID
)CtrlHandlers
,
1774 NrCtrlHandlers
* sizeof(PHANDLER_ROUTINE
));
1775 if (CtrlHandlers
== NULL
)
1777 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1780 CtrlHandlers
[NrCtrlHandlers
- 1] = HandlerRoutine
;
1786 RemoveConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine
)
1790 if (HandlerRoutine
== NULL
)
1792 IgnoreCtrlEvents
= FALSE
;
1797 for (i
= 0; i
< NrCtrlHandlers
; i
++)
1799 if (CtrlHandlers
[i
] == HandlerRoutine
)
1801 CtrlHandlers
[i
] = CtrlHandlers
[NrCtrlHandlers
- 1];
1804 RtlReAllocateHeap(RtlGetProcessHeap(),
1806 (PVOID
)CtrlHandlers
,
1807 NrCtrlHandlers
* sizeof(PHANDLER_ROUTINE
));
1815 WINBASEAPI BOOL WINAPI
1816 SetConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine
,
1821 RtlEnterCriticalSection(&DllLock
);
1824 Ret
= AddConsoleCtrlHandler(HandlerRoutine
);
1828 Ret
= RemoveConsoleCtrlHandler(HandlerRoutine
);
1830 RtlLeaveCriticalSection(&DllLock
);
1835 /*--------------------------------------------------------------
1836 * GenerateConsoleCtrlEvent
1838 WINBASEAPI BOOL WINAPI
1839 GenerateConsoleCtrlEvent(
1841 DWORD dwProcessGroupId
1849 /*--------------------------------------------------------------
1852 #define MAX_CONSOLE_TITLE_LENGTH 80
1858 LPWSTR lpConsoleTitle
,
1863 CSRSS_API_REQUEST quest
;
1864 CSRSS_API_REPLY ply
;
1869 Re
.quest
.Type
= CSRSS_GET_TITLE
;
1870 Re
.quest
.Data
.GetTitleRequest
.ConsoleHandle
=
1871 GetStdHandle (STD_INPUT_HANDLE
);
1874 Status
= CsrClientCallServer (
1877 (sizeof (CSRSS_GET_TITLE_REQUEST
) +
1878 sizeof (LPC_MESSAGE_HEADER
) +
1880 sizeof (CSRSS_API_REPLY
)
1882 if ( !NT_SUCCESS(Status
)
1883 || !NT_SUCCESS (Status
= Re
.ply
.Status
)
1886 SetLastErrorByStatus (Status
);
1890 /* Convert size in characters to size in bytes */
1891 nSize
= sizeof (WCHAR
) * nSize
;
1893 /* Unmarshall data */
1894 if (nSize
< Re
.ply
.Data
.GetTitleReply
.Length
)
1896 DbgPrint ("%s: ret=%d\n", __FUNCTION__
, Re
.ply
.Data
.GetTitleReply
.Length
);
1897 nSize
/= sizeof (WCHAR
);
1902 Re
.ply
.Data
.GetTitleReply
.Title
,
1906 lpConsoleTitle
[nSize
--] = L
'\0';
1911 nSize
= Re
.ply
.Data
.GetTitleReply
.Length
/ sizeof (WCHAR
);
1912 wcscpy (lpConsoleTitle
, Re
.ply
.Data
.GetTitleReply
.Title
);
1919 /*--------------------------------------------------------------
1928 LPSTR lpConsoleTitle
,
1932 wchar_t WideTitle
[MAX_CONSOLE_TITLE_LENGTH
];
1933 DWORD nWideTitle
= sizeof WideTitle
;
1936 if (!lpConsoleTitle
|| !nSize
) return 0;
1937 nWideTitle
= GetConsoleTitleW( (LPWSTR
) WideTitle
, nWideTitle
);
1938 if (!nWideTitle
) return 0;
1940 if ( (nWritten
= WideCharToMultiByte(
1941 CP_ACP
, // ANSI code page
1942 0, // performance and mapping flags
1943 (LPWSTR
) WideTitle
, // address of wide-character string
1944 nWideTitle
, // number of characters in string
1945 lpConsoleTitle
, // address of buffer for new string
1946 nSize
, // size of buffer
1951 lpConsoleTitle
[nWritten
] = '\0';
1959 /*--------------------------------------------------------------
1966 LPCWSTR lpConsoleTitle
1969 PCSRSS_API_REQUEST Request
;
1970 CSRSS_API_REPLY Reply
;
1974 Request
= RtlAllocateHeap(GetProcessHeap(),
1976 sizeof(CSRSS_API_REQUEST
) + CSRSS_MAX_SET_TITLE_REQUEST
);
1977 if (Request
== NULL
)
1982 Request
->Type
= CSRSS_SET_TITLE
;
1983 Request
->Data
.SetTitleRequest
.Console
= GetStdHandle( STD_INPUT_HANDLE
);
1985 for( c
= 0; lpConsoleTitle
[c
] && c
< CSRSS_MAX_TITLE_LENGTH
; c
++ )
1986 Request
->Data
.SetTitleRequest
.Title
[c
] = lpConsoleTitle
[c
];
1988 Request
->Data
.SetTitleRequest
.Title
[c
] = 0;
1989 Request
->Data
.SetTitleRequest
.Length
= c
;
1990 Status
= CsrClientCallServer(Request
,
1992 sizeof(CSRSS_SET_TITLE_REQUEST
) +
1994 sizeof( LPC_MESSAGE_HEADER
) +
1996 sizeof(CSRSS_API_REPLY
));
1998 if (!NT_SUCCESS(Status
) || !NT_SUCCESS( Status
= Reply
.Status
) )
2000 RtlFreeHeap( GetProcessHeap(), 0, Request
);
2001 SetLastErrorByStatus (Status
);
2004 RtlFreeHeap( GetProcessHeap(), 0, Request
);
2009 /*--------------------------------------------------------------
2018 LPCSTR lpConsoleTitle
2021 PCSRSS_API_REQUEST Request
;
2022 CSRSS_API_REPLY Reply
;
2026 Request
= RtlAllocateHeap(GetProcessHeap(),
2028 sizeof(CSRSS_API_REQUEST
) + CSRSS_MAX_SET_TITLE_REQUEST
);
2029 if (Request
== NULL
)
2034 Request
->Type
= CSRSS_SET_TITLE
;
2035 Request
->Data
.SetTitleRequest
.Console
= GetStdHandle( STD_INPUT_HANDLE
);
2037 for( c
= 0; lpConsoleTitle
[c
] && c
< CSRSS_MAX_TITLE_LENGTH
; c
++ )
2038 Request
->Data
.SetTitleRequest
.Title
[c
] = lpConsoleTitle
[c
];
2040 Request
->Data
.SetTitleRequest
.Title
[c
] = 0;
2041 Request
->Data
.SetTitleRequest
.Length
= c
;
2042 Status
= CsrClientCallServer(Request
,
2044 sizeof(CSRSS_SET_TITLE_REQUEST
) +
2046 sizeof( LPC_MESSAGE_HEADER
) +
2048 sizeof(CSRSS_API_REPLY
));
2050 if (!NT_SUCCESS(Status
) || !NT_SUCCESS( Status
= Reply
.Status
) )
2052 RtlFreeHeap( GetProcessHeap(), 0, Request
);
2053 SetLastErrorByStatus (Status
);
2056 RtlFreeHeap( GetProcessHeap(), 0, Request
);
2061 /*--------------------------------------------------------------
2068 HANDLE hConsoleInput
,
2070 DWORD nNumberOfCharsToRead
,
2071 LPDWORD lpNumberOfCharsRead
,
2080 /*--------------------------------------------------------------
2087 HANDLE hConsoleOutput
,
2088 CONST VOID
*lpBuffer
,
2089 DWORD nNumberOfCharsToWrite
,
2090 LPDWORD lpNumberOfCharsWritten
,
2095 PCSRSS_API_REQUEST Request
;
2096 CSRSS_API_REPLY Reply
;
2099 Request
= RtlAllocateHeap(GetProcessHeap(),
2101 sizeof(CSRSS_API_REQUEST
) + nNumberOfCharsToWrite
* sizeof(WCHAR
));
2102 if (Request
== NULL
)
2107 Request
->Type
= CSRSS_WRITE_CONSOLE
;
2108 Request
->Data
.WriteConsoleRequest
.ConsoleHandle
= hConsoleOutput
;
2109 Request
->Data
.WriteConsoleRequest
.NrCharactersToWrite
=
2110 nNumberOfCharsToWrite
;
2111 // DbgPrint("nNumberOfCharsToWrite %d\n", nNumberOfCharsToWrite);
2112 // DbgPrint("Buffer %s\n", Request->Data.WriteConsoleRequest.Buffer);
2113 memcpy(Request
->Data
.WriteConsoleRequest
.Buffer
,
2115 nNumberOfCharsToWrite
* sizeof(WCHAR
));
2117 Status
= CsrClientCallServer(Request
,
2119 sizeof(CSRSS_API_REQUEST
) +
2120 nNumberOfCharsToWrite
,
2121 sizeof(CSRSS_API_REPLY
));
2123 RtlFreeHeap(GetProcessHeap(),
2127 if (!NT_SUCCESS(Status
))
2132 if (lpNumberOfCharsWritten
!= NULL
)
2134 *lpNumberOfCharsWritten
=
2135 Reply
.Data
.WriteConsoleReply
.NrCharactersWritten
;
2144 /*--------------------------------------------------------------
2145 * CreateConsoleScreenBuffer
2150 CreateConsoleScreenBuffer(
2151 DWORD dwDesiredAccess
,
2153 CONST SECURITY_ATTRIBUTES
*lpSecurityAttributes
,
2155 LPVOID lpScreenBufferData
2158 // FIXME: don't ignore access, share mode, and security
2159 CSRSS_API_REQUEST Request
;
2160 CSRSS_API_REPLY Reply
;
2163 Request
.Type
= CSRSS_CREATE_SCREEN_BUFFER
;
2164 Status
= CsrClientCallServer( &Request
, &Reply
, sizeof( CSRSS_API_REQUEST
), sizeof( CSRSS_API_REPLY
) );
2165 if( !NT_SUCCESS( Status
) || !NT_SUCCESS( Status
= Reply
.Status
) )
2167 SetLastErrorByStatus ( Status
);
2170 return Reply
.Data
.CreateScreenBufferReply
.OutputHandle
;
2174 /*--------------------------------------------------------------
2180 GetConsoleCP( VOID
)
2183 return CP_OEMCP
; /* FIXME */
2187 /*--------------------------------------------------------------
2202 /*--------------------------------------------------------------
2203 * GetConsoleOutputCP
2208 GetConsoleOutputCP( VOID
)
2211 return 0; /* FIXME */
2215 /*--------------------------------------------------------------
2216 * SetConsoleOutputCP