e4250c52b372da501d11bff09a5c98a1b89dd30a
[reactos.git] / dll / win32 / kernel32 / client / console / console.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: dll/win32/kernel32/client/console/console.c
5 * PURPOSE: Win32 server console functions
6 * PROGRAMMER: James Tabor
7 * <jimtabor@adsl-64-217-116-74.dsl.hstntx.swbell.net>
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 <debug.h>
20
21 extern RTL_CRITICAL_SECTION ConsoleLock;
22 extern BOOL ConsoleInitialized;
23 extern BOOL WINAPI IsDebuggerPresent(VOID);
24
25 /* GLOBALS ********************************************************************/
26
27 PHANDLER_ROUTINE InitialHandler[1];
28 PHANDLER_ROUTINE* CtrlHandlers;
29 ULONG NrCtrlHandlers;
30 ULONG NrAllocatedHandlers;
31
32 #define INPUTEXENAME_BUFLEN 256
33 static WCHAR InputExeName[INPUTEXENAME_BUFLEN];
34
35 /* Default Console Control Handler ********************************************/
36
37 BOOL
38 WINAPI
39 DefaultConsoleCtrlHandler(DWORD Event)
40 {
41 DPRINT("Default handler called: %lx\n", Event);
42 switch(Event)
43 {
44 case CTRL_C_EVENT:
45 DPRINT("Ctrl-C Event\n");
46 break;
47
48 case CTRL_BREAK_EVENT:
49 DPRINT("Ctrl-Break Event\n");
50 break;
51
52 case CTRL_SHUTDOWN_EVENT:
53 DPRINT("Ctrl Shutdown Event\n");
54 break;
55
56 case CTRL_CLOSE_EVENT:
57 DPRINT("Ctrl Close Event\n");
58 break;
59
60 case CTRL_LOGOFF_EVENT:
61 DPRINT("Ctrl Logoff Event\n");
62 break;
63 }
64
65 ExitProcess(CONTROL_C_EXIT);
66 return TRUE;
67 }
68
69 DWORD
70 WINAPI
71 ConsoleControlDispatcher(IN LPVOID lpThreadParameter)
72 {
73 DWORD nExitCode = 0;
74 DWORD CodeAndFlag = PtrToUlong(lpThreadParameter);
75 DWORD nCode = CodeAndFlag & MAXLONG;
76 UINT i;
77 EXCEPTION_RECORD erException;
78
79 DPRINT("Console Dispatcher Active: %lx %lx\n", CodeAndFlag, nCode);
80 SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST);
81
82 switch(nCode)
83 {
84 case CTRL_C_EVENT:
85 case CTRL_BREAK_EVENT:
86 {
87 if (IsDebuggerPresent())
88 {
89 erException.ExceptionCode = (nCode == CTRL_C_EVENT ?
90 DBG_CONTROL_C : DBG_CONTROL_BREAK);
91 erException.ExceptionFlags = 0;
92 erException.ExceptionRecord = NULL;
93 erException.ExceptionAddress = DefaultConsoleCtrlHandler;
94 erException.NumberParameters = 0;
95
96 _SEH2_TRY
97 {
98 RtlRaiseException(&erException);
99 }
100 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
101 {
102 RtlEnterCriticalSection(&ConsoleLock);
103
104 if ((nCode != CTRL_C_EVENT) ||
105 (NtCurrentPeb()->ProcessParameters->ConsoleFlags != 1))
106 {
107 for (i = NrCtrlHandlers; i > 0; i--)
108 {
109 if (CtrlHandlers[i - 1](nCode)) break;
110 }
111 }
112
113 RtlLeaveCriticalSection(&ConsoleLock);
114 }
115 _SEH2_END;
116
117 ExitThread(0);
118 }
119 break;
120 }
121
122 case CTRL_CLOSE_EVENT:
123 case CTRL_LOGOFF_EVENT:
124 case CTRL_SHUTDOWN_EVENT:
125 break;
126
127 case 3:
128 ExitThread(0);
129 break;
130
131 case 4:
132 ExitProcess(CONTROL_C_EXIT);
133 break;
134
135 default:
136 ASSERT(FALSE);
137 break;
138 }
139
140 ASSERT(ConsoleInitialized);
141
142 RtlEnterCriticalSection(&ConsoleLock);
143 nExitCode = 0;
144 if ((nCode != CTRL_C_EVENT) || (NtCurrentPeb()->ProcessParameters->ConsoleFlags != 1))
145 {
146 for (i = NrCtrlHandlers; i > 0; i--)
147 {
148 if ((i == 1) &&
149 (CodeAndFlag & MINLONG) &&
150 ((nCode == CTRL_LOGOFF_EVENT) || (nCode == CTRL_SHUTDOWN_EVENT)))
151 {
152 DPRINT("Skipping system/service apps\n");
153 break;
154 }
155
156 if (CtrlHandlers[i - 1](nCode))
157 {
158 switch(nCode)
159 {
160 case CTRL_CLOSE_EVENT:
161 case CTRL_LOGOFF_EVENT:
162 case CTRL_SHUTDOWN_EVENT:
163 case 3:
164 nExitCode = CodeAndFlag;
165 break;
166 }
167 break;
168 }
169 }
170 }
171
172 RtlLeaveCriticalSection(&ConsoleLock);
173 ExitThread(nExitCode);
174 return STATUS_SUCCESS;
175 }
176
177
178 /* FUNCTIONS ******************************************************************/
179
180 /*
181 * @unimplemented (Undocumented)
182 */
183 BOOL
184 WINAPI
185 ConsoleMenuControl(HANDLE hConsole,
186 DWORD Unknown1,
187 DWORD Unknown2)
188 {
189 DPRINT1("ConsoleMenuControl(0x%x, 0x%x, 0x%x) UNIMPLEMENTED!\n", hConsole, Unknown1, Unknown2);
190 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
191 return FALSE;
192 }
193
194
195 /*
196 * @implemented
197 */
198 HANDLE
199 WINAPI
200 DuplicateConsoleHandle(HANDLE hConsole,
201 DWORD dwDesiredAccess,
202 BOOL bInheritHandle,
203 DWORD dwOptions)
204 {
205 CSR_API_MESSAGE Request;
206 NTSTATUS Status;
207
208 if (dwOptions & ~(DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS)
209 || (!(dwOptions & DUPLICATE_SAME_ACCESS)
210 && dwDesiredAccess & ~(GENERIC_READ | GENERIC_WRITE)))
211 {
212 SetLastError (ERROR_INVALID_PARAMETER);
213 return INVALID_HANDLE_VALUE;
214 }
215
216 Request.Data.DuplicateHandleRequest.Handle = hConsole;
217 Request.Data.DuplicateHandleRequest.Access = dwDesiredAccess;
218 Request.Data.DuplicateHandleRequest.Inheritable = bInheritHandle;
219 Request.Data.DuplicateHandleRequest.Options = dwOptions;
220
221 Status = CsrClientCallServer(&Request,
222 NULL,
223 CSR_CREATE_API_NUMBER(CSR_NATIVE, DUPLICATE_HANDLE),
224 sizeof(CSR_API_MESSAGE));
225 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status=Request.Status))
226 {
227 BaseSetLastNTError(Status);
228 return INVALID_HANDLE_VALUE;
229 }
230
231 return Request.Data.DuplicateHandleRequest.Handle;
232 }
233
234
235 /*
236 * @unimplemented
237 */
238 INT
239 WINAPI
240 GetConsoleDisplayMode(LPDWORD lpdwMode)
241 /*
242 * FUNCTION: Get the console display mode
243 * ARGUMENTS:
244 * lpdwMode - Address of variable that receives the current value
245 * of display mode
246 * STATUS: Undocumented
247 */
248 {
249 DPRINT1("GetConsoleDisplayMode(0x%x) UNIMPLEMENTED!\n", lpdwMode);
250 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
251 return 0;
252 }
253
254
255 /*
256 * @unimplemented (Undocumented)
257 */
258 DWORD
259 WINAPI
260 GetConsoleFontInfo(DWORD Unknown0,
261 DWORD Unknown1,
262 DWORD Unknown2,
263 DWORD Unknown3)
264 {
265 DPRINT1("GetConsoleFontInfo(0x%x, 0x%x, 0x%x, 0x%x) UNIMPLEMENTED!\n", Unknown0, Unknown1, Unknown2, Unknown3);
266 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
267 return 0;
268 }
269
270
271 /*
272 * @unimplemented
273 */
274 COORD
275 WINAPI
276 GetConsoleFontSize(HANDLE hConsoleOutput,
277 DWORD nFont)
278 {
279 COORD Empty = {0, 0};
280 DPRINT1("GetConsoleFontSize(0x%x, 0x%x) UNIMPLEMENTED!\n", hConsoleOutput, nFont);
281 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
282 return Empty;
283 }
284
285
286 /*
287 * @implemented (Undocumented)
288 */
289 DWORD
290 WINAPI
291 GetConsoleHardwareState(HANDLE hConsole,
292 DWORD Flags,
293 PDWORD State)
294 {
295 CSR_API_MESSAGE Request;
296 NTSTATUS Status;
297
298 Request.Data.ConsoleHardwareStateRequest.ConsoleHandle = hConsole;
299 Request.Data.ConsoleHardwareStateRequest.SetGet = CONSOLE_HARDWARE_STATE_GET;
300
301 Status = CsrClientCallServer(&Request,
302 NULL,
303 CSR_CREATE_API_NUMBER(CSR_CONSOLE, SETGET_CONSOLE_HW_STATE),
304 sizeof(CSR_API_MESSAGE));
305 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
306 {
307 BaseSetLastNTError(Status);
308 return FALSE;
309 }
310
311 *State = Request.Data.ConsoleHardwareStateRequest.State;
312 return TRUE;
313 }
314
315
316 /*
317 * @implemented (Undocumented)
318 */
319 HANDLE
320 WINAPI
321 GetConsoleInputWaitHandle(VOID)
322 {
323 CSR_API_MESSAGE Request;
324 NTSTATUS Status;
325
326 Status = CsrClientCallServer(&Request,
327 NULL,
328 CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_INPUT_WAIT_HANDLE),
329 sizeof(CSR_API_MESSAGE));
330 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
331 {
332 BaseSetLastNTError(Status);
333 return 0;
334 }
335
336 return Request.Data.GetConsoleInputWaitHandle.InputWaitHandle;
337 }
338
339
340 /*
341 * @unimplemented
342 */
343 INT
344 WINAPI
345 GetCurrentConsoleFont(HANDLE hConsoleOutput,
346 BOOL bMaximumWindow,
347 PCONSOLE_FONT_INFO lpConsoleCurrentFont)
348 {
349 DPRINT1("GetCurrentConsoleFont(0x%x, 0x%x, 0x%x) UNIMPLEMENTED!\n", hConsoleOutput, bMaximumWindow, lpConsoleCurrentFont);
350 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
351 return 0;
352 }
353
354
355 /*
356 * @unimplemented (Undocumented)
357 */
358 ULONG
359 WINAPI
360 GetNumberOfConsoleFonts(VOID)
361 {
362 DPRINT1("GetNumberOfConsoleFonts() UNIMPLEMENTED!\n");
363 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
364 return 1; /* FIXME: call csrss.exe */
365 }
366
367
368 /*
369 * @unimplemented (Undocumented)
370 */
371 DWORD
372 WINAPI
373 InvalidateConsoleDIBits(DWORD Unknown0,
374 DWORD Unknown1)
375 {
376 DPRINT1("InvalidateConsoleDIBits(0x%x, 0x%x) UNIMPLEMENTED!\n", Unknown0, Unknown1);
377 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
378 return 0;
379 }
380
381
382 /*
383 * @unimplemented (Undocumented)
384 */
385 HANDLE
386 WINAPI
387 OpenConsoleW(LPCWSTR wsName,
388 DWORD dwDesiredAccess,
389 BOOL bInheritHandle,
390 DWORD dwShareMode)
391 {
392 CSR_API_MESSAGE Request;
393 ULONG CsrRequest;
394 NTSTATUS Status = STATUS_SUCCESS;
395
396 if (wsName && 0 == _wcsicmp(wsName, L"CONIN$"))
397 {
398 CsrRequest = CSR_CREATE_API_NUMBER(CSR_NATIVE, GET_INPUT_HANDLE);
399 }
400 else if (wsName && 0 == _wcsicmp(wsName, L"CONOUT$"))
401 {
402 CsrRequest = CSR_CREATE_API_NUMBER(CSR_NATIVE, GET_OUTPUT_HANDLE);
403 }
404 else
405 {
406 SetLastError(ERROR_INVALID_PARAMETER);
407 return(INVALID_HANDLE_VALUE);
408 }
409
410 if (dwDesiredAccess & ~(GENERIC_READ|GENERIC_WRITE))
411 {
412 SetLastError(ERROR_INVALID_PARAMETER);
413 return(INVALID_HANDLE_VALUE);
414 }
415
416 if (dwShareMode & ~(FILE_SHARE_READ|FILE_SHARE_WRITE))
417 {
418 SetLastError(ERROR_INVALID_PARAMETER);
419 return(INVALID_HANDLE_VALUE);
420 }
421
422 /* Structures for GET_INPUT_HANDLE and GET_OUTPUT_HANDLE requests are identical */
423 Request.Data.GetInputHandleRequest.Access = dwDesiredAccess;
424 Request.Data.GetInputHandleRequest.Inheritable = bInheritHandle;
425 Request.Data.GetInputHandleRequest.ShareMode = dwShareMode;
426
427 Status = CsrClientCallServer(&Request,
428 NULL,
429 CsrRequest,
430 sizeof(CSR_API_MESSAGE));
431 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
432 {
433 BaseSetLastNTError(Status);
434 return INVALID_HANDLE_VALUE;
435 }
436
437 return Request.Data.GetInputHandleRequest.Handle;
438 }
439
440
441 /*
442 * @unimplemented (Undocumented)
443 */
444 BOOL
445 WINAPI
446 SetConsoleCursor(DWORD Unknown0,
447 DWORD Unknown1)
448 {
449 DPRINT1("SetConsoleCursor(0x%x, 0x%x) UNIMPLEMENTED!\n", Unknown0, Unknown1);
450 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
451 return FALSE;
452 }
453
454
455 /*
456 * @unimplemented
457 */
458 BOOL
459 WINAPI
460 SetConsoleDisplayMode(HANDLE hOut,
461 DWORD dwNewMode,
462 PCOORD lpdwOldMode)
463 /*
464 * FUNCTION: Set the console display mode.
465 * ARGUMENTS:
466 * hOut - Standard output handle.
467 * dwNewMode - New mode.
468 * lpdwOldMode - Address of a variable that receives the old mode.
469 */
470 {
471 DPRINT1("SetConsoleDisplayMode(0x%x, 0x%x, 0x%p) UNIMPLEMENTED!\n", hOut, dwNewMode, lpdwOldMode);
472 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
473 return FALSE;
474 }
475
476
477 /*
478 * @unimplemented (Undocumented)
479 */
480 BOOL
481 WINAPI
482 SetConsoleFont(DWORD Unknown0,
483 DWORD Unknown1)
484 {
485 DPRINT1("SetConsoleFont(0x%x, 0x%x) UNIMPLEMENTED!\n", Unknown0, Unknown1);
486 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
487 return FALSE;
488 }
489
490
491 /*
492 * @implemented (Undocumented)
493 */
494 BOOL
495 WINAPI
496 SetConsoleHardwareState(HANDLE hConsole,
497 DWORD Flags,
498 DWORD State)
499 {
500 CSR_API_MESSAGE Request;
501 NTSTATUS Status;
502
503 Request.Data.ConsoleHardwareStateRequest.ConsoleHandle = hConsole;
504 Request.Data.ConsoleHardwareStateRequest.SetGet = CONSOLE_HARDWARE_STATE_SET;
505 Request.Data.ConsoleHardwareStateRequest.State = State;
506
507 Status = CsrClientCallServer(&Request,
508 NULL,
509 CSR_CREATE_API_NUMBER(CSR_CONSOLE, SETGET_CONSOLE_HW_STATE),
510 sizeof(CSR_API_MESSAGE));
511 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
512 {
513 BaseSetLastNTError(Status);
514 return FALSE;
515 }
516
517 return TRUE;
518 }
519
520
521 /*
522 * @unimplemented (Undocumented)
523 */
524 BOOL
525 WINAPI
526 SetConsoleKeyShortcuts(DWORD Unknown0,
527 DWORD Unknown1,
528 DWORD Unknown2,
529 DWORD Unknown3)
530 {
531 DPRINT1("SetConsoleKeyShortcuts(0x%x, 0x%x, 0x%x, 0x%x) UNIMPLEMENTED!\n", Unknown0, Unknown1, Unknown2, Unknown3);
532 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
533 return FALSE;
534 }
535
536
537 /*
538 * @unimplemented (Undocumented)
539 */
540 BOOL
541 WINAPI
542 SetConsoleMaximumWindowSize(DWORD Unknown0,
543 DWORD Unknown1)
544 {
545 DPRINT1("SetConsoleMaximumWindowSize(0x%x, 0x%x) UNIMPLEMENTED!\n", Unknown0, Unknown1);
546 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
547 return FALSE;
548 }
549
550
551 /*
552 * @unimplemented (Undocumented)
553 */
554 BOOL
555 WINAPI
556 SetConsoleMenuClose(DWORD Unknown0)
557 {
558 DPRINT1("SetConsoleMenuClose(0x%x) UNIMPLEMENTED!\n", Unknown0);
559 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
560 return FALSE;
561 }
562
563
564 /*
565 * @unimplemented (Undocumented)
566 */
567 BOOL
568 WINAPI
569 SetConsolePalette(DWORD Unknown0,
570 DWORD Unknown1,
571 DWORD Unknown2)
572 {
573 DPRINT1("SetConsolePalette(0x%x, 0x%x, 0x%x) UNIMPLEMENTED!\n", Unknown0, Unknown1, Unknown2);
574 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
575 return FALSE;
576 }
577
578 /*
579 * @unimplemented (Undocumented)
580 */
581 DWORD
582 WINAPI
583 ShowConsoleCursor(DWORD Unknown0,
584 DWORD Unknown1)
585 {
586 DPRINT1("ShowConsoleCursor(0x%x, 0x%x) UNIMPLEMENTED!\n", Unknown0, Unknown1);
587 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
588 return 0;
589 }
590
591
592 /*
593 * FUNCTION: Checks whether the given handle is a valid console handle.
594 * ARGUMENTS:
595 * Handle - Handle to be checked
596 * RETURNS:
597 * TRUE: Handle is a valid console handle
598 * FALSE: Handle is not a valid console handle.
599 * STATUS: Officially undocumented
600 *
601 * @implemented
602 */
603 BOOL
604 WINAPI
605 VerifyConsoleIoHandle(HANDLE Handle)
606 {
607 CSR_API_MESSAGE Request;
608 NTSTATUS Status;
609
610 Request.Data.VerifyHandleRequest.Handle = Handle;
611
612 Status = CsrClientCallServer(&Request,
613 NULL,
614 CSR_CREATE_API_NUMBER(CSR_NATIVE, VERIFY_HANDLE),
615 sizeof(CSR_API_MESSAGE));
616 if (!NT_SUCCESS(Status))
617 {
618 BaseSetLastNTError(Status);
619 return FALSE;
620 }
621
622 return (BOOL)NT_SUCCESS(Request.Status);
623 }
624
625
626 /*
627 * @unimplemented
628 */
629 DWORD
630 WINAPI
631 WriteConsoleInputVDMA(DWORD Unknown0,
632 DWORD Unknown1,
633 DWORD Unknown2,
634 DWORD Unknown3)
635 {
636 DPRINT1("WriteConsoleInputVDMA(0x%x, 0x%x, 0x%x, 0x%x) UNIMPLEMENTED!\n", Unknown0, Unknown1, Unknown2, Unknown3);
637 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
638 return 0;
639 }
640
641
642 /*
643 * @unimplemented
644 */
645 DWORD
646 WINAPI
647 WriteConsoleInputVDMW(DWORD Unknown0,
648 DWORD Unknown1,
649 DWORD Unknown2,
650 DWORD Unknown3)
651 {
652 DPRINT1("WriteConsoleInputVDMW(0x%x, 0x%x, 0x%x, 0x%x) UNIMPLEMENTED!\n", Unknown0, Unknown1, Unknown2, Unknown3);
653 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
654 return 0;
655 }
656
657
658 /*
659 * @implemented (Undocumented)
660 */
661 BOOL
662 WINAPI
663 CloseConsoleHandle(HANDLE Handle)
664 {
665 CSR_API_MESSAGE Request;
666 NTSTATUS Status;
667
668 Request.Data.CloseHandleRequest.Handle = Handle;
669
670 Status = CsrClientCallServer(&Request,
671 NULL,
672 CSR_CREATE_API_NUMBER(CSR_NATIVE, CLOSE_HANDLE),
673 sizeof(CSR_API_MESSAGE));
674 if (!NT_SUCCESS(Status))
675 {
676 BaseSetLastNTError(Status);
677 return FALSE;
678 }
679
680 return TRUE;
681 }
682
683 /*
684 * @implemented
685 */
686 HANDLE
687 WINAPI
688 GetStdHandle(DWORD nStdHandle)
689 /*
690 * FUNCTION: Get a handle for the standard input, standard output
691 * and a standard error device.
692 * ARGUMENTS:
693 * nStdHandle - Specifies the device for which to return the handle.
694 * RETURNS: If the function succeeds, the return value is the handle
695 * of the specified device. Otherwise the value is INVALID_HANDLE_VALUE.
696 */
697 {
698 PRTL_USER_PROCESS_PARAMETERS Ppb;
699
700 Ppb = NtCurrentPeb()->ProcessParameters;
701 switch (nStdHandle)
702 {
703 case STD_INPUT_HANDLE:
704 return Ppb->StandardInput;
705
706 case STD_OUTPUT_HANDLE:
707 return Ppb->StandardOutput;
708
709 case STD_ERROR_HANDLE:
710 return Ppb->StandardError;
711 }
712
713 SetLastError (ERROR_INVALID_PARAMETER);
714 return INVALID_HANDLE_VALUE;
715 }
716
717
718 /*
719 * @implemented
720 */
721 BOOL
722 WINAPI
723 SetStdHandle(DWORD nStdHandle,
724 HANDLE hHandle)
725 /*
726 * FUNCTION: Set the handle for the standard input, standard output or
727 * the standard error device.
728 * ARGUMENTS:
729 * nStdHandle - Specifies the handle to be set.
730 * hHandle - The handle to set.
731 * RETURNS: TRUE if the function succeeds, FALSE otherwise.
732 */
733 {
734 PRTL_USER_PROCESS_PARAMETERS Ppb;
735
736 /* no need to check if hHandle == INVALID_HANDLE_VALUE */
737
738 Ppb = NtCurrentPeb()->ProcessParameters;
739
740 switch (nStdHandle)
741 {
742 case STD_INPUT_HANDLE:
743 Ppb->StandardInput = hHandle;
744 return TRUE;
745
746 case STD_OUTPUT_HANDLE:
747 Ppb->StandardOutput = hHandle;
748 return TRUE;
749
750 case STD_ERROR_HANDLE:
751 Ppb->StandardError = hHandle;
752 return TRUE;
753 }
754
755 /* windows for whatever reason sets the last error to ERROR_INVALID_HANDLE here */
756 SetLastError(ERROR_INVALID_HANDLE);
757 return FALSE;
758 }
759
760
761 /*--------------------------------------------------------------
762 * AllocConsole
763 *
764 * @implemented
765 */
766 BOOL
767 WINAPI
768 AllocConsole(VOID)
769 {
770 CSR_API_MESSAGE Request;
771 NTSTATUS Status;
772 HANDLE hStdError;
773 STARTUPINFO si;
774
775 if (NtCurrentPeb()->ProcessParameters->ConsoleHandle)
776 {
777 DPRINT("AllocConsole: Allocate duplicate console to the same Process\n");
778 BaseSetLastNTError (STATUS_OBJECT_NAME_EXISTS);
779 return FALSE;
780 }
781
782 GetStartupInfo(&si);
783
784 Request.Data.AllocConsoleRequest.CtrlDispatcher = ConsoleControlDispatcher;
785 Request.Data.AllocConsoleRequest.ConsoleNeeded = TRUE;
786 Request.Data.AllocConsoleRequest.ShowCmd = si.wShowWindow;
787
788 Status = CsrClientCallServer(&Request,
789 NULL,
790 CSR_CREATE_API_NUMBER(CSR_CONSOLE, ALLOC_CONSOLE),
791 sizeof(CSR_API_MESSAGE));
792 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
793 {
794 BaseSetLastNTError(Status);
795 return FALSE;
796 }
797
798 NtCurrentPeb()->ProcessParameters->ConsoleHandle = Request.Data.AllocConsoleRequest.Console;
799
800 SetStdHandle(STD_INPUT_HANDLE, Request.Data.AllocConsoleRequest.InputHandle);
801 SetStdHandle(STD_OUTPUT_HANDLE, Request.Data.AllocConsoleRequest.OutputHandle);
802
803 hStdError = DuplicateConsoleHandle(Request.Data.AllocConsoleRequest.OutputHandle,
804 0,
805 TRUE,
806 DUPLICATE_SAME_ACCESS);
807
808 SetStdHandle(STD_ERROR_HANDLE, hStdError);
809 return TRUE;
810 }
811
812
813 /*--------------------------------------------------------------
814 * FreeConsole
815 *
816 * @implemented
817 */
818 BOOL
819 WINAPI
820 FreeConsole(VOID)
821 {
822 // AG: I'm not sure if this is correct (what happens to std handles?)
823 // but I just tried to reverse what AllocConsole() does...
824
825 CSR_API_MESSAGE Request;
826 NTSTATUS Status;
827
828 Status = CsrClientCallServer(&Request,
829 NULL,
830 CSR_CREATE_API_NUMBER(CSR_CONSOLE, FREE_CONSOLE),
831 sizeof(CSR_API_MESSAGE));
832 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
833 {
834 BaseSetLastNTError(Status);
835 return FALSE;
836 }
837
838 NtCurrentPeb()->ProcessParameters->ConsoleHandle = NULL;
839 return TRUE;
840 }
841
842
843 /*--------------------------------------------------------------
844 * GetConsoleScreenBufferInfo
845 *
846 * @implemented
847 */
848 BOOL
849 WINAPI
850 GetConsoleScreenBufferInfo(HANDLE hConsoleOutput,
851 PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
852 {
853 CSR_API_MESSAGE Request;
854 NTSTATUS Status;
855
856 Request.Data.ScreenBufferInfoRequest.ConsoleHandle = hConsoleOutput;
857
858 Status = CsrClientCallServer(&Request,
859 NULL,
860 CSR_CREATE_API_NUMBER(CSR_CONSOLE, SCREEN_BUFFER_INFO),
861 sizeof(CSR_API_MESSAGE));
862 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
863 {
864 BaseSetLastNTError(Status);
865 return FALSE;
866 }
867 *lpConsoleScreenBufferInfo = Request.Data.ScreenBufferInfoRequest.Info;
868 return TRUE;
869 }
870
871
872 /*--------------------------------------------------------------
873 * SetConsoleCursorPosition
874 *
875 * @implemented
876 */
877 BOOL
878 WINAPI
879 SetConsoleCursorPosition(HANDLE hConsoleOutput,
880 COORD dwCursorPosition)
881 {
882 CSR_API_MESSAGE Request;
883 NTSTATUS Status;
884
885 Request.Data.SetCursorRequest.ConsoleHandle = hConsoleOutput;
886 Request.Data.SetCursorRequest.Position = dwCursorPosition;
887
888 Status = CsrClientCallServer(&Request,
889 NULL,
890 CSR_CREATE_API_NUMBER(CSR_CONSOLE, SET_CURSOR),
891 sizeof(CSR_API_MESSAGE));
892 if(!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
893 {
894 BaseSetLastNTError(Status);
895 return FALSE;
896 }
897
898 return TRUE;
899 }
900
901
902 /*--------------------------------------------------------------
903 * GetConsoleMode
904 *
905 * @implemented
906 */
907 BOOL
908 WINAPI
909 GetConsoleMode(HANDLE hConsoleHandle,
910 LPDWORD lpMode)
911 {
912 CSR_API_MESSAGE Request;
913 NTSTATUS Status;
914
915 Request.Data.GetConsoleModeRequest.ConsoleHandle = hConsoleHandle;
916
917 Status = CsrClientCallServer(&Request,
918 NULL,
919 CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_CONSOLE_MODE),
920 sizeof(CSR_API_MESSAGE));
921 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
922 {
923 BaseSetLastNTError(Status);
924 return FALSE;
925 }
926
927 *lpMode = Request.Data.GetConsoleModeRequest.ConsoleMode;
928
929 return TRUE;
930 }
931
932
933 /*--------------------------------------------------------------
934 * GetNumberOfConsoleInputEvents
935 *
936 * @implemented
937 */
938 BOOL
939 WINAPI
940 GetNumberOfConsoleInputEvents(HANDLE hConsoleInput,
941 LPDWORD lpNumberOfEvents)
942 {
943 CSR_API_MESSAGE Request;
944 NTSTATUS Status;
945
946 if (lpNumberOfEvents == NULL)
947 {
948 SetLastError(ERROR_INVALID_PARAMETER);
949 return FALSE;
950 }
951
952 Request.Data.GetNumInputEventsRequest.ConsoleHandle = hConsoleInput;
953
954 Status = CsrClientCallServer(&Request,
955 NULL,
956 CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_NUM_INPUT_EVENTS),
957 sizeof(CSR_API_MESSAGE));
958 if(!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
959 {
960 BaseSetLastNTError(Status);
961 return FALSE;
962 }
963
964 *lpNumberOfEvents = Request.Data.GetNumInputEventsRequest.NumInputEvents;
965
966 return TRUE;
967 }
968
969
970 /*--------------------------------------------------------------
971 * GetLargestConsoleWindowSize
972 *
973 * @unimplemented
974 */
975 COORD
976 WINAPI
977 GetLargestConsoleWindowSize(HANDLE hConsoleOutput)
978 {
979 COORD Coord = {80,25};
980 DPRINT1("GetLargestConsoleWindowSize(0x%x) UNIMPLEMENTED!\n", hConsoleOutput);
981 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
982 return Coord;
983 }
984
985
986 /*--------------------------------------------------------------
987 * GetConsoleCursorInfo
988 *
989 * @implemented
990 */
991 BOOL
992 WINAPI
993 GetConsoleCursorInfo(HANDLE hConsoleOutput,
994 PCONSOLE_CURSOR_INFO lpConsoleCursorInfo)
995 {
996 CSR_API_MESSAGE Request;
997 NTSTATUS Status;
998
999 if (!lpConsoleCursorInfo)
1000 {
1001 if (!hConsoleOutput)
1002 SetLastError(ERROR_INVALID_HANDLE);
1003 else
1004 SetLastError(ERROR_INVALID_ACCESS);
1005
1006 return FALSE;
1007 }
1008
1009 Request.Data.GetCursorInfoRequest.ConsoleHandle = hConsoleOutput;
1010
1011 Status = CsrClientCallServer(&Request,
1012 NULL,
1013 CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_CURSOR_INFO),
1014 sizeof(CSR_API_MESSAGE));
1015 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
1016 {
1017 BaseSetLastNTError(Status);
1018 return FALSE;
1019 }
1020
1021 *lpConsoleCursorInfo = Request.Data.GetCursorInfoRequest.Info;
1022
1023 return TRUE;
1024 }
1025
1026
1027 /*--------------------------------------------------------------
1028 * GetNumberOfConsoleMouseButtons
1029 *
1030 * @unimplemented
1031 */
1032 BOOL
1033 WINAPI
1034 GetNumberOfConsoleMouseButtons(LPDWORD lpNumberOfMouseButtons)
1035 {
1036 DPRINT1("GetNumberOfConsoleMouseButtons(0x%x) UNIMPLEMENTED!\n", lpNumberOfMouseButtons);
1037 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1038 return FALSE;
1039 }
1040
1041
1042 /*--------------------------------------------------------------
1043 * SetConsoleMode
1044 *
1045 * @implemented
1046 */
1047 BOOL
1048 WINAPI
1049 SetConsoleMode(HANDLE hConsoleHandle,
1050 DWORD dwMode)
1051 {
1052 CSR_API_MESSAGE Request;
1053 NTSTATUS Status;
1054
1055 Request.Data.SetConsoleModeRequest.ConsoleHandle = hConsoleHandle;
1056 Request.Data.SetConsoleModeRequest.Mode = dwMode;
1057
1058 Status = CsrClientCallServer(&Request,
1059 NULL,
1060 CSR_CREATE_API_NUMBER(CSR_CONSOLE, SET_CONSOLE_MODE),
1061 sizeof(CSR_API_MESSAGE));
1062 if(!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
1063 {
1064 BaseSetLastNTError(Status);
1065 return FALSE;
1066 }
1067
1068 return TRUE;
1069 }
1070
1071
1072 /*--------------------------------------------------------------
1073 * SetConsoleActiveScreenBuffer
1074 *
1075 * @implemented
1076 */
1077 BOOL
1078 WINAPI
1079 SetConsoleActiveScreenBuffer(HANDLE hConsoleOutput)
1080 {
1081 CSR_API_MESSAGE Request;
1082 NTSTATUS Status;
1083
1084 Request.Data.SetScreenBufferRequest.OutputHandle = hConsoleOutput;
1085
1086 Status = CsrClientCallServer(&Request,
1087 NULL,
1088 CSR_CREATE_API_NUMBER(CSR_CONSOLE, SET_SCREEN_BUFFER),
1089 sizeof(CSR_API_MESSAGE));
1090 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
1091 {
1092 BaseSetLastNTError(Status);
1093 return FALSE;
1094 }
1095
1096 return TRUE;
1097 }
1098
1099
1100 /*--------------------------------------------------------------
1101 * FlushConsoleInputBuffer
1102 *
1103 * @implemented
1104 */
1105 BOOL
1106 WINAPI
1107 FlushConsoleInputBuffer(HANDLE hConsoleInput)
1108 {
1109 CSR_API_MESSAGE Request;
1110 NTSTATUS Status;
1111
1112 Request.Data.FlushInputBufferRequest.ConsoleInput = hConsoleInput;
1113
1114 Status = CsrClientCallServer(&Request,
1115 NULL,
1116 CSR_CREATE_API_NUMBER(CSR_CONSOLE, FLUSH_INPUT_BUFFER),
1117 sizeof(CSR_API_MESSAGE));
1118 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
1119 {
1120 BaseSetLastNTError(Status);
1121 return FALSE;
1122 }
1123
1124 return TRUE;
1125 }
1126
1127
1128 /*--------------------------------------------------------------
1129 * SetConsoleScreenBufferSize
1130 *
1131 * @implemented
1132 */
1133 BOOL
1134 WINAPI
1135 SetConsoleScreenBufferSize(HANDLE hConsoleOutput,
1136 COORD dwSize)
1137 {
1138 CSR_API_MESSAGE Request;
1139 NTSTATUS Status;
1140
1141 Request.Data.SetScreenBufferSize.OutputHandle = hConsoleOutput;
1142 Request.Data.SetScreenBufferSize.Size = dwSize;
1143
1144 Status = CsrClientCallServer(&Request,
1145 NULL,
1146 CSR_CREATE_API_NUMBER(CSR_CONSOLE, SET_SCREEN_BUFFER_SIZE),
1147 sizeof(CSR_API_MESSAGE));
1148 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
1149 {
1150 BaseSetLastNTError(Status);
1151 return FALSE;
1152 }
1153
1154 return TRUE;
1155 }
1156
1157 /*--------------------------------------------------------------
1158 * SetConsoleCursorInfo
1159 *
1160 * @implemented
1161 */
1162 BOOL
1163 WINAPI
1164 SetConsoleCursorInfo(HANDLE hConsoleOutput,
1165 CONST CONSOLE_CURSOR_INFO *lpConsoleCursorInfo)
1166 {
1167 CSR_API_MESSAGE Request;
1168 NTSTATUS Status;
1169
1170 Request.Data.SetCursorInfoRequest.ConsoleHandle = hConsoleOutput;
1171 Request.Data.SetCursorInfoRequest.Info = *lpConsoleCursorInfo;
1172
1173 Status = CsrClientCallServer(&Request,
1174 NULL,
1175 CSR_CREATE_API_NUMBER(CSR_CONSOLE, SET_CURSOR_INFO),
1176 sizeof(CSR_API_MESSAGE));
1177 if(!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
1178 {
1179 BaseSetLastNTError(Status);
1180 return FALSE;
1181 }
1182
1183 return TRUE;
1184 }
1185
1186
1187 static
1188 BOOL
1189 IntScrollConsoleScreenBuffer(HANDLE hConsoleOutput,
1190 const SMALL_RECT *lpScrollRectangle,
1191 const SMALL_RECT *lpClipRectangle,
1192 COORD dwDestinationOrigin,
1193 const CHAR_INFO *lpFill,
1194 BOOL bUnicode)
1195 {
1196 CSR_API_MESSAGE Request;
1197 NTSTATUS Status;
1198
1199 Request.Data.ScrollConsoleScreenBufferRequest.ConsoleHandle = hConsoleOutput;
1200 Request.Data.ScrollConsoleScreenBufferRequest.Unicode = bUnicode;
1201 Request.Data.ScrollConsoleScreenBufferRequest.ScrollRectangle = *lpScrollRectangle;
1202
1203 if (lpClipRectangle != NULL)
1204 {
1205 Request.Data.ScrollConsoleScreenBufferRequest.UseClipRectangle = TRUE;
1206 Request.Data.ScrollConsoleScreenBufferRequest.ClipRectangle = *lpClipRectangle;
1207 }
1208 else
1209 {
1210 Request.Data.ScrollConsoleScreenBufferRequest.UseClipRectangle = FALSE;
1211 }
1212
1213 Request.Data.ScrollConsoleScreenBufferRequest.DestinationOrigin = dwDestinationOrigin;
1214 Request.Data.ScrollConsoleScreenBufferRequest.Fill = *lpFill;
1215
1216 Status = CsrClientCallServer(&Request,
1217 NULL,
1218 CSR_CREATE_API_NUMBER(CSR_CONSOLE, SCROLL_CONSOLE_SCREEN_BUFFER),
1219 sizeof(CSR_API_MESSAGE));
1220
1221 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
1222 {
1223 BaseSetLastNTError(Status);
1224 return FALSE;
1225 }
1226
1227 return TRUE;
1228 }
1229
1230
1231 /*--------------------------------------------------------------
1232 * ScrollConsoleScreenBufferA
1233 *
1234 * @implemented
1235 */
1236 BOOL
1237 WINAPI
1238 ScrollConsoleScreenBufferA(HANDLE hConsoleOutput,
1239 CONST SMALL_RECT *lpScrollRectangle,
1240 CONST SMALL_RECT *lpClipRectangle,
1241 COORD dwDestinationOrigin,
1242 CONST CHAR_INFO *lpFill)
1243 {
1244 return IntScrollConsoleScreenBuffer(hConsoleOutput,
1245 (PSMALL_RECT)lpScrollRectangle,
1246 (PSMALL_RECT)lpClipRectangle,
1247 dwDestinationOrigin,
1248 (PCHAR_INFO)lpFill,
1249 FALSE);
1250 }
1251
1252
1253 /*--------------------------------------------------------------
1254 * ScrollConsoleScreenBufferW
1255 *
1256 * @implemented
1257 */
1258 BOOL
1259 WINAPI
1260 ScrollConsoleScreenBufferW(HANDLE hConsoleOutput,
1261 CONST SMALL_RECT *lpScrollRectangle,
1262 CONST SMALL_RECT *lpClipRectangle,
1263 COORD dwDestinationOrigin,
1264 CONST CHAR_INFO *lpFill)
1265 {
1266 return IntScrollConsoleScreenBuffer(hConsoleOutput,
1267 lpScrollRectangle,
1268 lpClipRectangle,
1269 dwDestinationOrigin,
1270 lpFill,
1271 TRUE);
1272 }
1273
1274
1275 /*--------------------------------------------------------------
1276 * SetConsoleWindowInfo
1277 *
1278 * @unimplemented
1279 */
1280 BOOL
1281 WINAPI
1282 SetConsoleWindowInfo(HANDLE hConsoleOutput,
1283 BOOL bAbsolute,
1284 CONST SMALL_RECT *lpConsoleWindow)
1285 {
1286 DPRINT1("SetConsoleWindowInfo(0x%x, 0x%x, 0x%x) UNIMPLEMENTED!\n", hConsoleOutput, bAbsolute, lpConsoleWindow);
1287 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1288 return FALSE;
1289 }
1290
1291
1292 /*--------------------------------------------------------------
1293 * SetConsoleTextAttribute
1294 *
1295 * @implemented
1296 */
1297 BOOL
1298 WINAPI
1299 SetConsoleTextAttribute(HANDLE hConsoleOutput,
1300 WORD wAttributes)
1301 {
1302 CSR_API_MESSAGE Request;
1303 NTSTATUS Status;
1304
1305 Request.Data.SetAttribRequest.ConsoleHandle = hConsoleOutput;
1306 Request.Data.SetAttribRequest.Attrib = wAttributes;
1307
1308 Status = CsrClientCallServer(&Request,
1309 NULL,
1310 CSR_CREATE_API_NUMBER(CSR_CONSOLE, SET_ATTRIB),
1311 sizeof(CSR_API_MESSAGE));
1312 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
1313 {
1314 BaseSetLastNTError(Status);
1315 return FALSE;
1316 }
1317
1318 return TRUE;
1319 }
1320
1321
1322 static
1323 BOOL
1324 AddConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine)
1325 {
1326 PHANDLER_ROUTINE* NewCtrlHandlers = NULL;
1327
1328 if (HandlerRoutine == NULL)
1329 {
1330 NtCurrentPeb()->ProcessParameters->ConsoleFlags = TRUE;
1331 return TRUE;
1332 }
1333
1334 if (NrCtrlHandlers == NrAllocatedHandlers)
1335 {
1336 NewCtrlHandlers = RtlAllocateHeap(RtlGetProcessHeap(),
1337 0,
1338 (NrCtrlHandlers + 4) * sizeof(PHANDLER_ROUTINE));
1339 if (NewCtrlHandlers == NULL)
1340 {
1341 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
1342 return FALSE;
1343 }
1344
1345 memmove(NewCtrlHandlers, CtrlHandlers, sizeof(PHANDLER_ROUTINE) * NrCtrlHandlers);
1346
1347 if (NrAllocatedHandlers > 1) RtlFreeHeap(RtlGetProcessHeap(), 0, CtrlHandlers);
1348
1349 CtrlHandlers = NewCtrlHandlers;
1350 NrAllocatedHandlers += 4;
1351 }
1352
1353 ASSERT(NrCtrlHandlers < NrAllocatedHandlers);
1354
1355 CtrlHandlers[NrCtrlHandlers++] = HandlerRoutine;
1356 return TRUE;
1357 }
1358
1359
1360 static
1361 BOOL
1362 RemoveConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine)
1363 {
1364 ULONG i;
1365
1366 if (HandlerRoutine == NULL)
1367 {
1368 NtCurrentPeb()->ProcessParameters->ConsoleFlags = FALSE;
1369 return TRUE;
1370 }
1371
1372 for (i = 0; i < NrCtrlHandlers; i++)
1373 {
1374 if (CtrlHandlers[i] == HandlerRoutine)
1375 {
1376 if (i < (NrCtrlHandlers - 1))
1377 {
1378 memmove(&CtrlHandlers[i],
1379 &CtrlHandlers[i+1],
1380 (NrCtrlHandlers - i + 1) * sizeof(PHANDLER_ROUTINE));
1381 }
1382
1383 NrCtrlHandlers--;
1384 return TRUE;
1385 }
1386 }
1387
1388 SetLastError(ERROR_INVALID_PARAMETER);
1389 return FALSE;
1390 }
1391
1392
1393 /*
1394 * @implemented
1395 */
1396 BOOL
1397 WINAPI
1398 SetConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine,
1399 BOOL Add)
1400 {
1401 BOOL Ret;
1402
1403 RtlEnterCriticalSection(&BaseDllDirectoryLock);
1404 if (Add)
1405 {
1406 Ret = AddConsoleCtrlHandler(HandlerRoutine);
1407 }
1408 else
1409 {
1410 Ret = RemoveConsoleCtrlHandler(HandlerRoutine);
1411 }
1412
1413 RtlLeaveCriticalSection(&BaseDllDirectoryLock);
1414 return(Ret);
1415 }
1416
1417
1418 /*--------------------------------------------------------------
1419 * GenerateConsoleCtrlEvent
1420 *
1421 * @implemented
1422 */
1423 BOOL
1424 WINAPI
1425 GenerateConsoleCtrlEvent(DWORD dwCtrlEvent,
1426 DWORD dwProcessGroupId)
1427 {
1428 CSR_API_MESSAGE Request;
1429 NTSTATUS Status;
1430
1431 if (dwCtrlEvent != CTRL_C_EVENT && dwCtrlEvent != CTRL_BREAK_EVENT)
1432 {
1433 SetLastError(ERROR_INVALID_PARAMETER);
1434 return FALSE;
1435 }
1436
1437 Request.Data.GenerateCtrlEvent.Event = dwCtrlEvent;
1438 Request.Data.GenerateCtrlEvent.ProcessGroup = dwProcessGroupId;
1439
1440 Status = CsrClientCallServer(&Request,
1441 NULL,
1442 CSR_CREATE_API_NUMBER(CSR_CONSOLE, GENERATE_CTRL_EVENT),
1443 sizeof(CSR_API_MESSAGE));
1444 if(!NT_SUCCESS(Status) || !(NT_SUCCESS(Status = Request.Status)))
1445 {
1446 BaseSetLastNTError(Status);
1447 return FALSE;
1448 }
1449
1450 return TRUE;
1451 }
1452
1453
1454 static DWORD
1455 IntGetConsoleTitle(LPVOID lpConsoleTitle, DWORD nSize, BOOL bUnicode)
1456 {
1457 CSR_API_MESSAGE Request;
1458 PCSR_CAPTURE_BUFFER CaptureBuffer;
1459 NTSTATUS Status;
1460
1461 if (nSize == 0)
1462 return 0;
1463
1464 Request.Data.GetTitleRequest.Length = nSize * (bUnicode ? 1 : sizeof(WCHAR));
1465 CaptureBuffer = CsrAllocateCaptureBuffer(1, Request.Data.GetTitleRequest.Length);
1466 if (CaptureBuffer == NULL)
1467 {
1468 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
1469 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
1470 return 0;
1471 }
1472
1473 CsrAllocateMessagePointer(CaptureBuffer,
1474 Request.Data.GetTitleRequest.Length,
1475 (PVOID*)&Request.Data.GetTitleRequest.Title);
1476
1477 Status = CsrClientCallServer(&Request,
1478 CaptureBuffer,
1479 CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_TITLE),
1480 sizeof(CSR_API_MESSAGE));
1481 if (!NT_SUCCESS(Status) || !(NT_SUCCESS(Status = Request.Status)))
1482 {
1483 CsrFreeCaptureBuffer(CaptureBuffer);
1484 BaseSetLastNTError(Status);
1485 return 0;
1486 }
1487
1488 if (bUnicode)
1489 {
1490 if (nSize >= sizeof(WCHAR))
1491 wcscpy((LPWSTR)lpConsoleTitle, Request.Data.GetTitleRequest.Title);
1492 }
1493 else
1494 {
1495 if (nSize < Request.Data.GetTitleRequest.Length / sizeof(WCHAR) ||
1496 !WideCharToMultiByte(CP_ACP, // ANSI code page
1497 0, // performance and mapping flags
1498 Request.Data.GetTitleRequest.Title, // address of wide-character string
1499 -1, // number of characters in string
1500 (LPSTR)lpConsoleTitle, // address of buffer for new string
1501 nSize, // size of buffer
1502 NULL, // FAST
1503 NULL))
1504 {
1505 /* Yes, if the buffer isn't big enough, it returns 0... Bad API */
1506 *(LPSTR)lpConsoleTitle = '\0';
1507 Request.Data.GetTitleRequest.Length = 0;
1508 }
1509 }
1510 CsrFreeCaptureBuffer(CaptureBuffer);
1511
1512 return Request.Data.GetTitleRequest.Length / sizeof(WCHAR);
1513 }
1514
1515 /*--------------------------------------------------------------
1516 * GetConsoleTitleW
1517 *
1518 * @implemented
1519 */
1520 DWORD
1521 WINAPI
1522 GetConsoleTitleW(LPWSTR lpConsoleTitle,
1523 DWORD nSize)
1524 {
1525 return IntGetConsoleTitle(lpConsoleTitle, nSize, TRUE);
1526 }
1527
1528 /*--------------------------------------------------------------
1529 * GetConsoleTitleA
1530 *
1531 * 19990306 EA
1532 *
1533 * @implemented
1534 */
1535 DWORD
1536 WINAPI
1537 GetConsoleTitleA(LPSTR lpConsoleTitle,
1538 DWORD nSize)
1539 {
1540 return IntGetConsoleTitle(lpConsoleTitle, nSize, FALSE);
1541 }
1542
1543
1544 /*--------------------------------------------------------------
1545 * SetConsoleTitleW
1546 *
1547 * @implemented
1548 */
1549 BOOL
1550 WINAPI
1551 SetConsoleTitleW(LPCWSTR lpConsoleTitle)
1552 {
1553 CSR_API_MESSAGE Request;
1554 PCSR_CAPTURE_BUFFER CaptureBuffer;
1555 NTSTATUS Status;
1556
1557 Request.Data.SetTitleRequest.Length = wcslen(lpConsoleTitle) * sizeof(WCHAR);
1558
1559 CaptureBuffer = CsrAllocateCaptureBuffer(1, Request.Data.SetTitleRequest.Length);
1560 if (CaptureBuffer == NULL)
1561 {
1562 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
1563 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
1564 return FALSE;
1565 }
1566
1567 CsrCaptureMessageBuffer(CaptureBuffer,
1568 (PVOID)lpConsoleTitle,
1569 Request.Data.SetTitleRequest.Length,
1570 (PVOID*)&Request.Data.SetTitleRequest.Title);
1571
1572 Status = CsrClientCallServer(&Request,
1573 CaptureBuffer,
1574 CSR_CREATE_API_NUMBER(CSR_CONSOLE, SET_TITLE),
1575 sizeof(CSR_API_MESSAGE));
1576
1577 CsrFreeCaptureBuffer(CaptureBuffer);
1578
1579 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
1580 {
1581 BaseSetLastNTError(Status);
1582 return FALSE;
1583 }
1584
1585 return TRUE;
1586 }
1587
1588
1589 /*--------------------------------------------------------------
1590 * SetConsoleTitleA
1591 *
1592 * 19990204 EA Added
1593 *
1594 * @implemented
1595 */
1596 BOOL
1597 WINAPI
1598 SetConsoleTitleA(LPCSTR lpConsoleTitle)
1599 {
1600 ULONG Length = strlen(lpConsoleTitle) + 1;
1601 LPWSTR WideTitle = HeapAlloc(GetProcessHeap(), 0, Length * sizeof(WCHAR));
1602 BOOL Ret;
1603 if (!WideTitle)
1604 {
1605 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
1606 return FALSE;
1607 }
1608 MultiByteToWideChar(CP_ACP, 0, lpConsoleTitle, -1, WideTitle, Length);
1609 Ret = SetConsoleTitleW(WideTitle);
1610 HeapFree(GetProcessHeap(), 0, WideTitle);
1611 return Ret;
1612 }
1613
1614
1615 /*--------------------------------------------------------------
1616 * CreateConsoleScreenBuffer
1617 *
1618 * @implemented
1619 */
1620 HANDLE
1621 WINAPI
1622 CreateConsoleScreenBuffer(DWORD dwDesiredAccess,
1623 DWORD dwShareMode,
1624 CONST SECURITY_ATTRIBUTES *lpSecurityAttributes,
1625 DWORD dwFlags,
1626 LPVOID lpScreenBufferData)
1627 {
1628 CSR_API_MESSAGE Request;
1629 NTSTATUS Status;
1630
1631 if (dwDesiredAccess & ~(GENERIC_READ | GENERIC_WRITE)
1632 || dwShareMode & ~(FILE_SHARE_READ | FILE_SHARE_WRITE)
1633 || dwFlags != CONSOLE_TEXTMODE_BUFFER)
1634 {
1635 SetLastError(ERROR_INVALID_PARAMETER);
1636 return INVALID_HANDLE_VALUE;
1637 }
1638
1639 Request.Data.CreateScreenBufferRequest.Access = dwDesiredAccess;
1640 Request.Data.CreateScreenBufferRequest.ShareMode = dwShareMode;
1641 Request.Data.CreateScreenBufferRequest.Inheritable =
1642 lpSecurityAttributes ? lpSecurityAttributes->bInheritHandle : FALSE;
1643
1644 Status = CsrClientCallServer(&Request,
1645 NULL,
1646 CSR_CREATE_API_NUMBER(CSR_CONSOLE, CREATE_SCREEN_BUFFER),
1647 sizeof(CSR_API_MESSAGE));
1648 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
1649 {
1650 BaseSetLastNTError(Status);
1651 return INVALID_HANDLE_VALUE;
1652 }
1653 return Request.Data.CreateScreenBufferRequest.OutputHandle;
1654 }
1655
1656
1657 /*--------------------------------------------------------------
1658 * GetConsoleCP
1659 *
1660 * @implemented
1661 */
1662 UINT
1663 WINAPI
1664 GetConsoleCP(VOID)
1665 {
1666 CSR_API_MESSAGE Request;
1667 NTSTATUS Status;
1668
1669 Status = CsrClientCallServer(&Request,
1670 NULL,
1671 CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_CONSOLE_CP),
1672 sizeof(CSR_API_MESSAGE));
1673 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
1674 {
1675 BaseSetLastNTError (Status);
1676 return 0;
1677 }
1678
1679 return Request.Data.GetConsoleCodePage.CodePage;
1680 }
1681
1682
1683 /*--------------------------------------------------------------
1684 * SetConsoleCP
1685 *
1686 * @implemented
1687 */
1688 BOOL
1689 WINAPI
1690 SetConsoleCP(UINT wCodePageID)
1691 {
1692 CSR_API_MESSAGE Request;
1693 NTSTATUS Status;
1694
1695 Request.Data.SetConsoleCodePage.CodePage = wCodePageID;
1696
1697 Status = CsrClientCallServer(&Request,
1698 NULL,
1699 CSR_CREATE_API_NUMBER(CSR_CONSOLE, SET_CONSOLE_CP),
1700 sizeof(CSR_API_MESSAGE));
1701 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
1702 {
1703 BaseSetLastNTError(Status);
1704 }
1705
1706 return NT_SUCCESS(Status);
1707 }
1708
1709
1710 /*--------------------------------------------------------------
1711 * GetConsoleOutputCP
1712 *
1713 * @implemented
1714 */
1715 UINT
1716 WINAPI
1717 GetConsoleOutputCP(VOID)
1718 {
1719 CSR_API_MESSAGE Request;
1720 NTSTATUS Status;
1721
1722 Status = CsrClientCallServer(&Request,
1723 NULL,
1724 CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_CONSOLE_OUTPUT_CP),
1725 sizeof(CSR_API_MESSAGE));
1726 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
1727 {
1728 BaseSetLastNTError (Status);
1729 return 0;
1730 }
1731
1732 return Request.Data.GetConsoleOutputCodePage.CodePage;
1733 }
1734
1735
1736 /*--------------------------------------------------------------
1737 * SetConsoleOutputCP
1738 *
1739 * @implemented
1740 */
1741 BOOL
1742 WINAPI
1743 SetConsoleOutputCP(UINT wCodePageID)
1744 {
1745 CSR_API_MESSAGE Request;
1746 NTSTATUS Status;
1747
1748 Request.Data.SetConsoleOutputCodePage.CodePage = wCodePageID;
1749
1750 Status = CsrClientCallServer(&Request,
1751 NULL,
1752 CSR_CREATE_API_NUMBER(CSR_CONSOLE, SET_CONSOLE_OUTPUT_CP),
1753 sizeof(CSR_API_MESSAGE));
1754 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
1755 {
1756 BaseSetLastNTError(Status);
1757 }
1758
1759 return NT_SUCCESS(Status);
1760 }
1761
1762
1763 /*--------------------------------------------------------------
1764 * GetConsoleProcessList
1765 *
1766 * @implemented
1767 */
1768 DWORD
1769 WINAPI
1770 GetConsoleProcessList(LPDWORD lpdwProcessList,
1771 DWORD dwProcessCount)
1772 {
1773 PCSR_CAPTURE_BUFFER CaptureBuffer;
1774 CSR_API_MESSAGE Request;
1775 ULONG nProcesses;
1776 NTSTATUS Status;
1777
1778 if (lpdwProcessList == NULL || dwProcessCount == 0)
1779 {
1780 SetLastError(ERROR_INVALID_PARAMETER);
1781 return 0;
1782 }
1783
1784 CaptureBuffer = CsrAllocateCaptureBuffer(1, dwProcessCount * sizeof(DWORD));
1785 if (CaptureBuffer == NULL)
1786 {
1787 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
1788 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
1789 return FALSE;
1790 }
1791
1792 Request.Data.GetProcessListRequest.nMaxIds = dwProcessCount;
1793 CsrAllocateMessagePointer(CaptureBuffer,
1794 dwProcessCount * sizeof(DWORD),
1795 (PVOID*)&Request.Data.GetProcessListRequest.ProcessId);
1796
1797 Status = CsrClientCallServer(&Request,
1798 CaptureBuffer,
1799 CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_PROCESS_LIST),
1800 sizeof(CSR_API_MESSAGE));
1801 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
1802 {
1803 BaseSetLastNTError (Status);
1804 nProcesses = 0;
1805 }
1806 else
1807 {
1808 nProcesses = Request.Data.GetProcessListRequest.nProcessIdsTotal;
1809 if (dwProcessCount >= nProcesses)
1810 {
1811 memcpy(lpdwProcessList, Request.Data.GetProcessListRequest.ProcessId, nProcesses * sizeof(DWORD));
1812 }
1813 }
1814
1815 CsrFreeCaptureBuffer(CaptureBuffer);
1816 return nProcesses;
1817 }
1818
1819
1820 /*--------------------------------------------------------------
1821 * GetConsoleSelectionInfo
1822 *
1823 * @implemented
1824 */
1825 BOOL
1826 WINAPI
1827 GetConsoleSelectionInfo(PCONSOLE_SELECTION_INFO lpConsoleSelectionInfo)
1828 {
1829 CSR_API_MESSAGE Request;
1830 NTSTATUS Status = CsrClientCallServer(&Request,
1831 NULL,
1832 CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_CONSOLE_SELECTION_INFO),
1833 sizeof(CSR_API_MESSAGE));
1834 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
1835 {
1836 BaseSetLastNTError(Status);
1837 return FALSE;
1838 }
1839
1840 *lpConsoleSelectionInfo = Request.Data.GetConsoleSelectionInfo.Info;
1841 return TRUE;
1842 }
1843
1844
1845 /*--------------------------------------------------------------
1846 * AttachConsole
1847 *
1848 * @unimplemented
1849 */
1850 BOOL
1851 WINAPI
1852 AttachConsole(DWORD dwProcessId)
1853 {
1854 DPRINT1("AttachConsole(0x%x) UNIMPLEMENTED!\n", dwProcessId);
1855 return TRUE;
1856 }
1857
1858 /*--------------------------------------------------------------
1859 * GetConsoleWindow
1860 *
1861 * @implemented
1862 */
1863 HWND
1864 WINAPI
1865 GetConsoleWindow(VOID)
1866 {
1867 CSR_API_MESSAGE Request;
1868 NTSTATUS Status;
1869
1870 Status = CsrClientCallServer(&Request,
1871 NULL,
1872 CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_CONSOLE_WINDOW),
1873 sizeof(CSR_API_MESSAGE));
1874 if (!NT_SUCCESS(Status ) || !NT_SUCCESS(Status = Request.Status))
1875 {
1876 BaseSetLastNTError(Status);
1877 return (HWND) NULL;
1878 }
1879
1880 return Request.Data.GetConsoleWindowRequest.WindowHandle;
1881 }
1882
1883
1884 /*--------------------------------------------------------------
1885 * SetConsoleIcon
1886 *
1887 * @implemented
1888 */
1889 BOOL
1890 WINAPI
1891 SetConsoleIcon(HICON hicon)
1892 {
1893 CSR_API_MESSAGE Request;
1894 NTSTATUS Status;
1895
1896 Request.Data.SetConsoleIconRequest.WindowIcon = hicon;
1897
1898 Status = CsrClientCallServer(&Request,
1899 NULL,
1900 CSR_CREATE_API_NUMBER(CSR_CONSOLE, SET_CONSOLE_ICON),
1901 sizeof(CSR_API_MESSAGE));
1902 if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
1903 {
1904 BaseSetLastNTError(Status);
1905 return FALSE;
1906 }
1907
1908 return NT_SUCCESS(Status);
1909 }
1910
1911
1912 /******************************************************************************
1913 * \name SetConsoleInputExeNameW
1914 * \brief Sets the console input file name from a unicode string.
1915 * \param lpInputExeName Pointer to a unicode string with the name.
1916 * \return TRUE if successful, FALSE if unsuccsedful.
1917 * \remarks If lpInputExeName is 0 or the string length is 0 or greater than 255,
1918 * the function fails and sets last error to ERROR_INVALID_PARAMETER.
1919 */
1920 BOOL
1921 WINAPI
1922 SetConsoleInputExeNameW(LPCWSTR lpInputExeName)
1923 {
1924 int lenName;
1925
1926 if (!lpInputExeName
1927 || (lenName = lstrlenW(lpInputExeName)) == 0
1928 || lenName > INPUTEXENAME_BUFLEN - 1)
1929 {
1930 /* Fail if string is empty or too long */
1931 SetLastError(ERROR_INVALID_PARAMETER);
1932 return FALSE;
1933 }
1934
1935 RtlEnterCriticalSection(&ConsoleLock);
1936 _SEH2_TRY
1937 {
1938 RtlCopyMemory(InputExeName, lpInputExeName, lenName * sizeof(WCHAR));
1939 InputExeName[lenName] = L'\0';
1940 }
1941 _SEH2_FINALLY
1942 {
1943 RtlLeaveCriticalSection(&ConsoleLock);
1944 }
1945 _SEH2_END;
1946
1947 return TRUE;
1948 }
1949
1950
1951 /******************************************************************************
1952 * \name SetConsoleInputExeNameA
1953 * \brief Sets the console input file name from an ansi string.
1954 * \param lpInputExeName Pointer to an ansi string with the name.
1955 * \return TRUE if successful, FALSE if unsuccsedful.
1956 * \remarks If lpInputExeName is 0 or the string length is 0 or greater than 255,
1957 * the function fails and sets last error to ERROR_INVALID_PARAMETER.
1958 */
1959 BOOL
1960 WINAPI
1961 SetConsoleInputExeNameA(LPCSTR lpInputExeName)
1962 {
1963 WCHAR Buffer[INPUTEXENAME_BUFLEN];
1964 ANSI_STRING InputExeNameA;
1965 UNICODE_STRING InputExeNameU;
1966 NTSTATUS Status;
1967 BOOL Ret;
1968
1969 RtlInitAnsiString(&InputExeNameA, lpInputExeName);
1970
1971 if(InputExeNameA.Length == 0 ||
1972 InputExeNameA.Length > INPUTEXENAME_BUFLEN - 1)
1973 {
1974 /* Fail if string is empty or too long */
1975 SetLastError(ERROR_INVALID_PARAMETER);
1976 return FALSE;
1977 }
1978
1979 InputExeNameU.Buffer = Buffer;
1980 InputExeNameU.MaximumLength = sizeof(Buffer);
1981 InputExeNameU.Length = 0;
1982 Status = RtlAnsiStringToUnicodeString(&InputExeNameU, &InputExeNameA, FALSE);
1983 if(NT_SUCCESS(Status))
1984 {
1985 Ret = SetConsoleInputExeNameW(InputExeNameU.Buffer);
1986 }
1987 else
1988 {
1989 BaseSetLastNTError(Status);
1990 Ret = FALSE;
1991 }
1992
1993 return Ret;
1994 }
1995
1996
1997 /******************************************************************************
1998 * \name GetConsoleInputExeNameW
1999 * \brief Retrieves the console input file name as unicode string.
2000 * \param nBufferLength Length of the buffer in WCHARs.
2001 * Specify 0 to recieve the needed buffer length.
2002 * \param lpBuffer Pointer to a buffer that recieves the string.
2003 * \return Needed buffer size if \p nBufferLength is 0.
2004 * Otherwise 1 if successful, 2 if buffer is too small.
2005 * \remarks Sets last error value to ERROR_BUFFER_OVERFLOW if the buffer
2006 * is not big enough.
2007 */
2008 DWORD
2009 WINAPI
2010 GetConsoleInputExeNameW(DWORD nBufferLength, LPWSTR lpBuffer)
2011 {
2012 int lenName = lstrlenW(InputExeName);
2013
2014 if (nBufferLength == 0)
2015 {
2016 /* Buffer size is requested, return it */
2017 return lenName + 1;
2018 }
2019
2020 if(lenName + 1 > nBufferLength)
2021 {
2022 /* Buffer is not large enough! */
2023 SetLastError(ERROR_BUFFER_OVERFLOW);
2024 return 2;
2025 }
2026
2027 RtlEnterCriticalSection(&ConsoleLock);
2028 _SEH2_TRY
2029 {
2030 RtlCopyMemory(lpBuffer, InputExeName, lenName * sizeof(WCHAR));
2031 lpBuffer[lenName] = '\0';
2032 }
2033 _SEH2_FINALLY
2034 {
2035 RtlLeaveCriticalSection(&ConsoleLock);
2036 }
2037 _SEH2_END;
2038
2039 /* Success, return 1 */
2040 return 1;
2041 }
2042
2043
2044 /******************************************************************************
2045 * \name GetConsoleInputExeNameA
2046 * \brief Retrieves the console input file name as ansi string.
2047 * \param nBufferLength Length of the buffer in CHARs.
2048 * \param lpBuffer Pointer to a buffer that recieves the string.
2049 * \return 1 if successful, 2 if buffer is too small.
2050 * \remarks Sets last error value to ERROR_BUFFER_OVERFLOW if the buffer
2051 * is not big enough. The buffer recieves as much characters as fit.
2052 */
2053 DWORD
2054 WINAPI
2055 GetConsoleInputExeNameA(DWORD nBufferLength, LPSTR lpBuffer)
2056 {
2057 WCHAR Buffer[INPUTEXENAME_BUFLEN];
2058 DWORD Ret;
2059 UNICODE_STRING BufferU;
2060 ANSI_STRING BufferA;
2061
2062 /* Get the unicode name */
2063 Ret = GetConsoleInputExeNameW(sizeof(Buffer) / sizeof(Buffer[0]), Buffer);
2064
2065 /* Initialize strings for conversion */
2066 RtlInitUnicodeString(&BufferU, Buffer);
2067 BufferA.Length = 0;
2068 BufferA.MaximumLength = nBufferLength;
2069 BufferA.Buffer = lpBuffer;
2070
2071 /* Convert unicode name to ansi, copying as much chars as fit */
2072 RtlUnicodeStringToAnsiString(&BufferA, &BufferU, FALSE);
2073
2074 /* Error handling */
2075 if(nBufferLength <= BufferU.Length / sizeof(WCHAR))
2076 {
2077 SetLastError(ERROR_BUFFER_OVERFLOW);
2078 return 2;
2079 }
2080
2081 return Ret;
2082 }
2083
2084 BOOL
2085 WINAPI
2086 GetConsoleCharType(HANDLE hConsole, COORD Coord, PDWORD Type)
2087 {
2088 STUB;
2089 return FALSE;
2090 }
2091
2092 BOOL
2093 WINAPI
2094 GetConsoleCursorMode(HANDLE hConsole, PBOOL pUnknown1, PBOOL pUnknown2)
2095 {
2096 STUB;
2097 return FALSE;
2098 }
2099
2100 BOOL
2101 WINAPI
2102 GetConsoleNlsMode(HANDLE hConsole, LPDWORD lpMode)
2103 {
2104 STUB;
2105 return FALSE;
2106 }
2107
2108 BOOL
2109 WINAPI
2110 RegisterConsoleIME(HWND hWnd, LPDWORD ThreadId)
2111 {
2112 STUB;
2113 return FALSE;
2114 }
2115
2116 BOOL
2117 WINAPI
2118 RegisterConsoleOS2(BOOL bUnknown)
2119 {
2120 STUB;
2121 return FALSE;
2122 }
2123
2124 BOOL
2125 WINAPI
2126 SetConsoleCursorMode(HANDLE hConsole, BOOL Unknown1, BOOL Unknown2)
2127 {
2128 STUB;
2129 return FALSE;
2130 }
2131
2132 BOOL
2133 WINAPI
2134 SetConsoleLocalEUDC(DWORD Unknown1, DWORD Unknown2, DWORD Unknown3, DWORD Unknown4)
2135 {
2136 STUB;
2137 return FALSE;
2138 }
2139
2140 BOOL
2141 WINAPI
2142 SetConsoleNlsMode(HANDLE hConsole, DWORD dwMode)
2143 {
2144 STUB;
2145 return FALSE;
2146 }
2147
2148 BOOL
2149 WINAPI
2150 SetConsoleOS2OemFormat(BOOL bUnknown)
2151 {
2152 STUB;
2153 return FALSE;
2154 }
2155
2156 BOOL
2157 WINAPI
2158 UnregisterConsoleIME(VOID)
2159 {
2160 STUB;
2161 return FALSE;
2162 }
2163
2164
2165 /*
2166 * @unimplemented
2167 */
2168 BOOL WINAPI GetConsoleKeyboardLayoutNameA(LPSTR name)
2169 {
2170 STUB;
2171 return 0;
2172 }
2173
2174 /*
2175 * @unimplemented
2176 */
2177 BOOL WINAPI GetConsoleKeyboardLayoutNameW(LPWSTR name)
2178 {
2179 STUB;
2180 return 0;
2181 }
2182
2183 /*
2184 * @unimplemented
2185 */
2186 BOOL
2187 WINAPI
2188 SetLastConsoleEventActive(VOID)
2189 {
2190 STUB;
2191 return FALSE;
2192 }
2193
2194 /* EOF */