ReactOS 0.4.15-dev-7958-gcd0bb1a
console.c
Go to the documentation of this file.
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 * PROGRAMMERS: James Tabor <jimtabor@adsl-64-217-116-74.dsl.hstntx.swbell.net>
7 * Hermes Belusca-Maito (hermes.belusca@sfr.fr)
8 */
9
10/* INCLUDES *******************************************************************/
11
12#include <k32.h>
13
14#define NDEBUG
15#include <debug.h>
16
17
18/* GLOBALS ********************************************************************/
19
22
23/* Console reserved "file" names */
27
28/* Console Control handling */
34
36
37/* Console Input facilities */
39
40#define EXENAME_LENGTH (255 + 1)
43static WCHAR ExeNameBuffer[EXENAME_LENGTH]; // NULL-terminated
44static USHORT ExeNameLength; // Count in number of characters without NULL
45static WCHAR StartDirBuffer[MAX_PATH + 1]; // NULL-terminated
46static USHORT StartDirLength; // Count in number of characters without NULL
47
48
49/* Default Console Control Handler ********************************************/
50
51static BOOL
54{
55 DPRINT("Default handler called: %lx\n", Event);
56 switch(Event)
57 {
58 case CTRL_C_EVENT:
59 DPRINT("Ctrl-C Event\n");
60 break;
61
63 DPRINT("Ctrl-Break Event\n");
64 break;
65
67 DPRINT("Ctrl Close Event\n");
68 break;
69
71 DPRINT("Ctrl Last Close Event\n");
72 break;
73
75 DPRINT("Ctrl Logoff Event\n");
76 break;
77
79 DPRINT("Ctrl Shutdown Event\n");
80 break;
81 }
82
84 return TRUE;
85}
86
90{
91 DWORD nExitCode = 0;
92 DWORD CodeAndFlag = PtrToUlong(lpThreadParameter);
93 DWORD nCode = CodeAndFlag & MAXLONG;
94 UINT i;
95 EXCEPTION_RECORD erException;
96
97 DPRINT1("Console Dispatcher Active: %lx %lx\n", CodeAndFlag, nCode);
99
100 switch(nCode)
101 {
102 case CTRL_C_EVENT:
103 case CTRL_BREAK_EVENT:
104 {
105 if (IsDebuggerPresent())
106 {
107 erException.ExceptionCode = (nCode == CTRL_C_EVENT ?
109 erException.ExceptionFlags = 0;
110 erException.ExceptionRecord = NULL;
112 erException.NumberParameters = 0;
113
115 {
116 RtlRaiseException(&erException);
117 }
119 {
121
122 if ((nCode != CTRL_C_EVENT) ||
123 (NtCurrentPeb()->ProcessParameters->ConsoleFlags != 1))
124 {
125 for (i = NrCtrlHandlers; i > 0; i--)
126 {
127 if (CtrlHandlers[i - 1](nCode)) break;
128 }
129 }
130
132 }
133 _SEH2_END;
134
135 ExitThread(0);
136 }
137 break;
138 }
139
140 case CTRL_CLOSE_EVENT:
143 break;
144
146 /*
147 * In case the console app hasn't register for last close notification,
148 * just kill this console handler thread. We don't want that such apps
149 * get killed for unexpected reasons. On the contrary apps that registered
150 * can be killed because they expect to be.
151 */
153 break;
154
155 case 4:
157 break;
158
159 default:
160 ASSERT(FALSE);
161 break;
162 }
163
165
167
168 nExitCode = 0;
169 if ((nCode != CTRL_C_EVENT) || (NtCurrentPeb()->ProcessParameters->ConsoleFlags != 1))
170 {
171 for (i = NrCtrlHandlers; i > 0; i--)
172 {
173 if ((i == 1) &&
174 (CodeAndFlag & MINLONG) &&
175 ((nCode == CTRL_LOGOFF_EVENT) || (nCode == CTRL_SHUTDOWN_EVENT)))
176 {
177 DPRINT("Skipping system/service apps\n");
178 break;
179 }
180
181 if (CtrlHandlers[i - 1](nCode))
182 {
183 switch(nCode)
184 {
185 case CTRL_CLOSE_EVENT:
189 nExitCode = CodeAndFlag;
190 break;
191 }
192 break;
193 }
194 }
195 }
196
198
199 ExitThread(nExitCode);
200 return STATUS_SUCCESS;
201}
202
203VOID
205{
206 /* Initialize Console Ctrl Handler */
210}
211
212
213/* Input EXE Name Support *****************************************************/
214
215VOID
217{
221 PLDR_DATA_TABLE_ENTRY ImageEntry;
222
223 if (ExeNameInitialized) return;
224
225 /* Initialize the EXE name lock */
227 if (!NT_SUCCESS(Status)) return;
229
232 InLoadOrderLinks);
233
234 /* Retrieve the EXE name, NULL-terminate it... */
235 ExeNameLength = min(sizeof(ExeNameBuffer)/sizeof(ExeNameBuffer[0]),
236 ImageEntry->BaseDllName.Length / sizeof(WCHAR));
238 ImageEntry->BaseDllName.Buffer,
239 ImageEntry->BaseDllName.Length);
241
242 /* ... and retrieve the current directory path and NULL-terminate it. */
243 StartDirLength = min(sizeof(StartDirBuffer)/sizeof(StartDirBuffer[0]),
244 CurrentDirectory->DosPath.Length / sizeof(WCHAR));
246 CurrentDirectory->DosPath.Buffer,
247 CurrentDirectory->DosPath.Length);
249}
250
251/*
252 * NOTE:
253 * The "LPDWORD Length" parameters point on input to the maximum size of
254 * the buffers that can hold data (if != 0), and on output they hold the
255 * real size of the data. If "Length" are == 0 on input, then on output
256 * they receive the full size of the data.
257 * The "LPWSTR* String" parameters have a double meaning:
258 * - when "CaptureStrings" is TRUE, data is copied to the buffers pointed
259 * by the pointers (*String).
260 * - when "CaptureStrings" is FALSE, "*String" are set to the addresses of
261 * the source data.
262 */
263VOID
264SetUpAppName(IN BOOLEAN CaptureStrings,
265 IN OUT LPDWORD CurDirLength,
266 IN OUT LPWSTR* CurDir,
267 IN OUT LPDWORD AppNameLength,
269{
271
272 /* Retrieve the needed buffer size */
273 Length = (StartDirLength + 1) * sizeof(WCHAR);
274 if (*CurDirLength > 0) Length = min(Length, *CurDirLength);
275 *CurDirLength = Length;
276
277 /* Capture the data if needed, or, return a pointer to it */
278 if (CaptureStrings)
279 {
280 /*
281 * Length is always >= sizeof(WCHAR). Copy everything but the
282 * possible trailing NULL character, and then NULL-terminate.
283 */
284 Length -= sizeof(WCHAR);
286 (*CurDir)[Length / sizeof(WCHAR)] = UNICODE_NULL;
287 }
288 else
289 {
290 *CurDir = StartDirBuffer;
291 }
292
293 /* Retrieve the needed buffer size */
294 Length = (ExeNameLength + 1) * sizeof(WCHAR);
295 if (*AppNameLength > 0) Length = min(Length, *AppNameLength);
296 *AppNameLength = Length;
297
298 /* Capture the data if needed, or, return a pointer to it */
299 if (CaptureStrings)
300 {
301 /*
302 * Length is always >= sizeof(WCHAR). Copy everything but the
303 * possible trailing NULL character, and then NULL-terminate.
304 */
305 Length -= sizeof(WCHAR);
307 (*AppName)[Length / sizeof(WCHAR)] = UNICODE_NULL;
308 }
309 else
310 {
312 }
313}
314
315USHORT
318{
319 USHORT ExeLength;
320
322 {
324
325 if (BufferSize > ExeNameLength * sizeof(WCHAR))
326 BufferSize = ExeNameLength * sizeof(WCHAR);
327
329
331 ExeLength = BufferSize;
332 }
333 else
334 {
335 *ExeName = UNICODE_NULL;
336 ExeLength = 0;
337 }
338
339 return ExeLength;
340}
341
342/* FUNCTIONS ******************************************************************/
343
346 IN DWORD dwDesiredAccess)
347{
348 LPCWSTR ConsoleName = pszName;
349 ULONG DeviceNameInfo;
350
351 /*
352 * Check whether we deal with a DOS device, and if so,
353 * strip the path till the file name.
354 * Therefore, things like \\.\CON or C:\some_path\CONIN$
355 * are transformed into CON or CONIN$, for example.
356 */
357 DeviceNameInfo = RtlIsDosDeviceName_U(pszName);
358 if (DeviceNameInfo != 0)
359 {
360 ConsoleName = (LPCWSTR)((ULONG_PTR)ConsoleName + ((DeviceNameInfo >> 16) & 0xFFFF));
361 }
362
363 /* Return a standard console "file" name according to what we passed in parameters */
364 if (_wcsicmp(ConsoleName, BaseConInputFileName) == 0)
365 {
367 }
368 else if (_wcsicmp(ConsoleName, BaseConOutputFileName) == 0)
369 {
371 }
372 else if (_wcsicmp(ConsoleName, BaseConFileName) == 0)
373 {
374 if ((dwDesiredAccess & (GENERIC_READ | GENERIC_WRITE)) == GENERIC_READ)
375 {
377 }
378 else if ((dwDesiredAccess & (GENERIC_READ | GENERIC_WRITE)) == GENERIC_WRITE)
379 {
381 }
382 }
383
384 /* If we are there, that means that either the file name or the desired access are wrong */
385 return NULL;
386}
387
388
389/*
390 * @implemented (Undocumented)
391 * @note See http://undoc.airesoft.co.uk/kernel32.dll/ConsoleMenuControl.php
392 */
393HMENU
394WINAPI
397 DWORD dwCmdIdLow,
398 DWORD dwCmdIdHigh)
399{
400 CONSOLE_API_MESSAGE ApiMessage;
401 PCONSOLE_MENUCONTROL MenuControlRequest = &ApiMessage.Data.MenuControlRequest;
402
403 MenuControlRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
404 MenuControlRequest->OutputHandle = hConsoleOutput;
405 MenuControlRequest->CmdIdLow = dwCmdIdLow;
406 MenuControlRequest->CmdIdHigh = dwCmdIdHigh;
407 MenuControlRequest->MenuHandle = NULL;
408
410 NULL,
412 sizeof(*MenuControlRequest));
413
414 return MenuControlRequest->MenuHandle;
415}
416
417
418/*
419 * @implemented
420 */
421HANDLE
422WINAPI
425 DWORD dwDesiredAccess,
428{
429 CONSOLE_API_MESSAGE ApiMessage;
430 PCONSOLE_DUPLICATEHANDLE DuplicateHandleRequest = &ApiMessage.Data.DuplicateHandleRequest;
431
434 (dwDesiredAccess & ~(GENERIC_READ | GENERIC_WRITE))) )
435 {
438 }
439
440 DuplicateHandleRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
441 DuplicateHandleRequest->SourceHandle = hConsole;
442 DuplicateHandleRequest->DesiredAccess = dwDesiredAccess;
443 DuplicateHandleRequest->InheritHandle = bInheritHandle;
444 DuplicateHandleRequest->Options = dwOptions;
445
447 NULL,
449 sizeof(*DuplicateHandleRequest));
450 if (!NT_SUCCESS(ApiMessage.Status))
451 {
452 BaseSetLastNTError(ApiMessage.Status);
454 }
455
456 return DuplicateHandleRequest->TargetHandle;
457}
458
459
460/*
461 * @implemented
462 */
463BOOL
464WINAPI
466 OUT LPDWORD lpdwFlags)
467{
468 CONSOLE_API_MESSAGE ApiMessage;
469 PCONSOLE_GETHANDLEINFO GetHandleInfoRequest = &ApiMessage.Data.GetHandleInfoRequest;
470
471 GetHandleInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
472 GetHandleInfoRequest->Handle = hHandle;
473
475 NULL,
477 sizeof(*GetHandleInfoRequest));
478 if (!NT_SUCCESS(ApiMessage.Status))
479 {
480 BaseSetLastNTError(ApiMessage.Status);
481 return FALSE;
482 }
483
484 *lpdwFlags = GetHandleInfoRequest->Flags;
485
486 return TRUE;
487}
488
489
490/*
491 * @implemented
492 */
493BOOL
494WINAPI
496 IN DWORD dwMask,
498{
499 CONSOLE_API_MESSAGE ApiMessage;
500 PCONSOLE_SETHANDLEINFO SetHandleInfoRequest = &ApiMessage.Data.SetHandleInfoRequest;
501
502 SetHandleInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
503 SetHandleInfoRequest->Handle = hHandle;
504 SetHandleInfoRequest->Mask = dwMask;
505 SetHandleInfoRequest->Flags = dwFlags;
506
508 NULL,
510 sizeof(*SetHandleInfoRequest));
511 if (!NT_SUCCESS(ApiMessage.Status))
512 {
513 BaseSetLastNTError(ApiMessage.Status);
514 return FALSE;
515 }
516
517 return TRUE;
518}
519
520
521/*
522 * @implemented
523 */
524BOOL
525WINAPI
527{
528 CONSOLE_API_MESSAGE ApiMessage;
529 PCONSOLE_GETDISPLAYMODE GetDisplayModeRequest = &ApiMessage.Data.GetDisplayModeRequest;
530
531 if (lpModeFlags == NULL)
532 {
534 return FALSE;
535 }
536
537 GetDisplayModeRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
538
540 NULL,
542 sizeof(*GetDisplayModeRequest));
543 if (!NT_SUCCESS(ApiMessage.Status))
544 {
545 BaseSetLastNTError(ApiMessage.Status);
546 return FALSE;
547 }
548
549 *lpModeFlags = GetDisplayModeRequest->DisplayMode; // ModeFlags
550
551 return TRUE;
552}
553
554
555/*
556 * @implemented (Undocumented)
557 * @note See http://cboard.cprogramming.com/windows-programming/102187-console-font-size.html
558 */
559DWORD
560WINAPI
562 IN BOOL bMaximumWindow,
563 IN DWORD nFontCount,
564 OUT PCONSOLE_FONT_INFO lpConsoleFontInfo)
565{
566 CONSOLE_API_MESSAGE ApiMessage;
567 PCONSOLE_GETFONTINFO GetFontInfoRequest = &ApiMessage.Data.GetFontInfoRequest;
568 PCSR_CAPTURE_BUFFER CaptureBuffer;
569
570 GetFontInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
571 GetFontInfoRequest->OutputHandle = hConsoleOutput;
572 GetFontInfoRequest->MaximumWindow = bMaximumWindow;
573 GetFontInfoRequest->NumFonts = nFontCount;
574
575 CaptureBuffer = CsrAllocateCaptureBuffer(1, nFontCount * sizeof(CONSOLE_FONT_INFO));
576 if (CaptureBuffer == NULL)
577 {
578 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
580 return 0;
581 }
582
583 CsrAllocateMessagePointer(CaptureBuffer,
584 nFontCount * sizeof(CONSOLE_FONT_INFO),
585 (PVOID*)&GetFontInfoRequest->FontInfo);
586
588 CaptureBuffer,
590 sizeof(*GetFontInfoRequest));
591 if (!NT_SUCCESS(ApiMessage.Status))
592 {
593 BaseSetLastNTError(ApiMessage.Status);
594 }
595 else
596 {
597 RtlCopyMemory(lpConsoleFontInfo,
598 GetFontInfoRequest->FontInfo,
599 GetFontInfoRequest->NumFonts * sizeof(CONSOLE_FONT_INFO));
600 }
601
602 CsrFreeCaptureBuffer(CaptureBuffer);
603 return GetFontInfoRequest->NumFonts;
604}
605
606
607/*
608 * @implemented
609 */
610COORD
611WINAPI
614 IN DWORD nFont)
615{
616 CONSOLE_API_MESSAGE ApiMessage;
617 PCONSOLE_GETFONTSIZE GetFontSizeRequest = &ApiMessage.Data.GetFontSizeRequest;
618 COORD Empty = {0, 0};
619
620 GetFontSizeRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
621 GetFontSizeRequest->OutputHandle = hConsoleOutput;
622 GetFontSizeRequest->FontIndex = nFont;
623
625 NULL,
627 sizeof(*GetFontSizeRequest));
628 if (!NT_SUCCESS(ApiMessage.Status))
629 {
630 BaseSetLastNTError(ApiMessage.Status);
631 return Empty;
632 }
633
634 return GetFontSizeRequest->FontSize;
635}
636
637
638/*
639 * @implemented (Undocumented)
640 */
641BOOL
642WINAPI
646{
647 CONSOLE_API_MESSAGE ApiMessage;
648 PCONSOLE_GETSETHWSTATE HardwareStateRequest = &ApiMessage.Data.HardwareStateRequest;
649
650 DPRINT1("GetConsoleHardwareState(%lu, 0x%p) UNIMPLEMENTED!\n", Flags, State);
651
652 if (Flags == NULL || State == NULL)
653 {
655 return FALSE;
656 }
657
658 HardwareStateRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
659 HardwareStateRequest->OutputHandle = hConsoleOutput;
660
662 NULL,
664 sizeof(*HardwareStateRequest));
665 if (!NT_SUCCESS(ApiMessage.Status))
666 {
667 BaseSetLastNTError(ApiMessage.Status);
668 return FALSE;
669 }
670
671 *Flags = HardwareStateRequest->Flags;
672 *State = HardwareStateRequest->State;
673
674 return TRUE;
675}
676
677
678/*
679 * @implemented (Undocumented)
680 */
681HANDLE
682WINAPI
684{
685 return InputWaitHandle;
686}
687
688
689/*
690 * @implemented
691 */
692BOOL
693WINAPI
695 IN BOOL bMaximumWindow,
696 OUT PCONSOLE_FONT_INFO lpConsoleCurrentFont)
697{
698 CONSOLE_API_MESSAGE ApiMessage;
699 PCONSOLE_GETCURRENTFONT GetCurrentFontRequest = &ApiMessage.Data.GetCurrentFontRequest;
700
701 GetCurrentFontRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
702 GetCurrentFontRequest->OutputHandle = hConsoleOutput;
703 GetCurrentFontRequest->MaximumWindow = bMaximumWindow;
704
706 NULL,
708 sizeof(*GetCurrentFontRequest));
709 if (!NT_SUCCESS(ApiMessage.Status))
710 {
711 BaseSetLastNTError(ApiMessage.Status);
712 return FALSE;
713 }
714
715 lpConsoleCurrentFont->dwFontSize = GetCurrentFontRequest->FontSize;
716 lpConsoleCurrentFont->nFont = GetCurrentFontRequest->FontIndex;
717
718 return TRUE;
719}
720
721
722/*
723 * @implemented (Undocumented)
724 * @note See http://cboard.cprogramming.com/windows-programming/102187-console-font-size.html
725 */
726DWORD
727WINAPI
730{
731 CONSOLE_API_MESSAGE ApiMessage;
732 PCONSOLE_GETNUMFONTS GetNumFontsRequest = &ApiMessage.Data.GetNumFontsRequest;
733
734 GetNumFontsRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
735
737 NULL,
739 sizeof(*GetNumFontsRequest));
740 if (!NT_SUCCESS(ApiMessage.Status))
741 {
742 BaseSetLastNTError(ApiMessage.Status);
743 return 0;
744 }
745
746 return GetNumFontsRequest->NumFonts;
747}
748
749
750/*
751 * @implemented (Undocumented)
752 * @note See http://blog.airesoft.co.uk/2012/10/things-ms-can-do-that-they-dont-tell-you-about-console-graphics/
753 */
754BOOL
755WINAPI
757 IN PSMALL_RECT lpRect)
758{
759 CONSOLE_API_MESSAGE ApiMessage;
760 PCONSOLE_INVALIDATEDIBITS InvalidateDIBitsRequest = &ApiMessage.Data.InvalidateDIBitsRequest;
761
762 if (lpRect == NULL)
763 {
765 return FALSE;
766 }
767
768 InvalidateDIBitsRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
769 InvalidateDIBitsRequest->OutputHandle = hConsoleOutput;
770 InvalidateDIBitsRequest->Region = *lpRect;
771
773 NULL,
775 sizeof(*InvalidateDIBitsRequest));
776 if (!NT_SUCCESS(ApiMessage.Status))
777 {
778 BaseSetLastNTError(ApiMessage.Status);
779 return FALSE;
780 }
781
782 return TRUE;
783}
784
785
786/*
787 * @implemented (Undocumented)
788 */
789HANDLE
790WINAPI
792 DWORD dwDesiredAccess,
794 DWORD dwShareMode)
795{
796 CONSOLE_API_MESSAGE ApiMessage;
797 PCONSOLE_OPENCONSOLE OpenConsoleRequest = &ApiMessage.Data.OpenConsoleRequest;
798 CONSOLE_HANDLE_TYPE HandleType;
799
800 if (wsName && (_wcsicmp(wsName, BaseConInputFileName) == 0))
801 {
802 HandleType = HANDLE_INPUT;
803 }
804 else if (wsName && (_wcsicmp(wsName, BaseConOutputFileName) == 0))
805 {
806 HandleType = HANDLE_OUTPUT;
807 }
808 else
809 {
812 }
813
814 if ( (dwDesiredAccess & ~(GENERIC_READ | GENERIC_WRITE)) ||
815 (dwShareMode & ~(FILE_SHARE_READ | FILE_SHARE_WRITE)) )
816 {
819 }
820
821 OpenConsoleRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
822 OpenConsoleRequest->HandleType = HandleType;
823 OpenConsoleRequest->DesiredAccess = dwDesiredAccess;
824 OpenConsoleRequest->InheritHandle = bInheritHandle;
825 OpenConsoleRequest->ShareMode = dwShareMode;
826
828 NULL,
830 sizeof(*OpenConsoleRequest));
831 if (!NT_SUCCESS(ApiMessage.Status))
832 {
833 BaseSetLastNTError(ApiMessage.Status);
835 }
836
837 return OpenConsoleRequest->Handle;
838}
839
840
841/*
842 * @implemented (Undocumented)
843 * @note See http://undoc.airesoft.co.uk/kernel32.dll/SetConsoleCursor.php
844 */
845BOOL
846WINAPI
849 HCURSOR hCursor)
850{
851 CONSOLE_API_MESSAGE ApiMessage;
852 PCONSOLE_SETCURSOR SetCursorRequest = &ApiMessage.Data.SetCursorRequest;
853
854 SetCursorRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
855 SetCursorRequest->OutputHandle = hConsoleOutput;
856 SetCursorRequest->CursorHandle = hCursor;
857
859 NULL,
861 sizeof(*SetCursorRequest));
862 if (!NT_SUCCESS(ApiMessage.Status))
863 {
864 BaseSetLastNTError(ApiMessage.Status);
865 return FALSE;
866 }
867
868 return TRUE;
869}
870
871
872/*
873 * @implemented
874 */
875BOOL
876WINAPI
878 DWORD dwFlags, // dwModeFlags
879 PCOORD lpNewScreenBufferDimensions)
880{
881 CONSOLE_API_MESSAGE ApiMessage;
882 PCONSOLE_SETDISPLAYMODE SetDisplayModeRequest = &ApiMessage.Data.SetDisplayModeRequest;
883
884 SetDisplayModeRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
885 SetDisplayModeRequest->OutputHandle = hConsoleOutput;
886 SetDisplayModeRequest->DisplayMode = dwFlags; // ModeFlags ; dwModeFlags
887 SetDisplayModeRequest->NewSBDim.X = 0;
888 SetDisplayModeRequest->NewSBDim.Y = 0;
889 /* SetDisplayModeRequest->EventHandle; */
890
892 NULL,
894 sizeof(*SetDisplayModeRequest));
895 if (!NT_SUCCESS(ApiMessage.Status))
896 {
897 BaseSetLastNTError(ApiMessage.Status);
898 return FALSE;
899 }
900
901 if (lpNewScreenBufferDimensions)
902 *lpNewScreenBufferDimensions = SetDisplayModeRequest->NewSBDim;
903
904 return TRUE;
905}
906
907
908/*
909 * @implemented (Undocumented)
910 * @note See http://cboard.cprogramming.com/windows-programming/102187-console-font-size.html
911 */
912BOOL
913WINAPI
915SetConsoleFont(IN HANDLE hConsoleOutput,
916 IN DWORD nFont)
917{
918 CONSOLE_API_MESSAGE ApiMessage;
919 PCONSOLE_SETFONT SetFontRequest = &ApiMessage.Data.SetFontRequest;
920
921 SetFontRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
922 SetFontRequest->OutputHandle = hConsoleOutput;
923 SetFontRequest->FontIndex = nFont;
924
926 NULL,
928 sizeof(*SetFontRequest));
929 if (!NT_SUCCESS(ApiMessage.Status))
930 {
931 BaseSetLastNTError(ApiMessage.Status);
932 return FALSE;
933 }
934
935 return TRUE;
936}
937
938
939/*
940 * @implemented (Undocumented)
941 */
942BOOL
943WINAPI
945 DWORD Flags,
946 DWORD State)
947{
948 CONSOLE_API_MESSAGE ApiMessage;
949 PCONSOLE_GETSETHWSTATE HardwareStateRequest = &ApiMessage.Data.HardwareStateRequest;
950
951 DPRINT1("SetConsoleHardwareState(%lu, %lu) UNIMPLEMENTED!\n", Flags, State);
952
953 HardwareStateRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
954 HardwareStateRequest->OutputHandle = hConsoleOutput;
955 HardwareStateRequest->Flags = Flags;
956 HardwareStateRequest->State = State;
957
959 NULL,
961 sizeof(*HardwareStateRequest));
962 if (!NT_SUCCESS(ApiMessage.Status))
963 {
964 BaseSetLastNTError(ApiMessage.Status);
965 return FALSE;
966 }
967
968 return TRUE;
969}
970
971
972/*
973 * @unimplemented (Undocumented)
974 */
975BOOL
976WINAPI
979 DWORD Unknown1,
980 DWORD Unknown2,
982{
983 DPRINT1("SetConsoleKeyShortcuts(0x%x, 0x%x, 0x%x, 0x%x) UNIMPLEMENTED!\n", Unknown0, Unknown1, Unknown2, Unknown3);
985 return FALSE;
986}
987
988
989/*
990 * @implemented (Undocumented)
991 * @note See http://undoc.airesoft.co.uk/kernel32.dll/SetConsoleMaximumWindowSize.php
992 * Does nothing, returns TRUE only. Checked on Windows Server 2003.
993 */
994BOOL
995WINAPI
997 COORD dwMaximumSize)
998{
999 DPRINT1("SetConsoleMaximumWindowSize(0x%p, {%d, %d}) does nothing\n",
1000 hConsoleOutput, dwMaximumSize.X, dwMaximumSize.Y);
1001 return TRUE;
1002}
1003
1004
1005/*
1006 * @implemented (Undocumented)
1007 */
1008BOOL
1009WINAPI
1012{
1013 CONSOLE_API_MESSAGE ApiMessage;
1014 PCONSOLE_SETMENUCLOSE SetMenuCloseRequest = &ApiMessage.Data.SetMenuCloseRequest;
1015
1016 SetMenuCloseRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1017 SetMenuCloseRequest->Enable = bEnable;
1018
1020 NULL,
1022 sizeof(*SetMenuCloseRequest));
1023 if (!NT_SUCCESS(ApiMessage.Status))
1024 {
1025 BaseSetLastNTError(ApiMessage.Status);
1026 return FALSE;
1027 }
1028
1029 return TRUE;
1030}
1031
1032
1033/*
1034 * @implemented (Undocumented)
1035 * @note See http://comments.gmane.org/gmane.comp.lang.harbour.devel/27844
1036 * Usage example: https://github.com/harbour/core/commit/d79a1b7b812cbde6ddf718ebfd6939a24f633e52
1037 */
1038BOOL
1039WINAPI
1042 HPALETTE hPalette,
1043 UINT dwUsage)
1044{
1045 CONSOLE_API_MESSAGE ApiMessage;
1046 PCONSOLE_SETPALETTE SetPaletteRequest = &ApiMessage.Data.SetPaletteRequest;
1047
1048 SetPaletteRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1049 SetPaletteRequest->OutputHandle = hConsoleOutput;
1050 SetPaletteRequest->PaletteHandle = hPalette;
1051 SetPaletteRequest->Usage = dwUsage;
1052
1054 NULL,
1056 sizeof(*SetPaletteRequest));
1057 if (!NT_SUCCESS(ApiMessage.Status))
1058 {
1059 BaseSetLastNTError(ApiMessage.Status);
1060 return FALSE;
1061 }
1062
1063 return TRUE;
1064}
1065
1066/*
1067 * @implemented (Undocumented)
1068 * @note See http://undoc.airesoft.co.uk/kernel32.dll/ShowConsoleCursor.php
1069 */
1070INT
1071WINAPI
1074 BOOL bShow)
1075{
1076 CONSOLE_API_MESSAGE ApiMessage;
1077 PCONSOLE_SHOWCURSOR ShowCursorRequest = &ApiMessage.Data.ShowCursorRequest;
1078
1079 ShowCursorRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1080 ShowCursorRequest->OutputHandle = hConsoleOutput;
1081 ShowCursorRequest->Show = bShow;
1082 ShowCursorRequest->RefCount = 0;
1083
1085 NULL,
1087 sizeof(*ShowCursorRequest));
1088
1089 return ShowCursorRequest->RefCount;
1090}
1091
1092
1093/*
1094 * FUNCTION: Checks whether the given handle is a valid console handle.
1095 *
1096 * ARGUMENTS:
1097 * hIoHandle - Handle to be checked.
1098 *
1099 * RETURNS:
1100 * TRUE : Handle is a valid console handle.
1101 * FALSE: Handle is not a valid console handle.
1102 *
1103 * STATUS: Officially undocumented
1104 *
1105 * @implemented
1106 */
1107BOOL
1108WINAPI
1111{
1112 CONSOLE_API_MESSAGE ApiMessage;
1113 PCONSOLE_VERIFYHANDLE VerifyHandleRequest = &ApiMessage.Data.VerifyHandleRequest;
1114
1115 VerifyHandleRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1116 VerifyHandleRequest->Handle = hIoHandle;
1117 VerifyHandleRequest->IsValid = FALSE;
1118
1119 /* If the process is not attached to a console, return invalid handle */
1120 if (VerifyHandleRequest->ConsoleHandle == NULL) return FALSE;
1121
1123 NULL,
1125 sizeof(*VerifyHandleRequest));
1126 if (!NT_SUCCESS(ApiMessage.Status))
1127 {
1128 BaseSetLastNTError(ApiMessage.Status);
1129 return FALSE;
1130 }
1131
1132 return VerifyHandleRequest->IsValid;
1133}
1134
1135
1136/*
1137 * @implemented (Undocumented)
1138 */
1139BOOL
1140WINAPI
1143{
1144 CONSOLE_API_MESSAGE ApiMessage;
1145 PCONSOLE_CLOSEHANDLE CloseHandleRequest = &ApiMessage.Data.CloseHandleRequest;
1146
1147 CloseHandleRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1148 CloseHandleRequest->Handle = hHandle;
1149
1151 NULL,
1153 sizeof(*CloseHandleRequest));
1154 if (!NT_SUCCESS(ApiMessage.Status))
1155 {
1156 BaseSetLastNTError(ApiMessage.Status);
1157 return FALSE;
1158 }
1159
1160 return TRUE;
1161}
1162
1163
1164/*
1165 * @implemented
1166 */
1167HANDLE
1168WINAPI
1171/*
1172 * FUNCTION: Get a handle for the standard input, standard output
1173 * and a standard error device.
1174 *
1175 * ARGUMENTS:
1176 * nStdHandle - Specifies the device for which to return the handle.
1177 *
1178 * RETURNS: If the function succeeds, the return value is the handle
1179 * of the specified device. Otherwise the value is INVALID_HANDLE_VALUE.
1180 */
1181{
1182 PRTL_USER_PROCESS_PARAMETERS Ppb = NtCurrentPeb()->ProcessParameters;
1184
1185 switch (nStdHandle)
1186 {
1187 case STD_INPUT_HANDLE:
1188 Handle = Ppb->StandardInput;
1189 break;
1190
1191 case STD_OUTPUT_HANDLE:
1192 Handle = Ppb->StandardOutput;
1193 break;
1194
1195 case STD_ERROR_HANDLE:
1196 Handle = Ppb->StandardError;
1197 break;
1198 }
1199
1200 /* If the returned handle is invalid, set last error */
1202
1203 return Handle;
1204}
1205
1206
1207/*
1208 * @implemented
1209 */
1210BOOL
1211WINAPI
1214 HANDLE hHandle)
1215/*
1216 * FUNCTION: Set the handle for the standard input, standard output or
1217 * the standard error device.
1218 *
1219 * ARGUMENTS:
1220 * nStdHandle - Specifies the handle to be set.
1221 * hHandle - The handle to set.
1222 *
1223 * RETURNS: TRUE if the function succeeds, FALSE otherwise.
1224 */
1225{
1226 PRTL_USER_PROCESS_PARAMETERS Ppb = NtCurrentPeb()->ProcessParameters;
1227
1228 /* No need to check if hHandle == INVALID_HANDLE_VALUE */
1229
1230 switch (nStdHandle)
1231 {
1232 case STD_INPUT_HANDLE:
1233 Ppb->StandardInput = hHandle;
1234 return TRUE;
1235
1236 case STD_OUTPUT_HANDLE:
1237 Ppb->StandardOutput = hHandle;
1238 return TRUE;
1239
1240 case STD_ERROR_HANDLE:
1241 Ppb->StandardError = hHandle;
1242 return TRUE;
1243 }
1244
1245 /* nStdHandle was invalid, bail out */
1247 return FALSE;
1248}
1249
1250
1251/*
1252 * @implemented
1253 */
1254static BOOL
1256 DWORD TitleLength,
1258 DWORD DesktopLength,
1259 LPWSTR CurDir,
1260 DWORD CurDirLength,
1262 DWORD AppNameLength,
1263 LPTHREAD_START_ROUTINE CtrlRoutine,
1264 LPTHREAD_START_ROUTINE PropRoutine,
1265 PCONSOLE_START_INFO ConsoleStartInfo)
1266{
1267 BOOL Success = TRUE;
1269
1270 CONSOLE_API_MESSAGE ApiMessage;
1271 PCONSOLE_ALLOCCONSOLE AllocConsoleRequest = &ApiMessage.Data.AllocConsoleRequest;
1272 PCSR_CAPTURE_BUFFER CaptureBuffer;
1273
1274 AllocConsoleRequest->CtrlRoutine = CtrlRoutine;
1275 AllocConsoleRequest->PropRoutine = PropRoutine;
1276
1277 CaptureBuffer = CsrAllocateCaptureBuffer(5, TitleLength +
1278 DesktopLength +
1279 CurDirLength +
1280 AppNameLength +
1281 sizeof(CONSOLE_START_INFO));
1282 if (CaptureBuffer == NULL)
1283 {
1285 Success = FALSE;
1286 goto Quit;
1287 }
1288
1289 CsrCaptureMessageBuffer(CaptureBuffer,
1290 ConsoleStartInfo,
1291 sizeof(CONSOLE_START_INFO),
1292 (PVOID*)&AllocConsoleRequest->ConsoleStartInfo);
1293
1294 AllocConsoleRequest->TitleLength = TitleLength;
1295 CsrCaptureMessageBuffer(CaptureBuffer,
1296 Title,
1297 TitleLength,
1298 (PVOID*)&AllocConsoleRequest->ConsoleTitle);
1299
1300 AllocConsoleRequest->DesktopLength = DesktopLength;
1301 CsrCaptureMessageBuffer(CaptureBuffer,
1302 Desktop,
1303 DesktopLength,
1304 (PVOID*)&AllocConsoleRequest->Desktop);
1305
1306 AllocConsoleRequest->CurDirLength = CurDirLength;
1307 CsrCaptureMessageBuffer(CaptureBuffer,
1308 CurDir,
1309 CurDirLength,
1310 (PVOID*)&AllocConsoleRequest->CurDir);
1311
1312 AllocConsoleRequest->AppNameLength = AppNameLength;
1313 CsrCaptureMessageBuffer(CaptureBuffer,
1314 AppName,
1315 AppNameLength,
1316 (PVOID*)&AllocConsoleRequest->AppName);
1317
1319 CaptureBuffer,
1321 sizeof(*AllocConsoleRequest));
1322 if (!NT_SUCCESS(ApiMessage.Status))
1323 {
1324 BaseSetLastNTError(ApiMessage.Status);
1325 Success = FALSE;
1326 goto Quit;
1327 }
1328
1329 // Is AllocConsoleRequest->ConsoleStartInfo->InitEvents aligned on handle boundary ????
1331 AllocConsoleRequest->ConsoleStartInfo->InitEvents,
1332 WaitAny, FALSE, NULL);
1333 if (!NT_SUCCESS(Status))
1334 {
1336 Success = FALSE;
1337 goto Quit;
1338 }
1339
1340 NtClose(AllocConsoleRequest->ConsoleStartInfo->InitEvents[INIT_SUCCESS]);
1341 NtClose(AllocConsoleRequest->ConsoleStartInfo->InitEvents[INIT_FAILURE]);
1342 if (Status != INIT_SUCCESS)
1343 {
1344 NtCurrentPeb()->ProcessParameters->ConsoleHandle = NULL;
1345 Success = FALSE;
1346 }
1347 else
1348 {
1349 RtlCopyMemory(ConsoleStartInfo,
1350 AllocConsoleRequest->ConsoleStartInfo,
1351 sizeof(CONSOLE_START_INFO));
1352 Success = TRUE;
1353 }
1354
1355Quit:
1356 if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
1357 return Success;
1358}
1359
1360BOOL
1361WINAPI
1364{
1365 BOOL Success;
1366 CONSOLE_START_INFO ConsoleStartInfo;
1367
1368 PWCHAR ConsoleTitle;
1371 PWCHAR CurDir;
1372
1373 ULONG TitleLength = (MAX_PATH + 1) * sizeof(WCHAR);
1374 ULONG DesktopLength = (MAX_PATH + 1) * sizeof(WCHAR);
1375 ULONG AppNameLength = 128 * sizeof(WCHAR);
1376 ULONG CurDirLength = (MAX_PATH + 1) * sizeof(WCHAR);
1377
1379
1380 if (NtCurrentPeb()->ProcessParameters->ConsoleHandle)
1381 {
1382 DPRINT1("AllocConsole: Allocating a console to a process already having one\n");
1384 Success = FALSE;
1385 goto Quit;
1386 }
1387
1388 /* Set up the console properties */
1390 &TitleLength,
1391 &ConsoleTitle,
1392 &DesktopLength,
1393 &Desktop,
1394 &ConsoleStartInfo);
1395 DPRINT("ConsoleTitle = '%S' - Desktop = '%S'\n",
1396 ConsoleTitle, Desktop);
1397
1398 /* Initialize the Input EXE name */
1399 InitExeName();
1401 &CurDirLength,
1402 &CurDir,
1403 &AppNameLength,
1404 &AppName);
1405 DPRINT("CurDir = '%S' - AppName = '%S'\n",
1406 CurDir, AppName);
1407
1408 Success = IntAllocConsole(ConsoleTitle,
1409 TitleLength,
1410 Desktop,
1411 DesktopLength,
1412 CurDir,
1413 CurDirLength,
1414 AppName,
1415 AppNameLength,
1418 &ConsoleStartInfo);
1419 if (Success)
1420 {
1421 /* Set up the handles */
1422 SetUpHandles(&ConsoleStartInfo);
1423 InputWaitHandle = ConsoleStartInfo.InputWaitHandle;
1424
1425 /* Initialize Console Ctrl Handling */
1427
1428 /* Sync the current thread's LangId with the console's one */
1429 SetTEBLangID();
1430 }
1431
1432Quit:
1434 return Success;
1435}
1436
1437
1438/*
1439 * @implemented
1440 */
1441BOOL
1442WINAPI
1445{
1446 BOOL Success = TRUE;
1447 CONSOLE_API_MESSAGE ApiMessage;
1448 PCONSOLE_FREECONSOLE FreeConsoleRequest = &ApiMessage.Data.FreeConsoleRequest;
1449 HANDLE ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1450
1452
1453 /* We must have a non-trivial handle to close */
1454 if (ConsoleHandle == NULL) // IsConsoleHandle(ConsoleHandle)
1455 {
1457 Success = FALSE;
1458 goto Quit;
1459 }
1460
1461 /* Set up the data to send to the Console Server */
1462 FreeConsoleRequest->ConsoleHandle = ConsoleHandle;
1463
1464 /* Call the server */
1466 NULL,
1468 sizeof(*FreeConsoleRequest));
1469
1470 /* Check for success */
1471 if (!NT_SUCCESS(ApiMessage.Status))
1472 {
1473 BaseSetLastNTError(ApiMessage.Status);
1474 Success = FALSE;
1475 goto Quit;
1476 }
1477
1478 /* Reset the console handle */
1479 NtCurrentPeb()->ProcessParameters->ConsoleHandle = NULL;
1480
1481 /* Close the associated input handle */
1484
1485Quit:
1487 return Success;
1488}
1489
1490
1491/*
1492 * @implemented
1493 */
1494BOOL
1495WINAPI
1497 PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
1498{
1499 CONSOLE_API_MESSAGE ApiMessage;
1500 PCONSOLE_GETSCREENBUFFERINFO ScreenBufferInfoRequest = &ApiMessage.Data.ScreenBufferInfoRequest;
1501
1502 if (lpConsoleScreenBufferInfo == NULL)
1503 {
1505 return FALSE;
1506 }
1507
1508 ScreenBufferInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1509 ScreenBufferInfoRequest->OutputHandle = hConsoleOutput;
1510
1512 NULL,
1514 sizeof(*ScreenBufferInfoRequest));
1515 if (!NT_SUCCESS(ApiMessage.Status))
1516 {
1517 BaseSetLastNTError(ApiMessage.Status);
1518 return FALSE;
1519 }
1520
1521 lpConsoleScreenBufferInfo->dwSize = ScreenBufferInfoRequest->ScreenBufferSize;
1522 lpConsoleScreenBufferInfo->dwCursorPosition = ScreenBufferInfoRequest->CursorPosition;
1523 lpConsoleScreenBufferInfo->wAttributes = ScreenBufferInfoRequest->Attributes;
1524 lpConsoleScreenBufferInfo->srWindow.Left = ScreenBufferInfoRequest->ViewOrigin.X;
1525 lpConsoleScreenBufferInfo->srWindow.Top = ScreenBufferInfoRequest->ViewOrigin.Y;
1526 lpConsoleScreenBufferInfo->srWindow.Right = ScreenBufferInfoRequest->ViewOrigin.X + ScreenBufferInfoRequest->ViewSize.X - 1;
1527 lpConsoleScreenBufferInfo->srWindow.Bottom = ScreenBufferInfoRequest->ViewOrigin.Y + ScreenBufferInfoRequest->ViewSize.Y - 1;
1528 lpConsoleScreenBufferInfo->dwMaximumWindowSize = ScreenBufferInfoRequest->MaximumViewSize;
1529
1530 return TRUE;
1531}
1532
1533
1534/*
1535 * @implemented
1536 */
1537BOOL
1538WINAPI
1541 COORD dwCursorPosition)
1542{
1543 CONSOLE_API_MESSAGE ApiMessage;
1544 PCONSOLE_SETCURSORPOSITION SetCursorPositionRequest = &ApiMessage.Data.SetCursorPositionRequest;
1545
1546 SetCursorPositionRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1547 SetCursorPositionRequest->OutputHandle = hConsoleOutput;
1548 SetCursorPositionRequest->Position = dwCursorPosition;
1549
1551 NULL,
1553 sizeof(*SetCursorPositionRequest));
1554 if (!NT_SUCCESS(ApiMessage.Status))
1555 {
1556 BaseSetLastNTError(ApiMessage.Status);
1557 return FALSE;
1558 }
1559
1560 return TRUE;
1561}
1562
1563
1564/*
1565 * @implemented
1566 */
1567BOOL
1568WINAPI
1569GetConsoleMode(HANDLE hConsoleHandle,
1570 LPDWORD lpMode)
1571{
1572 CONSOLE_API_MESSAGE ApiMessage;
1573 PCONSOLE_GETSETCONSOLEMODE ConsoleModeRequest = &ApiMessage.Data.ConsoleModeRequest;
1574
1575 if (lpMode == NULL)
1576 {
1578 return FALSE;
1579 }
1580
1581 ConsoleModeRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1582 ConsoleModeRequest->Handle = hConsoleHandle;
1583
1585 NULL,
1587 sizeof(*ConsoleModeRequest));
1588 if (!NT_SUCCESS(ApiMessage.Status))
1589 {
1590 BaseSetLastNTError(ApiMessage.Status);
1591 return FALSE;
1592 }
1593
1594 *lpMode = ConsoleModeRequest->Mode;
1595
1596 return TRUE;
1597}
1598
1599
1600/*
1601 * @implemented
1602 */
1603BOOL
1604WINAPI
1606SetConsoleMode(HANDLE hConsoleHandle,
1607 DWORD dwMode)
1608{
1609 CONSOLE_API_MESSAGE ApiMessage;
1610 PCONSOLE_GETSETCONSOLEMODE ConsoleModeRequest = &ApiMessage.Data.ConsoleModeRequest;
1611
1612 ConsoleModeRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1613 ConsoleModeRequest->Handle = hConsoleHandle;
1614 ConsoleModeRequest->Mode = dwMode;
1615
1617 NULL,
1619 sizeof(*ConsoleModeRequest));
1620 if (!NT_SUCCESS(ApiMessage.Status))
1621 {
1622 BaseSetLastNTError(ApiMessage.Status);
1623 return FALSE;
1624 }
1625
1626 return TRUE;
1627}
1628
1629
1630/*
1631 * @implemented
1632 */
1633BOOL
1634WINAPI
1636 LPDWORD lpNumberOfEvents)
1637{
1638 CONSOLE_API_MESSAGE ApiMessage;
1639 PCONSOLE_GETNUMINPUTEVENTS GetNumInputEventsRequest = &ApiMessage.Data.GetNumInputEventsRequest;
1640
1641 GetNumInputEventsRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1642 GetNumInputEventsRequest->InputHandle = hConsoleInput;
1643 GetNumInputEventsRequest->NumberOfEvents = 0;
1644
1646 NULL,
1648 sizeof(*GetNumInputEventsRequest));
1649 if (!NT_SUCCESS(ApiMessage.Status))
1650 {
1651 BaseSetLastNTError(ApiMessage.Status);
1652 return FALSE;
1653 }
1654
1655 if (lpNumberOfEvents == NULL)
1656 {
1658 return FALSE;
1659 }
1660
1661 *lpNumberOfEvents = GetNumInputEventsRequest->NumberOfEvents;
1662
1663 return TRUE;
1664}
1665
1666
1667/*
1668 * @implemented
1669 */
1670COORD
1671WINAPI
1674{
1675 CONSOLE_API_MESSAGE ApiMessage;
1676 PCONSOLE_GETLARGESTWINDOWSIZE GetLargestWindowSizeRequest = &ApiMessage.Data.GetLargestWindowSizeRequest;
1677
1678 GetLargestWindowSizeRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1679 GetLargestWindowSizeRequest->OutputHandle = hConsoleOutput;
1680 GetLargestWindowSizeRequest->Size.X = 0;
1681 GetLargestWindowSizeRequest->Size.Y = 0;
1682
1684 NULL,
1686 sizeof(*GetLargestWindowSizeRequest));
1687 if (!NT_SUCCESS(ApiMessage.Status))
1688 {
1689 BaseSetLastNTError(ApiMessage.Status);
1690 }
1691
1692 DPRINT("GetLargestConsoleWindowSize, X = %d, Y = %d\n", GetLargestWindowSizeRequest->Size.X, GetLargestWindowSizeRequest->Size.Y);
1693 return GetLargestWindowSizeRequest->Size;
1694}
1695
1696
1697/*
1698 * @implemented
1699 */
1700BOOL
1701WINAPI
1703 PCONSOLE_CURSOR_INFO lpConsoleCursorInfo)
1704{
1705 CONSOLE_API_MESSAGE ApiMessage;
1706 PCONSOLE_GETSETCURSORINFO CursorInfoRequest = &ApiMessage.Data.CursorInfoRequest;
1707
1708 if (!lpConsoleCursorInfo)
1709 {
1710 if (!hConsoleOutput)
1712 else
1714
1715 return FALSE;
1716 }
1717
1718 CursorInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1719 CursorInfoRequest->OutputHandle = hConsoleOutput;
1720
1722 NULL,
1724 sizeof(*CursorInfoRequest));
1725 if (!NT_SUCCESS(ApiMessage.Status))
1726 {
1727 BaseSetLastNTError(ApiMessage.Status);
1728 return FALSE;
1729 }
1730
1731 *lpConsoleCursorInfo = CursorInfoRequest->Info;
1732
1733 return TRUE;
1734}
1735
1736
1737/*
1738 * @implemented
1739 */
1740BOOL
1741WINAPI
1743 CONST CONSOLE_CURSOR_INFO *lpConsoleCursorInfo)
1744{
1745 CONSOLE_API_MESSAGE ApiMessage;
1746 PCONSOLE_GETSETCURSORINFO CursorInfoRequest = &ApiMessage.Data.CursorInfoRequest;
1747
1748 CursorInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1749 CursorInfoRequest->OutputHandle = hConsoleOutput;
1750 CursorInfoRequest->Info = *lpConsoleCursorInfo;
1751
1753 NULL,
1755 sizeof(*CursorInfoRequest));
1756 if (!NT_SUCCESS(ApiMessage.Status))
1757 {
1758 BaseSetLastNTError(ApiMessage.Status);
1759 return FALSE;
1760 }
1761
1762 return TRUE;
1763}
1764
1765
1766/*
1767 * @implemented
1768 */
1769BOOL
1770WINAPI
1772{
1773 CONSOLE_API_MESSAGE ApiMessage;
1774 PCONSOLE_GETMOUSEINFO GetMouseInfoRequest = &ApiMessage.Data.GetMouseInfoRequest;
1775
1776 GetMouseInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1777
1779 NULL,
1781 sizeof(*GetMouseInfoRequest));
1782 if (!NT_SUCCESS(ApiMessage.Status))
1783 {
1784 BaseSetLastNTError(ApiMessage.Status);
1785 return FALSE;
1786 }
1787
1788 *lpNumberOfMouseButtons = GetMouseInfoRequest->NumButtons;
1789 return TRUE;
1790}
1791
1792
1793/*
1794 * @implemented
1795 */
1796BOOL
1797WINAPI
1800{
1801 CONSOLE_API_MESSAGE ApiMessage;
1802 PCONSOLE_SETACTIVESCREENBUFFER SetScreenBufferRequest = &ApiMessage.Data.SetScreenBufferRequest;
1803
1804 SetScreenBufferRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1805 SetScreenBufferRequest->OutputHandle = hConsoleOutput;
1806
1808 NULL,
1810 sizeof(*SetScreenBufferRequest));
1811 if (!NT_SUCCESS(ApiMessage.Status))
1812 {
1813 BaseSetLastNTError(ApiMessage.Status);
1814 return FALSE;
1815 }
1816
1817 return TRUE;
1818}
1819
1820
1821/*
1822 * @implemented
1823 */
1824BOOL
1825WINAPI
1828{
1829 CONSOLE_API_MESSAGE ApiMessage;
1830 PCONSOLE_FLUSHINPUTBUFFER FlushInputBufferRequest = &ApiMessage.Data.FlushInputBufferRequest;
1831
1832 FlushInputBufferRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1833 FlushInputBufferRequest->InputHandle = hConsoleInput;
1834
1836 NULL,
1838 sizeof(*FlushInputBufferRequest));
1839 if (!NT_SUCCESS(ApiMessage.Status))
1840 {
1841 BaseSetLastNTError(ApiMessage.Status);
1842 return FALSE;
1843 }
1844
1845 return TRUE;
1846}
1847
1848
1849/*
1850 * @implemented
1851 */
1852BOOL
1853WINAPI
1856 COORD dwSize)
1857{
1858 CONSOLE_API_MESSAGE ApiMessage;
1859 PCONSOLE_SETSCREENBUFFERSIZE SetScreenBufferSizeRequest = &ApiMessage.Data.SetScreenBufferSizeRequest;
1860
1861 SetScreenBufferSizeRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1862 SetScreenBufferSizeRequest->OutputHandle = hConsoleOutput;
1863 SetScreenBufferSizeRequest->Size = dwSize;
1864
1866 NULL,
1868 sizeof(*SetScreenBufferSizeRequest));
1869 if (!NT_SUCCESS(ApiMessage.Status))
1870 {
1871 BaseSetLastNTError(ApiMessage.Status);
1872 return FALSE;
1873 }
1874
1875 return TRUE;
1876}
1877
1878
1879static
1880BOOL
1882 CONST SMALL_RECT* lpScrollRectangle,
1883 CONST SMALL_RECT* lpClipRectangle,
1884 COORD dwDestinationOrigin,
1885 CONST CHAR_INFO* lpFill,
1886 BOOL bUnicode)
1887{
1888 CONSOLE_API_MESSAGE ApiMessage;
1889 PCONSOLE_SCROLLSCREENBUFFER ScrollScreenBufferRequest = &ApiMessage.Data.ScrollScreenBufferRequest;
1890
1891 ScrollScreenBufferRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1892 ScrollScreenBufferRequest->OutputHandle = hConsoleOutput;
1893 ScrollScreenBufferRequest->ScrollRectangle = *lpScrollRectangle;
1894
1895 if (lpClipRectangle != NULL)
1896 {
1897 ScrollScreenBufferRequest->UseClipRectangle = TRUE;
1898 ScrollScreenBufferRequest->ClipRectangle = *lpClipRectangle;
1899 }
1900 else
1901 {
1902 ScrollScreenBufferRequest->UseClipRectangle = FALSE;
1903 }
1904
1905 ScrollScreenBufferRequest->DestinationOrigin = dwDestinationOrigin;
1906 ScrollScreenBufferRequest->Fill = *lpFill;
1907 ScrollScreenBufferRequest->Unicode = bUnicode;
1908
1910 NULL,
1912 sizeof(*ScrollScreenBufferRequest));
1913 if (!NT_SUCCESS(ApiMessage.Status))
1914 {
1915 BaseSetLastNTError(ApiMessage.Status);
1916 return FALSE;
1917 }
1918
1919 return TRUE;
1920}
1921
1922
1923/*
1924 * @implemented
1925 */
1926BOOL
1927WINAPI
1930 CONST SMALL_RECT* lpScrollRectangle,
1931 CONST SMALL_RECT* lpClipRectangle,
1932 COORD dwDestinationOrigin,
1933 CONST CHAR_INFO* lpFill)
1934{
1935 return IntScrollConsoleScreenBuffer(hConsoleOutput,
1936 lpScrollRectangle,
1937 lpClipRectangle,
1938 dwDestinationOrigin,
1939 lpFill,
1940 FALSE);
1941}
1942
1943
1944/*
1945 * @implemented
1946 */
1947BOOL
1948WINAPI
1951 CONST SMALL_RECT *lpScrollRectangle,
1952 CONST SMALL_RECT *lpClipRectangle,
1953 COORD dwDestinationOrigin,
1954 CONST CHAR_INFO *lpFill)
1955{
1956 return IntScrollConsoleScreenBuffer(hConsoleOutput,
1957 lpScrollRectangle,
1958 lpClipRectangle,
1959 dwDestinationOrigin,
1960 lpFill,
1961 TRUE);
1962}
1963
1964
1965/*
1966 * @implemented
1967 */
1968BOOL
1969WINAPI
1971 BOOL bAbsolute,
1972 CONST SMALL_RECT *lpConsoleWindow)
1973{
1974 CONSOLE_API_MESSAGE ApiMessage;
1975 PCONSOLE_SETWINDOWINFO SetWindowInfoRequest = &ApiMessage.Data.SetWindowInfoRequest;
1976
1977 if (lpConsoleWindow == NULL)
1978 {
1980 return FALSE;
1981 }
1982
1983 SetWindowInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1984 SetWindowInfoRequest->OutputHandle = hConsoleOutput;
1985 SetWindowInfoRequest->Absolute = bAbsolute;
1986 SetWindowInfoRequest->WindowRect = *lpConsoleWindow;
1987
1989 NULL,
1991 sizeof(*SetWindowInfoRequest));
1992 if (!NT_SUCCESS(ApiMessage.Status))
1993 {
1994 BaseSetLastNTError(ApiMessage.Status);
1995 return FALSE;
1996 }
1997
1998 return TRUE;
1999}
2000
2001
2002/*
2003 * @implemented
2004 */
2005BOOL
2006WINAPI
2009 WORD wAttributes)
2010{
2011 CONSOLE_API_MESSAGE ApiMessage;
2012 PCONSOLE_SETTEXTATTRIB SetTextAttribRequest = &ApiMessage.Data.SetTextAttribRequest;
2013
2014 SetTextAttribRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2015 SetTextAttribRequest->OutputHandle = hConsoleOutput;
2016 SetTextAttribRequest->Attributes = wAttributes;
2017
2019 NULL,
2021 sizeof(*SetTextAttribRequest));
2022 if (!NT_SUCCESS(ApiMessage.Status))
2023 {
2024 BaseSetLastNTError(ApiMessage.Status);
2025 return FALSE;
2026 }
2027
2028 return TRUE;
2029}
2030
2031
2032static
2033BOOL
2035{
2036 PHANDLER_ROUTINE* NewCtrlHandlers = NULL;
2037
2038 if (HandlerRoutine == NULL)
2039 {
2040 NtCurrentPeb()->ProcessParameters->ConsoleFlags = TRUE;
2041 return TRUE;
2042 }
2043
2045 {
2046 NewCtrlHandlers = RtlAllocateHeap(RtlGetProcessHeap(),
2047 0,
2048 (NrCtrlHandlers + 4) * sizeof(PHANDLER_ROUTINE));
2049 if (NewCtrlHandlers == NULL)
2050 {
2052 return FALSE;
2053 }
2054
2055 memmove(NewCtrlHandlers, CtrlHandlers, sizeof(PHANDLER_ROUTINE) * NrCtrlHandlers);
2056
2057 if (NrAllocatedHandlers > 1) RtlFreeHeap(RtlGetProcessHeap(), 0, CtrlHandlers);
2058
2059 CtrlHandlers = NewCtrlHandlers;
2061 }
2062
2064
2066 return TRUE;
2067}
2068
2069
2070static
2071BOOL
2073{
2074 ULONG i;
2075
2076 if (HandlerRoutine == NULL)
2077 {
2078 NtCurrentPeb()->ProcessParameters->ConsoleFlags = FALSE;
2079 return TRUE;
2080 }
2081
2082 for (i = 0; i < NrCtrlHandlers; i++)
2083 {
2085 {
2086 if (i < (NrCtrlHandlers - 1))
2087 {
2089 &CtrlHandlers[i+1],
2090 (NrCtrlHandlers - i + 1) * sizeof(PHANDLER_ROUTINE));
2091 }
2092
2094 return TRUE;
2095 }
2096 }
2097
2099 return FALSE;
2100}
2101
2102
2103/*
2104 * @implemented
2105 */
2106BOOL
2107WINAPI
2110 BOOL Add)
2111{
2112 BOOL Ret;
2113
2115
2116 if (Add)
2118 else
2120
2122 return Ret;
2123}
2124
2125
2126/*
2127 * @implemented
2128 */
2129BOOL
2130WINAPI
2133 DWORD dwProcessGroupId)
2134{
2135 CONSOLE_API_MESSAGE ApiMessage;
2136 PCONSOLE_GENERATECTRLEVENT GenerateCtrlEventRequest = &ApiMessage.Data.GenerateCtrlEventRequest;
2137
2138 if (dwCtrlEvent != CTRL_C_EVENT && dwCtrlEvent != CTRL_BREAK_EVENT)
2139 {
2141 return FALSE;
2142 }
2143
2144 GenerateCtrlEventRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2145 GenerateCtrlEventRequest->CtrlEvent = dwCtrlEvent;
2146 GenerateCtrlEventRequest->ProcessGroupId = dwProcessGroupId;
2147
2149 NULL,
2151 sizeof(*GenerateCtrlEventRequest));
2152 if (!NT_SUCCESS(ApiMessage.Status))
2153 {
2154 BaseSetLastNTError(ApiMessage.Status);
2155 return FALSE;
2156 }
2157
2158 return TRUE;
2159}
2160
2161
2162static DWORD
2163IntGetConsoleTitle(LPVOID lpConsoleTitle, DWORD dwNumChars, BOOLEAN bUnicode)
2164{
2165 CONSOLE_API_MESSAGE ApiMessage;
2166 PCONSOLE_GETSETCONSOLETITLE TitleRequest = &ApiMessage.Data.TitleRequest;
2167 PCSR_CAPTURE_BUFFER CaptureBuffer;
2168
2169 if (dwNumChars == 0) return 0;
2170
2171 TitleRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2172 TitleRequest->Length = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
2173 TitleRequest->Unicode = bUnicode;
2174
2175 CaptureBuffer = CsrAllocateCaptureBuffer(1, TitleRequest->Length);
2176 if (CaptureBuffer == NULL)
2177 {
2178 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
2180 return 0;
2181 }
2182
2183 CsrAllocateMessagePointer(CaptureBuffer,
2184 TitleRequest->Length,
2185 (PVOID*)&TitleRequest->Title);
2186
2188 CaptureBuffer,
2190 sizeof(*TitleRequest));
2191 if (!NT_SUCCESS(ApiMessage.Status))
2192 {
2193 CsrFreeCaptureBuffer(CaptureBuffer);
2194 BaseSetLastNTError(ApiMessage.Status);
2195 return 0;
2196 }
2197
2198 dwNumChars = TitleRequest->Length / (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
2199
2200 if (dwNumChars > 0)
2201 {
2202 RtlCopyMemory(lpConsoleTitle, TitleRequest->Title, TitleRequest->Length);
2203
2204 if (bUnicode)
2205 ((LPWSTR)lpConsoleTitle)[dwNumChars] = UNICODE_NULL;
2206 else
2207 ((LPSTR)lpConsoleTitle)[dwNumChars] = ANSI_NULL;
2208 }
2209
2210 CsrFreeCaptureBuffer(CaptureBuffer);
2211
2212 return dwNumChars;
2213}
2214
2215
2216/*
2217 * @implemented
2218 */
2219DWORD
2220WINAPI
2223 DWORD nSize)
2224{
2225 return IntGetConsoleTitle(lpConsoleTitle, nSize, TRUE);
2226}
2227
2228
2229/*
2230 * @implemented
2231 */
2232DWORD
2233WINAPI
2236 DWORD nSize)
2237{
2238 return IntGetConsoleTitle(lpConsoleTitle, nSize, FALSE);
2239}
2240
2241
2242static BOOL
2243IntSetConsoleTitle(CONST VOID *lpConsoleTitle, BOOLEAN bUnicode)
2244{
2245 CONSOLE_API_MESSAGE ApiMessage;
2246 PCONSOLE_GETSETCONSOLETITLE TitleRequest = &ApiMessage.Data.TitleRequest;
2247 PCSR_CAPTURE_BUFFER CaptureBuffer;
2248
2249 ULONG NumChars = (ULONG)(lpConsoleTitle ? (bUnicode ? wcslen(lpConsoleTitle) : strlen(lpConsoleTitle)) : 0);
2250
2251 TitleRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2252 TitleRequest->Length = NumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
2253 TitleRequest->Unicode = bUnicode;
2254
2255 CaptureBuffer = CsrAllocateCaptureBuffer(1, TitleRequest->Length);
2256 if (CaptureBuffer == NULL)
2257 {
2258 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
2260 return FALSE;
2261 }
2262
2263 CsrCaptureMessageBuffer(CaptureBuffer,
2264 (PVOID)lpConsoleTitle,
2265 TitleRequest->Length,
2266 (PVOID*)&TitleRequest->Title);
2267
2269 CaptureBuffer,
2271 sizeof(*TitleRequest));
2272
2273 CsrFreeCaptureBuffer(CaptureBuffer);
2274
2275 if (!NT_SUCCESS(ApiMessage.Status))
2276 {
2277 BaseSetLastNTError(ApiMessage.Status);
2278 return FALSE;
2279 }
2280
2281 return TRUE;
2282}
2283
2284/*
2285 * @implemented
2286 */
2287BOOL
2288WINAPI
2291{
2292 return IntSetConsoleTitle(lpConsoleTitle, TRUE);
2293}
2294
2295
2296/*
2297 * @implemented
2298 */
2299BOOL
2300WINAPI
2303{
2304 return IntSetConsoleTitle(lpConsoleTitle, FALSE);
2305}
2306
2307
2308/*
2309 * @implemented
2310 */
2311HANDLE
2312WINAPI
2314 DWORD dwShareMode,
2315 CONST SECURITY_ATTRIBUTES *lpSecurityAttributes,
2316 DWORD dwFlags,
2317 LPVOID lpScreenBufferData)
2318{
2319 CONSOLE_API_MESSAGE ApiMessage;
2320 PCONSOLE_CREATESCREENBUFFER CreateScreenBufferRequest = &ApiMessage.Data.CreateScreenBufferRequest;
2321 PCSR_CAPTURE_BUFFER CaptureBuffer = NULL;
2322 PCONSOLE_GRAPHICS_BUFFER_INFO GraphicsBufferInfo = lpScreenBufferData;
2323
2324 if ( (dwDesiredAccess & ~(GENERIC_READ | GENERIC_WRITE)) ||
2325 (dwShareMode & ~(FILE_SHARE_READ | FILE_SHARE_WRITE)) ||
2327 {
2329 return INVALID_HANDLE_VALUE;
2330 }
2331
2332 CreateScreenBufferRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2333 CreateScreenBufferRequest->DesiredAccess = dwDesiredAccess;
2334 CreateScreenBufferRequest->InheritHandle =
2335 (lpSecurityAttributes ? lpSecurityAttributes->bInheritHandle : FALSE);
2336 CreateScreenBufferRequest->ShareMode = dwShareMode;
2337 CreateScreenBufferRequest->ScreenBufferType = dwFlags;
2338
2340 {
2341 if (CreateScreenBufferRequest->InheritHandle || GraphicsBufferInfo == NULL)
2342 {
2344 return INVALID_HANDLE_VALUE;
2345 }
2346
2347 CreateScreenBufferRequest->GraphicsBufferInfo = *GraphicsBufferInfo;
2348
2349 CaptureBuffer = CsrAllocateCaptureBuffer(1, GraphicsBufferInfo->dwBitMapInfoLength);
2350 if (CaptureBuffer == NULL)
2351 {
2353 return INVALID_HANDLE_VALUE;
2354 }
2355
2356 CsrCaptureMessageBuffer(CaptureBuffer,
2357 (PVOID)GraphicsBufferInfo->lpBitMapInfo,
2358 GraphicsBufferInfo->dwBitMapInfoLength,
2359 (PVOID*)&CreateScreenBufferRequest->GraphicsBufferInfo.lpBitMapInfo);
2360 }
2361
2363 CaptureBuffer,
2365 sizeof(*CreateScreenBufferRequest));
2366
2367 if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
2368
2369 if (!NT_SUCCESS(ApiMessage.Status))
2370 {
2371 BaseSetLastNTError(ApiMessage.Status);
2372 return INVALID_HANDLE_VALUE;
2373 }
2374
2375 if (dwFlags == CONSOLE_GRAPHICS_BUFFER && GraphicsBufferInfo)
2376 {
2377 GraphicsBufferInfo->hMutex = CreateScreenBufferRequest->hMutex ; // CreateScreenBufferRequest->GraphicsBufferInfo.hMutex ;
2378 GraphicsBufferInfo->lpBitMap = CreateScreenBufferRequest->lpBitMap; // CreateScreenBufferRequest->GraphicsBufferInfo.lpBitMap;
2379 }
2380
2381 return CreateScreenBufferRequest->OutputHandle;
2382}
2383
2384
2385/*
2386 * @implemented
2387 */
2388UINT
2389WINAPI
2392{
2393 CONSOLE_API_MESSAGE ApiMessage;
2394 PCONSOLE_GETINPUTOUTPUTCP GetConsoleCPRequest = &ApiMessage.Data.GetConsoleCPRequest;
2395
2396 /* Get the Input Code Page */
2397 GetConsoleCPRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2398 GetConsoleCPRequest->OutputCP = FALSE;
2399
2401 NULL,
2403 sizeof(*GetConsoleCPRequest));
2404 if (!NT_SUCCESS(ApiMessage.Status))
2405 {
2406 BaseSetLastNTError(ApiMessage.Status);
2407 return 0;
2408 }
2409
2410 return GetConsoleCPRequest->CodePage;
2411}
2412
2413
2414/*
2415 * @implemented
2416 */
2417BOOL
2418WINAPI
2420SetConsoleCP(UINT wCodePageID)
2421{
2422 CONSOLE_API_MESSAGE ApiMessage;
2423 PCONSOLE_SETINPUTOUTPUTCP SetConsoleCPRequest = &ApiMessage.Data.SetConsoleCPRequest;
2424
2425 /* Set the Input Code Page */
2426 SetConsoleCPRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2427 SetConsoleCPRequest->CodePage = wCodePageID;
2428 SetConsoleCPRequest->OutputCP = FALSE;
2429 /* SetConsoleCPRequest->EventHandle; */
2430
2432 NULL,
2434 sizeof(*SetConsoleCPRequest));
2435 if (!NT_SUCCESS(ApiMessage.Status))
2436 {
2437 BaseSetLastNTError(ApiMessage.Status);
2438 return FALSE;
2439 }
2440
2441 return TRUE;
2442}
2443
2444
2445/*
2446 * @implemented
2447 */
2448UINT
2449WINAPI
2452{
2453 CONSOLE_API_MESSAGE ApiMessage;
2454 PCONSOLE_GETINPUTOUTPUTCP GetConsoleCPRequest = &ApiMessage.Data.GetConsoleCPRequest;
2455
2456 /* Get the Output Code Page */
2457 GetConsoleCPRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2458 GetConsoleCPRequest->OutputCP = TRUE;
2459
2461 NULL,
2463 sizeof(*GetConsoleCPRequest));
2464 if (!NT_SUCCESS(ApiMessage.Status))
2465 {
2466 BaseSetLastNTError(ApiMessage.Status);
2467 return 0;
2468 }
2469
2470 return GetConsoleCPRequest->CodePage;
2471}
2472
2473
2474/*
2475 * @implemented
2476 */
2477BOOL
2478WINAPI
2481{
2482 CONSOLE_API_MESSAGE ApiMessage;
2483 PCONSOLE_SETINPUTOUTPUTCP SetConsoleCPRequest = &ApiMessage.Data.SetConsoleCPRequest;
2484
2485 /* Set the Output Code Page */
2486 SetConsoleCPRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2487 SetConsoleCPRequest->CodePage = wCodePageID;
2488 SetConsoleCPRequest->OutputCP = TRUE;
2489 /* SetConsoleCPRequest->EventHandle; */
2490
2492 NULL,
2494 sizeof(*SetConsoleCPRequest));
2495 if (!NT_SUCCESS(ApiMessage.Status))
2496 {
2497 BaseSetLastNTError(ApiMessage.Status);
2498 return FALSE;
2499 }
2500
2501 /* Sync the current thread's LangId with the console's one */
2502 SetTEBLangID();
2503
2504 return TRUE;
2505}
2506
2507
2508/*
2509 * @implemented
2510 */
2511DWORD
2512WINAPI
2514 DWORD dwProcessCount)
2515{
2516 CONSOLE_API_MESSAGE ApiMessage;
2517 PCONSOLE_GETPROCESSLIST GetProcessListRequest = &ApiMessage.Data.GetProcessListRequest;
2518 PCSR_CAPTURE_BUFFER CaptureBuffer;
2519 ULONG nProcesses = 0;
2520
2521 if (lpdwProcessList == NULL || dwProcessCount == 0)
2522 {
2524 return 0;
2525 }
2526
2527 CaptureBuffer = CsrAllocateCaptureBuffer(1, dwProcessCount * sizeof(DWORD));
2528 if (CaptureBuffer == NULL)
2529 {
2530 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
2532 return 0;
2533 }
2534
2535 GetProcessListRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2536 GetProcessListRequest->ProcessCount = dwProcessCount;
2537
2538 CsrAllocateMessagePointer(CaptureBuffer,
2539 dwProcessCount * sizeof(DWORD),
2540 (PVOID*)&GetProcessListRequest->ProcessIdsList);
2541
2543 CaptureBuffer,
2545 sizeof(*GetProcessListRequest));
2546 if (!NT_SUCCESS(ApiMessage.Status))
2547 {
2548 BaseSetLastNTError(ApiMessage.Status);
2549 }
2550 else
2551 {
2552 nProcesses = GetProcessListRequest->ProcessCount;
2553 if (dwProcessCount >= nProcesses)
2554 {
2555 RtlCopyMemory(lpdwProcessList, GetProcessListRequest->ProcessIdsList, nProcesses * sizeof(DWORD));
2556 }
2557 }
2558
2559 CsrFreeCaptureBuffer(CaptureBuffer);
2560 return nProcesses;
2561}
2562
2563
2564/*
2565 * @implemented
2566 */
2567BOOL
2568WINAPI
2570{
2571 CONSOLE_API_MESSAGE ApiMessage;
2572 PCONSOLE_GETSELECTIONINFO GetSelectionInfoRequest = &ApiMessage.Data.GetSelectionInfoRequest;
2573
2574 if (lpConsoleSelectionInfo == NULL)
2575 {
2577 return FALSE;
2578 }
2579
2580 GetSelectionInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2581
2583 NULL,
2585 sizeof(*GetSelectionInfoRequest));
2586 if (!NT_SUCCESS(ApiMessage.Status))
2587 {
2588 BaseSetLastNTError(ApiMessage.Status);
2589 return FALSE;
2590 }
2591
2592 *lpConsoleSelectionInfo = GetSelectionInfoRequest->Info;
2593
2594 return TRUE;
2595}
2596
2597
2598/*
2599 * @implemented
2600 * @note Strongly inspired by AllocConsole.
2601 */
2602static BOOL
2604 LPTHREAD_START_ROUTINE CtrlRoutine,
2605 LPTHREAD_START_ROUTINE PropRoutine,
2606 PCONSOLE_START_INFO ConsoleStartInfo)
2607{
2608 BOOL Success = TRUE;
2610
2611 CONSOLE_API_MESSAGE ApiMessage;
2612 PCONSOLE_ATTACHCONSOLE AttachConsoleRequest = &ApiMessage.Data.AttachConsoleRequest;
2613 PCSR_CAPTURE_BUFFER CaptureBuffer;
2614
2615 AttachConsoleRequest->ProcessId = ProcessId;
2616 AttachConsoleRequest->CtrlRoutine = CtrlRoutine;
2617 AttachConsoleRequest->PropRoutine = PropRoutine;
2618
2619 CaptureBuffer = CsrAllocateCaptureBuffer(1, sizeof(CONSOLE_START_INFO));
2620 if (CaptureBuffer == NULL)
2621 {
2623 Success = FALSE;
2624 goto Quit;
2625 }
2626
2627 CsrCaptureMessageBuffer(CaptureBuffer,
2628 ConsoleStartInfo,
2629 sizeof(CONSOLE_START_INFO),
2630 (PVOID*)&AttachConsoleRequest->ConsoleStartInfo);
2631
2633 CaptureBuffer,
2635 sizeof(*AttachConsoleRequest));
2636 if (!NT_SUCCESS(ApiMessage.Status))
2637 {
2638 BaseSetLastNTError(ApiMessage.Status);
2639 Success = FALSE;
2640 goto Quit;
2641 }
2642
2643 // Is AttachConsoleRequest->ConsoleStartInfo->InitEvents aligned on handle boundary ????
2645 AttachConsoleRequest->ConsoleStartInfo->InitEvents,
2646 WaitAny, FALSE, NULL);
2647 if (!NT_SUCCESS(Status))
2648 {
2650 Success = FALSE;
2651 goto Quit;
2652 }
2653
2654 NtClose(AttachConsoleRequest->ConsoleStartInfo->InitEvents[INIT_SUCCESS]);
2655 NtClose(AttachConsoleRequest->ConsoleStartInfo->InitEvents[INIT_FAILURE]);
2656 if (Status != INIT_SUCCESS)
2657 {
2658 NtCurrentPeb()->ProcessParameters->ConsoleHandle = NULL;
2659 Success = FALSE;
2660 }
2661 else
2662 {
2663 RtlCopyMemory(ConsoleStartInfo,
2664 AttachConsoleRequest->ConsoleStartInfo,
2665 sizeof(CONSOLE_START_INFO));
2666 Success = TRUE;
2667 }
2668
2669Quit:
2670 if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
2671 return Success;
2672}
2673
2674BOOL
2675WINAPI
2677{
2678 BOOL Success;
2679 CONSOLE_START_INFO ConsoleStartInfo;
2680 DWORD dummy;
2681
2683
2684 if (NtCurrentPeb()->ProcessParameters->ConsoleHandle)
2685 {
2686 DPRINT1("AttachConsole: Attaching a console to a process already having one\n");
2688 Success = FALSE;
2689 goto Quit;
2690 }
2691
2692 /* Set up the console properties */
2694 &dummy,
2695 NULL,
2696 &dummy,
2697 NULL,
2698 &ConsoleStartInfo);
2699
2700 Success = IntAttachConsole(dwProcessId,
2703 &ConsoleStartInfo);
2704 if (Success)
2705 {
2706 /* Set up the handles */
2707 SetUpHandles(&ConsoleStartInfo);
2708 InputWaitHandle = ConsoleStartInfo.InputWaitHandle;
2709
2710 /* Initialize Console Ctrl Handling */
2712
2713 /* Sync the current thread's LangId with the console's one */
2714 SetTEBLangID();
2715 }
2716
2717Quit:
2719 return Success;
2720}
2721
2722
2723/*
2724 * @implemented
2725 */
2726HWND
2727WINAPI
2730{
2731 CONSOLE_API_MESSAGE ApiMessage;
2732 PCONSOLE_GETWINDOW GetWindowRequest = &ApiMessage.Data.GetWindowRequest;
2733
2734 GetWindowRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2735
2737 NULL,
2739 sizeof(*GetWindowRequest));
2740 if (!NT_SUCCESS(ApiMessage.Status))
2741 {
2742 BaseSetLastNTError(ApiMessage.Status);
2743 return (HWND)NULL;
2744 }
2745
2746 return GetWindowRequest->WindowHandle;
2747}
2748
2749
2750/*
2751 * @implemented
2752 */
2753BOOL
2754WINAPI
2757{
2758 CONSOLE_API_MESSAGE ApiMessage;
2759 PCONSOLE_SETICON SetIconRequest = &ApiMessage.Data.SetIconRequest;
2760
2761 SetIconRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2762 SetIconRequest->IconHandle = hIcon;
2763
2765 NULL,
2767 sizeof(*SetIconRequest));
2768 if (!NT_SUCCESS(ApiMessage.Status))
2769 {
2770 BaseSetLastNTError(ApiMessage.Status);
2771 return FALSE;
2772 }
2773
2774 return TRUE;
2775}
2776
2777
2778/******************************************************************************
2779 * \name SetConsoleInputExeNameW
2780 * \brief Sets the console input file name from a unicode string.
2781 * \param lpExeName Pointer to a unicode string with the name.
2782 * \return TRUE if successful, FALSE if unsuccessful.
2783 * \remarks If lpExeName is 0 or the string length is 0 or greater than 255,
2784 * the function fails and sets last error to ERROR_INVALID_PARAMETER.
2785 */
2786BOOL
2787WINAPI
2790{
2791 DWORD ExeLength;
2792
2793 ExeLength = lstrlenW(lpExeName);
2794 if ((ExeLength == 0) || (ExeLength >= EXENAME_LENGTH))
2795 {
2796 /* Fail if string is empty or too long */
2798 return FALSE;
2799 }
2800
2802 _SEH2_TRY
2803 {
2804 /* Set the input EXE name, not NULL terminated */
2805 RtlCopyMemory(ExeNameBuffer, lpExeName, ExeLength * sizeof(WCHAR));
2806 ExeNameLength = (USHORT)ExeLength;
2807 }
2809 {
2811 }
2812 _SEH2_END;
2813
2814 return TRUE;
2815}
2816
2817
2818/******************************************************************************
2819 * \name SetConsoleInputExeNameA
2820 * \brief Sets the console input file name from an ansi string.
2821 * \param lpExeName Pointer to an ansi string with the name.
2822 * \return TRUE if successful, FALSE if unsuccessful.
2823 * \remarks If lpExeName is 0 or the string length is 0 or greater than 255,
2824 * the function fails and sets last error to ERROR_INVALID_PARAMETER.
2825 */
2826BOOL
2827WINAPI
2830{
2832#ifdef USE_TEB_STATIC_USTR
2833 PUNICODE_STRING ExeNameU;
2834#else
2835 UNICODE_STRING ExeNameU;
2836#endif
2837 ANSI_STRING ExeNameA;
2838#ifndef USE_TEB_STATIC_USTR
2840#endif
2841
2842#ifdef USE_TEB_STATIC_USTR
2843 /*
2844 * Use the TEB static UNICODE string for storage. It is already
2845 * initialized at process creation time by the Memory Manager.
2846 */
2847 ExeNameU = &NtCurrentTeb()->StaticUnicodeString;
2848#endif
2849
2850 /* Initialize string for conversion */
2851 RtlInitAnsiString(&ExeNameA, lpExeName);
2852
2853#if 1
2854 if ((ExeNameA.Length == 0) || (ExeNameA.Length >= EXENAME_LENGTH))
2855 {
2856 /* Fail if string is empty or too long */
2858 return FALSE;
2859 }
2860#endif
2861#ifndef USE_TEB_STATIC_USTR
2862 ExeNameU.Length = 0;
2863 ExeNameU.MaximumLength = (USHORT)sizeof(Buffer);
2864 ExeNameU.Buffer = Buffer;
2865#endif
2866
2867#ifdef USE_TEB_STATIC_USTR
2868 Status = RtlAnsiStringToUnicodeString(ExeNameU, &ExeNameA, FALSE);
2869#else
2870 Status = RtlAnsiStringToUnicodeString(&ExeNameU, &ExeNameA, FALSE);
2871#endif
2872 if (!NT_SUCCESS(Status))
2873 {
2874 /* Fail if string is empty or too long */
2877 else
2879
2880 return FALSE;
2881 }
2882
2883#ifdef USE_TEB_STATIC_USTR
2884 return SetConsoleInputExeNameW(ExeNameU->Buffer);
2885#else
2886 return SetConsoleInputExeNameW(ExeNameU.Buffer);
2887#endif
2888}
2889
2890
2891/******************************************************************************
2892 * \name GetConsoleInputExeNameW
2893 * \brief Retrieves the console input file name as unicode string.
2894 * \param nBufferLength Length of the buffer in WCHARs.
2895 * Specify 0 to receive the needed buffer length.
2896 * \param lpBuffer Pointer to a buffer that receives the string.
2897 * \return Needed buffer size if \p nBufferLength is 0.
2898 * Otherwise 1 if successful, 2 if buffer is too small.
2899 * \remarks Sets last error value to ERROR_BUFFER_OVERFLOW if the buffer
2900 * is not big enough.
2901 */
2902DWORD
2903WINAPI
2907{
2909 {
2910 /* Buffer is not large enough! Return the correct size. */
2912 return ExeNameLength + 1;
2913 }
2914
2916 _SEH2_TRY
2917 {
2918 /* Copy the input EXE name and NULL-terminate it */
2921 }
2923 {
2925 }
2926 _SEH2_END;
2927
2928 return TRUE;
2929}
2930
2931
2932/******************************************************************************
2933 * \name GetConsoleInputExeNameA
2934 * \brief Retrieves the console input file name as ansi string.
2935 * \param nBufferLength Length of the buffer in CHARs.
2936 * \param lpBuffer Pointer to a buffer that receives the string.
2937 * \return 1 if successful, 2 if buffer is too small.
2938 * \remarks Sets last error value to ERROR_BUFFER_OVERFLOW if the buffer
2939 * is not big enough. The buffer receives as much characters as fit.
2940 */
2941DWORD
2942WINAPI
2946{
2948 DWORD ExeLength;
2949 UNICODE_STRING BufferU;
2950 ANSI_STRING BufferA;
2952
2953 /* Get the UNICODE name */
2955
2956 if ((ExeLength == 0) || (ExeLength >= EXENAME_LENGTH))
2957 return ExeLength;
2958
2959 /* Initialize the strings for conversion */
2960 RtlInitUnicodeString(&BufferU, Buffer);
2961 BufferA.Length = 0;
2963 BufferA.Buffer = lpExeName;
2964
2965 /* Convert UNICODE name to ANSI, copying as much chars as it can fit */
2966 Status = RtlUnicodeStringToAnsiString(&BufferA, &BufferU, FALSE);
2967 if (!NT_SUCCESS(Status))
2968 {
2970 {
2972 return ExeLength + 1;
2973 }
2975 }
2976
2977 return ExeLength;
2978}
2979
2980BOOL
2981WINAPI
2983{
2984 STUB;
2985 return FALSE;
2986}
2987
2988BOOL
2989WINAPI
2991GetConsoleCursorMode(HANDLE hConsole, PBOOL pUnknown1, PBOOL pUnknown2)
2992{
2993 STUB;
2994 return FALSE;
2995}
2996
2997BOOL
2998WINAPI
3000SetConsoleCursorMode(HANDLE hConsole, BOOL Unknown1, BOOL Unknown2)
3001{
3002 STUB;
3003 return FALSE;
3004}
3005
3006BOOL
3007WINAPI
3010{
3011 STUB;
3012 return FALSE;
3013}
3014
3015BOOL
3016WINAPI
3019{
3020 STUB;
3021 return FALSE;
3022}
3023
3024BOOL
3025WINAPI
3028{
3029 STUB;
3030 return FALSE;
3031}
3032
3033static BOOL
3035 _In_ HWND hWnd,
3037 _In_opt_ SIZE_T cbDesktop,
3038 _In_opt_ PWSTR pDesktop,
3039 _Out_opt_ PDWORD pdwAttachToThreadId)
3040{
3041 CONSOLE_API_MESSAGE ApiMessage;
3043 PCSR_CAPTURE_BUFFER CaptureBuffer;
3044
3045 if (!cbDesktop || !pDesktop)
3046 {
3047 pDesktop = NtCurrentPeb()->ProcessParameters->DesktopInfo.Buffer;
3048 cbDesktop = NtCurrentPeb()->ProcessParameters->DesktopInfo.Length;
3049 }
3050
3051 cbDesktop = min(cbDesktop, (MAX_PATH + 1) * sizeof(WCHAR));
3052
3053 RegisterConsoleIME->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
3054 RegisterConsoleIME->hWnd = hWnd;
3055 RegisterConsoleIME->dwThreadId = dwThreadId;
3056 RegisterConsoleIME->cbDesktop = cbDesktop;
3057
3058 CaptureBuffer = CsrAllocateCaptureBuffer(1, cbDesktop);
3059 if (!CaptureBuffer)
3060 {
3062 return FALSE;
3063 }
3064
3065 CsrCaptureMessageBuffer(CaptureBuffer,
3066 pDesktop,
3067 cbDesktop,
3068 (PVOID*)&RegisterConsoleIME->pDesktop);
3069
3071 CaptureBuffer,
3073 sizeof(*RegisterConsoleIME));
3074
3075 CsrFreeCaptureBuffer(CaptureBuffer);
3076
3077 if (!NT_SUCCESS(ApiMessage.Status))
3078 {
3079 BaseSetLastNTError(ApiMessage.Status);
3080 return FALSE;
3081 }
3082
3083 if (pdwAttachToThreadId)
3084 {
3085 _SEH2_TRY
3086 {
3087 *pdwAttachToThreadId = RegisterConsoleIME->dwAttachToThreadId;
3088 }
3090 {
3092 _SEH2_YIELD(return FALSE);
3093 }
3094 _SEH2_END;
3095 }
3096
3097 return TRUE;
3098}
3099
3100static BOOL
3103{
3104 CONSOLE_API_MESSAGE ApiMessage;
3106
3107 UnregisterConsoleIME->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
3108 UnregisterConsoleIME->dwThreadId = dwThreadId;
3109
3111 NULL,
3113 sizeof(*UnregisterConsoleIME));
3114 if (!NT_SUCCESS(ApiMessage.Status))
3115 {
3116 BaseSetLastNTError(ApiMessage.Status);
3117 return FALSE;
3118 }
3119
3120 return TRUE;
3121}
3122
3123/* This function is called by CONIME.EXE */
3124BOOL
3125WINAPI
3128 _In_ HWND hWnd,
3129 _Out_opt_ LPDWORD pdwAttachToThreadId)
3130{
3133 0,
3134 NULL,
3135 pdwAttachToThreadId);
3136}
3137
3138BOOL
3139WINAPI
3142{
3143 STUB;
3144 return FALSE;
3145}
3146
3147BOOL
3148WINAPI
3151{
3152 STUB;
3153 return FALSE;
3154}
3155
3156/* This function is called by CONIME.EXE */
3157BOOL
3158WINAPI
3161{
3163}
3164
3170VOID
3172{
3173 CONSOLE_API_MESSAGE ApiMessage;
3174 PCONSOLE_GETLANGID LangIdRequest = &ApiMessage.Data.LangIdRequest;
3175
3176 /* Retrieve the "best-suited" language ID corresponding
3177 * to the active console output code page. */
3178 LangIdRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
3179
3181 NULL,
3183 sizeof(*LangIdRequest));
3184 if (!NT_SUCCESS(ApiMessage.Status))
3185 {
3186 /*
3187 * No best console language ID: keep the current thread's one.
3188 * Since this internal function only modifies an optional setting,
3189 * don't set any last error, as it could otherwise mess with the
3190 * main last error set by the caller.
3191 */
3192 return;
3193 }
3194
3195 /*
3196 * We succeeded, set the current thread's language ID by
3197 * modifying its locale -- Windows <= 2003 does not have
3198 * the concept of a separate thread UI language.
3199 * Ignore the returned value.
3200 */
3201 if (!SetThreadLocale(MAKELCID(LangIdRequest->LangId, SORT_DEFAULT)))
3202 {
3203 DPRINT1("SetTEBLangID: Could not set thread locale to console lang ID %lu\n",
3204 LangIdRequest->LangId);
3205 }
3206}
3207
3208static
3209BOOL
3211 IN BOOL bAnsi)
3212{
3213 CONSOLE_API_MESSAGE ApiMessage;
3214 PCONSOLE_GETKBDLAYOUTNAME GetKbdLayoutNameRequest = &ApiMessage.Data.GetKbdLayoutNameRequest;
3215
3216 /* Set up the data to send to the Console Server */
3217 GetKbdLayoutNameRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
3218 GetKbdLayoutNameRequest->Ansi = bAnsi;
3219
3220 /* Call the server */
3222 NULL,
3224 sizeof(*GetKbdLayoutNameRequest));
3225
3226 /* Check for success */
3227 if (!NT_SUCCESS(ApiMessage.Status))
3228 {
3229 BaseSetLastNTError(ApiMessage.Status);
3230 return FALSE;
3231 }
3232
3233 /* Retrieve the results */
3234 _SEH2_TRY
3235 {
3236 /* Copy only KL_NAMELENGTH == 9 characters, ANSI or UNICODE */
3237 if (bAnsi)
3238 strncpy(pszLayoutName, (PCHAR)GetKbdLayoutNameRequest->LayoutBuffer, KL_NAMELENGTH);
3239 else
3240 wcsncpy(pszLayoutName, (PWCHAR)GetKbdLayoutNameRequest->LayoutBuffer, KL_NAMELENGTH);
3241 }
3243 {
3245 _SEH2_YIELD(return FALSE);
3246 }
3247 _SEH2_END;
3248
3249 return TRUE;
3250}
3251
3252/*
3253 * @implemented (undocumented)
3254 */
3255BOOL
3256WINAPI
3259{
3260 return IntGetConsoleKeyboardLayoutName(pszLayoutName, TRUE);
3261}
3262
3263/*
3264 * @implemented (undocumented)
3265 */
3266BOOL
3267WINAPI
3270{
3271 return IntGetConsoleKeyboardLayoutName(pszLayoutName, FALSE);
3272}
3273
3274/*
3275 * @implemented
3276 */
3277DWORD
3278WINAPI
3280{
3281 CONSOLE_API_MESSAGE ApiMessage;
3282 PCONSOLE_NOTIFYLASTCLOSE NotifyLastCloseRequest = &ApiMessage.Data.NotifyLastCloseRequest;
3283
3284 /* Set the flag used by the console control dispatcher */
3286
3287 /* Set up the input arguments */
3288 NotifyLastCloseRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
3289
3290 /* Call CSRSS; just return the NTSTATUS cast to DWORD */
3291 return CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
3292 NULL,
3294 sizeof(*NotifyLastCloseRequest));
3295}
3296
3297/* EOF */
#define NtCurrentPeb()
Definition: FLS.c:22
unsigned char BOOLEAN
BOOL WINAPI HandlerRoutine(DWORD dwCtrlType)
PRTL_UNICODE_STRING_BUFFER PULONG PULONG Unknown4
Type
Definition: Type.h:7
#define DECLSPEC_HOTPATCH
Definition: _mingw.h:243
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
HWND hWnd
Definition: settings.c:17
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
BOOL WINAPI SetConsoleOutputCP(IN UINT wCodepage)
Definition: console.c:695
BOOL WINAPI FlushConsoleInputBuffer(IN HANDLE hConsoleInput)
Definition: console.c:220
BOOL WINAPI SetConsoleCursorPosition(IN HANDLE hConsoleOutput, IN COORD dwCursorPosition)
Definition: console.c:641
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:203
BOOL WINAPI AllocConsole(VOID)
Definition: console.c:74
BOOL WINAPI FreeConsole(VOID)
Definition: console.c:156
BOOL WINAPI SetConsoleTextAttribute(IN HANDLE hConsoleOutput, IN WORD wAttributes)
Definition: console.c:672
BOOL WINAPI SetConsoleCursorInfo(IN HANDLE hConsoleOutput, IN const CONSOLE_CURSOR_INFO *lpConsoleCursorInfo)
Definition: console.c:618
BOOL WINAPI AttachConsole(IN DWORD dwProcessId)
Definition: console.c:147
BOOL WINAPI GetConsoleScreenBufferInfo(IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
Definition: console.c:595
WCHAR CurrentDirectory[1024]
Definition: chkdsk.c:74
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
Definition: bufpool.h:45
@ MAX_INIT_EVENTS
Definition: conmsg.h:165
@ INIT_SUCCESS
Definition: conmsg.h:163
@ INIT_FAILURE
Definition: conmsg.h:164
@ HANDLE_INPUT
Definition: conmsg.h:667
@ HANDLE_OUTPUT
Definition: conmsg.h:668
@ ConsolepGetCP
Definition: conmsg.h:84
@ ConsolepSetCursorPosition
Definition: conmsg.h:43
@ ConsolepCloseHandle
Definition: conmsg.h:55
@ ConsolepMenuControl
Definition: conmsg.h:66
@ ConsolepGetHardwareState
Definition: conmsg.h:70
@ ConsolepGetMouseInfo
Definition: conmsg.h:34
@ ConsolepSetActiveScreenBuffer
Definition: conmsg.h:39
@ ConsolepSetCP
Definition: conmsg.h:85
@ ConsolepGetProcessList
Definition: conmsg.h:106
@ ConsolepDuplicateHandle
Definition: conmsg.h:52
@ ConsolepSetFont
Definition: conmsg.h:48
@ ConsolepUnregisterConsoleIME
Definition: conmsg.h:101
@ ConsolepAlloc
Definition: conmsg.h:57
@ ConsolepGetHandleInformation
Definition: conmsg.h:53
@ ConsolepVerifyIoHandle
Definition: conmsg.h:56
@ ConsolepInvalidateBitMapRect
Definition: conmsg.h:62
@ ConsolepGetLangId
Definition: conmsg.h:103
@ ConsolepSetDisplayMode
Definition: conmsg.h:68
@ ConsolepCreateScreenBuffer
Definition: conmsg.h:61
@ ConsolepAttach
Definition: conmsg.h:104
@ ConsolepGenerateCtrlEvent
Definition: conmsg.h:89
@ ConsolepGetFontSize
Definition: conmsg.h:36
@ ConsolepGetTitle
Definition: conmsg.h:59
@ ConsolepGetSelectionInfo
Definition: conmsg.h:105
@ ConsolepRegisterConsoleIME
Definition: conmsg.h:100
@ ConsolepSetPalette
Definition: conmsg.h:67
@ ConsolepFlushInputBuffer
Definition: conmsg.h:40
@ ConsolepGetNumberOfFonts
Definition: conmsg.h:30
@ ConsolepSetCursor
Definition: conmsg.h:64
@ ConsolepNotifyLastClose
Definition: conmsg.h:88
@ ConsolepGetCursorInfo
Definition: conmsg.h:33
@ ConsolepSetTitle
Definition: conmsg.h:60
@ ConsolepSetWindowInfo
Definition: conmsg.h:45
@ ConsolepGetNumberOfInputEvents
Definition: conmsg.h:31
@ ConsolepGetMode
Definition: conmsg.h:29
@ ConsolepSetMenuClose
Definition: conmsg.h:87
@ ConsolepGetKeyboardLayoutName
Definition: conmsg.h:90
@ ConsolepSetCursorInfo
Definition: conmsg.h:44
@ ConsolepGetCurrentFont
Definition: conmsg.h:37
@ ConsolepShowCursor
Definition: conmsg.h:65
@ ConsolepSetHardwareState
Definition: conmsg.h:71
@ ConsolepScrollScreenBuffer
Definition: conmsg.h:46
@ ConsolepOpenConsole
Definition: conmsg.h:21
@ ConsolepSetIcon
Definition: conmsg.h:49
@ ConsolepSetMode
Definition: conmsg.h:38
@ ConsolepGetLargestWindowSize
Definition: conmsg.h:41
@ ConsolepGetConsoleWindow
Definition: conmsg.h:91
@ ConsolepSetTextAttribute
Definition: conmsg.h:47
@ ConsolepGetFontInfo
Definition: conmsg.h:35
@ ConsolepGetDisplayMode
Definition: conmsg.h:72
@ ConsolepSetScreenBufferSize
Definition: conmsg.h:42
@ ConsolepSetHandleInformation
Definition: conmsg.h:54
@ ConsolepGetScreenBufferInfo
Definition: conmsg.h:32
@ ConsolepFree
Definition: conmsg.h:58
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15
enum _CONSOLE_HANDLE_TYPE CONSOLE_HANDLE_TYPE
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES IN DWORD Unknown3
Definition: conport.c:37
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define BufferSize
Definition: mmc.h:75
static CHAR AppName[MAX_PATH]
Definition: dem.c:252
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const WCHAR Title[]
Definition: oid.c:1259
#define CloseHandle
Definition: compat.h:739
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define MAX_PATH
Definition: compat.h:34
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
#define FILE_SHARE_READ
Definition: compat.h:136
#define lstrlenW
Definition: compat.h:750
BOOL WINAPI DECLSPEC_HOTPATCH GetConsoleKeyboardLayoutNameA(OUT LPSTR pszLayoutName)
Definition: console.c:3258
BOOL WINAPI SetConsoleWindowInfo(HANDLE hConsoleOutput, BOOL bAbsolute, CONST SMALL_RECT *lpConsoleWindow)
Definition: console.c:1970
BOOL WINAPI GetConsoleSelectionInfo(PCONSOLE_SELECTION_INFO lpConsoleSelectionInfo)
Definition: console.c:2569
BOOL WINAPI DECLSPEC_HOTPATCH GetConsoleCursorMode(HANDLE hConsole, PBOOL pUnknown1, PBOOL pUnknown2)
Definition: console.c:2991
BOOL WINAPI DECLSPEC_HOTPATCH CloseConsoleHandle(HANDLE hHandle)
Definition: console.c:1142
static BOOL IntUnregisterConsoleIME(_In_ DWORD dwThreadId)
Definition: console.c:3101
static BOOL AddConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine)
Definition: console.c:2034
static WCHAR StartDirBuffer[MAX_PATH+1]
Definition: console.c:45
static WCHAR ExeNameBuffer[EXENAME_LENGTH]
Definition: console.c:43
LPCWSTR IntCheckForConsoleFileName(IN LPCWSTR pszName, IN DWORD dwDesiredAccess)
Definition: console.c:345
HMENU WINAPI DECLSPEC_HOTPATCH ConsoleMenuControl(HANDLE hConsoleOutput, DWORD dwCmdIdLow, DWORD dwCmdIdHigh)
Definition: console.c:396
static ULONG NrCtrlHandlers
Definition: console.c:31
DWORD WINAPI DECLSPEC_HOTPATCH GetNumberOfConsoleFonts(VOID)
Definition: console.c:729
static PHANDLER_ROUTINE * CtrlHandlers
Definition: console.c:30
HANDLE WINAPI DECLSPEC_HOTPATCH DuplicateConsoleHandle(HANDLE hConsole, DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwOptions)
Definition: console.c:424
DWORD WINAPI DECLSPEC_HOTPATCH GetConsoleTitleA(LPSTR lpConsoleTitle, DWORD nSize)
Definition: console.c:2235
static ULONG NrAllocatedHandlers
Definition: console.c:32
BOOL WINAPI InvalidateConsoleDIBits(IN HANDLE hConsoleOutput, IN PSMALL_RECT lpRect)
Definition: console.c:756
BOOL WINAPI DECLSPEC_HOTPATCH GetConsoleNlsMode(HANDLE hConsole, LPDWORD lpMode)
Definition: console.c:3009
#define EXENAME_LENGTH
Definition: console.c:40
static LPCWSTR BaseConInputFileName
Definition: console.c:25
VOID InitExeName(VOID)
Definition: console.c:216
DWORD WINAPI ConsoleControlDispatcher(IN LPVOID lpThreadParameter)
Definition: console.c:89
RTL_CRITICAL_SECTION ConsoleLock
Definition: init.c:24
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleCursorMode(HANDLE hConsole, BOOL Unknown1, BOOL Unknown2)
Definition: console.c:3000
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleOS2OemFormat(BOOL bUnknown)
Definition: console.c:3150
UINT WINAPI DECLSPEC_HOTPATCH GetConsoleOutputCP(VOID)
Definition: console.c:2451
BOOL WINAPI GetConsoleHandleInformation(IN HANDLE hHandle, OUT LPDWORD lpdwFlags)
Definition: console.c:465
BOOL WINAPI DECLSPEC_HOTPATCH ScrollConsoleScreenBufferA(HANDLE hConsoleOutput, CONST SMALL_RECT *lpScrollRectangle, CONST SMALL_RECT *lpClipRectangle, COORD dwDestinationOrigin, CONST CHAR_INFO *lpFill)
Definition: console.c:1929
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleScreenBufferSize(HANDLE hConsoleOutput, COORD dwSize)
Definition: console.c:1855
static BOOL IntRegisterConsoleIME(_In_ HWND hWnd, _In_ DWORD dwThreadId, _In_opt_ SIZE_T cbDesktop, _In_opt_ PWSTR pDesktop, _Out_opt_ PDWORD pdwAttachToThreadId)
Definition: console.c:3034
BOOL WINAPI DECLSPEC_HOTPATCH RegisterConsoleOS2(BOOL bUnknown)
Definition: console.c:3141
VOID SetTEBLangID(VOID)
Internal helper function used to synchronize the current thread's language ID with the one from the c...
Definition: console.c:3171
BOOL WINAPI SetConsoleHardwareState(HANDLE hConsoleOutput, DWORD Flags, DWORD State)
Definition: console.c:944
COORD WINAPI DECLSPEC_HOTPATCH GetLargestConsoleWindowSize(HANDLE hConsoleOutput)
Definition: console.c:1673
BOOL WINAPI DECLSPEC_HOTPATCH VerifyConsoleIoHandle(HANDLE hIoHandle)
Definition: console.c:1110
static BOOLEAN ExeNameInitialized
Definition: console.c:42
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleIcon(HICON hIcon)
Definition: console.c:2756
BOOL WINAPI GetNumberOfConsoleMouseButtons(LPDWORD lpNumberOfMouseButtons)
Definition: console.c:1771
HANDLE WINAPI CreateConsoleScreenBuffer(DWORD dwDesiredAccess, DWORD dwShareMode, CONST SECURITY_ATTRIBUTES *lpSecurityAttributes, DWORD dwFlags, LPVOID lpScreenBufferData)
Definition: console.c:2313
static LPCWSTR BaseConFileName
Definition: console.c:24
BOOL WINAPI GetConsoleMode(HANDLE hConsoleHandle, LPDWORD lpMode)
Definition: console.c:1569
BOOL WINAPI GetCurrentConsoleFont(IN HANDLE hConsoleOutput, IN BOOL bMaximumWindow, OUT PCONSOLE_FONT_INFO lpConsoleCurrentFont)
Definition: console.c:694
static BOOL RemoveConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine)
Definition: console.c:2072
BOOL WINAPI GetConsoleHardwareState(HANDLE hConsoleOutput, PDWORD Flags, PDWORD State)
Definition: console.c:643
BOOL WINAPI SetConsoleMaximumWindowSize(HANDLE hConsoleOutput, COORD dwMaximumSize)
Definition: console.c:996
static BOOL IntAttachConsole(DWORD ProcessId, LPTHREAD_START_ROUTINE CtrlRoutine, LPTHREAD_START_ROUTINE PropRoutine, PCONSOLE_START_INFO ConsoleStartInfo)
Definition: console.c:2603
BOOL WINAPI GetConsoleDisplayMode(LPDWORD lpModeFlags)
Definition: console.c:526
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleTitleA(LPCSTR lpConsoleTitle)
Definition: console.c:2302
BOOL WINAPI DECLSPEC_HOTPATCH SetConsolePalette(HANDLE hConsoleOutput, HPALETTE hPalette, UINT dwUsage)
Definition: console.c:1041
INT WINAPI DECLSPEC_HOTPATCH ShowConsoleCursor(HANDLE hConsoleOutput, BOOL bShow)
Definition: console.c:1073
COORD WINAPI DECLSPEC_HOTPATCH GetConsoleFontSize(IN HANDLE hConsoleOutput, IN DWORD nFont)
Definition: console.c:613
static RTL_CRITICAL_SECTION ExeNameLock
Definition: console.c:41
DWORD WINAPI SetLastConsoleEventActive(VOID)
Definition: console.c:3279
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleCP(UINT wCodePageID)
Definition: console.c:2420
BOOL WINAPI DECLSPEC_HOTPATCH GetConsoleKeyboardLayoutNameW(OUT LPWSTR pszLayoutName)
Definition: console.c:3269
BOOL WINAPI SetConsoleHandleInformation(IN HANDLE hHandle, IN DWORD dwMask, IN DWORD dwFlags)
Definition: console.c:495
USHORT GetCurrentExeName(OUT PWCHAR ExeName, IN USHORT BufferSize)
Definition: console.c:316
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleCursor(HANDLE hConsoleOutput, HCURSOR hCursor)
Definition: console.c:848
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleTitleW(LPCWSTR lpConsoleTitle)
Definition: console.c:2290
static DWORD IntGetConsoleTitle(LPVOID lpConsoleTitle, DWORD dwNumChars, BOOLEAN bUnicode)
Definition: console.c:2163
BOOL WINAPI GetConsoleCharType(HANDLE hConsole, COORD Coord, PDWORD Type)
Definition: console.c:2982
static PHANDLER_ROUTINE InitialHandler[1]
Definition: console.c:29
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleMode(HANDLE hConsoleHandle, DWORD dwMode)
Definition: console.c:1606
BOOL WINAPI SetConsoleDisplayMode(HANDLE hConsoleOutput, DWORD dwFlags, PCOORD lpNewScreenBufferDimensions)
Definition: console.c:877
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine, BOOL Add)
Definition: console.c:2109
static BOOL IntSetConsoleTitle(CONST VOID *lpConsoleTitle, BOOLEAN bUnicode)
Definition: console.c:2243
BOOL WINAPI DECLSPEC_HOTPATCH SetStdHandle(DWORD nStdHandle, HANDLE hHandle)
Definition: console.c:1213
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleActiveScreenBuffer(HANDLE hConsoleOutput)
Definition: console.c:1799
BOOL WINAPI DECLSPEC_HOTPATCH RegisterConsoleIME(_In_ HWND hWnd, _Out_opt_ LPDWORD pdwAttachToThreadId)
Definition: console.c:3127
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleNlsMode(HANDLE hConsole, DWORD dwMode)
Definition: console.c:3018
HANDLE InputWaitHandle
Definition: console.c:38
BOOL WINAPI GetNumberOfConsoleInputEvents(HANDLE hConsoleInput, LPDWORD lpNumberOfEvents)
Definition: console.c:1635
DWORD WINAPI GetConsoleFontInfo(IN HANDLE hConsoleOutput, IN BOOL bMaximumWindow, IN DWORD nFontCount, OUT PCONSOLE_FONT_INFO lpConsoleFontInfo)
Definition: console.c:561
static BOOL WINAPI DefaultConsoleCtrlHandler(DWORD Event)
Definition: console.c:53
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleMenuClose(BOOL bEnable)
Definition: console.c:1011
BOOL WINAPI DECLSPEC_HOTPATCH UnregisterConsoleIME(VOID)
Definition: console.c:3160
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleLocalEUDC(DWORD Unknown1, DWORD Unknown2, DWORD Unknown3, DWORD Unknown4)
Definition: console.c:3027
HANDLE WINAPI GetConsoleInputWaitHandle(VOID)
Definition: console.c:683
static BOOL IntGetConsoleKeyboardLayoutName(OUT PVOID pszLayoutName, IN BOOL bAnsi)
Definition: console.c:3210
BOOL WINAPI GetConsoleCursorInfo(HANDLE hConsoleOutput, PCONSOLE_CURSOR_INFO lpConsoleCursorInfo)
Definition: console.c:1702
UINT WINAPI DECLSPEC_HOTPATCH GetConsoleCP(VOID)
Definition: console.c:2391
static USHORT ExeNameLength
Definition: console.c:44
DWORD WINAPI DECLSPEC_HOTPATCH GetConsoleInputExeNameW(IN DWORD nBufferLength, OUT LPWSTR lpExeName)
Definition: console.c:2905
HWND WINAPI DECLSPEC_HOTPATCH GetConsoleWindow(VOID)
Definition: console.c:2729
DWORD WINAPI DECLSPEC_HOTPATCH GetConsoleTitleW(LPWSTR lpConsoleTitle, DWORD nSize)
Definition: console.c:2222
VOID InitializeCtrlHandling(VOID)
Definition: console.c:204
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleInputExeNameW(IN LPCWSTR lpExeName)
Definition: console.c:2789
HANDLE WINAPI OpenConsoleW(LPCWSTR wsName, DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwShareMode)
Definition: console.c:791
static LPCWSTR BaseConOutputFileName
Definition: console.c:26
static BOOLEAN LastCloseNotify
Definition: console.c:33
DWORD WINAPI GetConsoleProcessList(LPDWORD lpdwProcessList, DWORD dwProcessCount)
Definition: console.c:2513
DWORD WINAPI DECLSPEC_HOTPATCH GetConsoleInputExeNameA(IN DWORD nBufferLength, OUT LPSTR lpExeName)
Definition: console.c:2944
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleInputExeNameA(IN LPCSTR lpExeName)
Definition: console.c:2829
VOID SetUpAppName(IN BOOLEAN CaptureStrings, IN OUT LPDWORD CurDirLength, IN OUT LPWSTR *CurDir, IN OUT LPDWORD AppNameLength, IN OUT LPWSTR *AppName)
Definition: console.c:264
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleFont(IN HANDLE hConsoleOutput, IN DWORD nFont)
Definition: console.c:915
static USHORT StartDirLength
Definition: console.c:46
BOOLEAN ConsoleInitialized
Definition: init.c:25
static BOOL IntAllocConsole(LPWSTR Title, DWORD TitleLength, LPWSTR Desktop, DWORD DesktopLength, LPWSTR CurDir, DWORD CurDirLength, LPWSTR AppName, DWORD AppNameLength, LPTHREAD_START_ROUTINE CtrlRoutine, LPTHREAD_START_ROUTINE PropRoutine, PCONSOLE_START_INFO ConsoleStartInfo)
Definition: console.c:1255
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleKeyShortcuts(DWORD Unknown0, DWORD Unknown1, DWORD Unknown2, DWORD Unknown3)
Definition: console.c:978
BOOL WINAPI DECLSPEC_HOTPATCH GenerateConsoleCtrlEvent(DWORD dwCtrlEvent, DWORD dwProcessGroupId)
Definition: console.c:2132
BOOL WINAPI DECLSPEC_HOTPATCH ScrollConsoleScreenBufferW(HANDLE hConsoleOutput, CONST SMALL_RECT *lpScrollRectangle, CONST SMALL_RECT *lpClipRectangle, COORD dwDestinationOrigin, CONST CHAR_INFO *lpFill)
Definition: console.c:1950
static BOOL IntScrollConsoleScreenBuffer(HANDLE hConsoleOutput, CONST SMALL_RECT *lpScrollRectangle, CONST SMALL_RECT *lpClipRectangle, COORD dwDestinationOrigin, CONST CHAR_INFO *lpFill, BOOL bUnicode)
Definition: console.c:1881
DWORD WINAPI PropDialogHandler(IN LPVOID lpThreadParameter)
Definition: init.c:34
VOID SetUpConsoleInfo(IN BOOLEAN CaptureTitle, IN OUT LPDWORD pTitleLength, IN OUT LPWSTR *lpTitle OPTIONAL, IN OUT LPDWORD pDesktopLength, IN OUT LPWSTR *lpDesktop OPTIONAL, IN OUT PCONSOLE_START_INFO ConsoleStartInfo)
Definition: init.c:134
VOID SetUpHandles(IN PCONSOLE_START_INFO ConsoleStartInfo)
Definition: init.c:250
PPEB Peb
Definition: dllmain.c:27
VOID WINAPI ExitProcess(IN UINT uExitCode)
Definition: proc.c:1487
BOOL WINAPI SetThreadPriority(IN HANDLE hThread, IN int nPriority)
Definition: thread.c:700
VOID WINAPI ExitThread(IN DWORD uExitCode)
Definition: thread.c:365
@ Empty
Definition: npfs.h:125
#define PtrToUlong(u)
Definition: config.h:107
@ Success
Definition: eventcreate.c:712
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2711
DWORD dwThreadId
Definition: fdebug.c:31
#define _SEH2_FINALLY
Definition: filesup.c:21
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
ULONG Handle
Definition: gdb_input.c:15
Status
Definition: gdiplustypes.h:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define NtCurrentTeb
#define STUB
Definition: kernel32.h:27
BOOL WINAPI SetThreadLocale(LCID lcid)
Definition: lang.c:1478
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define ASSERT(a)
Definition: mode.c:44
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static HICON
Definition: imagelist.c:84
static DWORD LPSTR lpExeName
Definition: process.c:72
static BOOL bInheritHandle
Definition: pipe.c:82
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
#define min(a, b)
Definition: monoChain.cc:55
#define _Out_opt_
Definition: ms_sal.h:346
#define _In_
Definition: ms_sal.h:308
#define _In_opt_
Definition: ms_sal.h:309
HICON hIcon
Definition: msconfig.c:44
unsigned int UINT
Definition: ndis.h:50
NTSYSAPI ULONG NTAPI RtlIsDosDeviceName_U(_In_ PCWSTR Name)
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
NTSYSAPI NTSTATUS NTAPI RtlInitializeCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
NTSYSAPI VOID NTAPI RtlRaiseException(_In_ PEXCEPTION_RECORD ExceptionRecord)
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define GENERIC_WRITE
Definition: nt_native.h:90
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
#define UNICODE_NULL
#define SORT_DEFAULT
#define MAKELCID(lgid, srtid)
#define ANSI_NULL
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
@ WaitAny
#define DBG_CONTROL_BREAK
Definition: ntstatus.h:55
#define DBG_CONTROL_C
Definition: ntstatus.h:52
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
NTSTATUS NTAPI NtWaitForMultipleObjects(IN ULONG ObjectCount, IN PHANDLE HandleArray, IN WAIT_TYPE WaitType, IN BOOLEAN Alertable, IN PLARGE_INTEGER TimeOut OPTIONAL)
Definition: obwait.c:46
#define CONST
Definition: pedump.c:81
DWORD * PDWORD
Definition: pedump.c:68
unsigned short USHORT
Definition: pedump.c:61
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:162
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
PCSR_CAPTURE_BUFFER NTAPI CsrAllocateCaptureBuffer(_In_ ULONG ArgumentCount, _In_ ULONG BufferSize)
Definition: capture.c:87
ULONG NTAPI CsrAllocateMessagePointer(_Inout_ PCSR_CAPTURE_BUFFER CaptureBuffer, _In_ ULONG MessageLength, _Out_ PVOID *CapturedData)
Definition: capture.c:152
VOID NTAPI CsrFreeCaptureBuffer(_In_ _Frees_ptr_ PCSR_CAPTURE_BUFFER CaptureBuffer)
Definition: capture.c:210
VOID NTAPI CsrCaptureMessageBuffer(_Inout_ PCSR_CAPTURE_BUFFER CaptureBuffer, _In_opt_ PVOID MessageBuffer, _In_ ULONG MessageLength, _Out_ PVOID *CapturedData)
Definition: capture.c:189
NTSTATUS NTAPI CsrClientCallServer(_Inout_ PCSR_API_MESSAGE ApiMessage, _Inout_opt_ PCSR_CAPTURE_BUFFER CaptureBuffer, _In_ CSR_API_NUMBER ApiNumber, _In_ ULONG DataLength)
Definition: connect.c:366
#define CONSOLE_FILE_NAME
Definition: console.h:18
#define CONSOLE_INPUT_FILE_NAME
Definition: console.h:19
#define CONSOLE_OUTPUT_FILE_NAME
Definition: console.h:20
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define DPRINT
Definition: sndvol32.h:71
DWORD dwOptions
Definition: solitaire.cpp:25
USHORT MaximumLength
Definition: env_spec_w32.h:377
LPTHREAD_START_ROUTINE PropRoutine
Definition: conmsg.h:286
PCONSOLE_START_INFO ConsoleStartInfo
Definition: conmsg.h:274
LPTHREAD_START_ROUTINE CtrlRoutine
Definition: conmsg.h:285
CONSOLE_GETMOUSEINFO GetMouseInfoRequest
Definition: conmsg.h:946
CONSOLE_SETCURSORPOSITION SetCursorPositionRequest
Definition: conmsg.h:945
CONSOLE_OPENCONSOLE OpenConsoleRequest
Definition: conmsg.h:934
CONSOLE_SETTEXTATTRIB SetTextAttribRequest
Definition: conmsg.h:996
CONSOLE_GETSETHWSTATE HardwareStateRequest
Definition: conmsg.h:962
CONSOLE_CLOSEHANDLE CloseHandleRequest
Definition: conmsg.h:935
CONSOLE_GETFONTINFO GetFontInfoRequest
Definition: conmsg.h:966
CONSOLE_ALLOCCONSOLE AllocConsoleRequest
Definition: conmsg.h:924
CONSOLE_SETPALETTE SetPaletteRequest
Definition: conmsg.h:973
CONSOLE_SETDISPLAYMODE SetDisplayModeRequest
Definition: conmsg.h:961
CONSOLE_REGISTERCONSOLEIME RegisterConsoleIME
Definition: conmsg.h:1023
NTSTATUS Status
Definition: conmsg.h:919
CONSOLE_GETNUMINPUTEVENTS GetNumInputEventsRequest
Definition: conmsg.h:987
CONSOLE_GETINPUTOUTPUTCP GetConsoleCPRequest
Definition: conmsg.h:1014
CONSOLE_MENUCONTROL MenuControlRequest
Definition: conmsg.h:976
CONSOLE_GETSETCONSOLEMODE ConsoleModeRequest
Definition: conmsg.h:959
CONSOLE_GETSELECTIONINFO GetSelectionInfoRequest
Definition: conmsg.h:955
CONSOLE_GETNUMFONTS GetNumFontsRequest
Definition: conmsg.h:965
CONSOLE_GETSCREENBUFFERINFO ScreenBufferInfoRequest
Definition: conmsg.h:951
CONSOLE_GETLANGID LangIdRequest
Definition: conmsg.h:1016
CONSOLE_VERIFYHANDLE VerifyHandleRequest
Definition: conmsg.h:936
CONSOLE_SETACTIVESCREENBUFFER SetScreenBufferRequest
Definition: conmsg.h:950
CONSOLE_SETCURSOR SetCursorRequest
Definition: conmsg.h:943
CONSOLE_FLUSHINPUTBUFFER FlushInputBufferRequest
Definition: conmsg.h:956
CONSOLE_DUPLICATEHANDLE DuplicateHandleRequest
Definition: conmsg.h:937
CONSOLE_GETKBDLAYOUTNAME GetKbdLayoutNameRequest
Definition: conmsg.h:1017
CONSOLE_GETPROCESSLIST GetProcessListRequest
Definition: conmsg.h:929
CONSOLE_SETSCREENBUFFERSIZE SetScreenBufferSizeRequest
Definition: conmsg.h:952
CONSOLE_SETMENUCLOSE SetMenuCloseRequest
Definition: conmsg.h:977
CONSOLE_FREECONSOLE FreeConsoleRequest
Definition: conmsg.h:926
CONSOLE_GETWINDOW GetWindowRequest
Definition: conmsg.h:979
CONSOLE_SETHANDLEINFO SetHandleInfoRequest
Definition: conmsg.h:939
CONSOLE_GETSETCONSOLETITLE TitleRequest
Definition: conmsg.h:974
CONSOLE_GETCURRENTFONT GetCurrentFontRequest
Definition: conmsg.h:968
CONSOLE_NOTIFYLASTCLOSE NotifyLastCloseRequest
Definition: conmsg.h:931
CONSOLE_GETDISPLAYMODE GetDisplayModeRequest
Definition: conmsg.h:960
CONSOLE_SCROLLSCREENBUFFER ScrollScreenBufferRequest
Definition: conmsg.h:953
CONSOLE_GETFONTSIZE GetFontSizeRequest
Definition: conmsg.h:967
CONSOLE_ATTACHCONSOLE AttachConsoleRequest
Definition: conmsg.h:925
CONSOLE_CREATESCREENBUFFER CreateScreenBufferRequest
Definition: conmsg.h:949
CONSOLE_UNREGISTERCONSOLEIME UnregisterConsoleIME
Definition: conmsg.h:1024
CONSOLE_GETSETCURSORINFO CursorInfoRequest
Definition: conmsg.h:944
CONSOLE_SETFONT SetFontRequest
Definition: conmsg.h:969
CONSOLE_GETHANDLEINFO GetHandleInfoRequest
Definition: conmsg.h:938
CONSOLE_SETWINDOWINFO SetWindowInfoRequest
Definition: conmsg.h:978
CONSOLE_INVALIDATEDIBITS InvalidateDIBitsRequest
Definition: conmsg.h:972
CONSOLE_GETLARGESTWINDOWSIZE GetLargestWindowSizeRequest
Definition: conmsg.h:975
union _CONSOLE_API_MESSAGE::@3540 Data
CONSOLE_SHOWCURSOR ShowCursorRequest
Definition: conmsg.h:942
CONSOLE_SETINPUTOUTPUTCP SetConsoleCPRequest
Definition: conmsg.h:1015
CONSOLE_SETICON SetIconRequest
Definition: conmsg.h:980
CONSOLE_GENERATECTRLEVENT GenerateCtrlEventRequest
Definition: conmsg.h:930
LPTHREAD_START_ROUTINE CtrlRoutine
Definition: conmsg.h:299
LPTHREAD_START_ROUTINE PropRoutine
Definition: conmsg.h:300
PCONSOLE_START_INFO ConsoleStartInfo
Definition: conmsg.h:297
HANDLE ConsoleHandle
Definition: conmsg.h:626
CONSOLE_GRAPHICS_BUFFER_INFO GraphicsBufferInfo
Definition: conmsg.h:456
HANDLE ConsoleHandle
Definition: conmsg.h:305
HANDLE ConsoleHandle
Definition: conmsg.h:411
BOOLEAN MaximumWindow
Definition: conmsg.h:413
HANDLE OutputHandle
Definition: conmsg.h:412
PCONSOLE_FONT_INFO FontInfo
Definition: conmsg.h:414
HANDLE ConsoleHandle
Definition: conmsg.h:420
HANDLE OutputHandle
Definition: conmsg.h:421
CHAR LayoutBuffer[KL_NAMELENGTH *sizeof(WCHAR)]
Definition: conmsg.h:871
HANDLE ConsoleHandle
Definition: conmsg.h:864
HANDLE ConsoleHandle
Definition: conmsg.h:355
HANDLE ConsoleHandle
Definition: conmsg.h:405
CONSOLE_SELECTION_INFO Info
Definition: conmsg.h:844
CONSOLE_CURSOR_INFO Info
Definition: conmsg.h:346
HANDLE ConsoleHandle
Definition: conmsg.h:716
LPBITMAPINFO lpBitMapInfo
Definition: wincon.h:230
HANDLE ConsoleHandle
Definition: conmsg.h:692
HANDLE OutputHandle
Definition: conmsg.h:693
CONSOLE_HANDLE_TYPE HandleType
Definition: conmsg.h:674
HANDLE ConsoleHandle
Definition: conmsg.h:673
SMALL_RECT ClipRectangle
Definition: conmsg.h:502
SMALL_RECT ScrollRectangle
Definition: conmsg.h:501
HANDLE ConsoleHandle
Definition: conmsg.h:337
HCURSOR CursorHandle
Definition: conmsg.h:339
HANDLE OutputHandle
Definition: conmsg.h:338
HANDLE ConsoleHandle
Definition: conmsg.h:437
HANDLE OutputHandle
Definition: conmsg.h:438
ULONG FontIndex
Definition: conmsg.h:439
HANDLE ConsoleHandle
Definition: conmsg.h:722
HICON IconHandle
Definition: conmsg.h:723
HANDLE ConsoleHandle
Definition: conmsg.h:701
HANDLE OutputHandle
Definition: conmsg.h:478
HANDLE ConsoleHandle
Definition: conmsg.h:477
HPALETTE PaletteHandle
Definition: conmsg.h:479
SMALL_RECT WindowRect
Definition: conmsg.h:710
HANDLE OutputHandle
Definition: conmsg.h:330
HANDLE ConsoleHandle
Definition: conmsg.h:329
HANDLE InputWaitHandle
Definition: conmsg.h:171
HANDLE InitEvents[MAX_INIT_EVENTS]
Definition: conmsg.h:175
HANDLE ConsoleHandle
Definition: conmsg.h:633
Definition: bl.h:1338
ULONG Y
Definition: bl.h:1340
ULONG X
Definition: bl.h:1339
struct _EXCEPTION_RECORD * ExceptionRecord
Definition: compat.h:210
DWORD ExceptionCode
Definition: compat.h:208
DWORD NumberParameters
Definition: compat.h:212
DWORD ExceptionFlags
Definition: compat.h:209
PVOID ExceptionAddress
Definition: compat.h:211
Definition: btrfs_drv.h:1876
UNICODE_STRING BaseDllName
Definition: ldrtypes.h:145
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
LIST_ENTRY InLoadOrderModuleList
Definition: ldrtypes.h:120
PPEB_LDR_DATA Ldr
Definition: btrfs_drv.h:1912
PRTL_USER_PROCESS_PARAMETERS ProcessParameters
Definition: btrfs_drv.h:1913
USHORT MaximumLength
Definition: env_spec_w32.h:370
SHORT Right
Definition: blue.h:34
SHORT Left
Definition: blue.h:32
SHORT Top
Definition: blue.h:33
SHORT Bottom
Definition: blue.h:35
uint16_t * PWSTR
Definition: typedefs.h:56
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t * LPDWORD
Definition: typedefs.h:59
int32_t INT
Definition: typedefs.h:58
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
uint16_t * PWCHAR
Definition: typedefs.h:56
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
char * PCHAR
Definition: typedefs.h:51
#define MAXLONG
Definition: umtypes.h:116
#define MINLONG
Definition: umtypes.h:115
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
#define STD_OUTPUT_HANDLE
Definition: winbase.h:268
#define STD_INPUT_HANDLE
Definition: winbase.h:267
#define CONTROL_C_EXIT
Definition: winbase.h:333
HANDLE WINAPI GetCurrentThread(void)
Definition: proc.c:1148
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
#define STD_ERROR_HANDLE
Definition: winbase.h:269
#define THREAD_PRIORITY_HIGHEST
Definition: winbase.h:277
DWORD(WINAPI * LPTHREAD_START_ROUTINE)(LPVOID)
Definition: winbase.h:729
*nSize LPSTR _Inout_ LPDWORD nSize
Definition: winbase.h:2084
BOOL WINAPI IsDebuggerPresent(void)
Definition: debugger.c:580
_In_ LPCSTR _In_opt_ LPCSTR _In_ DWORD nBufferLength
Definition: winbase.h:3073
#define CTRL_C_EVENT
Definition: wincon.h:68
#define CTRL_SHUTDOWN_EVENT
Definition: wincon.h:73
BOOL(CALLBACK * PHANDLER_ROUTINE)(_In_ DWORD)
Definition: wincon.h:237
#define CTRL_BREAK_EVENT
Definition: wincon.h:69
#define CTRL_LOGOFF_EVENT
Definition: wincon.h:72
#define CONSOLE_TEXTMODE_BUFFER
Definition: wincon.h:62
#define CONSOLE_GRAPHICS_BUFFER
Definition: wincon.h:63
#define CTRL_LAST_CLOSE_EVENT
Definition: wincon.h:71
#define CTRL_CLOSE_EVENT
Definition: wincon.h:70
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
_In_ BOOL bEnable
Definition: winddi.h:3426
HICON HCURSOR
Definition: windef.h:299
BOOL * PBOOL
Definition: windef.h:161
#define WINAPI
Definition: msvc.h:6
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
#define ERROR_FILENAME_EXCED_RANGE
Definition: winerror.h:263
#define ERROR_INVALID_ACCESS
Definition: winerror.h:115
#define KL_NAMELENGTH
Definition: winuser.h:122
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define DUPLICATE_SAME_ACCESS
#define DUPLICATE_CLOSE_SOURCE
const char * LPCSTR
Definition: xmlstorage.h:183
char * LPSTR
Definition: xmlstorage.h:182
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
char CHAR
Definition: xmlstorage.h:175