KERNEL32.GetConsoleWindow implemented
[reactos.git] / reactos / lib / kernel32 / misc / console.c
1 /* $Id: console.c,v 1.58 2003/06/19 19:38:26 ea Exp $
2 *
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
7 * PROGRAMMER: ???
8 * UPDATE HISTORY:
9 * 199901?? ?? Created
10 * 19990204 EA SetConsoleTitleA
11 * 19990306 EA Stubs
12 */
13
14 /* INCLUDES ******************************************************************/
15
16 #include <k32.h>
17
18 #define NDEBUG
19 #include <kernel32/kernel32.h>
20
21 /* GLOBALS *******************************************************************/
22
23 static BOOL IgnoreCtrlEvents = FALSE;
24 static ULONG NrCtrlHandlers = 0;
25 static PHANDLER_ROUTINE* CtrlHandlers = NULL;
26
27 /* FUNCTIONS *****************************************************************/
28
29 BOOL STDCALL
30 AddConsoleAliasA (LPSTR Source,
31 LPSTR Target,
32 LPSTR ExeName)
33 {
34 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
35 return FALSE;
36 }
37
38 BOOL STDCALL
39 AddConsoleAliasW (LPWSTR Source,
40 LPWSTR Target,
41 LPWSTR ExeName)
42 {
43 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
44 return FALSE;
45 }
46
47 BOOL STDCALL
48 ConsoleMenuControl (HANDLE hConsole,
49 DWORD Unknown1,
50 DWORD Unknown2)
51 /*
52 * Undocumented
53 */
54 {
55 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
56 return FALSE;
57 }
58
59 HANDLE STDCALL
60 DuplicateConsoleHandle (HANDLE hConsole,
61 DWORD dwDesiredAccess,
62 BOOL bInheritHandle,
63 DWORD dwOptions)
64 {
65 CSRSS_API_REQUEST Request;
66 CSRSS_API_REPLY Reply;
67 NTSTATUS Status;
68
69 if (IsConsoleHandle (hConsole) == FALSE)
70 {
71 SetLastError (ERROR_INVALID_PARAMETER);
72 return INVALID_HANDLE_VALUE;
73 }
74
75 Request.Type = CSRSS_DUPLICATE_HANDLE;
76 Request.Data.DuplicateHandleRequest.Handle = hConsole;
77 Request.Data.DuplicateHandleRequest.ProcessId = GetCurrentProcessId();
78 Status = CsrClientCallServer(&Request,
79 &Reply,
80 sizeof(CSRSS_API_REQUEST),
81 sizeof(CSRSS_API_REPLY));
82 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status=Reply.Status))
83 {
84 SetLastErrorByStatus(Status);
85 return INVALID_HANDLE_VALUE;
86 }
87 return Reply.Data.DuplicateHandleReply.Handle;
88 }
89
90 DWORD STDCALL
91 ExpungeConsoleCommandHistoryW (DWORD Unknown0)
92 /*
93 * Undocumented
94 */
95 {
96 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
97 return 0;
98 }
99
100
101 DWORD STDCALL
102 ExpungeConsoleCommandHistoryA (DWORD Unknown0)
103 /*
104 * Undocumented
105 */
106 {
107 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
108 return 0;
109 }
110
111 DWORD STDCALL
112 GetConsoleAliasW (DWORD Unknown0,
113 DWORD Unknown1,
114 DWORD Unknown2,
115 DWORD Unknown3)
116 /*
117 * Undocumented
118 */
119 {
120 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
121 return 0;
122 }
123
124
125 DWORD STDCALL
126 GetConsoleAliasA (DWORD Unknown0,
127 DWORD Unknown1,
128 DWORD Unknown2,
129 DWORD Unknown3)
130 /*
131 * Undocumented
132 */
133 {
134 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
135 return 0;
136 }
137
138 DWORD STDCALL
139 GetConsoleAliasExesW (DWORD Unknown0,
140 DWORD Unknown1)
141 /*
142 * Undocumented
143 */
144 {
145 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
146 return 0;
147 }
148
149
150
151 DWORD STDCALL
152 GetConsoleAliasExesA (DWORD Unknown0,
153 DWORD Unknown1)
154 /*
155 * Undocumented
156 */
157 {
158 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
159 return 0;
160 }
161
162
163
164 DWORD STDCALL
165 GetConsoleAliasExesLengthA (VOID)
166 /*
167 * Undocumented
168 */
169 {
170 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
171 return 0;
172 }
173
174 DWORD STDCALL
175 GetConsoleAliasExesLengthW (VOID)
176 /*
177 * Undocumented
178 */
179 {
180 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
181 return 0;
182 }
183
184 DWORD STDCALL
185 GetConsoleAliasesW (DWORD Unknown0,
186 DWORD Unknown1,
187 DWORD Unknown2)
188 /*
189 * Undocumented
190 */
191 {
192 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
193 return 0;
194 }
195
196 DWORD STDCALL
197 GetConsoleAliasesA (DWORD Unknown0,
198 DWORD Unknown1,
199 DWORD Unknown2)
200 /*
201 * Undocumented
202 */
203 {
204 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
205 return 0;
206 }
207
208 DWORD STDCALL
209 GetConsoleAliasesLengthW (DWORD Unknown0)
210 /*
211 * Undocumented
212 */
213 {
214 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
215 return 0;
216 }
217
218 DWORD STDCALL
219 GetConsoleAliasesLengthA (DWORD Unknown0)
220 /*
221 * Undocumented
222 */
223 {
224 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
225 return 0;
226 }
227
228 DWORD STDCALL
229 GetConsoleCommandHistoryW (DWORD Unknown0,
230 DWORD Unknown1,
231 DWORD Unknown2)
232 /*
233 * Undocumented
234 */
235 {
236 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
237 return 0;
238 }
239
240 DWORD STDCALL
241 GetConsoleCommandHistoryA (DWORD Unknown0,
242 DWORD Unknown1,
243 DWORD Unknown2)
244 /*
245 * Undocumented
246 */
247 {
248 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
249 return 0;
250 }
251
252 DWORD STDCALL
253 GetConsoleCommandHistoryLengthW (DWORD Unknown0)
254 /*
255 * Undocumented
256 */
257 {
258 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
259 return 0;
260 }
261
262 DWORD STDCALL
263 GetConsoleCommandHistoryLengthA (DWORD Unknown0)
264 /*
265 * Undocumented
266 */
267 {
268 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
269 return 0;
270 }
271
272 DWORD STDCALL
273 GetConsoleDisplayMode (LPDWORD lpdwMode)
274 /*
275 * FUNCTION: Get the console display mode
276 * ARGUMENTS:
277 * lpdwMode - Address of variable that receives the current value
278 * of display mode
279 * STATUS: Undocumented
280 */
281 {
282 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
283 return 0;
284 }
285
286 DWORD STDCALL
287 GetConsoleFontInfo (DWORD Unknown0,
288 DWORD Unknown1,
289 DWORD Unknown2,
290 DWORD Unknown3)
291 /*
292 * Undocumented
293 */
294 {
295 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
296 return 0;
297 }
298
299 DWORD STDCALL
300 GetConsoleFontSize(HANDLE hConsoleOutput,
301 DWORD nFont)
302 {
303 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
304 return 0;
305 }
306
307 DWORD STDCALL
308 GetConsoleHardwareState (HANDLE hConsole,
309 DWORD Flags,
310 PDWORD State)
311 /*
312 * Undocumented
313 */
314 {
315 CSRSS_API_REQUEST Request;
316 CSRSS_API_REPLY Reply;
317 NTSTATUS Status;
318
319 Request.Type = CSRSS_SETGET_CONSOLE_HW_STATE;
320 Request.Data.ConsoleHardwareStateRequest.ConsoleHandle = hConsole;
321 Request.Data.ConsoleHardwareStateRequest.SetGet = CONSOLE_HARDWARE_STATE_GET;
322
323 Status = CsrClientCallServer(& Request,
324 & Reply,
325 sizeof(CSRSS_API_REQUEST),
326 sizeof(CSRSS_API_REPLY));
327 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Reply.Status))
328 {
329 SetLastErrorByStatus(Status);
330 return FALSE;
331 }
332 *State = Reply.Data.ConsoleHardwareStateReply.State;
333 return TRUE;
334 }
335
336 DWORD STDCALL
337 GetConsoleInputWaitHandle (VOID)
338 /*
339 * Undocumented
340 */
341 {
342 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
343 return FALSE;
344 }
345
346 DWORD STDCALL
347 GetCurrentConsoleFont(HANDLE hConsoleOutput,
348 BOOL bMaximumWindow,
349 PCONSOLE_FONT_INFO lpConsoleCurrentFont)
350 {
351 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
352 return 0;
353 }
354
355 ULONG STDCALL
356 GetNumberOfConsoleFonts (VOID)
357 /*
358 * Undocumented
359 */
360 {
361 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
362 return 1; /* FIXME: call csrss.exe */
363 }
364
365 DWORD STDCALL
366 InvalidateConsoleDIBits (DWORD Unknown0,
367 DWORD Unknown1)
368 /*
369 * Undocumented
370 */
371 {
372 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
373 return 0;
374 }
375
376 HANDLE STDCALL
377 OpenConsoleW (LPWSTR wsName,
378 DWORD dwDesiredAccess,
379 BOOL bInheritHandle,
380 DWORD dwCreationDistribution)
381 /*
382 * Undocumented
383 */
384 {
385 CSRSS_API_REQUEST Request;
386 CSRSS_API_REPLY Reply;
387 PHANDLE phConsole = NULL;
388 NTSTATUS Status = STATUS_SUCCESS;
389
390
391 if(0 == _wcsicmp(wsName, L"CONIN$"))
392 {
393 Request.Type = CSRSS_GET_INPUT_HANDLE;
394 phConsole = & Reply.Data.GetInputHandleReply.InputHandle;
395 }
396 else if (0 == _wcsicmp(wsName, L"CONOUT$"))
397 {
398 Request.Type = CSRSS_GET_OUTPUT_HANDLE;
399 phConsole = & Reply.Data.GetOutputHandleReply.OutputHandle;
400 }
401 else
402 {
403 SetLastError(ERROR_INVALID_PARAMETER);
404 return(INVALID_HANDLE_VALUE);
405 }
406 if ((GENERIC_READ|GENERIC_WRITE) != dwDesiredAccess)
407 {
408 SetLastError(ERROR_INVALID_PARAMETER);
409 return(INVALID_HANDLE_VALUE);
410 }
411 if (OPEN_EXISTING != dwCreationDistribution)
412 {
413 SetLastError(ERROR_INVALID_PARAMETER);
414 return(INVALID_HANDLE_VALUE);
415 }
416 Status = CsrClientCallServer(& Request,
417 & Reply,
418 sizeof(CSRSS_API_REQUEST),
419 sizeof(CSRSS_API_REPLY));
420 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Reply.Status))
421 {
422 SetLastErrorByStatus(Status);
423 return INVALID_HANDLE_VALUE;
424 }
425 return(*phConsole);
426 }
427
428 WINBOOL STDCALL
429 SetConsoleCommandHistoryMode (DWORD dwMode)
430 /*
431 * Undocumented
432 */
433 {
434 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
435 return FALSE;
436 }
437
438 WINBOOL STDCALL
439 SetConsoleCursor (DWORD Unknown0,
440 DWORD Unknown1)
441 /*
442 * Undocumented
443 */
444 {
445 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
446 return FALSE;
447 }
448
449 WINBOOL STDCALL
450 SetConsoleDisplayMode (HANDLE hOut,
451 DWORD dwNewMode,
452 LPDWORD lpdwOldMode)
453 /*
454 * FUNCTION: Set the console display mode.
455 * ARGUMENTS:
456 * hOut - Standard output handle.
457 * dwNewMode - New mode.
458 * lpdwOldMode - Address of a variable that receives the old mode.
459 */
460 {
461 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
462 return FALSE;
463 }
464
465 WINBOOL STDCALL
466 SetConsoleFont (DWORD Unknown0,
467 DWORD Unknown1)
468 /*
469 * Undocumented
470 */
471 {
472 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
473 return FALSE;
474 }
475
476 WINBOOL STDCALL
477 SetConsoleHardwareState (HANDLE hConsole,
478 DWORD Flags,
479 DWORD State)
480 /*
481 * Undocumented
482 */
483 {
484 CSRSS_API_REQUEST Request;
485 CSRSS_API_REPLY Reply;
486 NTSTATUS Status;
487
488 Request.Type = CSRSS_SETGET_CONSOLE_HW_STATE;
489 Request.Data.ConsoleHardwareStateRequest.ConsoleHandle = hConsole;
490 Request.Data.ConsoleHardwareStateRequest.SetGet = CONSOLE_HARDWARE_STATE_SET;
491 Request.Data.ConsoleHardwareStateRequest.State = State;
492
493 Status = CsrClientCallServer(& Request,
494 & Reply,
495 sizeof(CSRSS_API_REQUEST),
496 sizeof(CSRSS_API_REPLY));
497 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Reply.Status))
498 {
499 SetLastErrorByStatus(Status);
500 return FALSE;
501 }
502 return TRUE;
503 }
504
505 WINBOOL STDCALL
506 SetConsoleKeyShortcuts (DWORD Unknown0,
507 DWORD Unknown1,
508 DWORD Unknown2,
509 DWORD Unknown3)
510 /*
511 * Undocumented
512 */
513 {
514 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
515 return FALSE;
516 }
517
518 WINBOOL STDCALL
519 SetConsoleMaximumWindowSize (DWORD Unknown0,
520 DWORD Unknown1)
521 /*
522 * Undocumented
523 */
524 {
525 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
526 return FALSE;
527 }
528
529 WINBOOL STDCALL
530 SetConsoleMenuClose (DWORD Unknown0)
531 /*
532 * Undocumented
533 */
534 {
535 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
536 return FALSE;
537 }
538
539 WINBOOL STDCALL
540 SetConsoleNumberOfCommandsA (DWORD Unknown0,
541 DWORD Unknown1)
542 /*
543 * Undocumented
544 */
545 {
546 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
547 return FALSE;
548 }
549
550 WINBOOL STDCALL
551 SetConsoleNumberOfCommandsW (DWORD Unknown0,
552 DWORD Unknown1)
553 /*
554 * Undocumented
555 */
556 {
557 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
558 return FALSE;
559 }
560
561 WINBOOL STDCALL
562 SetConsolePalette (DWORD Unknown0,
563 DWORD Unknown1,
564 DWORD Unknown2)
565 /*
566 * Undocumented
567 */
568 {
569 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
570 return FALSE;
571 }
572
573 WINBOOL STDCALL
574 SetLastConsoleEventActive (VOID)
575 /*
576 * Undocumented
577 */
578 {
579 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
580 return FALSE;
581 }
582
583 DWORD STDCALL
584 ShowConsoleCursor (DWORD Unknown0,
585 DWORD Unknown1)
586 /*
587 * Undocumented
588 */
589 {
590 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
591 return 0;
592 }
593
594
595 /*
596 * FUNCTION: Checks whether the given handle is a valid console handle.
597 * ARGUMENTS:
598 * Handle - Handle to be checked
599 * RETURNS:
600 * TRUE: Handle is a valid console handle
601 * FALSE: Handle is not a valid console handle.
602 * STATUS: Officially undocumented
603 */
604 BOOL STDCALL
605 VerifyConsoleIoHandle(HANDLE Handle)
606 {
607 CSRSS_API_REQUEST Request;
608 CSRSS_API_REPLY Reply;
609 NTSTATUS Status;
610
611 Request.Type = CSRSS_VERIFY_HANDLE;
612 Request.Data.VerifyHandleRequest.Handle = Handle;
613 Status = CsrClientCallServer(&Request,
614 &Reply,
615 sizeof(CSRSS_API_REQUEST),
616 sizeof(CSRSS_API_REPLY));
617 if (!NT_SUCCESS(Status))
618 {
619 SetLastErrorByStatus(Status);
620 return FALSE;
621 }
622
623 return (BOOL)NT_SUCCESS(Reply.Status);
624 }
625
626
627 DWORD STDCALL
628 WriteConsoleInputVDMA (DWORD Unknown0,
629 DWORD Unknown1,
630 DWORD Unknown2,
631 DWORD Unknown3)
632 {
633 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
634 return 0;
635 }
636
637 DWORD STDCALL
638 WriteConsoleInputVDMW (DWORD Unknown0,
639 DWORD Unknown1,
640 DWORD Unknown2,
641 DWORD Unknown3)
642 {
643 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
644 return 0;
645 }
646
647 WINBOOL STDCALL
648 CloseConsoleHandle(HANDLE Handle)
649 /*
650 * Undocumented
651 */
652 {
653 CSRSS_API_REQUEST Request;
654 CSRSS_API_REPLY Reply;
655 NTSTATUS Status;
656
657 if (IsConsoleHandle (Handle) == FALSE)
658 {
659 SetLastError (ERROR_INVALID_PARAMETER);
660 return FALSE;
661 }
662
663 Request.Type = CSRSS_CLOSE_HANDLE;
664 Request.Data.CloseHandleRequest.Handle = Handle;
665 Status = CsrClientCallServer(&Request,
666 &Reply,
667 sizeof(CSRSS_API_REQUEST),
668 sizeof(CSRSS_API_REPLY));
669 if (!NT_SUCCESS(Status))
670 {
671 SetLastErrorByStatus(Status);
672 return FALSE;
673 }
674
675 return TRUE;
676 }
677
678
679 BOOLEAN STDCALL
680 IsConsoleHandle(HANDLE Handle)
681 {
682 if ((((ULONG)Handle) & 0x10000003) == 0x3)
683 {
684 return(TRUE);
685 }
686 return(FALSE);
687 }
688
689 HANDLE STDCALL
690 GetStdHandle(DWORD nStdHandle)
691 /*
692 * FUNCTION: Get a handle for the standard input, standard output
693 * and a standard error device.
694 * ARGUMENTS:
695 * nStdHandle - Specifies the device for which to return the handle.
696 * RETURNS: If the function succeeds, the return value is the handle
697 * of the specified device. Otherwise the value is INVALID_HANDLE_VALUE.
698 */
699 {
700 PRTL_USER_PROCESS_PARAMETERS Ppb;
701
702 Ppb = NtCurrentPeb()->ProcessParameters;
703 switch (nStdHandle)
704 {
705 case STD_INPUT_HANDLE:
706 return Ppb->hStdInput;
707
708 case STD_OUTPUT_HANDLE:
709 return Ppb->hStdOutput;
710
711 case STD_ERROR_HANDLE:
712 return Ppb->hStdError;
713 }
714
715 SetLastError (ERROR_INVALID_PARAMETER);
716 return INVALID_HANDLE_VALUE;
717 }
718
719 WINBASEAPI BOOL WINAPI
720 SetStdHandle(DWORD nStdHandle,
721 HANDLE hHandle)
722 /*
723 * FUNCTION: Set the handle for the standard input, standard output or
724 * the standard error device.
725 * ARGUMENTS:
726 * nStdHandle - Specifies the handle to be set.
727 * hHandle - The handle to set.
728 * RETURNS: TRUE if the function succeeds, FALSE otherwise.
729 */
730 {
731 PRTL_USER_PROCESS_PARAMETERS Ppb;
732
733 Ppb = NtCurrentPeb()->ProcessParameters;
734
735 /* More checking needed? */
736 if (hHandle == INVALID_HANDLE_VALUE)
737 {
738 SetLastError (ERROR_INVALID_HANDLE);
739 return FALSE;
740 }
741
742 SetLastError(ERROR_SUCCESS); /* OK */
743
744 switch (nStdHandle)
745 {
746 case STD_INPUT_HANDLE:
747 Ppb->hStdInput = hHandle;
748 return TRUE;
749
750 case STD_OUTPUT_HANDLE:
751 Ppb->hStdOutput = hHandle;
752 return TRUE;
753
754 case STD_ERROR_HANDLE:
755 Ppb->hStdError = hHandle;
756 return TRUE;
757 }
758
759 SetLastError (ERROR_INVALID_PARAMETER);
760 return FALSE;
761 }
762
763
764 /*--------------------------------------------------------------
765 * WriteConsoleA
766 */
767 WINBOOL STDCALL
768 WriteConsoleA(HANDLE hConsoleOutput,
769 CONST VOID *lpBuffer,
770 DWORD nNumberOfCharsToWrite,
771 LPDWORD lpNumberOfCharsWritten,
772 LPVOID lpReserved)
773 {
774 PCSRSS_API_REQUEST Request;
775 CSRSS_API_REPLY Reply;
776 NTSTATUS Status;
777 USHORT Size;
778 ULONG MessageSize;
779
780 Request = RtlAllocateHeap(GetProcessHeap(),
781 HEAP_ZERO_MEMORY,
782 sizeof(CSRSS_API_REQUEST) +
783 CSRSS_MAX_WRITE_CONSOLE_REQUEST);
784 if (Request == NULL)
785 {
786 SetLastError(ERROR_OUTOFMEMORY);
787 return(FALSE);
788 }
789
790 Request->Type = CSRSS_WRITE_CONSOLE;
791 Request->Data.WriteConsoleRequest.ConsoleHandle = hConsoleOutput;
792 if (lpNumberOfCharsWritten != NULL)
793 *lpNumberOfCharsWritten = nNumberOfCharsToWrite;
794 while (nNumberOfCharsToWrite)
795 {
796 if (nNumberOfCharsToWrite > CSRSS_MAX_WRITE_CONSOLE_REQUEST)
797 {
798 Size = CSRSS_MAX_WRITE_CONSOLE_REQUEST;
799 }
800 else
801 {
802 Size = nNumberOfCharsToWrite;
803 }
804 Request->Data.WriteConsoleRequest.NrCharactersToWrite = Size;
805
806 memcpy(Request->Data.WriteConsoleRequest.Buffer, lpBuffer, Size);
807
808 MessageSize = CSRSS_REQUEST_HEADER_SIZE +
809 sizeof(CSRSS_WRITE_CONSOLE_REQUEST) + Size;
810 Status = CsrClientCallServer(Request,
811 &Reply,
812 MessageSize,
813 sizeof(CSRSS_API_REPLY));
814
815 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Reply.Status))
816 {
817 RtlFreeHeap(GetProcessHeap(), 0, Request);
818 SetLastErrorByStatus(Status);
819 return(FALSE);
820 }
821 nNumberOfCharsToWrite -= Size;
822 lpBuffer += Size;
823 }
824
825 RtlFreeHeap(GetProcessHeap(), 0, Request);
826
827 return TRUE;
828 }
829
830
831 /*--------------------------------------------------------------
832 * ReadConsoleA
833 */
834 WINBOOL STDCALL ReadConsoleA(HANDLE hConsoleInput,
835 LPVOID lpBuffer,
836 DWORD nNumberOfCharsToRead,
837 LPDWORD lpNumberOfCharsRead,
838 LPVOID lpReserved)
839 {
840 CSRSS_API_REQUEST Request;
841 PCSRSS_API_REPLY Reply;
842 NTSTATUS Status;
843 ULONG CharsRead = 0;
844
845 Reply = RtlAllocateHeap(GetProcessHeap(),
846 HEAP_ZERO_MEMORY,
847 sizeof(CSRSS_API_REPLY) + nNumberOfCharsToRead);
848 if (Reply == NULL)
849 {
850 SetLastError(ERROR_OUTOFMEMORY);
851 return(FALSE);
852 }
853
854 Request.Type = CSRSS_READ_CONSOLE;
855 Request.Data.ReadConsoleRequest.ConsoleHandle = hConsoleInput;
856 Request.Data.ReadConsoleRequest.NrCharactersToRead = nNumberOfCharsToRead > CSRSS_MAX_READ_CONSOLE_REQUEST ? CSRSS_MAX_READ_CONSOLE_REQUEST : nNumberOfCharsToRead;
857 Request.Data.ReadConsoleRequest.nCharsCanBeDeleted = 0;
858 Status = CsrClientCallServer(&Request,
859 Reply,
860 sizeof(CSRSS_API_REQUEST),
861 sizeof(CSRSS_API_REPLY) +
862 Request.Data.ReadConsoleRequest.NrCharactersToRead);
863 if (!NT_SUCCESS(Status) || !NT_SUCCESS( Status = Reply->Status ))
864 {
865 DbgPrint( "CSR returned error in ReadConsole\n" );
866 SetLastErrorByStatus ( Status );
867 RtlFreeHeap( GetProcessHeap(), 0, Reply );
868 return(FALSE);
869 }
870 if( Reply->Status == STATUS_NOTIFY_CLEANUP )
871 Reply->Status = STATUS_PENDING; // ignore backspace because we have no chars to backspace
872 /* There may not be any chars or lines to read yet, so wait */
873 while( Reply->Status == STATUS_PENDING )
874 {
875 /* some chars may have been returned, but not a whole line yet, so recompute buffer and try again */
876 nNumberOfCharsToRead -= Reply->Data.ReadConsoleReply.NrCharactersRead;
877 /* don't overflow caller's buffer, even if you still don't have a complete line */
878 if( !nNumberOfCharsToRead )
879 break;
880 Request.Data.ReadConsoleRequest.NrCharactersToRead = nNumberOfCharsToRead > CSRSS_MAX_READ_CONSOLE_REQUEST ? CSRSS_MAX_READ_CONSOLE_REQUEST : nNumberOfCharsToRead;
881 /* copy any chars already read to buffer */
882 memcpy( lpBuffer + CharsRead, Reply->Data.ReadConsoleReply.Buffer, Reply->Data.ReadConsoleReply.NrCharactersRead );
883 CharsRead += Reply->Data.ReadConsoleReply.NrCharactersRead;
884 /* wait for csrss to signal there is more data to read, but not if we got STATUS_NOTIFY_CLEANUP for backspace */
885 Status = NtWaitForSingleObject( Reply->Data.ReadConsoleReply.EventHandle, FALSE, 0 );
886 if( !NT_SUCCESS( Status ) )
887 {
888 DbgPrint( "Wait for console input failed!\n" );
889 RtlFreeHeap( GetProcessHeap(), 0, Reply );
890 return FALSE;
891 }
892 Request.Data.ReadConsoleRequest.nCharsCanBeDeleted = CharsRead;
893 Status = CsrClientCallServer( &Request, Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) + Request.Data.ReadConsoleRequest.NrCharactersToRead );
894 if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply->Status ) )
895 {
896 SetLastErrorByStatus ( Status );
897 RtlFreeHeap( GetProcessHeap(), 0, Reply );
898 return FALSE;
899 }
900 if( Reply->Status == STATUS_NOTIFY_CLEANUP )
901 {
902 // delete last char
903 if( CharsRead )
904 {
905 CharsRead--;
906 nNumberOfCharsToRead++;
907 }
908 Reply->Status = STATUS_PENDING; // retry
909 }
910 }
911 /* copy data to buffer, count total returned, and return */
912 memcpy( lpBuffer + CharsRead, Reply->Data.ReadConsoleReply.Buffer, Reply->Data.ReadConsoleReply.NrCharactersRead );
913 CharsRead += Reply->Data.ReadConsoleReply.NrCharactersRead;
914 if (lpNumberOfCharsRead != NULL)
915 *lpNumberOfCharsRead = CharsRead;
916 RtlFreeHeap(GetProcessHeap(),
917 0,
918 Reply);
919
920 return(TRUE);
921 }
922
923
924 /*--------------------------------------------------------------
925 * AllocConsole
926 */
927 WINBOOL STDCALL AllocConsole(VOID)
928 {
929 CSRSS_API_REQUEST Request;
930 CSRSS_API_REPLY Reply;
931 NTSTATUS Status;
932 HANDLE hStdError;
933
934 Request.Type = CSRSS_ALLOC_CONSOLE;
935 Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
936 if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
937 {
938 SetLastErrorByStatus ( Status );
939 return FALSE;
940 }
941 SetStdHandle( STD_INPUT_HANDLE, Reply.Data.AllocConsoleReply.InputHandle );
942 SetStdHandle( STD_OUTPUT_HANDLE, Reply.Data.AllocConsoleReply.OutputHandle );
943 hStdError = DuplicateConsoleHandle(Reply.Data.AllocConsoleReply.OutputHandle,
944 0,
945 TRUE,
946 DUPLICATE_SAME_ACCESS);
947 SetStdHandle( STD_ERROR_HANDLE, hStdError );
948 return TRUE;
949 }
950
951
952 /*--------------------------------------------------------------
953 * FreeConsole
954 */
955 WINBOOL STDCALL FreeConsole(VOID)
956 {
957 DbgPrint("FreeConsole() is unimplemented\n");
958 return FALSE;
959 }
960
961
962 /*--------------------------------------------------------------
963 * GetConsoleScreenBufferInfo
964 */
965 WINBOOL
966 STDCALL
967 GetConsoleScreenBufferInfo(
968 HANDLE hConsoleOutput,
969 PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo
970 )
971 {
972 CSRSS_API_REQUEST Request;
973 CSRSS_API_REPLY Reply;
974 NTSTATUS Status;
975
976 Request.Type = CSRSS_SCREEN_BUFFER_INFO;
977 Request.Data.ScreenBufferInfoRequest.ConsoleHandle = hConsoleOutput;
978 Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
979 if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
980 {
981 SetLastErrorByStatus ( Status );
982 return FALSE;
983 }
984 *lpConsoleScreenBufferInfo = Reply.Data.ScreenBufferInfoReply.Info;
985 return TRUE;
986 }
987
988
989 /*--------------------------------------------------------------
990 * SetConsoleCursorPosition
991 */
992 WINBOOL
993 STDCALL
994 SetConsoleCursorPosition(
995 HANDLE hConsoleOutput,
996 COORD dwCursorPosition
997 )
998 {
999 CSRSS_API_REQUEST Request;
1000 CSRSS_API_REPLY Reply;
1001 NTSTATUS Status;
1002
1003 Request.Type = CSRSS_SET_CURSOR;
1004 Request.Data.SetCursorRequest.ConsoleHandle = hConsoleOutput;
1005 Request.Data.SetCursorRequest.Position = dwCursorPosition;
1006 Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
1007 if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
1008 {
1009 SetLastErrorByStatus ( Status );
1010 return FALSE;
1011 }
1012 return TRUE;
1013 }
1014
1015
1016 /*--------------------------------------------------------------
1017 * FillConsoleOutputCharacterA
1018 */
1019 WINBOOL STDCALL
1020 FillConsoleOutputCharacterA(
1021 HANDLE hConsoleOutput,
1022 CHAR cCharacter,
1023 DWORD nLength,
1024 COORD dwWriteCoord,
1025 LPDWORD lpNumberOfCharsWritten
1026 )
1027 {
1028 CSRSS_API_REQUEST Request;
1029 CSRSS_API_REPLY Reply;
1030 NTSTATUS Status;
1031
1032 Request.Type = CSRSS_FILL_OUTPUT;
1033 Request.Data.FillOutputRequest.ConsoleHandle = hConsoleOutput;
1034 Request.Data.FillOutputRequest.Char = cCharacter;
1035 Request.Data.FillOutputRequest.Position = dwWriteCoord;
1036 Request.Data.FillOutputRequest.Length = nLength;
1037 Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
1038 if ( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
1039 {
1040 SetLastErrorByStatus(Status);
1041 return(FALSE);
1042 }
1043 if (lpNumberOfCharsWritten != NULL)
1044 *lpNumberOfCharsWritten = nLength;
1045 return(TRUE);
1046 }
1047
1048
1049 /*--------------------------------------------------------------
1050 * FillConsoleOutputCharacterW
1051 */
1052 WINBOOL
1053 STDCALL
1054 FillConsoleOutputCharacterW(
1055 HANDLE hConsoleOutput,
1056 WCHAR cCharacter,
1057 DWORD nLength,
1058 COORD dwWriteCoord,
1059 LPDWORD lpNumberOfCharsWritten
1060 )
1061 {
1062 /* TO DO */
1063 return FALSE;
1064 }
1065
1066
1067 /*--------------------------------------------------------------
1068 * PeekConsoleInputA
1069 */
1070 WINBASEAPI
1071 BOOL
1072 WINAPI
1073 PeekConsoleInputA(
1074 HANDLE hConsoleInput,
1075 PINPUT_RECORD lpBuffer,
1076 DWORD nLength,
1077 LPDWORD lpNumberOfEventsRead
1078 )
1079 {
1080 PCSRSS_API_REQUEST Request;
1081 CSRSS_API_REPLY Reply;
1082 NTSTATUS Status;
1083 PVOID BufferBase;
1084 PVOID BufferTargetBase;
1085 DWORD Size;
1086
1087 if(lpBuffer == NULL)
1088 {
1089 SetLastError(ERROR_INVALID_PARAMETER);
1090 return FALSE;
1091 }
1092
1093 Size = nLength * sizeof(INPUT_RECORD);
1094
1095 Status = CsrCaptureParameterBuffer((PVOID)lpBuffer, Size, &BufferBase, &BufferTargetBase);
1096 if(!NT_SUCCESS(Status))
1097 {
1098 SetLastErrorByStatus(Status);
1099 return FALSE;
1100 }
1101
1102 Request = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CSRSS_API_REQUEST));
1103 if(Request == NULL)
1104 {
1105 CsrReleaseParameterBuffer(BufferBase);
1106 SetLastError(ERROR_OUTOFMEMORY);
1107 return FALSE;
1108 }
1109
1110 Request->Type = CSRSS_PEEK_CONSOLE_INPUT;
1111 Request->Data.PeekConsoleInputRequest.ConsoleHandle = hConsoleInput;
1112 Request->Data.PeekConsoleInputRequest.Length = nLength;
1113 Request->Data.PeekConsoleInputRequest.InputRecord = (INPUT_RECORD*)BufferTargetBase;
1114
1115 Status = CsrClientCallServer(Request, &Reply, sizeof(CSRSS_API_REQUEST), sizeof(CSRSS_API_REPLY));
1116
1117 if(!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Reply.Status))
1118 {
1119 RtlFreeHeap(GetProcessHeap(), 0, Request);
1120 CsrReleaseParameterBuffer(BufferBase);
1121 return FALSE;
1122 }
1123
1124 memcpy(lpBuffer, BufferBase, sizeof(INPUT_RECORD) * Reply.Data.PeekConsoleInputReply.Length);
1125
1126 if(lpNumberOfEventsRead != NULL)
1127 *lpNumberOfEventsRead = Reply.Data.PeekConsoleInputReply.Length;
1128
1129 RtlFreeHeap(GetProcessHeap(), 0, Request);
1130 CsrReleaseParameterBuffer(BufferBase);
1131
1132 return TRUE;
1133 }
1134
1135
1136 /*--------------------------------------------------------------
1137 * PeekConsoleInputW
1138 */
1139 WINBASEAPI
1140 BOOL
1141 WINAPI
1142 PeekConsoleInputW(
1143 HANDLE hConsoleInput,
1144 PINPUT_RECORD lpBuffer,
1145 DWORD nLength,
1146 LPDWORD lpNumberOfEventsRead
1147 )
1148 {
1149 /* TO DO */
1150 return FALSE;
1151 }
1152
1153
1154 /*--------------------------------------------------------------
1155 * ReadConsoleInputA
1156 */
1157 WINBASEAPI BOOL WINAPI
1158 ReadConsoleInputA(HANDLE hConsoleInput,
1159 PINPUT_RECORD lpBuffer,
1160 DWORD nLength,
1161 LPDWORD lpNumberOfEventsRead)
1162 {
1163 CSRSS_API_REQUEST Request;
1164 CSRSS_API_REPLY Reply;
1165 DWORD NumEventsRead;
1166 NTSTATUS Status;
1167
1168 Request.Type = CSRSS_READ_INPUT;
1169 Request.Data.ReadInputRequest.ConsoleHandle = hConsoleInput;
1170 Status = CsrClientCallServer(&Request, &Reply, sizeof(CSRSS_API_REQUEST),
1171 sizeof(CSRSS_API_REPLY));
1172 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Reply.Status))
1173 {
1174 SetLastErrorByStatus(Status);
1175 return(FALSE);
1176 }
1177
1178 while (Status == STATUS_PENDING)
1179 {
1180 Status = NtWaitForSingleObject(Reply.Data.ReadInputReply.Event, FALSE,
1181 0);
1182 if(!NT_SUCCESS(Status))
1183 {
1184 SetLastErrorByStatus(Status);
1185 return FALSE;
1186 }
1187
1188 Request.Type = CSRSS_READ_INPUT;
1189 Request.Data.ReadInputRequest.ConsoleHandle = hConsoleInput;
1190 Status = CsrClientCallServer(&Request, &Reply, sizeof(CSRSS_API_REQUEST),
1191 sizeof(CSRSS_API_REPLY));
1192 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Reply.Status))
1193 {
1194 SetLastErrorByStatus(Status);
1195 return(FALSE);
1196 }
1197 }
1198
1199 NumEventsRead = 0;
1200 *lpBuffer = Reply.Data.ReadInputReply.Input;
1201 lpBuffer++;
1202 NumEventsRead++;
1203
1204 while ((NumEventsRead < nLength) && (Reply.Data.ReadInputReply.MoreEvents))
1205 {
1206 Status = CsrClientCallServer(&Request, &Reply, sizeof(CSRSS_API_REQUEST),
1207 sizeof(CSRSS_API_REPLY));
1208 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Reply.Status))
1209 {
1210 SetLastErrorByStatus(Status);
1211 return(FALSE);
1212 }
1213
1214 if (Status == STATUS_PENDING)
1215 {
1216 break;
1217 }
1218
1219 *lpBuffer = Reply.Data.ReadInputReply.Input;
1220 lpBuffer++;
1221 NumEventsRead++;
1222
1223 }
1224 *lpNumberOfEventsRead = NumEventsRead;
1225
1226 return TRUE;
1227 }
1228
1229
1230 /*--------------------------------------------------------------
1231 * ReadConsoleInputW
1232 */
1233 WINBASEAPI
1234 BOOL
1235 WINAPI
1236 ReadConsoleInputW(
1237 HANDLE hConsoleInput,
1238 PINPUT_RECORD lpBuffer,
1239 DWORD nLength,
1240 LPDWORD lpNumberOfEventsRead
1241 )
1242 {
1243 /* TO DO */
1244 return FALSE;
1245 }
1246
1247
1248 /*--------------------------------------------------------------
1249 * WriteConsoleInputA
1250 */
1251 WINBASEAPI
1252 BOOL
1253 WINAPI
1254 WriteConsoleInputA(
1255 HANDLE hConsoleInput,
1256 CONST INPUT_RECORD *lpBuffer,
1257 DWORD nLength,
1258 LPDWORD lpNumberOfEventsWritten
1259 )
1260 {
1261 PCSRSS_API_REQUEST Request;
1262 CSRSS_API_REPLY Reply;
1263 PVOID BufferBase, BufferTargetBase;
1264 NTSTATUS Status;
1265 DWORD Size;
1266
1267 if(lpBuffer == NULL)
1268 {
1269 SetLastError(ERROR_INVALID_PARAMETER);
1270 return FALSE;
1271 }
1272
1273 Size = nLength * sizeof(INPUT_RECORD);
1274
1275 Status = CsrCaptureParameterBuffer((PVOID)lpBuffer, Size, &BufferBase, &BufferTargetBase);
1276 if(!NT_SUCCESS(Status))
1277 {
1278 SetLastErrorByStatus(Status);
1279 return FALSE;
1280 }
1281
1282 Request = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CSRSS_API_REQUEST));
1283 if(Request == NULL)
1284 {
1285 SetLastError(ERROR_OUTOFMEMORY);
1286 CsrReleaseParameterBuffer(BufferBase);
1287 return FALSE;
1288 }
1289
1290 Request->Type = CSRSS_WRITE_CONSOLE_INPUT;
1291 Request->Data.WriteConsoleInputRequest.ConsoleHandle = hConsoleInput;
1292 Request->Data.WriteConsoleInputRequest.Length = nLength;
1293 Request->Data.WriteConsoleInputRequest.InputRecord = (PINPUT_RECORD)BufferTargetBase;
1294
1295 Status = CsrClientCallServer(Request, &Reply, sizeof(CSRSS_API_REQUEST), sizeof(CSRSS_API_REPLY));
1296 if(!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Reply.Status))
1297 {
1298 RtlFreeHeap(GetProcessHeap(), 0, Request);
1299 CsrReleaseParameterBuffer(BufferBase);
1300 return FALSE;
1301 }
1302
1303 if(lpNumberOfEventsWritten != NULL)
1304 *lpNumberOfEventsWritten = Reply.Data.WriteConsoleInputReply.Length;
1305
1306 RtlFreeHeap(GetProcessHeap(), 0, Request);
1307 CsrReleaseParameterBuffer(BufferBase);
1308
1309 return TRUE;
1310 }
1311
1312
1313 /*--------------------------------------------------------------
1314 * WriteConsoleInputW
1315 */
1316 WINBASEAPI
1317 BOOL
1318 WINAPI
1319 WriteConsoleInputW(
1320 HANDLE hConsoleInput,
1321 CONST INPUT_RECORD *lpBuffer,
1322 DWORD nLength,
1323 LPDWORD lpNumberOfEventsWritten
1324 )
1325 {
1326 /* TO DO */
1327 return FALSE;
1328 }
1329
1330
1331 /*--------------------------------------------------------------
1332 * ReadConsoleOutputA
1333 */
1334 WINBASEAPI
1335 BOOL
1336 WINAPI
1337 ReadConsoleOutputA(
1338 HANDLE hConsoleOutput,
1339 PCHAR_INFO lpBuffer,
1340 COORD dwBufferSize,
1341 COORD dwBufferCoord,
1342 PSMALL_RECT lpReadRegion
1343 )
1344 {
1345 PCSRSS_API_REQUEST Request;
1346 CSRSS_API_REPLY Reply;
1347 PVOID BufferBase;
1348 PVOID BufferTargetBase;
1349 NTSTATUS Status;
1350 DWORD Size, SizeX, SizeY;
1351
1352 if(lpBuffer == NULL)
1353 {
1354 SetLastError(ERROR_INVALID_PARAMETER);
1355 return FALSE;
1356 }
1357
1358 Size = dwBufferSize.X * dwBufferSize.Y * sizeof(CHAR_INFO);
1359
1360 Status = CsrCaptureParameterBuffer((PVOID)lpBuffer, Size, &BufferBase, &BufferTargetBase);
1361 if(!NT_SUCCESS(Status))
1362 {
1363 SetLastErrorByStatus(Status);
1364 return FALSE;
1365 }
1366
1367 Request = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CSRSS_API_REQUEST));
1368 if(Request == NULL)
1369 {
1370 SetLastError(ERROR_OUTOFMEMORY);
1371 CsrReleaseParameterBuffer(BufferBase);
1372 return FALSE;
1373 }
1374
1375 Request->Type = CSRSS_READ_CONSOLE_OUTPUT;
1376 Request->Data.ReadConsoleOutputRequest.ConsoleHandle = hConsoleOutput;
1377 Request->Data.ReadConsoleOutputRequest.BufferSize = dwBufferSize;
1378 Request->Data.ReadConsoleOutputRequest.BufferCoord = dwBufferCoord;
1379 Request->Data.ReadConsoleOutputRequest.ReadRegion = *lpReadRegion;
1380 Request->Data.ReadConsoleOutputRequest.CharInfo = (PCHAR_INFO)BufferTargetBase;
1381
1382 Status = CsrClientCallServer(Request, &Reply, sizeof(CSRSS_API_REQUEST), sizeof(CSRSS_API_REPLY));
1383 if(!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Reply.Status))
1384 {
1385 SetLastErrorByStatus(Status);
1386 RtlFreeHeap(GetProcessHeap(), 0, Request);
1387 CsrReleaseParameterBuffer(BufferBase);
1388 return FALSE;
1389 }
1390
1391 SizeX = Reply.Data.ReadConsoleOutputReply.ReadRegion.Right - Reply.Data.ReadConsoleOutputReply.ReadRegion.Left + 1;
1392 SizeY = Reply.Data.ReadConsoleOutputReply.ReadRegion.Bottom - Reply.Data.ReadConsoleOutputReply.ReadRegion.Top + 1;
1393
1394 memcpy(lpBuffer, BufferBase, sizeof(CHAR_INFO) * SizeX * SizeY);
1395 *lpReadRegion = Reply.Data.ReadConsoleOutputReply.ReadRegion;
1396
1397 RtlFreeHeap(GetProcessHeap(), 0, Request);
1398 CsrReleaseParameterBuffer(BufferBase);
1399
1400 return TRUE;
1401 }
1402
1403
1404 /*--------------------------------------------------------------
1405 * ReadConsoleOutputW
1406 */
1407 WINBASEAPI
1408 BOOL
1409 WINAPI
1410 ReadConsoleOutputW(
1411 HANDLE hConsoleOutput,
1412 PCHAR_INFO lpBuffer,
1413 COORD dwBufferSize,
1414 COORD dwBufferCoord,
1415 PSMALL_RECT lpReadRegion
1416 )
1417 {
1418 /* TO DO */
1419 return FALSE;
1420 }
1421
1422 /*--------------------------------------------------------------
1423 * WriteConsoleOutputA
1424 */
1425 WINBASEAPI BOOL WINAPI
1426 WriteConsoleOutputA(HANDLE hConsoleOutput,
1427 CONST CHAR_INFO *lpBuffer,
1428 COORD dwBufferSize,
1429 COORD dwBufferCoord,
1430 PSMALL_RECT lpWriteRegion)
1431 {
1432 PCSRSS_API_REQUEST Request;
1433 CSRSS_API_REPLY Reply;
1434 NTSTATUS Status;
1435 ULONG Size;
1436 BOOLEAN Result;
1437 ULONG i, j;
1438 PVOID BufferBase;
1439 PVOID BufferTargetBase;
1440
1441 Size = dwBufferSize.Y * dwBufferSize.X * sizeof(CHAR_INFO);
1442
1443 Status = CsrCaptureParameterBuffer((PVOID)lpBuffer,
1444 Size,
1445 &BufferBase,
1446 &BufferTargetBase);
1447 if (!NT_SUCCESS(Status))
1448 {
1449 SetLastErrorByStatus(Status);
1450 return(FALSE);
1451 }
1452
1453 Request = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY,
1454 sizeof(CSRSS_API_REQUEST));
1455 if (Request == NULL)
1456 {
1457 CsrReleaseParameterBuffer(BufferBase);
1458 SetLastError(ERROR_OUTOFMEMORY);
1459 return FALSE;
1460 }
1461 Request->Type = CSRSS_WRITE_CONSOLE_OUTPUT;
1462 Request->Data.WriteConsoleOutputRequest.ConsoleHandle = hConsoleOutput;
1463 Request->Data.WriteConsoleOutputRequest.BufferSize = dwBufferSize;
1464 Request->Data.WriteConsoleOutputRequest.BufferCoord = dwBufferCoord;
1465 Request->Data.WriteConsoleOutputRequest.WriteRegion = *lpWriteRegion;
1466 Request->Data.WriteConsoleOutputRequest.CharInfo =
1467 (CHAR_INFO*)BufferTargetBase;
1468
1469 Status = CsrClientCallServer(Request, &Reply,
1470 sizeof(CSRSS_API_REQUEST),
1471 sizeof(CSRSS_API_REPLY));
1472 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Reply.Status))
1473 {
1474 CsrReleaseParameterBuffer(BufferBase);
1475 RtlFreeHeap(GetProcessHeap(), 0, Request);
1476 SetLastErrorByStatus(Status);
1477 return FALSE;
1478 }
1479
1480 *lpWriteRegion = Reply.Data.WriteConsoleOutputReply.WriteRegion;
1481 RtlFreeHeap(GetProcessHeap(), 0, Request);
1482 CsrReleaseParameterBuffer(BufferBase);
1483 return(TRUE);
1484 }
1485
1486
1487 /*--------------------------------------------------------------
1488 * WriteConsoleOutputW
1489 */
1490 WINBASEAPI
1491 BOOL
1492 WINAPI
1493 WriteConsoleOutputW(
1494 HANDLE hConsoleOutput,
1495 CONST CHAR_INFO *lpBuffer,
1496 COORD dwBufferSize,
1497 COORD dwBufferCoord,
1498 PSMALL_RECT lpWriteRegion
1499 )
1500 {
1501 /* TO DO */
1502 return FALSE;
1503 }
1504
1505
1506 /*--------------------------------------------------------------
1507 * ReadConsoleOutputCharacterA
1508 */
1509 WINBASEAPI
1510 BOOL
1511 WINAPI
1512 ReadConsoleOutputCharacterA(
1513 HANDLE hConsoleOutput,
1514 LPSTR lpCharacter,
1515 DWORD nLength,
1516 COORD dwReadCoord,
1517 LPDWORD lpNumberOfCharsRead
1518 )
1519 {
1520 CSRSS_API_REQUEST Request;
1521 PCSRSS_API_REPLY Reply;
1522 NTSTATUS Status;
1523 DWORD Size;
1524
1525 Reply = RtlAllocateHeap(GetProcessHeap(),
1526 HEAP_ZERO_MEMORY,
1527 sizeof(CSRSS_API_REPLY) + CSRSS_MAX_READ_CONSOLE_OUTPUT_CHAR);
1528 if (Reply == NULL)
1529 {
1530 SetLastError(ERROR_OUTOFMEMORY);
1531 return(FALSE);
1532 }
1533
1534 if (lpNumberOfCharsRead != NULL)
1535 *lpNumberOfCharsRead = nLength;
1536
1537 Request.Type = CSRSS_READ_CONSOLE_OUTPUT_CHAR;
1538 Request.Data.ReadConsoleOutputCharRequest.ConsoleHandle = hConsoleOutput;
1539 Request.Data.ReadConsoleOutputCharRequest.ReadCoord = dwReadCoord;
1540
1541 while (nLength != 0)
1542 {
1543 if (nLength > CSRSS_MAX_READ_CONSOLE_OUTPUT_CHAR)
1544 Size = CSRSS_MAX_READ_CONSOLE_OUTPUT_CHAR;
1545 else
1546 Size = nLength;
1547
1548 Request.Data.ReadConsoleOutputCharRequest.NumCharsToRead = Size;
1549
1550 Status = CsrClientCallServer(&Request,
1551 Reply,
1552 sizeof(CSRSS_API_REQUEST),
1553 sizeof(CSRSS_API_REPLY) + Size);
1554 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Reply->Status))
1555 {
1556 RtlFreeHeap(GetProcessHeap(), 0, Reply);
1557 SetLastErrorByStatus(Status);
1558 return(FALSE);
1559 }
1560
1561 memcpy(lpCharacter, &Reply->Data.ReadConsoleOutputCharReply.String[0], Size);
1562 lpCharacter += Size;
1563 nLength -= Size;
1564 Request.Data.ReadConsoleOutputCharRequest.ReadCoord = Reply->Data.ReadConsoleOutputCharReply.EndCoord;
1565 }
1566
1567 RtlFreeHeap(GetProcessHeap(), 0, Reply);
1568
1569 return(TRUE);
1570 }
1571
1572
1573 /*--------------------------------------------------------------
1574 * ReadConsoleOutputCharacterW
1575 */
1576 WINBASEAPI
1577 BOOL
1578 WINAPI
1579 ReadConsoleOutputCharacterW(
1580 HANDLE hConsoleOutput,
1581 LPWSTR lpCharacter,
1582 DWORD nLength,
1583 COORD dwReadCoord,
1584 LPDWORD lpNumberOfCharsRead
1585 )
1586 {
1587 /* TO DO */
1588 return FALSE;
1589 }
1590
1591
1592 /*--------------------------------------------------------------
1593 * ReadConsoleOutputAttribute
1594 */
1595 WINBASEAPI
1596 BOOL
1597 WINAPI
1598 ReadConsoleOutputAttribute(
1599 HANDLE hConsoleOutput,
1600 LPWORD lpAttribute,
1601 DWORD nLength,
1602 COORD dwReadCoord,
1603 LPDWORD lpNumberOfAttrsRead
1604 )
1605 {
1606 CSRSS_API_REQUEST Request;
1607 PCSRSS_API_REPLY Reply;
1608 NTSTATUS Status;
1609 DWORD Size, i;
1610
1611 Reply = RtlAllocateHeap(GetProcessHeap(),
1612 HEAP_ZERO_MEMORY,
1613 sizeof(CSRSS_API_REPLY) + CSRSS_MAX_READ_CONSOLE_OUTPUT_ATTRIB);
1614 if (Reply == NULL)
1615 {
1616 SetLastError(ERROR_OUTOFMEMORY);
1617 return(FALSE);
1618 }
1619
1620 if (lpNumberOfAttrsRead != NULL)
1621 *lpNumberOfAttrsRead = nLength;
1622
1623 Request.Type = CSRSS_READ_CONSOLE_OUTPUT_ATTRIB;
1624 Request.Data.ReadConsoleOutputAttribRequest.ConsoleHandle = hConsoleOutput;
1625 Request.Data.ReadConsoleOutputAttribRequest.ReadCoord = dwReadCoord;
1626
1627 while (nLength != 0)
1628 {
1629 if (nLength > CSRSS_MAX_READ_CONSOLE_OUTPUT_ATTRIB)
1630 Size = CSRSS_MAX_READ_CONSOLE_OUTPUT_ATTRIB;
1631 else
1632 Size = nLength;
1633
1634 Request.Data.ReadConsoleOutputAttribRequest.NumAttrsToRead = Size;
1635
1636 Status = CsrClientCallServer(&Request,
1637 Reply,
1638 sizeof(CSRSS_API_REQUEST),
1639 sizeof(CSRSS_API_REPLY) + Size);
1640 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Reply->Status))
1641 {
1642 RtlFreeHeap(GetProcessHeap(), 0, Reply);
1643 SetLastErrorByStatus(Status);
1644 return(FALSE);
1645 }
1646
1647 // Convert CHARs to WORDs
1648 for(i = 0; i < Size; ++i)
1649 *lpAttribute++ = Reply->Data.ReadConsoleOutputAttribReply.String[i];
1650
1651 nLength -= Size;
1652 Request.Data.ReadConsoleOutputAttribRequest.ReadCoord = Reply->Data.ReadConsoleOutputAttribReply.EndCoord;
1653 }
1654
1655 RtlFreeHeap(GetProcessHeap(), 0, Reply);
1656
1657 return(TRUE);
1658 }
1659
1660
1661 /*--------------------------------------------------------------
1662 * WriteConsoleOutputCharacterA
1663 */
1664 WINBASEAPI BOOL WINAPI
1665 WriteConsoleOutputCharacterA(HANDLE hConsoleOutput,
1666 LPCSTR lpCharacter,
1667 DWORD nLength,
1668 COORD dwWriteCoord,
1669 LPDWORD lpNumberOfCharsWritten)
1670 {
1671 PCSRSS_API_REQUEST Request;
1672 CSRSS_API_REPLY Reply;
1673 NTSTATUS Status;
1674 WORD Size;
1675
1676 Request = RtlAllocateHeap(GetProcessHeap(),
1677 HEAP_ZERO_MEMORY,
1678 sizeof(CSRSS_API_REQUEST) + CSRSS_MAX_WRITE_CONSOLE_OUTPUT_CHAR);
1679 if( !Request )
1680 {
1681 SetLastError( ERROR_OUTOFMEMORY );
1682 return FALSE;
1683 }
1684 Request->Type = CSRSS_WRITE_CONSOLE_OUTPUT_CHAR;
1685 Request->Data.WriteConsoleOutputCharRequest.ConsoleHandle = hConsoleOutput;
1686 Request->Data.WriteConsoleOutputCharRequest.Coord = dwWriteCoord;
1687 if( lpNumberOfCharsWritten )
1688 *lpNumberOfCharsWritten = nLength;
1689 while( nLength )
1690 {
1691 Size = nLength > CSRSS_MAX_WRITE_CONSOLE_OUTPUT_CHAR ? CSRSS_MAX_WRITE_CONSOLE_OUTPUT_CHAR : nLength;
1692 Request->Data.WriteConsoleOutputCharRequest.Length = Size;
1693 memcpy( &Request->Data.WriteConsoleOutputCharRequest.String[0],
1694 lpCharacter,
1695 Size );
1696 Status = CsrClientCallServer( Request, &Reply, sizeof( CSRSS_API_REQUEST ) + Size, sizeof( CSRSS_API_REPLY ) );
1697 if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
1698 {
1699 RtlFreeHeap( GetProcessHeap(), 0, Request );
1700 SetLastErrorByStatus ( Status );
1701 return FALSE;
1702 }
1703 nLength -= Size;
1704 lpCharacter += Size;
1705 Request->Data.WriteConsoleOutputCharRequest.Coord = Reply.Data.WriteConsoleOutputCharReply.EndCoord;
1706 }
1707
1708 RtlFreeHeap( GetProcessHeap(), 0, Request );
1709 return TRUE;
1710 }
1711
1712
1713 /*--------------------------------------------------------------
1714 * WriteConsoleOutputCharacterW
1715 */
1716 WINBASEAPI
1717 BOOL
1718 WINAPI
1719 WriteConsoleOutputCharacterW(
1720 HANDLE hConsoleOutput,
1721 LPCWSTR lpCharacter,
1722 DWORD nLength,
1723 COORD dwWriteCoord,
1724 LPDWORD lpNumberOfCharsWritten
1725 )
1726 {
1727 /* TO DO */
1728 return FALSE;
1729 }
1730
1731
1732
1733 /*--------------------------------------------------------------
1734 * WriteConsoleOutputAttribute
1735 */
1736 WINBASEAPI
1737 BOOL
1738 WINAPI
1739 WriteConsoleOutputAttribute(
1740 HANDLE hConsoleOutput,
1741 CONST WORD *lpAttribute,
1742 DWORD nLength,
1743 COORD dwWriteCoord,
1744 LPDWORD lpNumberOfAttrsWritten
1745 )
1746 {
1747 PCSRSS_API_REQUEST Request;
1748 CSRSS_API_REPLY Reply;
1749 NTSTATUS Status;
1750 WORD Size;
1751 int c;
1752
1753 Request = RtlAllocateHeap(GetProcessHeap(),
1754 HEAP_ZERO_MEMORY,
1755 sizeof(CSRSS_API_REQUEST) + CSRSS_MAX_WRITE_CONSOLE_OUTPUT_ATTRIB);
1756 if( !Request )
1757 {
1758 SetLastError( ERROR_OUTOFMEMORY );
1759 return FALSE;
1760 }
1761 Request->Type = CSRSS_WRITE_CONSOLE_OUTPUT_ATTRIB;
1762 Request->Data.WriteConsoleOutputAttribRequest.ConsoleHandle = hConsoleOutput;
1763 Request->Data.WriteConsoleOutputAttribRequest.Coord = dwWriteCoord;
1764 if( lpNumberOfAttrsWritten )
1765 *lpNumberOfAttrsWritten = nLength;
1766 while( nLength )
1767 {
1768 Size = nLength > CSRSS_MAX_WRITE_CONSOLE_OUTPUT_ATTRIB ? CSRSS_MAX_WRITE_CONSOLE_OUTPUT_ATTRIB : nLength;
1769 Request->Data.WriteConsoleOutputAttribRequest.Length = Size;
1770 for( c = 0; c < ( Size * 2 ); c++ )
1771 Request->Data.WriteConsoleOutputAttribRequest.String[c] = (char)lpAttribute[c];
1772 Status = CsrClientCallServer( Request, &Reply, sizeof( CSRSS_API_REQUEST ) + (Size * 2), sizeof( CSRSS_API_REPLY ) );
1773 if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
1774 {
1775 RtlFreeHeap( GetProcessHeap(), 0, Request );
1776 SetLastErrorByStatus ( Status );
1777 return FALSE;
1778 }
1779 nLength -= Size;
1780 lpAttribute += Size;
1781 Request->Data.WriteConsoleOutputAttribRequest.Coord = Reply.Data.WriteConsoleOutputAttribReply.EndCoord;
1782 }
1783
1784 RtlFreeHeap( GetProcessHeap(), 0, Request );
1785 return TRUE;
1786 }
1787
1788
1789 /*--------------------------------------------------------------
1790 * FillConsoleOutputAttribute
1791 */
1792 WINBASEAPI
1793 BOOL
1794 WINAPI
1795 FillConsoleOutputAttribute(
1796 HANDLE hConsoleOutput,
1797 WORD wAttribute,
1798 DWORD nLength,
1799 COORD dwWriteCoord,
1800 LPDWORD lpNumberOfAttrsWritten
1801 )
1802 {
1803 CSRSS_API_REQUEST Request;
1804 CSRSS_API_REPLY Reply;
1805 NTSTATUS Status;
1806
1807 Request.Type = CSRSS_FILL_OUTPUT_ATTRIB;
1808 Request.Data.FillOutputAttribRequest.ConsoleHandle = hConsoleOutput;
1809 Request.Data.FillOutputAttribRequest.Attribute = wAttribute;
1810 Request.Data.FillOutputAttribRequest.Coord = dwWriteCoord;
1811 Request.Data.FillOutputAttribRequest.Length = nLength;
1812 Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
1813 if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
1814 {
1815 SetLastErrorByStatus ( Status );
1816 return FALSE;
1817 }
1818 if( lpNumberOfAttrsWritten )
1819 *lpNumberOfAttrsWritten = nLength;
1820 return TRUE;
1821 }
1822
1823
1824 /*--------------------------------------------------------------
1825 * GetConsoleMode
1826 */
1827 WINBASEAPI
1828 BOOL
1829 WINAPI
1830 GetConsoleMode(
1831 HANDLE hConsoleHandle,
1832 LPDWORD lpMode
1833 )
1834 {
1835 CSRSS_API_REQUEST Request;
1836 CSRSS_API_REPLY Reply;
1837 NTSTATUS Status;
1838
1839 Request.Type = CSRSS_GET_MODE;
1840 Request.Data.GetConsoleModeRequest.ConsoleHandle = hConsoleHandle;
1841 Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
1842 if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
1843 {
1844 SetLastErrorByStatus ( Status );
1845 return FALSE;
1846 }
1847 *lpMode = Reply.Data.GetConsoleModeReply.ConsoleMode;
1848 return TRUE;
1849 }
1850
1851
1852 /*--------------------------------------------------------------
1853 * GetNumberOfConsoleInputEvents
1854 */
1855 WINBASEAPI
1856 BOOL
1857 WINAPI
1858 GetNumberOfConsoleInputEvents(
1859 HANDLE hConsoleInput,
1860 LPDWORD lpNumberOfEvents
1861 )
1862 {
1863 CSRSS_API_REQUEST Request;
1864 CSRSS_API_REPLY Reply;
1865 NTSTATUS Status;
1866
1867 if(lpNumberOfEvents == NULL)
1868 {
1869 SetLastError(ERROR_INVALID_PARAMETER);
1870 return FALSE;
1871 }
1872
1873 Request.Type = CSRSS_GET_NUM_INPUT_EVENTS;
1874 Request.Data.GetNumInputEventsRequest.ConsoleHandle = hConsoleInput;
1875 Status = CsrClientCallServer(&Request, &Reply, sizeof(CSRSS_API_REQUEST), sizeof(CSRSS_API_REPLY));
1876 if(!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Reply.Status))
1877 {
1878 SetLastErrorByStatus(Status);
1879 return FALSE;
1880 }
1881
1882 *lpNumberOfEvents = Reply.Data.GetNumInputEventsReply.NumInputEvents;
1883
1884 return TRUE;
1885 }
1886
1887
1888 /*--------------------------------------------------------------
1889 * GetLargestConsoleWindowSize
1890 */
1891 WINBASEAPI
1892 COORD
1893 WINAPI
1894 GetLargestConsoleWindowSize(
1895 HANDLE hConsoleOutput
1896 )
1897 {
1898 #if 1 /* FIXME: */
1899 COORD Coord = {80,25};
1900
1901 /* TO DO */
1902 return Coord;
1903 #endif
1904 }
1905
1906
1907 /*--------------------------------------------------------------
1908 * GetConsoleCursorInfo
1909 */
1910 WINBASEAPI
1911 BOOL
1912 WINAPI
1913 GetConsoleCursorInfo(
1914 HANDLE hConsoleOutput,
1915 PCONSOLE_CURSOR_INFO lpConsoleCursorInfo
1916 )
1917 {
1918 CSRSS_API_REQUEST Request;
1919 CSRSS_API_REPLY Reply;
1920 NTSTATUS Status;
1921
1922 Request.Type = CSRSS_GET_CURSOR_INFO;
1923 Request.Data.GetCursorInfoRequest.ConsoleHandle = hConsoleOutput;
1924 Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
1925
1926 if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
1927 {
1928 SetLastErrorByStatus ( Status );
1929 return FALSE;
1930 }
1931 *lpConsoleCursorInfo = Reply.Data.GetCursorInfoReply.Info;
1932 return TRUE;
1933 }
1934
1935
1936 /*--------------------------------------------------------------
1937 * GetNumberOfConsoleMouseButtons
1938 */
1939 WINBASEAPI
1940 BOOL
1941 WINAPI
1942 GetNumberOfConsoleMouseButtons(
1943 LPDWORD lpNumberOfMouseButtons
1944 )
1945 {
1946 /* TO DO */
1947 return FALSE;
1948 }
1949
1950
1951 /*--------------------------------------------------------------
1952 * SetConsoleMode
1953 */
1954 WINBASEAPI
1955 BOOL
1956 WINAPI
1957 SetConsoleMode(
1958 HANDLE hConsoleHandle,
1959 DWORD dwMode
1960 )
1961 {
1962 CSRSS_API_REQUEST Request;
1963 CSRSS_API_REPLY Reply;
1964 NTSTATUS Status;
1965
1966 Request.Type = CSRSS_SET_MODE;
1967 Request.Data.SetConsoleModeRequest.ConsoleHandle = hConsoleHandle;
1968 Request.Data.SetConsoleModeRequest.Mode = dwMode;
1969 Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
1970 if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
1971 {
1972 SetLastErrorByStatus ( Status );
1973 return FALSE;
1974 }
1975 return TRUE;
1976 }
1977
1978
1979 /*--------------------------------------------------------------
1980 * SetConsoleActiveScreenBuffer
1981 */
1982 WINBASEAPI
1983 BOOL
1984 WINAPI
1985 SetConsoleActiveScreenBuffer(
1986 HANDLE hConsoleOutput
1987 )
1988 {
1989 CSRSS_API_REQUEST Request;
1990 CSRSS_API_REPLY Reply;
1991 NTSTATUS Status;
1992
1993 Request.Type = CSRSS_SET_SCREEN_BUFFER;
1994 Request.Data.SetActiveScreenBufferRequest.OutputHandle = hConsoleOutput;
1995 Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
1996 if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
1997 {
1998 SetLastErrorByStatus ( Status );
1999 return FALSE;
2000 }
2001 return TRUE;
2002 }
2003
2004
2005 /*--------------------------------------------------------------
2006 * FlushConsoleInputBuffer
2007 */
2008 WINBASEAPI
2009 BOOL
2010 WINAPI
2011 FlushConsoleInputBuffer(
2012 HANDLE hConsoleInput
2013 )
2014 {
2015 CSRSS_API_REQUEST Request;
2016 CSRSS_API_REPLY Reply;
2017 NTSTATUS Status;
2018
2019 Request.Type = CSRSS_FLUSH_INPUT_BUFFER;
2020 Request.Data.FlushInputBufferRequest.ConsoleInput = hConsoleInput;
2021 Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
2022 if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
2023 {
2024 SetLastErrorByStatus ( Status );
2025 return FALSE;
2026 }
2027 return TRUE;
2028 }
2029
2030
2031 /*--------------------------------------------------------------
2032 * SetConsoleScreenBufferSize
2033 */
2034 WINBASEAPI
2035 BOOL
2036 WINAPI
2037 SetConsoleScreenBufferSize(
2038 HANDLE hConsoleOutput,
2039 COORD dwSize
2040 )
2041 {
2042 /* TO DO */
2043 return FALSE;
2044 }
2045
2046 /*--------------------------------------------------------------
2047 * SetConsoleCursorInfo
2048 */
2049 WINBASEAPI
2050 BOOL
2051 WINAPI
2052 SetConsoleCursorInfo(
2053 HANDLE hConsoleOutput,
2054 CONST CONSOLE_CURSOR_INFO *lpConsoleCursorInfo
2055 )
2056 {
2057 CSRSS_API_REQUEST Request;
2058 CSRSS_API_REPLY Reply;
2059 NTSTATUS Status;
2060
2061 Request.Type = CSRSS_SET_CURSOR_INFO;
2062 Request.Data.SetCursorInfoRequest.ConsoleHandle = hConsoleOutput;
2063 Request.Data.SetCursorInfoRequest.Info = *lpConsoleCursorInfo;
2064 Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
2065
2066 if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
2067 {
2068 SetLastErrorByStatus ( Status );
2069 return FALSE;
2070 }
2071 return TRUE;
2072 }
2073
2074
2075 /*--------------------------------------------------------------
2076 * ScrollConsoleScreenBufferA
2077 */
2078 WINBASEAPI
2079 BOOL
2080 WINAPI
2081 ScrollConsoleScreenBufferA(
2082 HANDLE hConsoleOutput,
2083 CONST SMALL_RECT *lpScrollRectangle,
2084 CONST SMALL_RECT *lpClipRectangle,
2085 COORD dwDestinationOrigin,
2086 CONST CHAR_INFO *lpFill
2087 )
2088 {
2089 CSRSS_API_REQUEST Request;
2090 CSRSS_API_REPLY Reply;
2091 NTSTATUS Status;
2092
2093 Request.Type = CSRSS_SCROLL_CONSOLE_SCREEN_BUFFER;
2094 Request.Data.ScrollConsoleScreenBufferRequest.ConsoleHandle = hConsoleOutput;
2095 Request.Data.ScrollConsoleScreenBufferRequest.ScrollRectangle = *lpScrollRectangle;
2096
2097 if (lpClipRectangle != NULL)
2098 {
2099 Request.Data.ScrollConsoleScreenBufferRequest.UseClipRectangle = TRUE;
2100 Request.Data.ScrollConsoleScreenBufferRequest.ClipRectangle = *lpClipRectangle;
2101 }
2102 else
2103 {
2104 Request.Data.ScrollConsoleScreenBufferRequest.UseClipRectangle = FALSE;
2105 }
2106
2107 Request.Data.ScrollConsoleScreenBufferRequest.DestinationOrigin = dwDestinationOrigin;
2108 Request.Data.ScrollConsoleScreenBufferRequest.Fill = *lpFill;
2109 Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
2110
2111 if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
2112 {
2113 SetLastErrorByStatus ( Status );
2114 return FALSE;
2115 }
2116 return TRUE;
2117 }
2118
2119
2120 /*--------------------------------------------------------------
2121 * ScrollConsoleScreenBufferW
2122 */
2123 WINBASEAPI
2124 BOOL
2125 WINAPI
2126 ScrollConsoleScreenBufferW(
2127 HANDLE hConsoleOutput,
2128 CONST SMALL_RECT *lpScrollRectangle,
2129 CONST SMALL_RECT *lpClipRectangle,
2130 COORD dwDestinationOrigin,
2131 CONST CHAR_INFO *lpFill
2132 )
2133 {
2134 /* TO DO */
2135 return FALSE;
2136 }
2137
2138
2139 /*--------------------------------------------------------------
2140 * SetConsoleWindowInfo
2141 */
2142 WINBASEAPI
2143 BOOL
2144 WINAPI
2145 SetConsoleWindowInfo(
2146 HANDLE hConsoleOutput,
2147 BOOL bAbsolute,
2148 CONST SMALL_RECT *lpConsoleWindow
2149 )
2150 {
2151 /* TO DO */
2152 return FALSE;
2153 }
2154
2155
2156 /*--------------------------------------------------------------
2157 * SetConsoleTextAttribute
2158 */
2159 WINBASEAPI
2160 BOOL
2161 WINAPI
2162 SetConsoleTextAttribute(
2163 HANDLE hConsoleOutput,
2164 WORD wAttributes
2165 )
2166 {
2167 CSRSS_API_REQUEST Request;
2168 CSRSS_API_REPLY Reply;
2169 NTSTATUS Status;
2170
2171 Request.Type = CSRSS_SET_ATTRIB;
2172 Request.Data.SetAttribRequest.ConsoleHandle = hConsoleOutput;
2173 Request.Data.SetAttribRequest.Attrib = wAttributes;
2174 Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
2175 if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
2176 {
2177 SetLastErrorByStatus ( Status );
2178 return FALSE;
2179 }
2180 return TRUE;
2181 }
2182
2183 BOOL STATIC
2184 AddConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine)
2185 {
2186 if (HandlerRoutine == NULL)
2187 {
2188 IgnoreCtrlEvents = TRUE;
2189 return(TRUE);
2190 }
2191 else
2192 {
2193 NrCtrlHandlers++;
2194 CtrlHandlers =
2195 RtlReAllocateHeap(RtlGetProcessHeap(),
2196 HEAP_ZERO_MEMORY,
2197 (PVOID)CtrlHandlers,
2198 NrCtrlHandlers * sizeof(PHANDLER_ROUTINE));
2199 if (CtrlHandlers == NULL)
2200 {
2201 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
2202 return(FALSE);
2203 }
2204 CtrlHandlers[NrCtrlHandlers - 1] = HandlerRoutine;
2205 return(TRUE);
2206 }
2207 }
2208
2209 BOOL STATIC
2210 RemoveConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine)
2211 {
2212 ULONG i;
2213
2214 if (HandlerRoutine == NULL)
2215 {
2216 IgnoreCtrlEvents = FALSE;
2217 return(TRUE);
2218 }
2219 else
2220 {
2221 for (i = 0; i < NrCtrlHandlers; i++)
2222 {
2223 if ((PHANDLER_ROUTINE) CtrlHandlers[i] == HandlerRoutine)
2224 {
2225 CtrlHandlers[i] = CtrlHandlers[NrCtrlHandlers - 1];
2226 NrCtrlHandlers--;
2227 CtrlHandlers =
2228 RtlReAllocateHeap(RtlGetProcessHeap(),
2229 HEAP_ZERO_MEMORY,
2230 (PVOID)CtrlHandlers,
2231 NrCtrlHandlers * sizeof(PHANDLER_ROUTINE));
2232 return(TRUE);
2233 }
2234 }
2235 }
2236 return(FALSE);
2237 }
2238
2239 WINBASEAPI BOOL WINAPI
2240 SetConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine,
2241 BOOL Add)
2242 {
2243 BOOLEAN Ret;
2244
2245 RtlEnterCriticalSection(&DllLock);
2246 if (Add)
2247 {
2248 Ret = AddConsoleCtrlHandler(HandlerRoutine);
2249 }
2250 else
2251 {
2252 Ret = RemoveConsoleCtrlHandler(HandlerRoutine);
2253 }
2254 RtlLeaveCriticalSection(&DllLock);
2255 return(Ret);
2256 }
2257
2258
2259 /*--------------------------------------------------------------
2260 * GenerateConsoleCtrlEvent
2261 */
2262 WINBASEAPI BOOL WINAPI
2263 GenerateConsoleCtrlEvent(
2264 DWORD dwCtrlEvent,
2265 DWORD dwProcessGroupId
2266 )
2267 {
2268 /* TO DO */
2269 return FALSE;
2270 }
2271
2272
2273 /*--------------------------------------------------------------
2274 * GetConsoleTitleW
2275 */
2276
2277 WINBASEAPI
2278 DWORD
2279 WINAPI
2280 GetConsoleTitleW(
2281 LPWSTR lpConsoleTitle,
2282 DWORD nSize
2283 )
2284 {
2285 CSRSS_API_REQUEST Request;
2286 PCSRSS_API_REPLY Reply;
2287 NTSTATUS Status;
2288 HANDLE hConsole;
2289
2290 hConsole = CreateFileW(L"CONIN$", GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
2291 if (hConsole == INVALID_HANDLE_VALUE)
2292 {
2293 return 0;
2294 }
2295
2296 Reply = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CSRSS_API_REPLY) + CSRSS_MAX_TITLE_LENGTH * sizeof(WCHAR));
2297 if(Reply == NULL)
2298 {
2299 CloseHandle(hConsole);
2300 SetLastError(ERROR_OUTOFMEMORY);
2301 return 0;
2302 }
2303
2304 Request.Type = CSRSS_GET_TITLE;
2305 Request.Data.GetTitleRequest.ConsoleHandle = hConsole;
2306
2307 Status = CsrClientCallServer(&Request, Reply, sizeof(CSRSS_API_REQUEST), sizeof(CSRSS_API_REPLY) + CSRSS_MAX_TITLE_LENGTH * sizeof(WCHAR));
2308 CloseHandle(hConsole);
2309 if(!NT_SUCCESS(Status) || !(NT_SUCCESS(Status = Reply->Status)))
2310 {
2311 SetLastErrorByStatus(Status);
2312 RtlFreeHeap(GetProcessHeap(), 0, Reply);
2313 return 0;
2314 }
2315
2316 if(nSize * sizeof(WCHAR) < Reply->Data.GetTitleReply.Length)
2317 {
2318 wcsncpy(lpConsoleTitle, Reply->Data.GetTitleReply.Title, nSize - 1);
2319 lpConsoleTitle[nSize--] = L'\0';
2320 }
2321 else
2322 {
2323 nSize = Reply->Data.GetTitleReply.Length / sizeof (WCHAR);
2324 wcscpy(lpConsoleTitle, Reply->Data.GetTitleReply.Title);
2325 lpConsoleTitle[nSize] = L'\0';
2326 }
2327
2328 RtlFreeHeap(GetProcessHeap(), 0, Reply);
2329 return nSize;
2330 }
2331
2332
2333 /*--------------------------------------------------------------
2334 * GetConsoleTitleA
2335 *
2336 * 19990306 EA
2337 */
2338 WINBASEAPI
2339 DWORD
2340 WINAPI
2341 GetConsoleTitleA(
2342 LPSTR lpConsoleTitle,
2343 DWORD nSize
2344 )
2345 {
2346 wchar_t WideTitle [CSRSS_MAX_TITLE_LENGTH];
2347 DWORD nWideTitle = sizeof WideTitle;
2348 DWORD nWritten;
2349
2350 if (!lpConsoleTitle || !nSize) return 0;
2351 nWideTitle = GetConsoleTitleW( (LPWSTR) WideTitle, nWideTitle );
2352 if (!nWideTitle) return 0;
2353
2354 if ( (nWritten = WideCharToMultiByte(
2355 CP_ACP, // ANSI code page
2356 0, // performance and mapping flags
2357 (LPWSTR) WideTitle, // address of wide-character string
2358 nWideTitle, // number of characters in string
2359 lpConsoleTitle, // address of buffer for new string
2360 nSize, // size of buffer
2361 NULL, // FAST
2362 NULL // FAST
2363 )))
2364 {
2365 lpConsoleTitle[nWritten] = '\0';
2366 return nWritten;
2367 }
2368
2369 return 0;
2370 }
2371
2372
2373 /*--------------------------------------------------------------
2374 * SetConsoleTitleW
2375 */
2376 WINBASEAPI
2377 BOOL
2378 WINAPI
2379 SetConsoleTitleW(
2380 LPCWSTR lpConsoleTitle
2381 )
2382 {
2383 PCSRSS_API_REQUEST Request;
2384 CSRSS_API_REPLY Reply;
2385 NTSTATUS Status;
2386 unsigned int c;
2387 HANDLE hConsole;
2388
2389 hConsole = CreateFileW(L"CONIN$", GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
2390 if (hConsole == INVALID_HANDLE_VALUE)
2391 {
2392 return FALSE;
2393 }
2394
2395 Request = RtlAllocateHeap(GetProcessHeap(),
2396 HEAP_ZERO_MEMORY,
2397 sizeof(CSRSS_API_REQUEST) + CSRSS_MAX_SET_TITLE_REQUEST);
2398 if (Request == NULL)
2399 {
2400 CloseHandle(hConsole);
2401 SetLastError(ERROR_OUTOFMEMORY);
2402 return(FALSE);
2403 }
2404
2405 Request->Type = CSRSS_SET_TITLE;
2406 Request->Data.SetTitleRequest.Console = hConsole;
2407
2408 for( c = 0; lpConsoleTitle[c] && c < CSRSS_MAX_TITLE_LENGTH; c++ )
2409 Request->Data.SetTitleRequest.Title[c] = lpConsoleTitle[c];
2410 // add null
2411 Request->Data.SetTitleRequest.Title[c] = 0;
2412 Request->Data.SetTitleRequest.Length = c;
2413 Status = CsrClientCallServer(Request,
2414 &Reply,
2415 sizeof(CSRSS_API_REQUEST) +
2416 c * sizeof(WCHAR),
2417 sizeof(CSRSS_API_REPLY));
2418 CloseHandle(hConsole);
2419 if (!NT_SUCCESS(Status) || !NT_SUCCESS( Status = Reply.Status ) )
2420 {
2421 RtlFreeHeap( GetProcessHeap(), 0, Request );
2422 SetLastErrorByStatus (Status);
2423 return(FALSE);
2424 }
2425 RtlFreeHeap( GetProcessHeap(), 0, Request );
2426 return TRUE;
2427 }
2428
2429
2430 /*--------------------------------------------------------------
2431 * SetConsoleTitleA
2432 *
2433 * 19990204 EA Added
2434 */
2435 WINBASEAPI
2436 BOOL
2437 WINAPI
2438 SetConsoleTitleA(
2439 LPCSTR lpConsoleTitle
2440 )
2441 {
2442 PCSRSS_API_REQUEST Request;
2443 CSRSS_API_REPLY Reply;
2444 NTSTATUS Status;
2445 unsigned int c;
2446 HANDLE hConsole;
2447
2448 hConsole = CreateFileW(L"CONIN$", GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
2449 if (hConsole == INVALID_HANDLE_VALUE)
2450 {
2451 return FALSE;
2452 }
2453
2454 Request = RtlAllocateHeap(GetProcessHeap(),
2455 HEAP_ZERO_MEMORY,
2456 sizeof(CSRSS_API_REQUEST) + CSRSS_MAX_SET_TITLE_REQUEST);
2457 if (Request == NULL)
2458 {
2459 CloseHandle(hConsole);
2460 SetLastError(ERROR_OUTOFMEMORY);
2461 return(FALSE);
2462 }
2463
2464 Request->Type = CSRSS_SET_TITLE;
2465 Request->Data.SetTitleRequest.Console = hConsole;
2466
2467 for( c = 0; lpConsoleTitle[c] && c < CSRSS_MAX_TITLE_LENGTH; c++ )
2468 Request->Data.SetTitleRequest.Title[c] = lpConsoleTitle[c];
2469 // add null
2470 Request->Data.SetTitleRequest.Title[c] = 0;
2471 Request->Data.SetTitleRequest.Length = c;
2472 Status = CsrClientCallServer(Request,
2473 &Reply,
2474 sizeof(CSRSS_API_REQUEST) +
2475 c * sizeof(WCHAR),
2476 sizeof(CSRSS_API_REPLY));
2477 CloseHandle(hConsole);
2478 if (!NT_SUCCESS(Status) || !NT_SUCCESS( Status = Reply.Status ) )
2479 {
2480 RtlFreeHeap( GetProcessHeap(), 0, Request );
2481 SetLastErrorByStatus (Status);
2482 return(FALSE);
2483 }
2484 RtlFreeHeap( GetProcessHeap(), 0, Request );
2485 return TRUE;
2486 }
2487
2488
2489 /*--------------------------------------------------------------
2490 * ReadConsoleW
2491 */
2492 WINBASEAPI
2493 BOOL
2494 WINAPI
2495 ReadConsoleW(
2496 HANDLE hConsoleInput,
2497 LPVOID lpBuffer,
2498 DWORD nNumberOfCharsToRead,
2499 LPDWORD lpNumberOfCharsRead,
2500 LPVOID lpReserved
2501 )
2502 {
2503 /* --- TO DO --- */
2504 return FALSE;
2505 }
2506
2507
2508 /*--------------------------------------------------------------
2509 * WriteConsoleW
2510 */
2511 WINBASEAPI
2512 BOOL
2513 WINAPI
2514 WriteConsoleW(
2515 HANDLE hConsoleOutput,
2516 CONST VOID *lpBuffer,
2517 DWORD nNumberOfCharsToWrite,
2518 LPDWORD lpNumberOfCharsWritten,
2519 LPVOID lpReserved
2520 )
2521 {
2522 #if 0
2523 PCSRSS_API_REQUEST Request;
2524 CSRSS_API_REPLY Reply;
2525 NTSTATUS Status;
2526
2527 Request = RtlAllocateHeap(GetProcessHeap(),
2528 HEAP_ZERO_MEMORY,
2529 sizeof(CSRSS_API_REQUEST) + nNumberOfCharsToWrite * sizeof(WCHAR));
2530 if (Request == NULL)
2531 {
2532 SetLastError(ERROR_OUTOFMEMORY);
2533 return(FALSE);
2534 }
2535
2536 Request->Type = CSRSS_WRITE_CONSOLE;
2537 Request->Data.WriteConsoleRequest.ConsoleHandle = hConsoleOutput;
2538 Request->Data.WriteConsoleRequest.NrCharactersToWrite =
2539 nNumberOfCharsToWrite;
2540 // DbgPrint("nNumberOfCharsToWrite %d\n", nNumberOfCharsToWrite);
2541 // DbgPrint("Buffer %s\n", Request->Data.WriteConsoleRequest.Buffer);
2542 memcpy(Request->Data.WriteConsoleRequest.Buffer,
2543 lpBuffer,
2544 nNumberOfCharsToWrite * sizeof(WCHAR));
2545
2546 Status = CsrClientCallServer(Request,
2547 &Reply,
2548 sizeof(CSRSS_API_REQUEST) + nNumberOfCharsToWrite,
2549 sizeof(CSRSS_API_REPLY));
2550
2551 RtlFreeHeap(GetProcessHeap(),
2552 0,
2553 Request);
2554
2555 if (!NT_SUCCESS(Status))
2556 {
2557 return(FALSE);
2558 }
2559
2560 if (lpNumberOfCharsWritten != NULL)
2561 {
2562 *lpNumberOfCharsWritten =
2563 Reply.Data.WriteConsoleReply.NrCharactersWritten;
2564 }
2565
2566 return(TRUE);
2567 #endif
2568 return(FALSE);
2569 }
2570
2571
2572 /*--------------------------------------------------------------
2573 * CreateConsoleScreenBuffer
2574 */
2575 WINBASEAPI
2576 HANDLE
2577 WINAPI
2578 CreateConsoleScreenBuffer(
2579 DWORD dwDesiredAccess,
2580 DWORD dwShareMode,
2581 CONST SECURITY_ATTRIBUTES *lpSecurityAttributes,
2582 DWORD dwFlags,
2583 LPVOID lpScreenBufferData
2584 )
2585 {
2586 // FIXME: don't ignore access, share mode, and security
2587 CSRSS_API_REQUEST Request;
2588 CSRSS_API_REPLY Reply;
2589 NTSTATUS Status;
2590
2591 Request.Type = CSRSS_CREATE_SCREEN_BUFFER;
2592 Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
2593 if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
2594 {
2595 SetLastErrorByStatus ( Status );
2596 return FALSE;
2597 }
2598 return Reply.Data.CreateScreenBufferReply.OutputHandle;
2599 }
2600
2601
2602 /*--------------------------------------------------------------
2603 * GetConsoleCP
2604 */
2605 WINBASEAPI
2606 UINT
2607 WINAPI
2608 GetConsoleCP( VOID )
2609 {
2610 /* --- TO DO --- */
2611 return CP_OEMCP; /* FIXME */
2612 }
2613
2614
2615 /*--------------------------------------------------------------
2616 * SetConsoleCP
2617 */
2618 WINBASEAPI
2619 BOOL
2620 WINAPI
2621 SetConsoleCP(
2622 UINT wCodePageID
2623 )
2624 {
2625 /* --- TO DO --- */
2626 return FALSE;
2627 }
2628
2629
2630 /*--------------------------------------------------------------
2631 * GetConsoleOutputCP
2632 */
2633 WINBASEAPI
2634 UINT
2635 WINAPI
2636 GetConsoleOutputCP( VOID )
2637 {
2638 /* --- TO DO --- */
2639 return 0; /* FIXME */
2640 }
2641
2642
2643 /*--------------------------------------------------------------
2644 * SetConsoleOutputCP
2645 */
2646 WINBASEAPI
2647 BOOL
2648 WINAPI
2649 SetConsoleOutputCP(
2650 UINT wCodePageID
2651 )
2652 {
2653 /* --- TO DO --- */
2654 return FALSE;
2655 }
2656
2657
2658 /*--------------------------------------------------------------
2659 * GetConsoleProcessList
2660 */
2661 DWORD STDCALL
2662 GetConsoleProcessList(LPDWORD lpdwProcessList,
2663 DWORD dwProcessCount)
2664 {
2665 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
2666 return 0;
2667 }
2668
2669
2670
2671 /*--------------------------------------------------------------
2672 * GetConsoleSelectionInfo
2673 */
2674 BOOL STDCALL
2675 GetConsoleSelectionInfo(PCONSOLE_SELECTION_INFO lpConsoleSelectionInfo)
2676 {
2677 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
2678 return FALSE;
2679 }
2680
2681
2682
2683 /*--------------------------------------------------------------
2684 * AttachConsole
2685 */
2686 BOOL STDCALL
2687 AttachConsole(DWORD dwProcessId)
2688 {
2689 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
2690 return FALSE;
2691 }
2692
2693 /*--------------------------------------------------------------
2694 * GetConsoleWindow/0
2695 */
2696 HWND STDCALL
2697 GetConsoleWindow (VOID)
2698 {
2699 CSRSS_API_REQUEST Request;
2700 CSRSS_API_REPLY Reply;
2701 NTSTATUS Status;
2702
2703 Request.Data.ConsoleWindowRequest.ConsoleHandle =
2704 OpenConsoleW (L"CONOUT$", (GENERIC_READ|GENERIC_WRITE), FALSE, OPEN_EXISTING);
2705 if (INVALID_HANDLE_VALUE == Request.Data.ConsoleWindowRequest.ConsoleHandle)
2706 {
2707 return (HWND) NULL;
2708 }
2709 Request.Type = CSRSS_GET_CONSOLE_WINDOW;
2710 Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
2711 if (!NT_SUCCESS(Status ) || !NT_SUCCESS(Status = Reply.Status))
2712 {
2713 SetLastErrorByStatus (Status);
2714 return (HWND) NULL;
2715 }
2716 return Reply.Data.ConsoleWindowReply.WindowHandle;
2717 }
2718
2719
2720 /* EOF */