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(DWORD Unknown0
,
354 DPRINT1("GetConsoleFontInfo(0x%x, 0x%x, 0x%x, 0x%x) UNIMPLEMENTED!\n", Unknown0
, Unknown1
, Unknown2
, Unknown3
);
355 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
365 GetConsoleFontSize(HANDLE hConsoleOutput
,
368 COORD Empty
= {0, 0};
369 DPRINT1("GetConsoleFontSize(0x%x, 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(%d, 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%x, 0x%x, 0x%x) 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(DWORD Unknown0
,
616 DPRINT1("SetConsoleFont(0x%x, 0x%x) UNIMPLEMENTED!\n", Unknown0
, Unknown1
);
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(%d, %d) 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%x, {%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 * @unimplemented (Undocumented)
718 SetConsolePalette(DWORD Unknown0
,
722 DPRINT1("SetConsolePalette(0x%x, 0x%x, 0x%x) UNIMPLEMENTED!\n", Unknown0
, Unknown1
, Unknown2
);
723 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
728 * @implemented (Undocumented)
729 * @note See http://undoc.airesoft.co.uk/kernel32.dll/ShowConsoleCursor.php
733 ShowConsoleCursor(HANDLE hConsoleOutput
,
736 CONSOLE_API_MESSAGE ApiMessage
;
737 PCONSOLE_SHOWCURSOR ShowCursorRequest
= &ApiMessage
.Data
.ShowCursorRequest
;
739 ShowCursorRequest
->OutputHandle
= hConsoleOutput
;
740 ShowCursorRequest
->Show
= bShow
;
741 ShowCursorRequest
->RefCount
= 0;
743 CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
745 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepShowCursor
),
746 sizeof(CONSOLE_SHOWCURSOR
));
748 return ShowCursorRequest
->RefCount
;
753 * FUNCTION: Checks whether the given handle is a valid console handle.
756 * Handle - Handle to be checked
759 * TRUE: Handle is a valid console handle
760 * FALSE: Handle is not a valid console handle.
762 * STATUS: Officially undocumented
768 VerifyConsoleIoHandle(HANDLE Handle
)
771 CONSOLE_API_MESSAGE ApiMessage
;
773 ApiMessage
.Data
.VerifyHandleRequest
.ConsoleHandle
= Handle
;
775 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
777 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepVerifyIoHandle
),
778 sizeof(CONSOLE_VERIFYHANDLE
));
779 if (!NT_SUCCESS(Status
))
781 BaseSetLastNTError(Status
);
794 WriteConsoleInputVDMA(DWORD Unknown0
,
799 DPRINT1("WriteConsoleInputVDMA(0x%x, 0x%x, 0x%x, 0x%x) UNIMPLEMENTED!\n", Unknown0
, Unknown1
, Unknown2
, Unknown3
);
800 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
810 WriteConsoleInputVDMW(DWORD Unknown0
,
815 DPRINT1("WriteConsoleInputVDMW(0x%x, 0x%x, 0x%x, 0x%x) UNIMPLEMENTED!\n", Unknown0
, Unknown1
, Unknown2
, Unknown3
);
816 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
822 * @implemented (Undocumented)
826 CloseConsoleHandle(HANDLE Handle
)
829 CONSOLE_API_MESSAGE ApiMessage
;
831 ApiMessage
.Data
.CloseHandleRequest
.ConsoleHandle
= Handle
;
833 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
835 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepCloseHandle
),
836 sizeof(CONSOLE_CLOSEHANDLE
));
837 if (!NT_SUCCESS(Status
))
839 BaseSetLastNTError(Status
);
852 GetStdHandle(DWORD nStdHandle
)
854 * FUNCTION: Get a handle for the standard input, standard output
855 * and a standard error device.
858 * nStdHandle - Specifies the device for which to return the handle.
860 * RETURNS: If the function succeeds, the return value is the handle
861 * of the specified device. Otherwise the value is INVALID_HANDLE_VALUE.
864 PRTL_USER_PROCESS_PARAMETERS Ppb
= NtCurrentPeb()->ProcessParameters
;
868 case STD_INPUT_HANDLE
:
869 return Ppb
->StandardInput
;
871 case STD_OUTPUT_HANDLE
:
872 return Ppb
->StandardOutput
;
874 case STD_ERROR_HANDLE
:
875 return Ppb
->StandardError
;
878 SetLastError(ERROR_INVALID_HANDLE
);
879 return INVALID_HANDLE_VALUE
;
888 SetStdHandle(DWORD nStdHandle
,
891 * FUNCTION: Set the handle for the standard input, standard output or
892 * the standard error device.
895 * nStdHandle - Specifies the handle to be set.
896 * hHandle - The handle to set.
898 * RETURNS: TRUE if the function succeeds, FALSE otherwise.
901 PRTL_USER_PROCESS_PARAMETERS Ppb
= NtCurrentPeb()->ProcessParameters
;
903 /* no need to check if hHandle == INVALID_HANDLE_VALUE */
907 case STD_INPUT_HANDLE
:
908 Ppb
->StandardInput
= hHandle
;
911 case STD_OUTPUT_HANDLE
:
912 Ppb
->StandardOutput
= hHandle
;
915 case STD_ERROR_HANDLE
:
916 Ppb
->StandardError
= hHandle
;
920 /* Windows for whatever reason sets the last error to ERROR_INVALID_HANDLE here */
921 SetLastError(ERROR_INVALID_HANDLE
);
926 /*--------------------------------------------------------------
936 PRTL_USER_PROCESS_PARAMETERS Parameters
= NtCurrentPeb()->ProcessParameters
;
937 CONSOLE_API_MESSAGE ApiMessage
;
938 PCONSOLE_ALLOCCONSOLE AllocConsoleRequest
= &ApiMessage
.Data
.AllocConsoleRequest
;
939 PCSR_CAPTURE_BUFFER CaptureBuffer
;
940 LPWSTR AppPath
= NULL
;
943 if (Parameters
->ConsoleHandle
)
945 DPRINT1("AllocConsole: Allocating a console to a process already having one\n");
946 SetLastError(ERROR_ACCESS_DENIED
);
950 CaptureBuffer
= CsrAllocateCaptureBuffer(1, sizeof(CONSOLE_START_INFO
));
951 if (CaptureBuffer
== NULL
)
953 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
954 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
958 CsrAllocateMessagePointer(CaptureBuffer
,
959 sizeof(CONSOLE_START_INFO
),
960 (PVOID
*)&AllocConsoleRequest
->ConsoleStartInfo
);
962 /** Copied from BasepInitConsole **********************************************/
963 InitConsoleInfo(AllocConsoleRequest
->ConsoleStartInfo
);
965 AppPath
= AllocConsoleRequest
->ConsoleStartInfo
->AppPath
;
966 Length
= min(MAX_PATH
, Parameters
->ImagePathName
.Length
/ sizeof(WCHAR
));
967 wcsncpy(AppPath
, Parameters
->ImagePathName
.Buffer
, Length
);
968 AppPath
[Length
] = L
'\0';
969 /******************************************************************************/
971 AllocConsoleRequest
->Console
= NULL
;
972 AllocConsoleRequest
->CtrlDispatcher
= ConsoleControlDispatcher
;
973 AllocConsoleRequest
->PropDispatcher
= PropDialogHandler
;
975 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
977 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepAlloc
),
978 sizeof(CONSOLE_ALLOCCONSOLE
));
980 CsrFreeCaptureBuffer(CaptureBuffer
);
982 if (!NT_SUCCESS(Status
))
984 BaseSetLastNTError(Status
);
988 Parameters
->ConsoleHandle
= AllocConsoleRequest
->Console
;
989 SetStdHandle(STD_INPUT_HANDLE
, AllocConsoleRequest
->InputHandle
);
990 SetStdHandle(STD_OUTPUT_HANDLE
, AllocConsoleRequest
->OutputHandle
);
991 SetStdHandle(STD_ERROR_HANDLE
, AllocConsoleRequest
->ErrorHandle
);
993 /* Initialize Console Ctrl Handler */
994 InitConsoleCtrlHandling();
996 InputWaitHandle
= AllocConsoleRequest
->InputWaitHandle
;
1002 /*--------------------------------------------------------------
1011 // AG: I'm not sure if this is correct (what happens to std handles?)
1012 // but I just tried to reverse what AllocConsole() does...
1015 CONSOLE_API_MESSAGE ApiMessage
;
1017 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1019 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepFree
),
1020 sizeof(CONSOLE_FREECONSOLE
));
1021 if (!NT_SUCCESS(Status
))
1023 BaseSetLastNTError(Status
);
1027 NtCurrentPeb()->ProcessParameters
->ConsoleHandle
= NULL
;
1029 CloseHandle(InputWaitHandle
);
1030 InputWaitHandle
= INVALID_HANDLE_VALUE
;
1036 /*--------------------------------------------------------------
1037 * GetConsoleScreenBufferInfo
1043 GetConsoleScreenBufferInfo(HANDLE hConsoleOutput
,
1044 PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo
)
1047 CONSOLE_API_MESSAGE ApiMessage
;
1049 if (lpConsoleScreenBufferInfo
== NULL
)
1051 SetLastError(ERROR_INVALID_PARAMETER
);
1055 ApiMessage
.Data
.ScreenBufferInfoRequest
.OutputHandle
= hConsoleOutput
;
1057 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1059 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetScreenBufferInfo
),
1060 sizeof(CONSOLE_GETSCREENBUFFERINFO
));
1061 if (!NT_SUCCESS(Status
))
1063 BaseSetLastNTError(Status
);
1067 *lpConsoleScreenBufferInfo
= ApiMessage
.Data
.ScreenBufferInfoRequest
.Info
;
1073 /*--------------------------------------------------------------
1074 * SetConsoleCursorPosition
1080 SetConsoleCursorPosition(HANDLE hConsoleOutput
,
1081 COORD dwCursorPosition
)
1084 CONSOLE_API_MESSAGE ApiMessage
;
1086 ApiMessage
.Data
.SetCursorPositionRequest
.OutputHandle
= hConsoleOutput
;
1087 ApiMessage
.Data
.SetCursorPositionRequest
.Position
= dwCursorPosition
;
1089 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1091 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetCursorPosition
),
1092 sizeof(CONSOLE_SETCURSORPOSITION
));
1093 if (!NT_SUCCESS(Status
))
1095 BaseSetLastNTError(Status
);
1103 /*--------------------------------------------------------------
1110 GetConsoleMode(HANDLE hConsoleHandle
,
1114 CONSOLE_API_MESSAGE ApiMessage
;
1115 PCONSOLE_GETSETCONSOLEMODE ConsoleModeRequest
= &ApiMessage
.Data
.ConsoleModeRequest
;
1119 SetLastError(ERROR_INVALID_PARAMETER
);
1123 ConsoleModeRequest
->ConsoleHandle
= hConsoleHandle
;
1125 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1127 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetMode
),
1128 sizeof(CONSOLE_GETSETCONSOLEMODE
));
1129 if (!NT_SUCCESS(Status
))
1131 BaseSetLastNTError(Status
);
1135 *lpMode
= ConsoleModeRequest
->ConsoleMode
;
1141 /*--------------------------------------------------------------
1142 * GetNumberOfConsoleInputEvents
1148 GetNumberOfConsoleInputEvents(HANDLE hConsoleInput
,
1149 LPDWORD lpNumberOfEvents
)
1152 CONSOLE_API_MESSAGE ApiMessage
;
1153 PCONSOLE_GETNUMINPUTEVENTS GetNumInputEventsRequest
= &ApiMessage
.Data
.GetNumInputEventsRequest
;
1155 GetNumInputEventsRequest
->InputHandle
= hConsoleInput
;
1156 GetNumInputEventsRequest
->NumInputEvents
= 0;
1158 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1160 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetNumberOfInputEvents
),
1161 sizeof(CONSOLE_GETNUMINPUTEVENTS
));
1162 if (!NT_SUCCESS(Status
))
1164 BaseSetLastNTError(Status
);
1168 if (lpNumberOfEvents
== NULL
)
1170 SetLastError(ERROR_INVALID_ACCESS
);
1174 *lpNumberOfEvents
= GetNumInputEventsRequest
->NumInputEvents
;
1180 /*--------------------------------------------------------------
1181 * GetLargestConsoleWindowSize
1187 GetLargestConsoleWindowSize(HANDLE hConsoleOutput
)
1190 CONSOLE_API_MESSAGE ApiMessage
;
1191 PCONSOLE_GETLARGESTWINDOWSIZE GetLargestWindowSizeRequest
= &ApiMessage
.Data
.GetLargestWindowSizeRequest
;
1193 GetLargestWindowSizeRequest
->OutputHandle
= hConsoleOutput
;
1194 GetLargestWindowSizeRequest
->Size
.X
= 0;
1195 GetLargestWindowSizeRequest
->Size
.Y
= 0;
1197 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1199 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetLargestWindowSize
),
1200 sizeof(CONSOLE_GETLARGESTWINDOWSIZE
));
1201 if (!NT_SUCCESS(Status
))
1203 BaseSetLastNTError(Status
);
1206 DPRINT1("GetLargestConsoleWindowSize, X = %d, Y = %d\n", GetLargestWindowSizeRequest
->Size
.X
, GetLargestWindowSizeRequest
->Size
.Y
);
1207 return GetLargestWindowSizeRequest
->Size
;
1211 /*--------------------------------------------------------------
1212 * GetConsoleCursorInfo
1218 GetConsoleCursorInfo(HANDLE hConsoleOutput
,
1219 PCONSOLE_CURSOR_INFO lpConsoleCursorInfo
)
1222 CONSOLE_API_MESSAGE ApiMessage
;
1224 if (!lpConsoleCursorInfo
)
1226 if (!hConsoleOutput
)
1227 SetLastError(ERROR_INVALID_HANDLE
);
1229 SetLastError(ERROR_INVALID_ACCESS
);
1234 ApiMessage
.Data
.CursorInfoRequest
.OutputHandle
= hConsoleOutput
;
1236 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1238 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetCursorInfo
),
1239 sizeof(CONSOLE_GETSETCURSORINFO
));
1240 if (!NT_SUCCESS(Status
))
1242 BaseSetLastNTError(Status
);
1246 *lpConsoleCursorInfo
= ApiMessage
.Data
.CursorInfoRequest
.Info
;
1252 /*--------------------------------------------------------------
1253 * GetNumberOfConsoleMouseButtons
1259 GetNumberOfConsoleMouseButtons(LPDWORD lpNumberOfMouseButtons
)
1261 DPRINT1("GetNumberOfConsoleMouseButtons(0x%x) UNIMPLEMENTED!\n", lpNumberOfMouseButtons
);
1262 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1267 /*--------------------------------------------------------------
1274 SetConsoleMode(HANDLE hConsoleHandle
,
1278 CONSOLE_API_MESSAGE ApiMessage
;
1279 PCONSOLE_GETSETCONSOLEMODE ConsoleModeRequest
= &ApiMessage
.Data
.ConsoleModeRequest
;
1281 ConsoleModeRequest
->ConsoleHandle
= hConsoleHandle
;
1282 ConsoleModeRequest
->ConsoleMode
= dwMode
;
1284 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1286 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetMode
),
1287 sizeof(CONSOLE_GETSETCONSOLEMODE
));
1288 if (!NT_SUCCESS(Status
))
1290 BaseSetLastNTError(Status
);
1298 /*--------------------------------------------------------------
1299 * SetConsoleActiveScreenBuffer
1305 SetConsoleActiveScreenBuffer(HANDLE hConsoleOutput
)
1308 CONSOLE_API_MESSAGE ApiMessage
;
1310 ApiMessage
.Data
.SetScreenBufferRequest
.OutputHandle
= hConsoleOutput
;
1312 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1314 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetActiveScreenBuffer
),
1315 sizeof(CONSOLE_SETACTIVESCREENBUFFER
));
1316 if (!NT_SUCCESS(Status
))
1318 BaseSetLastNTError(Status
);
1326 /*--------------------------------------------------------------
1327 * FlushConsoleInputBuffer
1333 FlushConsoleInputBuffer(HANDLE hConsoleInput
)
1336 CONSOLE_API_MESSAGE ApiMessage
;
1338 ApiMessage
.Data
.FlushInputBufferRequest
.InputHandle
= hConsoleInput
;
1340 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1342 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepFlushInputBuffer
),
1343 sizeof(CONSOLE_FLUSHINPUTBUFFER
));
1344 if (!NT_SUCCESS(Status
))
1346 BaseSetLastNTError(Status
);
1354 /*--------------------------------------------------------------
1355 * SetConsoleScreenBufferSize
1361 SetConsoleScreenBufferSize(HANDLE hConsoleOutput
,
1365 CONSOLE_API_MESSAGE ApiMessage
;
1367 ApiMessage
.Data
.SetScreenBufferSizeRequest
.OutputHandle
= hConsoleOutput
;
1368 ApiMessage
.Data
.SetScreenBufferSizeRequest
.Size
= dwSize
;
1370 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1372 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetScreenBufferSize
),
1373 sizeof(CONSOLE_SETSCREENBUFFERSIZE
));
1374 if (!NT_SUCCESS(Status
))
1376 BaseSetLastNTError(Status
);
1384 /*--------------------------------------------------------------
1385 * SetConsoleCursorInfo
1391 SetConsoleCursorInfo(HANDLE hConsoleOutput
,
1392 CONST CONSOLE_CURSOR_INFO
*lpConsoleCursorInfo
)
1395 CONSOLE_API_MESSAGE ApiMessage
;
1397 ApiMessage
.Data
.CursorInfoRequest
.OutputHandle
= hConsoleOutput
;
1398 ApiMessage
.Data
.CursorInfoRequest
.Info
= *lpConsoleCursorInfo
;
1400 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1402 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetCursorInfo
),
1403 sizeof(CONSOLE_GETSETCURSORINFO
));
1404 if (!NT_SUCCESS(Status
))
1406 BaseSetLastNTError(Status
);
1416 IntScrollConsoleScreenBuffer(HANDLE hConsoleOutput
,
1417 const SMALL_RECT
*lpScrollRectangle
,
1418 const SMALL_RECT
*lpClipRectangle
,
1419 COORD dwDestinationOrigin
,
1420 const CHAR_INFO
*lpFill
,
1424 CONSOLE_API_MESSAGE ApiMessage
;
1425 PCONSOLE_SCROLLSCREENBUFFER ScrollScreenBufferRequest
= &ApiMessage
.Data
.ScrollScreenBufferRequest
;
1427 ScrollScreenBufferRequest
->OutputHandle
= hConsoleOutput
;
1428 ScrollScreenBufferRequest
->Unicode
= bUnicode
;
1429 ScrollScreenBufferRequest
->ScrollRectangle
= *lpScrollRectangle
;
1431 if (lpClipRectangle
!= NULL
)
1433 ScrollScreenBufferRequest
->UseClipRectangle
= TRUE
;
1434 ScrollScreenBufferRequest
->ClipRectangle
= *lpClipRectangle
;
1438 ScrollScreenBufferRequest
->UseClipRectangle
= FALSE
;
1441 ScrollScreenBufferRequest
->DestinationOrigin
= dwDestinationOrigin
;
1442 ScrollScreenBufferRequest
->Fill
= *lpFill
;
1444 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1446 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepScrollScreenBuffer
),
1447 sizeof(CONSOLE_SCROLLSCREENBUFFER
));
1449 if (!NT_SUCCESS(Status
))
1451 BaseSetLastNTError(Status
);
1459 /*--------------------------------------------------------------
1460 * ScrollConsoleScreenBufferA
1466 ScrollConsoleScreenBufferA(HANDLE hConsoleOutput
,
1467 CONST SMALL_RECT
*lpScrollRectangle
,
1468 CONST SMALL_RECT
*lpClipRectangle
,
1469 COORD dwDestinationOrigin
,
1470 CONST CHAR_INFO
*lpFill
)
1472 return IntScrollConsoleScreenBuffer(hConsoleOutput
,
1473 (PSMALL_RECT
)lpScrollRectangle
,
1474 (PSMALL_RECT
)lpClipRectangle
,
1475 dwDestinationOrigin
,
1481 /*--------------------------------------------------------------
1482 * ScrollConsoleScreenBufferW
1488 ScrollConsoleScreenBufferW(HANDLE hConsoleOutput
,
1489 CONST SMALL_RECT
*lpScrollRectangle
,
1490 CONST SMALL_RECT
*lpClipRectangle
,
1491 COORD dwDestinationOrigin
,
1492 CONST CHAR_INFO
*lpFill
)
1494 return IntScrollConsoleScreenBuffer(hConsoleOutput
,
1497 dwDestinationOrigin
,
1503 /*--------------------------------------------------------------
1504 * SetConsoleWindowInfo
1510 SetConsoleWindowInfo(HANDLE hConsoleOutput
,
1512 CONST SMALL_RECT
*lpConsoleWindow
)
1515 CONSOLE_API_MESSAGE ApiMessage
;
1516 PCONSOLE_SETWINDOWINFO SetWindowInfoRequest
= &ApiMessage
.Data
.SetWindowInfoRequest
;
1518 if (lpConsoleWindow
== NULL
)
1520 SetLastError(ERROR_INVALID_PARAMETER
);
1524 SetWindowInfoRequest
->OutputHandle
= hConsoleOutput
;
1525 SetWindowInfoRequest
->Absolute
= bAbsolute
;
1526 SetWindowInfoRequest
->WindowRect
= *lpConsoleWindow
;
1528 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1530 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetWindowInfo
),
1531 sizeof(CONSOLE_SETWINDOWINFO
));
1532 if (!NT_SUCCESS(Status
))
1534 BaseSetLastNTError(Status
);
1542 /*--------------------------------------------------------------
1543 * SetConsoleTextAttribute
1549 SetConsoleTextAttribute(HANDLE hConsoleOutput
,
1553 CONSOLE_API_MESSAGE ApiMessage
;
1555 ApiMessage
.Data
.SetTextAttribRequest
.OutputHandle
= hConsoleOutput
;
1556 ApiMessage
.Data
.SetTextAttribRequest
.Attrib
= wAttributes
;
1558 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1560 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetTextAttribute
),
1561 sizeof(CONSOLE_SETTEXTATTRIB
));
1562 if (!NT_SUCCESS(Status
))
1564 BaseSetLastNTError(Status
);
1574 AddConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine
)
1576 PHANDLER_ROUTINE
* NewCtrlHandlers
= NULL
;
1578 if (HandlerRoutine
== NULL
)
1580 NtCurrentPeb()->ProcessParameters
->ConsoleFlags
= TRUE
;
1584 if (NrCtrlHandlers
== NrAllocatedHandlers
)
1586 NewCtrlHandlers
= RtlAllocateHeap(RtlGetProcessHeap(),
1588 (NrCtrlHandlers
+ 4) * sizeof(PHANDLER_ROUTINE
));
1589 if (NewCtrlHandlers
== NULL
)
1591 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1595 memmove(NewCtrlHandlers
, CtrlHandlers
, sizeof(PHANDLER_ROUTINE
) * NrCtrlHandlers
);
1597 if (NrAllocatedHandlers
> 1) RtlFreeHeap(RtlGetProcessHeap(), 0, CtrlHandlers
);
1599 CtrlHandlers
= NewCtrlHandlers
;
1600 NrAllocatedHandlers
+= 4;
1603 ASSERT(NrCtrlHandlers
< NrAllocatedHandlers
);
1605 CtrlHandlers
[NrCtrlHandlers
++] = HandlerRoutine
;
1612 RemoveConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine
)
1616 if (HandlerRoutine
== NULL
)
1618 NtCurrentPeb()->ProcessParameters
->ConsoleFlags
= FALSE
;
1622 for (i
= 0; i
< NrCtrlHandlers
; i
++)
1624 if (CtrlHandlers
[i
] == HandlerRoutine
)
1626 if (i
< (NrCtrlHandlers
- 1))
1628 memmove(&CtrlHandlers
[i
],
1630 (NrCtrlHandlers
- i
+ 1) * sizeof(PHANDLER_ROUTINE
));
1638 SetLastError(ERROR_INVALID_PARAMETER
);
1648 SetConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine
,
1653 RtlEnterCriticalSection(&BaseDllDirectoryLock
);
1656 Ret
= AddConsoleCtrlHandler(HandlerRoutine
);
1660 Ret
= RemoveConsoleCtrlHandler(HandlerRoutine
);
1663 RtlLeaveCriticalSection(&BaseDllDirectoryLock
);
1668 /*--------------------------------------------------------------
1669 * GenerateConsoleCtrlEvent
1675 GenerateConsoleCtrlEvent(DWORD dwCtrlEvent
,
1676 DWORD dwProcessGroupId
)
1679 CONSOLE_API_MESSAGE ApiMessage
;
1681 if (dwCtrlEvent
!= CTRL_C_EVENT
&& dwCtrlEvent
!= CTRL_BREAK_EVENT
)
1683 SetLastError(ERROR_INVALID_PARAMETER
);
1687 ApiMessage
.Data
.GenerateCtrlEventRequest
.Event
= dwCtrlEvent
;
1688 ApiMessage
.Data
.GenerateCtrlEventRequest
.ProcessGroup
= dwProcessGroupId
;
1690 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1692 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGenerateCtrlEvent
),
1693 sizeof(CONSOLE_GENERATECTRLEVENT
));
1694 if (!NT_SUCCESS(Status
))
1696 BaseSetLastNTError(Status
);
1705 IntGetConsoleTitle(LPVOID lpConsoleTitle
, DWORD nSize
, BOOL bUnicode
)
1708 CONSOLE_API_MESSAGE ApiMessage
;
1709 PCONSOLE_GETSETCONSOLETITLE TitleRequest
= &ApiMessage
.Data
.TitleRequest
;
1710 PCSR_CAPTURE_BUFFER CaptureBuffer
;
1712 if (nSize
== 0) return 0;
1714 TitleRequest
->Length
= nSize
* (bUnicode
? 1 : sizeof(WCHAR
));
1715 CaptureBuffer
= CsrAllocateCaptureBuffer(1, TitleRequest
->Length
);
1716 if (CaptureBuffer
== NULL
)
1718 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
1719 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1723 CsrAllocateMessagePointer(CaptureBuffer
,
1724 TitleRequest
->Length
,
1725 (PVOID
*)&TitleRequest
->Title
);
1727 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1729 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetTitle
),
1730 sizeof(CONSOLE_GETSETCONSOLETITLE
));
1731 if (!NT_SUCCESS(Status
))
1733 CsrFreeCaptureBuffer(CaptureBuffer
);
1734 BaseSetLastNTError(Status
);
1740 if (nSize
>= sizeof(WCHAR
))
1741 wcscpy((LPWSTR
)lpConsoleTitle
, TitleRequest
->Title
);
1745 if (nSize
< TitleRequest
->Length
/ sizeof(WCHAR
) ||
1746 !WideCharToMultiByte(CP_ACP
, // ANSI code page
1747 0, // performance and mapping flags
1748 TitleRequest
->Title
, // address of wide-character string
1749 -1, // number of characters in string
1750 (LPSTR
)lpConsoleTitle
, // address of buffer for new string
1751 nSize
, // size of buffer
1755 /* Yes, if the buffer isn't big enough, it returns 0... Bad API */
1756 *(LPSTR
)lpConsoleTitle
= '\0';
1757 TitleRequest
->Length
= 0;
1760 CsrFreeCaptureBuffer(CaptureBuffer
);
1762 return TitleRequest
->Length
/ sizeof(WCHAR
);
1766 /*--------------------------------------------------------------
1773 GetConsoleTitleW(LPWSTR lpConsoleTitle
,
1776 return IntGetConsoleTitle(lpConsoleTitle
, nSize
, TRUE
);
1780 /*--------------------------------------------------------------
1787 GetConsoleTitleA(LPSTR lpConsoleTitle
,
1790 return IntGetConsoleTitle(lpConsoleTitle
, nSize
, FALSE
);
1794 /*--------------------------------------------------------------
1801 SetConsoleTitleW(LPCWSTR lpConsoleTitle
)
1804 CONSOLE_API_MESSAGE ApiMessage
;
1805 PCONSOLE_GETSETCONSOLETITLE TitleRequest
= &ApiMessage
.Data
.TitleRequest
;
1806 PCSR_CAPTURE_BUFFER CaptureBuffer
;
1808 TitleRequest
->Length
= wcslen(lpConsoleTitle
) * sizeof(WCHAR
);
1810 CaptureBuffer
= CsrAllocateCaptureBuffer(1, TitleRequest
->Length
);
1811 if (CaptureBuffer
== NULL
)
1813 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
1814 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1818 CsrCaptureMessageBuffer(CaptureBuffer
,
1819 (PVOID
)lpConsoleTitle
,
1820 TitleRequest
->Length
,
1821 (PVOID
*)&TitleRequest
->Title
);
1823 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1825 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetTitle
),
1826 sizeof(CONSOLE_GETSETCONSOLETITLE
));
1828 CsrFreeCaptureBuffer(CaptureBuffer
);
1830 if (!NT_SUCCESS(Status
))
1832 BaseSetLastNTError(Status
);
1840 /*--------------------------------------------------------------
1847 SetConsoleTitleA(LPCSTR lpConsoleTitle
)
1850 ULONG Length
= strlen(lpConsoleTitle
) + 1;
1851 LPWSTR WideTitle
= HeapAlloc(GetProcessHeap(), 0, Length
* sizeof(WCHAR
));
1855 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1859 MultiByteToWideChar(CP_ACP
, 0, lpConsoleTitle
, -1, WideTitle
, Length
);
1861 Ret
= SetConsoleTitleW(WideTitle
);
1863 HeapFree(GetProcessHeap(), 0, WideTitle
);
1868 /*--------------------------------------------------------------
1869 * CreateConsoleScreenBuffer
1875 CreateConsoleScreenBuffer(DWORD dwDesiredAccess
,
1877 CONST SECURITY_ATTRIBUTES
*lpSecurityAttributes
,
1879 LPVOID lpScreenBufferData
)
1882 CONSOLE_API_MESSAGE ApiMessage
;
1883 PCONSOLE_CREATESCREENBUFFER CreateScreenBufferRequest
= &ApiMessage
.Data
.CreateScreenBufferRequest
;
1884 PCSR_CAPTURE_BUFFER CaptureBuffer
= NULL
;
1885 PCONSOLE_GRAPHICS_BUFFER_INFO GraphicsBufferInfo
= /*(PCONSOLE_GRAPHICS_BUFFER_INFO)*/lpScreenBufferData
;
1887 if ( (dwDesiredAccess
& ~(GENERIC_READ
| GENERIC_WRITE
)) ||
1888 (dwShareMode
& ~(FILE_SHARE_READ
| FILE_SHARE_WRITE
)) ||
1889 (dwFlags
!= CONSOLE_TEXTMODE_BUFFER
&& dwFlags
!= CONSOLE_GRAPHICS_BUFFER
) )
1891 SetLastError(ERROR_INVALID_PARAMETER
);
1892 return INVALID_HANDLE_VALUE
;
1895 CreateScreenBufferRequest
->ScreenBufferType
= dwFlags
;
1896 CreateScreenBufferRequest
->Access
= dwDesiredAccess
;
1897 CreateScreenBufferRequest
->ShareMode
= dwShareMode
;
1898 CreateScreenBufferRequest
->Inheritable
=
1899 (lpSecurityAttributes
? lpSecurityAttributes
->bInheritHandle
: FALSE
);
1901 if (dwFlags
== CONSOLE_GRAPHICS_BUFFER
)
1903 if (CreateScreenBufferRequest
->Inheritable
|| GraphicsBufferInfo
== NULL
)
1905 SetLastError(ERROR_INVALID_PARAMETER
);
1906 return INVALID_HANDLE_VALUE
;
1909 CreateScreenBufferRequest
->GraphicsBufferInfo
= *GraphicsBufferInfo
;
1911 CaptureBuffer
= CsrAllocateCaptureBuffer(1, GraphicsBufferInfo
->dwBitMapInfoLength
);
1912 if (CaptureBuffer
== NULL
)
1914 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1918 CsrCaptureMessageBuffer(CaptureBuffer
,
1919 (PVOID
)GraphicsBufferInfo
->lpBitMapInfo
,
1920 GraphicsBufferInfo
->dwBitMapInfoLength
,
1921 (PVOID
*)&CreateScreenBufferRequest
->GraphicsBufferInfo
.lpBitMapInfo
);
1924 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1926 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepCreateScreenBuffer
),
1927 sizeof(CONSOLE_CREATESCREENBUFFER
));
1930 CsrFreeCaptureBuffer(CaptureBuffer
);
1932 if (!NT_SUCCESS(Status
))
1934 BaseSetLastNTError(Status
);
1935 return INVALID_HANDLE_VALUE
;
1938 if (dwFlags
== CONSOLE_GRAPHICS_BUFFER
&& GraphicsBufferInfo
)
1940 GraphicsBufferInfo
->hMutex
= CreateScreenBufferRequest
->GraphicsBufferInfo
.hMutex
;
1941 GraphicsBufferInfo
->lpBitMap
= CreateScreenBufferRequest
->GraphicsBufferInfo
.lpBitMap
;
1944 return CreateScreenBufferRequest
->OutputHandle
;
1948 /*--------------------------------------------------------------
1958 CONSOLE_API_MESSAGE ApiMessage
;
1960 /* Get the Input Code Page */
1961 ApiMessage
.Data
.ConsoleCPRequest
.InputCP
= TRUE
;
1962 ApiMessage
.Data
.ConsoleCPRequest
.CodePage
= 0;
1964 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1966 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetCP
),
1967 sizeof(CONSOLE_GETSETINPUTOUTPUTCP
));
1969 if (!NT_SUCCESS(Status
)) BaseSetLastNTError(Status
);
1971 return ApiMessage
.Data
.ConsoleCPRequest
.CodePage
;
1975 /*--------------------------------------------------------------
1982 SetConsoleCP(UINT wCodePageID
)
1985 CONSOLE_API_MESSAGE ApiMessage
;
1987 /* Set the Input Code Page */
1988 ApiMessage
.Data
.ConsoleCPRequest
.InputCP
= TRUE
;
1989 ApiMessage
.Data
.ConsoleCPRequest
.CodePage
= wCodePageID
;
1991 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1993 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetCP
),
1994 sizeof(CONSOLE_GETSETINPUTOUTPUTCP
));
1996 if (!NT_SUCCESS(Status
)) BaseSetLastNTError(Status
);
1998 return NT_SUCCESS(Status
);
2002 /*--------------------------------------------------------------
2003 * GetConsoleOutputCP
2009 GetConsoleOutputCP(VOID
)
2012 CONSOLE_API_MESSAGE ApiMessage
;
2014 /* Get the Output Code Page */
2015 ApiMessage
.Data
.ConsoleCPRequest
.InputCP
= FALSE
;
2016 ApiMessage
.Data
.ConsoleCPRequest
.CodePage
= 0;
2018 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
2020 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetCP
),
2021 sizeof(CONSOLE_GETSETINPUTOUTPUTCP
));
2023 if (!NT_SUCCESS(Status
)) BaseSetLastNTError(Status
);
2025 return ApiMessage
.Data
.ConsoleCPRequest
.CodePage
;
2029 /*--------------------------------------------------------------
2030 * SetConsoleOutputCP
2036 SetConsoleOutputCP(UINT wCodePageID
)
2039 CONSOLE_API_MESSAGE ApiMessage
;
2041 /* Set the Output Code Page */
2042 ApiMessage
.Data
.ConsoleCPRequest
.InputCP
= FALSE
;
2043 ApiMessage
.Data
.ConsoleCPRequest
.CodePage
= wCodePageID
;
2045 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
2047 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetCP
),
2048 sizeof(CONSOLE_GETSETINPUTOUTPUTCP
));
2050 if (!NT_SUCCESS(Status
)) BaseSetLastNTError(Status
);
2052 return NT_SUCCESS(Status
);
2056 /*--------------------------------------------------------------
2057 * GetConsoleProcessList
2063 GetConsoleProcessList(LPDWORD lpdwProcessList
,
2064 DWORD dwProcessCount
)
2067 CONSOLE_API_MESSAGE ApiMessage
;
2068 PCONSOLE_GETPROCESSLIST GetProcessListRequest
= &ApiMessage
.Data
.GetProcessListRequest
;
2069 PCSR_CAPTURE_BUFFER CaptureBuffer
;
2072 if (lpdwProcessList
== NULL
|| dwProcessCount
== 0)
2074 SetLastError(ERROR_INVALID_PARAMETER
);
2078 CaptureBuffer
= CsrAllocateCaptureBuffer(1, dwProcessCount
* sizeof(DWORD
));
2079 if (CaptureBuffer
== NULL
)
2081 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
2082 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
2086 GetProcessListRequest
->nMaxIds
= dwProcessCount
;
2088 CsrAllocateMessagePointer(CaptureBuffer
,
2089 dwProcessCount
* sizeof(DWORD
),
2090 (PVOID
*)&GetProcessListRequest
->pProcessIds
);
2092 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
2094 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetProcessList
),
2095 sizeof(CONSOLE_GETPROCESSLIST
));
2096 if (!NT_SUCCESS(Status
))
2098 BaseSetLastNTError (Status
);
2103 nProcesses
= GetProcessListRequest
->nProcessIdsTotal
;
2104 if (dwProcessCount
>= nProcesses
)
2106 memcpy(lpdwProcessList
, GetProcessListRequest
->pProcessIds
, nProcesses
* sizeof(DWORD
));
2110 CsrFreeCaptureBuffer(CaptureBuffer
);
2115 /*--------------------------------------------------------------
2116 * GetConsoleSelectionInfo
2122 GetConsoleSelectionInfo(PCONSOLE_SELECTION_INFO lpConsoleSelectionInfo
)
2125 CONSOLE_API_MESSAGE ApiMessage
;
2127 if (lpConsoleSelectionInfo
== NULL
)
2129 SetLastError(ERROR_INVALID_PARAMETER
);
2133 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
2135 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetSelectionInfo
),
2136 sizeof(CONSOLE_GETSELECTIONINFO
));
2137 if (!NT_SUCCESS(Status
))
2139 BaseSetLastNTError(Status
);
2143 *lpConsoleSelectionInfo
= ApiMessage
.Data
.GetSelectionInfoRequest
.Info
;
2148 /*--------------------------------------------------------------
2153 * @note Strongly inspired by AllocConsole.
2157 AttachConsole(DWORD dwProcessId
)
2160 PRTL_USER_PROCESS_PARAMETERS Parameters
= NtCurrentPeb()->ProcessParameters
;
2161 CONSOLE_API_MESSAGE ApiMessage
;
2162 PCONSOLE_ATTACHCONSOLE AttachConsoleRequest
= &ApiMessage
.Data
.AttachConsoleRequest
;
2164 if (Parameters
->ConsoleHandle
)
2166 DPRINT1("AttachConsole: Attaching a console to a process already having one\n");
2167 SetLastError(ERROR_ACCESS_DENIED
);
2171 AttachConsoleRequest
->ProcessId
= dwProcessId
;
2172 AttachConsoleRequest
->CtrlDispatcher
= ConsoleControlDispatcher
;
2173 AttachConsoleRequest
->PropDispatcher
= PropDialogHandler
;
2175 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
2177 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepAttach
),
2178 sizeof(CONSOLE_ATTACHCONSOLE
));
2179 if (!NT_SUCCESS(Status
))
2181 BaseSetLastNTError(Status
);
2185 Parameters
->ConsoleHandle
= AttachConsoleRequest
->Console
;
2186 SetStdHandle(STD_INPUT_HANDLE
, AttachConsoleRequest
->InputHandle
);
2187 SetStdHandle(STD_OUTPUT_HANDLE
, AttachConsoleRequest
->OutputHandle
);
2188 SetStdHandle(STD_ERROR_HANDLE
, AttachConsoleRequest
->ErrorHandle
);
2190 /* Initialize Console Ctrl Handler */
2191 InitConsoleCtrlHandling();
2193 InputWaitHandle
= AttachConsoleRequest
->InputWaitHandle
;
2199 /*--------------------------------------------------------------
2206 GetConsoleWindow(VOID
)
2209 CONSOLE_API_MESSAGE ApiMessage
;
2211 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
2213 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetConsoleWindow
),
2214 sizeof(CONSOLE_GETWINDOW
));
2215 if (!NT_SUCCESS(Status
))
2217 BaseSetLastNTError(Status
);
2221 return ApiMessage
.Data
.GetWindowRequest
.WindowHandle
;
2225 /*--------------------------------------------------------------
2232 SetConsoleIcon(HICON hicon
)
2235 CONSOLE_API_MESSAGE ApiMessage
;
2237 ApiMessage
.Data
.SetIconRequest
.WindowIcon
= hicon
;
2239 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
2241 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetIcon
),
2242 sizeof(CONSOLE_SETICON
));
2243 if (!NT_SUCCESS(Status
))
2245 BaseSetLastNTError(Status
);
2249 return NT_SUCCESS(Status
);
2253 /******************************************************************************
2254 * \name SetConsoleInputExeNameW
2255 * \brief Sets the console input file name from a unicode string.
2256 * \param lpInputExeName Pointer to a unicode string with the name.
2257 * \return TRUE if successful, FALSE if unsuccsedful.
2258 * \remarks If lpInputExeName is 0 or the string length is 0 or greater than 255,
2259 * the function fails and sets last error to ERROR_INVALID_PARAMETER.
2263 SetConsoleInputExeNameW(LPCWSTR lpInputExeName
)
2267 if ( !lpInputExeName
||
2268 (lenName
= lstrlenW(lpInputExeName
)) == 0 ||
2269 lenName
> INPUTEXENAME_BUFLEN
- 1 )
2271 /* Fail if string is empty or too long */
2272 SetLastError(ERROR_INVALID_PARAMETER
);
2276 RtlEnterCriticalSection(&ConsoleLock
);
2279 RtlCopyMemory(InputExeName
, lpInputExeName
, lenName
* sizeof(WCHAR
));
2280 InputExeName
[lenName
] = L
'\0';
2284 RtlLeaveCriticalSection(&ConsoleLock
);
2292 /******************************************************************************
2293 * \name SetConsoleInputExeNameA
2294 * \brief Sets the console input file name from an ansi string.
2295 * \param lpInputExeName Pointer to an ansi string with the name.
2296 * \return TRUE if successful, FALSE if unsuccsedful.
2297 * \remarks If lpInputExeName is 0 or the string length is 0 or greater than 255,
2298 * the function fails and sets last error to ERROR_INVALID_PARAMETER.
2302 SetConsoleInputExeNameA(LPCSTR lpInputExeName
)
2304 WCHAR Buffer
[INPUTEXENAME_BUFLEN
];
2305 ANSI_STRING InputExeNameA
;
2306 UNICODE_STRING InputExeNameU
;
2309 RtlInitAnsiString(&InputExeNameA
, lpInputExeName
);
2311 if ( InputExeNameA
.Length
== 0 ||
2312 InputExeNameA
.Length
> INPUTEXENAME_BUFLEN
- 1 )
2314 /* Fail if string is empty or too long */
2315 SetLastError(ERROR_INVALID_PARAMETER
);
2319 InputExeNameU
.Buffer
= Buffer
;
2320 InputExeNameU
.MaximumLength
= sizeof(Buffer
);
2321 InputExeNameU
.Length
= 0;
2323 Status
= RtlAnsiStringToUnicodeString(&InputExeNameU
, &InputExeNameA
, FALSE
);
2324 if (!NT_SUCCESS(Status
))
2326 BaseSetLastNTError(Status
);
2330 return SetConsoleInputExeNameW(InputExeNameU
.Buffer
);
2334 /******************************************************************************
2335 * \name GetConsoleInputExeNameW
2336 * \brief Retrieves the console input file name as unicode string.
2337 * \param nBufferLength Length of the buffer in WCHARs.
2338 * Specify 0 to receive the needed buffer length.
2339 * \param lpBuffer Pointer to a buffer that receives the string.
2340 * \return Needed buffer size if \p nBufferLength is 0.
2341 * Otherwise 1 if successful, 2 if buffer is too small.
2342 * \remarks Sets last error value to ERROR_BUFFER_OVERFLOW if the buffer
2343 * is not big enough.
2347 GetConsoleInputExeNameW(DWORD nBufferLength
, LPWSTR lpBuffer
)
2349 ULONG lenName
= lstrlenW(InputExeName
);
2351 if (nBufferLength
== 0)
2353 /* Buffer size is requested, return it */
2357 if (lenName
+ 1 > nBufferLength
)
2359 /* Buffer is not large enough! */
2360 SetLastError(ERROR_BUFFER_OVERFLOW
);
2364 RtlEnterCriticalSection(&ConsoleLock
);
2367 RtlCopyMemory(lpBuffer
, InputExeName
, lenName
* sizeof(WCHAR
));
2368 lpBuffer
[lenName
] = '\0';
2372 RtlLeaveCriticalSection(&ConsoleLock
);
2376 /* Success, return 1 */
2381 /******************************************************************************
2382 * \name GetConsoleInputExeNameA
2383 * \brief Retrieves the console input file name as ansi string.
2384 * \param nBufferLength Length of the buffer in CHARs.
2385 * \param lpBuffer Pointer to a buffer that receives the string.
2386 * \return 1 if successful, 2 if buffer is too small.
2387 * \remarks Sets last error value to ERROR_BUFFER_OVERFLOW if the buffer
2388 * is not big enough. The buffer receives as much characters as fit.
2392 GetConsoleInputExeNameA(DWORD nBufferLength
, LPSTR lpBuffer
)
2394 WCHAR Buffer
[INPUTEXENAME_BUFLEN
];
2396 UNICODE_STRING BufferU
;
2397 ANSI_STRING BufferA
;
2399 /* Get the unicode name */
2400 Ret
= GetConsoleInputExeNameW(sizeof(Buffer
) / sizeof(Buffer
[0]), Buffer
);
2402 /* Initialize strings for conversion */
2403 RtlInitUnicodeString(&BufferU
, Buffer
);
2405 BufferA
.MaximumLength
= (USHORT
)nBufferLength
;
2406 BufferA
.Buffer
= lpBuffer
;
2408 /* Convert unicode name to ansi, copying as much chars as fit */
2409 RtlUnicodeStringToAnsiString(&BufferA
, &BufferU
, FALSE
);
2411 /* Error handling */
2412 if (nBufferLength
<= BufferU
.Length
/ sizeof(WCHAR
))
2414 SetLastError(ERROR_BUFFER_OVERFLOW
);
2423 GetConsoleCharType(HANDLE hConsole
, COORD Coord
, PDWORD Type
)
2431 GetConsoleCursorMode(HANDLE hConsole
, PBOOL pUnknown1
, PBOOL pUnknown2
)
2439 GetConsoleNlsMode(HANDLE hConsole
, LPDWORD lpMode
)
2447 SetConsoleCursorMode(HANDLE hConsole
, BOOL Unknown1
, BOOL Unknown2
)
2455 SetConsoleLocalEUDC(DWORD Unknown1
, DWORD Unknown2
, DWORD Unknown3
, DWORD Unknown4
)
2463 SetConsoleNlsMode(HANDLE hConsole
, DWORD dwMode
)
2471 RegisterConsoleIME(HWND hWnd
, LPDWORD ThreadId
)
2479 RegisterConsoleOS2(BOOL bUnknown
)
2487 SetConsoleOS2OemFormat(BOOL bUnknown
)
2495 UnregisterConsoleIME(VOID
)
2505 BOOL WINAPI
GetConsoleKeyboardLayoutNameA(LPSTR name
)
2514 BOOL WINAPI
GetConsoleKeyboardLayoutNameW(LPWSTR name
)
2525 SetLastConsoleEventActive(VOID
)