ReactOS  0.4.13-dev-79-gcd489d8
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)
 
BOOL WINAPI DECLSPEC_HOTPATCH RegisterConsoleIME (HWND hWnd, LPDWORD ThreadId)
 
BOOL WINAPI DECLSPEC_HOTPATCH RegisterConsoleOS2 (BOOL bUnknown)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleOS2OemFormat (BOOL bUnknown)
 
BOOL WINAPI DECLSPEC_HOTPATCH UnregisterConsoleIME (VOID)
 
static BOOL IntGetConsoleKeyboardLayoutName (OUT PVOID pszLayoutName, IN BOOL bAnsi)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetConsoleKeyboardLayoutNameA (OUT LPSTR pszLayoutName)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetConsoleKeyboardLayoutNameW (OUT LPWSTR pszLayoutName)
 
DWORD WINAPI SetLastConsoleEventActive (VOID)
 

Variables

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

Macro Definition Documentation

◆ EXENAME_LENGTH

#define EXENAME_LENGTH   (255 + 1)

Definition at line 40 of file console.c.

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file console.c.

Function Documentation

◆ AddConsoleCtrlHandler()

static BOOL AddConsoleCtrlHandler ( PHANDLER_ROUTINE  HandlerRoutine)
static

Definition at line 2036 of file console.c.

2037 {
2038  PHANDLER_ROUTINE* NewCtrlHandlers = NULL;
2039 
2040  if (HandlerRoutine == NULL)
2041  {
2042  NtCurrentPeb()->ProcessParameters->ConsoleFlags = TRUE;
2043  return TRUE;
2044  }
2045 
2047  {
2048  NewCtrlHandlers = RtlAllocateHeap(RtlGetProcessHeap(),
2049  0,
2050  (NrCtrlHandlers + 4) * sizeof(PHANDLER_ROUTINE));
2051  if (NewCtrlHandlers == NULL)
2052  {
2054  return FALSE;
2055  }
2056 
2057  memmove(NewCtrlHandlers, CtrlHandlers, sizeof(PHANDLER_ROUTINE) * NrCtrlHandlers);
2058 
2059  if (NrAllocatedHandlers > 1) RtlFreeHeap(RtlGetProcessHeap(), 0, CtrlHandlers);
2060 
2061  CtrlHandlers = NewCtrlHandlers;
2062  NrAllocatedHandlers += 4;
2063  }
2064 
2066 
2068  return TRUE;
2069 }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define TRUE
Definition: types.h:120
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
static ULONG NrAllocatedHandlers
Definition: console.c:32
smooth NULL
Definition: ftsmooth.c:416
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
#define SetLastError(x)
Definition: compat.h:409
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define NtCurrentPeb()
Definition: FLS.c:19
BOOL WINAPI HandlerRoutine(DWORD dwCtrlType)
static ULONG NrCtrlHandlers
Definition: console.c:31
BOOL(CALLBACK * PHANDLER_ROUTINE)(_In_ DWORD)
Definition: wincon.h:222
static PHANDLER_ROUTINE * CtrlHandlers
Definition: console.c:30

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;
1369  PWCHAR Desktop;
1370  PWCHAR AppName;
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 
1378  LCID lcid;
1379 
1381 
1382  if (NtCurrentPeb()->ProcessParameters->ConsoleHandle)
1383  {
1384  DPRINT1("AllocConsole: Allocating a console to a process already having one\n");
1386  Success = FALSE;
1387  goto Quit;
1388  }
1389 
1390  /* Set up the console properties */
1392  &TitleLength,
1393  &ConsoleTitle,
1394  &DesktopLength,
1395  &Desktop,
1396  &ConsoleStartInfo);
1397  DPRINT("ConsoleTitle = '%S' - Desktop = '%S'\n",
1398  ConsoleTitle, Desktop);
1399 
1400  /* Initialize the Input EXE name */
1401  InitExeName();
1403  &CurDirLength,
1404  &CurDir,
1405  &AppNameLength,
1406  &AppName);
1407  DPRINT("CurDir = '%S' - AppName = '%S'\n",
1408  CurDir, AppName);
1409 
1410  Success = IntAllocConsole(ConsoleTitle,
1411  TitleLength,
1412  Desktop,
1413  DesktopLength,
1414  CurDir,
1415  CurDirLength,
1416  AppName,
1417  AppNameLength,
1420  &ConsoleStartInfo);
1421  if (Success)
1422  {
1423  /* Set up the handles */
1424  SetUpHandles(&ConsoleStartInfo);
1425  InputWaitHandle = ConsoleStartInfo.InputWaitHandle;
1426 
1427  /* Initialize Console Ctrl Handling */
1429 
1430  /* Sets the current console locale for this thread */
1431  SetTEBLangID(lcid);
1432  }
1433 
1434 Quit:
1436  return Success;
1437 }
static CHAR AppName[MAX_PATH]
Definition: dem.c:252
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
VOID InitializeCtrlHandling(VOID)
Definition: console.c:204
DWORD LCID
Definition: nls.h:13
uint16_t * PWCHAR
Definition: typedefs.h:54
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
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
unsigned int BOOL
Definition: ntddk_ex.h:94
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
VOID InitExeName(VOID)
Definition: console.c:216
VOID SetUpHandles(IN PCONSOLE_START_INFO ConsoleStartInfo)
Definition: init.c:250
void DPRINT(...)
Definition: polytest.cpp:61
static CHAR Desktop[MAX_PATH]
Definition: dem.c:256
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
#define SetTEBLangID(p)
Definition: console.h:63
DWORD WINAPI PropDialogHandler(IN LPVOID lpThreadParameter)
Definition: init.c:34
HANDLE InputWaitHandle
Definition: console.c:38
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
#define SetLastError(x)
Definition: compat.h:409
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
RTL_CRITICAL_SECTION ConsoleLock
Definition: init.c:24
#define NtCurrentPeb()
Definition: FLS.c:19
HANDLE InputWaitHandle
Definition: conmsg.h:171
#define DPRINT1
Definition: precomp.h:8
DWORD WINAPI ConsoleControlDispatcher(IN LPVOID lpThreadParameter)
Definition: console.c:89
unsigned int ULONG
Definition: retypes.h:1

◆ AttachConsole()

BOOL WINAPI AttachConsole ( DWORD  dwProcessId)

Definition at line 2675 of file console.c.

2676 {
2677  BOOL Success;
2678  CONSOLE_START_INFO ConsoleStartInfo;
2679 
2680  DWORD dummy;
2681  LCID lcid;
2682 
2684 
2685  if (NtCurrentPeb()->ProcessParameters->ConsoleHandle)
2686  {
2687  DPRINT1("AttachConsole: Attaching a console to a process already having one\n");
2689  Success = FALSE;
2690  goto Quit;
2691  }
2692 
2693  /* Set up the console properties */
2695  &dummy,
2696  NULL,
2697  &dummy,
2698  NULL,
2699  &ConsoleStartInfo);
2700 
2701  Success = IntAttachConsole(dwProcessId,
2704  &ConsoleStartInfo);
2705  if (Success)
2706  {
2707  /* Set up the handles */
2708  SetUpHandles(&ConsoleStartInfo);
2709  InputWaitHandle = ConsoleStartInfo.InputWaitHandle;
2710 
2711  /* Initialize Console Ctrl Handling */
2713 
2714  /* Sets the current console locale for this thread */
2715  SetTEBLangID(lcid);
2716  }
2717 
2718 Quit:
2720  return Success;
2721 }
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
VOID InitializeCtrlHandling(VOID)
Definition: console.c:204
DWORD LCID
Definition: nls.h:13
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
unsigned int BOOL
Definition: ntddk_ex.h:94
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
static BOOL IntAttachConsole(DWORD ProcessId, LPTHREAD_START_ROUTINE CtrlRoutine, LPTHREAD_START_ROUTINE PropRoutine, PCONSOLE_START_INFO ConsoleStartInfo)
Definition: console.c:2602
smooth NULL
Definition: ftsmooth.c:416
VOID SetUpHandles(IN PCONSOLE_START_INFO ConsoleStartInfo)
Definition: init.c:250
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
#define SetTEBLangID(p)
Definition: console.h:63
DWORD WINAPI PropDialogHandler(IN LPVOID lpThreadParameter)
Definition: init.c:34
HANDLE InputWaitHandle
Definition: console.c:38
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
RTL_CRITICAL_SECTION ConsoleLock
Definition: init.c:24
#define NtCurrentPeb()
Definition: FLS.c:19
unsigned char dummy
Definition: maze.c:118
HANDLE InputWaitHandle
Definition: conmsg.h:171
#define DPRINT1
Definition: precomp.h:8
DWORD WINAPI ConsoleControlDispatcher(IN LPVOID lpThreadParameter)
Definition: console.c:89

◆ 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 }
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
NTSTATUS Status
Definition: csrmsg.h:112
HANDLE ConsoleHandle
Definition: conmsg.h:626
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define NtCurrentPeb()
Definition: FLS.c:19
CONSOLE_CLOSEHANDLE CloseHandleRequest
Definition: conmsg.h:913
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

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 
114  _SEH2_TRY
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:
141  case CTRL_LOGOFF_EVENT:
142  case CTRL_SHUTDOWN_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  */
152  if (!LastCloseNotify) ExitThread(0);
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:
187  case CTRL_LOGOFF_EVENT:
188  case CTRL_SHUTDOWN_EVENT:
189  nExitCode = CodeAndFlag;
190  break;
191  }
192  break;
193  }
194  }
195  }
196 
198 
199  ExitThread(nExitCode);
200  return STATUS_SUCCESS;
201 }
BOOL WINAPI IsDebuggerPresent(VOID)
Definition: debugger.c:615
#define CTRL_BREAK_EVENT
Definition: wincon.h:66
#define MAXLONG
Definition: umtypes.h:116
#define CTRL_CLOSE_EVENT
Definition: wincon.h:67
#define CTRL_C_EVENT
Definition: wincon.h:65
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
VOID WINAPI ExitProcess(IN UINT uExitCode)
Definition: proc.c:1517
NTSYSAPI VOID NTAPI RtlRaiseException(_In_ PEXCEPTION_RECORD ExceptionRecord)
PVOID ExceptionAddress
Definition: compat.h:199
_SEH2_TRY
Definition: create.c:4250
DWORD ExceptionCode
Definition: compat.h:196
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
HANDLE WINAPI GetCurrentThread(VOID)
Definition: proc.c:1178
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
BOOLEAN ConsoleInitialized
Definition: init.c:25
#define THREAD_PRIORITY_HIGHEST
Definition: winbase.h:274
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define DBG_CONTROL_BREAK
Definition: ntstatus.h:55
void DPRINT(...)
Definition: polytest.cpp:61
VOID WINAPI ExitThread(IN DWORD uExitCode)
Definition: thread.c:327
#define PtrToUlong(u)
Definition: config.h:107
BOOL WINAPI SetThreadPriority(IN HANDLE hThread, IN int nPriority)
Definition: thread.c:662
static BOOL WINAPI DefaultConsoleCtrlHandler(DWORD Event)
Definition: console.c:53
static BOOLEAN LastCloseNotify
Definition: console.c:33
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DBG_CONTROL_C
Definition: ntstatus.h:52
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define CTRL_LOGOFF_EVENT
Definition: wincon.h:69
#define MINLONG
Definition: umtypes.h:115
struct _EXCEPTION_RECORD * ExceptionRecord
Definition: compat.h:198
_SEH2_END
Definition: create.c:4424
#define CTRL_SHUTDOWN_EVENT
Definition: wincon.h:70
RTL_CRITICAL_SECTION ConsoleLock
Definition: init.c:24
#define NtCurrentPeb()
Definition: FLS.c:19
unsigned int UINT
Definition: ndis.h:50
#define CTRL_LAST_CLOSE_EVENT
Definition: wincon.h:68
#define DPRINT1
Definition: precomp.h:8
static ULONG NrCtrlHandlers
Definition: console.c:31
DWORD ExceptionFlags
Definition: compat.h:197
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
DWORD NumberParameters
Definition: compat.h:200
return STATUS_SUCCESS
Definition: btrfs.c:2725
static PHANDLER_ROUTINE * CtrlHandlers
Definition: console.c:30
#define CONTROL_C_EXIT
Definition: winbase.h:330

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 }
CONSOLE_MENUCONTROL MenuControlRequest
Definition: conmsg.h:954
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
HANDLE OutputHandle
Definition: conmsg.h:693
HANDLE ConsoleHandle
Definition: conmsg.h:692
smooth NULL
Definition: ftsmooth.c:416
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
#define NtCurrentPeb()
Definition: FLS.c:19
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

Referenced by CreateVdmMenu().

◆ CreateConsoleScreenBuffer()

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

Definition at line 2315 of file console.c.

2320 {
2321  CONSOLE_API_MESSAGE ApiMessage;
2322  PCONSOLE_CREATESCREENBUFFER CreateScreenBufferRequest = &ApiMessage.Data.CreateScreenBufferRequest;
2323  PCSR_CAPTURE_BUFFER CaptureBuffer = NULL;
2324  PCONSOLE_GRAPHICS_BUFFER_INFO GraphicsBufferInfo = lpScreenBufferData;
2325 
2326  if ( (dwDesiredAccess & ~(GENERIC_READ | GENERIC_WRITE)) ||
2327  (dwShareMode & ~(FILE_SHARE_READ | FILE_SHARE_WRITE)) ||
2329  {
2331  return INVALID_HANDLE_VALUE;
2332  }
2333 
2334  CreateScreenBufferRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2335  CreateScreenBufferRequest->DesiredAccess = dwDesiredAccess;
2336  CreateScreenBufferRequest->InheritHandle =
2337  (lpSecurityAttributes ? lpSecurityAttributes->bInheritHandle : FALSE);
2338  CreateScreenBufferRequest->ShareMode = dwShareMode;
2339  CreateScreenBufferRequest->ScreenBufferType = dwFlags;
2340 
2342  {
2343  if (CreateScreenBufferRequest->InheritHandle || GraphicsBufferInfo == NULL)
2344  {
2346  return INVALID_HANDLE_VALUE;
2347  }
2348 
2349  CreateScreenBufferRequest->GraphicsBufferInfo = *GraphicsBufferInfo;
2350 
2351  CaptureBuffer = CsrAllocateCaptureBuffer(1, GraphicsBufferInfo->dwBitMapInfoLength);
2352  if (CaptureBuffer == NULL)
2353  {
2355  return INVALID_HANDLE_VALUE;
2356  }
2357 
2358  CsrCaptureMessageBuffer(CaptureBuffer,
2359  (PVOID)GraphicsBufferInfo->lpBitMapInfo,
2360  GraphicsBufferInfo->dwBitMapInfoLength,
2361  (PVOID*)&CreateScreenBufferRequest->GraphicsBufferInfo.lpBitMapInfo);
2362  }
2363 
2365  CaptureBuffer,
2367  sizeof(*CreateScreenBufferRequest));
2368 
2369  if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
2370 
2371  if (!NT_SUCCESS(ApiMessage.Status))
2372  {
2373  BaseSetLastNTError(ApiMessage.Status);
2374  return INVALID_HANDLE_VALUE;
2375  }
2376 
2377  if (dwFlags == CONSOLE_GRAPHICS_BUFFER && GraphicsBufferInfo)
2378  {
2379  GraphicsBufferInfo->hMutex = CreateScreenBufferRequest->hMutex ; // CreateScreenBufferRequest->GraphicsBufferInfo.hMutex ;
2380  GraphicsBufferInfo->lpBitMap = CreateScreenBufferRequest->lpBitMap; // CreateScreenBufferRequest->GraphicsBufferInfo.lpBitMap;
2381  }
2382 
2383  return CreateScreenBufferRequest->OutputHandle;
2384 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
VOID NTAPI CsrFreeCaptureBuffer(IN PCSR_CAPTURE_BUFFER CaptureBuffer)
Definition: capture.c:189
CONSOLE_CREATESCREENBUFFER CreateScreenBufferRequest
Definition: conmsg.h:927
PCSR_CAPTURE_BUFFER NTAPI CsrAllocateCaptureBuffer(IN ULONG ArgumentCount, IN ULONG BufferSize)
Definition: capture.c:90
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:125
NTSTATUS Status
Definition: csrmsg.h:112
VOID NTAPI CsrCaptureMessageBuffer(IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer, IN PVOID MessageBuffer OPTIONAL, IN ULONG MessageLength, OUT PVOID *CapturedData)
Definition: capture.c:169
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:409
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
CONSOLE_GRAPHICS_BUFFER_INFO GraphicsBufferInfo
Definition: conmsg.h:456
#define GENERIC_READ
Definition: compat.h:124
#define NtCurrentPeb()
Definition: FLS.c:19
#define CONSOLE_TEXTMODE_BUFFER
Definition: wincon.h:59
#define CONSOLE_GRAPHICS_BUFFER
Definition: wincon.h:60
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

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 
62  case CTRL_BREAK_EVENT:
63  DPRINT("Ctrl-Break Event\n");
64  break;
65 
66  case CTRL_CLOSE_EVENT:
67  DPRINT("Ctrl Close Event\n");
68  break;
69 
71  DPRINT("Ctrl Last Close Event\n");
72  break;
73 
74  case CTRL_LOGOFF_EVENT:
75  DPRINT("Ctrl Logoff Event\n");
76  break;
77 
79  DPRINT("Ctrl Shutdown Event\n");
80  break;
81  }
82 
84  return TRUE;
85 }
#define TRUE
Definition: types.h:120
#define CTRL_BREAK_EVENT
Definition: wincon.h:66
#define CTRL_CLOSE_EVENT
Definition: wincon.h:67
#define CTRL_C_EVENT
Definition: wincon.h:65
VOID WINAPI ExitProcess(IN UINT uExitCode)
Definition: proc.c:1517
void DPRINT(...)
Definition: polytest.cpp:61
#define CTRL_LOGOFF_EVENT
Definition: wincon.h:69
#define CTRL_SHUTDOWN_EVENT
Definition: wincon.h:70
#define CTRL_LAST_CLOSE_EVENT
Definition: wincon.h:68
#define CONTROL_C_EXIT
Definition: winbase.h:330

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  {
437  return INVALID_HANDLE_VALUE;
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);
453  return INVALID_HANDLE_VALUE;
454  }
455 
456  return DuplicateHandleRequest->TargetHandle;
457 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
DWORD dwOptions
Definition: solitaire.cpp:23
CONSOLE_DUPLICATEHANDLE DuplicateHandleRequest
Definition: conmsg.h:915
#define DUPLICATE_CLOSE_SOURCE
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
NTSTATUS Status
Definition: csrmsg.h:112
#define DUPLICATE_SAME_ACCESS
static BOOL bInheritHandle
Definition: pipe.c:82
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:409
#define GENERIC_READ
Definition: compat.h:124
#define NtCurrentPeb()
Definition: FLS.c:19
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

Referenced by DuplicateHandle().

◆ FlushConsoleInputBuffer()

BOOL WINAPI DECLSPEC_HOTPATCH FlushConsoleInputBuffer ( HANDLE  hConsoleInput)

Definition at line 1829 of file console.c.

1830 {
1831  CONSOLE_API_MESSAGE ApiMessage;
1832  PCONSOLE_FLUSHINPUTBUFFER FlushInputBufferRequest = &ApiMessage.Data.FlushInputBufferRequest;
1833 
1834  FlushInputBufferRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1835  FlushInputBufferRequest->InputHandle = hConsoleInput;
1836 
1838  NULL,
1840  sizeof(*FlushInputBufferRequest));
1841  if (!NT_SUCCESS(ApiMessage.Status))
1842  {
1843  BaseSetLastNTError(ApiMessage.Status);
1844  return FALSE;
1845  }
1846 
1847  return TRUE;
1848 }
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
NTSTATUS Status
Definition: csrmsg.h:112
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define NtCurrentPeb()
Definition: FLS.c:19
CONSOLE_FLUSHINPUTBUFFER FlushInputBufferRequest
Definition: conmsg.h:934
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

◆ FreeConsole()

BOOL WINAPI DECLSPEC_HOTPATCH FreeConsole ( VOID  )

Definition at line 1446 of file console.c.

1447 {
1448  BOOL Success = TRUE;
1449  CONSOLE_API_MESSAGE ApiMessage;
1450  PCONSOLE_FREECONSOLE FreeConsoleRequest = &ApiMessage.Data.FreeConsoleRequest;
1451  HANDLE ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1452 
1454 
1455  /* We must have a non-trivial handle to close */
1456  if (ConsoleHandle == NULL) // IsConsoleHandle(ConsoleHandle)
1457  {
1459  Success = FALSE;
1460  goto Quit;
1461  }
1462 
1463  /* Set up the data to send to the Console Server */
1464  FreeConsoleRequest->ConsoleHandle = ConsoleHandle;
1465 
1466  /* Call the server */
1468  NULL,
1470  sizeof(*FreeConsoleRequest));
1471 
1472  /* Check for success */
1473  if (!NT_SUCCESS(ApiMessage.Status))
1474  {
1475  BaseSetLastNTError(ApiMessage.Status);
1476  Success = FALSE;
1477  goto Quit;
1478  }
1479 
1480  /* Reset the console handle */
1481  NtCurrentPeb()->ProcessParameters->ConsoleHandle = NULL;
1482 
1483  /* Close the associated input handle */
1486 
1487 Quit:
1489  return Success;
1490 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
HANDLE ConsoleHandle
Definition: conmsg.h:305
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
NTSTATUS Status
Definition: csrmsg.h:112
unsigned int BOOL
Definition: ntddk_ex.h:94
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
HANDLE InputWaitHandle
Definition: console.c:38
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:409
CONSOLE_FREECONSOLE FreeConsoleRequest
Definition: conmsg.h:904
RTL_CRITICAL_SECTION ConsoleLock
Definition: init.c:24
#define NtCurrentPeb()
Definition: FLS.c:19
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

◆ GenerateConsoleCtrlEvent()

BOOL WINAPI DECLSPEC_HOTPATCH GenerateConsoleCtrlEvent ( DWORD  dwCtrlEvent,
DWORD  dwProcessGroupId 
)

Definition at line 2134 of file console.c.

2136 {
2137  CONSOLE_API_MESSAGE ApiMessage;
2138  PCONSOLE_GENERATECTRLEVENT GenerateCtrlEventRequest = &ApiMessage.Data.GenerateCtrlEventRequest;
2139 
2140  if (dwCtrlEvent != CTRL_C_EVENT && dwCtrlEvent != CTRL_BREAK_EVENT)
2141  {
2143  return FALSE;
2144  }
2145 
2146  GenerateCtrlEventRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2147  GenerateCtrlEventRequest->CtrlEvent = dwCtrlEvent;
2148  GenerateCtrlEventRequest->ProcessGroupId = dwProcessGroupId;
2149 
2151  NULL,
2153  sizeof(*GenerateCtrlEventRequest));
2154  if (!NT_SUCCESS(ApiMessage.Status))
2155  {
2156  BaseSetLastNTError(ApiMessage.Status);
2157  return FALSE;
2158  }
2159 
2160  return TRUE;
2161 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define CTRL_BREAK_EVENT
Definition: wincon.h:66
CONSOLE_GENERATECTRLEVENT GenerateCtrlEventRequest
Definition: conmsg.h:908
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
#define CTRL_C_EVENT
Definition: wincon.h:65
NTSTATUS Status
Definition: csrmsg.h:112
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:409
#define NtCurrentPeb()
Definition: FLS.c:19
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

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

◆ GetConsoleCharType()

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

Definition at line 2983 of file console.c.

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

◆ GetConsoleCP()

UINT WINAPI DECLSPEC_HOTPATCH GetConsoleCP ( VOID  )

Definition at line 2393 of file console.c.

2394 {
2395  CONSOLE_API_MESSAGE ApiMessage;
2396  PCONSOLE_GETINPUTOUTPUTCP GetConsoleCPRequest = &ApiMessage.Data.GetConsoleCPRequest;
2397 
2398  /* Get the Input Code Page */
2399  GetConsoleCPRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2400  GetConsoleCPRequest->OutputCP = FALSE;
2401 
2403  NULL,
2405  sizeof(*GetConsoleCPRequest));
2406  if (!NT_SUCCESS(ApiMessage.Status))
2407  {
2408  BaseSetLastNTError(ApiMessage.Status);
2409  return 0;
2410  }
2411 
2412  return GetConsoleCPRequest->CodePage;
2413 }
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
NTSTATUS Status
Definition: csrmsg.h:112
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define NtCurrentPeb()
Definition: FLS.c:19
CONSOLE_GETINPUTOUTPUTCP GetConsoleCPRequest
Definition: conmsg.h:992
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

Referenced by _tmain(), cmd_start(), doChild(), Execute(), FileGetString(), test_Console(), and wmain().

◆ GetConsoleCursorInfo()

BOOL WINAPI GetConsoleCursorInfo ( HANDLE  hConsoleOutput,
PCONSOLE_CURSOR_INFO  lpConsoleCursorInfo 
)

Definition at line 1704 of file console.c.

1706 {
1707  CONSOLE_API_MESSAGE ApiMessage;
1708  PCONSOLE_GETSETCURSORINFO CursorInfoRequest = &ApiMessage.Data.CursorInfoRequest;
1709 
1710  if (!lpConsoleCursorInfo)
1711  {
1712  if (!hConsoleOutput)
1714  else
1716 
1717  return FALSE;
1718  }
1719 
1720  CursorInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1721  CursorInfoRequest->OutputHandle = hConsoleOutput;
1722 
1724  NULL,
1726  sizeof(*CursorInfoRequest));
1727  if (!NT_SUCCESS(ApiMessage.Status))
1728  {
1729  BaseSetLastNTError(ApiMessage.Status);
1730  return FALSE;
1731  }
1732 
1733  *lpConsoleCursorInfo = CursorInfoRequest->Info;
1734 
1735  return TRUE;
1736 }
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
CONSOLE_GETSETCURSORINFO CursorInfoRequest
Definition: conmsg.h:922
NTSTATUS Status
Definition: csrmsg.h:112
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
CONSOLE_CURSOR_INFO Info
Definition: conmsg.h:346
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:409
#define ERROR_INVALID_ACCESS
Definition: winerror.h:115
#define NtCurrentPeb()
Definition: FLS.c:19
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

Referenced by testCursorInfo(), and VgaConsoleInitialize().

◆ GetConsoleCursorMode()

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

Definition at line 2992 of file console.c.

2993 {
2994  STUB;
2995  return FALSE;
2996 }
#define STUB
Definition: kernel32.h:27

◆ 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 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
NTSTATUS Status
Definition: csrmsg.h:112
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
CONSOLE_GETDISPLAYMODE GetDisplayModeRequest
Definition: conmsg.h:938
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:409
#define NtCurrentPeb()
Definition: FLS.c:19
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

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 }
VOID NTAPI CsrFreeCaptureBuffer(IN PCSR_CAPTURE_BUFFER CaptureBuffer)
Definition: capture.c:189
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
ULONG NTAPI CsrAllocateMessagePointer(IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer, IN ULONG MessageLength, OUT PVOID *CapturedData)
Definition: capture.c:133
PCSR_CAPTURE_BUFFER NTAPI CsrAllocateCaptureBuffer(IN ULONG ArgumentCount, IN ULONG BufferSize)
Definition: capture.c:90
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
NTSTATUS Status
Definition: csrmsg.h:112
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
PCONSOLE_FONT_INFO FontInfo
Definition: conmsg.h:414
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
CONSOLE_GETFONTINFO GetFontInfoRequest
Definition: conmsg.h:944
#define SetLastError(x)
Definition: compat.h:409
#define NtCurrentPeb()
Definition: FLS.c:19
HANDLE ConsoleHandle
Definition: conmsg.h:411
BOOLEAN MaximumWindow
Definition: conmsg.h:413
#define DPRINT1
Definition: precomp.h:8
HANDLE OutputHandle
Definition: conmsg.h:412
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

◆ 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 }
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
CONSOLE_GETFONTSIZE GetFontSizeRequest
Definition: conmsg.h:945
NTSTATUS Status
Definition: csrmsg.h:112
smooth NULL
Definition: ftsmooth.c:416
HANDLE ConsoleHandle
Definition: conmsg.h:420
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Definition: bl.h:1338
HANDLE OutputHandle
Definition: conmsg.h:421
#define NtCurrentPeb()
Definition: FLS.c:19
union _CONSOLE_API_MESSAGE::@3381 Data
Definition: npfs.h:125
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

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 }
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
NTSTATUS Status
Definition: csrmsg.h:112
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
CONSOLE_GETHANDLEINFO GetHandleInfoRequest
Definition: conmsg.h:916
#define NtCurrentPeb()
Definition: FLS.c:19
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

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 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
CONSOLE_GETSETHWSTATE HardwareStateRequest
Definition: conmsg.h:940
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
NTSTATUS Status
Definition: csrmsg.h:112
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:409
#define NtCurrentPeb()
Definition: FLS.c:19
#define DPRINT1
Definition: precomp.h:8
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

◆ GetConsoleInputExeNameA()

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

Definition at line 2945 of file console.c.

2947 {
2948  NTSTATUS Status;
2949  DWORD ExeLength;
2950  UNICODE_STRING BufferU;
2951  ANSI_STRING BufferA;
2953 
2954  /* Get the UNICODE name */
2956 
2957  if ((ExeLength == 0) || (ExeLength >= EXENAME_LENGTH))
2958  return ExeLength;
2959 
2960  /* Initialize the strings for conversion */
2961  RtlInitUnicodeString(&BufferU, Buffer);
2962  BufferA.Length = 0;
2963  BufferA.MaximumLength = (USHORT)nBufferLength;
2964  BufferA.Buffer = lpExeName;
2965 
2966  /* Convert UNICODE name to ANSI, copying as much chars as it can fit */
2967  Status = RtlUnicodeStringToAnsiString(&BufferA, &BufferU, FALSE);
2968  if (!NT_SUCCESS(Status))
2969  {
2971  {
2973  return ExeLength + 1;
2974  }
2976  }
2977 
2978  return ExeLength;
2979 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
LONG NTSTATUS
Definition: precomp.h:26
static DWORD LPSTR lpExeName
Definition: process.c:72
#define EXENAME_LENGTH
Definition: console.c:40
Definition: bufpool.h:45
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
_In_ LPCSTR _In_opt_ LPCSTR _In_ DWORD nBufferLength
Definition: winbase.h:3011
DWORD WINAPI DECLSPEC_HOTPATCH GetConsoleInputExeNameW(IN DWORD nBufferLength, OUT LPWSTR lpExeName)
Definition: console.c:2906
USHORT MaximumLength
Definition: env_spec_w32.h:377
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
Status
Definition: gdiplustypes.h:24
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
unsigned short USHORT
Definition: pedump.c:61
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

Referenced by init_function_pointers().

◆ GetConsoleInputExeNameW()

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

Definition at line 2906 of file console.c.

2908 {
2910  {
2911  /* Buffer is not large enough! Return the correct size. */
2913  return ExeNameLength + 1;
2914  }
2915 
2917  _SEH2_TRY
2918  {
2919  /* Copy the input EXE name and NULL-terminate it */
2922  }
2924  {
2926  }
2927  _SEH2_END;
2928 
2929  return TRUE;
2930 }
static RTL_CRITICAL_SECTION ExeNameLock
Definition: console.c:41
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
static WCHAR ExeNameBuffer[EXENAME_LENGTH]
Definition: console.c:43
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
_SEH2_TRY
Definition: create.c:4250
static DWORD LPSTR lpExeName
Definition: process.c:72
#define UNICODE_NULL
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
static USHORT ExeNameLength
Definition: console.c:44
_In_ LPCSTR _In_opt_ LPCSTR _In_ DWORD nBufferLength
Definition: winbase.h:3011
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SetLastError(x)
Definition: compat.h:409
_SEH2_END
Definition: create.c:4424
_SEH2_FINALLY
Definition: create.c:4395

Referenced by GetConsoleInputExeNameA().

◆ GetConsoleInputWaitHandle()

HANDLE WINAPI GetConsoleInputWaitHandle ( VOID  )

◆ GetConsoleKeyboardLayoutNameA()

BOOL WINAPI DECLSPEC_HOTPATCH GetConsoleKeyboardLayoutNameA ( OUT LPSTR  pszLayoutName)

Definition at line 3121 of file console.c.

3122 {
3123  return IntGetConsoleKeyboardLayoutName(pszLayoutName, TRUE);
3124 }
#define TRUE
Definition: types.h:120
static BOOL IntGetConsoleKeyboardLayoutName(OUT PVOID pszLayoutName, IN BOOL bAnsi)
Definition: console.c:3073

◆ GetConsoleKeyboardLayoutNameW()

BOOL WINAPI DECLSPEC_HOTPATCH GetConsoleKeyboardLayoutNameW ( OUT LPWSTR  pszLayoutName)

Definition at line 3132 of file console.c.

3133 {
3134  return IntGetConsoleKeyboardLayoutName(pszLayoutName, FALSE);
3135 }
static BOOL IntGetConsoleKeyboardLayoutName(OUT PVOID pszLayoutName, IN BOOL bAnsi)
Definition: console.c:3073

◆ GetConsoleMode()

BOOL WINAPI GetConsoleMode ( HANDLE  hConsoleHandle,
LPDWORD  lpMode 
)

Definition at line 1571 of file console.c.

1573 {
1574  CONSOLE_API_MESSAGE ApiMessage;
1575  PCONSOLE_GETSETCONSOLEMODE ConsoleModeRequest = &ApiMessage.Data.ConsoleModeRequest;
1576 
1577  if (lpMode == NULL)
1578  {
1580  return FALSE;
1581  }
1582 
1583  ConsoleModeRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1584  ConsoleModeRequest->Handle = hConsoleHandle;
1585 
1587  NULL,
1589  sizeof(*ConsoleModeRequest));
1590  if (!NT_SUCCESS(ApiMessage.Status))
1591  {
1592  BaseSetLastNTError(ApiMessage.Status);
1593  return FALSE;
1594  }
1595 
1596  *lpMode = ConsoleModeRequest->Mode;
1597 
1598  return TRUE;
1599 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
NTSTATUS Status
Definition: csrmsg.h:112
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:409
CONSOLE_GETSETCONSOLEMODE ConsoleModeRequest
Definition: conmsg.h:937
#define NtCurrentPeb()
Definition: FLS.c:19
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

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

3011 {
3012  STUB;
3013  return FALSE;
3014 }
#define STUB
Definition: kernel32.h:27

◆ GetConsoleOutputCP()

UINT WINAPI DECLSPEC_HOTPATCH GetConsoleOutputCP ( VOID  )

Definition at line 2453 of file console.c.

2454 {
2455  CONSOLE_API_MESSAGE ApiMessage;
2456  PCONSOLE_GETINPUTOUTPUTCP GetConsoleCPRequest = &ApiMessage.Data.GetConsoleCPRequest;
2457 
2458  /* Get the Output Code Page */
2459  GetConsoleCPRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2460  GetConsoleCPRequest->OutputCP = TRUE;
2461 
2463  NULL,
2465  sizeof(*GetConsoleCPRequest));
2466  if (!NT_SUCCESS(ApiMessage.Status))
2467  {
2468  BaseSetLastNTError(ApiMessage.Status);
2469  return 0;
2470  }
2471 
2472  return GetConsoleCPRequest->CodePage;
2473 }
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
NTSTATUS Status
Definition: csrmsg.h:112
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define NtCurrentPeb()
Definition: FLS.c:19
CONSOLE_GETINPUTOUTPUTCP GetConsoleCPRequest
Definition: conmsg.h:992
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

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

◆ GetConsoleProcessList()

DWORD WINAPI GetConsoleProcessList ( LPDWORD  lpdwProcessList,
DWORD  dwProcessCount 
)

Definition at line 2512 of file console.c.

2514 {
2515  CONSOLE_API_MESSAGE ApiMessage;
2516  PCONSOLE_GETPROCESSLIST GetProcessListRequest = &ApiMessage.Data.GetProcessListRequest;
2517  PCSR_CAPTURE_BUFFER CaptureBuffer;
2518  ULONG nProcesses = 0;
2519 
2520  if (lpdwProcessList == NULL || dwProcessCount == 0)
2521  {
2523  return 0;
2524  }
2525 
2526  CaptureBuffer = CsrAllocateCaptureBuffer(1, dwProcessCount * sizeof(DWORD));
2527  if (CaptureBuffer == NULL)
2528  {
2529  DPRINT1("CsrAllocateCaptureBuffer failed!\n");
2531  return 0;
2532  }
2533 
2534  GetProcessListRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2535  GetProcessListRequest->ProcessCount = dwProcessCount;
2536 
2537  CsrAllocateMessagePointer(CaptureBuffer,
2538  dwProcessCount * sizeof(DWORD),
2539  (PVOID*)&GetProcessListRequest->ProcessIdsList);
2540 
2542  CaptureBuffer,
2544  sizeof(*GetProcessListRequest));
2545  if (!NT_SUCCESS(ApiMessage.Status))
2546  {
2547  BaseSetLastNTError(ApiMessage.Status);
2548  }
2549  else
2550  {
2551  nProcesses = GetProcessListRequest->ProcessCount;
2552  if (dwProcessCount >= nProcesses)
2553  {
2554  RtlCopyMemory(lpdwProcessList, GetProcessListRequest->ProcessIdsList, nProcesses * sizeof(DWORD));
2555  }
2556  }
2557 
2558  CsrFreeCaptureBuffer(CaptureBuffer);
2559  return nProcesses;
2560 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
VOID NTAPI CsrFreeCaptureBuffer(IN PCSR_CAPTURE_BUFFER CaptureBuffer)
Definition: capture.c:189
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
ULONG NTAPI CsrAllocateMessagePointer(IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer, IN ULONG MessageLength, OUT PVOID *CapturedData)
Definition: capture.c:133
PCSR_CAPTURE_BUFFER NTAPI CsrAllocateCaptureBuffer(IN ULONG ArgumentCount, IN ULONG BufferSize)
Definition: capture.c:90
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
NTSTATUS Status
Definition: csrmsg.h:112
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
#define NtCurrentPeb()
Definition: FLS.c:19
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
CONSOLE_GETPROCESSLIST GetProcessListRequest
Definition: conmsg.h:907
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

Referenced by init_function_pointers().

◆ GetConsoleScreenBufferInfo()

BOOL WINAPI GetConsoleScreenBufferInfo ( HANDLE  hConsoleOutput,
PCONSOLE_SCREEN_BUFFER_INFO  lpConsoleScreenBufferInfo 
)

Definition at line 1498 of file console.c.

1500 {
1501  CONSOLE_API_MESSAGE ApiMessage;
1502  PCONSOLE_GETSCREENBUFFERINFO ScreenBufferInfoRequest = &ApiMessage.Data.ScreenBufferInfoRequest;
1503 
1504  if (lpConsoleScreenBufferInfo == NULL)
1505  {
1507  return FALSE;
1508  }
1509 
1510  ScreenBufferInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1511  ScreenBufferInfoRequest->OutputHandle = hConsoleOutput;
1512 
1514  NULL,
1516  sizeof(*ScreenBufferInfoRequest));
1517  if (!NT_SUCCESS(ApiMessage.Status))
1518  {
1519  BaseSetLastNTError(ApiMessage.Status);
1520  return FALSE;
1521  }
1522 
1523  lpConsoleScreenBufferInfo->dwSize = ScreenBufferInfoRequest->ScreenBufferSize;
1524  lpConsoleScreenBufferInfo->dwCursorPosition = ScreenBufferInfoRequest->CursorPosition;
1525  lpConsoleScreenBufferInfo->wAttributes = ScreenBufferInfoRequest->Attributes;
1526  lpConsoleScreenBufferInfo->srWindow.Left = ScreenBufferInfoRequest->ViewOrigin.X;
1527  lpConsoleScreenBufferInfo->srWindow.Top = ScreenBufferInfoRequest->ViewOrigin.Y;
1528  lpConsoleScreenBufferInfo->srWindow.Right = ScreenBufferInfoRequest->ViewOrigin.X + ScreenBufferInfoRequest->ViewSize.X - 1;
1529  lpConsoleScreenBufferInfo->srWindow.Bottom = ScreenBufferInfoRequest->ViewOrigin.Y + ScreenBufferInfoRequest->ViewSize.Y - 1;
1530  lpConsoleScreenBufferInfo->dwMaximumWindowSize = ScreenBufferInfoRequest->MaximumViewSize;
1531 
1532  return TRUE;
1533 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
NTSTATUS Status
Definition: csrmsg.h:112
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
SHORT Left
Definition: blue.h:25
ULONG X
Definition: bl.h:1340
SHORT Bottom
Definition: blue.h:28
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:409
SHORT Top
Definition: blue.h:26
#define NtCurrentPeb()
Definition: FLS.c:19
CONSOLE_GETSCREENBUFFERINFO ScreenBufferInfoRequest
Definition: conmsg.h:929
SHORT Right
Definition: blue.h:27
ULONG Y
Definition: bl.h:1341
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

◆ GetConsoleSelectionInfo()

BOOL WINAPI GetConsoleSelectionInfo ( PCONSOLE_SELECTION_INFO  lpConsoleSelectionInfo)

Definition at line 2568 of file console.c.

2569 {
2570  CONSOLE_API_MESSAGE ApiMessage;
2571  PCONSOLE_GETSELECTIONINFO GetSelectionInfoRequest = &ApiMessage.Data.GetSelectionInfoRequest;
2572 
2573  if (lpConsoleSelectionInfo == NULL)
2574  {
2576  return FALSE;
2577  }
2578 
2579  GetSelectionInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2580 
2582  NULL,
2584  sizeof(*GetSelectionInfoRequest));
2585  if (!NT_SUCCESS(ApiMessage.Status))
2586  {
2587  BaseSetLastNTError(ApiMessage.Status);
2588  return FALSE;
2589  }
2590 
2591  *lpConsoleSelectionInfo = GetSelectionInfoRequest->Info;
2592 
2593  return TRUE;
2594 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
NTSTATUS Status
Definition: csrmsg.h:112
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
CONSOLE_SELECTION_INFO Info
Definition: conmsg.h:844
CONSOLE_GETSELECTIONINFO GetSelectionInfoRequest
Definition: conmsg.h:933
#define SetLastError(x)
Definition: compat.h:409
#define NtCurrentPeb()
Definition: FLS.c:19
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

◆ GetConsoleTitleA()

DWORD WINAPI DECLSPEC_HOTPATCH GetConsoleTitleA ( LPSTR  lpConsoleTitle,
DWORD  nSize 
)

Definition at line 2237 of file console.c.

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

◆ GetConsoleTitleW()

DWORD WINAPI DECLSPEC_HOTPATCH GetConsoleTitleW ( LPWSTR  lpConsoleTitle,
DWORD  nSize 
)

Definition at line 2224 of file console.c.

2226 {
2227  return IntGetConsoleTitle(lpConsoleTitle, nSize, TRUE);
2228 }
#define TRUE
Definition: types.h:120
*nSize LPSTR _Inout_ LPDWORD nSize
Definition: winbase.h:2024
static DWORD IntGetConsoleTitle(LPVOID lpConsoleTitle, DWORD dwNumChars, BOOLEAN bUnicode)
Definition: console.c:2165

◆ GetConsoleWindow()

HWND WINAPI DECLSPEC_HOTPATCH GetConsoleWindow ( VOID  )

Definition at line 2730 of file console.c.

2731 {
2732  CONSOLE_API_MESSAGE ApiMessage;
2733  PCONSOLE_GETWINDOW GetWindowRequest = &ApiMessage.Data.GetWindowRequest;
2734 
2735  GetWindowRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2736 
2738  NULL,
2740  sizeof(*GetWindowRequest));
2741  if (!NT_SUCCESS(ApiMessage.Status))
2742  {
2743  BaseSetLastNTError(ApiMessage.Status);
2744  return (HWND)NULL;
2745  }
2746 
2747  return GetWindowRequest->WindowHandle;
2748 }
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
NTSTATUS Status
Definition: csrmsg.h:112
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
HANDLE ConsoleHandle
Definition: conmsg.h:716
#define NtCurrentPeb()
Definition: FLS.c:19
CONSOLE_GETWINDOW GetWindowRequest
Definition: conmsg.h:957
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

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 }
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
NTSTATUS Status
Definition: csrmsg.h:112
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
CONSOLE_GETCURRENTFONT GetCurrentFontRequest
Definition: conmsg.h:946
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define NtCurrentPeb()
Definition: FLS.c:19
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

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 
321  if (ExeNameInitialized)
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 }
static RTL_CRITICAL_SECTION ExeNameLock
Definition: console.c:41
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
static WCHAR ExeNameBuffer[EXENAME_LENGTH]
Definition: console.c:43
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define UNICODE_NULL
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
static USHORT ExeNameLength
Definition: console.c:44
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define BufferSize
Definition: classpnp.h:419
unsigned short USHORT
Definition: pedump.c:61
static BOOLEAN ExeNameInitialized
Definition: console.c:42

Referenced by IntReadConsole().

◆ GetLargestConsoleWindowSize()

COORD WINAPI DECLSPEC_HOTPATCH GetLargestConsoleWindowSize ( HANDLE  hConsoleOutput)

Definition at line 1675 of file console.c.

1676 {
1677  CONSOLE_API_MESSAGE ApiMessage;
1678  PCONSOLE_GETLARGESTWINDOWSIZE GetLargestWindowSizeRequest = &ApiMessage.Data.GetLargestWindowSizeRequest;
1679 
1680  GetLargestWindowSizeRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1681  GetLargestWindowSizeRequest->OutputHandle = hConsoleOutput;
1682  GetLargestWindowSizeRequest->Size.X = 0;
1683  GetLargestWindowSizeRequest->Size.Y = 0;
1684 
1686  NULL,
1688  sizeof(*GetLargestWindowSizeRequest));
1689  if (!NT_SUCCESS(ApiMessage.Status))
1690  {
1691  BaseSetLastNTError(ApiMessage.Status);
1692  }
1693 
1694  DPRINT("GetLargestConsoleWindowSize, X = %d, Y = %d\n", GetLargestWindowSizeRequest->Size.X, GetLargestWindowSizeRequest->Size.Y);
1695  return GetLargestWindowSizeRequest->Size;
1696 }
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
CONSOLE_GETLARGESTWINDOWSIZE GetLargestWindowSizeRequest
Definition: conmsg.h:953
NTSTATUS Status
Definition: csrmsg.h:112
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
ULONG X
Definition: bl.h:1340
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define NtCurrentPeb()
Definition: FLS.c:19
ULONG Y
Definition: bl.h:1341
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

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 }
CONSOLE_GETNUMFONTS GetNumFontsRequest
Definition: conmsg.h:943
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
NTSTATUS Status
Definition: csrmsg.h:112
smooth NULL
Definition: ftsmooth.c:416
HANDLE ConsoleHandle
Definition: conmsg.h:405
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define NtCurrentPeb()
Definition: FLS.c:19
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

◆ GetNumberOfConsoleInputEvents()

BOOL WINAPI GetNumberOfConsoleInputEvents ( HANDLE  hConsoleInput,
LPDWORD  lpNumberOfEvents 
)

Definition at line 1637 of file console.c.

1639 {
1640  CONSOLE_API_MESSAGE ApiMessage;
1641  PCONSOLE_GETNUMINPUTEVENTS GetNumInputEventsRequest = &ApiMessage.Data.GetNumInputEventsRequest;
1642 
1643  GetNumInputEventsRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1644  GetNumInputEventsRequest->InputHandle = hConsoleInput;
1645  GetNumInputEventsRequest->NumberOfEvents = 0;
1646 
1648  NULL,
1650  sizeof(*GetNumInputEventsRequest));
1651  if (!NT_SUCCESS(ApiMessage.Status))
1652  {
1653  BaseSetLastNTError(ApiMessage.Status);
1654  return FALSE;
1655  }
1656 
1657  if (lpNumberOfEvents == NULL)
1658  {
1660  return FALSE;
1661  }
1662 
1663  *lpNumberOfEvents = GetNumInputEventsRequest->NumberOfEvents;
1664 
1665  return TRUE;
1666 }
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
NTSTATUS Status
Definition: csrmsg.h:112
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:409
#define ERROR_INVALID_ACCESS
Definition: winerror.h:115
#define NtCurrentPeb()
Definition: FLS.c:19
CONSOLE_GETNUMINPUTEVENTS GetNumInputEventsRequest
Definition: conmsg.h:965
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

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

◆ GetNumberOfConsoleMouseButtons()

BOOL WINAPI GetNumberOfConsoleMouseButtons ( LPDWORD  lpNumberOfMouseButtons)

Definition at line 1773 of file console.c.

1774 {
1775  CONSOLE_API_MESSAGE ApiMessage;
1776  PCONSOLE_GETMOUSEINFO GetMouseInfoRequest = &ApiMessage.Data.GetMouseInfoRequest;
1777 
1778  GetMouseInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1779 
1781  NULL,
1783  sizeof(*GetMouseInfoRequest));
1784  if (!NT_SUCCESS(ApiMessage.Status))
1785  {
1786  BaseSetLastNTError(ApiMessage.Status);
1787  return FALSE;
1788  }
1789 
1790  *lpNumberOfMouseButtons = GetMouseInfoRequest->NumButtons;
1791  return TRUE;
1792 }
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
NTSTATUS Status
Definition: csrmsg.h:112
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
HANDLE ConsoleHandle
Definition: conmsg.h:355
#define NtCurrentPeb()
Definition: FLS.c:19
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15
CONSOLE_GETMOUSEINFO GetMouseInfoRequest
Definition: conmsg.h:924

◆ 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 }
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define STD_INPUT_HANDLE
Definition: winbase.h:264
_In_ HANDLE Handle
Definition: extypes.h:390
#define STD_ERROR_HANDLE
Definition: winbase.h:266
#define SetLastError(x)
Definition: compat.h:409
#define STD_OUTPUT_HANDLE
Definition: winbase.h:265
#define NtCurrentPeb()
Definition: FLS.c:19

◆ InitExeName()

VOID InitExeName ( VOID  )

Definition at line 216 of file console.c.

217 {
219  PPEB Peb = NtCurrentPeb();
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 }
static RTL_CRITICAL_SECTION ExeNameLock
Definition: console.c:41
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
PPEB Peb
Definition: dllmain.c:27
static WCHAR ExeNameBuffer[EXENAME_LENGTH]
Definition: console.c:43
WCHAR CurrentDirectory[1024]
Definition: chkdsk.c:74
LIST_ENTRY InLoadOrderModuleList
Definition: ldrtypes.h:119
LONG NTSTATUS
Definition: precomp.h:26
#define UNICODE_NULL
static USHORT ExeNameLength
Definition: console.c:44
static USHORT StartDirLength
Definition: console.c:46
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
__wchar_t WCHAR
Definition: xmlstorage.h:180
NTSYSAPI NTSTATUS NTAPI RtlInitializeCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PRTL_USER_PROCESS_PARAMETERS ProcessParameters
Definition: btrfs_drv.h:1838
Definition: btrfs_drv.h:1801
Status
Definition: gdiplustypes.h:24
static WCHAR StartDirBuffer[MAX_PATH+1]
Definition: console.c:45
#define NtCurrentPeb()
Definition: FLS.c:19
static BOOLEAN ExeNameInitialized
Definition: console.c:42
PPEB_LDR_DATA Ldr
Definition: btrfs_drv.h:1837
UNICODE_STRING BaseDllName
Definition: ldrtypes.h:144
#define min(a, b)
Definition: monoChain.cc:55

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 ULONG NrAllocatedHandlers
Definition: console.c:32
static BOOL WINAPI DefaultConsoleCtrlHandler(DWORD Event)
Definition: console.c:53
static ULONG NrCtrlHandlers
Definition: console.c:31
static PHANDLER_ROUTINE InitialHandler[1]
Definition: console.c:29
static PHANDLER_ROUTINE * CtrlHandlers
Definition: console.c:30

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;
1268  NTSTATUS Status;
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 
1355 Quit:
1356  if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
1357  return Success;
1358 }
VOID NTAPI CsrFreeCaptureBuffer(IN PCSR_CAPTURE_BUFFER CaptureBuffer)
Definition: capture.c:189
LPTHREAD_START_ROUTINE PropRoutine
Definition: conmsg.h:286
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
PCSR_CAPTURE_BUFFER NTAPI CsrAllocateCaptureBuffer(IN ULONG ArgumentCount, IN ULONG BufferSize)
Definition: capture.c:90
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
CONSOLE_ALLOCCONSOLE AllocConsoleRequest
Definition: conmsg.h:902
LONG NTSTATUS
Definition: precomp.h:26
HANDLE InitEvents[MAX_INIT_EVENTS]
Definition: conmsg.h:175
LPTHREAD_START_ROUTINE CtrlRoutine
Definition: conmsg.h:285
static CHAR AppName[MAX_PATH]
Definition: dem.c:252
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
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
NTSTATUS Status
Definition: csrmsg.h:112
VOID NTAPI CsrCaptureMessageBuffer(IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer, IN PVOID MessageBuffer OPTIONAL, IN ULONG MessageLength, OUT PVOID *CapturedData)
Definition: capture.c:169
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
static const WCHAR Title[]
Definition: oid.c:1259
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:409
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
Status
Definition: gdiplustypes.h:24
#define NtCurrentPeb()
Definition: FLS.c:19
PCONSOLE_START_INFO ConsoleStartInfo
Definition: conmsg.h:274
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

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

2606 {
2607  BOOL Success = TRUE;
2608  NTSTATUS Status;
2609 
2610  CONSOLE_API_MESSAGE ApiMessage;
2611  PCONSOLE_ATTACHCONSOLE AttachConsoleRequest = &ApiMessage.Data.AttachConsoleRequest;
2612  PCSR_CAPTURE_BUFFER CaptureBuffer;
2613 
2614  AttachConsoleRequest->ProcessId = ProcessId;
2615  AttachConsoleRequest->CtrlRoutine = CtrlRoutine;
2616  AttachConsoleRequest->PropRoutine = PropRoutine;
2617 
2618  CaptureBuffer = CsrAllocateCaptureBuffer(1, sizeof(CONSOLE_START_INFO));
2619  if (CaptureBuffer == NULL)
2620  {
2622  Success = FALSE;
2623  goto Quit;
2624  }
2625 
2626  CsrCaptureMessageBuffer(CaptureBuffer,
2627  ConsoleStartInfo,
2628  sizeof(CONSOLE_START_INFO),
2629  (PVOID*)&AttachConsoleRequest->ConsoleStartInfo);
2630 
2632  CaptureBuffer,
2634  sizeof(*AttachConsoleRequest));
2635  if (!NT_SUCCESS(ApiMessage.Status))
2636  {
2637  BaseSetLastNTError(ApiMessage.Status);
2638  Success = FALSE;
2639  goto Quit;
2640  }
2641 
2642  // Is AttachConsoleRequest->ConsoleStartInfo->InitEvents aligned on handle boundary ????
2644  AttachConsoleRequest->ConsoleStartInfo->InitEvents,
2645  WaitAny, FALSE, NULL);
2646  if (!NT_SUCCESS(Status))
2647  {
2649  Success = FALSE;
2650  goto Quit;
2651  }
2652 
2653  NtClose(AttachConsoleRequest->ConsoleStartInfo->InitEvents[INIT_SUCCESS]);
2654  NtClose(AttachConsoleRequest->ConsoleStartInfo->InitEvents[INIT_FAILURE]);
2655  if (Status != INIT_SUCCESS)
2656  {
2657  NtCurrentPeb()->ProcessParameters->ConsoleHandle = NULL;
2658  Success = FALSE;
2659  }
2660  else
2661  {
2662  RtlCopyMemory(ConsoleStartInfo,
2663  AttachConsoleRequest->ConsoleStartInfo,
2664  sizeof(CONSOLE_START_INFO));
2665  Success = TRUE;
2666  }
2667 
2668 Quit:
2669  if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
2670  return Success;
2671 }
VOID NTAPI CsrFreeCaptureBuffer(IN PCSR_CAPTURE_BUFFER CaptureBuffer)
Definition: capture.c:189
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2697
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
LPTHREAD_START_ROUTINE CtrlRoutine
Definition: conmsg.h:299
PCSR_CAPTURE_BUFFER NTAPI CsrAllocateCaptureBuffer(IN ULONG ArgumentCount, IN ULONG BufferSize)
Definition: capture.c:90
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
LONG NTSTATUS
Definition: precomp.h:26
HANDLE InitEvents[MAX_INIT_EVENTS]
Definition: conmsg.h:175
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
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
NTSTATUS Status
Definition: csrmsg.h:112
VOID NTAPI CsrCaptureMessageBuffer(IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer, IN PVOID MessageBuffer OPTIONAL, IN ULONG MessageLength, OUT PVOID *CapturedData)
Definition: capture.c:169
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:409
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
CONSOLE_ATTACHCONSOLE AttachConsoleRequest
Definition: conmsg.h:903
LPTHREAD_START_ROUTINE PropRoutine
Definition: conmsg.h:300
Status
Definition: gdiplustypes.h:24
#define NtCurrentPeb()
Definition: FLS.c:19
PCONSOLE_START_INFO ConsoleStartInfo
Definition: conmsg.h:297
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

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  {
366  return BaseConInputFileName;
367  }
368  else if (_wcsicmp(ConsoleName, BaseConOutputFileName) == 0)
369  {
370  return BaseConOutputFileName;
371  }
372  else if (_wcsicmp(ConsoleName, BaseConFileName) == 0)
373  {
374  if ((dwDesiredAccess & (GENERIC_READ | GENERIC_WRITE)) == GENERIC_READ)
375  {
376  return BaseConInputFileName;
377  }
378  else if ((dwDesiredAccess & (GENERIC_READ | GENERIC_WRITE)) == GENERIC_WRITE)
379  {
380  return BaseConOutputFileName;
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 }
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
static LPCWSTR BaseConOutputFileName
Definition: console.c:26
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define GENERIC_WRITE
Definition: nt_native.h:90
static LPCWSTR BaseConInputFileName
Definition: console.c:25
smooth NULL
Definition: ftsmooth.c:416
static LPCWSTR BaseConFileName
Definition: console.c:24
#define GENERIC_READ
Definition: compat.h:124
unsigned int ULONG
Definition: retypes.h:1
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)

Referenced by CreateFileW().

◆ IntGetConsoleKeyboardLayoutName()

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

Definition at line 3073 of file console.c.

3075 {
3076  CONSOLE_API_MESSAGE ApiMessage;
3077  PCONSOLE_GETKBDLAYOUTNAME GetKbdLayoutNameRequest = &ApiMessage.Data.GetKbdLayoutNameRequest;
3078 
3079  /* Set up the data to send to the Console Server */
3080  GetKbdLayoutNameRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
3081  GetKbdLayoutNameRequest->Ansi = bAnsi;
3082 
3083  /* Call the server */
3085  NULL,
3087  sizeof(*GetKbdLayoutNameRequest));
3088 
3089  /* Check for success */
3090  if (!NT_SUCCESS(ApiMessage.Status))
3091  {
3092  BaseSetLastNTError(ApiMessage.Status);
3093  return FALSE;
3094  }
3095 
3096  /* Retrieve the results */
3097  _SEH2_TRY
3098  {
3099  /* Copy only KL_NAMELENGTH == 9 characters, ANSI or UNICODE */
3100  if (bAnsi)
3101  strncpy(pszLayoutName, (PCHAR)GetKbdLayoutNameRequest->LayoutBuffer, KL_NAMELENGTH);
3102  else
3103  wcsncpy(pszLayoutName, (PWCHAR)GetKbdLayoutNameRequest->LayoutBuffer, KL_NAMELENGTH);
3104  }
3106  {
3108  _SEH2_YIELD(return FALSE);
3109  }
3110  _SEH2_END;
3111 
3112  return TRUE;
3113 }
signed char * PCHAR
Definition: retypes.h:7
#define TRUE
Definition: types.h:120
#define KL_NAMELENGTH
Definition: winuser.h:122
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
uint16_t * PWCHAR
Definition: typedefs.h:54
_SEH2_TRY
Definition: create.c:4250
NTSTATUS Status
Definition: csrmsg.h:112
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:409
#define ERROR_INVALID_ACCESS
Definition: winerror.h:115
_SEH2_END
Definition: create.c:4424
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
#define NtCurrentPeb()
Definition: FLS.c:19
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
CONSOLE_GETKBDLAYOUTNAME GetKbdLayoutNameRequest
Definition: conmsg.h:994
CHAR LayoutBuffer[KL_NAMELENGTH *sizeof(WCHAR)]
Definition: conmsg.h:865
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

Referenced by GetConsoleKeyboardLayoutNameA(), and GetConsoleKeyboardLayoutNameW().

◆ IntGetConsoleTitle()

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

Definition at line 2165 of file console.c.

2166 {
2167  CONSOLE_API_MESSAGE ApiMessage;
2168  PCONSOLE_GETSETCONSOLETITLE TitleRequest = &ApiMessage.Data.TitleRequest;
2169  PCSR_CAPTURE_BUFFER CaptureBuffer;
2170 
2171  if (dwNumChars == 0) return 0;
2172 
2173  TitleRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2174  TitleRequest->Length = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
2175  TitleRequest->Unicode = bUnicode;
2176 
2177  CaptureBuffer = CsrAllocateCaptureBuffer(1, TitleRequest->Length);
2178  if (CaptureBuffer == NULL)
2179  {
2180  DPRINT1("CsrAllocateCaptureBuffer failed!\n");
2182  return 0;
2183  }
2184 
2185  CsrAllocateMessagePointer(CaptureBuffer,
2186  TitleRequest->Length,
2187  (PVOID*)&TitleRequest->Title);
2188 
2190  CaptureBuffer,
2192  sizeof(*TitleRequest));
2193  if (!NT_SUCCESS(ApiMessage.Status))
2194  {
2195  CsrFreeCaptureBuffer(CaptureBuffer);
2196  BaseSetLastNTError(ApiMessage.Status);
2197  return 0;
2198  }
2199 
2200  dwNumChars = TitleRequest->Length / (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
2201 
2202  if (dwNumChars > 0)
2203  {
2204  RtlCopyMemory(lpConsoleTitle, TitleRequest->Title, TitleRequest->Length);
2205 
2206  if (bUnicode)
2207  ((LPWSTR)lpConsoleTitle)[dwNumChars] = UNICODE_NULL;
2208  else
2209  ((LPSTR)lpConsoleTitle)[dwNumChars] = ANSI_NULL;
2210  }
2211 
2212  CsrFreeCaptureBuffer(CaptureBuffer);
2213 
2214  return dwNumChars;
2215 }
VOID NTAPI CsrFreeCaptureBuffer(IN PCSR_CAPTURE_BUFFER CaptureBuffer)
Definition: capture.c:189
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
ULONG NTAPI CsrAllocateMessagePointer(IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer, IN ULONG MessageLength, OUT PVOID *CapturedData)
Definition: capture.c:133
PCSR_CAPTURE_BUFFER NTAPI CsrAllocateCaptureBuffer(IN ULONG ArgumentCount, IN ULONG BufferSize)
Definition: capture.c:90
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
char CHAR
Definition: xmlstorage.h:175
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
char * LPSTR
Definition: xmlstorage.h:182
NTSTATUS Status
Definition: csrmsg.h:112
#define UNICODE_NULL
#define ANSI_NULL
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:409
#define NtCurrentPeb()
Definition: FLS.c:19
#define DPRINT1
Definition: precomp.h:8
WCHAR * LPWSTR
Definition: xmlstorage.h:184
CONSOLE_GETSETCONSOLETITLE TitleRequest
Definition: conmsg.h:952
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

Referenced by GetConsoleTitleA(), and GetConsoleTitleW().

◆ IntScrollConsoleScreenBuffer()

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

Definition at line 1883 of file console.c.

1889 {
1890  CONSOLE_API_MESSAGE ApiMessage;
1891  PCONSOLE_SCROLLSCREENBUFFER ScrollScreenBufferRequest = &ApiMessage.Data.ScrollScreenBufferRequest;
1892 
1893  ScrollScreenBufferRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1894  ScrollScreenBufferRequest->OutputHandle = hConsoleOutput;
1895  ScrollScreenBufferRequest->ScrollRectangle = *lpScrollRectangle;
1896 
1897  if (lpClipRectangle != NULL)
1898  {
1899  ScrollScreenBufferRequest->UseClipRectangle = TRUE;
1900  ScrollScreenBufferRequest->ClipRectangle = *lpClipRectangle;
1901  }
1902  else
1903  {
1904  ScrollScreenBufferRequest->UseClipRectangle = FALSE;
1905  }
1906 
1907  ScrollScreenBufferRequest->DestinationOrigin = dwDestinationOrigin;
1908  ScrollScreenBufferRequest->Fill = *lpFill;
1909  ScrollScreenBufferRequest->Unicode = bUnicode;
1910 
1912  NULL,
1914  sizeof(*ScrollScreenBufferRequest));
1915  if (!NT_SUCCESS(ApiMessage.Status))
1916  {
1917  BaseSetLastNTError(ApiMessage.Status);
1918  return FALSE;
1919  }
1920 
1921  return TRUE;
1922 }
SMALL_RECT ScrollRectangle
Definition: conmsg.h:501
SMALL_RECT ClipRectangle
Definition: conmsg.h:502
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
CONSOLE_SCROLLSCREENBUFFER ScrollScreenBufferRequest
Definition: conmsg.h:931
NTSTATUS Status
Definition: csrmsg.h:112
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define NtCurrentPeb()
Definition: FLS.c:19
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

Referenced by ScrollConsoleScreenBufferA(), and ScrollConsoleScreenBufferW().

◆ IntSetConsoleTitle()

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

Definition at line 2245 of file console.c.

2246 {
2247  CONSOLE_API_MESSAGE ApiMessage;
2248  PCONSOLE_GETSETCONSOLETITLE TitleRequest = &ApiMessage.Data.TitleRequest;
2249  PCSR_CAPTURE_BUFFER CaptureBuffer;
2250 
2251  ULONG NumChars = (ULONG)(lpConsoleTitle ? (bUnicode ? wcslen(lpConsoleTitle) : strlen(lpConsoleTitle)) : 0);
2252 
2253  TitleRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2254  TitleRequest->Length = NumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
2255  TitleRequest->Unicode = bUnicode;
2256 
2257  CaptureBuffer = CsrAllocateCaptureBuffer(1, TitleRequest->Length);
2258  if (CaptureBuffer == NULL)
2259  {
2260  DPRINT1("CsrAllocateCaptureBuffer failed!\n");
2262  return FALSE;
2263  }
2264 
2265  CsrCaptureMessageBuffer(CaptureBuffer,
2266  (PVOID)lpConsoleTitle,
2267  TitleRequest->Length,
2268  (PVOID*)&TitleRequest->Title);
2269 
2271  CaptureBuffer,
2273  sizeof(*TitleRequest));
2274 
2275  CsrFreeCaptureBuffer(CaptureBuffer);
2276 
2277  if (!NT_SUCCESS(ApiMessage.Status))
2278  {
2279  BaseSetLastNTError(ApiMessage.Status);
2280  return FALSE;
2281  }
2282 
2283  return TRUE;
2284 }
VOID NTAPI CsrFreeCaptureBuffer(IN PCSR_CAPTURE_BUFFER CaptureBuffer)
Definition: capture.c:189
#define TRUE
Definition: types.h:120
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
PCSR_CAPTURE_BUFFER NTAPI CsrAllocateCaptureBuffer(IN ULONG ArgumentCount, IN ULONG BufferSize)
Definition: capture.c:90
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
char CHAR
Definition: xmlstorage.h:175
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
NTSTATUS Status
Definition: csrmsg.h:112
VOID NTAPI CsrCaptureMessageBuffer(IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer, IN PVOID MessageBuffer OPTIONAL, IN ULONG MessageLength, OUT PVOID *CapturedData)
Definition: capture.c:169
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:409
#define NtCurrentPeb()
Definition: FLS.c:19
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
CONSOLE_GETSETCONSOLETITLE TitleRequest
Definition: conmsg.h:952
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

Referenced by SetConsoleTitleA(), and SetConsoleTitleW().

◆ 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 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
NTSTATUS Status
Definition: csrmsg.h:112
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
CONSOLE_INVALIDATEDIBITS InvalidateDIBitsRequest
Definition: conmsg.h:950
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:409
#define NtCurrentPeb()
Definition: FLS.c:19
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

Referenced by __InvalidateConsoleDIBits().

◆ IsDebuggerPresent()

BOOL WINAPI IsDebuggerPresent ( VOID  )

Definition at line 615 of file debugger.c.

616 {
617  return (BOOL)NtCurrentPeb()->BeingDebugged;
618 }
unsigned int BOOL
Definition: ntddk_ex.h:94
#define NtCurrentPeb()
Definition: FLS.c:19

Referenced by ConsoleControlDispatcher(), init_funcs(), InitThreads(), and wmain().

◆ 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  {
811  return INVALID_HANDLE_VALUE;
812  }
813 
814  if ( (dwDesiredAccess & ~(GENERIC_READ | GENERIC_WRITE)) ||
815  (dwShareMode & ~(FILE_SHARE_READ | FILE_SHARE_WRITE)) )
816  {
818  return INVALID_HANDLE_VALUE;
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);
834  return INVALID_HANDLE_VALUE;
835  }
836 
837  return OpenConsoleRequest->Handle;
838 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
CONSOLE_HANDLE_TYPE HandleType
Definition: conmsg.h:674
static LPCWSTR BaseConOutputFileName
Definition: console.c:26
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:125
CONSOLE_OPENCONSOLE OpenConsoleRequest
Definition: conmsg.h:912
NTSTATUS Status
Definition: csrmsg.h:112
static BOOL bInheritHandle
Definition: pipe.c:82
#define GENERIC_WRITE
Definition: nt_native.h:90
static LPCWSTR BaseConInputFileName
Definition: console.c:25
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
enum _CONSOLE_HANDLE_TYPE CONSOLE_HANDLE_TYPE
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:409
#define GENERIC_READ
Definition: compat.h:124
#define NtCurrentPeb()
Definition: FLS.c:19
HANDLE ConsoleHandle
Definition: conmsg.h:673
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

Referenced by CreateFileW(), and init_function_pointers().

◆ RegisterConsoleIME()

BOOL WINAPI DECLSPEC_HOTPATCH RegisterConsoleIME ( HWND  hWnd,
LPDWORD  ThreadId 
)

Definition at line 3037 of file console.c.

3038 {
3039  STUB;
3040  return FALSE;
3041 }
#define STUB
Definition: kernel32.h:27

◆ RegisterConsoleOS2()

BOOL WINAPI DECLSPEC_HOTPATCH RegisterConsoleOS2 ( BOOL  bUnknown)

Definition at line 3046 of file console.c.

3047 {
3048  STUB;
3049  return FALSE;
3050 }
#define STUB
Definition: kernel32.h:27

◆ RemoveConsoleCtrlHandler()

static BOOL RemoveConsoleCtrlHandler ( PHANDLER_ROUTINE  HandlerRoutine)
static

Definition at line 2074 of file console.c.

2075 {
2076  ULONG i;
2077 
2078  if (HandlerRoutine == NULL)
2079  {
2080  NtCurrentPeb()->ProcessParameters->ConsoleFlags = FALSE;
2081  return TRUE;
2082  }
2083 
2084  for (i = 0; i < NrCtrlHandlers; i++)
2085  {
2086  if (CtrlHandlers[i] == HandlerRoutine)
2087  {
2088  if (i < (NrCtrlHandlers - 1))
2089  {
2091  &CtrlHandlers[i+1],
2092  (NrCtrlHandlers - i + 1) * sizeof(PHANDLER_ROUTINE));
2093  }
2094 
2095  NrCtrlHandlers--;
2096  return TRUE;
2097  }
2098  }
2099 
2101  return FALSE;
2102 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define TRUE
Definition: types.h:120
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
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:409
#define NtCurrentPeb()
Definition: FLS.c:19
BOOL WINAPI HandlerRoutine(DWORD dwCtrlType)
static ULONG NrCtrlHandlers
Definition: console.c:31
unsigned int ULONG
Definition: retypes.h:1
BOOL(CALLBACK * PHANDLER_ROUTINE)(_In_ DWORD)
Definition: wincon.h:222
static PHANDLER_ROUTINE * CtrlHandlers
Definition: console.c:30

Referenced by SetConsoleCtrlHandler().

◆ ScrollConsoleScreenBufferA()

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

Definition at line 1931 of file console.c.

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

Referenced by testScroll().

◆ ScrollConsoleScreenBufferW()

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

Definition at line 1952 of file console.c.

1957 {
1958  return IntScrollConsoleScreenBuffer(hConsoleOutput,
1959  lpScrollRectangle,
1960  lpClipRectangle,
1961  dwDestinationOrigin,
1962  lpFill,
1963  TRUE);
1964 }
#define TRUE
Definition: types.h:120
static BOOL IntScrollConsoleScreenBuffer(HANDLE hConsoleOutput, CONST SMALL_RECT *lpScrollRectangle, CONST SMALL_RECT *lpClipRectangle, COORD dwDestinationOrigin, CONST CHAR_INFO *lpFill, BOOL bUnicode)
Definition: console.c:1883

◆ SetConsoleActiveScreenBuffer()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleActiveScreenBuffer ( HANDLE  hConsoleOutput)

Definition at line 1801 of file console.c.

1802 {
1803  CONSOLE_API_MESSAGE ApiMessage;
1804  PCONSOLE_SETACTIVESCREENBUFFER SetScreenBufferRequest = &ApiMessage.Data.SetScreenBufferRequest;
1805 
1806  SetScreenBufferRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1807  SetScreenBufferRequest->OutputHandle = hConsoleOutput;
1808 
1810  NULL,
1812  sizeof(*SetScreenBufferRequest));
1813  if (!NT_SUCCESS(ApiMessage.Status))
1814  {
1815  BaseSetLastNTError(ApiMessage.Status);
1816  return FALSE;
1817  }
1818 
1819  return TRUE;
1820 }
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
NTSTATUS Status
Definition: csrmsg.h:112
CONSOLE_SETACTIVESCREENBUFFER SetScreenBufferRequest
Definition: conmsg.h:928
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define NtCurrentPeb()
Definition: FLS.c:19
union _CONSOLE_API_MESSAGE::@3381 Data
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

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

◆ SetConsoleCP()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleCP ( UINT  wCodePageID)

Definition at line 2422 of file console.c.

2423 {
2424  CONSOLE_API_MESSAGE ApiMessage;
2425  PCONSOLE_SETINPUTOUTPUTCP SetConsoleCPRequest = &ApiMessage.Data.SetConsoleCPRequest;
2426 
2427  /* Set the Input Code Page */
2428  SetConsoleCPRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2429  SetConsoleCPRequest->CodePage = wCodePageID;
2430  SetConsoleCPRequest->OutputCP = FALSE;
2431  /* SetConsoleCPRequest->EventHandle; */
2432 
2434