ReactOS 0.4.16-dev-1214-gd663eb4
console.c File Reference
#include <k32.h>
#include <debug.h>
Include dependency graph for console.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define EXENAME_LENGTH   (255 + 1)
 

Functions

BOOL WINAPI IsDebuggerPresent (VOID)
 
static BOOL WINAPI DefaultConsoleCtrlHandler (DWORD Event)
 
DWORD WINAPI ConsoleControlDispatcher (IN LPVOID lpThreadParameter)
 
VOID InitializeCtrlHandling (VOID)
 
VOID InitExeName (VOID)
 
VOID SetUpAppName (IN BOOLEAN CaptureStrings, IN OUT LPDWORD CurDirLength, IN OUT LPWSTR *CurDir, IN OUT LPDWORD AppNameLength, IN OUT LPWSTR *AppName)
 
USHORT GetCurrentExeName (OUT PWCHAR ExeName, IN USHORT BufferSize)
 
LPCWSTR IntCheckForConsoleFileName (IN LPCWSTR pszName, IN DWORD dwDesiredAccess)
 
HMENU WINAPI DECLSPEC_HOTPATCH ConsoleMenuControl (HANDLE hConsoleOutput, DWORD dwCmdIdLow, DWORD dwCmdIdHigh)
 
HANDLE WINAPI DECLSPEC_HOTPATCH DuplicateConsoleHandle (HANDLE hSourceHandle, DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwOptions)
 
BOOL WINAPI GetConsoleHandleInformation (IN HANDLE hHandle, OUT LPDWORD lpdwFlags)
 
BOOL WINAPI SetConsoleHandleInformation (IN HANDLE hHandle, IN DWORD dwMask, IN DWORD dwFlags)
 
BOOL WINAPI GetConsoleDisplayMode (LPDWORD lpModeFlags)
 
DWORD WINAPI GetConsoleFontInfo (IN HANDLE hConsoleOutput, IN BOOL bMaximumWindow, IN DWORD nFontCount, OUT PCONSOLE_FONT_INFO lpConsoleFontInfo)
 
COORD WINAPI DECLSPEC_HOTPATCH GetConsoleFontSize (IN HANDLE hConsoleOutput, IN DWORD nFont)
 
BOOL WINAPI GetConsoleHardwareState (HANDLE hConsoleOutput, PDWORD Flags, PDWORD State)
 
HANDLE WINAPI GetConsoleInputWaitHandle (VOID)
 
BOOL WINAPI GetCurrentConsoleFont (IN HANDLE hConsoleOutput, IN BOOL bMaximumWindow, OUT PCONSOLE_FONT_INFO lpConsoleCurrentFont)
 
DWORD WINAPI DECLSPEC_HOTPATCH GetNumberOfConsoleFonts (VOID)
 
BOOL WINAPI InvalidateConsoleDIBits (IN HANDLE hConsoleOutput, IN PSMALL_RECT lpRect)
 
HANDLE WINAPI OpenConsoleW (LPCWSTR wsName, DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwShareMode)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleCursor (HANDLE hConsoleOutput, HCURSOR hCursor)
 
BOOL WINAPI SetConsoleDisplayMode (HANDLE hConsoleOutput, DWORD dwFlags, PCOORD lpNewScreenBufferDimensions)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleFont (IN HANDLE hConsoleOutput, IN DWORD nFont)
 
BOOL WINAPI SetConsoleHardwareState (HANDLE hConsoleOutput, DWORD Flags, DWORD State)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleKeyShortcuts (_In_ BOOL bSet, _In_ BYTE bReserveKeys, _In_reads_(dwNumAppKeys) LPAPPKEY lpAppKeys, _In_ DWORD dwNumAppKeys)
 
BOOL WINAPI SetConsoleMaximumWindowSize (HANDLE hConsoleOutput, COORD dwMaximumSize)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleMenuClose (BOOL bEnable)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetConsolePalette (HANDLE hConsoleOutput, HPALETTE hPalette, UINT dwUsage)
 
INT WINAPI DECLSPEC_HOTPATCH ShowConsoleCursor (HANDLE hConsoleOutput, BOOL bShow)
 
BOOL WINAPI DECLSPEC_HOTPATCH VerifyConsoleIoHandle (HANDLE hIoHandle)
 
BOOL WINAPI DECLSPEC_HOTPATCH CloseConsoleHandle (HANDLE hHandle)
 
HANDLE WINAPI DECLSPEC_HOTPATCH GetStdHandle (DWORD nStdHandle)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetStdHandle (DWORD nStdHandle, HANDLE hHandle)
 
static BOOL IntAllocConsole (LPWSTR Title, DWORD TitleLength, LPWSTR Desktop, DWORD DesktopLength, LPWSTR CurDir, DWORD CurDirLength, LPWSTR AppName, DWORD AppNameLength, LPTHREAD_START_ROUTINE CtrlRoutine, LPTHREAD_START_ROUTINE PropRoutine, PCONSOLE_START_INFO ConsoleStartInfo)
 
BOOL WINAPI DECLSPEC_HOTPATCH AllocConsole (VOID)
 
BOOL WINAPI DECLSPEC_HOTPATCH FreeConsole (VOID)
 
BOOL WINAPI GetConsoleScreenBufferInfo (HANDLE hConsoleOutput, PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleCursorPosition (HANDLE hConsoleOutput, COORD dwCursorPosition)
 
BOOL WINAPI GetConsoleMode (HANDLE hConsoleHandle, LPDWORD lpMode)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleMode (HANDLE hConsoleHandle, DWORD dwMode)
 
BOOL WINAPI GetNumberOfConsoleInputEvents (HANDLE hConsoleInput, LPDWORD lpNumberOfEvents)
 
COORD WINAPI DECLSPEC_HOTPATCH GetLargestConsoleWindowSize (HANDLE hConsoleOutput)
 
BOOL WINAPI GetConsoleCursorInfo (HANDLE hConsoleOutput, PCONSOLE_CURSOR_INFO lpConsoleCursorInfo)
 
BOOL WINAPI SetConsoleCursorInfo (HANDLE hConsoleOutput, CONST CONSOLE_CURSOR_INFO *lpConsoleCursorInfo)
 
BOOL WINAPI GetNumberOfConsoleMouseButtons (LPDWORD lpNumberOfMouseButtons)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleActiveScreenBuffer (HANDLE hConsoleOutput)
 
BOOL WINAPI DECLSPEC_HOTPATCH FlushConsoleInputBuffer (HANDLE hConsoleInput)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleScreenBufferSize (HANDLE hConsoleOutput, COORD dwSize)
 
static BOOL IntScrollConsoleScreenBuffer (HANDLE hConsoleOutput, CONST SMALL_RECT *lpScrollRectangle, CONST SMALL_RECT *lpClipRectangle, COORD dwDestinationOrigin, CONST CHAR_INFO *lpFill, BOOL bUnicode)
 
BOOL WINAPI DECLSPEC_HOTPATCH ScrollConsoleScreenBufferA (HANDLE hConsoleOutput, CONST SMALL_RECT *lpScrollRectangle, CONST SMALL_RECT *lpClipRectangle, COORD dwDestinationOrigin, CONST CHAR_INFO *lpFill)
 
BOOL WINAPI DECLSPEC_HOTPATCH ScrollConsoleScreenBufferW (HANDLE hConsoleOutput, CONST SMALL_RECT *lpScrollRectangle, CONST SMALL_RECT *lpClipRectangle, COORD dwDestinationOrigin, CONST CHAR_INFO *lpFill)
 
BOOL WINAPI SetConsoleWindowInfo (HANDLE hConsoleOutput, BOOL bAbsolute, CONST SMALL_RECT *lpConsoleWindow)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleTextAttribute (HANDLE hConsoleOutput, WORD wAttributes)
 
static BOOL AddConsoleCtrlHandler (PHANDLER_ROUTINE HandlerRoutine)
 
static BOOL RemoveConsoleCtrlHandler (PHANDLER_ROUTINE HandlerRoutine)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleCtrlHandler (PHANDLER_ROUTINE HandlerRoutine, BOOL Add)
 
BOOL WINAPI DECLSPEC_HOTPATCH GenerateConsoleCtrlEvent (DWORD dwCtrlEvent, DWORD dwProcessGroupId)
 
static DWORD IntGetConsoleTitle (LPVOID lpConsoleTitle, DWORD dwNumChars, BOOLEAN bUnicode)
 
DWORD WINAPI DECLSPEC_HOTPATCH GetConsoleTitleW (LPWSTR lpConsoleTitle, DWORD nSize)
 
DWORD WINAPI DECLSPEC_HOTPATCH GetConsoleTitleA (LPSTR lpConsoleTitle, DWORD nSize)
 
static BOOL IntSetConsoleTitle (CONST VOID *lpConsoleTitle, BOOLEAN bUnicode)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleTitleW (LPCWSTR lpConsoleTitle)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleTitleA (LPCSTR lpConsoleTitle)
 
HANDLE WINAPI CreateConsoleScreenBuffer (DWORD dwDesiredAccess, DWORD dwShareMode, CONST SECURITY_ATTRIBUTES *lpSecurityAttributes, DWORD dwFlags, LPVOID lpScreenBufferData)
 
UINT WINAPI DECLSPEC_HOTPATCH GetConsoleCP (VOID)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleCP (UINT wCodePageID)
 
UINT WINAPI DECLSPEC_HOTPATCH GetConsoleOutputCP (VOID)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleOutputCP (UINT wCodePageID)
 
DWORD WINAPI GetConsoleProcessList (LPDWORD lpdwProcessList, DWORD dwProcessCount)
 
BOOL WINAPI GetConsoleSelectionInfo (PCONSOLE_SELECTION_INFO lpConsoleSelectionInfo)
 
static BOOL IntAttachConsole (DWORD ProcessId, LPTHREAD_START_ROUTINE CtrlRoutine, LPTHREAD_START_ROUTINE PropRoutine, PCONSOLE_START_INFO ConsoleStartInfo)
 
BOOL WINAPI AttachConsole (DWORD dwProcessId)
 
HWND WINAPI DECLSPEC_HOTPATCH GetConsoleWindow (VOID)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleIcon (HICON hIcon)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleInputExeNameW (IN LPCWSTR lpExeName)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleInputExeNameA (IN LPCSTR lpExeName)
 
DWORD WINAPI DECLSPEC_HOTPATCH GetConsoleInputExeNameW (IN DWORD nBufferLength, OUT LPWSTR lpExeName)
 
DWORD WINAPI DECLSPEC_HOTPATCH GetConsoleInputExeNameA (IN DWORD nBufferLength, OUT LPSTR lpExeName)
 
BOOL WINAPI GetConsoleCharType (HANDLE hConsole, COORD Coord, PDWORD Type)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetConsoleCursorMode (HANDLE hConsole, PBOOL pUnknown1, PBOOL pUnknown2)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleCursorMode (HANDLE hConsole, BOOL Unknown1, BOOL Unknown2)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetConsoleNlsMode (HANDLE hConsole, LPDWORD lpMode)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleNlsMode (HANDLE hConsole, DWORD dwMode)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleLocalEUDC (_In_ HANDLE hConsoleHandle, _In_ WORD wCodePoint, _In_ COORD cFontSize, _In_ PCHAR lpSB)
 
static BOOL IntRegisterConsoleIME (_In_ HWND hWnd, _In_ DWORD dwThreadId, _In_opt_ SIZE_T cbDesktop, _In_opt_ PWSTR pDesktop, _Out_opt_ PDWORD pdwAttachToThreadId)
 
static BOOL IntUnregisterConsoleIME (_In_ DWORD dwThreadId)
 
BOOL WINAPI DECLSPEC_HOTPATCH RegisterConsoleIME (_In_ HWND hWnd, _Out_opt_ LPDWORD pdwAttachToThreadId)
 
BOOL WINAPI DECLSPEC_HOTPATCH RegisterConsoleOS2 (BOOL bUnknown)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleOS2OemFormat (BOOL bUnknown)
 
BOOL WINAPI DECLSPEC_HOTPATCH UnregisterConsoleIME (VOID)
 
VOID SetTEBLangID (VOID)
 Internal helper function used to synchronize the current thread's language ID with the one from the console.
 
static BOOL IntGetConsoleKeyboardLayoutName (OUT PVOID pszLayoutName, IN BOOL bAnsi)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetConsoleKeyboardLayoutNameA (OUT LPSTR pszLayoutName)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetConsoleKeyboardLayoutNameW (OUT LPWSTR pszLayoutName)
 
DWORD WINAPI SetLastConsoleEventActive (VOID)
 

Variables

RTL_CRITICAL_SECTION ConsoleLock
 
BOOLEAN ConsoleInitialized
 
static LPCWSTR BaseConFileName = CONSOLE_FILE_NAME
 
static LPCWSTR BaseConInputFileName = CONSOLE_INPUT_FILE_NAME
 
static LPCWSTR BaseConOutputFileName = CONSOLE_OUTPUT_FILE_NAME
 
static PHANDLER_ROUTINE InitialHandler [1]
 
static PHANDLER_ROUTINECtrlHandlers
 
static ULONG NrCtrlHandlers
 
static ULONG NrAllocatedHandlers
 
static BOOLEAN LastCloseNotify = FALSE
 
HANDLE InputWaitHandle = INVALID_HANDLE_VALUE
 
static RTL_CRITICAL_SECTION ExeNameLock
 
static BOOLEAN ExeNameInitialized
 
static WCHAR ExeNameBuffer [EXENAME_LENGTH]
 
static USHORT ExeNameLength
 
static WCHAR StartDirBuffer [MAX_PATH+1]
 
static USHORT StartDirLength
 

Macro Definition Documentation

◆ EXENAME_LENGTH

#define EXENAME_LENGTH   (255 + 1)

Definition at line 40 of file console.c.

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file console.c.

Function Documentation

◆ AddConsoleCtrlHandler()

static BOOL AddConsoleCtrlHandler ( PHANDLER_ROUTINE  HandlerRoutine)
static

Definition at line 2036 of file console.c.

2037{
2038 PHANDLER_ROUTINE* NewCtrlHandlers = NULL;
2039
2040 if (HandlerRoutine == NULL)
2041 {
2042 NtCurrentPeb()->ProcessParameters->ConsoleFlags = TRUE;
2043 return TRUE;
2044 }
2045
2047 {
2048 NewCtrlHandlers = RtlAllocateHeap(RtlGetProcessHeap(),
2049 0,
2050 (NrCtrlHandlers + 4) * sizeof(PHANDLER_ROUTINE));
2051 if (NewCtrlHandlers == NULL)
2052 {
2054 return FALSE;
2055 }
2056
2057 memmove(NewCtrlHandlers, CtrlHandlers, sizeof(PHANDLER_ROUTINE) * NrCtrlHandlers);
2058
2059 if (NrAllocatedHandlers > 1) RtlFreeHeap(RtlGetProcessHeap(), 0, CtrlHandlers);
2060
2061 CtrlHandlers = NewCtrlHandlers;
2063 }
2064
2066
2068 return TRUE;
2069}
#define NtCurrentPeb()
Definition: FLS.c:22
BOOL WINAPI HandlerRoutine(DWORD dwCtrlType)
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:616
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:634
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define SetLastError(x)
Definition: compat.h:752
static ULONG NrCtrlHandlers
Definition: console.c:31
static PHANDLER_ROUTINE * CtrlHandlers
Definition: console.c:30
static ULONG NrAllocatedHandlers
Definition: console.c:32
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define ASSERT(a)
Definition: mode.c:44
BOOL(WINAPI * PHANDLER_ROUTINE)(_In_ DWORD CtrlType)
Definition: wincon.h:257

Referenced by SetConsoleCtrlHandler().

◆ AllocConsole()

BOOL WINAPI DECLSPEC_HOTPATCH AllocConsole ( VOID  )

Definition at line 1365 of file console.c.

1366{
1367 BOOL Success;
1368 CONSOLE_START_INFO ConsoleStartInfo;
1369
1370 PWCHAR ConsoleTitle;
1373 PWCHAR CurDir;
1374
1375 ULONG TitleLength = (MAX_PATH + 1) * sizeof(WCHAR);
1376 ULONG DesktopLength = (MAX_PATH + 1) * sizeof(WCHAR);
1377 ULONG AppNameLength = 128 * sizeof(WCHAR);
1378 ULONG CurDirLength = (MAX_PATH + 1) * sizeof(WCHAR);
1379
1381
1382 if (NtCurrentPeb()->ProcessParameters->ConsoleHandle)
1383 {
1384 DPRINT1("AllocConsole: Allocating a console to a process already having one\n");
1386 Success = FALSE;
1387 goto Quit;
1388 }
1389
1390 /* Set up the console properties */
1392 &TitleLength,
1393 &ConsoleTitle,
1394 &DesktopLength,
1395 &Desktop,
1396 &ConsoleStartInfo);
1397 DPRINT("ConsoleTitle = '%S' - Desktop = '%S'\n",
1398 ConsoleTitle, Desktop);
1399
1400 /* Initialize the Input EXE name */
1401 InitExeName();
1403 &CurDirLength,
1404 &CurDir,
1405 &AppNameLength,
1406 &AppName);
1407 DPRINT("CurDir = '%S' - AppName = '%S'\n",
1408 CurDir, AppName);
1409
1410 Success = IntAllocConsole(ConsoleTitle,
1411 TitleLength,
1412 Desktop,
1413 DesktopLength,
1414 CurDir,
1415 CurDirLength,
1416 AppName,
1417 AppNameLength,
1420 &ConsoleStartInfo);
1421 if (Success)
1422 {
1423 /* Set up the handles */
1424 SetUpHandles(&ConsoleStartInfo);
1425 InputWaitHandle = ConsoleStartInfo.InputWaitHandle;
1426
1427 /* Initialize Console Ctrl Handling */
1429
1430 /* Sync the current thread's LangId with the console's one */
1431 SetTEBLangID();
1432 }
1433
1434Quit:
1436 return Success;
1437}
#define DPRINT1
Definition: precomp.h:8
static CHAR AppName[MAX_PATH]
Definition: dem.c:252
#define MAX_PATH
Definition: compat.h:34
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
VOID InitExeName(VOID)
Definition: console.c:216
DWORD WINAPI ConsoleControlDispatcher(IN LPVOID lpThreadParameter)
Definition: console.c:89
RTL_CRITICAL_SECTION ConsoleLock
Definition: init.c:24
VOID SetTEBLangID(VOID)
Internal helper function used to synchronize the current thread's language ID with the one from the c...
Definition: console.c:3177
HANDLE InputWaitHandle
Definition: console.c:38
VOID InitializeCtrlHandling(VOID)
Definition: console.c:204
VOID SetUpAppName(IN BOOLEAN CaptureStrings, IN OUT LPDWORD CurDirLength, IN OUT LPWSTR *CurDir, IN OUT LPDWORD AppNameLength, IN OUT LPWSTR *AppName)
Definition: console.c:264
static BOOL IntAllocConsole(LPWSTR Title, DWORD TitleLength, LPWSTR Desktop, DWORD DesktopLength, LPWSTR CurDir, DWORD CurDirLength, LPWSTR AppName, DWORD AppNameLength, LPTHREAD_START_ROUTINE CtrlRoutine, LPTHREAD_START_ROUTINE PropRoutine, PCONSOLE_START_INFO ConsoleStartInfo)
Definition: console.c:1257
DWORD WINAPI PropDialogHandler(IN LPVOID lpThreadParameter)
Definition: init.c:34
VOID SetUpConsoleInfo(IN BOOLEAN CaptureTitle, IN OUT LPDWORD pTitleLength, IN OUT LPWSTR *lpTitle OPTIONAL, IN OUT LPDWORD pDesktopLength, IN OUT LPWSTR *lpDesktop OPTIONAL, IN OUT PCONSOLE_START_INFO ConsoleStartInfo)
Definition: init.c:134
VOID SetUpHandles(IN PCONSOLE_START_INFO ConsoleStartInfo)
Definition: init.c:250
@ Success
Definition: eventcreate.c:712
unsigned int BOOL
Definition: ntddk_ex.h:94
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define DPRINT
Definition: sndvol32.h:73
HANDLE InputWaitHandle
Definition: conmsg.h:171
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ AttachConsole()

BOOL WINAPI AttachConsole ( DWORD  dwProcessId)

Definition at line 2678 of file console.c.

2679{
2680 BOOL Success;
2681 CONSOLE_START_INFO ConsoleStartInfo;
2682 DWORD dummy;
2683
2685
2686 if (NtCurrentPeb()->ProcessParameters->ConsoleHandle)
2687 {
2688 DPRINT1("AttachConsole: Attaching a console to a process already having one\n");
2690 Success = FALSE;
2691 goto Quit;
2692 }
2693
2694 /* Set up the console properties */
2696 &dummy,
2697 NULL,
2698 &dummy,
2699 NULL,
2700 &ConsoleStartInfo);
2701
2702 Success = IntAttachConsole(dwProcessId,
2705 &ConsoleStartInfo);
2706 if (Success)
2707 {
2708 /* Set up the handles */
2709 SetUpHandles(&ConsoleStartInfo);
2710 InputWaitHandle = ConsoleStartInfo.InputWaitHandle;
2711
2712 /* Initialize Console Ctrl Handling */
2714
2715 /* Sync the current thread's LangId with the console's one */
2716 SetTEBLangID();
2717 }
2718
2719Quit:
2721 return Success;
2722}
static BOOL IntAttachConsole(DWORD ProcessId, LPTHREAD_START_ROUTINE CtrlRoutine, LPTHREAD_START_ROUTINE PropRoutine, PCONSOLE_START_INFO ConsoleStartInfo)
Definition: console.c:2605
unsigned long DWORD
Definition: ntddk_ex.h:95

◆ CloseConsoleHandle()

BOOL WINAPI DECLSPEC_HOTPATCH CloseConsoleHandle ( HANDLE  hHandle)

Definition at line 1144 of file console.c.

1145{
1146 CONSOLE_API_MESSAGE ApiMessage;
1147 PCONSOLE_CLOSEHANDLE CloseHandleRequest = &ApiMessage.Data.CloseHandleRequest;
1148
1149 CloseHandleRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1150 CloseHandleRequest->Handle = hHandle;
1151
1153 NULL,
1155 sizeof(*CloseHandleRequest));
1156 if (!NT_SUCCESS(ApiMessage.Status))
1157 {
1158 BaseSetLastNTError(ApiMessage.Status);
1159 return FALSE;
1160 }
1161
1162 return TRUE;
1163}
@ ConsolepCloseHandle
Definition: conmsg.h:55
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:167
NTSTATUS NTAPI CsrClientCallServer(_Inout_ PCSR_API_MESSAGE ApiMessage, _Inout_opt_ PCSR_CAPTURE_BUFFER CaptureBuffer, _In_ CSR_API_NUMBER ApiNumber, _In_ ULONG DataLength)
Definition: connect.c:366
CONSOLE_CLOSEHANDLE CloseHandleRequest
Definition: conmsg.h:935
union _CONSOLE_API_MESSAGE::@3644 Data
HANDLE ConsoleHandle
Definition: conmsg.h:626
NTSTATUS Status
Definition: csrmsg.h:110

Referenced by CloseHandle().

◆ ConsoleControlDispatcher()

DWORD WINAPI ConsoleControlDispatcher ( IN LPVOID  lpThreadParameter)

Definition at line 89 of file console.c.

90{
91 DWORD nExitCode = 0;
92 DWORD CodeAndFlag = PtrToUlong(lpThreadParameter);
93 DWORD nCode = CodeAndFlag & MAXLONG;
94 UINT i;
95 EXCEPTION_RECORD erException;
96
97 DPRINT1("Console Dispatcher Active: %lx %lx\n", CodeAndFlag, nCode);
99
100 switch(nCode)
101 {
102 case CTRL_C_EVENT:
103 case CTRL_BREAK_EVENT:
104 {
105 if (IsDebuggerPresent())
106 {
107 erException.ExceptionCode = (nCode == CTRL_C_EVENT ?
109 erException.ExceptionFlags = 0;
110 erException.ExceptionRecord = NULL;
112 erException.NumberParameters = 0;
113
115 {
116 RtlRaiseException(&erException);
117 }
119 {
121
122 if ((nCode != CTRL_C_EVENT) ||
123 (NtCurrentPeb()->ProcessParameters->ConsoleFlags != 1))
124 {
125 for (i = NrCtrlHandlers; i > 0; i--)
126 {
127 if (CtrlHandlers[i - 1](nCode)) break;
128 }
129 }
130
132 }
133 _SEH2_END;
134
135 ExitThread(0);
136 }
137 break;
138 }
139
140 case CTRL_CLOSE_EVENT:
143 break;
144
146 /*
147 * In case the console app hasn't register for last close notification,
148 * just kill this console handler thread. We don't want that such apps
149 * get killed for unexpected reasons. On the contrary apps that registered
150 * can be killed because they expect to be.
151 */
153 break;
154
155 case 4:
157 break;
158
159 default:
160 ASSERT(FALSE);
161 break;
162 }
163
165
167
168 nExitCode = 0;
169 if ((nCode != CTRL_C_EVENT) || (NtCurrentPeb()->ProcessParameters->ConsoleFlags != 1))
170 {
171 for (i = NrCtrlHandlers; i > 0; i--)
172 {
173 if ((i == 1) &&
174 (CodeAndFlag & MINLONG) &&
175 ((nCode == CTRL_LOGOFF_EVENT) || (nCode == CTRL_SHUTDOWN_EVENT)))
176 {
177 DPRINT("Skipping system/service apps\n");
178 break;
179 }
180
181 if (CtrlHandlers[i - 1](nCode))
182 {
183 switch(nCode)
184 {
185 case CTRL_CLOSE_EVENT:
189 nExitCode = CodeAndFlag;
190 break;
191 }
192 break;
193 }
194 }
195 }
196
198
199 ExitThread(nExitCode);
200 return STATUS_SUCCESS;
201}
static BOOL WINAPI DefaultConsoleCtrlHandler(DWORD Event)
Definition: console.c:53
static BOOLEAN LastCloseNotify
Definition: console.c:33
BOOLEAN ConsoleInitialized
Definition: init.c:25
VOID WINAPI ExitProcess(IN UINT uExitCode)
Definition: proc.c:1487
BOOL WINAPI SetThreadPriority(IN HANDLE hThread, IN int nPriority)
Definition: thread.c:700
VOID WINAPI ExitThread(IN DWORD uExitCode)
Definition: thread.c:365
#define PtrToUlong(u)
Definition: config.h:107
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
unsigned int UINT
Definition: ndis.h:50
NTSYSAPI VOID NTAPI RtlRaiseException(_In_ PEXCEPTION_RECORD ExceptionRecord)
#define DBG_CONTROL_BREAK
Definition: ntstatus.h:55
#define DBG_CONTROL_C
Definition: ntstatus.h:52
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:82
#define _SEH2_END
Definition: pseh2_64.h:171
#define _SEH2_TRY
Definition: pseh2_64.h:71
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _EXCEPTION_RECORD * ExceptionRecord
Definition: compat.h:210
DWORD ExceptionCode
Definition: compat.h:208
DWORD NumberParameters
Definition: compat.h:212
DWORD ExceptionFlags
Definition: compat.h:209
PVOID ExceptionAddress
Definition: compat.h:211
#define MAXLONG
Definition: umtypes.h:116
#define MINLONG
Definition: umtypes.h:115
#define CONTROL_C_EXIT
Definition: winbase.h:366
HANDLE WINAPI GetCurrentThread(void)
Definition: proc.c:1148
#define THREAD_PRIORITY_HIGHEST
Definition: winbase.h:310
BOOL WINAPI IsDebuggerPresent(void)
Definition: debugger.c:580
#define CTRL_C_EVENT
Definition: wincon.h:96
#define CTRL_SHUTDOWN_EVENT
Definition: wincon.h:102
#define CTRL_BREAK_EVENT
Definition: wincon.h:97
#define CTRL_LOGOFF_EVENT
Definition: wincon.h:101
#define CTRL_CLOSE_EVENT
Definition: wincon.h:98
#define CTRL_LAST_CLOSE_EVENT
Definition: wincon_undoc.h:75

Referenced by AllocConsole(), AttachConsole(), and ConDllInitialize().

◆ ConsoleMenuControl()

HMENU WINAPI DECLSPEC_HOTPATCH ConsoleMenuControl ( HANDLE  hConsoleOutput,
DWORD  dwCmdIdLow,
DWORD  dwCmdIdHigh 
)

Definition at line 396 of file console.c.

399{
400 CONSOLE_API_MESSAGE ApiMessage;
401 PCONSOLE_MENUCONTROL MenuControlRequest = &ApiMessage.Data.MenuControlRequest;
402
403 MenuControlRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
404 MenuControlRequest->OutputHandle = hConsoleOutput;
405 MenuControlRequest->CmdIdLow = dwCmdIdLow;
406 MenuControlRequest->CmdIdHigh = dwCmdIdHigh;
407 MenuControlRequest->MenuHandle = NULL;
408
410 NULL,
412 sizeof(*MenuControlRequest));
413
414 return MenuControlRequest->MenuHandle;
415}
@ ConsolepMenuControl
Definition: conmsg.h:66
CONSOLE_MENUCONTROL MenuControlRequest
Definition: conmsg.h:976
HANDLE ConsoleHandle
Definition: conmsg.h:692
HANDLE OutputHandle
Definition: conmsg.h:693

Referenced by CreateVdmMenu().

◆ CreateConsoleScreenBuffer()

HANDLE WINAPI CreateConsoleScreenBuffer ( DWORD  dwDesiredAccess,
DWORD  dwShareMode,
CONST SECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD  dwFlags,
LPVOID  lpScreenBufferData 
)

Definition at line 2315 of file console.c.

2320{
2321 CONSOLE_API_MESSAGE ApiMessage;
2322 PCONSOLE_CREATESCREENBUFFER CreateScreenBufferRequest = &ApiMessage.Data.CreateScreenBufferRequest;
2323 PCSR_CAPTURE_BUFFER CaptureBuffer = NULL;
2324 PCONSOLE_GRAPHICS_BUFFER_INFO GraphicsBufferInfo = lpScreenBufferData;
2325
2326 if ( (dwDesiredAccess & ~(GENERIC_READ | GENERIC_WRITE)) ||
2327 (dwShareMode & ~(FILE_SHARE_READ | FILE_SHARE_WRITE)) ||
2329 {
2331 return INVALID_HANDLE_VALUE;
2332 }
2333
2334 CreateScreenBufferRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2335 CreateScreenBufferRequest->DesiredAccess = dwDesiredAccess;
2336 CreateScreenBufferRequest->InheritHandle =
2337 (lpSecurityAttributes ? lpSecurityAttributes->bInheritHandle : FALSE);
2338 CreateScreenBufferRequest->ShareMode = dwShareMode;
2339 CreateScreenBufferRequest->ScreenBufferType = dwFlags;
2340
2342 {
2343 if (CreateScreenBufferRequest->InheritHandle || GraphicsBufferInfo == NULL)
2344 {
2346 return INVALID_HANDLE_VALUE;
2347 }
2348
2349 CreateScreenBufferRequest->GraphicsBufferInfo = *GraphicsBufferInfo;
2350
2351 CaptureBuffer = CsrAllocateCaptureBuffer(1, GraphicsBufferInfo->dwBitMapInfoLength);
2352 if (CaptureBuffer == NULL)
2353 {
2355 return INVALID_HANDLE_VALUE;
2356 }
2357
2358 CsrCaptureMessageBuffer(CaptureBuffer,
2359 (PVOID)GraphicsBufferInfo->lpBitMapInfo,
2360 GraphicsBufferInfo->dwBitMapInfoLength,
2361 (PVOID*)&CreateScreenBufferRequest->GraphicsBufferInfo.lpBitMapInfo);
2362 }
2363
2365 CaptureBuffer,
2367 sizeof(*CreateScreenBufferRequest));
2368
2369 if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
2370
2371 if (!NT_SUCCESS(ApiMessage.Status))
2372 {
2373 BaseSetLastNTError(ApiMessage.Status);
2374 return INVALID_HANDLE_VALUE;
2375 }
2376
2377 if (dwFlags == CONSOLE_GRAPHICS_BUFFER && GraphicsBufferInfo)
2378 {
2379 GraphicsBufferInfo->hMutex = CreateScreenBufferRequest->hMutex ; // CreateScreenBufferRequest->GraphicsBufferInfo.hMutex ;
2380 GraphicsBufferInfo->lpBitMap = CreateScreenBufferRequest->lpBitMap; // CreateScreenBufferRequest->GraphicsBufferInfo.lpBitMap;
2381 }
2382
2383 return CreateScreenBufferRequest->OutputHandle;
2384}
@ ConsolepCreateScreenBuffer
Definition: conmsg.h:61
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define FILE_SHARE_READ
Definition: compat.h:136
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define GENERIC_WRITE
Definition: nt_native.h:90
PCSR_CAPTURE_BUFFER NTAPI CsrAllocateCaptureBuffer(_In_ ULONG ArgumentCount, _In_ ULONG BufferSize)
Definition: capture.c:87
VOID NTAPI CsrFreeCaptureBuffer(_In_ _Frees_ptr_ PCSR_CAPTURE_BUFFER CaptureBuffer)
Definition: capture.c:210
VOID NTAPI CsrCaptureMessageBuffer(_Inout_ PCSR_CAPTURE_BUFFER CaptureBuffer, _In_opt_ PVOID MessageBuffer, _In_ ULONG MessageLength, _Out_ PVOID *CapturedData)
Definition: capture.c:189
CONSOLE_CREATESCREENBUFFER CreateScreenBufferRequest
Definition: conmsg.h:949
CONSOLE_GRAPHICS_BUFFER_INFO GraphicsBufferInfo
Definition: conmsg.h:456
#define CONSOLE_TEXTMODE_BUFFER
Definition: wincon.h:90
#define CONSOLE_GRAPHICS_BUFFER
Definition: wincon_undoc.h:68
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

Referenced by GetInputOutputHandles(), testScreenBuffer(), VgaConsoleCreateGraphicsScreen(), and wmain().

◆ DefaultConsoleCtrlHandler()

static BOOL WINAPI DefaultConsoleCtrlHandler ( DWORD  Event)
static

Definition at line 53 of file console.c.

54{
55 DPRINT("Default handler called: %lx\n", Event);
56 switch(Event)
57 {
58 case CTRL_C_EVENT:
59 DPRINT("Ctrl-C Event\n");
60 break;
61
63 DPRINT("Ctrl-Break Event\n");
64 break;
65
67 DPRINT("Ctrl Close Event\n");
68 break;
69
71 DPRINT("Ctrl Last Close Event\n");
72 break;
73
75 DPRINT("Ctrl Logoff Event\n");
76 break;
77
79 DPRINT("Ctrl Shutdown Event\n");
80 break;
81 }
82
84 return TRUE;
85}

Referenced by ConsoleControlDispatcher(), and InitializeCtrlHandling().

◆ DuplicateConsoleHandle()

HANDLE WINAPI DECLSPEC_HOTPATCH DuplicateConsoleHandle ( HANDLE  hSourceHandle,
DWORD  dwDesiredAccess,
BOOL  bInheritHandle,
DWORD  dwOptions 
)

Definition at line 424 of file console.c.

428{
429 CONSOLE_API_MESSAGE ApiMessage;
430 PCONSOLE_DUPLICATEHANDLE DuplicateHandleRequest = &ApiMessage.Data.DuplicateHandleRequest;
431
434 (dwDesiredAccess & ~(GENERIC_READ | GENERIC_WRITE))) )
435 {
438 }
439
440 DuplicateHandleRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
441 DuplicateHandleRequest->SourceHandle = hSourceHandle;
442 DuplicateHandleRequest->DesiredAccess = dwDesiredAccess;
443 DuplicateHandleRequest->InheritHandle = bInheritHandle;
444 DuplicateHandleRequest->Options = dwOptions;
445
447 NULL,
449 sizeof(*DuplicateHandleRequest));
450 if (!NT_SUCCESS(ApiMessage.Status))
451 {
452 BaseSetLastNTError(ApiMessage.Status);
454 }
455
456 return DuplicateHandleRequest->TargetHandle;
457}
@ ConsolepDuplicateHandle
Definition: conmsg.h:52
static BOOL bInheritHandle
Definition: pipe.c:82
DWORD dwOptions
Definition: solitaire.cpp:25
CONSOLE_DUPLICATEHANDLE DuplicateHandleRequest
Definition: conmsg.h:937
#define DUPLICATE_SAME_ACCESS
#define DUPLICATE_CLOSE_SOURCE

Referenced by DuplicateHandle().

◆ FlushConsoleInputBuffer()

BOOL WINAPI DECLSPEC_HOTPATCH FlushConsoleInputBuffer ( HANDLE  hConsoleInput)

Definition at line 1829 of file console.c.

1830{
1831 CONSOLE_API_MESSAGE ApiMessage;
1832 PCONSOLE_FLUSHINPUTBUFFER FlushInputBufferRequest = &ApiMessage.Data.FlushInputBufferRequest;
1833
1834 FlushInputBufferRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1835 FlushInputBufferRequest->InputHandle = hConsoleInput;
1836
1838 NULL,
1840 sizeof(*FlushInputBufferRequest));
1841 if (!NT_SUCCESS(ApiMessage.Status))
1842 {
1843 BaseSetLastNTError(ApiMessage.Status);
1844 return FALSE;
1845 }
1846
1847 return TRUE;
1848}
@ ConsolepFlushInputBuffer
Definition: conmsg.h:40
CONSOLE_FLUSHINPUTBUFFER FlushInputBufferRequest
Definition: conmsg.h:956

◆ FreeConsole()

BOOL WINAPI DECLSPEC_HOTPATCH FreeConsole ( VOID  )

Definition at line 1446 of file console.c.

1447{
1448 BOOL Success = TRUE;
1449 CONSOLE_API_MESSAGE ApiMessage;
1450 PCONSOLE_FREECONSOLE FreeConsoleRequest = &ApiMessage.Data.FreeConsoleRequest;
1451 HANDLE ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1452
1454
1455 /* We must have a non-trivial handle to close */
1456 if (ConsoleHandle == NULL) // IsConsoleHandle(ConsoleHandle)
1457 {
1459 Success = FALSE;
1460 goto Quit;
1461 }
1462
1463 /* Set up the data to send to the Console Server */
1464 FreeConsoleRequest->ConsoleHandle = ConsoleHandle;
1465
1466 /* Call the server */
1468 NULL,
1470 sizeof(*FreeConsoleRequest));
1471
1472 /* Check for success */
1473 if (!NT_SUCCESS(ApiMessage.Status))
1474 {
1475 BaseSetLastNTError(ApiMessage.Status);
1476 Success = FALSE;
1477 goto Quit;
1478 }
1479
1480 /* Reset the console handle */
1481 NtCurrentPeb()->ProcessParameters->ConsoleHandle = NULL;
1482
1483 /* Close the associated input handle */
1486
1487Quit:
1489 return Success;
1490}
@ ConsolepFree
Definition: conmsg.h:58
#define CloseHandle
Definition: compat.h:739
CONSOLE_FREECONSOLE FreeConsoleRequest
Definition: conmsg.h:926
HANDLE ConsoleHandle
Definition: conmsg.h:305

◆ GenerateConsoleCtrlEvent()

BOOL WINAPI DECLSPEC_HOTPATCH GenerateConsoleCtrlEvent ( DWORD  dwCtrlEvent,
DWORD  dwProcessGroupId 
)

Definition at line 2134 of file console.c.

2136{
2137 CONSOLE_API_MESSAGE ApiMessage;
2138 PCONSOLE_GENERATECTRLEVENT GenerateCtrlEventRequest = &ApiMessage.Data.GenerateCtrlEventRequest;
2139
2140 if (dwCtrlEvent != CTRL_C_EVENT && dwCtrlEvent != CTRL_BREAK_EVENT)
2141 {
2143 return FALSE;
2144 }
2145
2146 GenerateCtrlEventRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2147 GenerateCtrlEventRequest->CtrlEvent = dwCtrlEvent;
2148 GenerateCtrlEventRequest->ProcessGroupId = dwProcessGroupId;
2149
2151 NULL,
2153 sizeof(*GenerateCtrlEventRequest));
2154 if (!NT_SUCCESS(ApiMessage.Status))
2155 {
2156 BaseSetLastNTError(ApiMessage.Status);
2157 return FALSE;
2158 }
2159
2160 return TRUE;
2161}
@ ConsolepGenerateCtrlEvent
Definition: conmsg.h:89
CONSOLE_GENERATECTRLEVENT GenerateCtrlEventRequest
Definition: conmsg.h:930

Referenced by TerminateShell(), testCtrlHandler(), CConsole::Write(), and WriteToPipeThread().

◆ GetConsoleCharType()

BOOL WINAPI GetConsoleCharType ( HANDLE  hConsole,
COORD  Coord,
PDWORD  Type 
)

Definition at line 2984 of file console.c.

2985{
2986 STUB;
2987 return FALSE;
2988}
#define STUB
Definition: kernel32.h:27

◆ GetConsoleCP()

UINT WINAPI DECLSPEC_HOTPATCH GetConsoleCP ( VOID  )

Definition at line 2393 of file console.c.

2394{
2395 CONSOLE_API_MESSAGE ApiMessage;
2396 PCONSOLE_GETINPUTOUTPUTCP GetConsoleCPRequest = &ApiMessage.Data.GetConsoleCPRequest;
2397
2398 /* Get the Input Code Page */
2399 GetConsoleCPRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2400 GetConsoleCPRequest->OutputCP = FALSE;
2401
2403 NULL,
2405 sizeof(*GetConsoleCPRequest));
2406 if (!NT_SUCCESS(ApiMessage.Status))
2407 {
2408 BaseSetLastNTError(ApiMessage.Status);
2409 return 0;
2410 }
2411
2412 return GetConsoleCPRequest->CodePage;
2413}
@ ConsolepGetCP
Definition: conmsg.h:84
CONSOLE_GETINPUTOUTPUTCP GetConsoleCPRequest
Definition: conmsg.h:1014

Referenced by _getch_nolock(), _tmain(), cmd_start(), ConInString(), doChild(), Execute(), FileGetString(), SetConsoleCPState(), START_TEST(), test_Console(), and wmain().

◆ GetConsoleCursorInfo()

BOOL WINAPI GetConsoleCursorInfo ( HANDLE  hConsoleOutput,
PCONSOLE_CURSOR_INFO  lpConsoleCursorInfo 
)

Definition at line 1704 of file console.c.

1706{
1707 CONSOLE_API_MESSAGE ApiMessage;
1708 PCONSOLE_GETSETCURSORINFO CursorInfoRequest = &ApiMessage.Data.CursorInfoRequest;
1709
1710 if (!lpConsoleCursorInfo)
1711 {
1712 if (!hConsoleOutput)
1714 else
1716
1717 return FALSE;
1718 }
1719
1720 CursorInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1721 CursorInfoRequest->OutputHandle = hConsoleOutput;
1722
1724 NULL,
1726 sizeof(*CursorInfoRequest));
1727 if (!NT_SUCCESS(ApiMessage.Status))
1728 {
1729 BaseSetLastNTError(ApiMessage.Status);
1730 return FALSE;
1731 }
1732
1733 *lpConsoleCursorInfo = CursorInfoRequest->Info;
1734
1735 return TRUE;
1736}
@ ConsolepGetCursorInfo
Definition: conmsg.h:33
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
CONSOLE_GETSETCURSORINFO CursorInfoRequest
Definition: conmsg.h:944
CONSOLE_CURSOR_INFO Info
Definition: conmsg.h:346
#define ERROR_INVALID_ACCESS
Definition: winerror.h:115

Referenced by testCursorInfo(), and VgaConsoleInitialize().

◆ GetConsoleCursorMode()

BOOL WINAPI DECLSPEC_HOTPATCH GetConsoleCursorMode ( HANDLE  hConsole,
PBOOL  pUnknown1,
PBOOL  pUnknown2 
)

Definition at line 2993 of file console.c.

2994{
2995 STUB;
2996 return FALSE;
2997}

◆ GetConsoleDisplayMode()

BOOL WINAPI GetConsoleDisplayMode ( LPDWORD  lpModeFlags)

Definition at line 526 of file console.c.

527{
528 CONSOLE_API_MESSAGE ApiMessage;
529 PCONSOLE_GETDISPLAYMODE GetDisplayModeRequest = &ApiMessage.Data.GetDisplayModeRequest;
530
531 if (lpModeFlags == NULL)
532 {
534 return FALSE;
535 }
536
537 GetDisplayModeRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
538
540 NULL,
542 sizeof(*GetDisplayModeRequest));
543 if (!NT_SUCCESS(ApiMessage.Status))
544 {
545 BaseSetLastNTError(ApiMessage.Status);
546 return FALSE;
547 }
548
549 *lpModeFlags = GetDisplayModeRequest->DisplayMode; // ModeFlags
550
551 return TRUE;
552}
@ ConsolepGetDisplayMode
Definition: conmsg.h:72
CONSOLE_GETDISPLAYMODE GetDisplayModeRequest
Definition: conmsg.h:960

Referenced by NotifySoundSentry().

◆ GetConsoleFontInfo()

DWORD WINAPI GetConsoleFontInfo ( IN HANDLE  hConsoleOutput,
IN BOOL  bMaximumWindow,
IN DWORD  nFontCount,
OUT PCONSOLE_FONT_INFO  lpConsoleFontInfo 
)

Definition at line 561 of file console.c.

565{
566 CONSOLE_API_MESSAGE ApiMessage;
567 PCONSOLE_GETFONTINFO GetFontInfoRequest = &ApiMessage.Data.GetFontInfoRequest;
568 PCSR_CAPTURE_BUFFER CaptureBuffer;
569
570 GetFontInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
571 GetFontInfoRequest->OutputHandle = hConsoleOutput;
572 GetFontInfoRequest->MaximumWindow = bMaximumWindow;
573 GetFontInfoRequest->NumFonts = nFontCount;
574
575 CaptureBuffer = CsrAllocateCaptureBuffer(1, nFontCount * sizeof(CONSOLE_FONT_INFO));
576 if (CaptureBuffer == NULL)
577 {
578 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
580 return 0;
581 }
582
583 CsrAllocateMessagePointer(CaptureBuffer,
584 nFontCount * sizeof(CONSOLE_FONT_INFO),
585 (PVOID*)&GetFontInfoRequest->FontInfo);
586
588 CaptureBuffer,
590 sizeof(*GetFontInfoRequest));
591 if (!NT_SUCCESS(ApiMessage.Status))
592 {
593 BaseSetLastNTError(ApiMessage.Status);
594 }
595 else
596 {
597 RtlCopyMemory(lpConsoleFontInfo,
598 GetFontInfoRequest->FontInfo,
599 GetFontInfoRequest->NumFonts * sizeof(CONSOLE_FONT_INFO));
600 }
601
602 CsrFreeCaptureBuffer(CaptureBuffer);
603 return GetFontInfoRequest->NumFonts;
604}
@ ConsolepGetFontInfo
Definition: conmsg.h:35
ULONG NTAPI CsrAllocateMessagePointer(_Inout_ PCSR_CAPTURE_BUFFER CaptureBuffer, _In_ ULONG MessageLength, _Out_ PVOID *CapturedData)
Definition: capture.c:152
CONSOLE_GETFONTINFO GetFontInfoRequest
Definition: conmsg.h:966
HANDLE ConsoleHandle
Definition: conmsg.h:411
BOOLEAN MaximumWindow
Definition: conmsg.h:413
HANDLE OutputHandle
Definition: conmsg.h:412
PCONSOLE_FONT_INFO FontInfo
Definition: conmsg.h:414
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263

◆ GetConsoleFontSize()

COORD WINAPI DECLSPEC_HOTPATCH GetConsoleFontSize ( IN HANDLE  hConsoleOutput,
IN DWORD  nFont 
)

Definition at line 613 of file console.c.

615{
616 CONSOLE_API_MESSAGE ApiMessage;
617 PCONSOLE_GETFONTSIZE GetFontSizeRequest = &ApiMessage.Data.GetFontSizeRequest;
618 COORD Empty = {0, 0};
619
620 GetFontSizeRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
621 GetFontSizeRequest->OutputHandle = hConsoleOutput;
622 GetFontSizeRequest->FontIndex = nFont;
623
625 NULL,
627 sizeof(*GetFontSizeRequest));
628 if (!NT_SUCCESS(ApiMessage.Status))
629 {
630 BaseSetLastNTError(ApiMessage.Status);
631 return Empty;
632 }
633
634 return GetFontSizeRequest->FontSize;
635}
@ ConsolepGetFontSize
Definition: conmsg.h:36
@ Empty
Definition: npfs.h:125
CONSOLE_GETFONTSIZE GetFontSizeRequest
Definition: conmsg.h:967
HANDLE ConsoleHandle
Definition: conmsg.h:420
HANDLE OutputHandle
Definition: conmsg.h:421
Definition: bl.h:1338

Referenced by test_GetConsoleFontInfo(), test_GetConsoleFontSize(), test_GetCurrentConsoleFont(), and test_GetLargestConsoleWindowSize().

◆ GetConsoleHandleInformation()

BOOL WINAPI GetConsoleHandleInformation ( IN HANDLE  hHandle,
OUT LPDWORD  lpdwFlags 
)

Definition at line 465 of file console.c.

467{
468 CONSOLE_API_MESSAGE ApiMessage;
469 PCONSOLE_GETHANDLEINFO GetHandleInfoRequest = &ApiMessage.Data.GetHandleInfoRequest;
470
471 GetHandleInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
472 GetHandleInfoRequest->Handle = hHandle;
473
475 NULL,
477 sizeof(*GetHandleInfoRequest));
478 if (!NT_SUCCESS(ApiMessage.Status))
479 {
480 BaseSetLastNTError(ApiMessage.Status);
481 return FALSE;
482 }
483
484 *lpdwFlags = GetHandleInfoRequest->Flags;
485
486 return TRUE;
487}
@ ConsolepGetHandleInformation
Definition: conmsg.h:53
CONSOLE_GETHANDLEINFO GetHandleInfoRequest
Definition: conmsg.h:938

Referenced by GetHandleInformation().

◆ GetConsoleHardwareState()

BOOL WINAPI GetConsoleHardwareState ( HANDLE  hConsoleOutput,
PDWORD  Flags,
PDWORD  State 
)

Definition at line 643 of file console.c.

646{
647 CONSOLE_API_MESSAGE ApiMessage;
648 PCONSOLE_GETSETHWSTATE HardwareStateRequest = &ApiMessage.Data.HardwareStateRequest;
649
650 DPRINT1("GetConsoleHardwareState(%lu, 0x%p) UNIMPLEMENTED!\n", Flags, State);
651
652 if (Flags == NULL || State == NULL)
653 {
655 return FALSE;
656 }
657
658 HardwareStateRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
659 HardwareStateRequest->OutputHandle = hConsoleOutput;
660
662 NULL,
664 sizeof(*HardwareStateRequest));
665 if (!NT_SUCCESS(ApiMessage.Status))
666 {
667 BaseSetLastNTError(ApiMessage.Status);
668 return FALSE;
669 }
670
671 *Flags = HardwareStateRequest->Flags;
672 *State = HardwareStateRequest->State;
673
674 return TRUE;
675}
@ ConsolepGetHardwareState
Definition: conmsg.h:70
CONSOLE_GETSETHWSTATE HardwareStateRequest
Definition: conmsg.h:962
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

◆ GetConsoleInputExeNameA()

DWORD WINAPI DECLSPEC_HOTPATCH GetConsoleInputExeNameA ( IN DWORD  nBufferLength,
OUT LPSTR  lpExeName 
)

Definition at line 2946 of file console.c.

2948{
2950 DWORD ExeLength;
2951 UNICODE_STRING BufferU;
2952 ANSI_STRING BufferA;
2954
2955 /* Get the UNICODE name */
2957
2958 if ((ExeLength == 0) || (ExeLength >= EXENAME_LENGTH))
2959 return ExeLength;
2960
2961 /* Initialize the strings for conversion */
2962 RtlInitUnicodeString(&BufferU, Buffer);
2963 BufferA.Length = 0;
2965 BufferA.Buffer = lpExeName;
2966
2967 /* Convert UNICODE name to ANSI, copying as much chars as it can fit */
2968 Status = RtlUnicodeStringToAnsiString(&BufferA, &BufferU, FALSE);
2969 if (!NT_SUCCESS(Status))
2970 {
2972 {
2974 return ExeLength + 1;
2975 }
2977 }
2978
2979 return ExeLength;
2980}
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
#define EXENAME_LENGTH
Definition: console.c:40
DWORD WINAPI DECLSPEC_HOTPATCH GetConsoleInputExeNameW(IN DWORD nBufferLength, OUT LPWSTR lpExeName)
Definition: console.c:2907
Status
Definition: gdiplustypes.h:25
static DWORD LPSTR lpExeName
Definition: process.c:72
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
USHORT MaximumLength
Definition: env_spec_w32.h:377
_In_ LPCSTR _In_opt_ LPCSTR _In_ DWORD nBufferLength
Definition: winbase.h:3114
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185

Referenced by init_function_pointers().

◆ GetConsoleInputExeNameW()

DWORD WINAPI DECLSPEC_HOTPATCH GetConsoleInputExeNameW ( IN DWORD  nBufferLength,
OUT LPWSTR  lpExeName 
)

Definition at line 2907 of file console.c.

2909{
2911 {
2912 /* Buffer is not large enough! Return the correct size. */
2914 return ExeNameLength + 1;
2915 }
2916
2918 _SEH2_TRY
2919 {
2920 /* Copy the input EXE name and NULL-terminate it */
2923 }
2925 {
2927 }
2928 _SEH2_END;
2929
2930 return TRUE;
2931}
static WCHAR ExeNameBuffer[EXENAME_LENGTH]
Definition: console.c:43
static RTL_CRITICAL_SECTION ExeNameLock
Definition: console.c:41
static USHORT ExeNameLength
Definition: console.c:44
#define UNICODE_NULL
#define _SEH2_FINALLY
Definition: pseh2_64.h:130

Referenced by GetConsoleInputExeNameA().

◆ GetConsoleInputWaitHandle()

◆ GetConsoleKeyboardLayoutNameA()

BOOL WINAPI DECLSPEC_HOTPATCH GetConsoleKeyboardLayoutNameA ( OUT LPSTR  pszLayoutName)

Definition at line 3264 of file console.c.

3265{
3266 return IntGetConsoleKeyboardLayoutName(pszLayoutName, TRUE);
3267}
static BOOL IntGetConsoleKeyboardLayoutName(OUT PVOID pszLayoutName, IN BOOL bAnsi)
Definition: console.c:3216

◆ GetConsoleKeyboardLayoutNameW()

BOOL WINAPI DECLSPEC_HOTPATCH GetConsoleKeyboardLayoutNameW ( OUT LPWSTR  pszLayoutName)

Definition at line 3275 of file console.c.

3276{
3277 return IntGetConsoleKeyboardLayoutName(pszLayoutName, FALSE);
3278}

◆ GetConsoleMode()

BOOL WINAPI GetConsoleMode ( HANDLE  hConsoleHandle,
LPDWORD  lpMode 
)

Definition at line 1571 of file console.c.

1573{
1574 CONSOLE_API_MESSAGE ApiMessage;
1575 PCONSOLE_GETSETCONSOLEMODE ConsoleModeRequest = &ApiMessage.Data.ConsoleModeRequest;
1576
1577 if (lpMode == NULL)
1578 {
1580 return FALSE;
1581 }
1582
1583 ConsoleModeRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1584 ConsoleModeRequest->Handle = hConsoleHandle;
1585
1587 NULL,
1589 sizeof(*ConsoleModeRequest));
1590 if (!NT_SUCCESS(ApiMessage.Status))
1591 {
1592 BaseSetLastNTError(ApiMessage.Status);
1593 return FALSE;
1594 }
1595
1596 *lpMode = ConsoleModeRequest->Mode;
1597
1598 return TRUE;
1599}
@ ConsolepGetMode
Definition: conmsg.h:29
CONSOLE_GETSETCONSOLEMODE ConsoleModeRequest
Definition: conmsg.h:959

Referenced by _getch(), _kbhit(), _read_nolock(), _tmain(), cfgets(), Confirm(), ConInDisable(), ConInEnable(), ConInString(), ConsoleAttach(), ConsolePager(), doChild(), EnableExtraHardware(), getpass(), CConsole::Init(), IsConsoleHandle(), PagePrompt(), ReadFile(), ReadFromConsole(), SetInsert(), test_Console(), test_WriteConsoleInputA(), test_WriteConsoleInputW(), testWriteNotWrappedNotProcessed(), testWriteNotWrappedProcessed(), testWriteWrappedNotProcessed(), testWriteWrappedProcessed(), and write_requires_double_translation_nolock().

◆ GetConsoleNlsMode()

BOOL WINAPI DECLSPEC_HOTPATCH GetConsoleNlsMode ( HANDLE  hConsole,
LPDWORD  lpMode 
)

Definition at line 3011 of file console.c.

3012{
3013 STUB;
3014 return FALSE;
3015}

◆ GetConsoleOutputCP()

UINT WINAPI DECLSPEC_HOTPATCH GetConsoleOutputCP ( VOID  )

Definition at line 2453 of file console.c.

2454{
2455 CONSOLE_API_MESSAGE ApiMessage;
2456 PCONSOLE_GETINPUTOUTPUTCP GetConsoleCPRequest = &ApiMessage.Data.GetConsoleCPRequest;
2457
2458 /* Get the Output Code Page */
2459 GetConsoleCPRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2460 GetConsoleCPRequest->OutputCP = TRUE;
2461
2463 NULL,
2465 sizeof(*GetConsoleCPRequest));
2466 if (!NT_SUCCESS(ApiMessage.Status))
2467 {
2468 BaseSetLastNTError(ApiMessage.Status);
2469 return 0;
2470 }
2471
2472 return GetConsoleCPRequest->CodePage;
2473}

Referenced by _tmain(), cmd_start(), ConPagerWorker(), ConWrite(), doChild(), doTest_CP_ThreadLang_(), Execute(), output_writeconsole(), print_string(), ShowConsoleCPStatus(), ShowConsoleStatus(), START_TEST(), test_Console(), test_cp855(), test_cp932(), test_CP_ThreadLang(), testScreenBuffer(), wmain(), write_double_translated_ansi_nolock(), and XCOPY_wprintf().

◆ GetConsoleProcessList()

DWORD WINAPI GetConsoleProcessList ( LPDWORD  lpdwProcessList,
DWORD  dwProcessCount 
)

Definition at line 2515 of file console.c.

2517{
2518 CONSOLE_API_MESSAGE ApiMessage;
2519 PCONSOLE_GETPROCESSLIST GetProcessListRequest = &ApiMessage.Data.GetProcessListRequest;
2520 PCSR_CAPTURE_BUFFER CaptureBuffer;
2521 ULONG nProcesses = 0;
2522
2523 if (lpdwProcessList == NULL || dwProcessCount == 0)
2524 {
2526 return 0;
2527 }
2528
2529 CaptureBuffer = CsrAllocateCaptureBuffer(1, dwProcessCount * sizeof(DWORD));
2530 if (CaptureBuffer == NULL)
2531 {
2532 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
2534 return 0;
2535 }
2536
2537 GetProcessListRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2538 GetProcessListRequest->ProcessCount = dwProcessCount;
2539
2540 CsrAllocateMessagePointer(CaptureBuffer,
2541 dwProcessCount * sizeof(DWORD),
2542 (PVOID*)&GetProcessListRequest->ProcessIdsList);
2543
2545 CaptureBuffer,
2547 sizeof(*GetProcessListRequest));
2548 if (!NT_SUCCESS(ApiMessage.Status))
2549 {
2550 BaseSetLastNTError(ApiMessage.Status);
2551 }
2552 else
2553 {
2554 nProcesses = GetProcessListRequest->ProcessCount;
2555 if (dwProcessCount >= nProcesses)
2556 {
2557 RtlCopyMemory(lpdwProcessList, GetProcessListRequest->ProcessIdsList, nProcesses * sizeof(DWORD));
2558 }
2559 }
2560
2561 CsrFreeCaptureBuffer(CaptureBuffer);
2562 return nProcesses;
2563}
@ ConsolepGetProcessList
Definition: conmsg.h:106
CONSOLE_GETPROCESSLIST GetProcessListRequest
Definition: conmsg.h:929

Referenced by init_function_pointers().

◆ GetConsoleScreenBufferInfo()

BOOL WINAPI GetConsoleScreenBufferInfo ( HANDLE  hConsoleOutput,
PCONSOLE_SCREEN_BUFFER_INFO  lpConsoleScreenBufferInfo 
)

Definition at line 1498 of file console.c.

1500{
1501 CONSOLE_API_MESSAGE ApiMessage;
1502 PCONSOLE_GETSCREENBUFFERINFO ScreenBufferInfoRequest = &ApiMessage.Data.ScreenBufferInfoRequest;
1503
1504 if (lpConsoleScreenBufferInfo == NULL)
1505 {
1507 return FALSE;
1508 }
1509
1510 ScreenBufferInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1511 ScreenBufferInfoRequest->OutputHandle = hConsoleOutput;
1512
1514 NULL,
1516 sizeof(*ScreenBufferInfoRequest));
1517 if (!NT_SUCCESS(ApiMessage.Status))
1518 {
1519 BaseSetLastNTError(ApiMessage.Status);
1520 return FALSE;
1521 }
1522
1523 lpConsoleScreenBufferInfo->dwSize = ScreenBufferInfoRequest->ScreenBufferSize;
1524 lpConsoleScreenBufferInfo->dwCursorPosition = ScreenBufferInfoRequest->CursorPosition;
1525 lpConsoleScreenBufferInfo->wAttributes = ScreenBufferInfoRequest->Attributes;
1526 lpConsoleScreenBufferInfo->srWindow.Left = ScreenBufferInfoRequest->ViewOrigin.X;
1527 lpConsoleScreenBufferInfo->srWindow.Top = ScreenBufferInfoRequest->ViewOrigin.Y;
1528 lpConsoleScreenBufferInfo->srWindow.Right = ScreenBufferInfoRequest->ViewOrigin.X + ScreenBufferInfoRequest->ViewSize.X - 1;
1529 lpConsoleScreenBufferInfo->srWindow.Bottom = ScreenBufferInfoRequest->ViewOrigin.Y + ScreenBufferInfoRequest->ViewSize.Y - 1;
1530 lpConsoleScreenBufferInfo->dwMaximumWindowSize = ScreenBufferInfoRequest->MaximumViewSize;
1531
1532 return TRUE;
1533}
@ ConsolepGetScreenBufferInfo
Definition: conmsg.h:32
CONSOLE_GETSCREENBUFFERINFO ScreenBufferInfoRequest
Definition: conmsg.h:951
ULONG Y
Definition: bl.h:1340
ULONG X
Definition: bl.h:1339
SHORT Right
Definition: blue.h:34
SHORT Left
Definition: blue.h:32
SHORT Top
Definition: blue.h:33
SHORT Bottom
Definition: blue.h:35

◆ GetConsoleSelectionInfo()

BOOL WINAPI GetConsoleSelectionInfo ( PCONSOLE_SELECTION_INFO  lpConsoleSelectionInfo)

Definition at line 2571 of file console.c.

2572{
2573 CONSOLE_API_MESSAGE ApiMessage;
2574 PCONSOLE_GETSELECTIONINFO GetSelectionInfoRequest = &ApiMessage.Data.GetSelectionInfoRequest;
2575
2576 if (lpConsoleSelectionInfo == NULL)
2577 {
2579 return FALSE;
2580 }
2581
2582 GetSelectionInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2583
2585 NULL,
2587 sizeof(*GetSelectionInfoRequest));
2588 if (!NT_SUCCESS(ApiMessage.Status))
2589 {
2590 BaseSetLastNTError(ApiMessage.Status);
2591 return FALSE;
2592 }
2593
2594 *lpConsoleSelectionInfo = GetSelectionInfoRequest->Info;
2595
2596 return TRUE;
2597}
@ ConsolepGetSelectionInfo
Definition: conmsg.h:105
CONSOLE_GETSELECTIONINFO GetSelectionInfoRequest
Definition: conmsg.h:955
CONSOLE_SELECTION_INFO Info
Definition: conmsg.h:844

◆ GetConsoleTitleA()

DWORD WINAPI DECLSPEC_HOTPATCH GetConsoleTitleA ( LPSTR  lpConsoleTitle,
DWORD  nSize 
)

Definition at line 2237 of file console.c.

2239{
2240 return IntGetConsoleTitle(lpConsoleTitle, nSize, FALSE);
2241}
static DWORD IntGetConsoleTitle(LPVOID lpConsoleTitle, DWORD dwNumChars, BOOLEAN bUnicode)
Definition: console.c:2165
*nSize LPSTR _Inout_ LPDWORD nSize
Definition: winbase.h:2125

◆ GetConsoleTitleW()

DWORD WINAPI DECLSPEC_HOTPATCH GetConsoleTitleW ( LPWSTR  lpConsoleTitle,
DWORD  nSize 
)

Definition at line 2224 of file console.c.

2226{
2227 return IntGetConsoleTitle(lpConsoleTitle, nSize, TRUE);
2228}

◆ GetConsoleWindow()

HWND WINAPI DECLSPEC_HOTPATCH GetConsoleWindow ( VOID  )

Definition at line 2731 of file console.c.

2732{
2733 CONSOLE_API_MESSAGE ApiMessage;
2734 PCONSOLE_GETWINDOW GetWindowRequest = &ApiMessage.Data.GetWindowRequest;
2735
2736 GetWindowRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2737
2739 NULL,
2741 sizeof(*GetWindowRequest));
2742 if (!NT_SUCCESS(ApiMessage.Status))
2743 {
2744 BaseSetLastNTError(ApiMessage.Status);
2745 return (HWND)NULL;
2746 }
2747
2748 return GetWindowRequest->WindowHandle;
2749}
@ ConsolepGetConsoleWindow
Definition: conmsg.h:91
CONSOLE_GETWINDOW GetWindowRequest
Definition: conmsg.h:979
HANDLE ConsoleHandle
Definition: conmsg.h:716

Referenced by ConsoleInitUI(), START_TEST(), test_GetConsoleFontSize(), and WaitWindows().

◆ GetCurrentConsoleFont()

BOOL WINAPI GetCurrentConsoleFont ( IN HANDLE  hConsoleOutput,
IN BOOL  bMaximumWindow,
OUT PCONSOLE_FONT_INFO  lpConsoleCurrentFont 
)

Definition at line 694 of file console.c.

697{
698 CONSOLE_API_MESSAGE ApiMessage;
699 PCONSOLE_GETCURRENTFONT GetCurrentFontRequest = &ApiMessage.Data.GetCurrentFontRequest;
700
701 GetCurrentFontRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
702 GetCurrentFontRequest->OutputHandle = hConsoleOutput;
703 GetCurrentFontRequest->MaximumWindow = bMaximumWindow;
704
706 NULL,
708 sizeof(*GetCurrentFontRequest));
709 if (!NT_SUCCESS(ApiMessage.Status))
710 {
711 BaseSetLastNTError(ApiMessage.Status);
712 return FALSE;
713 }
714
715 lpConsoleCurrentFont->dwFontSize = GetCurrentFontRequest->FontSize;
716 lpConsoleCurrentFont->nFont = GetCurrentFontRequest->FontIndex;
717
718 return TRUE;
719}
@ ConsolepGetCurrentFont
Definition: conmsg.h:37
CONSOLE_GETCURRENTFONT GetCurrentFontRequest
Definition: conmsg.h:968

Referenced by test_GetConsoleFontInfo(), test_GetConsoleFontSize(), test_GetCurrentConsoleFont(), and test_GetLargestConsoleWindowSize().

◆ GetCurrentExeName()

USHORT GetCurrentExeName ( OUT PWCHAR  ExeName,
IN USHORT  BufferSize 
)

Definition at line 316 of file console.c.

318{
319 USHORT ExeLength;
320
322 {
324
325 if (BufferSize > ExeNameLength * sizeof(WCHAR))
326 BufferSize = ExeNameLength * sizeof(WCHAR);
327
329
331 ExeLength = BufferSize;
332 }
333 else
334 {
335 *ExeName = UNICODE_NULL;
336 ExeLength = 0;
337 }
338
339 return ExeLength;
340}
#define BufferSize
Definition: mmc.h:75
static BOOLEAN ExeNameInitialized
Definition: console.c:42
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254

Referenced by IntReadConsole().

◆ GetLargestConsoleWindowSize()

COORD WINAPI DECLSPEC_HOTPATCH GetLargestConsoleWindowSize ( HANDLE  hConsoleOutput)

Definition at line 1675 of file console.c.

1676{
1677 CONSOLE_API_MESSAGE ApiMessage;
1678 PCONSOLE_GETLARGESTWINDOWSIZE GetLargestWindowSizeRequest = &ApiMessage.Data.GetLargestWindowSizeRequest;
1679
1680 GetLargestWindowSizeRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1681 GetLargestWindowSizeRequest->OutputHandle = hConsoleOutput;
1682 GetLargestWindowSizeRequest->Size.X = 0;
1683 GetLargestWindowSizeRequest->Size.Y = 0;
1684
1686 NULL,
1688 sizeof(*GetLargestWindowSizeRequest));
1689 if (!NT_SUCCESS(ApiMessage.Status))
1690 {
1691 BaseSetLastNTError(ApiMessage.Status);
1692 }
1693
1694 DPRINT("GetLargestConsoleWindowSize, X = %d, Y = %d\n", GetLargestWindowSizeRequest->Size.X, GetLargestWindowSizeRequest->Size.Y);
1695 return GetLargestWindowSizeRequest->Size;
1696}
@ ConsolepGetLargestWindowSize
Definition: conmsg.h:41
CONSOLE_GETLARGESTWINDOWSIZE GetLargestWindowSizeRequest
Definition: conmsg.h:975

Referenced by test_GetLargestConsoleWindowSize().

◆ GetNumberOfConsoleFonts()

DWORD WINAPI DECLSPEC_HOTPATCH GetNumberOfConsoleFonts ( VOID  )

Definition at line 729 of file console.c.

730{
731 CONSOLE_API_MESSAGE ApiMessage;
732 PCONSOLE_GETNUMFONTS GetNumFontsRequest = &ApiMessage.Data.GetNumFontsRequest;
733
734 GetNumFontsRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
735
737 NULL,
739 sizeof(*GetNumFontsRequest));
740 if (!NT_SUCCESS(ApiMessage.Status))
741 {
742 BaseSetLastNTError(ApiMessage.Status);
743 return 0;
744 }
745
746 return GetNumFontsRequest->NumFonts;
747}
@ ConsolepGetNumberOfFonts
Definition: conmsg.h:30
CONSOLE_GETNUMFONTS GetNumFontsRequest
Definition: conmsg.h:965
HANDLE ConsoleHandle
Definition: conmsg.h:405

◆ GetNumberOfConsoleInputEvents()

BOOL WINAPI GetNumberOfConsoleInputEvents ( HANDLE  hConsoleInput,
LPDWORD  lpNumberOfEvents 
)

Definition at line 1637 of file console.c.

1639{
1640 CONSOLE_API_MESSAGE ApiMessage;
1641 PCONSOLE_GETNUMINPUTEVENTS GetNumInputEventsRequest = &ApiMessage.Data.GetNumInputEventsRequest;
1642
1643 GetNumInputEventsRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1644 GetNumInputEventsRequest->InputHandle = hConsoleInput;
1645 GetNumInputEventsRequest->NumberOfEvents = 0;
1646
1648 NULL,
1650 sizeof(*GetNumInputEventsRequest));
1651 if (!NT_SUCCESS(ApiMessage.Status))
1652 {
1653 BaseSetLastNTError(ApiMessage.Status);
1654 return FALSE;
1655 }
1656
1657 if (lpNumberOfEvents == NULL)
1658 {
1660 return FALSE;
1661 }
1662
1663 *lpNumberOfEvents = GetNumInputEventsRequest->NumberOfEvents;
1664
1665 return TRUE;
1666}
@ ConsolepGetNumberOfInputEvents
Definition: conmsg.h:31
CONSOLE_GETNUMINPUTEVENTS GetNumInputEventsRequest
Definition: conmsg.h:987

Referenced by _kbhit(), _tmain(), InputWait(), ProcessKeys(), test_GetNumberOfConsoleInputEvents(), test_WriteConsoleInputA(), and test_WriteConsoleInputW().

◆ GetNumberOfConsoleMouseButtons()

BOOL WINAPI GetNumberOfConsoleMouseButtons ( LPDWORD  lpNumberOfMouseButtons)

Definition at line 1773 of file console.c.

1774{
1775 CONSOLE_API_MESSAGE ApiMessage;
1776 PCONSOLE_GETMOUSEINFO GetMouseInfoRequest = &ApiMessage.Data.GetMouseInfoRequest;
1777
1778 GetMouseInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1779
1781 NULL,
1783 sizeof(*GetMouseInfoRequest));
1784 if (!NT_SUCCESS(ApiMessage.Status))
1785 {
1786 BaseSetLastNTError(ApiMessage.Status);
1787 return FALSE;
1788 }
1789
1790 *lpNumberOfMouseButtons = GetMouseInfoRequest->NumButtons;
1791 return TRUE;
1792}
@ ConsolepGetMouseInfo
Definition: conmsg.h:34
CONSOLE_GETMOUSEINFO GetMouseInfoRequest
Definition: conmsg.h:946
HANDLE ConsoleHandle
Definition: conmsg.h:355

◆ GetStdHandle()

HANDLE WINAPI DECLSPEC_HOTPATCH GetStdHandle ( DWORD  nStdHandle)

Definition at line 1172 of file console.c.

1183{
1184 PRTL_USER_PROCESS_PARAMETERS Ppb = NtCurrentPeb()->ProcessParameters;
1186
1187 switch (nStdHandle)
1188 {
1189 case STD_INPUT_HANDLE:
1190 Handle = Ppb->StandardInput;
1191 break;
1192
1193 case STD_OUTPUT_HANDLE:
1194 Handle = Ppb->StandardOutput;
1195 break;
1196
1197 case STD_ERROR_HANDLE:
1198 Handle = Ppb->StandardError;
1199 break;
1200 }
1201
1202 /* If the returned handle is invalid, set last error */
1204
1205 return Handle;
1206}
ULONG Handle
Definition: gdb_input.c:15
#define STD_OUTPUT_HANDLE
Definition: winbase.h:301
#define STD_INPUT_HANDLE
Definition: winbase.h:300
#define STD_ERROR_HANDLE
Definition: winbase.h:302

◆ InitExeName()

VOID InitExeName ( VOID  )

Definition at line 216 of file console.c.

217{
221 PLDR_DATA_TABLE_ENTRY ImageEntry;
222
223 if (ExeNameInitialized) return;
224
225 /* Initialize the EXE name lock */
227 if (!NT_SUCCESS(Status)) return;
229
232 InLoadOrderLinks);
233
234 /* Retrieve the EXE name, NULL-terminate it... */
235 ExeNameLength = min(sizeof(ExeNameBuffer)/sizeof(ExeNameBuffer[0]),
236 ImageEntry->BaseDllName.Length / sizeof(WCHAR));
238 ImageEntry->BaseDllName.Buffer,
239 ImageEntry->BaseDllName.Length);
241
242 /* ... and retrieve the current directory path and NULL-terminate it. */
243 StartDirLength = min(sizeof(StartDirBuffer)/sizeof(StartDirBuffer[0]),
244 CurrentDirectory->DosPath.Length / sizeof(WCHAR));
246 CurrentDirectory->DosPath.Buffer,
247 CurrentDirectory->DosPath.Length);
249}
WCHAR CurrentDirectory[1024]
Definition: chkdsk.c:74
static WCHAR StartDirBuffer[MAX_PATH+1]
Definition: console.c:45
static USHORT StartDirLength
Definition: console.c:46
PPEB Peb
Definition: dllmain.c:27
#define min(a, b)
Definition: monoChain.cc:55
NTSYSAPI NTSTATUS NTAPI RtlInitializeCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
Definition: btrfs_drv.h:1876
UNICODE_STRING BaseDllName
Definition: ldrtypes.h:149
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
LIST_ENTRY InLoadOrderModuleList
Definition: ldrtypes.h:124
PPEB_LDR_DATA Ldr
Definition: btrfs_drv.h:1912
PRTL_USER_PROCESS_PARAMETERS ProcessParameters
Definition: btrfs_drv.h:1913
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by AllocConsole(), and ConDllInitialize().

◆ InitializeCtrlHandling()

VOID InitializeCtrlHandling ( VOID  )

Definition at line 204 of file console.c.

205{
206 /* Initialize Console Ctrl Handler */
210}
static PHANDLER_ROUTINE InitialHandler[1]
Definition: console.c:29

Referenced by AllocConsole(), AttachConsole(), and ConDllInitialize().

◆ IntAllocConsole()

static BOOL IntAllocConsole ( LPWSTR  Title,
DWORD  TitleLength,
LPWSTR  Desktop,
DWORD  DesktopLength,
LPWSTR  CurDir,
DWORD  CurDirLength,
LPWSTR  AppName,
DWORD  AppNameLength,
LPTHREAD_START_ROUTINE  CtrlRoutine,
LPTHREAD_START_ROUTINE  PropRoutine,
PCONSOLE_START_INFO  ConsoleStartInfo 
)
static

Definition at line 1257 of file console.c.

1268{
1269 BOOL Success = TRUE;
1271
1272 CONSOLE_API_MESSAGE ApiMessage;
1273 PCONSOLE_ALLOCCONSOLE AllocConsoleRequest = &ApiMessage.Data.AllocConsoleRequest;
1274 PCSR_CAPTURE_BUFFER CaptureBuffer;
1275
1276 AllocConsoleRequest->CtrlRoutine = CtrlRoutine;
1277 AllocConsoleRequest->PropRoutine = PropRoutine;
1278
1279 CaptureBuffer = CsrAllocateCaptureBuffer(5, TitleLength +
1280 DesktopLength +
1281 CurDirLength +
1282 AppNameLength +
1283 sizeof(CONSOLE_START_INFO));
1284 if (CaptureBuffer == NULL)
1285 {
1287 Success = FALSE;
1288 goto Quit;
1289 }
1290
1291 CsrCaptureMessageBuffer(CaptureBuffer,
1292 ConsoleStartInfo,
1293 sizeof(CONSOLE_START_INFO),
1294 (PVOID*)&AllocConsoleRequest->ConsoleStartInfo);
1295
1296 AllocConsoleRequest->TitleLength = TitleLength;
1297 CsrCaptureMessageBuffer(CaptureBuffer,
1298 Title,
1299 TitleLength,
1300 (PVOID*)&AllocConsoleRequest->ConsoleTitle);
1301
1302 AllocConsoleRequest->DesktopLength = DesktopLength;
1303 CsrCaptureMessageBuffer(CaptureBuffer,
1304 Desktop,
1305 DesktopLength,
1306 (PVOID*)&AllocConsoleRequest->Desktop);
1307
1308 AllocConsoleRequest->CurDirLength = CurDirLength;
1309 CsrCaptureMessageBuffer(CaptureBuffer,
1310 CurDir,
1311 CurDirLength,
1312 (PVOID*)&AllocConsoleRequest->CurDir);
1313
1314 AllocConsoleRequest->AppNameLength = AppNameLength;
1315 CsrCaptureMessageBuffer(CaptureBuffer,
1316 AppName,
1317 AppNameLength,
1318 (PVOID*)&AllocConsoleRequest->AppName);
1319
1321 CaptureBuffer,
1323 sizeof(*AllocConsoleRequest));
1324 if (!NT_SUCCESS(ApiMessage.Status))
1325 {
1326 BaseSetLastNTError(ApiMessage.Status);
1327 Success = FALSE;
1328 goto Quit;
1329 }
1330
1331 // Is AllocConsoleRequest->ConsoleStartInfo->InitEvents aligned on handle boundary ????
1333 AllocConsoleRequest->ConsoleStartInfo->InitEvents,
1334 WaitAny, FALSE, NULL);
1335 if (!NT_SUCCESS(Status))
1336 {
1338 Success = FALSE;
1339 goto Quit;
1340 }
1341
1342 NtClose(AllocConsoleRequest->ConsoleStartInfo->InitEvents[INIT_SUCCESS]);
1343 NtClose(AllocConsoleRequest->ConsoleStartInfo->InitEvents[INIT_FAILURE]);
1344 if (Status != INIT_SUCCESS)
1345 {
1346 NtCurrentPeb()->ProcessParameters->ConsoleHandle = NULL;
1347 Success = FALSE;
1348 }
1349 else
1350 {
1351 RtlCopyMemory(ConsoleStartInfo,
1352 AllocConsoleRequest->ConsoleStartInfo,
1353 sizeof(CONSOLE_START_INFO));
1354 Success = TRUE;
1355 }
1356
1357Quit:
1358 if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
1359 return Success;
1360}
@ MAX_INIT_EVENTS
Definition: conmsg.h:165
@ INIT_SUCCESS
Definition: conmsg.h:163
@ INIT_FAILURE
Definition: conmsg.h:164
@ ConsolepAlloc
Definition: conmsg.h:57
static const WCHAR Title[]
Definition: oid.c:1259
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
@ WaitAny
NTSTATUS NTAPI NtWaitForMultipleObjects(IN ULONG ObjectCount, IN PHANDLE HandleArray, IN WAIT_TYPE WaitType, IN BOOLEAN Alertable, IN PLARGE_INTEGER TimeOut OPTIONAL)
Definition: obwait.c:46
LPTHREAD_START_ROUTINE PropRoutine
Definition: conmsg.h:286
PCONSOLE_START_INFO ConsoleStartInfo
Definition: conmsg.h:274
LPTHREAD_START_ROUTINE CtrlRoutine
Definition: conmsg.h:285
CONSOLE_ALLOCCONSOLE AllocConsoleRequest
Definition: conmsg.h:924
HANDLE InitEvents[MAX_INIT_EVENTS]
Definition: conmsg.h:175

Referenced by AllocConsole().

◆ IntAttachConsole()

static BOOL IntAttachConsole ( DWORD  ProcessId,
LPTHREAD_START_ROUTINE  CtrlRoutine,
LPTHREAD_START_ROUTINE  PropRoutine,
PCONSOLE_START_INFO  ConsoleStartInfo 
)
static

Definition at line 2605 of file console.c.

2609{
2610 BOOL Success = TRUE;
2612
2613 CONSOLE_API_MESSAGE ApiMessage;
2614 PCONSOLE_ATTACHCONSOLE AttachConsoleRequest = &ApiMessage.Data.AttachConsoleRequest;
2615 PCSR_CAPTURE_BUFFER CaptureBuffer;
2616
2617 AttachConsoleRequest->ProcessId = ProcessId;
2618 AttachConsoleRequest->CtrlRoutine = CtrlRoutine;
2619 AttachConsoleRequest->PropRoutine = PropRoutine;
2620
2621 CaptureBuffer = CsrAllocateCaptureBuffer(1, sizeof(CONSOLE_START_INFO));
2622 if (CaptureBuffer == NULL)
2623 {
2625 Success = FALSE;
2626 goto Quit;
2627 }
2628
2629 CsrCaptureMessageBuffer(CaptureBuffer,
2630 ConsoleStartInfo,
2631 sizeof(CONSOLE_START_INFO),
2632 (PVOID*)&AttachConsoleRequest->ConsoleStartInfo);
2633
2635 CaptureBuffer,
2637 sizeof(*AttachConsoleRequest));
2638 if (!NT_SUCCESS(ApiMessage.Status))
2639 {
2640 BaseSetLastNTError(ApiMessage.Status);
2641 Success = FALSE;
2642 goto Quit;
2643 }
2644
2645 // Is AttachConsoleRequest->ConsoleStartInfo->InitEvents aligned on handle boundary ????
2647 AttachConsoleRequest->ConsoleStartInfo->InitEvents,
2648 WaitAny, FALSE, NULL);
2649 if (!NT_SUCCESS(Status))
2650 {
2652 Success = FALSE;
2653 goto Quit;
2654 }
2655
2656 NtClose(AttachConsoleRequest->ConsoleStartInfo->InitEvents[INIT_SUCCESS]);
2657 NtClose(AttachConsoleRequest->ConsoleStartInfo->InitEvents[INIT_FAILURE]);
2658 if (Status != INIT_SUCCESS)
2659 {
2660 NtCurrentPeb()->ProcessParameters->ConsoleHandle = NULL;
2661 Success = FALSE;
2662 }
2663 else
2664 {
2665 RtlCopyMemory(ConsoleStartInfo,
2666 AttachConsoleRequest->ConsoleStartInfo,
2667 sizeof(CONSOLE_START_INFO));
2668 Success = TRUE;
2669 }
2670
2671Quit:
2672 if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
2673 return Success;
2674}
@ ConsolepAttach
Definition: conmsg.h:104
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2712
CONSOLE_ATTACHCONSOLE AttachConsoleRequest
Definition: conmsg.h:925
LPTHREAD_START_ROUTINE CtrlRoutine
Definition: conmsg.h:299
LPTHREAD_START_ROUTINE PropRoutine
Definition: conmsg.h:300
PCONSOLE_START_INFO ConsoleStartInfo
Definition: conmsg.h:297

Referenced by AttachConsole().

◆ IntCheckForConsoleFileName()

LPCWSTR IntCheckForConsoleFileName ( IN LPCWSTR  pszName,
IN DWORD  dwDesiredAccess 
)

Definition at line 345 of file console.c.

347{
348 LPCWSTR ConsoleName = pszName;
349 ULONG DeviceNameInfo;
350
351 /*
352 * Check whether we deal with a DOS device, and if so,
353 * strip the path till the file name.
354 * Therefore, things like \\.\CON or C:\some_path\CONIN$
355 * are transformed into CON or CONIN$, for example.
356 */
357 DeviceNameInfo = RtlIsDosDeviceName_U(pszName);
358 if (DeviceNameInfo != 0)
359 {
360 ConsoleName = (LPCWSTR)((ULONG_PTR)ConsoleName + ((DeviceNameInfo >> 16) & 0xFFFF));
361 }
362
363 /* Return a standard console "file" name according to what we passed in parameters */
364 if (_wcsicmp(ConsoleName, BaseConInputFileName) == 0)
365 {
367 }
368 else if (_wcsicmp(ConsoleName, BaseConOutputFileName) == 0)
369 {
371 }
372 else if (_wcsicmp(ConsoleName, BaseConFileName) == 0)
373 {
374 if ((dwDesiredAccess & (GENERIC_READ | GENERIC_WRITE)) == GENERIC_READ)
375 {
377 }
378 else if ((dwDesiredAccess & (GENERIC_READ | GENERIC_WRITE)) == GENERIC_WRITE)
379 {
381 }
382 }
383
384 /* If we are there, that means that either the file name or the desired access are wrong */
385 return NULL;
386}
static LPCWSTR BaseConInputFileName
Definition: console.c:25
static LPCWSTR BaseConFileName
Definition: console.c:24
static LPCWSTR BaseConOutputFileName
Definition: console.c:26
NTSYSAPI ULONG NTAPI RtlIsDosDeviceName_U(_In_ PCWSTR Name)
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
uint32_t ULONG_PTR
Definition: typedefs.h:65
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by CreateFileW().

◆ IntGetConsoleKeyboardLayoutName()

static BOOL IntGetConsoleKeyboardLayoutName ( OUT PVOID  pszLayoutName,
IN BOOL  bAnsi 
)
static

Definition at line 3216 of file console.c.

3218{
3219 CONSOLE_API_MESSAGE ApiMessage;
3220 PCONSOLE_GETKBDLAYOUTNAME GetKbdLayoutNameRequest = &ApiMessage.Data.GetKbdLayoutNameRequest;
3221
3222 /* Set up the data to send to the Console Server */
3223 GetKbdLayoutNameRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
3224 GetKbdLayoutNameRequest->Ansi = bAnsi;
3225
3226 /* Call the server */
3228 NULL,
3230 sizeof(*GetKbdLayoutNameRequest));
3231
3232 /* Check for success */
3233 if (!NT_SUCCESS(ApiMessage.Status))
3234 {
3235 BaseSetLastNTError(ApiMessage.Status);
3236 return FALSE;
3237 }
3238
3239 /* Retrieve the results */
3240 _SEH2_TRY
3241 {
3242 /* Copy only KL_NAMELENGTH == 9 characters, ANSI or UNICODE */
3243 if (bAnsi)
3244 strncpy(pszLayoutName, (PCHAR)GetKbdLayoutNameRequest->LayoutBuffer, KL_NAMELENGTH);
3245 else
3246 wcsncpy(pszLayoutName, (PWCHAR)GetKbdLayoutNameRequest->LayoutBuffer, KL_NAMELENGTH);
3247 }
3249 {
3251 _SEH2_YIELD(return FALSE);
3252 }
3253 _SEH2_END;
3254
3255 return TRUE;
3256}
@ ConsolepGetKeyboardLayoutName
Definition: conmsg.h:90
wcsncpy
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:184
strncpy
Definition: string.h:335
CONSOLE_GETKBDLAYOUTNAME GetKbdLayoutNameRequest
Definition: conmsg.h:1017
CHAR LayoutBuffer[KL_NAMELENGTH *sizeof(WCHAR)]
Definition: conmsg.h:871
char * PCHAR
Definition: typedefs.h:51
#define KL_NAMELENGTH
Definition: winuser.h:122

Referenced by GetConsoleKeyboardLayoutNameA(), and GetConsoleKeyboardLayoutNameW().

◆ IntGetConsoleTitle()

static DWORD IntGetConsoleTitle ( LPVOID  lpConsoleTitle,
DWORD  dwNumChars,
BOOLEAN  bUnicode 
)
static

Definition at line 2165 of file console.c.

2166{
2167 CONSOLE_API_MESSAGE ApiMessage;
2168 PCONSOLE_GETSETCONSOLETITLE TitleRequest = &ApiMessage.Data.TitleRequest;
2169 PCSR_CAPTURE_BUFFER CaptureBuffer;
2170
2171 if (dwNumChars == 0) return 0;
2172
2173 TitleRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2174 TitleRequest->Length = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
2175 TitleRequest->Unicode = bUnicode;
2176
2177 CaptureBuffer = CsrAllocateCaptureBuffer(1, TitleRequest->Length);
2178 if (CaptureBuffer == NULL)
2179 {
2180 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
2182 return 0;
2183 }
2184
2185 CsrAllocateMessagePointer(CaptureBuffer,
2186 TitleRequest->Length,
2187 (PVOID*)&TitleRequest->Title);
2188
2190 CaptureBuffer,
2192 sizeof(*TitleRequest));
2193 if (!NT_SUCCESS(ApiMessage.Status))
2194 {
2195 CsrFreeCaptureBuffer(CaptureBuffer);
2196 BaseSetLastNTError(ApiMessage.Status);
2197 return 0;
2198 }
2199
2200 dwNumChars = TitleRequest->Length / (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
2201
2202 if (dwNumChars > 0)
2203 {
2204 RtlCopyMemory(lpConsoleTitle, TitleRequest->Title, TitleRequest->Length);
2205
2206 if (bUnicode)
2207 ((LPWSTR)lpConsoleTitle)[dwNumChars] = UNICODE_NULL;
2208 else
2209 ((LPSTR)lpConsoleTitle)[dwNumChars] = ANSI_NULL;
2210 }
2211
2212 CsrFreeCaptureBuffer(CaptureBuffer);
2213
2214 return dwNumChars;
2215}
@ ConsolepGetTitle
Definition: conmsg.h:59
#define ANSI_NULL
CONSOLE_GETSETCONSOLETITLE TitleRequest
Definition: conmsg.h:974
char * LPSTR
Definition: xmlstorage.h:182
WCHAR * LPWSTR
Definition: xmlstorage.h:184
char CHAR
Definition: xmlstorage.h:175

Referenced by GetConsoleTitleA(), and GetConsoleTitleW().

◆ IntRegisterConsoleIME()

static BOOL IntRegisterConsoleIME ( _In_ HWND  hWnd,
_In_ DWORD  dwThreadId,
_In_opt_ SIZE_T  cbDesktop,
_In_opt_ PWSTR  pDesktop,
_Out_opt_ PDWORD  pdwAttachToThreadId 
)
static

Definition at line 3040 of file console.c.

3046{
3047 CONSOLE_API_MESSAGE ApiMessage;
3049 PCSR_CAPTURE_BUFFER CaptureBuffer;
3050
3051 if (!cbDesktop || !pDesktop)
3052 {
3053 pDesktop = NtCurrentPeb()->ProcessParameters->DesktopInfo.Buffer;
3054 cbDesktop = NtCurrentPeb()->ProcessParameters->DesktopInfo.Length;
3055 }
3056
3057 cbDesktop = min(cbDesktop, (MAX_PATH + 1) * sizeof(WCHAR));
3058
3059 RegisterConsoleIME->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
3060 RegisterConsoleIME->hWnd = hWnd;
3061 RegisterConsoleIME->dwThreadId = dwThreadId;
3062 RegisterConsoleIME->cbDesktop = cbDesktop;
3063
3064 CaptureBuffer = CsrAllocateCaptureBuffer(1, cbDesktop);
3065 if (!CaptureBuffer)
3066 {
3068 return FALSE;
3069 }
3070
3071 CsrCaptureMessageBuffer(CaptureBuffer,
3072 pDesktop,
3073 cbDesktop,
3074 (PVOID*)&RegisterConsoleIME->pDesktop);
3075
3077 CaptureBuffer,
3079 sizeof(*RegisterConsoleIME));
3080
3081 CsrFreeCaptureBuffer(CaptureBuffer);
3082
3083 if (!NT_SUCCESS(ApiMessage.Status))
3084 {
3085 BaseSetLastNTError(ApiMessage.Status);
3086 return FALSE;
3087 }
3088
3089 if (pdwAttachToThreadId)
3090 {
3091 _SEH2_TRY
3092 {
3093 *pdwAttachToThreadId = RegisterConsoleIME->dwAttachToThreadId;
3094 }
3096 {
3098 _SEH2_YIELD(return FALSE);
3099 }
3100 _SEH2_END;
3101 }
3102
3103 return TRUE;
3104}
HWND hWnd
Definition: settings.c:17
@ ConsolepRegisterConsoleIME
Definition: conmsg.h:100
BOOL WINAPI DECLSPEC_HOTPATCH RegisterConsoleIME(_In_ HWND hWnd, _Out_opt_ LPDWORD pdwAttachToThreadId)
Definition: console.c:3133
DWORD dwThreadId
Definition: fdebug.c:31
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
CONSOLE_REGISTERCONSOLEIME RegisterConsoleIME
Definition: conmsg.h:1023

Referenced by RegisterConsoleIME().

◆ IntScrollConsoleScreenBuffer()

static BOOL IntScrollConsoleScreenBuffer ( HANDLE  hConsoleOutput,
CONST SMALL_RECT lpScrollRectangle,
CONST SMALL_RECT lpClipRectangle,
COORD  dwDestinationOrigin,
CONST CHAR_INFO lpFill,
BOOL  bUnicode 
)
static

Definition at line 1883 of file console.c.

1889{
1890 CONSOLE_API_MESSAGE ApiMessage;
1891 PCONSOLE_SCROLLSCREENBUFFER ScrollScreenBufferRequest = &ApiMessage.Data.ScrollScreenBufferRequest;
1892
1893 ScrollScreenBufferRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1894 ScrollScreenBufferRequest->OutputHandle = hConsoleOutput;
1895 ScrollScreenBufferRequest->ScrollRectangle = *lpScrollRectangle;
1896
1897 if (lpClipRectangle != NULL)
1898 {
1899 ScrollScreenBufferRequest->UseClipRectangle = TRUE;
1900 ScrollScreenBufferRequest->ClipRectangle = *lpClipRectangle;
1901 }
1902 else
1903 {
1904 ScrollScreenBufferRequest->UseClipRectangle = FALSE;
1905 }
1906
1907 ScrollScreenBufferRequest->DestinationOrigin = dwDestinationOrigin;
1908 ScrollScreenBufferRequest->Fill = *lpFill;
1909 ScrollScreenBufferRequest->Unicode = bUnicode;
1910
1912 NULL,
1914 sizeof(*ScrollScreenBufferRequest));
1915 if (!NT_SUCCESS(ApiMessage.Status))
1916 {
1917 BaseSetLastNTError(ApiMessage.Status);
1918 return FALSE;
1919 }
1920
1921 return TRUE;
1922}
@ ConsolepScrollScreenBuffer
Definition: conmsg.h:46
CONSOLE_SCROLLSCREENBUFFER ScrollScreenBufferRequest
Definition: conmsg.h:953
SMALL_RECT ClipRectangle
Definition: conmsg.h:502
SMALL_RECT ScrollRectangle
Definition: conmsg.h:501

Referenced by ScrollConsoleScreenBufferA(), and ScrollConsoleScreenBufferW().

◆ IntSetConsoleTitle()

static BOOL IntSetConsoleTitle ( CONST VOID lpConsoleTitle,
BOOLEAN  bUnicode 
)
static

Definition at line 2245 of file console.c.

2246{
2247 CONSOLE_API_MESSAGE ApiMessage;
2248 PCONSOLE_GETSETCONSOLETITLE TitleRequest = &ApiMessage.Data.TitleRequest;
2249 PCSR_CAPTURE_BUFFER CaptureBuffer;
2250
2251 ULONG NumChars = (ULONG)(lpConsoleTitle ? (bUnicode ? wcslen(lpConsoleTitle) : strlen(lpConsoleTitle)) : 0);
2252
2253 TitleRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2254 TitleRequest->Length = NumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
2255 TitleRequest->Unicode = bUnicode;
2256
2257 CaptureBuffer = CsrAllocateCaptureBuffer(1, TitleRequest->Length);
2258 if (CaptureBuffer == NULL)
2259 {
2260 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
2262 return FALSE;
2263 }
2264
2265 CsrCaptureMessageBuffer(CaptureBuffer,
2266 (PVOID)lpConsoleTitle,
2267 TitleRequest->Length,
2268 (PVOID*)&TitleRequest->Title);
2269
2271 CaptureBuffer,
2273 sizeof(*TitleRequest));
2274
2275 CsrFreeCaptureBuffer(CaptureBuffer);
2276
2277 if (!NT_SUCCESS(ApiMessage.Status))
2278 {
2279 BaseSetLastNTError(ApiMessage.Status);
2280 return FALSE;
2281 }
2282
2283 return TRUE;
2284}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
@ ConsolepSetTitle
Definition: conmsg.h:60
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by SetConsoleTitleA(), and SetConsoleTitleW().

◆ IntUnregisterConsoleIME()

static BOOL IntUnregisterConsoleIME ( _In_ DWORD  dwThreadId)
static

Definition at line 3107 of file console.c.

3109{
3110 CONSOLE_API_MESSAGE ApiMessage;
3112
3113 UnregisterConsoleIME->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
3114 UnregisterConsoleIME->dwThreadId = dwThreadId;
3115
3117 NULL,
3119 sizeof(*UnregisterConsoleIME));
3120 if (!NT_SUCCESS(ApiMessage.Status))
3121 {
3122 BaseSetLastNTError(ApiMessage.Status);
3123 return FALSE;
3124 }
3125
3126 return TRUE;
3127}
@ ConsolepUnregisterConsoleIME
Definition: conmsg.h:101
BOOL WINAPI DECLSPEC_HOTPATCH UnregisterConsoleIME(VOID)
Definition: console.c:3166
CONSOLE_UNREGISTERCONSOLEIME UnregisterConsoleIME
Definition: conmsg.h:1024

Referenced by UnregisterConsoleIME().

◆ InvalidateConsoleDIBits()

BOOL WINAPI InvalidateConsoleDIBits ( IN HANDLE  hConsoleOutput,
IN PSMALL_RECT  lpRect 
)

Definition at line 756 of file console.c.

758{
759 CONSOLE_API_MESSAGE ApiMessage;
760 PCONSOLE_INVALIDATEDIBITS InvalidateDIBitsRequest = &ApiMessage.Data.InvalidateDIBitsRequest;
761
762 if (lpRect == NULL)
763 {
765 return FALSE;
766 }
767
768 InvalidateDIBitsRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
769 InvalidateDIBitsRequest->OutputHandle = hConsoleOutput;
770 InvalidateDIBitsRequest->Region = *lpRect;
771
773 NULL,
775 sizeof(*InvalidateDIBitsRequest));
776 if (!NT_SUCCESS(ApiMessage.Status))
777 {
778 BaseSetLastNTError(ApiMessage.Status);
779 return FALSE;
780 }
781
782 return TRUE;
783}
@ ConsolepInvalidateBitMapRect
Definition: conmsg.h:62
CONSOLE_INVALIDATEDIBITS InvalidateDIBitsRequest
Definition: conmsg.h:972

Referenced by __InvalidateConsoleDIBits().

◆ IsDebuggerPresent()

BOOL WINAPI IsDebuggerPresent ( VOID  )

Definition at line 580 of file debugger.c.

581{
582 return (BOOL)NtCurrentPeb()->BeingDebugged;
583}

◆ OpenConsoleW()

HANDLE WINAPI OpenConsoleW ( LPCWSTR  wsName,
DWORD  dwDesiredAccess,
BOOL  bInheritHandle,
DWORD  dwShareMode 
)

Definition at line 791 of file console.c.

795{
796 CONSOLE_API_MESSAGE ApiMessage;
797 PCONSOLE_OPENCONSOLE OpenConsoleRequest = &ApiMessage.Data.OpenConsoleRequest;
798 CONSOLE_HANDLE_TYPE HandleType;
799
800 if (wsName && (_wcsicmp(wsName, BaseConInputFileName) == 0))
801 {
802 HandleType = HANDLE_INPUT;
803 }
804 else if (wsName && (_wcsicmp(wsName, BaseConOutputFileName) == 0))
805 {
806 HandleType = HANDLE_OUTPUT;
807 }
808 else
809 {
812 }
813
814 if ( (dwDesiredAccess & ~(GENERIC_READ | GENERIC_WRITE)) ||
815 (dwShareMode & ~(FILE_SHARE_READ | FILE_SHARE_WRITE)) )
816 {
819 }
820
821 OpenConsoleRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
822 OpenConsoleRequest->HandleType = HandleType;
823 OpenConsoleRequest->DesiredAccess = dwDesiredAccess;
824 OpenConsoleRequest->InheritHandle = bInheritHandle;
825 OpenConsoleRequest->ShareMode = dwShareMode;
826
828 NULL,
830 sizeof(*OpenConsoleRequest));
831 if (!NT_SUCCESS(ApiMessage.Status))
832 {
833 BaseSetLastNTError(ApiMessage.Status);
835 }
836
837 return OpenConsoleRequest->Handle;
838}
@ HANDLE_INPUT
Definition: conmsg.h:667
@ HANDLE_OUTPUT
Definition: conmsg.h:668
@ ConsolepOpenConsole
Definition: conmsg.h:21
enum _CONSOLE_HANDLE_TYPE CONSOLE_HANDLE_TYPE
CONSOLE_OPENCONSOLE OpenConsoleRequest
Definition: conmsg.h:934
CONSOLE_HANDLE_TYPE HandleType
Definition: conmsg.h:674
HANDLE ConsoleHandle
Definition: conmsg.h:673

Referenced by CreateFileW(), and init_function_pointers().

◆ RegisterConsoleIME()

BOOL WINAPI DECLSPEC_HOTPATCH RegisterConsoleIME ( _In_ HWND  hWnd,
_Out_opt_ LPDWORD  pdwAttachToThreadId 
)

Definition at line 3133 of file console.c.

3136{
3139 0,
3140 NULL,
3141 pdwAttachToThreadId);
3142}
static BOOL IntRegisterConsoleIME(_In_ HWND hWnd, _In_ DWORD dwThreadId, _In_opt_ SIZE_T cbDesktop, _In_opt_ PWSTR pDesktop, _Out_opt_ PDWORD pdwAttachToThreadId)
Definition: console.c:3040
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459

Referenced by IntRegisterConsoleIME().

◆ RegisterConsoleOS2()

BOOL WINAPI DECLSPEC_HOTPATCH RegisterConsoleOS2 ( BOOL  bUnknown)

Definition at line 3147 of file console.c.

3148{
3149 STUB;
3150 return FALSE;
3151}

◆ RemoveConsoleCtrlHandler()

static BOOL RemoveConsoleCtrlHandler ( PHANDLER_ROUTINE  HandlerRoutine)
static

Definition at line 2074 of file console.c.

2075{
2076 ULONG i;
2077
2078 if (HandlerRoutine == NULL)
2079 {
2080 NtCurrentPeb()->ProcessParameters->ConsoleFlags = FALSE;
2081 return TRUE;
2082 }
2083
2084 for (i = 0; i < NrCtrlHandlers; i++)
2085 {
2087 {
2088 if (i < (NrCtrlHandlers - 1))
2089 {
2091 &CtrlHandlers[i+1],
2092 (NrCtrlHandlers - i + 1) * sizeof(PHANDLER_ROUTINE));
2093 }
2094
2096 return TRUE;
2097 }
2098 }
2099
2101 return FALSE;
2102}

Referenced by SetConsoleCtrlHandler().

◆ ScrollConsoleScreenBufferA()

BOOL WINAPI DECLSPEC_HOTPATCH ScrollConsoleScreenBufferA ( HANDLE  hConsoleOutput,
CONST SMALL_RECT lpScrollRectangle,
CONST SMALL_RECT lpClipRectangle,
COORD  dwDestinationOrigin,
CONST CHAR_INFO lpFill 
)

Definition at line 1931 of file console.c.

1936{
1937 return IntScrollConsoleScreenBuffer(hConsoleOutput,
1938 lpScrollRectangle,
1939 lpClipRectangle,
1940 dwDestinationOrigin,
1941 lpFill,
1942 FALSE);
1943}
static BOOL IntScrollConsoleScreenBuffer(HANDLE hConsoleOutput, CONST SMALL_RECT *lpScrollRectangle, CONST SMALL_RECT *lpClipRectangle, COORD dwDestinationOrigin, CONST CHAR_INFO *lpFill, BOOL bUnicode)
Definition: console.c:1883

Referenced by testScroll().

◆ ScrollConsoleScreenBufferW()

BOOL WINAPI DECLSPEC_HOTPATCH ScrollConsoleScreenBufferW ( HANDLE  hConsoleOutput,
CONST SMALL_RECT lpScrollRectangle,
CONST SMALL_RECT lpClipRectangle,
COORD  dwDestinationOrigin,
CONST CHAR_INFO lpFill 
)

Definition at line 1952 of file console.c.

1957{
1958 return IntScrollConsoleScreenBuffer(hConsoleOutput,
1959 lpScrollRectangle,
1960 lpClipRectangle,
1961 dwDestinationOrigin,
1962 lpFill,
1963 TRUE);
1964}

◆ SetConsoleActiveScreenBuffer()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleActiveScreenBuffer ( HANDLE  hConsoleOutput)

Definition at line 1801 of file console.c.

1802{
1803 CONSOLE_API_MESSAGE ApiMessage;
1804 PCONSOLE_SETACTIVESCREENBUFFER SetScreenBufferRequest = &ApiMessage.Data.SetScreenBufferRequest;
1805
1806 SetScreenBufferRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1807 SetScreenBufferRequest->OutputHandle = hConsoleOutput;
1808
1810 NULL,
1812 sizeof(*SetScreenBufferRequest));
1813 if (!NT_SUCCESS(ApiMessage.Status))
1814 {
1815 BaseSetLastNTError(ApiMessage.Status);
1816 return FALSE;
1817 }
1818
1819 return TRUE;
1820}
@ ConsolepSetActiveScreenBuffer
Definition: conmsg.h:39
CONSOLE_SETACTIVESCREENBUFFER SetScreenBufferRequest
Definition: conmsg.h:950

Referenced by GetInputOutputHandles(), RestoreConsole(), SetActiveScreenBuffer(), testScreenBuffer(), and wmain().

◆ SetConsoleCP()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleCP ( UINT  wCodePageID)

Definition at line 2422 of file console.c.

2423{
2424 CONSOLE_API_MESSAGE ApiMessage;
2425 PCONSOLE_SETINPUTOUTPUTCP SetConsoleCPRequest = &ApiMessage.Data.SetConsoleCPRequest;
2426
2427 /* Set the Input Code Page */
2428 SetConsoleCPRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2429 SetConsoleCPRequest->CodePage = wCodePageID;
2430 SetConsoleCPRequest->OutputCP = FALSE;
2431 /* SetConsoleCPRequest->EventHandle; */
2432
2434 NULL,
2436 sizeof(*SetConsoleCPRequest));
2437 if (!NT_SUCCESS(ApiMessage.Status))
2438 {
2439 BaseSetLastNTError(ApiMessage.Status);
2440 return FALSE;
2441 }
2442
2443 return TRUE;
2444}
@ ConsolepSetCP
Definition: conmsg.h:85
CONSOLE_SETINPUTOUTPUTCP SetConsoleCPRequest
Definition: conmsg.h:1015

Referenced by doChild(), SetConsoleCPState(), START_TEST(), test_Console(), and wmain().

◆ SetConsoleCtrlHandler()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleCtrlHandler ( PHANDLER_ROUTINE  HandlerRoutine,
BOOL  Add 
)

Definition at line 2111 of file console.c.

2113{
2114 BOOL Ret;
2115
2117
2118 if (Add)
2120 else
2122
2124 return Ret;
2125}
static BOOL AddConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine)
Definition: console.c:2036
static BOOL RemoveConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine)
Definition: console.c:2074

Referenced by AddBreakHandler(), Telnet::Close(), CmdDebugService(), ConsoleInit(), CtrlCIntercept(), InputWait(), InteractiveConsole(), kickoff_telnetd(), main(), msvcrt_free_signals(), msvcrt_init_signals(), Telnet::Open(), PagePrompt(), RemoveBreakHandler(), Setup(), signal(), testCtrlHandler(), wmain(), and wWinMain().

◆ SetConsoleCursor()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleCursor ( HANDLE  hConsoleOutput,
HCURSOR  hCursor 
)

Definition at line 848 of file console.c.

850{
851 CONSOLE_API_MESSAGE ApiMessage;
852 PCONSOLE_SETCURSOR SetCursorRequest = &ApiMessage.Data.SetCursorRequest;
853
854 SetCursorRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
855 SetCursorRequest->OutputHandle = hConsoleOutput;
856 SetCursorRequest->CursorHandle = hCursor;
857
859 NULL,
861 sizeof(*SetCursorRequest));
862 if (!NT_SUCCESS(ApiMessage.Status))
863 {
864 BaseSetLastNTError(ApiMessage.Status);
865 return FALSE;
866 }
867
868 return TRUE;
869}
@ ConsolepSetCursor
Definition: conmsg.h:64
CONSOLE_SETCURSOR SetCursorRequest
Definition: conmsg.h:943
HANDLE ConsoleHandle
Definition: conmsg.h:337
HCURSOR CursorHandle
Definition: conmsg.h:339
HANDLE OutputHandle
Definition: conmsg.h:338

◆ SetConsoleCursorInfo()

BOOL WINAPI SetConsoleCursorInfo ( HANDLE  hConsoleOutput,
CONST CONSOLE_CURSOR_INFO lpConsoleCursorInfo 
)

Definition at line 1744 of file console.c.

1746{
1747 CONSOLE_API_MESSAGE ApiMessage;
1748 PCONSOLE_GETSETCURSORINFO CursorInfoRequest = &ApiMessage.Data.CursorInfoRequest;
1749
1750 CursorInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1751 CursorInfoRequest->OutputHandle = hConsoleOutput;
1752 CursorInfoRequest->Info = *lpConsoleCursorInfo;
1753
1755 NULL,
1757 sizeof(*CursorInfoRequest));
1758 if (!NT_SUCCESS(ApiMessage.Status))
1759 {
1760 BaseSetLastNTError(ApiMessage.Status);
1761 return FALSE;
1762 }
1763
1764 return TRUE;
1765}
@ ConsolepSetCursorInfo
Definition: conmsg.h:44

◆ SetConsoleCursorMode()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleCursorMode ( HANDLE  hConsole,
BOOL  Unknown1,
BOOL  Unknown2 
)

Definition at line 3002 of file console.c.

3003{
3004 STUB;
3005 return FALSE;
3006}

◆ SetConsoleCursorPosition()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleCursorPosition ( HANDLE  hConsoleOutput,
COORD  dwCursorPosition 
)

Definition at line 1542 of file console.c.

1544{
1545 CONSOLE_API_MESSAGE ApiMessage;
1546 PCONSOLE_SETCURSORPOSITION SetCursorPositionRequest = &ApiMessage.Data.SetCursorPositionRequest;
1547
1548 SetCursorPositionRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1549 SetCursorPositionRequest->OutputHandle = hConsoleOutput;
1550 SetCursorPositionRequest->Position = dwCursorPosition;
1551
1553 NULL,
1555 sizeof(*SetCursorPositionRequest));
1556 if (!NT_SUCCESS(ApiMessage.Status))
1557 {
1558 BaseSetLastNTError(ApiMessage.Status);
1559 return FALSE;
1560 }
1561
1562 return TRUE;
1563}
@ ConsolepSetCursorPosition
Definition: conmsg.h:43
CONSOLE_SETCURSORPOSITION SetCursorPositionRequest
Definition: conmsg.h:945

◆ SetConsoleDisplayMode()

BOOL WINAPI SetConsoleDisplayMode ( HANDLE  hConsoleOutput,
DWORD  dwFlags,
PCOORD  lpNewScreenBufferDimensions 
)

Definition at line 877 of file console.c.

880{
881 CONSOLE_API_MESSAGE ApiMessage;
882 PCONSOLE_SETDISPLAYMODE SetDisplayModeRequest = &ApiMessage.Data.SetDisplayModeRequest;
883
884 SetDisplayModeRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
885 SetDisplayModeRequest->OutputHandle = hConsoleOutput;
886 SetDisplayModeRequest->DisplayMode = dwFlags; // ModeFlags ; dwModeFlags
887 SetDisplayModeRequest->NewSBDim.X = 0;
888 SetDisplayModeRequest->NewSBDim.Y = 0;
889 /* SetDisplayModeRequest->EventHandle; */
890
892 NULL,
894 sizeof(*SetDisplayModeRequest));
895 if (!NT_SUCCESS(ApiMessage.Status))
896 {
897 BaseSetLastNTError(ApiMessage.Status);
898 return FALSE;
899 }
900
901 if (lpNewScreenBufferDimensions)
902 *lpNewScreenBufferDimensions = SetDisplayModeRequest->NewSBDim;
903
904 return TRUE;
905}
@ ConsolepSetDisplayMode
Definition: conmsg.h:68
CONSOLE_SETDISPLAYMODE SetDisplayModeRequest
Definition: conmsg.h:961

◆ SetConsoleFont()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleFont ( IN HANDLE  hConsoleOutput,
IN DWORD  nFont 
)

Definition at line 915 of file console.c.

917{
918 CONSOLE_API_MESSAGE ApiMessage;
919 PCONSOLE_SETFONT SetFontRequest = &ApiMessage.Data.SetFontRequest;
920
921 SetFontRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
922 SetFontRequest->OutputHandle = hConsoleOutput;
923 SetFontRequest->FontIndex = nFont;
924
926 NULL,
928 sizeof(*SetFontRequest));
929 if (!NT_SUCCESS(ApiMessage.Status))
930 {
931 BaseSetLastNTError(ApiMessage.Status);
932 return FALSE;
933 }
934
935 return TRUE;
936}
@ ConsolepSetFont
Definition: conmsg.h:48
CONSOLE_SETFONT SetFontRequest
Definition: conmsg.h:969
HANDLE ConsoleHandle
Definition: conmsg.h:437
HANDLE OutputHandle
Definition: conmsg.h:438
ULONG FontIndex
Definition: conmsg.h:439

◆ SetConsoleHandleInformation()

BOOL WINAPI SetConsoleHandleInformation ( IN HANDLE  hHandle,
IN DWORD  dwMask,
IN DWORD  dwFlags 
)

Definition at line 495 of file console.c.

498{
499 CONSOLE_API_MESSAGE ApiMessage;
500 PCONSOLE_SETHANDLEINFO SetHandleInfoRequest = &ApiMessage.Data.SetHandleInfoRequest;
501
502 SetHandleInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
503 SetHandleInfoRequest->Handle = hHandle;
504 SetHandleInfoRequest->Mask = dwMask;
505 SetHandleInfoRequest->Flags = dwFlags;
506
508 NULL,
510 sizeof(*SetHandleInfoRequest));
511 if (!NT_SUCCESS(ApiMessage.Status))
512 {
513 BaseSetLastNTError(ApiMessage.Status);
514 return FALSE;
515 }
516
517 return TRUE;
518}
@ ConsolepSetHandleInformation
Definition: conmsg.h:54
CONSOLE_SETHANDLEINFO SetHandleInfoRequest
Definition: conmsg.h:939

Referenced by SetHandleInformation().

◆ SetConsoleHardwareState()

BOOL WINAPI SetConsoleHardwareState ( HANDLE  hConsoleOutput,
DWORD  Flags,
DWORD  State 
)

Definition at line 944 of file console.c.

947{
948 CONSOLE_API_MESSAGE ApiMessage;
949 PCONSOLE_GETSETHWSTATE HardwareStateRequest = &ApiMessage.Data.HardwareStateRequest;
950
951 DPRINT1("SetConsoleHardwareState(%lu, %lu) UNIMPLEMENTED!\n", Flags, State);
952
953 HardwareStateRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
954 HardwareStateRequest->OutputHandle = hConsoleOutput;
955 HardwareStateRequest->Flags = Flags;
956 HardwareStateRequest->State = State;
957
959 NULL,
961 sizeof(*HardwareStateRequest));
962 if (!NT_SUCCESS(ApiMessage.Status))
963 {
964 BaseSetLastNTError(ApiMessage.Status);
965 return FALSE;
966 }
967
968 return TRUE;
969}
@ ConsolepSetHardwareState
Definition: conmsg.h:71

Referenced by CON_API().

◆ SetConsoleIcon()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleIcon ( HICON  hIcon)

Definition at line 2758 of file console.c.

2759{
2760 CONSOLE_API_MESSAGE ApiMessage;
2761 PCONSOLE_SETICON SetIconRequest = &ApiMessage.Data.SetIconRequest;
2762
2763 SetIconRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2764 SetIconRequest->IconHandle = hIcon;
2765
2767 NULL,
2769 sizeof(*SetIconRequest));
2770 if (!NT_SUCCESS(ApiMessage.Status))
2771 {
2772 BaseSetLastNTError(ApiMessage.Status);
2773 return FALSE;
2774 }
2775
2776 return TRUE;
2777}
@ ConsolepSetIcon
Definition: conmsg.h:49
HICON hIcon
Definition: msconfig.c:44
CONSOLE_SETICON SetIconRequest
Definition: conmsg.h:980
HANDLE ConsoleHandle
Definition: conmsg.h:722
HICON IconHandle
Definition: conmsg.h:723

◆ SetConsoleInputExeNameA()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleInputExeNameA ( IN LPCSTR  lpExeName)

Definition at line 2831 of file console.c.

2832{
2834#ifdef USE_TEB_STATIC_USTR
2835 PUNICODE_STRING ExeNameU;
2836#else
2837 UNICODE_STRING ExeNameU;
2838#endif
2839 ANSI_STRING ExeNameA;
2840#ifndef USE_TEB_STATIC_USTR
2842#endif
2843
2844#ifdef USE_TEB_STATIC_USTR
2845 /*
2846 * Use the TEB static UNICODE string for storage. It is already
2847 * initialized at process creation time by the Memory Manager.
2848 */
2849 ExeNameU = &NtCurrentTeb()->StaticUnicodeString;
2850#endif
2851
2852 /* Initialize string for conversion */
2853 RtlInitAnsiString(&ExeNameA, lpExeName);
2854
2855#if 1
2856 if ((ExeNameA.Length == 0) || (ExeNameA.Length >= EXENAME_LENGTH))
2857 {
2858 /* Fail if string is empty or too long */
2860 return FALSE;
2861 }
2862#endif
2863#ifndef USE_TEB_STATIC_USTR
2864 ExeNameU.Length = 0;
2865 ExeNameU.MaximumLength = (USHORT)sizeof(Buffer);
2866 ExeNameU.Buffer = Buffer;
2867#endif
2868
2869#ifdef USE_TEB_STATIC_USTR
2870 Status = RtlAnsiStringToUnicodeString(ExeNameU, &ExeNameA, FALSE);
2871#else
2872 Status = RtlAnsiStringToUnicodeString(&ExeNameU, &ExeNameA, FALSE);
2873#endif
2874 if (!NT_SUCCESS(Status))
2875 {
2876 /* Fail if string is empty or too long */
2879 else
2881
2882 return FALSE;
2883 }
2884
2885#ifdef USE_TEB_STATIC_USTR
2886 return SetConsoleInputExeNameW(ExeNameU->Buffer);
2887#else
2888 return SetConsoleInputExeNameW(ExeNameU.Buffer);
2889#endif
2890}
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleInputExeNameW(IN LPCWSTR lpExeName)
Definition: console.c:2791
#define NtCurrentTeb
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define ERROR_FILENAME_EXCED_RANGE
Definition: winerror.h:263

Referenced by init_function_pointers().

◆ SetConsoleInputExeNameW()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleInputExeNameW ( IN LPCWSTR  lpExeName)

Definition at line 2791 of file console.c.

2792{
2793 DWORD ExeLength;
2794
2795 ExeLength = lstrlenW(lpExeName);
2796 if ((ExeLength == 0) || (ExeLength >= EXENAME_LENGTH))
2797 {
2798 /* Fail if string is empty or too long */
2800 return FALSE;
2801 }
2802
2804 _SEH2_TRY
2805 {
2806 /* Set the input EXE name, not NULL terminated */
2807 RtlCopyMemory(ExeNameBuffer, lpExeName, ExeLength * sizeof(WCHAR));
2808 ExeNameLength = (USHORT)ExeLength;
2809 }
2811 {
2813 }
2814 _SEH2_END;
2815
2816 return TRUE;
2817}
#define lstrlenW
Definition: compat.h:750

Referenced by SetConsoleInputExeNameA().

◆ SetConsoleKeyShortcuts()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleKeyShortcuts ( _In_ BOOL  bSet,
_In_ BYTE  bReserveKeys,
_In_reads_(dwNumAppKeys) LPAPPKEY  lpAppKeys,
_In_ DWORD  dwNumAppKeys 
)

Definition at line 978 of file console.c.

983{
984 DPRINT1("SetConsoleKeyShortcuts(%lu, 0x%x, 0x%p, 0x%x) UNIMPLEMENTED!\n",
985 bSet, bReserveKeys, lpAppKeys, dwNumAppKeys);
987 return FALSE;
988}
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102

◆ SetConsoleLocalEUDC()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleLocalEUDC ( _In_ HANDLE  hConsoleHandle,
_In_ WORD  wCodePoint,
_In_ COORD  cFontSize,
_In_ PCHAR  lpSB 
)

Definition at line 3029 of file console.c.

3034{
3035 STUB;
3036 return FALSE;
3037}

◆ SetConsoleMaximumWindowSize()

BOOL WINAPI SetConsoleMaximumWindowSize ( HANDLE  hConsoleOutput,
COORD  dwMaximumSize 
)

Definition at line 998 of file console.c.

1000{
1001 DPRINT1("SetConsoleMaximumWindowSize(0x%p, {%d, %d}) does nothing\n",
1002 hConsoleOutput, dwMaximumSize.X, dwMaximumSize.Y);
1003 return TRUE;
1004}

◆ SetConsoleMenuClose()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleMenuClose ( BOOL  bEnable)

Definition at line 1013 of file console.c.

1014{
1015 CONSOLE_API_MESSAGE ApiMessage;
1016 PCONSOLE_SETMENUCLOSE SetMenuCloseRequest = &ApiMessage.Data.SetMenuCloseRequest;
1017
1018 SetMenuCloseRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1019 SetMenuCloseRequest->Enable = bEnable;
1020
1022 NULL,
1024 sizeof(*SetMenuCloseRequest));
1025 if (!NT_SUCCESS(ApiMessage.Status))
1026 {
1027 BaseSetLastNTError(ApiMessage.Status);
1028 return FALSE;
1029 }
1030
1031 return TRUE;
1032}
@ ConsolepSetMenuClose
Definition: conmsg.h:87
CONSOLE_SETMENUCLOSE SetMenuCloseRequest
Definition: conmsg.h:977
HANDLE ConsoleHandle
Definition: conmsg.h:701
_In_ BOOL bEnable
Definition: winddi.h:3426

◆ SetConsoleMode()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleMode ( HANDLE  hConsoleHandle,
DWORD  dwMode 
)

Definition at line 1608 of file console.c.

1610{
1611 CONSOLE_API_MESSAGE ApiMessage;
1612 PCONSOLE_GETSETCONSOLEMODE ConsoleModeRequest = &ApiMessage.Data.ConsoleModeRequest;
1613
1614 ConsoleModeRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1615 ConsoleModeRequest->Handle = hConsoleHandle;
1616 ConsoleModeRequest->Mode = dwMode;
1617
1619 NULL,
1621 sizeof(*ConsoleModeRequest));
1622 if (!NT_SUCCESS(ApiMessage.Status))
1623 {
1624 BaseSetLastNTError(ApiMessage.Status);
1625 return FALSE;
1626 }
1627
1628 return TRUE;
1629}
@ ConsolepSetMode
Definition: conmsg.h:38

Referenced by _getch(), _kbhit(), _tmain(), cfgets(), Cleanup(), Confirm(), ConInDisable(), ConInEnable(), ConInString(), ConsoleAttach(), ConsoleDetach(), ConsolePager(), doChild(), EnableExtraHardware(), Execute(), getpass(), CConsole::Init(), Initialize(), main(), PagePrompt(), ReadFromConsole(), ReadString(), RestoreConsole(), SetInsert(), telProcessConsole(), test_Console(), test_WriteConsoleInputA(), test_WriteConsoleInputW(), testWriteNotWrappedNotProcessed(), testWriteNotWrappedProcessed(), testWriteWrappedNotProcessed(), testWriteWrappedProcessed(), and CConsole::~CConsole().

◆ SetConsoleNlsMode()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleNlsMode ( HANDLE  hConsole,
DWORD  dwMode 
)

Definition at line 3020 of file console.c.

3021{
3022 STUB;
3023 return FALSE;
3024}

◆ SetConsoleOS2OemFormat()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleOS2OemFormat ( BOOL  bUnknown)

Definition at line 3156 of file console.c.

3157{
3158 STUB;
3159 return FALSE;
3160}

◆ SetConsoleOutputCP()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleOutputCP ( UINT  wCodePageID)

Definition at line 2482 of file console.c.

2483{
2484 CONSOLE_API_MESSAGE ApiMessage;
2485 PCONSOLE_SETINPUTOUTPUTCP SetConsoleCPRequest = &ApiMessage.Data.SetConsoleCPRequest;
2486
2487 /* Set the Output Code Page */
2488 SetConsoleCPRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2489 SetConsoleCPRequest->CodePage = wCodePageID;
2490 SetConsoleCPRequest->OutputCP = TRUE;
2491 /* SetConsoleCPRequest->EventHandle; */
2492
2494 NULL,
2496 sizeof(*SetConsoleCPRequest));
2497 if (!NT_SUCCESS(ApiMessage.Status))
2498 {
2499 BaseSetLastNTError(ApiMessage.Status);
2500 return FALSE;
2501 }
2502
2503 /* Sync the current thread's LangId with the console's one */
2504 SetTEBLangID();
2505
2506 return TRUE;
2507}

◆ SetConsolePalette()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsolePalette ( HANDLE  hConsoleOutput,
HPALETTE  hPalette,
UINT  dwUsage 
)

Definition at line 1043 of file console.c.

1046{
1047 CONSOLE_API_MESSAGE ApiMessage;
1048 PCONSOLE_SETPALETTE SetPaletteRequest = &ApiMessage.Data.SetPaletteRequest;
1049
1050 SetPaletteRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1051 SetPaletteRequest->OutputHandle = hConsoleOutput;
1052 SetPaletteRequest->PaletteHandle = hPalette;
1053 SetPaletteRequest->Usage = dwUsage;
1054
1056 NULL,
1058 sizeof(*SetPaletteRequest));
1059 if (!NT_SUCCESS(ApiMessage.Status))
1060 {
1061 BaseSetLastNTError(ApiMessage.Status);
1062 return FALSE;
1063 }
1064
1065 return TRUE;
1066}
@ ConsolepSetPalette
Definition: conmsg.h:67
CONSOLE_SETPALETTE SetPaletteRequest
Definition: conmsg.h:973
HANDLE OutputHandle
Definition: conmsg.h:478
HANDLE ConsoleHandle
Definition: conmsg.h:477
HPALETTE PaletteHandle
Definition: conmsg.h:479

Referenced by VgaConsoleCreateGraphicsScreen(), and VgaConsoleCreateTextScreen().

◆ SetConsoleScreenBufferSize()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleScreenBufferSize ( HANDLE  hConsoleOutput,
COORD  dwSize 
)

Definition at line 1857 of file console.c.

1859{
1860 CONSOLE_API_MESSAGE ApiMessage;
1861 PCONSOLE_SETSCREENBUFFERSIZE SetScreenBufferSizeRequest = &ApiMessage.Data.SetScreenBufferSizeRequest;
1862
1863 SetScreenBufferSizeRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1864 SetScreenBufferSizeRequest->OutputHandle = hConsoleOutput;
1865 SetScreenBufferSizeRequest->Size = dwSize;
1866
1868 NULL,
1870 sizeof(*SetScreenBufferSizeRequest));
1871 if (!NT_SUCCESS(ApiMessage.Status))
1872 {
1873 BaseSetLastNTError(ApiMessage.Status);
1874 return FALSE;
1875 }
1876
1877 return TRUE;
1878}
@ ConsolepSetScreenBufferSize
Definition: conmsg.h:42
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
CONSOLE_SETSCREENBUFFERSIZE SetScreenBufferSizeRequest
Definition: conmsg.h:952

Referenced by main(), ResizeTextConsole(), TConsole::SetWindowSize(), START_TEST(), and test_GetConsoleFontInfo().

◆ SetConsoleTextAttribute()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleTextAttribute ( HANDLE  hConsoleOutput,
WORD  wAttributes 
)

Definition at line 2010 of file console.c.

2012{
2013 CONSOLE_API_MESSAGE ApiMessage;
2014 PCONSOLE_SETTEXTATTRIB SetTextAttribRequest = &ApiMessage.Data.SetTextAttribRequest;
2015
2016 SetTextAttribRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2017 SetTextAttribRequest->OutputHandle = hConsoleOutput;
2018 SetTextAttribRequest->Attributes = wAttributes;
2019
2021 NULL,
2023 sizeof(*SetTextAttribRequest));
2024 if (!NT_SUCCESS(ApiMessage.Status))
2025 {
2026 BaseSetLastNTError(ApiMessage.Status);
2027 return FALSE;
2028 }
2029
2030 return TRUE;
2031}
@ ConsolepSetTextAttribute
Definition: conmsg.h:47
CONSOLE_SETTEXTATTRIB SetTextAttribRequest
Definition: conmsg.h:996

◆ SetConsoleTitleA()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleTitleA ( LPCSTR  lpConsoleTitle)

Definition at line 2304 of file console.c.

2305{
2306 return IntSetConsoleTitle(lpConsoleTitle, FALSE);
2307}
static BOOL IntSetConsoleTitle(CONST VOID *lpConsoleTitle, BOOLEAN bUnicode)
Definition: console.c:2245

Referenced by CmdStartProcess().

◆ SetConsoleTitleW()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleTitleW ( LPCWSTR  lpConsoleTitle)

Definition at line 2292 of file console.c.

2293{
2294 return IntSetConsoleTitle(lpConsoleTitle, TRUE);
2295}

Referenced by wmain().

◆ SetConsoleWindowInfo()

BOOL WINAPI SetConsoleWindowInfo ( HANDLE  hConsoleOutput,
BOOL  bAbsolute,
CONST SMALL_RECT lpConsoleWindow 
)

Definition at line 1972 of file console.c.

1975{
1976 CONSOLE_API_MESSAGE ApiMessage;
1977 PCONSOLE_SETWINDOWINFO SetWindowInfoRequest = &ApiMessage.Data.SetWindowInfoRequest;
1978
1979 if (lpConsoleWindow == NULL)
1980 {
1982 return FALSE;
1983 }
1984
1985 SetWindowInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1986 SetWindowInfoRequest->OutputHandle = hConsoleOutput;
1987 SetWindowInfoRequest->Absolute = bAbsolute;
1988 SetWindowInfoRequest->WindowRect = *lpConsoleWindow;
1989
1991 NULL,
1993 sizeof(*SetWindowInfoRequest));
1994 if (!NT_SUCCESS(ApiMessage.Status))
1995 {
1996 BaseSetLastNTError(ApiMessage.Status);
1997 return FALSE;
1998 }
1999
2000 return TRUE;
2001}
@ ConsolepSetWindowInfo
Definition: conmsg.h:45
CONSOLE_SETWINDOWINFO SetWindowInfoRequest
Definition: conmsg.h:978
SMALL_RECT WindowRect
Definition: conmsg.h:710

Referenced by main(), ResizeTextConsole(), TConsole::SetWindowSize(), START_TEST(), and TConsole::WriteStringFast().

◆ SetLastConsoleEventActive()

DWORD WINAPI SetLastConsoleEventActive ( VOID  )

Definition at line 3285 of file console.c.

3286{
3287 CONSOLE_API_MESSAGE ApiMessage;
3288 PCONSOLE_NOTIFYLASTCLOSE NotifyLastCloseRequest = &ApiMessage.Data.NotifyLastCloseRequest;
3289
3290 /* Set the flag used by the console control dispatcher */
3292
3293 /* Set up the input arguments */
3294 NotifyLastCloseRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
3295
3296 /* Call CSRSS; just return the NTSTATUS cast to DWORD */
3297 return CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
3298 NULL,
3300 sizeof(*NotifyLastCloseRequest));
3301}
@ ConsolepNotifyLastClose
Definition: conmsg.h:88
CONSOLE_NOTIFYLASTCLOSE NotifyLastCloseRequest
Definition: conmsg.h:931

Referenced by ConsoleInit().

◆ SetStdHandle()

BOOL WINAPI DECLSPEC_HOTPATCH SetStdHandle ( DWORD  nStdHandle,
HANDLE  hHandle 
)

Definition at line 1215 of file console.c.

1227{
1228 PRTL_USER_PROCESS_PARAMETERS Ppb = NtCurrentPeb()->ProcessParameters;
1229
1230 /* No need to check if hHandle == INVALID_HANDLE_VALUE */
1231
1232 switch (nStdHandle)
1233 {
1234 case STD_INPUT_HANDLE:
1235 Ppb->StandardInput = hHandle;
1236 return TRUE;
1237
1238 case STD_OUTPUT_HANDLE:
1239 Ppb->StandardOutput = hHandle;
1240 return TRUE;
1241
1242 case STD_ERROR_HANDLE:
1243 Ppb->StandardError = hHandle;
1244 return TRUE;
1245 }
1246
1247 /* nStdHandle was invalid, bail out */
1249 return FALSE;
1250}

Referenced by __acrt_lowio_set_os_handle(), _free_osfhnd(), ExecutePipeline(), msvcrt_free_fd(), msvcrt_set_fd(), SetHandle(), test_close(), test_DetachStdHandles(), test_GetSetStdHandle(), test_Handles(), and test_stdin().

◆ SetTEBLangID()

VOID SetTEBLangID ( VOID  )

Internal helper function used to synchronize the current thread's language ID with the one from the console.

Definition at line 3177 of file console.c.

3178{
3179 CONSOLE_API_MESSAGE ApiMessage;
3180 PCONSOLE_GETLANGID LangIdRequest = &ApiMessage.Data.LangIdRequest;
3181
3182 /* Retrieve the "best-suited" language ID corresponding
3183 * to the active console output code page. */
3184 LangIdRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
3185
3187 NULL,
3189 sizeof(*LangIdRequest));
3190 if (!NT_SUCCESS(ApiMessage.Status))
3191 {
3192 /*
3193 * No best console language ID: keep the current thread's one.
3194 * Since this internal function only modifies an optional setting,
3195 * don't set any last error, as it could otherwise mess with the
3196 * main last error set by the caller.
3197 */
3198 return;
3199 }
3200
3201 /*
3202 * We succeeded, set the current thread's language ID by
3203 * modifying its locale -- Windows <= 2003 does not have
3204 * the concept of a separate thread UI language.
3205 * Ignore the returned value.
3206 */
3207 if (!SetThreadLocale(MAKELCID(LangIdRequest->LangId, SORT_DEFAULT)))
3208 {
3209 DPRINT1("SetTEBLangID: Could not set thread locale to console lang ID %lu\n",
3210 LangIdRequest->LangId);
3211 }
3212}
@ ConsolepGetLangId
Definition: conmsg.h:103
BOOL WINAPI SetThreadLocale(LCID lcid)
Definition: locale.c:2820
#define SORT_DEFAULT
#define MAKELCID(lgid, srtid)
CONSOLE_GETLANGID LangIdRequest
Definition: conmsg.h:1016
HANDLE ConsoleHandle
Definition: conmsg.h:864

Referenced by AllocConsole(), AttachConsole(), ConDllInitialize(), and SetConsoleOutputCP().

◆ SetUpAppName()

VOID SetUpAppName ( IN BOOLEAN  CaptureStrings,
IN OUT LPDWORD  CurDirLength,
IN OUT LPWSTR CurDir,
IN OUT LPDWORD  AppNameLength,
IN OUT LPWSTR AppName 
)

Definition at line 264 of file console.c.

269{
271
272 /* Retrieve the needed buffer size */
273 Length = (StartDirLength + 1) * sizeof(WCHAR);
274 if (*CurDirLength > 0) Length = min(Length, *CurDirLength);
275 *CurDirLength = Length;
276
277 /* Capture the data if needed, or, return a pointer to it */
278 if (CaptureStrings)
279 {
280 /*
281 * Length is always >= sizeof(WCHAR). Copy everything but the
282 * possible trailing NULL character, and then NULL-terminate.
283 */
284 Length -= sizeof(WCHAR);
286 (*CurDir)[Length / sizeof(WCHAR)] = UNICODE_NULL;
287 }
288 else
289 {
290 *CurDir = StartDirBuffer;
291 }
292
293 /* Retrieve the needed buffer size */
294 Length = (ExeNameLength + 1) * sizeof(WCHAR);
295 if (*AppNameLength > 0) Length = min(Length, *AppNameLength);
296 *AppNameLength = Length;
297
298 /* Capture the data if needed, or, return a pointer to it */
299 if (CaptureStrings)
300 {
301 /*
302 * Length is always >= sizeof(WCHAR). Copy everything but the
303 * possible trailing NULL character, and then NULL-terminate.
304 */
305 Length -= sizeof(WCHAR);
307 (*AppName)[Length / sizeof(WCHAR)] = UNICODE_NULL;
308 }
309 else
310 {
312 }
313}
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102

Referenced by AllocConsole(), and ConDllInitialize().

◆ ShowConsoleCursor()

INT WINAPI DECLSPEC_HOTPATCH ShowConsoleCursor ( HANDLE  hConsoleOutput,
BOOL  bShow 
)

Definition at line 1075 of file console.c.

1077{
1078 CONSOLE_API_MESSAGE ApiMessage;
1079 PCONSOLE_SHOWCURSOR ShowCursorRequest = &ApiMessage.Data.ShowCursorRequest;
1080
1081 ShowCursorRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1082 ShowCursorRequest->OutputHandle = hConsoleOutput;
1083 ShowCursorRequest->Show = bShow;
1084 ShowCursorRequest->RefCount = 0;
1085
1087 NULL,
1089 sizeof(*ShowCursorRequest));
1090
1091 return ShowCursorRequest->RefCount;
1092}
@ ConsolepShowCursor
Definition: conmsg.h:65
CONSOLE_SHOWCURSOR ShowCursorRequest
Definition: conmsg.h:942
HANDLE OutputHandle
Definition: conmsg.h:330
HANDLE ConsoleHandle
Definition: conmsg.h:329

Referenced by CaptureMousePointer().

◆ UnregisterConsoleIME()

BOOL WINAPI DECLSPEC_HOTPATCH UnregisterConsoleIME ( VOID  )

Definition at line 3166 of file console.c.

3167{
3169}
static BOOL IntUnregisterConsoleIME(_In_ DWORD dwThreadId)
Definition: console.c:3107

Referenced by IntUnregisterConsoleIME().

◆ VerifyConsoleIoHandle()

BOOL WINAPI DECLSPEC_HOTPATCH VerifyConsoleIoHandle ( HANDLE  hIoHandle)

Definition at line 1112 of file console.c.

1113{
1114 CONSOLE_API_MESSAGE ApiMessage;
1115 PCONSOLE_VERIFYHANDLE VerifyHandleRequest = &ApiMessage.Data.VerifyHandleRequest;
1116
1117 VerifyHandleRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1118 VerifyHandleRequest->Handle = hIoHandle;
1119 VerifyHandleRequest->IsValid = FALSE;
1120
1121 /* If the process is not attached to a console, return invalid handle */
1122 if (VerifyHandleRequest->ConsoleHandle == NULL) return FALSE;
1123
1125 NULL,
1127 sizeof(*VerifyHandleRequest));
1128 if (!NT_SUCCESS(ApiMessage.Status))
1129 {
1130 BaseSetLastNTError(ApiMessage.Status);
1131 return FALSE;
1132 }
1133
1134 return VerifyHandleRequest->IsValid;
1135}
@ ConsolepVerifyIoHandle
Definition: conmsg.h:56
CONSOLE_VERIFYHANDLE VerifyHandleRequest
Definition: conmsg.h:936
HANDLE ConsoleHandle
Definition: conmsg.h:633

Referenced by GetFileType(), init_function_pointers(), RegisterWaitForSingleObject(), RegisterWaitForSingleObjectEx(), SignalObjectAndWait(), WaitForMultipleObjectsEx(), and WaitForSingleObjectEx().

Variable Documentation

◆ BaseConFileName

LPCWSTR BaseConFileName = CONSOLE_FILE_NAME
static

Definition at line 24 of file console.c.

Referenced by IntCheckForConsoleFileName().

◆ BaseConInputFileName

LPCWSTR BaseConInputFileName = CONSOLE_INPUT_FILE_NAME
static

Definition at line 25 of file console.c.

Referenced by IntCheckForConsoleFileName(), and OpenConsoleW().

◆ BaseConOutputFileName

LPCWSTR BaseConOutputFileName = CONSOLE_OUTPUT_FILE_NAME
static

Definition at line 26 of file console.c.

Referenced by IntCheckForConsoleFileName(), and OpenConsoleW().

◆ ConsoleInitialized

BOOLEAN ConsoleInitialized
extern

Definition at line 25 of file init.c.

Referenced by ConDllInitialize(), ConsoleControlDispatcher(), and PropDialogHandler().

◆ ConsoleLock

◆ CtrlHandlers

◆ ExeNameBuffer

◆ ExeNameInitialized

BOOLEAN ExeNameInitialized
static

Definition at line 42 of file console.c.

Referenced by GetCurrentExeName(), and InitExeName().

◆ ExeNameLength

USHORT ExeNameLength
static

◆ ExeNameLock

RTL_CRITICAL_SECTION ExeNameLock
static

◆ InitialHandler

PHANDLER_ROUTINE InitialHandler[1]
static

Definition at line 29 of file console.c.

Referenced by InitializeCtrlHandling().

◆ InputWaitHandle

◆ LastCloseNotify

BOOLEAN LastCloseNotify = FALSE
static

Definition at line 33 of file console.c.

Referenced by ConsoleControlDispatcher(), and SetLastConsoleEventActive().

◆ NrAllocatedHandlers

ULONG NrAllocatedHandlers
static

Definition at line 32 of file console.c.

Referenced by AddConsoleCtrlHandler(), and InitializeCtrlHandling().

◆ NrCtrlHandlers

ULONG NrCtrlHandlers
static

◆ StartDirBuffer

WCHAR StartDirBuffer[MAX_PATH+1]
static

Definition at line 45 of file console.c.

Referenced by InitExeName(), and SetUpAppName().

◆ StartDirLength

USHORT StartDirLength
static

Definition at line 46 of file console.c.

Referenced by InitExeName(), and SetUpAppName().