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
7 * <jimtabor@adsl-64-217-116-74.dsl.hstntx.swbell.net>
10 /* INCLUDES *******************************************************************/
18 /* GLOBALS ********************************************************************/
20 extern RTL_CRITICAL_SECTION ConsoleLock
;
21 extern BOOL ConsoleInitialized
;
22 extern BOOL WINAPI
IsDebuggerPresent(VOID
);
24 /* Console reserved "file" names */
25 static LPCWSTR BaseConFileName
= CONSOLE_FILE_NAME
;
26 static LPCWSTR BaseConInputFileName
= CONSOLE_INPUT_FILE_NAME
;
27 static LPCWSTR BaseConOutputFileName
= CONSOLE_OUTPUT_FILE_NAME
;
29 PHANDLER_ROUTINE InitialHandler
[1];
30 PHANDLER_ROUTINE
* CtrlHandlers
;
32 ULONG NrAllocatedHandlers
;
34 HANDLE InputWaitHandle
= INVALID_HANDLE_VALUE
;
36 #define INPUTEXENAME_BUFLEN 256
37 static WCHAR InputExeName
[INPUTEXENAME_BUFLEN
];
40 /* Default Console Control Handler ********************************************/
44 DefaultConsoleCtrlHandler(DWORD Event
)
46 DPRINT("Default handler called: %lx\n", Event
);
50 DPRINT("Ctrl-C Event\n");
53 case CTRL_BREAK_EVENT
:
54 DPRINT("Ctrl-Break Event\n");
57 case CTRL_CLOSE_EVENT
:
58 DPRINT("Ctrl Close Event\n");
61 case CTRL_LOGOFF_EVENT
:
62 DPRINT("Ctrl Logoff Event\n");
65 case CTRL_SHUTDOWN_EVENT
:
66 DPRINT("Ctrl Shutdown Event\n");
70 ExitProcess(CONTROL_C_EXIT
);
76 ConsoleControlDispatcher(IN LPVOID lpThreadParameter
)
79 DWORD CodeAndFlag
= PtrToUlong(lpThreadParameter
);
80 DWORD nCode
= CodeAndFlag
& MAXLONG
;
82 EXCEPTION_RECORD erException
;
84 DPRINT1("Console Dispatcher Active: %lx %lx\n", CodeAndFlag
, nCode
);
85 SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST
);
90 case CTRL_BREAK_EVENT
:
92 if (IsDebuggerPresent())
94 erException
.ExceptionCode
= (nCode
== CTRL_C_EVENT
?
95 DBG_CONTROL_C
: DBG_CONTROL_BREAK
);
96 erException
.ExceptionFlags
= 0;
97 erException
.ExceptionRecord
= NULL
;
98 erException
.ExceptionAddress
= DefaultConsoleCtrlHandler
;
99 erException
.NumberParameters
= 0;
103 RtlRaiseException(&erException
);
105 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
107 RtlEnterCriticalSection(&ConsoleLock
);
109 if ((nCode
!= CTRL_C_EVENT
) ||
110 (NtCurrentPeb()->ProcessParameters
->ConsoleFlags
!= 1))
112 for (i
= NrCtrlHandlers
; i
> 0; i
--)
114 if (CtrlHandlers
[i
- 1](nCode
)) break;
118 RtlLeaveCriticalSection(&ConsoleLock
);
127 case CTRL_CLOSE_EVENT
:
128 case CTRL_LOGOFF_EVENT
:
129 case CTRL_SHUTDOWN_EVENT
:
137 ExitProcess(CONTROL_C_EXIT
);
145 ASSERT(ConsoleInitialized
);
147 RtlEnterCriticalSection(&ConsoleLock
);
150 if ((nCode
!= CTRL_C_EVENT
) || (NtCurrentPeb()->ProcessParameters
->ConsoleFlags
!= 1))
152 for (i
= NrCtrlHandlers
; i
> 0; i
--)
155 (CodeAndFlag
& MINLONG
) &&
156 ((nCode
== CTRL_LOGOFF_EVENT
) || (nCode
== CTRL_SHUTDOWN_EVENT
)))
158 DPRINT("Skipping system/service apps\n");
162 if (CtrlHandlers
[i
- 1](nCode
))
166 case CTRL_CLOSE_EVENT
:
167 case CTRL_LOGOFF_EVENT
:
168 case CTRL_SHUTDOWN_EVENT
:
170 nExitCode
= CodeAndFlag
;
178 RtlLeaveCriticalSection(&ConsoleLock
);
180 ExitThread(nExitCode
);
181 return STATUS_SUCCESS
;
186 InitConsoleCtrlHandling(VOID
)
188 /* Initialize Console Ctrl Handler */
189 NrAllocatedHandlers
= NrCtrlHandlers
= 1;
190 CtrlHandlers
= InitialHandler
;
191 CtrlHandlers
[0] = DefaultConsoleCtrlHandler
;
195 /* FUNCTIONS ******************************************************************/
198 IntCheckForConsoleFileName(IN LPCWSTR pszName
,
199 IN DWORD dwDesiredAccess
)
201 LPCWSTR ConsoleName
= pszName
;
202 ULONG DeviceNameInfo
;
205 * Check whether we deal with a DOS device, and if so,
206 * strip the path till the file name.
207 * Therefore, things like \\.\CON or C:\some_path\CONIN$
208 * are transformed into CON or CONIN$, for example.
210 DeviceNameInfo
= RtlIsDosDeviceName_U(pszName
);
211 if (DeviceNameInfo
!= 0)
213 ConsoleName
= (LPCWSTR
)((ULONG_PTR
)ConsoleName
+ ((DeviceNameInfo
>> 16) & 0xFFFF));
216 /* Return a standard console "file" name according to what we passed in parameters */
217 if (_wcsicmp(ConsoleName
, BaseConInputFileName
) == 0)
219 return BaseConInputFileName
;
221 else if (_wcsicmp(ConsoleName
, BaseConOutputFileName
) == 0)
223 return BaseConOutputFileName
;
225 else if (_wcsicmp(ConsoleName
, BaseConFileName
) == 0)
227 if ((dwDesiredAccess
& (GENERIC_READ
| GENERIC_WRITE
)) == GENERIC_READ
)
229 return BaseConInputFileName
;
231 else if ((dwDesiredAccess
& (GENERIC_READ
| GENERIC_WRITE
)) == GENERIC_WRITE
)
233 return BaseConOutputFileName
;
237 /* If we are there, that means that either the file name or the desired access are wrong */
243 * @implemented (Undocumented)
244 * @note See http://undoc.airesoft.co.uk/kernel32.dll/ConsoleMenuControl.php
248 ConsoleMenuControl(HANDLE hConsoleOutput
,
252 CONSOLE_API_MESSAGE ApiMessage
;
253 PCONSOLE_MENUCONTROL MenuControlRequest
= &ApiMessage
.Data
.MenuControlRequest
;
255 MenuControlRequest
->OutputHandle
= hConsoleOutput
;
256 MenuControlRequest
->dwCmdIdLow
= dwCmdIdLow
;
257 MenuControlRequest
->dwCmdIdHigh
= dwCmdIdHigh
;
258 MenuControlRequest
->hMenu
= NULL
;
260 CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
262 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepMenuControl
),
263 sizeof(CONSOLE_MENUCONTROL
));
265 return MenuControlRequest
->hMenu
;
274 DuplicateConsoleHandle(HANDLE hConsole
,
275 DWORD dwDesiredAccess
,
280 CONSOLE_API_MESSAGE ApiMessage
;
281 PCONSOLE_DUPLICATEHANDLE DuplicateHandleRequest
= &ApiMessage
.Data
.DuplicateHandleRequest
;
283 if ( (dwOptions
& ~(DUPLICATE_CLOSE_SOURCE
| DUPLICATE_SAME_ACCESS
)) ||
284 (!(dwOptions
& DUPLICATE_SAME_ACCESS
) &&
285 (dwDesiredAccess
& ~(GENERIC_READ
| GENERIC_WRITE
))) )
287 SetLastError (ERROR_INVALID_PARAMETER
);
288 return INVALID_HANDLE_VALUE
;
291 DuplicateHandleRequest
->ConsoleHandle
= hConsole
;
292 DuplicateHandleRequest
->Access
= dwDesiredAccess
;
293 DuplicateHandleRequest
->Inheritable
= bInheritHandle
;
294 DuplicateHandleRequest
->Options
= dwOptions
;
296 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
298 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepDuplicateHandle
),
299 sizeof(CONSOLE_DUPLICATEHANDLE
));
300 if (!NT_SUCCESS(Status
))
302 BaseSetLastNTError(Status
);
303 return INVALID_HANDLE_VALUE
;
306 return DuplicateHandleRequest
->ConsoleHandle
;
315 GetConsoleDisplayMode(LPDWORD lpModeFlags
)
318 CONSOLE_API_MESSAGE ApiMessage
;
319 PCONSOLE_GETDISPLAYMODE GetDisplayModeRequest
= &ApiMessage
.Data
.GetDisplayModeRequest
;
321 if (lpModeFlags
== NULL
)
323 SetLastError(ERROR_INVALID_PARAMETER
);
327 // GetDisplayModeRequest->OutputHandle = hConsoleOutput;
329 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
331 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetDisplayMode
),
332 sizeof(CONSOLE_GETDISPLAYMODE
));
333 if (!NT_SUCCESS(Status
))
335 BaseSetLastNTError(Status
);
339 *lpModeFlags
= GetDisplayModeRequest
->DisplayMode
;
345 * @unimplemented (Undocumented)
349 GetConsoleFontInfo(HANDLE hConsoleOutput
,
352 PCONSOLE_FONT_INFO lpConsoleFontInfo
)
354 DPRINT1("GetConsoleFontInfo(0x%p, %d, %lu, 0x%p) UNIMPLEMENTED!\n", hConsoleOutput
, bMaximumWindow
, nFontCount
, lpConsoleFontInfo
);
355 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
365 GetConsoleFontSize(HANDLE hConsoleOutput
,
368 COORD Empty
= {0, 0};
369 DPRINT1("GetConsoleFontSize(0x%p, 0x%x) UNIMPLEMENTED!\n", hConsoleOutput
, nFont
);
370 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
376 * @implemented (Undocumented)
380 GetConsoleHardwareState(HANDLE hConsoleOutput
,
385 CONSOLE_API_MESSAGE ApiMessage
;
386 PCONSOLE_GETSETHWSTATE HardwareStateRequest
= &ApiMessage
.Data
.HardwareStateRequest
;
388 DPRINT1("GetConsoleHardwareState(%lu, 0x%p) UNIMPLEMENTED!\n", Flags
, State
);
392 SetLastError(ERROR_INVALID_PARAMETER
);
396 HardwareStateRequest
->OutputHandle
= hConsoleOutput
;
398 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
400 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetHardwareState
),
401 sizeof(CONSOLE_GETSETHWSTATE
));
402 if (!NT_SUCCESS(Status
))
404 BaseSetLastNTError(Status
);
408 *State
= HardwareStateRequest
->State
;
414 * @implemented (Undocumented)
418 GetConsoleInputWaitHandle(VOID
)
420 return InputWaitHandle
;
429 GetCurrentConsoleFont(HANDLE hConsoleOutput
,
431 PCONSOLE_FONT_INFO lpConsoleCurrentFont
)
433 DPRINT1("GetCurrentConsoleFont(0x%p, 0x%x, 0x%p) UNIMPLEMENTED!\n", hConsoleOutput
, bMaximumWindow
, lpConsoleCurrentFont
);
434 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
440 * @unimplemented (Undocumented)
444 GetNumberOfConsoleFonts(VOID
)
446 DPRINT1("GetNumberOfConsoleFonts() UNIMPLEMENTED!\n");
447 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
453 * @implemented (Undocumented)
454 * @note See http://blog.airesoft.co.uk/2012/10/things-ms-can-do-that-they-dont-tell-you-about-console-graphics/
458 InvalidateConsoleDIBits(IN HANDLE hConsoleOutput
,
459 IN PSMALL_RECT lpRect
)
462 CONSOLE_API_MESSAGE ApiMessage
;
463 PCONSOLE_INVALIDATEDIBITS InvalidateDIBitsRequest
= &ApiMessage
.Data
.InvalidateDIBitsRequest
;
467 SetLastError(ERROR_INVALID_PARAMETER
);
471 InvalidateDIBitsRequest
->OutputHandle
= hConsoleOutput
;
472 InvalidateDIBitsRequest
->Region
= *lpRect
;
474 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
476 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepInvalidateBitMapRect
),
477 sizeof(CONSOLE_INVALIDATEDIBITS
));
478 if (!NT_SUCCESS(Status
))
480 BaseSetLastNTError(Status
);
489 * @unimplemented (Undocumented)
493 OpenConsoleW(LPCWSTR wsName
,
494 DWORD dwDesiredAccess
,
498 NTSTATUS Status
= STATUS_SUCCESS
;
499 CONSOLE_API_MESSAGE ApiMessage
;
500 PCONSOLE_OPENCONSOLE OpenConsoleRequest
= &ApiMessage
.Data
.OpenConsoleRequest
;
501 CONSOLE_HANDLE_TYPE HandleType
;
503 if (wsName
&& 0 == _wcsicmp(wsName
, BaseConInputFileName
))
505 HandleType
= HANDLE_INPUT
;
507 else if (wsName
&& 0 == _wcsicmp(wsName
, BaseConOutputFileName
))
509 HandleType
= HANDLE_OUTPUT
;
513 SetLastError(ERROR_INVALID_PARAMETER
);
514 return INVALID_HANDLE_VALUE
;
517 if ( (dwDesiredAccess
& ~(GENERIC_READ
| GENERIC_WRITE
)) ||
518 (dwShareMode
& ~(FILE_SHARE_READ
| FILE_SHARE_WRITE
)) )
520 SetLastError(ERROR_INVALID_PARAMETER
);
521 return INVALID_HANDLE_VALUE
;
524 OpenConsoleRequest
->HandleType
= HandleType
;
525 OpenConsoleRequest
->Access
= dwDesiredAccess
;
526 OpenConsoleRequest
->Inheritable
= bInheritHandle
;
527 OpenConsoleRequest
->ShareMode
= dwShareMode
;
529 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
531 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepOpenConsole
),
532 sizeof(CONSOLE_OPENCONSOLE
));
533 if (!NT_SUCCESS(Status
))
535 BaseSetLastNTError(Status
);
536 return INVALID_HANDLE_VALUE
;
539 return OpenConsoleRequest
->ConsoleHandle
;
544 * @implemented (Undocumented)
545 * @note See http://undoc.airesoft.co.uk/kernel32.dll/SetConsoleCursor.php
549 SetConsoleCursor(HANDLE hConsoleOutput
,
553 CONSOLE_API_MESSAGE ApiMessage
;
554 PCONSOLE_SETCURSOR SetCursorRequest
= &ApiMessage
.Data
.SetCursorRequest
;
556 SetCursorRequest
->OutputHandle
= hConsoleOutput
;
557 SetCursorRequest
->hCursor
= hCursor
;
559 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
561 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetCursor
),
562 sizeof(CONSOLE_SETCURSOR
));
563 if (!NT_SUCCESS(Status
))
565 BaseSetLastNTError(Status
);
578 SetConsoleDisplayMode(HANDLE hConsoleOutput
,
580 PCOORD lpNewScreenBufferDimensions
)
583 CONSOLE_API_MESSAGE ApiMessage
;
584 PCONSOLE_SETDISPLAYMODE SetDisplayModeRequest
= &ApiMessage
.Data
.SetDisplayModeRequest
;
586 SetDisplayModeRequest
->OutputHandle
= hConsoleOutput
;
587 SetDisplayModeRequest
->DisplayMode
= dwFlags
;
588 SetDisplayModeRequest
->NewSBDim
.X
= 0;
589 SetDisplayModeRequest
->NewSBDim
.Y
= 0;
591 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
593 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetDisplayMode
),
594 sizeof(CONSOLE_SETDISPLAYMODE
));
595 if (!NT_SUCCESS(Status
))
597 BaseSetLastNTError(Status
);
601 if (lpNewScreenBufferDimensions
)
602 *lpNewScreenBufferDimensions
= SetDisplayModeRequest
->NewSBDim
;
609 * @unimplemented (Undocumented)
613 SetConsoleFont(HANDLE hConsoleOutput
,
616 DPRINT1("SetConsoleFont(0x%p, %lu) UNIMPLEMENTED!\n", hConsoleOutput
, nFont
);
617 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
623 * @implemented (Undocumented)
627 SetConsoleHardwareState(HANDLE hConsoleOutput
,
632 CONSOLE_API_MESSAGE ApiMessage
;
633 PCONSOLE_GETSETHWSTATE HardwareStateRequest
= &ApiMessage
.Data
.HardwareStateRequest
;
635 DPRINT1("SetConsoleHardwareState(%lu, %lu) UNIMPLEMENTED!\n", Flags
, State
);
637 HardwareStateRequest
->OutputHandle
= hConsoleOutput
;
638 HardwareStateRequest
->State
= State
;
640 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
642 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetHardwareState
),
643 sizeof(CONSOLE_GETSETHWSTATE
));
644 if (!NT_SUCCESS(Status
))
646 BaseSetLastNTError(Status
);
655 * @unimplemented (Undocumented)
659 SetConsoleKeyShortcuts(DWORD Unknown0
,
664 DPRINT1("SetConsoleKeyShortcuts(0x%x, 0x%x, 0x%x, 0x%x) UNIMPLEMENTED!\n", Unknown0
, Unknown1
, Unknown2
, Unknown3
);
665 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
671 * @implemented (Undocumented)
672 * @note See http://undoc.airesoft.co.uk/kernel32.dll/SetConsoleMaximumWindowSize.php
673 * Does nothing, returns TRUE only. Checked on Windows Server 2003.
677 SetConsoleMaximumWindowSize(HANDLE hConsoleOutput
,
680 DPRINT1("SetConsoleMaximumWindowSize(0x%p, {%d, %d}) does nothing\n",
681 hConsoleOutput
, dwMaximumSize
.X
, dwMaximumSize
.Y
);
687 * @implemented (Undocumented)
691 SetConsoleMenuClose(BOOL bEnable
)
694 CONSOLE_API_MESSAGE ApiMessage
;
695 PCONSOLE_SETMENUCLOSE SetMenuCloseRequest
= &ApiMessage
.Data
.SetMenuCloseRequest
;
697 SetMenuCloseRequest
->Enable
= bEnable
;
699 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
701 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetMenuClose
),
702 sizeof(CONSOLE_SETMENUCLOSE
));
703 if (!NT_SUCCESS(Status
))
705 BaseSetLastNTError(Status
);
714 * @implemented (Undocumented)
715 * @note See http://comments.gmane.org/gmane.comp.lang.harbour.devel/27844
716 * Usage example: https://github.com/harbour/core/commit/d79a1b7b812cbde6ddf718ebfd6939a24f633e52
720 SetConsolePalette(HANDLE hConsoleOutput
,
725 CONSOLE_API_MESSAGE ApiMessage
;
726 PCONSOLE_SETPALETTE SetPaletteRequest
= &ApiMessage
.Data
.SetPaletteRequest
;
728 SetPaletteRequest
->OutputHandle
= hConsoleOutput
;
729 SetPaletteRequest
->PaletteHandle
= hPalette
;
730 SetPaletteRequest
->Usage
= dwUsage
;
732 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
734 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetPalette
),
735 sizeof(CONSOLE_SETPALETTE
));
736 if (!NT_SUCCESS(Status
))
738 BaseSetLastNTError(Status
);
746 * @implemented (Undocumented)
747 * @note See http://undoc.airesoft.co.uk/kernel32.dll/ShowConsoleCursor.php
751 ShowConsoleCursor(HANDLE hConsoleOutput
,
754 CONSOLE_API_MESSAGE ApiMessage
;
755 PCONSOLE_SHOWCURSOR ShowCursorRequest
= &ApiMessage
.Data
.ShowCursorRequest
;
757 ShowCursorRequest
->OutputHandle
= hConsoleOutput
;
758 ShowCursorRequest
->Show
= bShow
;
759 ShowCursorRequest
->RefCount
= 0;
761 CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
763 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepShowCursor
),
764 sizeof(CONSOLE_SHOWCURSOR
));
766 return ShowCursorRequest
->RefCount
;
771 * FUNCTION: Checks whether the given handle is a valid console handle.
774 * Handle - Handle to be checked
777 * TRUE: Handle is a valid console handle
778 * FALSE: Handle is not a valid console handle.
780 * STATUS: Officially undocumented
786 VerifyConsoleIoHandle(HANDLE Handle
)
789 CONSOLE_API_MESSAGE ApiMessage
;
791 ApiMessage
.Data
.VerifyHandleRequest
.ConsoleHandle
= Handle
;
793 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
795 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepVerifyIoHandle
),
796 sizeof(CONSOLE_VERIFYHANDLE
));
797 if (!NT_SUCCESS(Status
))
799 BaseSetLastNTError(Status
);
808 * @implemented (Undocumented)
812 CloseConsoleHandle(HANDLE Handle
)
815 CONSOLE_API_MESSAGE ApiMessage
;
817 ApiMessage
.Data
.CloseHandleRequest
.ConsoleHandle
= Handle
;
819 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
821 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepCloseHandle
),
822 sizeof(CONSOLE_CLOSEHANDLE
));
823 if (!NT_SUCCESS(Status
))
825 BaseSetLastNTError(Status
);
838 GetStdHandle(DWORD nStdHandle
)
840 * FUNCTION: Get a handle for the standard input, standard output
841 * and a standard error device.
844 * nStdHandle - Specifies the device for which to return the handle.
846 * RETURNS: If the function succeeds, the return value is the handle
847 * of the specified device. Otherwise the value is INVALID_HANDLE_VALUE.
850 PRTL_USER_PROCESS_PARAMETERS Ppb
= NtCurrentPeb()->ProcessParameters
;
854 case STD_INPUT_HANDLE
:
855 return Ppb
->StandardInput
;
857 case STD_OUTPUT_HANDLE
:
858 return Ppb
->StandardOutput
;
860 case STD_ERROR_HANDLE
:
861 return Ppb
->StandardError
;
864 SetLastError(ERROR_INVALID_HANDLE
);
865 return INVALID_HANDLE_VALUE
;
874 SetStdHandle(DWORD nStdHandle
,
877 * FUNCTION: Set the handle for the standard input, standard output or
878 * the standard error device.
881 * nStdHandle - Specifies the handle to be set.
882 * hHandle - The handle to set.
884 * RETURNS: TRUE if the function succeeds, FALSE otherwise.
887 PRTL_USER_PROCESS_PARAMETERS Ppb
= NtCurrentPeb()->ProcessParameters
;
889 /* no need to check if hHandle == INVALID_HANDLE_VALUE */
893 case STD_INPUT_HANDLE
:
894 Ppb
->StandardInput
= hHandle
;
897 case STD_OUTPUT_HANDLE
:
898 Ppb
->StandardOutput
= hHandle
;
901 case STD_ERROR_HANDLE
:
902 Ppb
->StandardError
= hHandle
;
906 /* Windows for whatever reason sets the last error to ERROR_INVALID_HANDLE here */
907 SetLastError(ERROR_INVALID_HANDLE
);
912 /*--------------------------------------------------------------
922 PRTL_USER_PROCESS_PARAMETERS Parameters
= NtCurrentPeb()->ProcessParameters
;
923 CONSOLE_API_MESSAGE ApiMessage
;
924 PCONSOLE_ALLOCCONSOLE AllocConsoleRequest
= &ApiMessage
.Data
.AllocConsoleRequest
;
925 PCSR_CAPTURE_BUFFER CaptureBuffer
;
927 if (Parameters
->ConsoleHandle
)
929 DPRINT1("AllocConsole: Allocating a console to a process already having one\n");
930 SetLastError(ERROR_ACCESS_DENIED
);
934 CaptureBuffer
= CsrAllocateCaptureBuffer(1, sizeof(CONSOLE_START_INFO
));
935 if (CaptureBuffer
== NULL
)
937 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
938 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
942 CsrAllocateMessagePointer(CaptureBuffer
,
943 sizeof(CONSOLE_START_INFO
),
944 (PVOID
*)&AllocConsoleRequest
->ConsoleStartInfo
);
946 InitConsoleInfo(AllocConsoleRequest
->ConsoleStartInfo
,
947 &Parameters
->ImagePathName
);
949 AllocConsoleRequest
->ConsoleHandle
= NULL
;
950 AllocConsoleRequest
->CtrlDispatcher
= ConsoleControlDispatcher
;
951 AllocConsoleRequest
->PropDispatcher
= PropDialogHandler
;
953 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
955 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepAlloc
),
956 sizeof(CONSOLE_ALLOCCONSOLE
));
958 CsrFreeCaptureBuffer(CaptureBuffer
);
960 if (!NT_SUCCESS(Status
))
962 BaseSetLastNTError(Status
);
966 Parameters
->ConsoleHandle
= AllocConsoleRequest
->ConsoleHandle
;
967 SetStdHandle(STD_INPUT_HANDLE
, AllocConsoleRequest
->InputHandle
);
968 SetStdHandle(STD_OUTPUT_HANDLE
, AllocConsoleRequest
->OutputHandle
);
969 SetStdHandle(STD_ERROR_HANDLE
, AllocConsoleRequest
->ErrorHandle
);
971 /* Initialize Console Ctrl Handler */
972 InitConsoleCtrlHandling();
974 InputWaitHandle
= AllocConsoleRequest
->InputWaitHandle
;
980 /*--------------------------------------------------------------
989 // AG: I'm not sure if this is correct (what happens to std handles?)
990 // but I just tried to reverse what AllocConsole() does...
993 CONSOLE_API_MESSAGE ApiMessage
;
995 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
997 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepFree
),
998 sizeof(CONSOLE_FREECONSOLE
));
999 if (!NT_SUCCESS(Status
))
1001 BaseSetLastNTError(Status
);
1005 NtCurrentPeb()->ProcessParameters
->ConsoleHandle
= NULL
;
1007 CloseHandle(InputWaitHandle
);
1008 InputWaitHandle
= INVALID_HANDLE_VALUE
;
1014 /*--------------------------------------------------------------
1015 * GetConsoleScreenBufferInfo
1021 GetConsoleScreenBufferInfo(HANDLE hConsoleOutput
,
1022 PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo
)
1025 CONSOLE_API_MESSAGE ApiMessage
;
1027 if (lpConsoleScreenBufferInfo
== NULL
)
1029 SetLastError(ERROR_INVALID_PARAMETER
);
1033 ApiMessage
.Data
.ScreenBufferInfoRequest
.OutputHandle
= hConsoleOutput
;
1035 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1037 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetScreenBufferInfo
),
1038 sizeof(CONSOLE_GETSCREENBUFFERINFO
));
1039 if (!NT_SUCCESS(Status
))
1041 BaseSetLastNTError(Status
);
1045 *lpConsoleScreenBufferInfo
= ApiMessage
.Data
.ScreenBufferInfoRequest
.Info
;
1051 /*--------------------------------------------------------------
1052 * SetConsoleCursorPosition
1058 SetConsoleCursorPosition(HANDLE hConsoleOutput
,
1059 COORD dwCursorPosition
)
1062 CONSOLE_API_MESSAGE ApiMessage
;
1064 ApiMessage
.Data
.SetCursorPositionRequest
.OutputHandle
= hConsoleOutput
;
1065 ApiMessage
.Data
.SetCursorPositionRequest
.Position
= dwCursorPosition
;
1067 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1069 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetCursorPosition
),
1070 sizeof(CONSOLE_SETCURSORPOSITION
));
1071 if (!NT_SUCCESS(Status
))
1073 BaseSetLastNTError(Status
);
1081 /*--------------------------------------------------------------
1088 GetConsoleMode(HANDLE hConsoleHandle
,
1092 CONSOLE_API_MESSAGE ApiMessage
;
1093 PCONSOLE_GETSETCONSOLEMODE ConsoleModeRequest
= &ApiMessage
.Data
.ConsoleModeRequest
;
1097 SetLastError(ERROR_INVALID_PARAMETER
);
1101 ConsoleModeRequest
->ConsoleHandle
= hConsoleHandle
;
1103 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1105 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetMode
),
1106 sizeof(CONSOLE_GETSETCONSOLEMODE
));
1107 if (!NT_SUCCESS(Status
))
1109 BaseSetLastNTError(Status
);
1113 *lpMode
= ConsoleModeRequest
->ConsoleMode
;
1119 /*--------------------------------------------------------------
1120 * GetNumberOfConsoleInputEvents
1126 GetNumberOfConsoleInputEvents(HANDLE hConsoleInput
,
1127 LPDWORD lpNumberOfEvents
)
1130 CONSOLE_API_MESSAGE ApiMessage
;
1131 PCONSOLE_GETNUMINPUTEVENTS GetNumInputEventsRequest
= &ApiMessage
.Data
.GetNumInputEventsRequest
;
1133 GetNumInputEventsRequest
->InputHandle
= hConsoleInput
;
1134 GetNumInputEventsRequest
->NumInputEvents
= 0;
1136 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1138 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetNumberOfInputEvents
),
1139 sizeof(CONSOLE_GETNUMINPUTEVENTS
));
1140 if (!NT_SUCCESS(Status
))
1142 BaseSetLastNTError(Status
);
1146 if (lpNumberOfEvents
== NULL
)
1148 SetLastError(ERROR_INVALID_ACCESS
);
1152 *lpNumberOfEvents
= GetNumInputEventsRequest
->NumInputEvents
;
1158 /*--------------------------------------------------------------
1159 * GetLargestConsoleWindowSize
1165 GetLargestConsoleWindowSize(HANDLE hConsoleOutput
)
1168 CONSOLE_API_MESSAGE ApiMessage
;
1169 PCONSOLE_GETLARGESTWINDOWSIZE GetLargestWindowSizeRequest
= &ApiMessage
.Data
.GetLargestWindowSizeRequest
;
1171 GetLargestWindowSizeRequest
->OutputHandle
= hConsoleOutput
;
1172 GetLargestWindowSizeRequest
->Size
.X
= 0;
1173 GetLargestWindowSizeRequest
->Size
.Y
= 0;
1175 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1177 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetLargestWindowSize
),
1178 sizeof(CONSOLE_GETLARGESTWINDOWSIZE
));
1179 if (!NT_SUCCESS(Status
))
1181 BaseSetLastNTError(Status
);
1184 DPRINT1("GetLargestConsoleWindowSize, X = %d, Y = %d\n", GetLargestWindowSizeRequest
->Size
.X
, GetLargestWindowSizeRequest
->Size
.Y
);
1185 return GetLargestWindowSizeRequest
->Size
;
1189 /*--------------------------------------------------------------
1190 * GetConsoleCursorInfo
1196 GetConsoleCursorInfo(HANDLE hConsoleOutput
,
1197 PCONSOLE_CURSOR_INFO lpConsoleCursorInfo
)
1200 CONSOLE_API_MESSAGE ApiMessage
;
1202 if (!lpConsoleCursorInfo
)
1204 if (!hConsoleOutput
)
1205 SetLastError(ERROR_INVALID_HANDLE
);
1207 SetLastError(ERROR_INVALID_ACCESS
);
1212 ApiMessage
.Data
.CursorInfoRequest
.OutputHandle
= hConsoleOutput
;
1214 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1216 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetCursorInfo
),
1217 sizeof(CONSOLE_GETSETCURSORINFO
));
1218 if (!NT_SUCCESS(Status
))
1220 BaseSetLastNTError(Status
);
1224 *lpConsoleCursorInfo
= ApiMessage
.Data
.CursorInfoRequest
.Info
;
1230 /*--------------------------------------------------------------
1231 * GetNumberOfConsoleMouseButtons
1237 GetNumberOfConsoleMouseButtons(LPDWORD lpNumberOfMouseButtons
)
1239 DPRINT1("GetNumberOfConsoleMouseButtons(0x%p) UNIMPLEMENTED!\n", lpNumberOfMouseButtons
);
1240 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1245 /*--------------------------------------------------------------
1252 SetConsoleMode(HANDLE hConsoleHandle
,
1256 CONSOLE_API_MESSAGE ApiMessage
;
1257 PCONSOLE_GETSETCONSOLEMODE ConsoleModeRequest
= &ApiMessage
.Data
.ConsoleModeRequest
;
1259 ConsoleModeRequest
->ConsoleHandle
= hConsoleHandle
;
1260 ConsoleModeRequest
->ConsoleMode
= dwMode
;
1262 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1264 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetMode
),
1265 sizeof(CONSOLE_GETSETCONSOLEMODE
));
1266 if (!NT_SUCCESS(Status
))
1268 BaseSetLastNTError(Status
);
1276 /*--------------------------------------------------------------
1277 * SetConsoleActiveScreenBuffer
1283 SetConsoleActiveScreenBuffer(HANDLE hConsoleOutput
)
1286 CONSOLE_API_MESSAGE ApiMessage
;
1288 ApiMessage
.Data
.SetScreenBufferRequest
.OutputHandle
= hConsoleOutput
;
1290 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1292 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetActiveScreenBuffer
),
1293 sizeof(CONSOLE_SETACTIVESCREENBUFFER
));
1294 if (!NT_SUCCESS(Status
))
1296 BaseSetLastNTError(Status
);
1304 /*--------------------------------------------------------------
1305 * FlushConsoleInputBuffer
1311 FlushConsoleInputBuffer(HANDLE hConsoleInput
)
1314 CONSOLE_API_MESSAGE ApiMessage
;
1316 ApiMessage
.Data
.FlushInputBufferRequest
.InputHandle
= hConsoleInput
;
1318 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1320 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepFlushInputBuffer
),
1321 sizeof(CONSOLE_FLUSHINPUTBUFFER
));
1322 if (!NT_SUCCESS(Status
))
1324 BaseSetLastNTError(Status
);
1332 /*--------------------------------------------------------------
1333 * SetConsoleScreenBufferSize
1339 SetConsoleScreenBufferSize(HANDLE hConsoleOutput
,
1343 CONSOLE_API_MESSAGE ApiMessage
;
1345 ApiMessage
.Data
.SetScreenBufferSizeRequest
.OutputHandle
= hConsoleOutput
;
1346 ApiMessage
.Data
.SetScreenBufferSizeRequest
.Size
= dwSize
;
1348 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1350 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetScreenBufferSize
),
1351 sizeof(CONSOLE_SETSCREENBUFFERSIZE
));
1352 if (!NT_SUCCESS(Status
))
1354 BaseSetLastNTError(Status
);
1362 /*--------------------------------------------------------------
1363 * SetConsoleCursorInfo
1369 SetConsoleCursorInfo(HANDLE hConsoleOutput
,
1370 CONST CONSOLE_CURSOR_INFO
*lpConsoleCursorInfo
)
1373 CONSOLE_API_MESSAGE ApiMessage
;
1375 ApiMessage
.Data
.CursorInfoRequest
.OutputHandle
= hConsoleOutput
;
1376 ApiMessage
.Data
.CursorInfoRequest
.Info
= *lpConsoleCursorInfo
;
1378 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1380 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetCursorInfo
),
1381 sizeof(CONSOLE_GETSETCURSORINFO
));
1382 if (!NT_SUCCESS(Status
))
1384 BaseSetLastNTError(Status
);
1394 IntScrollConsoleScreenBuffer(HANDLE hConsoleOutput
,
1395 const SMALL_RECT
*lpScrollRectangle
,
1396 const SMALL_RECT
*lpClipRectangle
,
1397 COORD dwDestinationOrigin
,
1398 const CHAR_INFO
*lpFill
,
1402 CONSOLE_API_MESSAGE ApiMessage
;
1403 PCONSOLE_SCROLLSCREENBUFFER ScrollScreenBufferRequest
= &ApiMessage
.Data
.ScrollScreenBufferRequest
;
1405 ScrollScreenBufferRequest
->OutputHandle
= hConsoleOutput
;
1406 ScrollScreenBufferRequest
->Unicode
= bUnicode
;
1407 ScrollScreenBufferRequest
->ScrollRectangle
= *lpScrollRectangle
;
1409 if (lpClipRectangle
!= NULL
)
1411 ScrollScreenBufferRequest
->UseClipRectangle
= TRUE
;
1412 ScrollScreenBufferRequest
->ClipRectangle
= *lpClipRectangle
;
1416 ScrollScreenBufferRequest
->UseClipRectangle
= FALSE
;
1419 ScrollScreenBufferRequest
->DestinationOrigin
= dwDestinationOrigin
;
1420 ScrollScreenBufferRequest
->Fill
= *lpFill
;
1422 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1424 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepScrollScreenBuffer
),
1425 sizeof(CONSOLE_SCROLLSCREENBUFFER
));
1427 if (!NT_SUCCESS(Status
))
1429 BaseSetLastNTError(Status
);
1437 /*--------------------------------------------------------------
1438 * ScrollConsoleScreenBufferA
1444 ScrollConsoleScreenBufferA(HANDLE hConsoleOutput
,
1445 CONST SMALL_RECT
*lpScrollRectangle
,
1446 CONST SMALL_RECT
*lpClipRectangle
,
1447 COORD dwDestinationOrigin
,
1448 CONST CHAR_INFO
*lpFill
)
1450 return IntScrollConsoleScreenBuffer(hConsoleOutput
,
1451 (PSMALL_RECT
)lpScrollRectangle
,
1452 (PSMALL_RECT
)lpClipRectangle
,
1453 dwDestinationOrigin
,
1459 /*--------------------------------------------------------------
1460 * ScrollConsoleScreenBufferW
1466 ScrollConsoleScreenBufferW(HANDLE hConsoleOutput
,
1467 CONST SMALL_RECT
*lpScrollRectangle
,
1468 CONST SMALL_RECT
*lpClipRectangle
,
1469 COORD dwDestinationOrigin
,
1470 CONST CHAR_INFO
*lpFill
)
1472 return IntScrollConsoleScreenBuffer(hConsoleOutput
,
1475 dwDestinationOrigin
,
1481 /*--------------------------------------------------------------
1482 * SetConsoleWindowInfo
1488 SetConsoleWindowInfo(HANDLE hConsoleOutput
,
1490 CONST SMALL_RECT
*lpConsoleWindow
)
1493 CONSOLE_API_MESSAGE ApiMessage
;
1494 PCONSOLE_SETWINDOWINFO SetWindowInfoRequest
= &ApiMessage
.Data
.SetWindowInfoRequest
;
1496 if (lpConsoleWindow
== NULL
)
1498 SetLastError(ERROR_INVALID_PARAMETER
);
1502 SetWindowInfoRequest
->OutputHandle
= hConsoleOutput
;
1503 SetWindowInfoRequest
->Absolute
= bAbsolute
;
1504 SetWindowInfoRequest
->WindowRect
= *lpConsoleWindow
;
1506 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1508 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetWindowInfo
),
1509 sizeof(CONSOLE_SETWINDOWINFO
));
1510 if (!NT_SUCCESS(Status
))
1512 BaseSetLastNTError(Status
);
1520 /*--------------------------------------------------------------
1521 * SetConsoleTextAttribute
1527 SetConsoleTextAttribute(HANDLE hConsoleOutput
,
1531 CONSOLE_API_MESSAGE ApiMessage
;
1533 ApiMessage
.Data
.SetTextAttribRequest
.OutputHandle
= hConsoleOutput
;
1534 ApiMessage
.Data
.SetTextAttribRequest
.Attrib
= wAttributes
;
1536 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1538 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetTextAttribute
),
1539 sizeof(CONSOLE_SETTEXTATTRIB
));
1540 if (!NT_SUCCESS(Status
))
1542 BaseSetLastNTError(Status
);
1552 AddConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine
)
1554 PHANDLER_ROUTINE
* NewCtrlHandlers
= NULL
;
1556 if (HandlerRoutine
== NULL
)
1558 NtCurrentPeb()->ProcessParameters
->ConsoleFlags
= TRUE
;
1562 if (NrCtrlHandlers
== NrAllocatedHandlers
)
1564 NewCtrlHandlers
= RtlAllocateHeap(RtlGetProcessHeap(),
1566 (NrCtrlHandlers
+ 4) * sizeof(PHANDLER_ROUTINE
));
1567 if (NewCtrlHandlers
== NULL
)
1569 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1573 memmove(NewCtrlHandlers
, CtrlHandlers
, sizeof(PHANDLER_ROUTINE
) * NrCtrlHandlers
);
1575 if (NrAllocatedHandlers
> 1) RtlFreeHeap(RtlGetProcessHeap(), 0, CtrlHandlers
);
1577 CtrlHandlers
= NewCtrlHandlers
;
1578 NrAllocatedHandlers
+= 4;
1581 ASSERT(NrCtrlHandlers
< NrAllocatedHandlers
);
1583 CtrlHandlers
[NrCtrlHandlers
++] = HandlerRoutine
;
1590 RemoveConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine
)
1594 if (HandlerRoutine
== NULL
)
1596 NtCurrentPeb()->ProcessParameters
->ConsoleFlags
= FALSE
;
1600 for (i
= 0; i
< NrCtrlHandlers
; i
++)
1602 if (CtrlHandlers
[i
] == HandlerRoutine
)
1604 if (i
< (NrCtrlHandlers
- 1))
1606 memmove(&CtrlHandlers
[i
],
1608 (NrCtrlHandlers
- i
+ 1) * sizeof(PHANDLER_ROUTINE
));
1616 SetLastError(ERROR_INVALID_PARAMETER
);
1626 SetConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine
,
1631 RtlEnterCriticalSection(&BaseDllDirectoryLock
);
1634 Ret
= AddConsoleCtrlHandler(HandlerRoutine
);
1638 Ret
= RemoveConsoleCtrlHandler(HandlerRoutine
);
1641 RtlLeaveCriticalSection(&BaseDllDirectoryLock
);
1646 /*--------------------------------------------------------------
1647 * GenerateConsoleCtrlEvent
1653 GenerateConsoleCtrlEvent(DWORD dwCtrlEvent
,
1654 DWORD dwProcessGroupId
)
1657 CONSOLE_API_MESSAGE ApiMessage
;
1659 if (dwCtrlEvent
!= CTRL_C_EVENT
&& dwCtrlEvent
!= CTRL_BREAK_EVENT
)
1661 SetLastError(ERROR_INVALID_PARAMETER
);
1665 ApiMessage
.Data
.GenerateCtrlEventRequest
.Event
= dwCtrlEvent
;
1666 ApiMessage
.Data
.GenerateCtrlEventRequest
.ProcessGroup
= dwProcessGroupId
;
1668 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1670 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGenerateCtrlEvent
),
1671 sizeof(CONSOLE_GENERATECTRLEVENT
));
1672 if (!NT_SUCCESS(Status
))
1674 BaseSetLastNTError(Status
);
1683 IntGetConsoleTitle(LPVOID lpConsoleTitle
, DWORD nSize
, BOOL bUnicode
)
1686 CONSOLE_API_MESSAGE ApiMessage
;
1687 PCONSOLE_GETSETCONSOLETITLE TitleRequest
= &ApiMessage
.Data
.TitleRequest
;
1688 PCSR_CAPTURE_BUFFER CaptureBuffer
;
1690 if (nSize
== 0) return 0;
1692 TitleRequest
->Length
= nSize
* (bUnicode
? 1 : sizeof(WCHAR
));
1693 CaptureBuffer
= CsrAllocateCaptureBuffer(1, TitleRequest
->Length
);
1694 if (CaptureBuffer
== NULL
)
1696 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
1697 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1701 CsrAllocateMessagePointer(CaptureBuffer
,
1702 TitleRequest
->Length
,
1703 (PVOID
*)&TitleRequest
->Title
);
1705 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1707 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetTitle
),
1708 sizeof(CONSOLE_GETSETCONSOLETITLE
));
1709 if (!NT_SUCCESS(Status
))
1711 CsrFreeCaptureBuffer(CaptureBuffer
);
1712 BaseSetLastNTError(Status
);
1718 if (nSize
>= sizeof(WCHAR
))
1719 wcscpy((LPWSTR
)lpConsoleTitle
, TitleRequest
->Title
);
1723 if (nSize
< TitleRequest
->Length
/ sizeof(WCHAR
) ||
1724 !WideCharToMultiByte(CP_ACP
, // ANSI code page
1725 0, // performance and mapping flags
1726 TitleRequest
->Title
, // address of wide-character string
1727 -1, // number of characters in string
1728 (LPSTR
)lpConsoleTitle
, // address of buffer for new string
1729 nSize
, // size of buffer
1733 /* Yes, if the buffer isn't big enough, it returns 0... Bad API */
1734 *(LPSTR
)lpConsoleTitle
= '\0';
1735 TitleRequest
->Length
= 0;
1738 CsrFreeCaptureBuffer(CaptureBuffer
);
1740 return TitleRequest
->Length
/ sizeof(WCHAR
);
1744 /*--------------------------------------------------------------
1751 GetConsoleTitleW(LPWSTR lpConsoleTitle
,
1754 return IntGetConsoleTitle(lpConsoleTitle
, nSize
, TRUE
);
1758 /*--------------------------------------------------------------
1765 GetConsoleTitleA(LPSTR lpConsoleTitle
,
1768 return IntGetConsoleTitle(lpConsoleTitle
, nSize
, FALSE
);
1772 /*--------------------------------------------------------------
1779 SetConsoleTitleW(LPCWSTR lpConsoleTitle
)
1782 CONSOLE_API_MESSAGE ApiMessage
;
1783 PCONSOLE_GETSETCONSOLETITLE TitleRequest
= &ApiMessage
.Data
.TitleRequest
;
1784 PCSR_CAPTURE_BUFFER CaptureBuffer
;
1786 TitleRequest
->Length
= wcslen(lpConsoleTitle
) * sizeof(WCHAR
);
1788 CaptureBuffer
= CsrAllocateCaptureBuffer(1, TitleRequest
->Length
);
1789 if (CaptureBuffer
== NULL
)
1791 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
1792 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1796 CsrCaptureMessageBuffer(CaptureBuffer
,
1797 (PVOID
)lpConsoleTitle
,
1798 TitleRequest
->Length
,
1799 (PVOID
*)&TitleRequest
->Title
);
1801 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1803 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetTitle
),
1804 sizeof(CONSOLE_GETSETCONSOLETITLE
));
1806 CsrFreeCaptureBuffer(CaptureBuffer
);
1808 if (!NT_SUCCESS(Status
))
1810 BaseSetLastNTError(Status
);
1818 /*--------------------------------------------------------------
1825 SetConsoleTitleA(LPCSTR lpConsoleTitle
)
1828 ULONG Length
= strlen(lpConsoleTitle
) + 1;
1829 LPWSTR WideTitle
= HeapAlloc(GetProcessHeap(), 0, Length
* sizeof(WCHAR
));
1833 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1837 MultiByteToWideChar(CP_ACP
, 0, lpConsoleTitle
, -1, WideTitle
, Length
);
1839 Ret
= SetConsoleTitleW(WideTitle
);
1841 HeapFree(GetProcessHeap(), 0, WideTitle
);
1846 /*--------------------------------------------------------------
1847 * CreateConsoleScreenBuffer
1853 CreateConsoleScreenBuffer(DWORD dwDesiredAccess
,
1855 CONST SECURITY_ATTRIBUTES
*lpSecurityAttributes
,
1857 LPVOID lpScreenBufferData
)
1860 CONSOLE_API_MESSAGE ApiMessage
;
1861 PCONSOLE_CREATESCREENBUFFER CreateScreenBufferRequest
= &ApiMessage
.Data
.CreateScreenBufferRequest
;
1862 PCSR_CAPTURE_BUFFER CaptureBuffer
= NULL
;
1863 PCONSOLE_GRAPHICS_BUFFER_INFO GraphicsBufferInfo
= /*(PCONSOLE_GRAPHICS_BUFFER_INFO)*/lpScreenBufferData
;
1865 if ( (dwDesiredAccess
& ~(GENERIC_READ
| GENERIC_WRITE
)) ||
1866 (dwShareMode
& ~(FILE_SHARE_READ
| FILE_SHARE_WRITE
)) ||
1867 (dwFlags
!= CONSOLE_TEXTMODE_BUFFER
&& dwFlags
!= CONSOLE_GRAPHICS_BUFFER
) )
1869 SetLastError(ERROR_INVALID_PARAMETER
);
1870 return INVALID_HANDLE_VALUE
;
1873 CreateScreenBufferRequest
->ScreenBufferType
= dwFlags
;
1874 CreateScreenBufferRequest
->Access
= dwDesiredAccess
;
1875 CreateScreenBufferRequest
->ShareMode
= dwShareMode
;
1876 CreateScreenBufferRequest
->Inheritable
=
1877 (lpSecurityAttributes
? lpSecurityAttributes
->bInheritHandle
: FALSE
);
1879 if (dwFlags
== CONSOLE_GRAPHICS_BUFFER
)
1881 if (CreateScreenBufferRequest
->Inheritable
|| GraphicsBufferInfo
== NULL
)
1883 SetLastError(ERROR_INVALID_PARAMETER
);
1884 return INVALID_HANDLE_VALUE
;
1887 CreateScreenBufferRequest
->GraphicsBufferInfo
= *GraphicsBufferInfo
;
1889 CaptureBuffer
= CsrAllocateCaptureBuffer(1, GraphicsBufferInfo
->dwBitMapInfoLength
);
1890 if (CaptureBuffer
== NULL
)
1892 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1896 CsrCaptureMessageBuffer(CaptureBuffer
,
1897 (PVOID
)GraphicsBufferInfo
->lpBitMapInfo
,
1898 GraphicsBufferInfo
->dwBitMapInfoLength
,
1899 (PVOID
*)&CreateScreenBufferRequest
->GraphicsBufferInfo
.lpBitMapInfo
);
1902 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1904 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepCreateScreenBuffer
),
1905 sizeof(CONSOLE_CREATESCREENBUFFER
));
1908 CsrFreeCaptureBuffer(CaptureBuffer
);
1910 if (!NT_SUCCESS(Status
))
1912 BaseSetLastNTError(Status
);
1913 return INVALID_HANDLE_VALUE
;
1916 if (dwFlags
== CONSOLE_GRAPHICS_BUFFER
&& GraphicsBufferInfo
)
1918 GraphicsBufferInfo
->hMutex
= CreateScreenBufferRequest
->GraphicsBufferInfo
.hMutex
;
1919 GraphicsBufferInfo
->lpBitMap
= CreateScreenBufferRequest
->GraphicsBufferInfo
.lpBitMap
;
1922 return CreateScreenBufferRequest
->OutputHandle
;
1926 /*--------------------------------------------------------------
1936 CONSOLE_API_MESSAGE ApiMessage
;
1938 /* Get the Input Code Page */
1939 ApiMessage
.Data
.ConsoleCPRequest
.InputCP
= TRUE
;
1940 ApiMessage
.Data
.ConsoleCPRequest
.CodePage
= 0;
1942 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1944 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetCP
),
1945 sizeof(CONSOLE_GETSETINPUTOUTPUTCP
));
1947 if (!NT_SUCCESS(Status
)) BaseSetLastNTError(Status
);
1949 return ApiMessage
.Data
.ConsoleCPRequest
.CodePage
;
1953 /*--------------------------------------------------------------
1960 SetConsoleCP(UINT wCodePageID
)
1963 CONSOLE_API_MESSAGE ApiMessage
;
1965 /* Set the Input Code Page */
1966 ApiMessage
.Data
.ConsoleCPRequest
.InputCP
= TRUE
;
1967 ApiMessage
.Data
.ConsoleCPRequest
.CodePage
= wCodePageID
;
1969 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1971 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetCP
),
1972 sizeof(CONSOLE_GETSETINPUTOUTPUTCP
));
1974 if (!NT_SUCCESS(Status
)) BaseSetLastNTError(Status
);
1976 return NT_SUCCESS(Status
);
1980 /*--------------------------------------------------------------
1981 * GetConsoleOutputCP
1987 GetConsoleOutputCP(VOID
)
1990 CONSOLE_API_MESSAGE ApiMessage
;
1992 /* Get the Output Code Page */
1993 ApiMessage
.Data
.ConsoleCPRequest
.InputCP
= FALSE
;
1994 ApiMessage
.Data
.ConsoleCPRequest
.CodePage
= 0;
1996 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1998 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetCP
),
1999 sizeof(CONSOLE_GETSETINPUTOUTPUTCP
));
2001 if (!NT_SUCCESS(Status
)) BaseSetLastNTError(Status
);
2003 return ApiMessage
.Data
.ConsoleCPRequest
.CodePage
;
2007 /*--------------------------------------------------------------
2008 * SetConsoleOutputCP
2014 SetConsoleOutputCP(UINT wCodePageID
)
2017 CONSOLE_API_MESSAGE ApiMessage
;
2019 /* Set the Output Code Page */
2020 ApiMessage
.Data
.ConsoleCPRequest
.InputCP
= FALSE
;
2021 ApiMessage
.Data
.ConsoleCPRequest
.CodePage
= wCodePageID
;
2023 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
2025 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetCP
),
2026 sizeof(CONSOLE_GETSETINPUTOUTPUTCP
));
2028 if (!NT_SUCCESS(Status
)) BaseSetLastNTError(Status
);
2030 return NT_SUCCESS(Status
);
2034 /*--------------------------------------------------------------
2035 * GetConsoleProcessList
2041 GetConsoleProcessList(LPDWORD lpdwProcessList
,
2042 DWORD dwProcessCount
)
2045 CONSOLE_API_MESSAGE ApiMessage
;
2046 PCONSOLE_GETPROCESSLIST GetProcessListRequest
= &ApiMessage
.Data
.GetProcessListRequest
;
2047 PCSR_CAPTURE_BUFFER CaptureBuffer
;
2050 if (lpdwProcessList
== NULL
|| dwProcessCount
== 0)
2052 SetLastError(ERROR_INVALID_PARAMETER
);
2056 CaptureBuffer
= CsrAllocateCaptureBuffer(1, dwProcessCount
* sizeof(DWORD
));
2057 if (CaptureBuffer
== NULL
)
2059 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
2060 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
2064 GetProcessListRequest
->nMaxIds
= dwProcessCount
;
2066 CsrAllocateMessagePointer(CaptureBuffer
,
2067 dwProcessCount
* sizeof(DWORD
),
2068 (PVOID
*)&GetProcessListRequest
->pProcessIds
);
2070 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
2072 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetProcessList
),
2073 sizeof(CONSOLE_GETPROCESSLIST
));
2074 if (!NT_SUCCESS(Status
))
2076 BaseSetLastNTError (Status
);
2081 nProcesses
= GetProcessListRequest
->nProcessIdsTotal
;
2082 if (dwProcessCount
>= nProcesses
)
2084 memcpy(lpdwProcessList
, GetProcessListRequest
->pProcessIds
, nProcesses
* sizeof(DWORD
));
2088 CsrFreeCaptureBuffer(CaptureBuffer
);
2093 /*--------------------------------------------------------------
2094 * GetConsoleSelectionInfo
2100 GetConsoleSelectionInfo(PCONSOLE_SELECTION_INFO lpConsoleSelectionInfo
)
2103 CONSOLE_API_MESSAGE ApiMessage
;
2105 if (lpConsoleSelectionInfo
== NULL
)
2107 SetLastError(ERROR_INVALID_PARAMETER
);
2111 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
2113 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetSelectionInfo
),
2114 sizeof(CONSOLE_GETSELECTIONINFO
));
2115 if (!NT_SUCCESS(Status
))
2117 BaseSetLastNTError(Status
);
2121 *lpConsoleSelectionInfo
= ApiMessage
.Data
.GetSelectionInfoRequest
.Info
;
2126 /*--------------------------------------------------------------
2131 * @note Strongly inspired by AllocConsole.
2135 AttachConsole(DWORD dwProcessId
)
2138 PRTL_USER_PROCESS_PARAMETERS Parameters
= NtCurrentPeb()->ProcessParameters
;
2139 CONSOLE_API_MESSAGE ApiMessage
;
2140 PCONSOLE_ATTACHCONSOLE AttachConsoleRequest
= &ApiMessage
.Data
.AttachConsoleRequest
;
2142 if (Parameters
->ConsoleHandle
)
2144 DPRINT1("AttachConsole: Attaching a console to a process already having one\n");
2145 SetLastError(ERROR_ACCESS_DENIED
);
2149 AttachConsoleRequest
->ProcessId
= dwProcessId
;
2150 AttachConsoleRequest
->CtrlDispatcher
= ConsoleControlDispatcher
;
2151 AttachConsoleRequest
->PropDispatcher
= PropDialogHandler
;
2153 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
2155 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepAttach
),
2156 sizeof(CONSOLE_ATTACHCONSOLE
));
2157 if (!NT_SUCCESS(Status
))
2159 BaseSetLastNTError(Status
);
2163 Parameters
->ConsoleHandle
= AttachConsoleRequest
->ConsoleHandle
;
2164 SetStdHandle(STD_INPUT_HANDLE
, AttachConsoleRequest
->InputHandle
);
2165 SetStdHandle(STD_OUTPUT_HANDLE
, AttachConsoleRequest
->OutputHandle
);
2166 SetStdHandle(STD_ERROR_HANDLE
, AttachConsoleRequest
->ErrorHandle
);
2168 /* Initialize Console Ctrl Handler */
2169 InitConsoleCtrlHandling();
2171 InputWaitHandle
= AttachConsoleRequest
->InputWaitHandle
;
2177 /*--------------------------------------------------------------
2184 GetConsoleWindow(VOID
)
2187 CONSOLE_API_MESSAGE ApiMessage
;
2189 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
2191 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetConsoleWindow
),
2192 sizeof(CONSOLE_GETWINDOW
));
2193 if (!NT_SUCCESS(Status
))
2195 BaseSetLastNTError(Status
);
2199 return ApiMessage
.Data
.GetWindowRequest
.WindowHandle
;
2203 /*--------------------------------------------------------------
2210 SetConsoleIcon(HICON hicon
)
2213 CONSOLE_API_MESSAGE ApiMessage
;
2215 ApiMessage
.Data
.SetIconRequest
.WindowIcon
= hicon
;
2217 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
2219 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetIcon
),
2220 sizeof(CONSOLE_SETICON
));
2221 if (!NT_SUCCESS(Status
))
2223 BaseSetLastNTError(Status
);
2227 return NT_SUCCESS(Status
);
2231 /******************************************************************************
2232 * \name SetConsoleInputExeNameW
2233 * \brief Sets the console input file name from a unicode string.
2234 * \param lpInputExeName Pointer to a unicode string with the name.
2235 * \return TRUE if successful, FALSE if unsuccsedful.
2236 * \remarks If lpInputExeName is 0 or the string length is 0 or greater than 255,
2237 * the function fails and sets last error to ERROR_INVALID_PARAMETER.
2241 SetConsoleInputExeNameW(LPCWSTR lpInputExeName
)
2245 if ( !lpInputExeName
||
2246 (lenName
= lstrlenW(lpInputExeName
)) == 0 ||
2247 lenName
> INPUTEXENAME_BUFLEN
- 1 )
2249 /* Fail if string is empty or too long */
2250 SetLastError(ERROR_INVALID_PARAMETER
);
2254 RtlEnterCriticalSection(&ConsoleLock
);
2257 RtlCopyMemory(InputExeName
, lpInputExeName
, lenName
* sizeof(WCHAR
));
2258 InputExeName
[lenName
] = L
'\0';
2262 RtlLeaveCriticalSection(&ConsoleLock
);
2270 /******************************************************************************
2271 * \name SetConsoleInputExeNameA
2272 * \brief Sets the console input file name from an ansi string.
2273 * \param lpInputExeName Pointer to an ansi string with the name.
2274 * \return TRUE if successful, FALSE if unsuccsedful.
2275 * \remarks If lpInputExeName is 0 or the string length is 0 or greater than 255,
2276 * the function fails and sets last error to ERROR_INVALID_PARAMETER.
2280 SetConsoleInputExeNameA(LPCSTR lpInputExeName
)
2282 WCHAR Buffer
[INPUTEXENAME_BUFLEN
];
2283 ANSI_STRING InputExeNameA
;
2284 UNICODE_STRING InputExeNameU
;
2287 RtlInitAnsiString(&InputExeNameA
, lpInputExeName
);
2289 if ( InputExeNameA
.Length
== 0 ||
2290 InputExeNameA
.Length
> INPUTEXENAME_BUFLEN
- 1 )
2292 /* Fail if string is empty or too long */
2293 SetLastError(ERROR_INVALID_PARAMETER
);
2297 InputExeNameU
.Buffer
= Buffer
;
2298 InputExeNameU
.MaximumLength
= sizeof(Buffer
);
2299 InputExeNameU
.Length
= 0;
2301 Status
= RtlAnsiStringToUnicodeString(&InputExeNameU
, &InputExeNameA
, FALSE
);
2302 if (!NT_SUCCESS(Status
))
2304 BaseSetLastNTError(Status
);
2308 return SetConsoleInputExeNameW(InputExeNameU
.Buffer
);
2312 /******************************************************************************
2313 * \name GetConsoleInputExeNameW
2314 * \brief Retrieves the console input file name as unicode string.
2315 * \param nBufferLength Length of the buffer in WCHARs.
2316 * Specify 0 to receive the needed buffer length.
2317 * \param lpBuffer Pointer to a buffer that receives the string.
2318 * \return Needed buffer size if \p nBufferLength is 0.
2319 * Otherwise 1 if successful, 2 if buffer is too small.
2320 * \remarks Sets last error value to ERROR_BUFFER_OVERFLOW if the buffer
2321 * is not big enough.
2325 GetConsoleInputExeNameW(DWORD nBufferLength
, LPWSTR lpBuffer
)
2327 ULONG lenName
= lstrlenW(InputExeName
);
2329 if (nBufferLength
== 0)
2331 /* Buffer size is requested, return it */
2335 if (lenName
+ 1 > nBufferLength
)
2337 /* Buffer is not large enough! */
2338 SetLastError(ERROR_BUFFER_OVERFLOW
);
2342 RtlEnterCriticalSection(&ConsoleLock
);
2345 RtlCopyMemory(lpBuffer
, InputExeName
, lenName
* sizeof(WCHAR
));
2346 lpBuffer
[lenName
] = '\0';
2350 RtlLeaveCriticalSection(&ConsoleLock
);
2354 /* Success, return 1 */
2359 /******************************************************************************
2360 * \name GetConsoleInputExeNameA
2361 * \brief Retrieves the console input file name as ansi string.
2362 * \param nBufferLength Length of the buffer in CHARs.
2363 * \param lpBuffer Pointer to a buffer that receives the string.
2364 * \return 1 if successful, 2 if buffer is too small.
2365 * \remarks Sets last error value to ERROR_BUFFER_OVERFLOW if the buffer
2366 * is not big enough. The buffer receives as much characters as fit.
2370 GetConsoleInputExeNameA(DWORD nBufferLength
, LPSTR lpBuffer
)
2372 WCHAR Buffer
[INPUTEXENAME_BUFLEN
];
2374 UNICODE_STRING BufferU
;
2375 ANSI_STRING BufferA
;
2377 /* Get the unicode name */
2378 Ret
= GetConsoleInputExeNameW(sizeof(Buffer
) / sizeof(Buffer
[0]), Buffer
);
2380 /* Initialize strings for conversion */
2381 RtlInitUnicodeString(&BufferU
, Buffer
);
2383 BufferA
.MaximumLength
= (USHORT
)nBufferLength
;
2384 BufferA
.Buffer
= lpBuffer
;
2386 /* Convert unicode name to ansi, copying as much chars as fit */
2387 RtlUnicodeStringToAnsiString(&BufferA
, &BufferU
, FALSE
);
2389 /* Error handling */
2390 if (nBufferLength
<= BufferU
.Length
/ sizeof(WCHAR
))
2392 SetLastError(ERROR_BUFFER_OVERFLOW
);
2401 GetConsoleCharType(HANDLE hConsole
, COORD Coord
, PDWORD Type
)
2409 GetConsoleCursorMode(HANDLE hConsole
, PBOOL pUnknown1
, PBOOL pUnknown2
)
2417 GetConsoleNlsMode(HANDLE hConsole
, LPDWORD lpMode
)
2425 SetConsoleCursorMode(HANDLE hConsole
, BOOL Unknown1
, BOOL Unknown2
)
2433 SetConsoleLocalEUDC(DWORD Unknown1
, DWORD Unknown2
, DWORD Unknown3
, DWORD Unknown4
)
2441 SetConsoleNlsMode(HANDLE hConsole
, DWORD dwMode
)
2449 RegisterConsoleIME(HWND hWnd
, LPDWORD ThreadId
)
2457 RegisterConsoleOS2(BOOL bUnknown
)
2465 SetConsoleOS2OemFormat(BOOL bUnknown
)
2473 UnregisterConsoleIME(VOID
)
2483 BOOL WINAPI
GetConsoleKeyboardLayoutNameA(LPSTR name
)
2492 BOOL WINAPI
GetConsoleKeyboardLayoutNameW(LPWSTR name
)
2503 SetLastConsoleEventActive(VOID
)