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