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
))
807 * @implemented (Undocumented)
811 CloseConsoleHandle(HANDLE Handle
)
814 CONSOLE_API_MESSAGE ApiMessage
;
816 ApiMessage
.Data
.CloseHandleRequest
.ConsoleHandle
= Handle
;
818 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
820 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepCloseHandle
),
821 sizeof(CONSOLE_CLOSEHANDLE
));
822 if (!NT_SUCCESS(Status
))
824 BaseSetLastNTError(Status
);
837 GetStdHandle(DWORD nStdHandle
)
839 * FUNCTION: Get a handle for the standard input, standard output
840 * and a standard error device.
843 * nStdHandle - Specifies the device for which to return the handle.
845 * RETURNS: If the function succeeds, the return value is the handle
846 * of the specified device. Otherwise the value is INVALID_HANDLE_VALUE.
849 PRTL_USER_PROCESS_PARAMETERS Ppb
= NtCurrentPeb()->ProcessParameters
;
853 case STD_INPUT_HANDLE
:
854 return Ppb
->StandardInput
;
856 case STD_OUTPUT_HANDLE
:
857 return Ppb
->StandardOutput
;
859 case STD_ERROR_HANDLE
:
860 return Ppb
->StandardError
;
863 SetLastError(ERROR_INVALID_HANDLE
);
864 return INVALID_HANDLE_VALUE
;
873 SetStdHandle(DWORD nStdHandle
,
876 * FUNCTION: Set the handle for the standard input, standard output or
877 * the standard error device.
880 * nStdHandle - Specifies the handle to be set.
881 * hHandle - The handle to set.
883 * RETURNS: TRUE if the function succeeds, FALSE otherwise.
886 PRTL_USER_PROCESS_PARAMETERS Ppb
= NtCurrentPeb()->ProcessParameters
;
888 /* no need to check if hHandle == INVALID_HANDLE_VALUE */
892 case STD_INPUT_HANDLE
:
893 Ppb
->StandardInput
= hHandle
;
896 case STD_OUTPUT_HANDLE
:
897 Ppb
->StandardOutput
= hHandle
;
900 case STD_ERROR_HANDLE
:
901 Ppb
->StandardError
= hHandle
;
905 /* Windows for whatever reason sets the last error to ERROR_INVALID_HANDLE here */
906 SetLastError(ERROR_INVALID_HANDLE
);
911 /*--------------------------------------------------------------
921 PRTL_USER_PROCESS_PARAMETERS Parameters
= NtCurrentPeb()->ProcessParameters
;
922 CONSOLE_API_MESSAGE ApiMessage
;
923 PCONSOLE_ALLOCCONSOLE AllocConsoleRequest
= &ApiMessage
.Data
.AllocConsoleRequest
;
924 PCSR_CAPTURE_BUFFER CaptureBuffer
;
926 if (Parameters
->ConsoleHandle
)
928 DPRINT1("AllocConsole: Allocating a console to a process already having one\n");
929 SetLastError(ERROR_ACCESS_DENIED
);
933 CaptureBuffer
= CsrAllocateCaptureBuffer(1, sizeof(CONSOLE_START_INFO
));
934 if (CaptureBuffer
== NULL
)
936 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
937 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
941 CsrAllocateMessagePointer(CaptureBuffer
,
942 sizeof(CONSOLE_START_INFO
),
943 (PVOID
*)&AllocConsoleRequest
->ConsoleStartInfo
);
945 InitConsoleInfo(AllocConsoleRequest
->ConsoleStartInfo
,
946 &Parameters
->ImagePathName
);
948 AllocConsoleRequest
->ConsoleHandle
= NULL
;
949 AllocConsoleRequest
->CtrlDispatcher
= ConsoleControlDispatcher
;
950 AllocConsoleRequest
->PropDispatcher
= PropDialogHandler
;
952 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
954 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepAlloc
),
955 sizeof(CONSOLE_ALLOCCONSOLE
));
957 CsrFreeCaptureBuffer(CaptureBuffer
);
959 if (!NT_SUCCESS(Status
))
961 BaseSetLastNTError(Status
);
965 Parameters
->ConsoleHandle
= AllocConsoleRequest
->ConsoleHandle
;
966 SetStdHandle(STD_INPUT_HANDLE
, AllocConsoleRequest
->InputHandle
);
967 SetStdHandle(STD_OUTPUT_HANDLE
, AllocConsoleRequest
->OutputHandle
);
968 SetStdHandle(STD_ERROR_HANDLE
, AllocConsoleRequest
->ErrorHandle
);
970 /* Initialize Console Ctrl Handler */
971 InitConsoleCtrlHandling();
973 InputWaitHandle
= AllocConsoleRequest
->InputWaitHandle
;
979 /*--------------------------------------------------------------
988 // AG: I'm not sure if this is correct (what happens to std handles?)
989 // but I just tried to reverse what AllocConsole() does...
992 CONSOLE_API_MESSAGE ApiMessage
;
994 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
996 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepFree
),
997 sizeof(CONSOLE_FREECONSOLE
));
998 if (!NT_SUCCESS(Status
))
1000 BaseSetLastNTError(Status
);
1004 NtCurrentPeb()->ProcessParameters
->ConsoleHandle
= NULL
;
1006 CloseHandle(InputWaitHandle
);
1007 InputWaitHandle
= INVALID_HANDLE_VALUE
;
1013 /*--------------------------------------------------------------
1014 * GetConsoleScreenBufferInfo
1020 GetConsoleScreenBufferInfo(HANDLE hConsoleOutput
,
1021 PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo
)
1024 CONSOLE_API_MESSAGE ApiMessage
;
1026 if (lpConsoleScreenBufferInfo
== NULL
)
1028 SetLastError(ERROR_INVALID_PARAMETER
);
1032 ApiMessage
.Data
.ScreenBufferInfoRequest
.OutputHandle
= hConsoleOutput
;
1034 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1036 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetScreenBufferInfo
),
1037 sizeof(CONSOLE_GETSCREENBUFFERINFO
));
1038 if (!NT_SUCCESS(Status
))
1040 BaseSetLastNTError(Status
);
1044 *lpConsoleScreenBufferInfo
= ApiMessage
.Data
.ScreenBufferInfoRequest
.Info
;
1050 /*--------------------------------------------------------------
1051 * SetConsoleCursorPosition
1057 SetConsoleCursorPosition(HANDLE hConsoleOutput
,
1058 COORD dwCursorPosition
)
1061 CONSOLE_API_MESSAGE ApiMessage
;
1063 ApiMessage
.Data
.SetCursorPositionRequest
.OutputHandle
= hConsoleOutput
;
1064 ApiMessage
.Data
.SetCursorPositionRequest
.Position
= dwCursorPosition
;
1066 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1068 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetCursorPosition
),
1069 sizeof(CONSOLE_SETCURSORPOSITION
));
1070 if (!NT_SUCCESS(Status
))
1072 BaseSetLastNTError(Status
);
1080 /*--------------------------------------------------------------
1087 GetConsoleMode(HANDLE hConsoleHandle
,
1091 CONSOLE_API_MESSAGE ApiMessage
;
1092 PCONSOLE_GETSETCONSOLEMODE ConsoleModeRequest
= &ApiMessage
.Data
.ConsoleModeRequest
;
1096 SetLastError(ERROR_INVALID_PARAMETER
);
1100 ConsoleModeRequest
->ConsoleHandle
= hConsoleHandle
;
1102 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1104 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetMode
),
1105 sizeof(CONSOLE_GETSETCONSOLEMODE
));
1106 if (!NT_SUCCESS(Status
))
1108 BaseSetLastNTError(Status
);
1112 *lpMode
= ConsoleModeRequest
->ConsoleMode
;
1118 /*--------------------------------------------------------------
1119 * GetNumberOfConsoleInputEvents
1125 GetNumberOfConsoleInputEvents(HANDLE hConsoleInput
,
1126 LPDWORD lpNumberOfEvents
)
1129 CONSOLE_API_MESSAGE ApiMessage
;
1130 PCONSOLE_GETNUMINPUTEVENTS GetNumInputEventsRequest
= &ApiMessage
.Data
.GetNumInputEventsRequest
;
1132 GetNumInputEventsRequest
->InputHandle
= hConsoleInput
;
1133 GetNumInputEventsRequest
->NumInputEvents
= 0;
1135 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1137 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetNumberOfInputEvents
),
1138 sizeof(CONSOLE_GETNUMINPUTEVENTS
));
1139 if (!NT_SUCCESS(Status
))
1141 BaseSetLastNTError(Status
);
1145 if (lpNumberOfEvents
== NULL
)
1147 SetLastError(ERROR_INVALID_ACCESS
);
1151 *lpNumberOfEvents
= GetNumInputEventsRequest
->NumInputEvents
;
1157 /*--------------------------------------------------------------
1158 * GetLargestConsoleWindowSize
1164 GetLargestConsoleWindowSize(HANDLE hConsoleOutput
)
1167 CONSOLE_API_MESSAGE ApiMessage
;
1168 PCONSOLE_GETLARGESTWINDOWSIZE GetLargestWindowSizeRequest
= &ApiMessage
.Data
.GetLargestWindowSizeRequest
;
1170 GetLargestWindowSizeRequest
->OutputHandle
= hConsoleOutput
;
1171 GetLargestWindowSizeRequest
->Size
.X
= 0;
1172 GetLargestWindowSizeRequest
->Size
.Y
= 0;
1174 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1176 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetLargestWindowSize
),
1177 sizeof(CONSOLE_GETLARGESTWINDOWSIZE
));
1178 if (!NT_SUCCESS(Status
))
1180 BaseSetLastNTError(Status
);
1183 DPRINT1("GetLargestConsoleWindowSize, X = %d, Y = %d\n", GetLargestWindowSizeRequest
->Size
.X
, GetLargestWindowSizeRequest
->Size
.Y
);
1184 return GetLargestWindowSizeRequest
->Size
;
1188 /*--------------------------------------------------------------
1189 * GetConsoleCursorInfo
1195 GetConsoleCursorInfo(HANDLE hConsoleOutput
,
1196 PCONSOLE_CURSOR_INFO lpConsoleCursorInfo
)
1199 CONSOLE_API_MESSAGE ApiMessage
;
1201 if (!lpConsoleCursorInfo
)
1203 if (!hConsoleOutput
)
1204 SetLastError(ERROR_INVALID_HANDLE
);
1206 SetLastError(ERROR_INVALID_ACCESS
);
1211 ApiMessage
.Data
.CursorInfoRequest
.OutputHandle
= hConsoleOutput
;
1213 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1215 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetCursorInfo
),
1216 sizeof(CONSOLE_GETSETCURSORINFO
));
1217 if (!NT_SUCCESS(Status
))
1219 BaseSetLastNTError(Status
);
1223 *lpConsoleCursorInfo
= ApiMessage
.Data
.CursorInfoRequest
.Info
;
1229 /*--------------------------------------------------------------
1230 * GetNumberOfConsoleMouseButtons
1236 GetNumberOfConsoleMouseButtons(LPDWORD lpNumberOfMouseButtons
)
1238 DPRINT1("GetNumberOfConsoleMouseButtons(0x%p) UNIMPLEMENTED!\n", lpNumberOfMouseButtons
);
1239 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1244 /*--------------------------------------------------------------
1251 SetConsoleMode(HANDLE hConsoleHandle
,
1255 CONSOLE_API_MESSAGE ApiMessage
;
1256 PCONSOLE_GETSETCONSOLEMODE ConsoleModeRequest
= &ApiMessage
.Data
.ConsoleModeRequest
;
1258 ConsoleModeRequest
->ConsoleHandle
= hConsoleHandle
;
1259 ConsoleModeRequest
->ConsoleMode
= dwMode
;
1261 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1263 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetMode
),
1264 sizeof(CONSOLE_GETSETCONSOLEMODE
));
1265 if (!NT_SUCCESS(Status
))
1267 BaseSetLastNTError(Status
);
1275 /*--------------------------------------------------------------
1276 * SetConsoleActiveScreenBuffer
1282 SetConsoleActiveScreenBuffer(HANDLE hConsoleOutput
)
1285 CONSOLE_API_MESSAGE ApiMessage
;
1287 ApiMessage
.Data
.SetScreenBufferRequest
.OutputHandle
= hConsoleOutput
;
1289 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1291 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetActiveScreenBuffer
),
1292 sizeof(CONSOLE_SETACTIVESCREENBUFFER
));
1293 if (!NT_SUCCESS(Status
))
1295 BaseSetLastNTError(Status
);
1303 /*--------------------------------------------------------------
1304 * FlushConsoleInputBuffer
1310 FlushConsoleInputBuffer(HANDLE hConsoleInput
)
1313 CONSOLE_API_MESSAGE ApiMessage
;
1315 ApiMessage
.Data
.FlushInputBufferRequest
.InputHandle
= hConsoleInput
;
1317 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1319 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepFlushInputBuffer
),
1320 sizeof(CONSOLE_FLUSHINPUTBUFFER
));
1321 if (!NT_SUCCESS(Status
))
1323 BaseSetLastNTError(Status
);
1331 /*--------------------------------------------------------------
1332 * SetConsoleScreenBufferSize
1338 SetConsoleScreenBufferSize(HANDLE hConsoleOutput
,
1342 CONSOLE_API_MESSAGE ApiMessage
;
1344 ApiMessage
.Data
.SetScreenBufferSizeRequest
.OutputHandle
= hConsoleOutput
;
1345 ApiMessage
.Data
.SetScreenBufferSizeRequest
.Size
= dwSize
;
1347 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1349 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetScreenBufferSize
),
1350 sizeof(CONSOLE_SETSCREENBUFFERSIZE
));
1351 if (!NT_SUCCESS(Status
))
1353 BaseSetLastNTError(Status
);
1361 /*--------------------------------------------------------------
1362 * SetConsoleCursorInfo
1368 SetConsoleCursorInfo(HANDLE hConsoleOutput
,
1369 CONST CONSOLE_CURSOR_INFO
*lpConsoleCursorInfo
)
1372 CONSOLE_API_MESSAGE ApiMessage
;
1374 ApiMessage
.Data
.CursorInfoRequest
.OutputHandle
= hConsoleOutput
;
1375 ApiMessage
.Data
.CursorInfoRequest
.Info
= *lpConsoleCursorInfo
;
1377 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1379 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetCursorInfo
),
1380 sizeof(CONSOLE_GETSETCURSORINFO
));
1381 if (!NT_SUCCESS(Status
))
1383 BaseSetLastNTError(Status
);
1393 IntScrollConsoleScreenBuffer(HANDLE hConsoleOutput
,
1394 const SMALL_RECT
*lpScrollRectangle
,
1395 const SMALL_RECT
*lpClipRectangle
,
1396 COORD dwDestinationOrigin
,
1397 const CHAR_INFO
*lpFill
,
1401 CONSOLE_API_MESSAGE ApiMessage
;
1402 PCONSOLE_SCROLLSCREENBUFFER ScrollScreenBufferRequest
= &ApiMessage
.Data
.ScrollScreenBufferRequest
;
1404 ScrollScreenBufferRequest
->OutputHandle
= hConsoleOutput
;
1405 ScrollScreenBufferRequest
->Unicode
= bUnicode
;
1406 ScrollScreenBufferRequest
->ScrollRectangle
= *lpScrollRectangle
;
1408 if (lpClipRectangle
!= NULL
)
1410 ScrollScreenBufferRequest
->UseClipRectangle
= TRUE
;
1411 ScrollScreenBufferRequest
->ClipRectangle
= *lpClipRectangle
;
1415 ScrollScreenBufferRequest
->UseClipRectangle
= FALSE
;
1418 ScrollScreenBufferRequest
->DestinationOrigin
= dwDestinationOrigin
;
1419 ScrollScreenBufferRequest
->Fill
= *lpFill
;
1421 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1423 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepScrollScreenBuffer
),
1424 sizeof(CONSOLE_SCROLLSCREENBUFFER
));
1426 if (!NT_SUCCESS(Status
))
1428 BaseSetLastNTError(Status
);
1436 /*--------------------------------------------------------------
1437 * ScrollConsoleScreenBufferA
1443 ScrollConsoleScreenBufferA(HANDLE hConsoleOutput
,
1444 CONST SMALL_RECT
*lpScrollRectangle
,
1445 CONST SMALL_RECT
*lpClipRectangle
,
1446 COORD dwDestinationOrigin
,
1447 CONST CHAR_INFO
*lpFill
)
1449 return IntScrollConsoleScreenBuffer(hConsoleOutput
,
1450 (PSMALL_RECT
)lpScrollRectangle
,
1451 (PSMALL_RECT
)lpClipRectangle
,
1452 dwDestinationOrigin
,
1458 /*--------------------------------------------------------------
1459 * ScrollConsoleScreenBufferW
1465 ScrollConsoleScreenBufferW(HANDLE hConsoleOutput
,
1466 CONST SMALL_RECT
*lpScrollRectangle
,
1467 CONST SMALL_RECT
*lpClipRectangle
,
1468 COORD dwDestinationOrigin
,
1469 CONST CHAR_INFO
*lpFill
)
1471 return IntScrollConsoleScreenBuffer(hConsoleOutput
,
1474 dwDestinationOrigin
,
1480 /*--------------------------------------------------------------
1481 * SetConsoleWindowInfo
1487 SetConsoleWindowInfo(HANDLE hConsoleOutput
,
1489 CONST SMALL_RECT
*lpConsoleWindow
)
1492 CONSOLE_API_MESSAGE ApiMessage
;
1493 PCONSOLE_SETWINDOWINFO SetWindowInfoRequest
= &ApiMessage
.Data
.SetWindowInfoRequest
;
1495 if (lpConsoleWindow
== NULL
)
1497 SetLastError(ERROR_INVALID_PARAMETER
);
1501 SetWindowInfoRequest
->OutputHandle
= hConsoleOutput
;
1502 SetWindowInfoRequest
->Absolute
= bAbsolute
;
1503 SetWindowInfoRequest
->WindowRect
= *lpConsoleWindow
;
1505 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1507 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetWindowInfo
),
1508 sizeof(CONSOLE_SETWINDOWINFO
));
1509 if (!NT_SUCCESS(Status
))
1511 BaseSetLastNTError(Status
);
1519 /*--------------------------------------------------------------
1520 * SetConsoleTextAttribute
1526 SetConsoleTextAttribute(HANDLE hConsoleOutput
,
1530 CONSOLE_API_MESSAGE ApiMessage
;
1532 ApiMessage
.Data
.SetTextAttribRequest
.OutputHandle
= hConsoleOutput
;
1533 ApiMessage
.Data
.SetTextAttribRequest
.Attrib
= wAttributes
;
1535 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1537 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetTextAttribute
),
1538 sizeof(CONSOLE_SETTEXTATTRIB
));
1539 if (!NT_SUCCESS(Status
))
1541 BaseSetLastNTError(Status
);
1551 AddConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine
)
1553 PHANDLER_ROUTINE
* NewCtrlHandlers
= NULL
;
1555 if (HandlerRoutine
== NULL
)
1557 NtCurrentPeb()->ProcessParameters
->ConsoleFlags
= TRUE
;
1561 if (NrCtrlHandlers
== NrAllocatedHandlers
)
1563 NewCtrlHandlers
= RtlAllocateHeap(RtlGetProcessHeap(),
1565 (NrCtrlHandlers
+ 4) * sizeof(PHANDLER_ROUTINE
));
1566 if (NewCtrlHandlers
== NULL
)
1568 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1572 memmove(NewCtrlHandlers
, CtrlHandlers
, sizeof(PHANDLER_ROUTINE
) * NrCtrlHandlers
);
1574 if (NrAllocatedHandlers
> 1) RtlFreeHeap(RtlGetProcessHeap(), 0, CtrlHandlers
);
1576 CtrlHandlers
= NewCtrlHandlers
;
1577 NrAllocatedHandlers
+= 4;
1580 ASSERT(NrCtrlHandlers
< NrAllocatedHandlers
);
1582 CtrlHandlers
[NrCtrlHandlers
++] = HandlerRoutine
;
1589 RemoveConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine
)
1593 if (HandlerRoutine
== NULL
)
1595 NtCurrentPeb()->ProcessParameters
->ConsoleFlags
= FALSE
;
1599 for (i
= 0; i
< NrCtrlHandlers
; i
++)
1601 if (CtrlHandlers
[i
] == HandlerRoutine
)
1603 if (i
< (NrCtrlHandlers
- 1))
1605 memmove(&CtrlHandlers
[i
],
1607 (NrCtrlHandlers
- i
+ 1) * sizeof(PHANDLER_ROUTINE
));
1615 SetLastError(ERROR_INVALID_PARAMETER
);
1625 SetConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine
,
1630 RtlEnterCriticalSection(&BaseDllDirectoryLock
);
1633 Ret
= AddConsoleCtrlHandler(HandlerRoutine
);
1637 Ret
= RemoveConsoleCtrlHandler(HandlerRoutine
);
1640 RtlLeaveCriticalSection(&BaseDllDirectoryLock
);
1645 /*--------------------------------------------------------------
1646 * GenerateConsoleCtrlEvent
1652 GenerateConsoleCtrlEvent(DWORD dwCtrlEvent
,
1653 DWORD dwProcessGroupId
)
1656 CONSOLE_API_MESSAGE ApiMessage
;
1658 if (dwCtrlEvent
!= CTRL_C_EVENT
&& dwCtrlEvent
!= CTRL_BREAK_EVENT
)
1660 SetLastError(ERROR_INVALID_PARAMETER
);
1664 ApiMessage
.Data
.GenerateCtrlEventRequest
.Event
= dwCtrlEvent
;
1665 ApiMessage
.Data
.GenerateCtrlEventRequest
.ProcessGroup
= dwProcessGroupId
;
1667 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1669 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGenerateCtrlEvent
),
1670 sizeof(CONSOLE_GENERATECTRLEVENT
));
1671 if (!NT_SUCCESS(Status
))
1673 BaseSetLastNTError(Status
);
1682 IntGetConsoleTitle(LPVOID lpConsoleTitle
, DWORD nSize
, BOOL bUnicode
)
1685 CONSOLE_API_MESSAGE ApiMessage
;
1686 PCONSOLE_GETSETCONSOLETITLE TitleRequest
= &ApiMessage
.Data
.TitleRequest
;
1687 PCSR_CAPTURE_BUFFER CaptureBuffer
;
1689 if (nSize
== 0) return 0;
1691 TitleRequest
->Length
= nSize
* (bUnicode
? 1 : sizeof(WCHAR
));
1692 CaptureBuffer
= CsrAllocateCaptureBuffer(1, TitleRequest
->Length
);
1693 if (CaptureBuffer
== NULL
)
1695 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
1696 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1700 CsrAllocateMessagePointer(CaptureBuffer
,
1701 TitleRequest
->Length
,
1702 (PVOID
*)&TitleRequest
->Title
);
1704 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1706 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetTitle
),
1707 sizeof(CONSOLE_GETSETCONSOLETITLE
));
1708 if (!NT_SUCCESS(Status
))
1710 CsrFreeCaptureBuffer(CaptureBuffer
);
1711 BaseSetLastNTError(Status
);
1717 if (nSize
>= sizeof(WCHAR
))
1718 wcscpy((LPWSTR
)lpConsoleTitle
, TitleRequest
->Title
);
1722 if (nSize
< TitleRequest
->Length
/ sizeof(WCHAR
) ||
1723 !WideCharToMultiByte(CP_ACP
, // ANSI code page
1724 0, // performance and mapping flags
1725 TitleRequest
->Title
, // address of wide-character string
1726 -1, // number of characters in string
1727 (LPSTR
)lpConsoleTitle
, // address of buffer for new string
1728 nSize
, // size of buffer
1732 /* Yes, if the buffer isn't big enough, it returns 0... Bad API */
1733 *(LPSTR
)lpConsoleTitle
= '\0';
1734 TitleRequest
->Length
= 0;
1737 CsrFreeCaptureBuffer(CaptureBuffer
);
1739 return TitleRequest
->Length
/ sizeof(WCHAR
);
1743 /*--------------------------------------------------------------
1750 GetConsoleTitleW(LPWSTR lpConsoleTitle
,
1753 return IntGetConsoleTitle(lpConsoleTitle
, nSize
, TRUE
);
1757 /*--------------------------------------------------------------
1764 GetConsoleTitleA(LPSTR lpConsoleTitle
,
1767 return IntGetConsoleTitle(lpConsoleTitle
, nSize
, FALSE
);
1771 /*--------------------------------------------------------------
1778 SetConsoleTitleW(LPCWSTR lpConsoleTitle
)
1781 CONSOLE_API_MESSAGE ApiMessage
;
1782 PCONSOLE_GETSETCONSOLETITLE TitleRequest
= &ApiMessage
.Data
.TitleRequest
;
1783 PCSR_CAPTURE_BUFFER CaptureBuffer
;
1785 TitleRequest
->Length
= wcslen(lpConsoleTitle
) * sizeof(WCHAR
);
1787 CaptureBuffer
= CsrAllocateCaptureBuffer(1, TitleRequest
->Length
);
1788 if (CaptureBuffer
== NULL
)
1790 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
1791 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1795 CsrCaptureMessageBuffer(CaptureBuffer
,
1796 (PVOID
)lpConsoleTitle
,
1797 TitleRequest
->Length
,
1798 (PVOID
*)&TitleRequest
->Title
);
1800 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1802 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetTitle
),
1803 sizeof(CONSOLE_GETSETCONSOLETITLE
));
1805 CsrFreeCaptureBuffer(CaptureBuffer
);
1807 if (!NT_SUCCESS(Status
))
1809 BaseSetLastNTError(Status
);
1817 /*--------------------------------------------------------------
1824 SetConsoleTitleA(LPCSTR lpConsoleTitle
)
1827 ULONG Length
= strlen(lpConsoleTitle
) + 1;
1828 LPWSTR WideTitle
= HeapAlloc(GetProcessHeap(), 0, Length
* sizeof(WCHAR
));
1832 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1836 MultiByteToWideChar(CP_ACP
, 0, lpConsoleTitle
, -1, WideTitle
, Length
);
1838 Ret
= SetConsoleTitleW(WideTitle
);
1840 HeapFree(GetProcessHeap(), 0, WideTitle
);
1845 /*--------------------------------------------------------------
1846 * CreateConsoleScreenBuffer
1852 CreateConsoleScreenBuffer(DWORD dwDesiredAccess
,
1854 CONST SECURITY_ATTRIBUTES
*lpSecurityAttributes
,
1856 LPVOID lpScreenBufferData
)
1859 CONSOLE_API_MESSAGE ApiMessage
;
1860 PCONSOLE_CREATESCREENBUFFER CreateScreenBufferRequest
= &ApiMessage
.Data
.CreateScreenBufferRequest
;
1861 PCSR_CAPTURE_BUFFER CaptureBuffer
= NULL
;
1862 PCONSOLE_GRAPHICS_BUFFER_INFO GraphicsBufferInfo
= /*(PCONSOLE_GRAPHICS_BUFFER_INFO)*/lpScreenBufferData
;
1864 if ( (dwDesiredAccess
& ~(GENERIC_READ
| GENERIC_WRITE
)) ||
1865 (dwShareMode
& ~(FILE_SHARE_READ
| FILE_SHARE_WRITE
)) ||
1866 (dwFlags
!= CONSOLE_TEXTMODE_BUFFER
&& dwFlags
!= CONSOLE_GRAPHICS_BUFFER
) )
1868 SetLastError(ERROR_INVALID_PARAMETER
);
1869 return INVALID_HANDLE_VALUE
;
1872 CreateScreenBufferRequest
->ScreenBufferType
= dwFlags
;
1873 CreateScreenBufferRequest
->Access
= dwDesiredAccess
;
1874 CreateScreenBufferRequest
->ShareMode
= dwShareMode
;
1875 CreateScreenBufferRequest
->Inheritable
=
1876 (lpSecurityAttributes
? lpSecurityAttributes
->bInheritHandle
: FALSE
);
1878 if (dwFlags
== CONSOLE_GRAPHICS_BUFFER
)
1880 if (CreateScreenBufferRequest
->Inheritable
|| GraphicsBufferInfo
== NULL
)
1882 SetLastError(ERROR_INVALID_PARAMETER
);
1883 return INVALID_HANDLE_VALUE
;
1886 CreateScreenBufferRequest
->GraphicsBufferInfo
= *GraphicsBufferInfo
;
1888 CaptureBuffer
= CsrAllocateCaptureBuffer(1, GraphicsBufferInfo
->dwBitMapInfoLength
);
1889 if (CaptureBuffer
== NULL
)
1891 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1895 CsrCaptureMessageBuffer(CaptureBuffer
,
1896 (PVOID
)GraphicsBufferInfo
->lpBitMapInfo
,
1897 GraphicsBufferInfo
->dwBitMapInfoLength
,
1898 (PVOID
*)&CreateScreenBufferRequest
->GraphicsBufferInfo
.lpBitMapInfo
);
1901 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1903 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepCreateScreenBuffer
),
1904 sizeof(CONSOLE_CREATESCREENBUFFER
));
1907 CsrFreeCaptureBuffer(CaptureBuffer
);
1909 if (!NT_SUCCESS(Status
))
1911 BaseSetLastNTError(Status
);
1912 return INVALID_HANDLE_VALUE
;
1915 if (dwFlags
== CONSOLE_GRAPHICS_BUFFER
&& GraphicsBufferInfo
)
1917 GraphicsBufferInfo
->hMutex
= CreateScreenBufferRequest
->GraphicsBufferInfo
.hMutex
;
1918 GraphicsBufferInfo
->lpBitMap
= CreateScreenBufferRequest
->GraphicsBufferInfo
.lpBitMap
;
1921 return CreateScreenBufferRequest
->OutputHandle
;
1925 /*--------------------------------------------------------------
1935 CONSOLE_API_MESSAGE ApiMessage
;
1937 /* Get the Input Code Page */
1938 ApiMessage
.Data
.ConsoleCPRequest
.InputCP
= TRUE
;
1939 ApiMessage
.Data
.ConsoleCPRequest
.CodePage
= 0;
1941 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1943 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetCP
),
1944 sizeof(CONSOLE_GETSETINPUTOUTPUTCP
));
1946 if (!NT_SUCCESS(Status
)) BaseSetLastNTError(Status
);
1948 return ApiMessage
.Data
.ConsoleCPRequest
.CodePage
;
1952 /*--------------------------------------------------------------
1959 SetConsoleCP(UINT wCodePageID
)
1962 CONSOLE_API_MESSAGE ApiMessage
;
1964 /* Set the Input Code Page */
1965 ApiMessage
.Data
.ConsoleCPRequest
.InputCP
= TRUE
;
1966 ApiMessage
.Data
.ConsoleCPRequest
.CodePage
= wCodePageID
;
1968 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1970 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetCP
),
1971 sizeof(CONSOLE_GETSETINPUTOUTPUTCP
));
1973 if (!NT_SUCCESS(Status
)) BaseSetLastNTError(Status
);
1975 return NT_SUCCESS(Status
);
1979 /*--------------------------------------------------------------
1980 * GetConsoleOutputCP
1986 GetConsoleOutputCP(VOID
)
1989 CONSOLE_API_MESSAGE ApiMessage
;
1991 /* Get the Output Code Page */
1992 ApiMessage
.Data
.ConsoleCPRequest
.InputCP
= FALSE
;
1993 ApiMessage
.Data
.ConsoleCPRequest
.CodePage
= 0;
1995 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1997 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetCP
),
1998 sizeof(CONSOLE_GETSETINPUTOUTPUTCP
));
2000 if (!NT_SUCCESS(Status
)) BaseSetLastNTError(Status
);
2002 return ApiMessage
.Data
.ConsoleCPRequest
.CodePage
;
2006 /*--------------------------------------------------------------
2007 * SetConsoleOutputCP
2013 SetConsoleOutputCP(UINT wCodePageID
)
2016 CONSOLE_API_MESSAGE ApiMessage
;
2018 /* Set the Output Code Page */
2019 ApiMessage
.Data
.ConsoleCPRequest
.InputCP
= FALSE
;
2020 ApiMessage
.Data
.ConsoleCPRequest
.CodePage
= wCodePageID
;
2022 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
2024 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetCP
),
2025 sizeof(CONSOLE_GETSETINPUTOUTPUTCP
));
2027 if (!NT_SUCCESS(Status
)) BaseSetLastNTError(Status
);
2029 return NT_SUCCESS(Status
);
2033 /*--------------------------------------------------------------
2034 * GetConsoleProcessList
2040 GetConsoleProcessList(LPDWORD lpdwProcessList
,
2041 DWORD dwProcessCount
)
2044 CONSOLE_API_MESSAGE ApiMessage
;
2045 PCONSOLE_GETPROCESSLIST GetProcessListRequest
= &ApiMessage
.Data
.GetProcessListRequest
;
2046 PCSR_CAPTURE_BUFFER CaptureBuffer
;
2049 if (lpdwProcessList
== NULL
|| dwProcessCount
== 0)
2051 SetLastError(ERROR_INVALID_PARAMETER
);
2055 CaptureBuffer
= CsrAllocateCaptureBuffer(1, dwProcessCount
* sizeof(DWORD
));
2056 if (CaptureBuffer
== NULL
)
2058 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
2059 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
2063 GetProcessListRequest
->nMaxIds
= dwProcessCount
;
2065 CsrAllocateMessagePointer(CaptureBuffer
,
2066 dwProcessCount
* sizeof(DWORD
),
2067 (PVOID
*)&GetProcessListRequest
->pProcessIds
);
2069 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
2071 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetProcessList
),
2072 sizeof(CONSOLE_GETPROCESSLIST
));
2073 if (!NT_SUCCESS(Status
))
2075 BaseSetLastNTError (Status
);
2080 nProcesses
= GetProcessListRequest
->nProcessIdsTotal
;
2081 if (dwProcessCount
>= nProcesses
)
2083 memcpy(lpdwProcessList
, GetProcessListRequest
->pProcessIds
, nProcesses
* sizeof(DWORD
));
2087 CsrFreeCaptureBuffer(CaptureBuffer
);
2092 /*--------------------------------------------------------------
2093 * GetConsoleSelectionInfo
2099 GetConsoleSelectionInfo(PCONSOLE_SELECTION_INFO lpConsoleSelectionInfo
)
2102 CONSOLE_API_MESSAGE ApiMessage
;
2104 if (lpConsoleSelectionInfo
== NULL
)
2106 SetLastError(ERROR_INVALID_PARAMETER
);
2110 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
2112 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetSelectionInfo
),
2113 sizeof(CONSOLE_GETSELECTIONINFO
));
2114 if (!NT_SUCCESS(Status
))
2116 BaseSetLastNTError(Status
);
2120 *lpConsoleSelectionInfo
= ApiMessage
.Data
.GetSelectionInfoRequest
.Info
;
2125 /*--------------------------------------------------------------
2130 * @note Strongly inspired by AllocConsole.
2134 AttachConsole(DWORD dwProcessId
)
2137 PRTL_USER_PROCESS_PARAMETERS Parameters
= NtCurrentPeb()->ProcessParameters
;
2138 CONSOLE_API_MESSAGE ApiMessage
;
2139 PCONSOLE_ATTACHCONSOLE AttachConsoleRequest
= &ApiMessage
.Data
.AttachConsoleRequest
;
2141 if (Parameters
->ConsoleHandle
)
2143 DPRINT1("AttachConsole: Attaching a console to a process already having one\n");
2144 SetLastError(ERROR_ACCESS_DENIED
);
2148 AttachConsoleRequest
->ProcessId
= dwProcessId
;
2149 AttachConsoleRequest
->CtrlDispatcher
= ConsoleControlDispatcher
;
2150 AttachConsoleRequest
->PropDispatcher
= PropDialogHandler
;
2152 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
2154 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepAttach
),
2155 sizeof(CONSOLE_ATTACHCONSOLE
));
2156 if (!NT_SUCCESS(Status
))
2158 BaseSetLastNTError(Status
);
2162 Parameters
->ConsoleHandle
= AttachConsoleRequest
->ConsoleHandle
;
2163 SetStdHandle(STD_INPUT_HANDLE
, AttachConsoleRequest
->InputHandle
);
2164 SetStdHandle(STD_OUTPUT_HANDLE
, AttachConsoleRequest
->OutputHandle
);
2165 SetStdHandle(STD_ERROR_HANDLE
, AttachConsoleRequest
->ErrorHandle
);
2167 /* Initialize Console Ctrl Handler */
2168 InitConsoleCtrlHandling();
2170 InputWaitHandle
= AttachConsoleRequest
->InputWaitHandle
;
2176 /*--------------------------------------------------------------
2183 GetConsoleWindow(VOID
)
2186 CONSOLE_API_MESSAGE ApiMessage
;
2188 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
2190 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetConsoleWindow
),
2191 sizeof(CONSOLE_GETWINDOW
));
2192 if (!NT_SUCCESS(Status
))
2194 BaseSetLastNTError(Status
);
2198 return ApiMessage
.Data
.GetWindowRequest
.WindowHandle
;
2202 /*--------------------------------------------------------------
2209 SetConsoleIcon(HICON hicon
)
2212 CONSOLE_API_MESSAGE ApiMessage
;
2214 ApiMessage
.Data
.SetIconRequest
.WindowIcon
= hicon
;
2216 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
2218 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetIcon
),
2219 sizeof(CONSOLE_SETICON
));
2220 if (!NT_SUCCESS(Status
))
2222 BaseSetLastNTError(Status
);
2226 return NT_SUCCESS(Status
);
2230 /******************************************************************************
2231 * \name SetConsoleInputExeNameW
2232 * \brief Sets the console input file name from a unicode string.
2233 * \param lpInputExeName Pointer to a unicode string with the name.
2234 * \return TRUE if successful, FALSE if unsuccsedful.
2235 * \remarks If lpInputExeName is 0 or the string length is 0 or greater than 255,
2236 * the function fails and sets last error to ERROR_INVALID_PARAMETER.
2240 SetConsoleInputExeNameW(LPCWSTR lpInputExeName
)
2244 if ( !lpInputExeName
||
2245 (lenName
= lstrlenW(lpInputExeName
)) == 0 ||
2246 lenName
> INPUTEXENAME_BUFLEN
- 1 )
2248 /* Fail if string is empty or too long */
2249 SetLastError(ERROR_INVALID_PARAMETER
);
2253 RtlEnterCriticalSection(&ConsoleLock
);
2256 RtlCopyMemory(InputExeName
, lpInputExeName
, lenName
* sizeof(WCHAR
));
2257 InputExeName
[lenName
] = L
'\0';
2261 RtlLeaveCriticalSection(&ConsoleLock
);
2269 /******************************************************************************
2270 * \name SetConsoleInputExeNameA
2271 * \brief Sets the console input file name from an ansi string.
2272 * \param lpInputExeName Pointer to an ansi string with the name.
2273 * \return TRUE if successful, FALSE if unsuccsedful.
2274 * \remarks If lpInputExeName is 0 or the string length is 0 or greater than 255,
2275 * the function fails and sets last error to ERROR_INVALID_PARAMETER.
2279 SetConsoleInputExeNameA(LPCSTR lpInputExeName
)
2281 WCHAR Buffer
[INPUTEXENAME_BUFLEN
];
2282 ANSI_STRING InputExeNameA
;
2283 UNICODE_STRING InputExeNameU
;
2286 RtlInitAnsiString(&InputExeNameA
, lpInputExeName
);
2288 if ( InputExeNameA
.Length
== 0 ||
2289 InputExeNameA
.Length
> INPUTEXENAME_BUFLEN
- 1 )
2291 /* Fail if string is empty or too long */
2292 SetLastError(ERROR_INVALID_PARAMETER
);
2296 InputExeNameU
.Buffer
= Buffer
;
2297 InputExeNameU
.MaximumLength
= sizeof(Buffer
);
2298 InputExeNameU
.Length
= 0;
2300 Status
= RtlAnsiStringToUnicodeString(&InputExeNameU
, &InputExeNameA
, FALSE
);
2301 if (!NT_SUCCESS(Status
))
2303 BaseSetLastNTError(Status
);
2307 return SetConsoleInputExeNameW(InputExeNameU
.Buffer
);
2311 /******************************************************************************
2312 * \name GetConsoleInputExeNameW
2313 * \brief Retrieves the console input file name as unicode string.
2314 * \param nBufferLength Length of the buffer in WCHARs.
2315 * Specify 0 to receive the needed buffer length.
2316 * \param lpBuffer Pointer to a buffer that receives the string.
2317 * \return Needed buffer size if \p nBufferLength is 0.
2318 * Otherwise 1 if successful, 2 if buffer is too small.
2319 * \remarks Sets last error value to ERROR_BUFFER_OVERFLOW if the buffer
2320 * is not big enough.
2324 GetConsoleInputExeNameW(DWORD nBufferLength
, LPWSTR lpBuffer
)
2326 ULONG lenName
= lstrlenW(InputExeName
);
2328 if (nBufferLength
== 0)
2330 /* Buffer size is requested, return it */
2334 if (lenName
+ 1 > nBufferLength
)
2336 /* Buffer is not large enough! */
2337 SetLastError(ERROR_BUFFER_OVERFLOW
);
2341 RtlEnterCriticalSection(&ConsoleLock
);
2344 RtlCopyMemory(lpBuffer
, InputExeName
, lenName
* sizeof(WCHAR
));
2345 lpBuffer
[lenName
] = '\0';
2349 RtlLeaveCriticalSection(&ConsoleLock
);
2353 /* Success, return 1 */
2358 /******************************************************************************
2359 * \name GetConsoleInputExeNameA
2360 * \brief Retrieves the console input file name as ansi string.
2361 * \param nBufferLength Length of the buffer in CHARs.
2362 * \param lpBuffer Pointer to a buffer that receives the string.
2363 * \return 1 if successful, 2 if buffer is too small.
2364 * \remarks Sets last error value to ERROR_BUFFER_OVERFLOW if the buffer
2365 * is not big enough. The buffer receives as much characters as fit.
2369 GetConsoleInputExeNameA(DWORD nBufferLength
, LPSTR lpBuffer
)
2371 WCHAR Buffer
[INPUTEXENAME_BUFLEN
];
2373 UNICODE_STRING BufferU
;
2374 ANSI_STRING BufferA
;
2376 /* Get the unicode name */
2377 Ret
= GetConsoleInputExeNameW(sizeof(Buffer
) / sizeof(Buffer
[0]), Buffer
);
2379 /* Initialize strings for conversion */
2380 RtlInitUnicodeString(&BufferU
, Buffer
);
2382 BufferA
.MaximumLength
= (USHORT
)nBufferLength
;
2383 BufferA
.Buffer
= lpBuffer
;
2385 /* Convert unicode name to ansi, copying as much chars as fit */
2386 RtlUnicodeStringToAnsiString(&BufferA
, &BufferU
, FALSE
);
2388 /* Error handling */
2389 if (nBufferLength
<= BufferU
.Length
/ sizeof(WCHAR
))
2391 SetLastError(ERROR_BUFFER_OVERFLOW
);
2400 GetConsoleCharType(HANDLE hConsole
, COORD Coord
, PDWORD Type
)
2408 GetConsoleCursorMode(HANDLE hConsole
, PBOOL pUnknown1
, PBOOL pUnknown2
)
2416 GetConsoleNlsMode(HANDLE hConsole
, LPDWORD lpMode
)
2424 SetConsoleCursorMode(HANDLE hConsole
, BOOL Unknown1
, BOOL Unknown2
)
2432 SetConsoleLocalEUDC(DWORD Unknown1
, DWORD Unknown2
, DWORD Unknown3
, DWORD Unknown4
)
2440 SetConsoleNlsMode(HANDLE hConsole
, DWORD dwMode
)
2448 RegisterConsoleIME(HWND hWnd
, LPDWORD ThreadId
)
2456 RegisterConsoleOS2(BOOL bUnknown
)
2464 SetConsoleOS2OemFormat(BOOL bUnknown
)
2472 UnregisterConsoleIME(VOID
)
2482 BOOL WINAPI
GetConsoleKeyboardLayoutNameA(LPSTR name
)
2491 BOOL WINAPI
GetConsoleKeyboardLayoutNameW(LPWSTR name
)
2502 SetLastConsoleEventActive(VOID
)