ReactOS 0.4.15-dev-7942-gd23573b
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 hConsole, 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 (DWORD Unknown0, DWORD Unknown1, DWORD Unknown2, DWORD Unknown3)
 
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 (DWORD Unknown1, DWORD Unknown2, DWORD Unknown3, DWORD Unknown4)
 
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 2034 of file console.c.

2035{
2036 PHANDLER_ROUTINE* NewCtrlHandlers = NULL;
2037
2038 if (HandlerRoutine == NULL)
2039 {
2040 NtCurrentPeb()->ProcessParameters->ConsoleFlags = TRUE;
2041 return TRUE;
2042 }
2043
2045 {
2046 NewCtrlHandlers = RtlAllocateHeap(RtlGetProcessHeap(),
2047 0,
2048 (NrCtrlHandlers + 4) * sizeof(PHANDLER_ROUTINE));
2049 if (NewCtrlHandlers == NULL)
2050 {
2052 return FALSE;
2053 }
2054
2055 memmove(NewCtrlHandlers, CtrlHandlers, sizeof(PHANDLER_ROUTINE) * NrCtrlHandlers);
2056
2057 if (NrAllocatedHandlers > 1) RtlFreeHeap(RtlGetProcessHeap(), 0, CtrlHandlers);
2058
2059 CtrlHandlers = NewCtrlHandlers;
2061 }
2062
2064
2066 return TRUE;
2067}
#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:590
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
#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(CALLBACK * PHANDLER_ROUTINE)(_In_ DWORD)
Definition: wincon.h:237

Referenced by SetConsoleCtrlHandler().

◆ AllocConsole()

BOOL WINAPI DECLSPEC_HOTPATCH AllocConsole ( VOID  )

Definition at line 1363 of file console.c.

1364{
1365 BOOL Success;
1366 CONSOLE_START_INFO ConsoleStartInfo;
1367
1368 PWCHAR ConsoleTitle;
1371 PWCHAR CurDir;
1372
1373 ULONG TitleLength = (MAX_PATH + 1) * sizeof(WCHAR);
1374 ULONG DesktopLength = (MAX_PATH + 1) * sizeof(WCHAR);
1375 ULONG AppNameLength = 128 * sizeof(WCHAR);
1376 ULONG CurDirLength = (MAX_PATH + 1) * sizeof(WCHAR);
1377
1379
1380 if (NtCurrentPeb()->ProcessParameters->ConsoleHandle)
1381 {
1382 DPRINT1("AllocConsole: Allocating a console to a process already having one\n");
1384 Success = FALSE;
1385 goto Quit;
1386 }
1387
1388 /* Set up the console properties */
1390 &TitleLength,
1391 &ConsoleTitle,
1392 &DesktopLength,
1393 &Desktop,
1394 &ConsoleStartInfo);
1395 DPRINT("ConsoleTitle = '%S' - Desktop = '%S'\n",
1396 ConsoleTitle, Desktop);
1397
1398 /* Initialize the Input EXE name */
1399 InitExeName();
1401 &CurDirLength,
1402 &CurDir,
1403 &AppNameLength,
1404 &AppName);
1405 DPRINT("CurDir = '%S' - AppName = '%S'\n",
1406 CurDir, AppName);
1407
1408 Success = IntAllocConsole(ConsoleTitle,
1409 TitleLength,
1410 Desktop,
1411 DesktopLength,
1412 CurDir,
1413 CurDirLength,
1414 AppName,
1415 AppNameLength,
1418 &ConsoleStartInfo);
1419 if (Success)
1420 {
1421 /* Set up the handles */
1422 SetUpHandles(&ConsoleStartInfo);
1423 InputWaitHandle = ConsoleStartInfo.InputWaitHandle;
1424
1425 /* Initialize Console Ctrl Handling */
1427
1428 /* Sync the current thread's LangId with the console's one */
1429 SetTEBLangID();
1430 }
1431
1432Quit:
1434 return Success;
1435}
#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:3171
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:1255
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:71
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 2676 of file console.c.

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

◆ CloseConsoleHandle()

BOOL WINAPI DECLSPEC_HOTPATCH CloseConsoleHandle ( HANDLE  hHandle)

Definition at line 1142 of file console.c.

1143{
1144 CONSOLE_API_MESSAGE ApiMessage;
1145 PCONSOLE_CLOSEHANDLE CloseHandleRequest = &ApiMessage.Data.CloseHandleRequest;
1146
1147 CloseHandleRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1148 CloseHandleRequest->Handle = hHandle;
1149
1151 NULL,
1153 sizeof(*CloseHandleRequest));
1154 if (!NT_SUCCESS(ApiMessage.Status))
1155 {
1156 BaseSetLastNTError(ApiMessage.Status);
1157 return FALSE;
1158 }
1159
1160 return TRUE;
1161}
@ 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:32
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
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::@3540 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
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
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:85
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:34
#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:333
HANDLE WINAPI GetCurrentThread(void)
Definition: proc.c:1148
#define THREAD_PRIORITY_HIGHEST
Definition: winbase.h:277
BOOL WINAPI IsDebuggerPresent(void)
Definition: debugger.c:580
#define CTRL_C_EVENT
Definition: wincon.h:68
#define CTRL_SHUTDOWN_EVENT
Definition: wincon.h:73
#define CTRL_BREAK_EVENT
Definition: wincon.h:69
#define CTRL_LOGOFF_EVENT
Definition: wincon.h:72
#define CTRL_LAST_CLOSE_EVENT
Definition: wincon.h:71
#define CTRL_CLOSE_EVENT
Definition: wincon.h:70

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 2313 of file console.c.

2318{
2319 CONSOLE_API_MESSAGE ApiMessage;
2320 PCONSOLE_CREATESCREENBUFFER CreateScreenBufferRequest = &ApiMessage.Data.CreateScreenBufferRequest;
2321 PCSR_CAPTURE_BUFFER CaptureBuffer = NULL;
2322 PCONSOLE_GRAPHICS_BUFFER_INFO GraphicsBufferInfo = lpScreenBufferData;
2323
2324 if ( (dwDesiredAccess & ~(GENERIC_READ | GENERIC_WRITE)) ||
2325 (dwShareMode & ~(FILE_SHARE_READ | FILE_SHARE_WRITE)) ||
2327 {
2329 return INVALID_HANDLE_VALUE;
2330 }
2331
2332 CreateScreenBufferRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2333 CreateScreenBufferRequest->DesiredAccess = dwDesiredAccess;
2334 CreateScreenBufferRequest->InheritHandle =
2335 (lpSecurityAttributes ? lpSecurityAttributes->bInheritHandle : FALSE);
2336 CreateScreenBufferRequest->ShareMode = dwShareMode;
2337 CreateScreenBufferRequest->ScreenBufferType = dwFlags;
2338
2340 {
2341 if (CreateScreenBufferRequest->InheritHandle || GraphicsBufferInfo == NULL)
2342 {
2344 return INVALID_HANDLE_VALUE;
2345 }
2346
2347 CreateScreenBufferRequest->GraphicsBufferInfo = *GraphicsBufferInfo;
2348
2349 CaptureBuffer = CsrAllocateCaptureBuffer(1, GraphicsBufferInfo->dwBitMapInfoLength);
2350 if (CaptureBuffer == NULL)
2351 {
2353 return INVALID_HANDLE_VALUE;
2354 }
2355
2356 CsrCaptureMessageBuffer(CaptureBuffer,
2357 (PVOID)GraphicsBufferInfo->lpBitMapInfo,
2358 GraphicsBufferInfo->dwBitMapInfoLength,
2359 (PVOID*)&CreateScreenBufferRequest->GraphicsBufferInfo.lpBitMapInfo);
2360 }
2361
2363 CaptureBuffer,
2365 sizeof(*CreateScreenBufferRequest));
2366
2367 if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
2368
2369 if (!NT_SUCCESS(ApiMessage.Status))
2370 {
2371 BaseSetLastNTError(ApiMessage.Status);
2372 return INVALID_HANDLE_VALUE;
2373 }
2374
2375 if (dwFlags == CONSOLE_GRAPHICS_BUFFER && GraphicsBufferInfo)
2376 {
2377 GraphicsBufferInfo->hMutex = CreateScreenBufferRequest->hMutex ; // CreateScreenBufferRequest->GraphicsBufferInfo.hMutex ;
2378 GraphicsBufferInfo->lpBitMap = CreateScreenBufferRequest->lpBitMap; // CreateScreenBufferRequest->GraphicsBufferInfo.lpBitMap;
2379 }
2380
2381 return CreateScreenBufferRequest->OutputHandle;
2382}
@ 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
LPBITMAPINFO lpBitMapInfo
Definition: wincon.h:230
#define CONSOLE_TEXTMODE_BUFFER
Definition: wincon.h:62
#define CONSOLE_GRAPHICS_BUFFER
Definition: wincon.h:63
_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  hConsole,
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 = hConsole;
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 1827 of file console.c.

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

◆ FreeConsole()

BOOL WINAPI DECLSPEC_HOTPATCH FreeConsole ( VOID  )

Definition at line 1444 of file console.c.

1445{
1446 BOOL Success = TRUE;
1447 CONSOLE_API_MESSAGE ApiMessage;
1448 PCONSOLE_FREECONSOLE FreeConsoleRequest = &ApiMessage.Data.FreeConsoleRequest;
1449 HANDLE ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1450
1452
1453 /* We must have a non-trivial handle to close */
1454 if (ConsoleHandle == NULL) // IsConsoleHandle(ConsoleHandle)
1455 {
1457 Success = FALSE;
1458 goto Quit;
1459 }
1460
1461 /* Set up the data to send to the Console Server */
1462 FreeConsoleRequest->ConsoleHandle = ConsoleHandle;
1463
1464 /* Call the server */
1466 NULL,
1468 sizeof(*FreeConsoleRequest));
1469
1470 /* Check for success */
1471 if (!NT_SUCCESS(ApiMessage.Status))
1472 {
1473 BaseSetLastNTError(ApiMessage.Status);
1474 Success = FALSE;
1475 goto Quit;
1476 }
1477
1478 /* Reset the console handle */
1479 NtCurrentPeb()->ProcessParameters->ConsoleHandle = NULL;
1480
1481 /* Close the associated input handle */
1484
1485Quit:
1487 return Success;
1488}
@ 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 2132 of file console.c.

2134{
2135 CONSOLE_API_MESSAGE ApiMessage;
2136 PCONSOLE_GENERATECTRLEVENT GenerateCtrlEventRequest = &ApiMessage.Data.GenerateCtrlEventRequest;
2137
2138 if (dwCtrlEvent != CTRL_C_EVENT && dwCtrlEvent != CTRL_BREAK_EVENT)
2139 {
2141 return FALSE;
2142 }
2143
2144 GenerateCtrlEventRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2145 GenerateCtrlEventRequest->CtrlEvent = dwCtrlEvent;
2146 GenerateCtrlEventRequest->ProcessGroupId = dwProcessGroupId;
2147
2149 NULL,
2151 sizeof(*GenerateCtrlEventRequest));
2152 if (!NT_SUCCESS(ApiMessage.Status))
2153 {
2154 BaseSetLastNTError(ApiMessage.Status);
2155 return FALSE;
2156 }
2157
2158 return TRUE;
2159}
@ 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 2982 of file console.c.

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

◆ GetConsoleCP()

UINT WINAPI DECLSPEC_HOTPATCH GetConsoleCP ( VOID  )

Definition at line 2391 of file console.c.

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

Referenced by _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 1702 of file console.c.

1704{
1705 CONSOLE_API_MESSAGE ApiMessage;
1706 PCONSOLE_GETSETCURSORINFO CursorInfoRequest = &ApiMessage.Data.CursorInfoRequest;
1707
1708 if (!lpConsoleCursorInfo)
1709 {
1710 if (!hConsoleOutput)
1712 else
1714
1715 return FALSE;
1716 }
1717
1718 CursorInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1719 CursorInfoRequest->OutputHandle = hConsoleOutput;
1720
1722 NULL,
1724 sizeof(*CursorInfoRequest));
1725 if (!NT_SUCCESS(ApiMessage.Status))
1726 {
1727 BaseSetLastNTError(ApiMessage.Status);
1728 return FALSE;
1729 }
1730
1731 *lpConsoleCursorInfo = CursorInfoRequest->Info;
1732
1733 return TRUE;
1734}
@ 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 2991 of file console.c.

2992{
2993 STUB;
2994 return FALSE;
2995}

◆ 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 2944 of file console.c.

2946{
2948 DWORD ExeLength;
2949 UNICODE_STRING BufferU;
2950 ANSI_STRING BufferA;
2952
2953 /* Get the UNICODE name */
2955
2956 if ((ExeLength == 0) || (ExeLength >= EXENAME_LENGTH))
2957 return ExeLength;
2958
2959 /* Initialize the strings for conversion */
2960 RtlInitUnicodeString(&BufferU, Buffer);
2961 BufferA.Length = 0;
2963 BufferA.Buffer = lpExeName;
2964
2965 /* Convert UNICODE name to ANSI, copying as much chars as it can fit */
2966 Status = RtlUnicodeStringToAnsiString(&BufferA, &BufferU, FALSE);
2967 if (!NT_SUCCESS(Status))
2968 {
2970 {
2972 return ExeLength + 1;
2973 }
2975 }
2976
2977 return ExeLength;
2978}
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:2905
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:3073
#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 2905 of file console.c.

2907{
2909 {
2910 /* Buffer is not large enough! Return the correct size. */
2912 return ExeNameLength + 1;
2913 }
2914
2916 _SEH2_TRY
2917 {
2918 /* Copy the input EXE name and NULL-terminate it */
2921 }
2923 {
2925 }
2926 _SEH2_END;
2927
2928 return TRUE;
2929}
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 _SEH2_FINALLY
Definition: filesup.c:21
#define UNICODE_NULL

Referenced by GetConsoleInputExeNameA().

◆ GetConsoleInputWaitHandle()

◆ GetConsoleKeyboardLayoutNameA()

BOOL WINAPI DECLSPEC_HOTPATCH GetConsoleKeyboardLayoutNameA ( OUT LPSTR  pszLayoutName)

Definition at line 3258 of file console.c.

3259{
3260 return IntGetConsoleKeyboardLayoutName(pszLayoutName, TRUE);
3261}
static BOOL IntGetConsoleKeyboardLayoutName(OUT PVOID pszLayoutName, IN BOOL bAnsi)
Definition: console.c:3210

◆ GetConsoleKeyboardLayoutNameW()

BOOL WINAPI DECLSPEC_HOTPATCH GetConsoleKeyboardLayoutNameW ( OUT LPWSTR  pszLayoutName)

Definition at line 3269 of file console.c.

3270{
3271 return IntGetConsoleKeyboardLayoutName(pszLayoutName, FALSE);
3272}

◆ GetConsoleMode()

BOOL WINAPI GetConsoleMode ( HANDLE  hConsoleHandle,
LPDWORD  lpMode 
)

Definition at line 1569 of file console.c.

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

Referenced by _getch(), _kbhit(), _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(), and testWriteWrappedProcessed().

◆ GetConsoleNlsMode()

BOOL WINAPI DECLSPEC_HOTPATCH GetConsoleNlsMode ( HANDLE  hConsole,
LPDWORD  lpMode 
)

Definition at line 3009 of file console.c.

3010{
3011 STUB;
3012 return FALSE;
3013}

◆ GetConsoleOutputCP()

UINT WINAPI DECLSPEC_HOTPATCH GetConsoleOutputCP ( VOID  )

Definition at line 2451 of file console.c.

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

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

◆ GetConsoleProcessList()

DWORD WINAPI GetConsoleProcessList ( LPDWORD  lpdwProcessList,
DWORD  dwProcessCount 
)

Definition at line 2513 of file console.c.

2515{
2516 CONSOLE_API_MESSAGE ApiMessage;
2517 PCONSOLE_GETPROCESSLIST GetProcessListRequest = &ApiMessage.Data.GetProcessListRequest;
2518 PCSR_CAPTURE_BUFFER CaptureBuffer;
2519 ULONG nProcesses = 0;
2520
2521 if (lpdwProcessList == NULL || dwProcessCount == 0)
2522 {
2524 return 0;
2525 }
2526
2527 CaptureBuffer = CsrAllocateCaptureBuffer(1, dwProcessCount * sizeof(DWORD));
2528 if (CaptureBuffer == NULL)
2529 {
2530 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
2532 return 0;
2533 }
2534
2535 GetProcessListRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2536 GetProcessListRequest->ProcessCount = dwProcessCount;
2537
2538 CsrAllocateMessagePointer(CaptureBuffer,
2539 dwProcessCount * sizeof(DWORD),
2540 (PVOID*)&GetProcessListRequest->ProcessIdsList);
2541
2543 CaptureBuffer,
2545 sizeof(*GetProcessListRequest));
2546 if (!NT_SUCCESS(ApiMessage.Status))
2547 {
2548 BaseSetLastNTError(ApiMessage.Status);
2549 }
2550 else
2551 {
2552 nProcesses = GetProcessListRequest->ProcessCount;
2553 if (dwProcessCount >= nProcesses)
2554 {
2555 RtlCopyMemory(lpdwProcessList, GetProcessListRequest->ProcessIdsList, nProcesses * sizeof(DWORD));
2556 }
2557 }
2558
2559 CsrFreeCaptureBuffer(CaptureBuffer);
2560 return nProcesses;
2561}
@ 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 1496 of file console.c.

1498{
1499 CONSOLE_API_MESSAGE ApiMessage;
1500 PCONSOLE_GETSCREENBUFFERINFO ScreenBufferInfoRequest = &ApiMessage.Data.ScreenBufferInfoRequest;
1501
1502 if (lpConsoleScreenBufferInfo == NULL)
1503 {
1505 return FALSE;
1506 }
1507
1508 ScreenBufferInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1509 ScreenBufferInfoRequest->OutputHandle = hConsoleOutput;
1510
1512 NULL,
1514 sizeof(*ScreenBufferInfoRequest));
1515 if (!NT_SUCCESS(ApiMessage.Status))
1516 {
1517 BaseSetLastNTError(ApiMessage.Status);
1518 return FALSE;
1519 }
1520
1521 lpConsoleScreenBufferInfo->dwSize = ScreenBufferInfoRequest->ScreenBufferSize;
1522 lpConsoleScreenBufferInfo->dwCursorPosition = ScreenBufferInfoRequest->CursorPosition;
1523 lpConsoleScreenBufferInfo->wAttributes = ScreenBufferInfoRequest->Attributes;
1524 lpConsoleScreenBufferInfo->srWindow.Left = ScreenBufferInfoRequest->ViewOrigin.X;
1525 lpConsoleScreenBufferInfo->srWindow.Top = ScreenBufferInfoRequest->ViewOrigin.Y;
1526 lpConsoleScreenBufferInfo->srWindow.Right = ScreenBufferInfoRequest->ViewOrigin.X + ScreenBufferInfoRequest->ViewSize.X - 1;
1527 lpConsoleScreenBufferInfo->srWindow.Bottom = ScreenBufferInfoRequest->ViewOrigin.Y + ScreenBufferInfoRequest->ViewSize.Y - 1;
1528 lpConsoleScreenBufferInfo->dwMaximumWindowSize = ScreenBufferInfoRequest->MaximumViewSize;
1529
1530 return TRUE;
1531}
@ 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 2569 of file console.c.

2570{
2571 CONSOLE_API_MESSAGE ApiMessage;
2572 PCONSOLE_GETSELECTIONINFO GetSelectionInfoRequest = &ApiMessage.Data.GetSelectionInfoRequest;
2573
2574 if (lpConsoleSelectionInfo == NULL)
2575 {
2577 return FALSE;
2578 }
2579
2580 GetSelectionInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2581
2583 NULL,
2585 sizeof(*GetSelectionInfoRequest));
2586 if (!NT_SUCCESS(ApiMessage.Status))
2587 {
2588 BaseSetLastNTError(ApiMessage.Status);
2589 return FALSE;
2590 }
2591
2592 *lpConsoleSelectionInfo = GetSelectionInfoRequest->Info;
2593
2594 return TRUE;
2595}
@ 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 2235 of file console.c.

2237{
2238 return IntGetConsoleTitle(lpConsoleTitle, nSize, FALSE);
2239}
static DWORD IntGetConsoleTitle(LPVOID lpConsoleTitle, DWORD dwNumChars, BOOLEAN bUnicode)
Definition: console.c:2163
*nSize LPSTR _Inout_ LPDWORD nSize
Definition: winbase.h:2084

◆ GetConsoleTitleW()

DWORD WINAPI DECLSPEC_HOTPATCH GetConsoleTitleW ( LPWSTR  lpConsoleTitle,
DWORD  nSize 
)

Definition at line 2222 of file console.c.

2224{
2225 return IntGetConsoleTitle(lpConsoleTitle, nSize, TRUE);
2226}

◆ GetConsoleWindow()

HWND WINAPI DECLSPEC_HOTPATCH GetConsoleWindow ( VOID  )

Definition at line 2729 of file console.c.

2730{
2731 CONSOLE_API_MESSAGE ApiMessage;
2732 PCONSOLE_GETWINDOW GetWindowRequest = &ApiMessage.Data.GetWindowRequest;
2733
2734 GetWindowRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2735
2737 NULL,
2739 sizeof(*GetWindowRequest));
2740 if (!NT_SUCCESS(ApiMessage.Status))
2741 {
2742 BaseSetLastNTError(ApiMessage.Status);
2743 return (HWND)NULL;
2744 }
2745
2746 return GetWindowRequest->WindowHandle;
2747}
@ 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 1673 of file console.c.

1674{
1675 CONSOLE_API_MESSAGE ApiMessage;
1676 PCONSOLE_GETLARGESTWINDOWSIZE GetLargestWindowSizeRequest = &ApiMessage.Data.GetLargestWindowSizeRequest;
1677
1678 GetLargestWindowSizeRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1679 GetLargestWindowSizeRequest->OutputHandle = hConsoleOutput;
1680 GetLargestWindowSizeRequest->Size.X = 0;
1681 GetLargestWindowSizeRequest->Size.Y = 0;
1682
1684 NULL,
1686 sizeof(*GetLargestWindowSizeRequest));
1687 if (!NT_SUCCESS(ApiMessage.Status))
1688 {
1689 BaseSetLastNTError(ApiMessage.Status);
1690 }
1691
1692 DPRINT("GetLargestConsoleWindowSize, X = %d, Y = %d\n", GetLargestWindowSizeRequest->Size.X, GetLargestWindowSizeRequest->Size.Y);
1693 return GetLargestWindowSizeRequest->Size;
1694}
@ 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 1635 of file console.c.

1637{
1638 CONSOLE_API_MESSAGE ApiMessage;
1639 PCONSOLE_GETNUMINPUTEVENTS GetNumInputEventsRequest = &ApiMessage.Data.GetNumInputEventsRequest;
1640
1641 GetNumInputEventsRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1642 GetNumInputEventsRequest->InputHandle = hConsoleInput;
1643 GetNumInputEventsRequest->NumberOfEvents = 0;
1644
1646 NULL,
1648 sizeof(*GetNumInputEventsRequest));
1649 if (!NT_SUCCESS(ApiMessage.Status))
1650 {
1651 BaseSetLastNTError(ApiMessage.Status);
1652 return FALSE;
1653 }
1654
1655 if (lpNumberOfEvents == NULL)
1656 {
1658 return FALSE;
1659 }
1660
1661 *lpNumberOfEvents = GetNumInputEventsRequest->NumberOfEvents;
1662
1663 return TRUE;
1664}
@ 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 1771 of file console.c.

1772{
1773 CONSOLE_API_MESSAGE ApiMessage;
1774 PCONSOLE_GETMOUSEINFO GetMouseInfoRequest = &ApiMessage.Data.GetMouseInfoRequest;
1775
1776 GetMouseInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1777
1779 NULL,
1781 sizeof(*GetMouseInfoRequest));
1782 if (!NT_SUCCESS(ApiMessage.Status))
1783 {
1784 BaseSetLastNTError(ApiMessage.Status);
1785 return FALSE;
1786 }
1787
1788 *lpNumberOfMouseButtons = GetMouseInfoRequest->NumButtons;
1789 return TRUE;
1790}
@ 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 1170 of file console.c.

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

◆ 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:145
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
LIST_ENTRY InLoadOrderModuleList
Definition: ldrtypes.h:120
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 1255 of file console.c.

1266{
1267 BOOL Success = TRUE;
1269
1270 CONSOLE_API_MESSAGE ApiMessage;
1271 PCONSOLE_ALLOCCONSOLE AllocConsoleRequest = &ApiMessage.Data.AllocConsoleRequest;
1272 PCSR_CAPTURE_BUFFER CaptureBuffer;
1273
1274 AllocConsoleRequest->CtrlRoutine = CtrlRoutine;
1275 AllocConsoleRequest->PropRoutine = PropRoutine;
1276
1277 CaptureBuffer = CsrAllocateCaptureBuffer(5, TitleLength +
1278 DesktopLength +
1279 CurDirLength +
1280 AppNameLength +
1281 sizeof(CONSOLE_START_INFO));
1282 if (CaptureBuffer == NULL)
1283 {
1285 Success = FALSE;
1286 goto Quit;
1287 }
1288
1289 CsrCaptureMessageBuffer(CaptureBuffer,
1290 ConsoleStartInfo,
1291 sizeof(CONSOLE_START_INFO),
1292 (PVOID*)&AllocConsoleRequest->ConsoleStartInfo);
1293
1294 AllocConsoleRequest->TitleLength = TitleLength;
1295 CsrCaptureMessageBuffer(CaptureBuffer,
1296 Title,
1297 TitleLength,
1298 (PVOID*)&AllocConsoleRequest->ConsoleTitle);
1299
1300 AllocConsoleRequest->DesktopLength = DesktopLength;
1301 CsrCaptureMessageBuffer(CaptureBuffer,
1302 Desktop,
1303 DesktopLength,
1304 (PVOID*)&AllocConsoleRequest->Desktop);
1305
1306 AllocConsoleRequest->CurDirLength = CurDirLength;
1307 CsrCaptureMessageBuffer(CaptureBuffer,
1308 CurDir,
1309 CurDirLength,
1310 (PVOID*)&AllocConsoleRequest->CurDir);
1311
1312 AllocConsoleRequest->AppNameLength = AppNameLength;
1313 CsrCaptureMessageBuffer(CaptureBuffer,
1314 AppName,
1315 AppNameLength,
1316 (PVOID*)&AllocConsoleRequest->AppName);
1317
1319 CaptureBuffer,
1321 sizeof(*AllocConsoleRequest));
1322 if (!NT_SUCCESS(ApiMessage.Status))
1323 {
1324 BaseSetLastNTError(ApiMessage.Status);
1325 Success = FALSE;
1326 goto Quit;
1327 }
1328
1329 // Is AllocConsoleRequest->ConsoleStartInfo->InitEvents aligned on handle boundary ????
1331 AllocConsoleRequest->ConsoleStartInfo->InitEvents,
1332 WaitAny, FALSE, NULL);
1333 if (!NT_SUCCESS(Status))
1334 {
1336 Success = FALSE;
1337 goto Quit;
1338 }
1339
1340 NtClose(AllocConsoleRequest->ConsoleStartInfo->InitEvents[INIT_SUCCESS]);
1341 NtClose(AllocConsoleRequest->ConsoleStartInfo->InitEvents[INIT_FAILURE]);
1342 if (Status != INIT_SUCCESS)
1343 {
1344 NtCurrentPeb()->ProcessParameters->ConsoleHandle = NULL;
1345 Success = FALSE;
1346 }
1347 else
1348 {
1349 RtlCopyMemory(ConsoleStartInfo,
1350 AllocConsoleRequest->ConsoleStartInfo,
1351 sizeof(CONSOLE_START_INFO));
1352 Success = TRUE;
1353 }
1354
1355Quit:
1356 if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
1357 return Success;
1358}
@ 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 2603 of file console.c.

2607{
2608 BOOL Success = TRUE;
2610
2611 CONSOLE_API_MESSAGE ApiMessage;
2612 PCONSOLE_ATTACHCONSOLE AttachConsoleRequest = &ApiMessage.Data.AttachConsoleRequest;
2613 PCSR_CAPTURE_BUFFER CaptureBuffer;
2614
2615 AttachConsoleRequest->ProcessId = ProcessId;
2616 AttachConsoleRequest->CtrlRoutine = CtrlRoutine;
2617 AttachConsoleRequest->PropRoutine = PropRoutine;
2618
2619 CaptureBuffer = CsrAllocateCaptureBuffer(1, sizeof(CONSOLE_START_INFO));
2620 if (CaptureBuffer == NULL)
2621 {
2623 Success = FALSE;
2624 goto Quit;
2625 }
2626
2627 CsrCaptureMessageBuffer(CaptureBuffer,
2628 ConsoleStartInfo,
2629 sizeof(CONSOLE_START_INFO),
2630 (PVOID*)&AttachConsoleRequest->ConsoleStartInfo);
2631
2633 CaptureBuffer,
2635 sizeof(*AttachConsoleRequest));
2636 if (!NT_SUCCESS(ApiMessage.Status))
2637 {
2638 BaseSetLastNTError(ApiMessage.Status);
2639 Success = FALSE;
2640 goto Quit;
2641 }
2642
2643 // Is AttachConsoleRequest->ConsoleStartInfo->InitEvents aligned on handle boundary ????
2645 AttachConsoleRequest->ConsoleStartInfo->InitEvents,
2646 WaitAny, FALSE, NULL);
2647 if (!NT_SUCCESS(Status))
2648 {
2650 Success = FALSE;
2651 goto Quit;
2652 }
2653
2654 NtClose(AttachConsoleRequest->ConsoleStartInfo->InitEvents[INIT_SUCCESS]);
2655 NtClose(AttachConsoleRequest->ConsoleStartInfo->InitEvents[INIT_FAILURE]);
2656 if (Status != INIT_SUCCESS)
2657 {
2658 NtCurrentPeb()->ProcessParameters->ConsoleHandle = NULL;
2659 Success = FALSE;
2660 }
2661 else
2662 {
2663 RtlCopyMemory(ConsoleStartInfo,
2664 AttachConsoleRequest->ConsoleStartInfo,
2665 sizeof(CONSOLE_START_INFO));
2666 Success = TRUE;
2667 }
2668
2669Quit:
2670 if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
2671 return Success;
2672}
@ ConsolepAttach
Definition: conmsg.h:104
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2711
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 3210 of file console.c.

3212{
3213 CONSOLE_API_MESSAGE ApiMessage;
3214 PCONSOLE_GETKBDLAYOUTNAME GetKbdLayoutNameRequest = &ApiMessage.Data.GetKbdLayoutNameRequest;
3215
3216 /* Set up the data to send to the Console Server */
3217 GetKbdLayoutNameRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
3218 GetKbdLayoutNameRequest->Ansi = bAnsi;
3219
3220 /* Call the server */
3222 NULL,
3224 sizeof(*GetKbdLayoutNameRequest));
3225
3226 /* Check for success */
3227 if (!NT_SUCCESS(ApiMessage.Status))
3228 {
3229 BaseSetLastNTError(ApiMessage.Status);
3230 return FALSE;
3231 }
3232
3233 /* Retrieve the results */
3234 _SEH2_TRY
3235 {
3236 /* Copy only KL_NAMELENGTH == 9 characters, ANSI or UNICODE */
3237 if (bAnsi)
3238 strncpy(pszLayoutName, (PCHAR)GetKbdLayoutNameRequest->LayoutBuffer, KL_NAMELENGTH);
3239 else
3240 wcsncpy(pszLayoutName, (PWCHAR)GetKbdLayoutNameRequest->LayoutBuffer, KL_NAMELENGTH);
3241 }
3243 {
3245 _SEH2_YIELD(return FALSE);
3246 }
3247 _SEH2_END;
3248
3249 return TRUE;
3250}
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
@ ConsolepGetKeyboardLayoutName
Definition: conmsg.h:90
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:162
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
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 2163 of file console.c.

2164{
2165 CONSOLE_API_MESSAGE ApiMessage;
2166 PCONSOLE_GETSETCONSOLETITLE TitleRequest = &ApiMessage.Data.TitleRequest;
2167 PCSR_CAPTURE_BUFFER CaptureBuffer;
2168
2169 if (dwNumChars == 0) return 0;
2170
2171 TitleRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2172 TitleRequest->Length = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
2173 TitleRequest->Unicode = bUnicode;
2174
2175 CaptureBuffer = CsrAllocateCaptureBuffer(1, TitleRequest->Length);
2176 if (CaptureBuffer == NULL)
2177 {
2178 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
2180 return 0;
2181 }
2182
2183 CsrAllocateMessagePointer(CaptureBuffer,
2184 TitleRequest->Length,
2185 (PVOID*)&TitleRequest->Title);
2186
2188 CaptureBuffer,
2190 sizeof(*TitleRequest));
2191 if (!NT_SUCCESS(ApiMessage.Status))
2192 {
2193 CsrFreeCaptureBuffer(CaptureBuffer);
2194 BaseSetLastNTError(ApiMessage.Status);
2195 return 0;
2196 }
2197
2198 dwNumChars = TitleRequest->Length / (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
2199
2200 if (dwNumChars > 0)
2201 {
2202 RtlCopyMemory(lpConsoleTitle, TitleRequest->Title, TitleRequest->Length);
2203
2204 if (bUnicode)
2205 ((LPWSTR)lpConsoleTitle)[dwNumChars] = UNICODE_NULL;
2206 else
2207 ((LPSTR)lpConsoleTitle)[dwNumChars] = ANSI_NULL;
2208 }
2209
2210 CsrFreeCaptureBuffer(CaptureBuffer);
2211
2212 return dwNumChars;
2213}
@ 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 3034 of file console.c.

3040{
3041 CONSOLE_API_MESSAGE ApiMessage;
3043 PCSR_CAPTURE_BUFFER CaptureBuffer;
3044
3045 if (!cbDesktop || !pDesktop)
3046 {
3047 pDesktop = NtCurrentPeb()->ProcessParameters->DesktopInfo.Buffer;
3048 cbDesktop = NtCurrentPeb()->ProcessParameters->DesktopInfo.Length;
3049 }
3050
3051 cbDesktop = min(cbDesktop, (MAX_PATH + 1) * sizeof(WCHAR));
3052
3053 RegisterConsoleIME->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
3054 RegisterConsoleIME->hWnd = hWnd;
3055 RegisterConsoleIME->dwThreadId = dwThreadId;
3056 RegisterConsoleIME->cbDesktop = cbDesktop;
3057
3058 CaptureBuffer = CsrAllocateCaptureBuffer(1, cbDesktop);
3059 if (!CaptureBuffer)
3060 {
3062 return FALSE;
3063 }
3064
3065 CsrCaptureMessageBuffer(CaptureBuffer,
3066 pDesktop,
3067 cbDesktop,
3068 (PVOID*)&RegisterConsoleIME->pDesktop);
3069
3071 CaptureBuffer,
3073 sizeof(*RegisterConsoleIME));
3074
3075 CsrFreeCaptureBuffer(CaptureBuffer);
3076
3077 if (!NT_SUCCESS(ApiMessage.Status))
3078 {
3079 BaseSetLastNTError(ApiMessage.Status);
3080 return FALSE;
3081 }
3082
3083 if (pdwAttachToThreadId)
3084 {
3085 _SEH2_TRY
3086 {
3087 *pdwAttachToThreadId = RegisterConsoleIME->dwAttachToThreadId;
3088 }
3090 {
3092 _SEH2_YIELD(return FALSE);
3093 }
3094 _SEH2_END;
3095 }
3096
3097 return TRUE;
3098}
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:3127
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 1881 of file console.c.

1887{
1888 CONSOLE_API_MESSAGE ApiMessage;
1889 PCONSOLE_SCROLLSCREENBUFFER ScrollScreenBufferRequest = &ApiMessage.Data.ScrollScreenBufferRequest;
1890
1891 ScrollScreenBufferRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1892 ScrollScreenBufferRequest->OutputHandle = hConsoleOutput;
1893 ScrollScreenBufferRequest->ScrollRectangle = *lpScrollRectangle;
1894
1895 if (lpClipRectangle != NULL)
1896 {
1897 ScrollScreenBufferRequest->UseClipRectangle = TRUE;
1898 ScrollScreenBufferRequest->ClipRectangle = *lpClipRectangle;
1899 }
1900 else
1901 {
1902 ScrollScreenBufferRequest->UseClipRectangle = FALSE;
1903 }
1904
1905 ScrollScreenBufferRequest->DestinationOrigin = dwDestinationOrigin;
1906 ScrollScreenBufferRequest->Fill = *lpFill;
1907 ScrollScreenBufferRequest->Unicode = bUnicode;
1908
1910 NULL,
1912 sizeof(*ScrollScreenBufferRequest));
1913 if (!NT_SUCCESS(ApiMessage.Status))
1914 {
1915 BaseSetLastNTError(ApiMessage.Status);
1916 return FALSE;
1917 }
1918
1919 return TRUE;
1920}
@ 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 2243 of file console.c.

2244{
2245 CONSOLE_API_MESSAGE ApiMessage;
2246 PCONSOLE_GETSETCONSOLETITLE TitleRequest = &ApiMessage.Data.TitleRequest;
2247 PCSR_CAPTURE_BUFFER CaptureBuffer;
2248
2249 ULONG NumChars = (ULONG)(lpConsoleTitle ? (bUnicode ? wcslen(lpConsoleTitle) : strlen(lpConsoleTitle)) : 0);
2250
2251 TitleRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2252 TitleRequest->Length = NumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
2253 TitleRequest->Unicode = bUnicode;
2254
2255 CaptureBuffer = CsrAllocateCaptureBuffer(1, TitleRequest->Length);
2256 if (CaptureBuffer == NULL)
2257 {
2258 DPRINT1("CsrAllocateCaptureBuffer failed!\n");
2260 return FALSE;
2261 }
2262
2263 CsrCaptureMessageBuffer(CaptureBuffer,
2264 (PVOID)lpConsoleTitle,
2265 TitleRequest->Length,
2266 (PVOID*)&TitleRequest->Title);
2267
2269 CaptureBuffer,
2271 sizeof(*TitleRequest));
2272
2273 CsrFreeCaptureBuffer(CaptureBuffer);
2274
2275 if (!NT_SUCCESS(ApiMessage.Status))
2276 {
2277 BaseSetLastNTError(ApiMessage.Status);
2278 return FALSE;
2279 }
2280
2281 return TRUE;
2282}
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 3101 of file console.c.

3103{
3104 CONSOLE_API_MESSAGE ApiMessage;
3106
3107 UnregisterConsoleIME->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
3108 UnregisterConsoleIME->dwThreadId = dwThreadId;
3109
3111 NULL,
3113 sizeof(*UnregisterConsoleIME));
3114 if (!NT_SUCCESS(ApiMessage.Status))
3115 {
3116 BaseSetLastNTError(ApiMessage.Status);
3117 return FALSE;
3118 }
3119
3120 return TRUE;
3121}
@ ConsolepUnregisterConsoleIME
Definition: conmsg.h:101
BOOL WINAPI DECLSPEC_HOTPATCH UnregisterConsoleIME(VOID)
Definition: console.c:3160
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 3127 of file console.c.

3130{
3133 0,
3134 NULL,
3135 pdwAttachToThreadId);
3136}
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:3034
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459

Referenced by IntRegisterConsoleIME().

◆ RegisterConsoleOS2()

BOOL WINAPI DECLSPEC_HOTPATCH RegisterConsoleOS2 ( BOOL  bUnknown)

Definition at line 3141 of file console.c.

3142{
3143 STUB;
3144 return FALSE;
3145}

◆ RemoveConsoleCtrlHandler()

static BOOL RemoveConsoleCtrlHandler ( PHANDLER_ROUTINE  HandlerRoutine)
static

Definition at line 2072 of file console.c.

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

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 1929 of file console.c.

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

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 1950 of file console.c.

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

◆ SetConsoleActiveScreenBuffer()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleActiveScreenBuffer ( HANDLE  hConsoleOutput)

Definition at line 1799 of file console.c.

1800{
1801 CONSOLE_API_MESSAGE ApiMessage;
1802 PCONSOLE_SETACTIVESCREENBUFFER SetScreenBufferRequest = &ApiMessage.Data.SetScreenBufferRequest;
1803
1804 SetScreenBufferRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1805 SetScreenBufferRequest->OutputHandle = hConsoleOutput;
1806
1808 NULL,
1810 sizeof(*SetScreenBufferRequest));
1811 if (!NT_SUCCESS(ApiMessage.Status))
1812 {
1813 BaseSetLastNTError(ApiMessage.Status);
1814 return FALSE;
1815 }
1816
1817 return TRUE;
1818}
@ 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 2420 of file console.c.

2421{
2422 CONSOLE_API_MESSAGE ApiMessage;
2423 PCONSOLE_SETINPUTOUTPUTCP SetConsoleCPRequest = &ApiMessage.Data.SetConsoleCPRequest;
2424
2425 /* Set the Input Code Page */
2426 SetConsoleCPRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2427 SetConsoleCPRequest->CodePage = wCodePageID;
2428 SetConsoleCPRequest->OutputCP = FALSE;
2429 /* SetConsoleCPRequest->EventHandle; */
2430
2432 NULL,
2434 sizeof(*SetConsoleCPRequest));
2435 if (!NT_SUCCESS(ApiMessage.Status))
2436 {
2437 BaseSetLastNTError(ApiMessage.Status);
2438 return FALSE;
2439 }
2440
2441 return TRUE;
2442}
@ 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 2109 of file console.c.

2111{
2112 BOOL Ret;
2113
2115
2116 if (Add)
2118 else
2120
2122 return Ret;
2123}
static BOOL AddConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine)
Definition: console.c:2034
static BOOL RemoveConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine)
Definition: console.c:2072

Referenced by AddBreakHandler(), Telnet::Close(), CmdDebugService(), ConsoleInit(), CtrlCIntercept(), InputWait(), InteractiveConsole(), kickoff_telnetd(), main(), msvcrt_free_signals(), msvcrt_init_signals(), Telnet::Open(), PagePrompt(), RemoveBreakHandler(), Setup(), 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 1742 of file console.c.

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

◆ SetConsoleCursorMode()

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

Definition at line 3000 of file console.c.

3001{
3002 STUB;
3003 return FALSE;
3004}

◆ SetConsoleCursorPosition()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleCursorPosition ( HANDLE  hConsoleOutput,
COORD  dwCursorPosition 
)

Definition at line 1540 of file console.c.

1542{
1543 CONSOLE_API_MESSAGE ApiMessage;
1544 PCONSOLE_SETCURSORPOSITION SetCursorPositionRequest = &ApiMessage.Data.SetCursorPositionRequest;
1545
1546 SetCursorPositionRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1547 SetCursorPositionRequest->OutputHandle = hConsoleOutput;
1548 SetCursorPositionRequest->Position = dwCursorPosition;
1549
1551 NULL,
1553 sizeof(*SetCursorPositionRequest));
1554 if (!NT_SUCCESS(ApiMessage.Status))
1555 {
1556 BaseSetLastNTError(ApiMessage.Status);
1557 return FALSE;
1558 }
1559
1560 return TRUE;
1561}
@ 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 2756 of file console.c.

2757{
2758 CONSOLE_API_MESSAGE ApiMessage;
2759 PCONSOLE_SETICON SetIconRequest = &ApiMessage.Data.SetIconRequest;
2760
2761 SetIconRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2762 SetIconRequest->IconHandle = hIcon;
2763
2765 NULL,
2767 sizeof(*SetIconRequest));
2768 if (!NT_SUCCESS(ApiMessage.Status))
2769 {
2770 BaseSetLastNTError(ApiMessage.Status);
2771 return FALSE;
2772 }
2773
2774 return TRUE;
2775}
@ 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 2829 of file console.c.

2830{
2832#ifdef USE_TEB_STATIC_USTR
2833 PUNICODE_STRING ExeNameU;
2834#else
2835 UNICODE_STRING ExeNameU;
2836#endif
2837 ANSI_STRING ExeNameA;
2838#ifndef USE_TEB_STATIC_USTR
2840#endif
2841
2842#ifdef USE_TEB_STATIC_USTR
2843 /*
2844 * Use the TEB static UNICODE string for storage. It is already
2845 * initialized at process creation time by the Memory Manager.
2846 */
2847 ExeNameU = &NtCurrentTeb()->StaticUnicodeString;
2848#endif
2849
2850 /* Initialize string for conversion */
2851 RtlInitAnsiString(&ExeNameA, lpExeName);
2852
2853#if 1
2854 if ((ExeNameA.Length == 0) || (ExeNameA.Length >= EXENAME_LENGTH))
2855 {
2856 /* Fail if string is empty or too long */
2858 return FALSE;
2859 }
2860#endif
2861#ifndef USE_TEB_STATIC_USTR
2862 ExeNameU.Length = 0;
2863 ExeNameU.MaximumLength = (USHORT)sizeof(Buffer);
2864 ExeNameU.Buffer = Buffer;
2865#endif
2866
2867#ifdef USE_TEB_STATIC_USTR
2868 Status = RtlAnsiStringToUnicodeString(ExeNameU, &ExeNameA, FALSE);
2869#else
2870 Status = RtlAnsiStringToUnicodeString(&ExeNameU, &ExeNameA, FALSE);
2871#endif
2872 if (!NT_SUCCESS(Status))
2873 {
2874 /* Fail if string is empty or too long */
2877 else
2879
2880 return FALSE;
2881 }
2882
2883#ifdef USE_TEB_STATIC_USTR
2884 return SetConsoleInputExeNameW(ExeNameU->Buffer);
2885#else
2886 return SetConsoleInputExeNameW(ExeNameU.Buffer);
2887#endif
2888}
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleInputExeNameW(IN LPCWSTR lpExeName)
Definition: console.c:2789
#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 2789 of file console.c.

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

Referenced by SetConsoleInputExeNameA().

◆ SetConsoleKeyShortcuts()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleKeyShortcuts ( DWORD  Unknown0,
DWORD  Unknown1,
DWORD  Unknown2,
DWORD  Unknown3 
)

Definition at line 978 of file console.c.

982{
983 DPRINT1("SetConsoleKeyShortcuts(0x%x, 0x%x, 0x%x, 0x%x) UNIMPLEMENTED!\n", Unknown0, Unknown1, Unknown2, Unknown3);
985 return FALSE;
986}
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES IN DWORD Unknown3
Definition: conport.c:37
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102

◆ SetConsoleLocalEUDC()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleLocalEUDC ( DWORD  Unknown1,
DWORD  Unknown2,
DWORD  Unknown3,
DWORD  Unknown4 
)

Definition at line 3027 of file console.c.

3028{
3029 STUB;
3030 return FALSE;
3031}

◆ SetConsoleMaximumWindowSize()

BOOL WINAPI SetConsoleMaximumWindowSize ( HANDLE  hConsoleOutput,
COORD  dwMaximumSize 
)

Definition at line 996 of file console.c.

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

◆ SetConsoleMenuClose()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleMenuClose ( BOOL  bEnable)

Definition at line 1011 of file console.c.

1012{
1013 CONSOLE_API_MESSAGE ApiMessage;
1014 PCONSOLE_SETMENUCLOSE SetMenuCloseRequest = &ApiMessage.Data.SetMenuCloseRequest;
1015
1016 SetMenuCloseRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1017 SetMenuCloseRequest->Enable = bEnable;
1018
1020 NULL,
1022 sizeof(*SetMenuCloseRequest));
1023 if (!NT_SUCCESS(ApiMessage.Status))
1024 {
1025 BaseSetLastNTError(ApiMessage.Status);
1026 return FALSE;
1027 }
1028
1029 return TRUE;
1030}
@ 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 1606 of file console.c.

1608{
1609 CONSOLE_API_MESSAGE ApiMessage;
1610 PCONSOLE_GETSETCONSOLEMODE ConsoleModeRequest = &ApiMessage.Data.ConsoleModeRequest;
1611
1612 ConsoleModeRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1613 ConsoleModeRequest->Handle = hConsoleHandle;
1614 ConsoleModeRequest->Mode = dwMode;
1615
1617 NULL,
1619 sizeof(*ConsoleModeRequest));
1620 if (!NT_SUCCESS(ApiMessage.Status))
1621 {
1622 BaseSetLastNTError(ApiMessage.Status);
1623 return FALSE;
1624 }
1625
1626 return TRUE;
1627}
@ 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 3018 of file console.c.

3019{
3020 STUB;
3021 return FALSE;
3022}

◆ SetConsoleOS2OemFormat()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleOS2OemFormat ( BOOL  bUnknown)

Definition at line 3150 of file console.c.

3151{
3152 STUB;
3153 return FALSE;
3154}

◆ SetConsoleOutputCP()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleOutputCP ( UINT  wCodePageID)

Definition at line 2480 of file console.c.

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

◆ SetConsolePalette()

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

Definition at line 1041 of file console.c.

1044{
1045 CONSOLE_API_MESSAGE ApiMessage;
1046 PCONSOLE_SETPALETTE SetPaletteRequest = &ApiMessage.Data.SetPaletteRequest;
1047
1048 SetPaletteRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1049 SetPaletteRequest->OutputHandle = hConsoleOutput;
1050 SetPaletteRequest->PaletteHandle = hPalette;
1051 SetPaletteRequest->Usage = dwUsage;
1052
1054 NULL,
1056 sizeof(*SetPaletteRequest));
1057 if (!NT_SUCCESS(ApiMessage.Status))
1058 {
1059 BaseSetLastNTError(ApiMessage.Status);
1060 return FALSE;
1061 }
1062
1063 return TRUE;
1064}
@ 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 1855 of file console.c.

1857{
1858 CONSOLE_API_MESSAGE ApiMessage;
1859 PCONSOLE_SETSCREENBUFFERSIZE SetScreenBufferSizeRequest = &ApiMessage.Data.SetScreenBufferSizeRequest;
1860
1861 SetScreenBufferSizeRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1862 SetScreenBufferSizeRequest->OutputHandle = hConsoleOutput;
1863 SetScreenBufferSizeRequest->Size = dwSize;
1864
1866 NULL,
1868 sizeof(*SetScreenBufferSizeRequest));
1869 if (!NT_SUCCESS(ApiMessage.Status))
1870 {
1871 BaseSetLastNTError(ApiMessage.Status);
1872 return FALSE;
1873 }
1874
1875 return TRUE;
1876}
@ 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 2008 of file console.c.

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

◆ SetConsoleTitleA()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleTitleA ( LPCSTR  lpConsoleTitle)

Definition at line 2302 of file console.c.

2303{
2304 return IntSetConsoleTitle(lpConsoleTitle, FALSE);
2305}
static BOOL IntSetConsoleTitle(CONST VOID *lpConsoleTitle, BOOLEAN bUnicode)
Definition: console.c:2243

Referenced by CmdStartProcess().

◆ SetConsoleTitleW()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleTitleW ( LPCWSTR  lpConsoleTitle)

Definition at line 2290 of file console.c.

2291{
2292 return IntSetConsoleTitle(lpConsoleTitle, TRUE);
2293}

Referenced by wmain().

◆ SetConsoleWindowInfo()

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

Definition at line 1970 of file console.c.

1973{
1974 CONSOLE_API_MESSAGE ApiMessage;
1975 PCONSOLE_SETWINDOWINFO SetWindowInfoRequest = &ApiMessage.Data.SetWindowInfoRequest;
1976
1977 if (lpConsoleWindow == NULL)
1978 {
1980 return FALSE;
1981 }
1982
1983 SetWindowInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1984 SetWindowInfoRequest->OutputHandle = hConsoleOutput;
1985 SetWindowInfoRequest->Absolute = bAbsolute;
1986 SetWindowInfoRequest->WindowRect = *lpConsoleWindow;
1987
1989 NULL,
1991 sizeof(*SetWindowInfoRequest));
1992 if (!NT_SUCCESS(ApiMessage.Status))
1993 {
1994 BaseSetLastNTError(ApiMessage.Status);
1995 return FALSE;
1996 }
1997
1998 return TRUE;
1999}
@ 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 3279 of file console.c.

3280{
3281 CONSOLE_API_MESSAGE ApiMessage;
3282 PCONSOLE_NOTIFYLASTCLOSE NotifyLastCloseRequest = &ApiMessage.Data.NotifyLastCloseRequest;
3283
3284 /* Set the flag used by the console control dispatcher */
3286
3287 /* Set up the input arguments */
3288 NotifyLastCloseRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
3289
3290 /* Call CSRSS; just return the NTSTATUS cast to DWORD */
3291 return CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
3292 NULL,
3294 sizeof(*NotifyLastCloseRequest));
3295}
@ 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 1213 of file console.c.

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

Referenced by 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 3171 of file console.c.

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

1075{
1076 CONSOLE_API_MESSAGE ApiMessage;
1077 PCONSOLE_SHOWCURSOR ShowCursorRequest = &ApiMessage.Data.ShowCursorRequest;
1078
1079 ShowCursorRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1080 ShowCursorRequest->OutputHandle = hConsoleOutput;
1081 ShowCursorRequest->Show = bShow;
1082 ShowCursorRequest->RefCount = 0;
1083
1085 NULL,
1087 sizeof(*ShowCursorRequest));
1088
1089 return ShowCursorRequest->RefCount;
1090}
@ 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 3160 of file console.c.

3161{
3163}
static BOOL IntUnregisterConsoleIME(_In_ DWORD dwThreadId)
Definition: console.c:3101

Referenced by IntUnregisterConsoleIME().

◆ VerifyConsoleIoHandle()

BOOL WINAPI DECLSPEC_HOTPATCH VerifyConsoleIoHandle ( HANDLE  hIoHandle)

Definition at line 1110 of file console.c.

1111{
1112 CONSOLE_API_MESSAGE ApiMessage;
1113 PCONSOLE_VERIFYHANDLE VerifyHandleRequest = &ApiMessage.Data.VerifyHandleRequest;
1114
1115 VerifyHandleRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1116 VerifyHandleRequest->Handle = hIoHandle;
1117 VerifyHandleRequest->IsValid = FALSE;
1118
1119 /* If the process is not attached to a console, return invalid handle */
1120 if (VerifyHandleRequest->ConsoleHandle == NULL) return FALSE;
1121
1123 NULL,
1125 sizeof(*VerifyHandleRequest));
1126 if (!NT_SUCCESS(ApiMessage.Status))
1127 {
1128 BaseSetLastNTError(ApiMessage.Status);
1129 return FALSE;
1130 }
1131
1132 return VerifyHandleRequest->IsValid;
1133}
@ 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().