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%x, %d, %d, 0x%x) 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%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(HANDLE hConsoleOutput
,
616 DPRINT1("SetConsoleFont(0x%x, %d) 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(%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)
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
,
724 DPRINT1("SetConsolePalette(0x%x, 0x%x, %d) UNIMPLEMENTED!\n", hConsoleOutput
, hPalette
, dwUsage
);
725 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
726 // Return TRUE so that we don't fail when being used by NTVDM even if not implemented.
731 * @implemented (Undocumented)
732 * @note See http://undoc.airesoft.co.uk/kernel32.dll/ShowConsoleCursor.php
736 ShowConsoleCursor(HANDLE hConsoleOutput
,
739 CONSOLE_API_MESSAGE ApiMessage
;
740 PCONSOLE_SHOWCURSOR ShowCursorRequest
= &ApiMessage
.Data
.ShowCursorRequest
;
742 ShowCursorRequest
->OutputHandle
= hConsoleOutput
;
743 ShowCursorRequest
->Show
= bShow
;
744 ShowCursorRequest
->RefCount
= 0;
746 CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
748 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepShowCursor
),
749 sizeof(CONSOLE_SHOWCURSOR
));
751 return ShowCursorRequest
->RefCount
;
756 * FUNCTION: Checks whether the given handle is a valid console handle.
759 * Handle - Handle to be checked
762 * TRUE: Handle is a valid console handle
763 * FALSE: Handle is not a valid console handle.
765 * STATUS: Officially undocumented
771 VerifyConsoleIoHandle(HANDLE Handle
)
774 CONSOLE_API_MESSAGE ApiMessage
;
776 ApiMessage
.Data
.VerifyHandleRequest
.ConsoleHandle
= Handle
;
778 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
780 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepVerifyIoHandle
),
781 sizeof(CONSOLE_VERIFYHANDLE
));
782 if (!NT_SUCCESS(Status
))
784 BaseSetLastNTError(Status
);
797 WriteConsoleInputVDMA(DWORD Unknown0
,
802 DPRINT1("WriteConsoleInputVDMA(0x%x, 0x%x, 0x%x, 0x%x) UNIMPLEMENTED!\n", Unknown0
, Unknown1
, Unknown2
, Unknown3
);
803 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
813 WriteConsoleInputVDMW(DWORD Unknown0
,
818 DPRINT1("WriteConsoleInputVDMW(0x%x, 0x%x, 0x%x, 0x%x) UNIMPLEMENTED!\n", Unknown0
, Unknown1
, Unknown2
, Unknown3
);
819 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
825 * @implemented (Undocumented)
829 CloseConsoleHandle(HANDLE Handle
)
832 CONSOLE_API_MESSAGE ApiMessage
;
834 ApiMessage
.Data
.CloseHandleRequest
.ConsoleHandle
= Handle
;
836 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
838 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepCloseHandle
),
839 sizeof(CONSOLE_CLOSEHANDLE
));
840 if (!NT_SUCCESS(Status
))
842 BaseSetLastNTError(Status
);
855 GetStdHandle(DWORD nStdHandle
)
857 * FUNCTION: Get a handle for the standard input, standard output
858 * and a standard error device.
861 * nStdHandle - Specifies the device for which to return the handle.
863 * RETURNS: If the function succeeds, the return value is the handle
864 * of the specified device. Otherwise the value is INVALID_HANDLE_VALUE.
867 PRTL_USER_PROCESS_PARAMETERS Ppb
= NtCurrentPeb()->ProcessParameters
;
871 case STD_INPUT_HANDLE
:
872 return Ppb
->StandardInput
;
874 case STD_OUTPUT_HANDLE
:
875 return Ppb
->StandardOutput
;
877 case STD_ERROR_HANDLE
:
878 return Ppb
->StandardError
;
881 SetLastError(ERROR_INVALID_HANDLE
);
882 return INVALID_HANDLE_VALUE
;
891 SetStdHandle(DWORD nStdHandle
,
894 * FUNCTION: Set the handle for the standard input, standard output or
895 * the standard error device.
898 * nStdHandle - Specifies the handle to be set.
899 * hHandle - The handle to set.
901 * RETURNS: TRUE if the function succeeds, FALSE otherwise.
904 PRTL_USER_PROCESS_PARAMETERS Ppb
= NtCurrentPeb()->ProcessParameters
;
906 /* no need to check if hHandle == INVALID_HANDLE_VALUE */
910 case STD_INPUT_HANDLE
:
911 Ppb
->StandardInput
= hHandle
;
914 case STD_OUTPUT_HANDLE
:
915 Ppb
->StandardOutput
= hHandle
;
918 case STD_ERROR_HANDLE
:
919 Ppb
->StandardError
= hHandle
;
923 /* Windows for whatever reason sets the last error to ERROR_INVALID_HANDLE here */
924 SetLastError(ERROR_INVALID_HANDLE
);
929 /*--------------------------------------------------------------
939 PRTL_USER_PROCESS_PARAMETERS Parameters
= NtCurrentPeb()->ProcessParameters
;
940 CONSOLE_API_MESSAGE ApiMessage
;
941 PCONSOLE_ALLOCCONSOLE AllocConsoleRequest
= &ApiMessage
.Data
.AllocConsoleRequest
;
942 PCSR_CAPTURE_BUFFER CaptureBuffer
;
944 if (Parameters
->ConsoleHandle
)
946 DPRINT1("AllocConsole: Allocating a console to a process already having one\n");
947 SetLastError(ERROR_ACCESS_DENIED
);
951 CaptureBuffer
= CsrAllocateCaptureBuffer(1, sizeof(CONSOLE_START_INFO
));
952 if (CaptureBuffer
== NULL
)
954 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
955 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
959 CsrAllocateMessagePointer(CaptureBuffer
,
960 sizeof(CONSOLE_START_INFO
),
961 (PVOID
*)&AllocConsoleRequest
->ConsoleStartInfo
);
963 InitConsoleInfo(AllocConsoleRequest
->ConsoleStartInfo
,
964 &Parameters
->ImagePathName
);
966 AllocConsoleRequest
->ConsoleHandle
= NULL
;
967 AllocConsoleRequest
->CtrlDispatcher
= ConsoleControlDispatcher
;
968 AllocConsoleRequest
->PropDispatcher
= PropDialogHandler
;
970 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
972 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepAlloc
),
973 sizeof(CONSOLE_ALLOCCONSOLE
));
975 CsrFreeCaptureBuffer(CaptureBuffer
);
977 if (!NT_SUCCESS(Status
))
979 BaseSetLastNTError(Status
);
983 Parameters
->ConsoleHandle
= AllocConsoleRequest
->ConsoleHandle
;
984 SetStdHandle(STD_INPUT_HANDLE
, AllocConsoleRequest
->InputHandle
);
985 SetStdHandle(STD_OUTPUT_HANDLE
, AllocConsoleRequest
->OutputHandle
);
986 SetStdHandle(STD_ERROR_HANDLE
, AllocConsoleRequest
->ErrorHandle
);
988 /* Initialize Console Ctrl Handler */
989 InitConsoleCtrlHandling();
991 InputWaitHandle
= AllocConsoleRequest
->InputWaitHandle
;
997 /*--------------------------------------------------------------
1006 // AG: I'm not sure if this is correct (what happens to std handles?)
1007 // but I just tried to reverse what AllocConsole() does...
1010 CONSOLE_API_MESSAGE ApiMessage
;
1012 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1014 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepFree
),
1015 sizeof(CONSOLE_FREECONSOLE
));
1016 if (!NT_SUCCESS(Status
))
1018 BaseSetLastNTError(Status
);
1022 NtCurrentPeb()->ProcessParameters
->ConsoleHandle
= NULL
;
1024 CloseHandle(InputWaitHandle
);
1025 InputWaitHandle
= INVALID_HANDLE_VALUE
;
1031 /*--------------------------------------------------------------
1032 * GetConsoleScreenBufferInfo
1038 GetConsoleScreenBufferInfo(HANDLE hConsoleOutput
,
1039 PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo
)
1042 CONSOLE_API_MESSAGE ApiMessage
;
1044 if (lpConsoleScreenBufferInfo
== NULL
)
1046 SetLastError(ERROR_INVALID_PARAMETER
);
1050 ApiMessage
.Data
.ScreenBufferInfoRequest
.OutputHandle
= hConsoleOutput
;
1052 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1054 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetScreenBufferInfo
),
1055 sizeof(CONSOLE_GETSCREENBUFFERINFO
));
1056 if (!NT_SUCCESS(Status
))
1058 BaseSetLastNTError(Status
);
1062 *lpConsoleScreenBufferInfo
= ApiMessage
.Data
.ScreenBufferInfoRequest
.Info
;
1068 /*--------------------------------------------------------------
1069 * SetConsoleCursorPosition
1075 SetConsoleCursorPosition(HANDLE hConsoleOutput
,
1076 COORD dwCursorPosition
)
1079 CONSOLE_API_MESSAGE ApiMessage
;
1081 ApiMessage
.Data
.SetCursorPositionRequest
.OutputHandle
= hConsoleOutput
;
1082 ApiMessage
.Data
.SetCursorPositionRequest
.Position
= dwCursorPosition
;
1084 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1086 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetCursorPosition
),
1087 sizeof(CONSOLE_SETCURSORPOSITION
));
1088 if (!NT_SUCCESS(Status
))
1090 BaseSetLastNTError(Status
);
1098 /*--------------------------------------------------------------
1105 GetConsoleMode(HANDLE hConsoleHandle
,
1109 CONSOLE_API_MESSAGE ApiMessage
;
1110 PCONSOLE_GETSETCONSOLEMODE ConsoleModeRequest
= &ApiMessage
.Data
.ConsoleModeRequest
;
1114 SetLastError(ERROR_INVALID_PARAMETER
);
1118 ConsoleModeRequest
->ConsoleHandle
= hConsoleHandle
;
1120 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1122 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetMode
),
1123 sizeof(CONSOLE_GETSETCONSOLEMODE
));
1124 if (!NT_SUCCESS(Status
))
1126 BaseSetLastNTError(Status
);
1130 *lpMode
= ConsoleModeRequest
->ConsoleMode
;
1136 /*--------------------------------------------------------------
1137 * GetNumberOfConsoleInputEvents
1143 GetNumberOfConsoleInputEvents(HANDLE hConsoleInput
,
1144 LPDWORD lpNumberOfEvents
)
1147 CONSOLE_API_MESSAGE ApiMessage
;
1148 PCONSOLE_GETNUMINPUTEVENTS GetNumInputEventsRequest
= &ApiMessage
.Data
.GetNumInputEventsRequest
;
1150 GetNumInputEventsRequest
->InputHandle
= hConsoleInput
;
1151 GetNumInputEventsRequest
->NumInputEvents
= 0;
1153 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1155 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetNumberOfInputEvents
),
1156 sizeof(CONSOLE_GETNUMINPUTEVENTS
));
1157 if (!NT_SUCCESS(Status
))
1159 BaseSetLastNTError(Status
);
1163 if (lpNumberOfEvents
== NULL
)
1165 SetLastError(ERROR_INVALID_ACCESS
);
1169 *lpNumberOfEvents
= GetNumInputEventsRequest
->NumInputEvents
;
1175 /*--------------------------------------------------------------
1176 * GetLargestConsoleWindowSize
1182 GetLargestConsoleWindowSize(HANDLE hConsoleOutput
)
1185 CONSOLE_API_MESSAGE ApiMessage
;
1186 PCONSOLE_GETLARGESTWINDOWSIZE GetLargestWindowSizeRequest
= &ApiMessage
.Data
.GetLargestWindowSizeRequest
;
1188 GetLargestWindowSizeRequest
->OutputHandle
= hConsoleOutput
;
1189 GetLargestWindowSizeRequest
->Size
.X
= 0;
1190 GetLargestWindowSizeRequest
->Size
.Y
= 0;
1192 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1194 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetLargestWindowSize
),
1195 sizeof(CONSOLE_GETLARGESTWINDOWSIZE
));
1196 if (!NT_SUCCESS(Status
))
1198 BaseSetLastNTError(Status
);
1201 DPRINT1("GetLargestConsoleWindowSize, X = %d, Y = %d\n", GetLargestWindowSizeRequest
->Size
.X
, GetLargestWindowSizeRequest
->Size
.Y
);
1202 return GetLargestWindowSizeRequest
->Size
;
1206 /*--------------------------------------------------------------
1207 * GetConsoleCursorInfo
1213 GetConsoleCursorInfo(HANDLE hConsoleOutput
,
1214 PCONSOLE_CURSOR_INFO lpConsoleCursorInfo
)
1217 CONSOLE_API_MESSAGE ApiMessage
;
1219 if (!lpConsoleCursorInfo
)
1221 if (!hConsoleOutput
)
1222 SetLastError(ERROR_INVALID_HANDLE
);
1224 SetLastError(ERROR_INVALID_ACCESS
);
1229 ApiMessage
.Data
.CursorInfoRequest
.OutputHandle
= hConsoleOutput
;
1231 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1233 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetCursorInfo
),
1234 sizeof(CONSOLE_GETSETCURSORINFO
));
1235 if (!NT_SUCCESS(Status
))
1237 BaseSetLastNTError(Status
);
1241 *lpConsoleCursorInfo
= ApiMessage
.Data
.CursorInfoRequest
.Info
;
1247 /*--------------------------------------------------------------
1248 * GetNumberOfConsoleMouseButtons
1254 GetNumberOfConsoleMouseButtons(LPDWORD lpNumberOfMouseButtons
)
1256 DPRINT1("GetNumberOfConsoleMouseButtons(0x%x) UNIMPLEMENTED!\n", lpNumberOfMouseButtons
);
1257 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1262 /*--------------------------------------------------------------
1269 SetConsoleMode(HANDLE hConsoleHandle
,
1273 CONSOLE_API_MESSAGE ApiMessage
;
1274 PCONSOLE_GETSETCONSOLEMODE ConsoleModeRequest
= &ApiMessage
.Data
.ConsoleModeRequest
;
1276 ConsoleModeRequest
->ConsoleHandle
= hConsoleHandle
;
1277 ConsoleModeRequest
->ConsoleMode
= dwMode
;
1279 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1281 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetMode
),
1282 sizeof(CONSOLE_GETSETCONSOLEMODE
));
1283 if (!NT_SUCCESS(Status
))
1285 BaseSetLastNTError(Status
);
1293 /*--------------------------------------------------------------
1294 * SetConsoleActiveScreenBuffer
1300 SetConsoleActiveScreenBuffer(HANDLE hConsoleOutput
)
1303 CONSOLE_API_MESSAGE ApiMessage
;
1305 ApiMessage
.Data
.SetScreenBufferRequest
.OutputHandle
= hConsoleOutput
;
1307 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1309 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetActiveScreenBuffer
),
1310 sizeof(CONSOLE_SETACTIVESCREENBUFFER
));
1311 if (!NT_SUCCESS(Status
))
1313 BaseSetLastNTError(Status
);
1321 /*--------------------------------------------------------------
1322 * FlushConsoleInputBuffer
1328 FlushConsoleInputBuffer(HANDLE hConsoleInput
)
1331 CONSOLE_API_MESSAGE ApiMessage
;
1333 ApiMessage
.Data
.FlushInputBufferRequest
.InputHandle
= hConsoleInput
;
1335 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1337 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepFlushInputBuffer
),
1338 sizeof(CONSOLE_FLUSHINPUTBUFFER
));
1339 if (!NT_SUCCESS(Status
))
1341 BaseSetLastNTError(Status
);
1349 /*--------------------------------------------------------------
1350 * SetConsoleScreenBufferSize
1356 SetConsoleScreenBufferSize(HANDLE hConsoleOutput
,
1360 CONSOLE_API_MESSAGE ApiMessage
;
1362 ApiMessage
.Data
.SetScreenBufferSizeRequest
.OutputHandle
= hConsoleOutput
;
1363 ApiMessage
.Data
.SetScreenBufferSizeRequest
.Size
= dwSize
;
1365 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1367 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetScreenBufferSize
),
1368 sizeof(CONSOLE_SETSCREENBUFFERSIZE
));
1369 if (!NT_SUCCESS(Status
))
1371 BaseSetLastNTError(Status
);
1379 /*--------------------------------------------------------------
1380 * SetConsoleCursorInfo
1386 SetConsoleCursorInfo(HANDLE hConsoleOutput
,
1387 CONST CONSOLE_CURSOR_INFO
*lpConsoleCursorInfo
)
1390 CONSOLE_API_MESSAGE ApiMessage
;
1392 ApiMessage
.Data
.CursorInfoRequest
.OutputHandle
= hConsoleOutput
;
1393 ApiMessage
.Data
.CursorInfoRequest
.Info
= *lpConsoleCursorInfo
;
1395 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1397 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetCursorInfo
),
1398 sizeof(CONSOLE_GETSETCURSORINFO
));
1399 if (!NT_SUCCESS(Status
))
1401 BaseSetLastNTError(Status
);
1411 IntScrollConsoleScreenBuffer(HANDLE hConsoleOutput
,
1412 const SMALL_RECT
*lpScrollRectangle
,
1413 const SMALL_RECT
*lpClipRectangle
,
1414 COORD dwDestinationOrigin
,
1415 const CHAR_INFO
*lpFill
,
1419 CONSOLE_API_MESSAGE ApiMessage
;
1420 PCONSOLE_SCROLLSCREENBUFFER ScrollScreenBufferRequest
= &ApiMessage
.Data
.ScrollScreenBufferRequest
;
1422 ScrollScreenBufferRequest
->OutputHandle
= hConsoleOutput
;
1423 ScrollScreenBufferRequest
->Unicode
= bUnicode
;
1424 ScrollScreenBufferRequest
->ScrollRectangle
= *lpScrollRectangle
;
1426 if (lpClipRectangle
!= NULL
)
1428 ScrollScreenBufferRequest
->UseClipRectangle
= TRUE
;
1429 ScrollScreenBufferRequest
->ClipRectangle
= *lpClipRectangle
;
1433 ScrollScreenBufferRequest
->UseClipRectangle
= FALSE
;
1436 ScrollScreenBufferRequest
->DestinationOrigin
= dwDestinationOrigin
;
1437 ScrollScreenBufferRequest
->Fill
= *lpFill
;
1439 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1441 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepScrollScreenBuffer
),
1442 sizeof(CONSOLE_SCROLLSCREENBUFFER
));
1444 if (!NT_SUCCESS(Status
))
1446 BaseSetLastNTError(Status
);
1454 /*--------------------------------------------------------------
1455 * ScrollConsoleScreenBufferA
1461 ScrollConsoleScreenBufferA(HANDLE hConsoleOutput
,
1462 CONST SMALL_RECT
*lpScrollRectangle
,
1463 CONST SMALL_RECT
*lpClipRectangle
,
1464 COORD dwDestinationOrigin
,
1465 CONST CHAR_INFO
*lpFill
)
1467 return IntScrollConsoleScreenBuffer(hConsoleOutput
,
1468 (PSMALL_RECT
)lpScrollRectangle
,
1469 (PSMALL_RECT
)lpClipRectangle
,
1470 dwDestinationOrigin
,
1476 /*--------------------------------------------------------------
1477 * ScrollConsoleScreenBufferW
1483 ScrollConsoleScreenBufferW(HANDLE hConsoleOutput
,
1484 CONST SMALL_RECT
*lpScrollRectangle
,
1485 CONST SMALL_RECT
*lpClipRectangle
,
1486 COORD dwDestinationOrigin
,
1487 CONST CHAR_INFO
*lpFill
)
1489 return IntScrollConsoleScreenBuffer(hConsoleOutput
,
1492 dwDestinationOrigin
,
1498 /*--------------------------------------------------------------
1499 * SetConsoleWindowInfo
1505 SetConsoleWindowInfo(HANDLE hConsoleOutput
,
1507 CONST SMALL_RECT
*lpConsoleWindow
)
1510 CONSOLE_API_MESSAGE ApiMessage
;
1511 PCONSOLE_SETWINDOWINFO SetWindowInfoRequest
= &ApiMessage
.Data
.SetWindowInfoRequest
;
1513 if (lpConsoleWindow
== NULL
)
1515 SetLastError(ERROR_INVALID_PARAMETER
);
1519 SetWindowInfoRequest
->OutputHandle
= hConsoleOutput
;
1520 SetWindowInfoRequest
->Absolute
= bAbsolute
;
1521 SetWindowInfoRequest
->WindowRect
= *lpConsoleWindow
;
1523 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1525 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetWindowInfo
),
1526 sizeof(CONSOLE_SETWINDOWINFO
));
1527 if (!NT_SUCCESS(Status
))
1529 BaseSetLastNTError(Status
);
1537 /*--------------------------------------------------------------
1538 * SetConsoleTextAttribute
1544 SetConsoleTextAttribute(HANDLE hConsoleOutput
,
1548 CONSOLE_API_MESSAGE ApiMessage
;
1550 ApiMessage
.Data
.SetTextAttribRequest
.OutputHandle
= hConsoleOutput
;
1551 ApiMessage
.Data
.SetTextAttribRequest
.Attrib
= wAttributes
;
1553 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1555 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetTextAttribute
),
1556 sizeof(CONSOLE_SETTEXTATTRIB
));
1557 if (!NT_SUCCESS(Status
))
1559 BaseSetLastNTError(Status
);
1569 AddConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine
)
1571 PHANDLER_ROUTINE
* NewCtrlHandlers
= NULL
;
1573 if (HandlerRoutine
== NULL
)
1575 NtCurrentPeb()->ProcessParameters
->ConsoleFlags
= TRUE
;
1579 if (NrCtrlHandlers
== NrAllocatedHandlers
)
1581 NewCtrlHandlers
= RtlAllocateHeap(RtlGetProcessHeap(),
1583 (NrCtrlHandlers
+ 4) * sizeof(PHANDLER_ROUTINE
));
1584 if (NewCtrlHandlers
== NULL
)
1586 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1590 memmove(NewCtrlHandlers
, CtrlHandlers
, sizeof(PHANDLER_ROUTINE
) * NrCtrlHandlers
);
1592 if (NrAllocatedHandlers
> 1) RtlFreeHeap(RtlGetProcessHeap(), 0, CtrlHandlers
);
1594 CtrlHandlers
= NewCtrlHandlers
;
1595 NrAllocatedHandlers
+= 4;
1598 ASSERT(NrCtrlHandlers
< NrAllocatedHandlers
);
1600 CtrlHandlers
[NrCtrlHandlers
++] = HandlerRoutine
;
1607 RemoveConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine
)
1611 if (HandlerRoutine
== NULL
)
1613 NtCurrentPeb()->ProcessParameters
->ConsoleFlags
= FALSE
;
1617 for (i
= 0; i
< NrCtrlHandlers
; i
++)
1619 if (CtrlHandlers
[i
] == HandlerRoutine
)
1621 if (i
< (NrCtrlHandlers
- 1))
1623 memmove(&CtrlHandlers
[i
],
1625 (NrCtrlHandlers
- i
+ 1) * sizeof(PHANDLER_ROUTINE
));
1633 SetLastError(ERROR_INVALID_PARAMETER
);
1643 SetConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine
,
1648 RtlEnterCriticalSection(&BaseDllDirectoryLock
);
1651 Ret
= AddConsoleCtrlHandler(HandlerRoutine
);
1655 Ret
= RemoveConsoleCtrlHandler(HandlerRoutine
);
1658 RtlLeaveCriticalSection(&BaseDllDirectoryLock
);
1663 /*--------------------------------------------------------------
1664 * GenerateConsoleCtrlEvent
1670 GenerateConsoleCtrlEvent(DWORD dwCtrlEvent
,
1671 DWORD dwProcessGroupId
)
1674 CONSOLE_API_MESSAGE ApiMessage
;
1676 if (dwCtrlEvent
!= CTRL_C_EVENT
&& dwCtrlEvent
!= CTRL_BREAK_EVENT
)
1678 SetLastError(ERROR_INVALID_PARAMETER
);
1682 ApiMessage
.Data
.GenerateCtrlEventRequest
.Event
= dwCtrlEvent
;
1683 ApiMessage
.Data
.GenerateCtrlEventRequest
.ProcessGroup
= dwProcessGroupId
;
1685 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1687 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGenerateCtrlEvent
),
1688 sizeof(CONSOLE_GENERATECTRLEVENT
));
1689 if (!NT_SUCCESS(Status
))
1691 BaseSetLastNTError(Status
);
1700 IntGetConsoleTitle(LPVOID lpConsoleTitle
, DWORD nSize
, BOOL bUnicode
)
1703 CONSOLE_API_MESSAGE ApiMessage
;
1704 PCONSOLE_GETSETCONSOLETITLE TitleRequest
= &ApiMessage
.Data
.TitleRequest
;
1705 PCSR_CAPTURE_BUFFER CaptureBuffer
;
1707 if (nSize
== 0) return 0;
1709 TitleRequest
->Length
= nSize
* (bUnicode
? 1 : sizeof(WCHAR
));
1710 CaptureBuffer
= CsrAllocateCaptureBuffer(1, TitleRequest
->Length
);
1711 if (CaptureBuffer
== NULL
)
1713 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
1714 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1718 CsrAllocateMessagePointer(CaptureBuffer
,
1719 TitleRequest
->Length
,
1720 (PVOID
*)&TitleRequest
->Title
);
1722 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1724 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetTitle
),
1725 sizeof(CONSOLE_GETSETCONSOLETITLE
));
1726 if (!NT_SUCCESS(Status
))
1728 CsrFreeCaptureBuffer(CaptureBuffer
);
1729 BaseSetLastNTError(Status
);
1735 if (nSize
>= sizeof(WCHAR
))
1736 wcscpy((LPWSTR
)lpConsoleTitle
, TitleRequest
->Title
);
1740 if (nSize
< TitleRequest
->Length
/ sizeof(WCHAR
) ||
1741 !WideCharToMultiByte(CP_ACP
, // ANSI code page
1742 0, // performance and mapping flags
1743 TitleRequest
->Title
, // address of wide-character string
1744 -1, // number of characters in string
1745 (LPSTR
)lpConsoleTitle
, // address of buffer for new string
1746 nSize
, // size of buffer
1750 /* Yes, if the buffer isn't big enough, it returns 0... Bad API */
1751 *(LPSTR
)lpConsoleTitle
= '\0';
1752 TitleRequest
->Length
= 0;
1755 CsrFreeCaptureBuffer(CaptureBuffer
);
1757 return TitleRequest
->Length
/ sizeof(WCHAR
);
1761 /*--------------------------------------------------------------
1768 GetConsoleTitleW(LPWSTR lpConsoleTitle
,
1771 return IntGetConsoleTitle(lpConsoleTitle
, nSize
, TRUE
);
1775 /*--------------------------------------------------------------
1782 GetConsoleTitleA(LPSTR lpConsoleTitle
,
1785 return IntGetConsoleTitle(lpConsoleTitle
, nSize
, FALSE
);
1789 /*--------------------------------------------------------------
1796 SetConsoleTitleW(LPCWSTR lpConsoleTitle
)
1799 CONSOLE_API_MESSAGE ApiMessage
;
1800 PCONSOLE_GETSETCONSOLETITLE TitleRequest
= &ApiMessage
.Data
.TitleRequest
;
1801 PCSR_CAPTURE_BUFFER CaptureBuffer
;
1803 TitleRequest
->Length
= wcslen(lpConsoleTitle
) * sizeof(WCHAR
);
1805 CaptureBuffer
= CsrAllocateCaptureBuffer(1, TitleRequest
->Length
);
1806 if (CaptureBuffer
== NULL
)
1808 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
1809 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1813 CsrCaptureMessageBuffer(CaptureBuffer
,
1814 (PVOID
)lpConsoleTitle
,
1815 TitleRequest
->Length
,
1816 (PVOID
*)&TitleRequest
->Title
);
1818 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1820 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetTitle
),
1821 sizeof(CONSOLE_GETSETCONSOLETITLE
));
1823 CsrFreeCaptureBuffer(CaptureBuffer
);
1825 if (!NT_SUCCESS(Status
))
1827 BaseSetLastNTError(Status
);
1835 /*--------------------------------------------------------------
1842 SetConsoleTitleA(LPCSTR lpConsoleTitle
)
1845 ULONG Length
= strlen(lpConsoleTitle
) + 1;
1846 LPWSTR WideTitle
= HeapAlloc(GetProcessHeap(), 0, Length
* sizeof(WCHAR
));
1850 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1854 MultiByteToWideChar(CP_ACP
, 0, lpConsoleTitle
, -1, WideTitle
, Length
);
1856 Ret
= SetConsoleTitleW(WideTitle
);
1858 HeapFree(GetProcessHeap(), 0, WideTitle
);
1863 /*--------------------------------------------------------------
1864 * CreateConsoleScreenBuffer
1870 CreateConsoleScreenBuffer(DWORD dwDesiredAccess
,
1872 CONST SECURITY_ATTRIBUTES
*lpSecurityAttributes
,
1874 LPVOID lpScreenBufferData
)
1877 CONSOLE_API_MESSAGE ApiMessage
;
1878 PCONSOLE_CREATESCREENBUFFER CreateScreenBufferRequest
= &ApiMessage
.Data
.CreateScreenBufferRequest
;
1879 PCSR_CAPTURE_BUFFER CaptureBuffer
= NULL
;
1880 PCONSOLE_GRAPHICS_BUFFER_INFO GraphicsBufferInfo
= /*(PCONSOLE_GRAPHICS_BUFFER_INFO)*/lpScreenBufferData
;
1882 if ( (dwDesiredAccess
& ~(GENERIC_READ
| GENERIC_WRITE
)) ||
1883 (dwShareMode
& ~(FILE_SHARE_READ
| FILE_SHARE_WRITE
)) ||
1884 (dwFlags
!= CONSOLE_TEXTMODE_BUFFER
&& dwFlags
!= CONSOLE_GRAPHICS_BUFFER
) )
1886 SetLastError(ERROR_INVALID_PARAMETER
);
1887 return INVALID_HANDLE_VALUE
;
1890 CreateScreenBufferRequest
->ScreenBufferType
= dwFlags
;
1891 CreateScreenBufferRequest
->Access
= dwDesiredAccess
;
1892 CreateScreenBufferRequest
->ShareMode
= dwShareMode
;
1893 CreateScreenBufferRequest
->Inheritable
=
1894 (lpSecurityAttributes
? lpSecurityAttributes
->bInheritHandle
: FALSE
);
1896 if (dwFlags
== CONSOLE_GRAPHICS_BUFFER
)
1898 if (CreateScreenBufferRequest
->Inheritable
|| GraphicsBufferInfo
== NULL
)
1900 SetLastError(ERROR_INVALID_PARAMETER
);
1901 return INVALID_HANDLE_VALUE
;
1904 CreateScreenBufferRequest
->GraphicsBufferInfo
= *GraphicsBufferInfo
;
1906 CaptureBuffer
= CsrAllocateCaptureBuffer(1, GraphicsBufferInfo
->dwBitMapInfoLength
);
1907 if (CaptureBuffer
== NULL
)
1909 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1913 CsrCaptureMessageBuffer(CaptureBuffer
,
1914 (PVOID
)GraphicsBufferInfo
->lpBitMapInfo
,
1915 GraphicsBufferInfo
->dwBitMapInfoLength
,
1916 (PVOID
*)&CreateScreenBufferRequest
->GraphicsBufferInfo
.lpBitMapInfo
);
1919 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1921 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepCreateScreenBuffer
),
1922 sizeof(CONSOLE_CREATESCREENBUFFER
));
1925 CsrFreeCaptureBuffer(CaptureBuffer
);
1927 if (!NT_SUCCESS(Status
))
1929 BaseSetLastNTError(Status
);
1930 return INVALID_HANDLE_VALUE
;
1933 if (dwFlags
== CONSOLE_GRAPHICS_BUFFER
&& GraphicsBufferInfo
)
1935 GraphicsBufferInfo
->hMutex
= CreateScreenBufferRequest
->GraphicsBufferInfo
.hMutex
;
1936 GraphicsBufferInfo
->lpBitMap
= CreateScreenBufferRequest
->GraphicsBufferInfo
.lpBitMap
;
1939 return CreateScreenBufferRequest
->OutputHandle
;
1943 /*--------------------------------------------------------------
1953 CONSOLE_API_MESSAGE ApiMessage
;
1955 /* Get the Input Code Page */
1956 ApiMessage
.Data
.ConsoleCPRequest
.InputCP
= TRUE
;
1957 ApiMessage
.Data
.ConsoleCPRequest
.CodePage
= 0;
1959 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1961 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetCP
),
1962 sizeof(CONSOLE_GETSETINPUTOUTPUTCP
));
1964 if (!NT_SUCCESS(Status
)) BaseSetLastNTError(Status
);
1966 return ApiMessage
.Data
.ConsoleCPRequest
.CodePage
;
1970 /*--------------------------------------------------------------
1977 SetConsoleCP(UINT wCodePageID
)
1980 CONSOLE_API_MESSAGE ApiMessage
;
1982 /* Set the Input Code Page */
1983 ApiMessage
.Data
.ConsoleCPRequest
.InputCP
= TRUE
;
1984 ApiMessage
.Data
.ConsoleCPRequest
.CodePage
= wCodePageID
;
1986 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1988 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetCP
),
1989 sizeof(CONSOLE_GETSETINPUTOUTPUTCP
));
1991 if (!NT_SUCCESS(Status
)) BaseSetLastNTError(Status
);
1993 return NT_SUCCESS(Status
);
1997 /*--------------------------------------------------------------
1998 * GetConsoleOutputCP
2004 GetConsoleOutputCP(VOID
)
2007 CONSOLE_API_MESSAGE ApiMessage
;
2009 /* Get the Output Code Page */
2010 ApiMessage
.Data
.ConsoleCPRequest
.InputCP
= FALSE
;
2011 ApiMessage
.Data
.ConsoleCPRequest
.CodePage
= 0;
2013 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
2015 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetCP
),
2016 sizeof(CONSOLE_GETSETINPUTOUTPUTCP
));
2018 if (!NT_SUCCESS(Status
)) BaseSetLastNTError(Status
);
2020 return ApiMessage
.Data
.ConsoleCPRequest
.CodePage
;
2024 /*--------------------------------------------------------------
2025 * SetConsoleOutputCP
2031 SetConsoleOutputCP(UINT wCodePageID
)
2034 CONSOLE_API_MESSAGE ApiMessage
;
2036 /* Set the Output Code Page */
2037 ApiMessage
.Data
.ConsoleCPRequest
.InputCP
= FALSE
;
2038 ApiMessage
.Data
.ConsoleCPRequest
.CodePage
= wCodePageID
;
2040 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
2042 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetCP
),
2043 sizeof(CONSOLE_GETSETINPUTOUTPUTCP
));
2045 if (!NT_SUCCESS(Status
)) BaseSetLastNTError(Status
);
2047 return NT_SUCCESS(Status
);
2051 /*--------------------------------------------------------------
2052 * GetConsoleProcessList
2058 GetConsoleProcessList(LPDWORD lpdwProcessList
,
2059 DWORD dwProcessCount
)
2062 CONSOLE_API_MESSAGE ApiMessage
;
2063 PCONSOLE_GETPROCESSLIST GetProcessListRequest
= &ApiMessage
.Data
.GetProcessListRequest
;
2064 PCSR_CAPTURE_BUFFER CaptureBuffer
;
2067 if (lpdwProcessList
== NULL
|| dwProcessCount
== 0)
2069 SetLastError(ERROR_INVALID_PARAMETER
);
2073 CaptureBuffer
= CsrAllocateCaptureBuffer(1, dwProcessCount
* sizeof(DWORD
));
2074 if (CaptureBuffer
== NULL
)
2076 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
2077 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
2081 GetProcessListRequest
->nMaxIds
= dwProcessCount
;
2083 CsrAllocateMessagePointer(CaptureBuffer
,
2084 dwProcessCount
* sizeof(DWORD
),
2085 (PVOID
*)&GetProcessListRequest
->pProcessIds
);
2087 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
2089 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetProcessList
),
2090 sizeof(CONSOLE_GETPROCESSLIST
));
2091 if (!NT_SUCCESS(Status
))
2093 BaseSetLastNTError (Status
);
2098 nProcesses
= GetProcessListRequest
->nProcessIdsTotal
;
2099 if (dwProcessCount
>= nProcesses
)
2101 memcpy(lpdwProcessList
, GetProcessListRequest
->pProcessIds
, nProcesses
* sizeof(DWORD
));
2105 CsrFreeCaptureBuffer(CaptureBuffer
);
2110 /*--------------------------------------------------------------
2111 * GetConsoleSelectionInfo
2117 GetConsoleSelectionInfo(PCONSOLE_SELECTION_INFO lpConsoleSelectionInfo
)
2120 CONSOLE_API_MESSAGE ApiMessage
;
2122 if (lpConsoleSelectionInfo
== NULL
)
2124 SetLastError(ERROR_INVALID_PARAMETER
);
2128 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
2130 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetSelectionInfo
),
2131 sizeof(CONSOLE_GETSELECTIONINFO
));
2132 if (!NT_SUCCESS(Status
))
2134 BaseSetLastNTError(Status
);
2138 *lpConsoleSelectionInfo
= ApiMessage
.Data
.GetSelectionInfoRequest
.Info
;
2143 /*--------------------------------------------------------------
2148 * @note Strongly inspired by AllocConsole.
2152 AttachConsole(DWORD dwProcessId
)
2155 PRTL_USER_PROCESS_PARAMETERS Parameters
= NtCurrentPeb()->ProcessParameters
;
2156 CONSOLE_API_MESSAGE ApiMessage
;
2157 PCONSOLE_ATTACHCONSOLE AttachConsoleRequest
= &ApiMessage
.Data
.AttachConsoleRequest
;
2159 if (Parameters
->ConsoleHandle
)
2161 DPRINT1("AttachConsole: Attaching a console to a process already having one\n");
2162 SetLastError(ERROR_ACCESS_DENIED
);
2166 AttachConsoleRequest
->ProcessId
= dwProcessId
;
2167 AttachConsoleRequest
->CtrlDispatcher
= ConsoleControlDispatcher
;
2168 AttachConsoleRequest
->PropDispatcher
= PropDialogHandler
;
2170 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
2172 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepAttach
),
2173 sizeof(CONSOLE_ATTACHCONSOLE
));
2174 if (!NT_SUCCESS(Status
))
2176 BaseSetLastNTError(Status
);
2180 Parameters
->ConsoleHandle
= AttachConsoleRequest
->ConsoleHandle
;
2181 SetStdHandle(STD_INPUT_HANDLE
, AttachConsoleRequest
->InputHandle
);
2182 SetStdHandle(STD_OUTPUT_HANDLE
, AttachConsoleRequest
->OutputHandle
);
2183 SetStdHandle(STD_ERROR_HANDLE
, AttachConsoleRequest
->ErrorHandle
);
2185 /* Initialize Console Ctrl Handler */
2186 InitConsoleCtrlHandling();
2188 InputWaitHandle
= AttachConsoleRequest
->InputWaitHandle
;
2194 /*--------------------------------------------------------------
2201 GetConsoleWindow(VOID
)
2204 CONSOLE_API_MESSAGE ApiMessage
;
2206 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
2208 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepGetConsoleWindow
),
2209 sizeof(CONSOLE_GETWINDOW
));
2210 if (!NT_SUCCESS(Status
))
2212 BaseSetLastNTError(Status
);
2216 return ApiMessage
.Data
.GetWindowRequest
.WindowHandle
;
2220 /*--------------------------------------------------------------
2227 SetConsoleIcon(HICON hicon
)
2230 CONSOLE_API_MESSAGE ApiMessage
;
2232 ApiMessage
.Data
.SetIconRequest
.WindowIcon
= hicon
;
2234 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
2236 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX
, ConsolepSetIcon
),
2237 sizeof(CONSOLE_SETICON
));
2238 if (!NT_SUCCESS(Status
))
2240 BaseSetLastNTError(Status
);
2244 return NT_SUCCESS(Status
);
2248 /******************************************************************************
2249 * \name SetConsoleInputExeNameW
2250 * \brief Sets the console input file name from a unicode string.
2251 * \param lpInputExeName Pointer to a unicode string with the name.
2252 * \return TRUE if successful, FALSE if unsuccsedful.
2253 * \remarks If lpInputExeName is 0 or the string length is 0 or greater than 255,
2254 * the function fails and sets last error to ERROR_INVALID_PARAMETER.
2258 SetConsoleInputExeNameW(LPCWSTR lpInputExeName
)
2262 if ( !lpInputExeName
||
2263 (lenName
= lstrlenW(lpInputExeName
)) == 0 ||
2264 lenName
> INPUTEXENAME_BUFLEN
- 1 )
2266 /* Fail if string is empty or too long */
2267 SetLastError(ERROR_INVALID_PARAMETER
);
2271 RtlEnterCriticalSection(&ConsoleLock
);
2274 RtlCopyMemory(InputExeName
, lpInputExeName
, lenName
* sizeof(WCHAR
));
2275 InputExeName
[lenName
] = L
'\0';
2279 RtlLeaveCriticalSection(&ConsoleLock
);
2287 /******************************************************************************
2288 * \name SetConsoleInputExeNameA
2289 * \brief Sets the console input file name from an ansi string.
2290 * \param lpInputExeName Pointer to an ansi string with the name.
2291 * \return TRUE if successful, FALSE if unsuccsedful.
2292 * \remarks If lpInputExeName is 0 or the string length is 0 or greater than 255,
2293 * the function fails and sets last error to ERROR_INVALID_PARAMETER.
2297 SetConsoleInputExeNameA(LPCSTR lpInputExeName
)
2299 WCHAR Buffer
[INPUTEXENAME_BUFLEN
];
2300 ANSI_STRING InputExeNameA
;
2301 UNICODE_STRING InputExeNameU
;
2304 RtlInitAnsiString(&InputExeNameA
, lpInputExeName
);
2306 if ( InputExeNameA
.Length
== 0 ||
2307 InputExeNameA
.Length
> INPUTEXENAME_BUFLEN
- 1 )
2309 /* Fail if string is empty or too long */
2310 SetLastError(ERROR_INVALID_PARAMETER
);
2314 InputExeNameU
.Buffer
= Buffer
;
2315 InputExeNameU
.MaximumLength
= sizeof(Buffer
);
2316 InputExeNameU
.Length
= 0;
2318 Status
= RtlAnsiStringToUnicodeString(&InputExeNameU
, &InputExeNameA
, FALSE
);
2319 if (!NT_SUCCESS(Status
))
2321 BaseSetLastNTError(Status
);
2325 return SetConsoleInputExeNameW(InputExeNameU
.Buffer
);
2329 /******************************************************************************
2330 * \name GetConsoleInputExeNameW
2331 * \brief Retrieves the console input file name as unicode string.
2332 * \param nBufferLength Length of the buffer in WCHARs.
2333 * Specify 0 to receive the needed buffer length.
2334 * \param lpBuffer Pointer to a buffer that receives the string.
2335 * \return Needed buffer size if \p nBufferLength is 0.
2336 * Otherwise 1 if successful, 2 if buffer is too small.
2337 * \remarks Sets last error value to ERROR_BUFFER_OVERFLOW if the buffer
2338 * is not big enough.
2342 GetConsoleInputExeNameW(DWORD nBufferLength
, LPWSTR lpBuffer
)
2344 ULONG lenName
= lstrlenW(InputExeName
);
2346 if (nBufferLength
== 0)
2348 /* Buffer size is requested, return it */
2352 if (lenName
+ 1 > nBufferLength
)
2354 /* Buffer is not large enough! */
2355 SetLastError(ERROR_BUFFER_OVERFLOW
);
2359 RtlEnterCriticalSection(&ConsoleLock
);
2362 RtlCopyMemory(lpBuffer
, InputExeName
, lenName
* sizeof(WCHAR
));
2363 lpBuffer
[lenName
] = '\0';
2367 RtlLeaveCriticalSection(&ConsoleLock
);
2371 /* Success, return 1 */
2376 /******************************************************************************
2377 * \name GetConsoleInputExeNameA
2378 * \brief Retrieves the console input file name as ansi string.
2379 * \param nBufferLength Length of the buffer in CHARs.
2380 * \param lpBuffer Pointer to a buffer that receives the string.
2381 * \return 1 if successful, 2 if buffer is too small.
2382 * \remarks Sets last error value to ERROR_BUFFER_OVERFLOW if the buffer
2383 * is not big enough. The buffer receives as much characters as fit.
2387 GetConsoleInputExeNameA(DWORD nBufferLength
, LPSTR lpBuffer
)
2389 WCHAR Buffer
[INPUTEXENAME_BUFLEN
];
2391 UNICODE_STRING BufferU
;
2392 ANSI_STRING BufferA
;
2394 /* Get the unicode name */
2395 Ret
= GetConsoleInputExeNameW(sizeof(Buffer
) / sizeof(Buffer
[0]), Buffer
);
2397 /* Initialize strings for conversion */
2398 RtlInitUnicodeString(&BufferU
, Buffer
);
2400 BufferA
.MaximumLength
= (USHORT
)nBufferLength
;
2401 BufferA
.Buffer
= lpBuffer
;
2403 /* Convert unicode name to ansi, copying as much chars as fit */
2404 RtlUnicodeStringToAnsiString(&BufferA
, &BufferU
, FALSE
);
2406 /* Error handling */
2407 if (nBufferLength
<= BufferU
.Length
/ sizeof(WCHAR
))
2409 SetLastError(ERROR_BUFFER_OVERFLOW
);
2418 GetConsoleCharType(HANDLE hConsole
, COORD Coord
, PDWORD Type
)
2426 GetConsoleCursorMode(HANDLE hConsole
, PBOOL pUnknown1
, PBOOL pUnknown2
)
2434 GetConsoleNlsMode(HANDLE hConsole
, LPDWORD lpMode
)
2442 SetConsoleCursorMode(HANDLE hConsole
, BOOL Unknown1
, BOOL Unknown2
)
2450 SetConsoleLocalEUDC(DWORD Unknown1
, DWORD Unknown2
, DWORD Unknown3
, DWORD Unknown4
)
2458 SetConsoleNlsMode(HANDLE hConsole
, DWORD dwMode
)
2466 RegisterConsoleIME(HWND hWnd
, LPDWORD ThreadId
)
2474 RegisterConsoleOS2(BOOL bUnknown
)
2482 SetConsoleOS2OemFormat(BOOL bUnknown
)
2490 UnregisterConsoleIME(VOID
)
2500 BOOL WINAPI
GetConsoleKeyboardLayoutNameA(LPSTR name
)
2509 BOOL WINAPI
GetConsoleKeyboardLayoutNameW(LPWSTR name
)
2520 SetLastConsoleEventActive(VOID
)