ReactOS  0.4.15-dev-4863-gba0d16f
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)
 
VOID SetTEBLangID (VOID)
 Internal helper function used to synchronize the current thread's language ID with the one from the console. More...
 
static BOOL IntGetConsoleKeyboardLayoutName (OUT PVOID pszLayoutName, IN BOOL bAnsi)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetConsoleKeyboardLayoutNameA (OUT LPSTR pszLayoutName)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetConsoleKeyboardLayoutNameW (OUT LPWSTR pszLayoutName)
 
DWORD WINAPI SetLastConsoleEventActive (VOID)
 

Variables

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

Macro Definition Documentation

◆ EXENAME_LENGTH

#define EXENAME_LENGTH   (255 + 1)

Definition at line 40 of file console.c.

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file console.c.

Function Documentation

◆ AddConsoleCtrlHandler()

static BOOL AddConsoleCtrlHandler ( PHANDLER_ROUTINE  HandlerRoutine)
static

Definition at line 2034 of file console.c.

2035 {
2036  PHANDLER_ROUTINE* NewCtrlHandlers = NULL;
2037 
2038  if (HandlerRoutine == NULL)
2039  {
2040  NtCurrentPeb()->ProcessParameters->ConsoleFlags = TRUE;
2041  return TRUE;
2042  }
2043 
2045  {
2046  NewCtrlHandlers = RtlAllocateHeap(RtlGetProcessHeap(),
2047  0,
2048  (NrCtrlHandlers + 4) * sizeof(PHANDLER_ROUTINE));
2049  if (NewCtrlHandlers == NULL)
2050  {
2052  return FALSE;
2053  }
2054 
2055  memmove(NewCtrlHandlers, CtrlHandlers, sizeof(PHANDLER_ROUTINE) * NrCtrlHandlers);
2056 
2057  if (NrAllocatedHandlers > 1) RtlFreeHeap(RtlGetProcessHeap(), 0, CtrlHandlers);
2058 
2059  CtrlHandlers = NewCtrlHandlers;
2060  NrAllocatedHandlers += 4;
2061  }
2062 
2064 
2066  return TRUE;
2067 }
#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:606
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define FALSE
Definition: types.h:117
static ULONG NrAllocatedHandlers
Definition: console.c:32
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
#define ASSERT(a)
Definition: mode.c:44
#define SetLastError(x)
Definition: compat.h:611
#define NtCurrentPeb()
Definition: FLS.c:22
BOOL WINAPI HandlerRoutine(DWORD dwCtrlType)
#define NULL
Definition: types.h:112
static ULONG NrCtrlHandlers
Definition: console.c:31
BOOL(CALLBACK * PHANDLER_ROUTINE)(_In_ DWORD)
Definition: wincon.h:237
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 
1379 
1380  if (NtCurrentPeb()->ProcessParameters->ConsoleHandle)
1381  {
1382  DPRINT1("AllocConsole: Allocating a console to a process already having one\n");
1384  Success = FALSE;
1385  goto Quit;
1386  }
1387 
1388  /* Set up the console properties */
1390  &TitleLength,
1391  &ConsoleTitle,
1392  &DesktopLength,
1393  &Desktop,
1394  &ConsoleStartInfo);
1395  DPRINT("ConsoleTitle = '%S' - Desktop = '%S'\n",
1396  ConsoleTitle, Desktop);
1397 
1398  /* Initialize the Input EXE name */
1399  InitExeName();
1401  &CurDirLength,
1402  &CurDir,
1403  &AppNameLength,
1404  &AppName);
1405  DPRINT("CurDir = '%S' - AppName = '%S'\n",
1406  CurDir, AppName);
1407 
1408  Success = IntAllocConsole(ConsoleTitle,
1409  TitleLength,
1410  Desktop,
1411  DesktopLength,
1412  CurDir,
1413  CurDirLength,
1414  AppName,
1415  AppNameLength,
1418  &ConsoleStartInfo);
1419  if (Success)
1420  {
1421  /* Set up the handles */
1422  SetUpHandles(&ConsoleStartInfo);
1423  InputWaitHandle = ConsoleStartInfo.InputWaitHandle;
1424 
1425  /* Initialize Console Ctrl Handling */
1427 
1428  /* Sync the current thread's LangId with the console's one */
1429  SetTEBLangID();
1430  }
1431 
1432 Quit:
1434  return Success;
1435 }
VOID SetTEBLangID(VOID)
Internal helper function used to synchronize the current thread's language ID with the one from the c...
Definition: console.c:3075
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
uint16_t * PWCHAR
Definition: typedefs.h:56
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 FALSE
Definition: types.h:117
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
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
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
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:34
#define SetLastError(x)
Definition: compat.h:611
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:22
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
#define DPRINT
Definition: sndvol32.h:71

◆ AttachConsole()

BOOL WINAPI AttachConsole ( DWORD  dwProcessId)

Definition at line 2676 of file console.c.

2677 {
2678  BOOL Success;
2679  CONSOLE_START_INFO ConsoleStartInfo;
2680  DWORD dummy;
2681 
2683 
2684  if (NtCurrentPeb()->ProcessParameters->ConsoleHandle)
2685  {
2686  DPRINT1("AttachConsole: Attaching a console to a process already having one\n");
2688  Success = FALSE;
2689  goto Quit;
2690  }
2691 
2692  /* Set up the console properties */
2694  &dummy,
2695  NULL,
2696  &dummy,
2697  NULL,
2698  &ConsoleStartInfo);
2699 
2700  Success = IntAttachConsole(dwProcessId,
2703  &ConsoleStartInfo);
2704  if (Success)
2705  {
2706  /* Set up the handles */
2707  SetUpHandles(&ConsoleStartInfo);
2708  InputWaitHandle = ConsoleStartInfo.InputWaitHandle;
2709 
2710  /* Initialize Console Ctrl Handling */
2712 
2713  /* Sync the current thread's LangId with the console's one */
2714  SetTEBLangID();
2715  }
2716 
2717 Quit:
2719  return Success;
2720 }
VOID SetTEBLangID(VOID)
Internal helper function used to synchronize the current thread's language ID with the one from the c...
Definition: console.c:3075
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
VOID InitializeCtrlHandling(VOID)
Definition: console.c:204
#define FALSE
Definition: types.h:117
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
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:2603
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
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:611
RTL_CRITICAL_SECTION ConsoleLock
Definition: init.c:24
#define NtCurrentPeb()
Definition: FLS.c:22
unsigned char dummy
Definition: maze.c:118
#define NULL
Definition: types.h:112
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:365
NTSTATUS Status
Definition: csrmsg.h:110
#define FALSE
Definition: types.h:117
union _CONSOLE_API_MESSAGE::@3488 Data
HANDLE ConsoleHandle
Definition: conmsg.h:626
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:22
#define NULL
Definition: types.h:112
CONSOLE_CLOSEHANDLE CloseHandleRequest
Definition: conmsg.h:919
#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:69
#define MAXLONG
Definition: umtypes.h:116
#define CTRL_CLOSE_EVENT
Definition: wincon.h:70
#define CTRL_C_EVENT
Definition: wincon.h:68
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
VOID WINAPI ExitProcess(IN UINT uExitCode)
Definition: proc.c:1487
NTSYSAPI VOID NTAPI RtlRaiseException(_In_ PEXCEPTION_RECORD ExceptionRecord)
PVOID ExceptionAddress
Definition: compat.h:211
_SEH2_TRY
Definition: create.c:4226
DWORD ExceptionCode
Definition: compat.h:208
#define FALSE
Definition: types.h:117
HANDLE WINAPI GetCurrentThread(VOID)
Definition: proc.c:1148
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
BOOLEAN ConsoleInitialized
Definition: init.c:25
#define THREAD_PRIORITY_HIGHEST
Definition: winbase.h:274
#define DBG_CONTROL_BREAK
Definition: ntstatus.h:55
VOID WINAPI ExitThread(IN DWORD uExitCode)
Definition: thread.c:365
#define PtrToUlong(u)
Definition: config.h:107
BOOL WINAPI SetThreadPriority(IN HANDLE hThread, IN int nPriority)
Definition: thread.c:700
static BOOL WINAPI DefaultConsoleCtrlHandler(DWORD Event)
Definition: console.c:53
static BOOLEAN LastCloseNotify
Definition: console.c:33
#define ASSERT(a)
Definition: mode.c:44
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DBG_CONTROL_C
Definition: ntstatus.h:52
#define CTRL_LOGOFF_EVENT
Definition: wincon.h:72
#define MINLONG
Definition: umtypes.h:115
struct _EXCEPTION_RECORD * ExceptionRecord
Definition: compat.h:210
_SEH2_END
Definition: create.c:4400
#define CTRL_SHUTDOWN_EVENT
Definition: wincon.h:73
RTL_CRITICAL_SECTION ConsoleLock
Definition: init.c:24
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NtCurrentPeb()
Definition: FLS.c:22
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define CTRL_LAST_CLOSE_EVENT
Definition: wincon.h:71
#define DPRINT1
Definition: precomp.h:8
static ULONG NrCtrlHandlers
Definition: console.c:31
DWORD ExceptionFlags
Definition: compat.h:209
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
#define STATUS_SUCCESS
Definition: shellext.h:65
DWORD NumberParameters
Definition: compat.h:212
#define DPRINT
Definition: sndvol32.h:71
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:960
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:365
HANDLE OutputHandle
Definition: conmsg.h:693
HANDLE ConsoleHandle
Definition: conmsg.h:692
union _CONSOLE_API_MESSAGE::@3488 Data
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
#define NtCurrentPeb()
Definition: FLS.c:22
#define NULL
Definition: types.h:112
#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 2313 of file console.c.

2318 {
2319  CONSOLE_API_MESSAGE ApiMessage;
2320  PCONSOLE_CREATESCREENBUFFER CreateScreenBufferRequest = &ApiMessage.Data.CreateScreenBufferRequest;
2321  PCSR_CAPTURE_BUFFER CaptureBuffer = NULL;
2322  PCONSOLE_GRAPHICS_BUFFER_INFO GraphicsBufferInfo = lpScreenBufferData;
2323 
2324  if ( (dwDesiredAccess & ~(GENERIC_READ | GENERIC_WRITE)) ||
2325  (dwShareMode & ~(FILE_SHARE_READ | FILE_SHARE_WRITE)) ||
2327  {
2329  return INVALID_HANDLE_VALUE;
2330  }
2331 
2332  CreateScreenBufferRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2333  CreateScreenBufferRequest->DesiredAccess = dwDesiredAccess;
2334  CreateScreenBufferRequest->InheritHandle =
2335  (lpSecurityAttributes ? lpSecurityAttributes->bInheritHandle : FALSE);
2336  CreateScreenBufferRequest->ShareMode = dwShareMode;
2337  CreateScreenBufferRequest->ScreenBufferType = dwFlags;
2338 
2340  {
2341  if (CreateScreenBufferRequest->InheritHandle || GraphicsBufferInfo == NULL)
2342  {
2344  return INVALID_HANDLE_VALUE;
2345  }
2346 
2347  CreateScreenBufferRequest->GraphicsBufferInfo = *GraphicsBufferInfo;
2348 
2349  CaptureBuffer = CsrAllocateCaptureBuffer(1, GraphicsBufferInfo->dwBitMapInfoLength);
2350  if (CaptureBuffer == NULL)
2351  {
2353  return INVALID_HANDLE_VALUE;
2354  }
2355 
2356  CsrCaptureMessageBuffer(CaptureBuffer,
2357  (PVOID)GraphicsBufferInfo->lpBitMapInfo,
2358  GraphicsBufferInfo->dwBitMapInfoLength,
2359  (PVOID*)&CreateScreenBufferRequest->GraphicsBufferInfo.lpBitMapInfo);
2360  }
2361 
2363  CaptureBuffer,
2365  sizeof(*CreateScreenBufferRequest));
2366 
2367  if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
2368 
2369  if (!NT_SUCCESS(ApiMessage.Status))
2370  {
2371  BaseSetLastNTError(ApiMessage.Status);
2372  return INVALID_HANDLE_VALUE;
2373  }
2374 
2375  if (dwFlags == CONSOLE_GRAPHICS_BUFFER && GraphicsBufferInfo)
2376  {
2377  GraphicsBufferInfo->hMutex = CreateScreenBufferRequest->hMutex ; // CreateScreenBufferRequest->GraphicsBufferInfo.hMutex ;
2378  GraphicsBufferInfo->lpBitMap = CreateScreenBufferRequest->lpBitMap; // CreateScreenBufferRequest->GraphicsBufferInfo.lpBitMap;
2379  }
2380 
2381  return CreateScreenBufferRequest->OutputHandle;
2382 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
VOID NTAPI CsrFreeCaptureBuffer(IN PCSR_CAPTURE_BUFFER CaptureBuffer)
Definition: capture.c:210
CONSOLE_CREATESCREENBUFFER CreateScreenBufferRequest
Definition: conmsg.h:933
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:365
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:136
NTSTATUS Status
Definition: csrmsg.h:110
VOID NTAPI CsrCaptureMessageBuffer(IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer, IN PVOID MessageBuffer OPTIONAL, IN ULONG MessageLength, OUT PVOID *CapturedData)
Definition: capture.c:190
#define FALSE
Definition: types.h:117
union _CONSOLE_API_MESSAGE::@3488 Data
#define GENERIC_WRITE
Definition: nt_native.h:90
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:611
LPBITMAPINFO lpBitMapInfo
Definition: wincon.h:230
_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:135
#define NtCurrentPeb()
Definition: FLS.c:22
#define CONSOLE_TEXTMODE_BUFFER
Definition: wincon.h:62
#define CONSOLE_GRAPHICS_BUFFER
Definition: wincon.h:63
#define NULL
Definition: types.h:112
#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 CTRL_BREAK_EVENT
Definition: wincon.h:69
#define CTRL_CLOSE_EVENT
Definition: wincon.h:70
#define TRUE
Definition: types.h:120
#define CTRL_C_EVENT
Definition: wincon.h:68
VOID WINAPI ExitProcess(IN UINT uExitCode)
Definition: proc.c:1487
#define CTRL_LOGOFF_EVENT
Definition: wincon.h:72
#define CTRL_SHUTDOWN_EVENT
Definition: wincon.h:73
#define CTRL_LAST_CLOSE_EVENT
Definition: wincon.h:71
#define DPRINT
Definition: sndvol32.h:71
#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:101
DWORD dwOptions
Definition: solitaire.cpp:24
CONSOLE_DUPLICATEHANDLE DuplicateHandleRequest
Definition: conmsg.h:921
#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:365
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
NTSTATUS Status
Definition: csrmsg.h:110
#define DUPLICATE_SAME_ACCESS
static BOOL bInheritHandle
Definition: pipe.c:82
union _CONSOLE_API_MESSAGE::@3488 Data
#define GENERIC_WRITE
Definition: nt_native.h:90
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:611
#define GENERIC_READ
Definition: compat.h:135
#define NtCurrentPeb()
Definition: FLS.c:22
#define NULL
Definition: types.h:112
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

Referenced by DuplicateHandle().

◆ FlushConsoleInputBuffer()

BOOL WINAPI DECLSPEC_HOTPATCH FlushConsoleInputBuffer ( HANDLE  hConsoleInput)

Definition at line 1827 of file console.c.

1828 {
1829  CONSOLE_API_MESSAGE ApiMessage;
1830  PCONSOLE_FLUSHINPUTBUFFER FlushInputBufferRequest = &ApiMessage.Data.FlushInputBufferRequest;
1831 
1832  FlushInputBufferRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1833  FlushInputBufferRequest->InputHandle = hConsoleInput;
1834 
1836  NULL,
1838  sizeof(*FlushInputBufferRequest));
1839  if (!NT_SUCCESS(ApiMessage.Status))
1840  {
1841  BaseSetLastNTError(ApiMessage.Status);
1842  return FALSE;
1843  }
1844 
1845  return TRUE;
1846 }
#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:365
NTSTATUS Status
Definition: csrmsg.h:110
#define FALSE
Definition: types.h:117
union _CONSOLE_API_MESSAGE::@3488 Data
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:22
CONSOLE_FLUSHINPUTBUFFER FlushInputBufferRequest
Definition: conmsg.h:940
#define NULL
Definition: types.h:112
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

◆ FreeConsole()

BOOL WINAPI DECLSPEC_HOTPATCH FreeConsole ( VOID  )

Definition at line 1444 of file console.c.

1445 {
1446  BOOL Success = TRUE;
1447  CONSOLE_API_MESSAGE ApiMessage;
1448  PCONSOLE_FREECONSOLE FreeConsoleRequest = &ApiMessage.Data.FreeConsoleRequest;
1449  HANDLE ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1450 
1452 
1453  /* We must have a non-trivial handle to close */
1454  if (ConsoleHandle == NULL) // IsConsoleHandle(ConsoleHandle)
1455  {
1457  Success = FALSE;
1458  goto Quit;
1459  }
1460 
1461  /* Set up the data to send to the Console Server */
1462  FreeConsoleRequest->ConsoleHandle = ConsoleHandle;
1463 
1464  /* Call the server */
1466  NULL,
1468  sizeof(*FreeConsoleRequest));
1469 
1470  /* Check for success */
1471  if (!NT_SUCCESS(ApiMessage.Status))
1472  {
1473  BaseSetLastNTError(ApiMessage.Status);
1474  Success = FALSE;
1475  goto Quit;
1476  }
1477 
1478  /* Reset the console handle */
1479  NtCurrentPeb()->ProcessParameters->ConsoleHandle = NULL;
1480 
1481  /* Close the associated input handle */
1484 
1485 Quit:
1487  return Success;
1488 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define CloseHandle
Definition: compat.h:598
#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:365
HANDLE ConsoleHandle
Definition: conmsg.h:305
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
NTSTATUS Status
Definition: csrmsg.h:110
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
union _CONSOLE_API_MESSAGE::@3488 Data
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:611
CONSOLE_FREECONSOLE FreeConsoleRequest
Definition: conmsg.h:910
RTL_CRITICAL_SECTION ConsoleLock
Definition: init.c:24
#define NtCurrentPeb()
Definition: FLS.c:22
#define NULL
Definition: types.h:112
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

◆ GenerateConsoleCtrlEvent()

BOOL WINAPI DECLSPEC_HOTPATCH GenerateConsoleCtrlEvent ( DWORD  dwCtrlEvent,
DWORD  dwProcessGroupId 
)

Definition at line 2132 of file console.c.

2134 {
2135  CONSOLE_API_MESSAGE ApiMessage;
2136  PCONSOLE_GENERATECTRLEVENT GenerateCtrlEventRequest = &ApiMessage.Data.GenerateCtrlEventRequest;
2137 
2138  if (dwCtrlEvent != CTRL_C_EVENT && dwCtrlEvent != CTRL_BREAK_EVENT)
2139  {
2141  return FALSE;
2142  }
2143 
2144  GenerateCtrlEventRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2145  GenerateCtrlEventRequest->CtrlEvent = dwCtrlEvent;
2146  GenerateCtrlEventRequest->ProcessGroupId = dwProcessGroupId;
2147 
2149  NULL,
2151  sizeof(*GenerateCtrlEventRequest));
2152  if (!NT_SUCCESS(ApiMessage.Status))
2153  {
2154  BaseSetLastNTError(ApiMessage.Status);
2155  return FALSE;
2156  }
2157 
2158  return TRUE;
2159 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define CTRL_BREAK_EVENT
Definition: wincon.h:69
CONSOLE_GENERATECTRLEVENT GenerateCtrlEventRequest
Definition: conmsg.h:914
#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:365
#define CTRL_C_EVENT
Definition: wincon.h:68
NTSTATUS Status
Definition: csrmsg.h:110
#define FALSE
Definition: types.h:117
union _CONSOLE_API_MESSAGE::@3488 Data
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:611
#define NtCurrentPeb()
Definition: FLS.c:22
#define NULL
Definition: types.h:112
#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 2982 of file console.c.

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

◆ GetConsoleCP()

UINT WINAPI DECLSPEC_HOTPATCH GetConsoleCP ( VOID  )

Definition at line 2391 of file console.c.

2392 {
2393  CONSOLE_API_MESSAGE ApiMessage;
2394  PCONSOLE_GETINPUTOUTPUTCP GetConsoleCPRequest = &ApiMessage.Data.GetConsoleCPRequest;
2395 
2396  /* Get the Input Code Page */
2397  GetConsoleCPRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2398  GetConsoleCPRequest->OutputCP = FALSE;
2399 
2401  NULL,
2403  sizeof(*GetConsoleCPRequest));
2404  if (!NT_SUCCESS(ApiMessage.Status))
2405  {
2406  BaseSetLastNTError(ApiMessage.Status);
2407  return 0;
2408  }
2409 
2410  return GetConsoleCPRequest->CodePage;
2411 }
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:365
NTSTATUS Status
Definition: csrmsg.h:110
#define FALSE
Definition: types.h:117
union _CONSOLE_API_MESSAGE::@3488 Data
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:22
#define NULL
Definition: types.h:112
CONSOLE_GETINPUTOUTPUTCP GetConsoleCPRequest
Definition: conmsg.h:998
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

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

◆ GetConsoleCursorInfo()

BOOL WINAPI GetConsoleCursorInfo ( HANDLE  hConsoleOutput,
PCONSOLE_CURSOR_INFO  lpConsoleCursorInfo 
)

Definition at line 1702 of file console.c.

1704 {
1705  CONSOLE_API_MESSAGE ApiMessage;
1706  PCONSOLE_GETSETCURSORINFO CursorInfoRequest = &ApiMessage.Data.CursorInfoRequest;
1707 
1708  if (!lpConsoleCursorInfo)
1709  {
1710  if (!hConsoleOutput)
1712  else
1714 
1715  return FALSE;
1716  }
1717 
1718  CursorInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1719  CursorInfoRequest->OutputHandle = hConsoleOutput;
1720 
1722  NULL,
1724  sizeof(*CursorInfoRequest));
1725  if (!NT_SUCCESS(ApiMessage.Status))
1726  {
1727  BaseSetLastNTError(ApiMessage.Status);
1728  return FALSE;
1729  }
1730 
1731  *lpConsoleCursorInfo = CursorInfoRequest->Info;
1732 
1733  return TRUE;
1734 }
#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:365
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
CONSOLE_GETSETCURSORINFO CursorInfoRequest
Definition: conmsg.h:928
NTSTATUS Status
Definition: csrmsg.h:110
#define FALSE
Definition: types.h:117
union _CONSOLE_API_MESSAGE::@3488 Data
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:611
#define ERROR_INVALID_ACCESS
Definition: winerror.h:115
#define NtCurrentPeb()
Definition: FLS.c:22
#define NULL
Definition: types.h:112
#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 2991 of file console.c.

2992 {
2993  STUB;
2994  return FALSE;
2995 }
#define FALSE
Definition: types.h:117
#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:101
#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:365
NTSTATUS Status
Definition: csrmsg.h:110
#define FALSE
Definition: types.h:117
union _CONSOLE_API_MESSAGE::@3488 Data
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:944
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:611
#define NtCurrentPeb()
Definition: FLS.c:22
#define NULL
Definition: types.h:112
#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:210
ULONG NTAPI CsrAllocateMessagePointer(IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer, IN ULONG MessageLength, OUT PVOID *CapturedData)
Definition: capture.c:154
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:365
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
NTSTATUS Status
Definition: csrmsg.h:110
union _CONSOLE_API_MESSAGE::@3488 Data
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:950
#define SetLastError(x)
Definition: compat.h:611
#define NtCurrentPeb()
Definition: FLS.c:22
HANDLE ConsoleHandle
Definition: conmsg.h:411
BOOLEAN MaximumWindow
Definition: conmsg.h:413
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
HANDLE OutputHandle
Definition: conmsg.h:412
#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:365
CONSOLE_GETFONTSIZE GetFontSizeRequest
Definition: conmsg.h:951
NTSTATUS Status
Definition: csrmsg.h:110
union _CONSOLE_API_MESSAGE::@3488 Data
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:1337
HANDLE OutputHandle
Definition: conmsg.h:421
#define NtCurrentPeb()
Definition: FLS.c:22
#define NULL
Definition: types.h:112
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:365
NTSTATUS Status
Definition: csrmsg.h:110
#define FALSE
Definition: types.h:117
union _CONSOLE_API_MESSAGE::@3488 Data
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:922
#define NtCurrentPeb()
Definition: FLS.c:22
#define NULL
Definition: types.h:112
#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:101
CONSOLE_GETSETHWSTATE HardwareStateRequest
Definition: conmsg.h:946
#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:365
NTSTATUS Status
Definition: csrmsg.h:110
#define FALSE
Definition: types.h:117
union _CONSOLE_API_MESSAGE::@3488 Data
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:611
#define NtCurrentPeb()
Definition: FLS.c:22
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

◆ GetConsoleInputExeNameA()

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

Definition at line 2944 of file console.c.

2946 {
2947  NTSTATUS Status;
2948  DWORD ExeLength;
2949  UNICODE_STRING BufferU;
2950  ANSI_STRING BufferA;
2952 
2953  /* Get the UNICODE name */
2955 
2956  if ((ExeLength == 0) || (ExeLength >= EXENAME_LENGTH))
2957  return ExeLength;
2958 
2959  /* Initialize the strings for conversion */
2960  RtlInitUnicodeString(&BufferU, Buffer);
2961  BufferA.Length = 0;
2962  BufferA.MaximumLength = (USHORT)nBufferLength;
2963  BufferA.Buffer = lpExeName;
2964 
2965  /* Convert UNICODE name to ANSI, copying as much chars as it can fit */
2966  Status = RtlUnicodeStringToAnsiString(&BufferA, &BufferU, FALSE);
2967  if (!NT_SUCCESS(Status))
2968  {
2970  {
2972  return ExeLength + 1;
2973  }
2975  }
2976 
2977  return ExeLength;
2978 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
LONG NTSTATUS
Definition: precomp.h:26
static DWORD LPSTR lpExeName
Definition: process.c:72
#define FALSE
Definition: types.h:117
#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:3055
DWORD WINAPI DECLSPEC_HOTPATCH GetConsoleInputExeNameW(IN DWORD nBufferLength, OUT LPWSTR lpExeName)
Definition: console.c:2905
Status
Definition: gdiplustypes.h:24
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:611
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
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 2905 of file console.c.

2907 {
2909  {
2910  /* Buffer is not large enough! Return the correct size. */
2912  return ExeNameLength + 1;
2913  }
2914 
2916  _SEH2_TRY
2917  {
2918  /* Copy the input EXE name and NULL-terminate it */
2921  }
2923  {
2925  }
2926  _SEH2_END;
2927 
2928  return TRUE;
2929 }
static RTL_CRITICAL_SECTION ExeNameLock
Definition: console.c:41
static WCHAR ExeNameBuffer[EXENAME_LENGTH]
Definition: console.c:43
#define TRUE
Definition: types.h:120
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
_SEH2_TRY
Definition: create.c:4226
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:3055
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SetLastError(x)
Definition: compat.h:611
_SEH2_END
Definition: create.c:4400
_SEH2_FINALLY
Definition: create.c:4371
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263

Referenced by GetConsoleInputExeNameA().

◆ GetConsoleInputWaitHandle()

HANDLE WINAPI GetConsoleInputWaitHandle ( VOID  )

◆ GetConsoleKeyboardLayoutNameA()

BOOL WINAPI DECLSPEC_HOTPATCH GetConsoleKeyboardLayoutNameA ( OUT LPSTR  pszLayoutName)

Definition at line 3162 of file console.c.

3163 {
3164  return IntGetConsoleKeyboardLayoutName(pszLayoutName, TRUE);
3165 }
#define TRUE
Definition: types.h:120
static BOOL IntGetConsoleKeyboardLayoutName(OUT PVOID pszLayoutName, IN BOOL bAnsi)
Definition: console.c:3114

◆ GetConsoleKeyboardLayoutNameW()

BOOL WINAPI DECLSPEC_HOTPATCH GetConsoleKeyboardLayoutNameW ( OUT LPWSTR  pszLayoutName)

Definition at line 3173 of file console.c.

3174 {
3175  return IntGetConsoleKeyboardLayoutName(pszLayoutName, FALSE);
3176 }
#define FALSE
Definition: types.h:117
static BOOL IntGetConsoleKeyboardLayoutName(OUT PVOID pszLayoutName, IN BOOL bAnsi)
Definition: console.c:3114

◆ GetConsoleMode()

BOOL WINAPI GetConsoleMode ( HANDLE  hConsoleHandle,
LPDWORD  lpMode 
)

Definition at line 1569 of file console.c.

1571 {
1572  CONSOLE_API_MESSAGE ApiMessage;
1573  PCONSOLE_GETSETCONSOLEMODE ConsoleModeRequest = &ApiMessage.Data.ConsoleModeRequest;
1574 
1575  if (lpMode == NULL)
1576  {
1578  return FALSE;
1579  }
1580 
1581  ConsoleModeRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1582  ConsoleModeRequest->Handle = hConsoleHandle;
1583 
1585  NULL,
1587  sizeof(*ConsoleModeRequest));
1588  if (!NT_SUCCESS(ApiMessage.Status))
1589  {
1590  BaseSetLastNTError(ApiMessage.Status);
1591  return FALSE;
1592  }
1593 
1594  *lpMode = ConsoleModeRequest->Mode;
1595 
1596  return TRUE;
1597 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#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:365
NTSTATUS Status
Definition: csrmsg.h:110
#define FALSE
Definition: types.h:117
union _CONSOLE_API_MESSAGE::@3488 Data
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:611
CONSOLE_GETSETCONSOLEMODE ConsoleModeRequest
Definition: conmsg.h:943
#define NtCurrentPeb()
Definition: FLS.c:22
#define NULL
Definition: types.h:112
#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 3009 of file console.c.

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

◆ GetConsoleOutputCP()

UINT WINAPI DECLSPEC_HOTPATCH GetConsoleOutputCP ( VOID  )

Definition at line 2451 of file console.c.

2452 {
2453  CONSOLE_API_MESSAGE ApiMessage;
2454  PCONSOLE_GETINPUTOUTPUTCP GetConsoleCPRequest = &ApiMessage.Data.GetConsoleCPRequest;
2455 
2456  /* Get the Output Code Page */
2457  GetConsoleCPRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2458  GetConsoleCPRequest->OutputCP = TRUE;
2459 
2461  NULL,
2463  sizeof(*GetConsoleCPRequest));
2464  if (!NT_SUCCESS(ApiMessage.Status))
2465  {
2466  BaseSetLastNTError(ApiMessage.Status);
2467  return 0;
2468  }
2469 
2470  return GetConsoleCPRequest->CodePage;
2471 }
#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:365
NTSTATUS Status
Definition: csrmsg.h:110
union _CONSOLE_API_MESSAGE::@3488 Data
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:22
#define NULL
Definition: types.h:112
CONSOLE_GETINPUTOUTPUTCP GetConsoleCPRequest
Definition: conmsg.h:998
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

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

◆ GetConsoleProcessList()

DWORD WINAPI GetConsoleProcessList ( LPDWORD  lpdwProcessList,
DWORD  dwProcessCount 
)

Definition at line 2513 of file console.c.

2515 {
2516  CONSOLE_API_MESSAGE ApiMessage;
2517  PCONSOLE_GETPROCESSLIST GetProcessListRequest = &ApiMessage.Data.GetProcessListRequest;
2518  PCSR_CAPTURE_BUFFER CaptureBuffer;
2519  ULONG nProcesses = 0;
2520 
2521  if (lpdwProcessList == NULL || dwProcessCount == 0)
2522  {
2524  return 0;
2525  }
2526 
2527  CaptureBuffer = CsrAllocateCaptureBuffer(1, dwProcessCount * sizeof(DWORD));
2528  if (CaptureBuffer == NULL)
2529  {
2530  DPRINT1("CsrAllocateCaptureBuffer failed!\n");
2532  return 0;
2533  }
2534 
2535  GetProcessListRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2536  GetProcessListRequest->ProcessCount = dwProcessCount;
2537 
2538  CsrAllocateMessagePointer(CaptureBuffer,
2539  dwProcessCount * sizeof(DWORD),
2540  (PVOID*)&GetProcessListRequest->ProcessIdsList);
2541 
2543  CaptureBuffer,
2545  sizeof(*GetProcessListRequest));
2546  if (!NT_SUCCESS(ApiMessage.Status))
2547  {
2548  BaseSetLastNTError(ApiMessage.Status);
2549  }
2550  else
2551  {
2552  nProcesses = GetProcessListRequest->ProcessCount;
2553  if (dwProcessCount >= nProcesses)
2554  {
2555  RtlCopyMemory(lpdwProcessList, GetProcessListRequest->ProcessIdsList, nProcesses * sizeof(DWORD));
2556  }
2557  }
2558 
2559  CsrFreeCaptureBuffer(CaptureBuffer);
2560  return nProcesses;
2561 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
VOID NTAPI CsrFreeCaptureBuffer(IN PCSR_CAPTURE_BUFFER CaptureBuffer)
Definition: capture.c:210
ULONG NTAPI CsrAllocateMessagePointer(IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer, IN ULONG MessageLength, OUT PVOID *CapturedData)
Definition: capture.c:154
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:365
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
NTSTATUS Status
Definition: csrmsg.h:110
union _CONSOLE_API_MESSAGE::@3488 Data
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:611
#define NtCurrentPeb()
Definition: FLS.c:22
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
CONSOLE_GETPROCESSLIST GetProcessListRequest
Definition: conmsg.h:913
#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 1496 of file console.c.

1498 {
1499  CONSOLE_API_MESSAGE ApiMessage;
1500  PCONSOLE_GETSCREENBUFFERINFO ScreenBufferInfoRequest = &ApiMessage.Data.ScreenBufferInfoRequest;
1501 
1502  if (lpConsoleScreenBufferInfo == NULL)
1503  {
1505  return FALSE;
1506  }
1507 
1508  ScreenBufferInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1509  ScreenBufferInfoRequest->OutputHandle = hConsoleOutput;
1510 
1512  NULL,
1514  sizeof(*ScreenBufferInfoRequest));
1515  if (!NT_SUCCESS(ApiMessage.Status))
1516  {
1517  BaseSetLastNTError(ApiMessage.Status);
1518  return FALSE;
1519  }
1520 
1521  lpConsoleScreenBufferInfo->dwSize = ScreenBufferInfoRequest->ScreenBufferSize;
1522  lpConsoleScreenBufferInfo->dwCursorPosition = ScreenBufferInfoRequest->CursorPosition;
1523  lpConsoleScreenBufferInfo->wAttributes = ScreenBufferInfoRequest->Attributes;
1524  lpConsoleScreenBufferInfo->srWindow.Left = ScreenBufferInfoRequest->ViewOrigin.X;
1525  lpConsoleScreenBufferInfo->srWindow.Top = ScreenBufferInfoRequest->ViewOrigin.Y;
1526  lpConsoleScreenBufferInfo->srWindow.Right = ScreenBufferInfoRequest->ViewOrigin.X + ScreenBufferInfoRequest->ViewSize.X - 1;
1527  lpConsoleScreenBufferInfo->srWindow.Bottom = ScreenBufferInfoRequest->ViewOrigin.Y + ScreenBufferInfoRequest->ViewSize.Y - 1;
1528  lpConsoleScreenBufferInfo->dwMaximumWindowSize = ScreenBufferInfoRequest->MaximumViewSize;
1529 
1530  return TRUE;
1531 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#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:365
NTSTATUS Status
Definition: csrmsg.h:110
#define FALSE
Definition: types.h:117
union _CONSOLE_API_MESSAGE::@3488 Data
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:32
ULONG X
Definition: bl.h:1339
SHORT Bottom
Definition: blue.h:35
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:611
SHORT Top
Definition: blue.h:33
#define NtCurrentPeb()
Definition: FLS.c:22
CONSOLE_GETSCREENBUFFERINFO ScreenBufferInfoRequest
Definition: conmsg.h:935
#define NULL
Definition: types.h:112
SHORT Right
Definition: blue.h:34
ULONG Y
Definition: bl.h:1340
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

◆ GetConsoleSelectionInfo()

BOOL WINAPI GetConsoleSelectionInfo ( PCONSOLE_SELECTION_INFO  lpConsoleSelectionInfo)

Definition at line 2569 of file console.c.

2570 {
2571  CONSOLE_API_MESSAGE ApiMessage;
2572  PCONSOLE_GETSELECTIONINFO GetSelectionInfoRequest = &ApiMessage.Data.GetSelectionInfoRequest;
2573 
2574  if (lpConsoleSelectionInfo == NULL)
2575  {
2577  return FALSE;
2578  }
2579 
2580  GetSelectionInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2581 
2583  NULL,
2585  sizeof(*GetSelectionInfoRequest));
2586  if (!NT_SUCCESS(ApiMessage.Status))
2587  {
2588  BaseSetLastNTError(ApiMessage.Status);
2589  return FALSE;
2590  }
2591 
2592  *lpConsoleSelectionInfo = GetSelectionInfoRequest->Info;
2593 
2594  return TRUE;
2595 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#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:365
NTSTATUS Status
Definition: csrmsg.h:110
#define FALSE
Definition: types.h:117
union _CONSOLE_API_MESSAGE::@3488 Data
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:939
#define SetLastError(x)
Definition: compat.h:611
#define NtCurrentPeb()
Definition: FLS.c:22
#define NULL
Definition: types.h:112
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

◆ GetConsoleTitleA()

DWORD WINAPI DECLSPEC_HOTPATCH GetConsoleTitleA ( LPSTR  lpConsoleTitle,
DWORD  nSize 
)

Definition at line 2235 of file console.c.

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

◆ GetConsoleTitleW()

DWORD WINAPI DECLSPEC_HOTPATCH GetConsoleTitleW ( LPWSTR  lpConsoleTitle,
DWORD  nSize 
)

Definition at line 2222 of file console.c.

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

◆ GetConsoleWindow()

HWND WINAPI DECLSPEC_HOTPATCH GetConsoleWindow ( VOID  )

Definition at line 2729 of file console.c.

2730 {
2731  CONSOLE_API_MESSAGE ApiMessage;
2732  PCONSOLE_GETWINDOW GetWindowRequest = &ApiMessage.Data.GetWindowRequest;
2733 
2734  GetWindowRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2735 
2737  NULL,
2739  sizeof(*GetWindowRequest));
2740  if (!NT_SUCCESS(ApiMessage.Status))
2741  {
2742  BaseSetLastNTError(ApiMessage.Status);
2743  return (HWND)NULL;
2744  }
2745 
2746  return GetWindowRequest->WindowHandle;
2747 }
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:365
NTSTATUS Status
Definition: csrmsg.h:110
union _CONSOLE_API_MESSAGE::@3488 Data
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:22
#define NULL
Definition: types.h:112
CONSOLE_GETWINDOW GetWindowRequest
Definition: conmsg.h:963
#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:365
NTSTATUS Status
Definition: csrmsg.h:110
#define FALSE
Definition: types.h:117
union _CONSOLE_API_MESSAGE::@3488 Data
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:952
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define NtCurrentPeb()
Definition: FLS.c:22
#define NULL
Definition: types.h:112
#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  {
336  ExeLength = 0;
337  }
338 
339  return ExeLength;
340 }
WCHAR * ExeName
static RTL_CRITICAL_SECTION ExeNameLock
Definition: console.c:41
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
unsigned short USHORT
Definition: pedump.c:61
static BOOLEAN ExeNameInitialized
Definition: console.c:42
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define BufferSize
Definition: mmc.h:75
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251

Referenced by IntReadConsole().

◆ GetLargestConsoleWindowSize()

COORD WINAPI DECLSPEC_HOTPATCH GetLargestConsoleWindowSize ( HANDLE  hConsoleOutput)

Definition at line 1673 of file console.c.

1674 {
1675  CONSOLE_API_MESSAGE ApiMessage;
1676  PCONSOLE_GETLARGESTWINDOWSIZE GetLargestWindowSizeRequest = &ApiMessage.Data.GetLargestWindowSizeRequest;
1677 
1678  GetLargestWindowSizeRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1679  GetLargestWindowSizeRequest->OutputHandle = hConsoleOutput;
1680  GetLargestWindowSizeRequest->Size.X = 0;
1681  GetLargestWindowSizeRequest->Size.Y = 0;
1682 
1684  NULL,
1686  sizeof(*GetLargestWindowSizeRequest));
1687  if (!NT_SUCCESS(ApiMessage.Status))
1688  {
1689  BaseSetLastNTError(ApiMessage.Status);
1690  }
1691 
1692  DPRINT("GetLargestConsoleWindowSize, X = %d, Y = %d\n", GetLargestWindowSizeRequest->Size.X, GetLargestWindowSizeRequest->Size.Y);
1693  return GetLargestWindowSizeRequest->Size;
1694 }
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:365
CONSOLE_GETLARGESTWINDOWSIZE GetLargestWindowSizeRequest
Definition: conmsg.h:959
NTSTATUS Status
Definition: csrmsg.h:110
union _CONSOLE_API_MESSAGE::@3488 Data
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:1339
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define NtCurrentPeb()
Definition: FLS.c:22
#define NULL
Definition: types.h:112
#define DPRINT
Definition: sndvol32.h:71
ULONG Y
Definition: bl.h:1340
#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:949
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:365
NTSTATUS Status
Definition: csrmsg.h:110
union _CONSOLE_API_MESSAGE::@3488 Data
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:22
#define NULL
Definition: types.h:112
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15

◆ GetNumberOfConsoleInputEvents()

BOOL WINAPI GetNumberOfConsoleInputEvents ( HANDLE  hConsoleInput,
LPDWORD  lpNumberOfEvents 
)

Definition at line 1635 of file console.c.

1637 {
1638  CONSOLE_API_MESSAGE ApiMessage;
1639  PCONSOLE_GETNUMINPUTEVENTS GetNumInputEventsRequest = &ApiMessage.Data.GetNumInputEventsRequest;
1640 
1641  GetNumInputEventsRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1642  GetNumInputEventsRequest->InputHandle = hConsoleInput;
1643  GetNumInputEventsRequest->NumberOfEvents = 0;
1644 
1646  NULL,
1648  sizeof(*GetNumInputEventsRequest));
1649  if (!NT_SUCCESS(ApiMessage.Status))
1650  {
1651  BaseSetLastNTError(ApiMessage.Status);
1652  return FALSE;
1653  }
1654 
1655  if (lpNumberOfEvents == NULL)
1656  {
1658  return FALSE;
1659  }
1660 
1661  *lpNumberOfEvents = GetNumInputEventsRequest->NumberOfEvents;
1662 
1663  return TRUE;
1664 }
#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:365
NTSTATUS Status
Definition: csrmsg.h:110
#define FALSE
Definition: types.h:117
union _CONSOLE_API_MESSAGE::@3488 Data
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:611
#define ERROR_INVALID_ACCESS
Definition: winerror.h:115
#define NtCurrentPeb()
Definition: FLS.c:22
#define NULL
Definition: types.h:112
CONSOLE_GETNUMINPUTEVENTS GetNumInputEventsRequest
Definition: conmsg.h:971
#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 1771 of file console.c.

1772 {
1773  CONSOLE_API_MESSAGE ApiMessage;
1774  PCONSOLE_GETMOUSEINFO GetMouseInfoRequest = &ApiMessage.Data.GetMouseInfoRequest;
1775 
1776  GetMouseInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
1777 
1779  NULL,
1781  sizeof(*GetMouseInfoRequest));
1782  if (!NT_SUCCESS(ApiMessage.Status))
1783  {
1784  BaseSetLastNTError(ApiMessage.Status);
1785  return FALSE;
1786  }
1787 
1788  *lpNumberOfMouseButtons = GetMouseInfoRequest->NumButtons;
1789  return TRUE;
1790 }
#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:365
NTSTATUS Status
Definition: csrmsg.h:110
#define FALSE
Definition: types.h:117
union _CONSOLE_API_MESSAGE::@3488 Data
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:22
#define NULL
Definition: types.h:112
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15
CONSOLE_GETMOUSEINFO GetMouseInfoRequest
Definition: conmsg.h:930

◆ 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:98
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
#define STD_INPUT_HANDLE
Definition: winbase.h:264
#define STD_ERROR_HANDLE
Definition: winbase.h:266
#define SetLastError(x)
Definition: compat.h:611
#define STD_OUTPUT_HANDLE
Definition: winbase.h:265
#define NtCurrentPeb()
Definition: FLS.c:22
_In_ HANDLE Handle
Definition: extypes.h:390

◆ 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
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:120
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
PRTL_USER_PROCESS_PARAMETERS ProcessParameters
Definition: btrfs_drv.h:1903
#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
Status
Definition: gdiplustypes.h:24
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
__wchar_t WCHAR
Definition: xmlstorage.h:180
NTSYSAPI NTSTATUS NTAPI RtlInitializeCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Definition: btrfs_drv.h:1866
static WCHAR StartDirBuffer[MAX_PATH+1]
Definition: console.c:45
#define NtCurrentPeb()
Definition: FLS.c:22
static BOOLEAN ExeNameInitialized
Definition: console.c:42
PPEB_LDR_DATA Ldr
Definition: btrfs_drv.h:1902
UNICODE_STRING BaseDllName
Definition: ldrtypes.h:145
#define min(a, b)
Definition: monoChain.cc:55
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263

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:210
LPTHREAD_START_ROUTINE PropRoutine
Definition: conmsg.h:286
PCSR_CAPTURE_BUFFER NTAPI CsrAllocateCaptureBuffer(IN ULONG ArgumentCount, IN ULONG BufferSize)
Definition: capture.c:90
#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:365
CONSOLE_ALLOCCONSOLE AllocConsoleRequest
Definition: conmsg.h:908
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:110
VOID NTAPI CsrCaptureMessageBuffer(IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer, IN PVOID MessageBuffer OPTIONAL, IN ULONG MessageLength, OUT PVOID *CapturedData)
Definition: capture.c:190
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
union _CONSOLE_API_MESSAGE::@3488 Data
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
Status
Definition: gdiplustypes.h:24
static const WCHAR Title[]
Definition: oid.c:1259
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:611
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define NtCurrentPeb()
Definition: FLS.c:22
#define NULL
Definition: types.h:112
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
PCONSOLE_START_INFO ConsoleStartInfo
Definition: conmsg.h:274
#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 2603 of file console.c.

2607 {
2608  BOOL Success = TRUE;
2609  NTSTATUS Status;
2610 
2611  CONSOLE_API_MESSAGE ApiMessage;
2612  PCONSOLE_ATTACHCONSOLE AttachConsoleRequest = &ApiMessage.Data.AttachConsoleRequest;
2613  PCSR_CAPTURE_BUFFER CaptureBuffer;
2614 
2615  AttachConsoleRequest->ProcessId = ProcessId;
2616  AttachConsoleRequest->CtrlRoutine = CtrlRoutine;
2617  AttachConsoleRequest->PropRoutine = PropRoutine;
2618 
2619  CaptureBuffer = CsrAllocateCaptureBuffer(1, sizeof(CONSOLE_START_INFO));
2620  if (CaptureBuffer == NULL)
2621  {
2623  Success = FALSE;
2624  goto Quit;
2625  }
2626 
2627  CsrCaptureMessageBuffer(CaptureBuffer,
2628  ConsoleStartInfo,
2629  sizeof(CONSOLE_START_INFO),
2630  (PVOID*)&AttachConsoleRequest->ConsoleStartInfo);
2631 
2633  CaptureBuffer,
2635  sizeof(*AttachConsoleRequest));
2636  if (!NT_SUCCESS(ApiMessage.Status))
2637  {
2638  BaseSetLastNTError(ApiMessage.Status);
2639  Success = FALSE;
2640  goto Quit;
2641  }
2642 
2643  // Is AttachConsoleRequest->ConsoleStartInfo->InitEvents aligned on handle boundary ????
2645  AttachConsoleRequest->ConsoleStartInfo->InitEvents,
2646  WaitAny, FALSE, NULL);
2647  if (!NT_SUCCESS(Status))
2648  {
2650  Success = FALSE;
2651  goto Quit;
2652  }
2653 
2654  NtClose(AttachConsoleRequest->ConsoleStartInfo->InitEvents[INIT_SUCCESS]);
2655  NtClose(AttachConsoleRequest->ConsoleStartInfo->InitEvents[INIT_FAILURE]);
2656  if (Status != INIT_SUCCESS)
2657  {
2658  NtCurrentPeb()->ProcessParameters->ConsoleHandle = NULL;
2659  Success = FALSE;
2660  }
2661  else
2662  {
2663  RtlCopyMemory(ConsoleStartInfo,
2664  AttachConsoleRequest->ConsoleStartInfo,
2665  sizeof(CONSOLE_START_INFO));
2666  Success = TRUE;
2667  }
2668 
2669 Quit:
2670  if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
2671  return Success;
2672 }
VOID NTAPI CsrFreeCaptureBuffer(IN PCSR_CAPTURE_BUFFER CaptureBuffer)
Definition: capture.c:210
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2709
LPTHREAD_START_ROUTINE CtrlRoutine
Definition: conmsg.h:299
PCSR_CAPTURE_BUFFER NTAPI CsrAllocateCaptureBuffer(IN ULONG ArgumentCount, IN ULONG BufferSize)
Definition: capture.c:90
#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:365
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:110
VOID NTAPI CsrCaptureMessageBuffer(IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer, IN PVOID MessageBuffer OPTIONAL, IN ULONG MessageLength, OUT PVOID *CapturedData)
Definition: capture.c:190
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
union _CONSOLE_API_MESSAGE::@3488 Data
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:611
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
CONSOLE_ATTACHCONSOLE AttachConsoleRequest
Definition: conmsg.h:909
LPTHREAD_START_ROUTINE PropRoutine
Definition: conmsg.h:300
#define NtCurrentPeb()
Definition: FLS.c:22
#define NULL
Definition: types.h:112
PCONSOLE_START_INFO ConsoleStartInfo
Definition: conmsg.h:297
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#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:65
#define GENERIC_WRITE
Definition: nt_native.h:90
static LPCWSTR BaseConInputFileName
Definition: console.c:25
static LPCWSTR BaseConFileName
Definition: console.c:24
#define GENERIC_READ
Definition: compat.h:135
#define NULL
Definition: types.h:112
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 3114 of file console.c.

3116 {
3117  CONSOLE_API_MESSAGE ApiMessage;
3118  PCONSOLE_GETKBDLAYOUTNAME GetKbdLayoutNameRequest = &ApiMessage.Data.GetKbdLayoutNameRequest;
3119 
3120  /* Set up the data to send to the Console Server */
3121  GetKbdLayoutNameRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
3122  GetKbdLayoutNameRequest->Ansi = bAnsi;
3123 
3124  /* Call the server */
3126  NULL,
3128  sizeof(*GetKbdLayoutNameRequest));
3129 
3130  /* Check for success */
3131  if (!NT_SUCCESS(ApiMessage.Status))
3132  {
3133  BaseSetLastNTError(ApiMessage.Status);
3134  return FALSE;
3135  }
3136 
3137  /* Retrieve the results */
3138  _SEH2_TRY
3139  {
3140  /* Copy only KL_NAMELENGTH == 9 characters, ANSI or UNICODE */
3141  if (bAnsi)
3142  strncpy(pszLayoutName, (PCHAR)GetKbdLayoutNameRequest->LayoutBuffer, KL_NAMELENGTH);
3143  else
3144  wcsncpy(pszLayoutName, (PWCHAR)GetKbdLayoutNameRequest->LayoutBuffer, KL_NAMELENGTH);
3145  }
3147  {
3149  _SEH2_YIELD(return FALSE);
3150  }
3151  _SEH2_END;
3152 
3153  return TRUE;
3154 }
signed char * PCHAR
Definition: retypes.h:7
#define KL_NAMELENGTH
Definition: winuser.h:122
#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:365
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
uint16_t * PWCHAR
Definition: typedefs.h:56
_SEH2_TRY
Definition: create.c:4226
NTSTATUS Status
Definition: csrmsg.h:110
#define FALSE
Definition: types.h:117
union _CONSOLE_API_MESSAGE::@3488 Data
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 EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define SetLastError(x)
Definition: compat.h:611
#define ERROR_INVALID_ACCESS
Definition: winerror.h:115
_SEH2_END
Definition: create.c:4400
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
#define NtCurrentPeb()
Definition: FLS.c:22
#define NULL
Definition: types.h:112
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:168
CONSOLE_GETKBDLAYOUTNAME GetKbdLayoutNameRequest
Definition: conmsg.h:1001
CHAR LayoutBuffer[KL_NAMELENGTH *sizeof(WCHAR)]
Definition: conmsg.h:871
#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 2163 of file console.c.

2164 {
2165  CONSOLE_API_MESSAGE ApiMessage;
2166  PCONSOLE_GETSETCONSOLETITLE TitleRequest = &ApiMessage.Data.TitleRequest;
2167  PCSR_CAPTURE_BUFFER CaptureBuffer;
2168 
2169  if (dwNumChars == 0) return 0;
2170 
2171  TitleRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2172  TitleRequest->Length = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
2173  TitleRequest->Unicode = bUnicode;
2174 
2175  CaptureBuffer = CsrAllocateCaptureBuffer(1, TitleRequest->Length);
2176  if (CaptureBuffer == NULL)
2177  {
2178  DPRINT1("CsrAllocateCaptureBuffer failed!\n");
2180  return 0;
2181  }
2182 
2183  CsrAllocateMessagePointer(CaptureBuffer,
2184  TitleRequest->Length,
2185  (PVOID*)&TitleRequest->Title);
2186 
2188  CaptureBuffer,
2190  sizeof(*TitleRequest));
2191  if (!NT_SUCCESS(ApiMessage.Status))
2192  {
2193  CsrFreeCaptureBuffer(CaptureBuffer);
2194  BaseSetLastNTError(ApiMessage.Status);
2195  return 0;
2196  }
2197 
2198  dwNumChars = TitleRequest->Length / (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
2199 
2200  if (dwNumChars > 0)
2201  {
2202  RtlCopyMemory(lpConsoleTitle, TitleRequest->Title, TitleRequest->Length);
2203 
2204  if (bUnicode)
2205  ((LPWSTR)lpConsoleTitle)[dwNumChars] = UNICODE_NULL;
2206  else
2207  ((LPSTR)lpConsoleTitle)[dwNumChars] = ANSI_NULL;
2208  }
2209 
2210  CsrFreeCaptureBuffer(CaptureBuffer);
2211 
2212  return dwNumChars;
2213 }
VOID NTAPI CsrFreeCaptureBuffer(IN PCSR_CAPTURE_BUFFER CaptureBuffer)
Definition: capture.c:210
ULONG NTAPI CsrAllocateMessagePointer(IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer, IN ULONG MessageLength, OUT PVOID *CapturedData)
Definition: capture.c:154
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:365
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:110
#define UNICODE_NULL
#define ANSI_NULL
union _CONSOLE_API_MESSAGE::@3488 Data
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:611
#define NtCurrentPeb()
Definition: FLS.c:22
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
WCHAR * LPWSTR
Definition: xmlstorage.h:184
CONSOLE_GETSETCONSOLETITLE TitleRequest
Definition: conmsg.h:958
#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 1881 of file console.c.

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

2244 {
2245  CONSOLE_API_MESSAGE ApiMessage;
2246  PCONSOLE_GETSETCONSOLETITLE TitleRequest = &ApiMessage.Data.TitleRequest;
2247  PCSR_CAPTURE_BUFFER CaptureBuffer;
2248 
2249  ULONG NumChars = (ULONG)(lpConsoleTitle ? (bUnicode ? wcslen(lpConsoleTitle) : strlen(lpConsoleTitle)) : 0);
2250 
2251  TitleRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
2252  TitleRequest->Length = NumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
2253  TitleRequest->Unicode = bUnicode;
2254 
2255  CaptureBuffer = CsrAllocateCaptureBuffer(1, TitleRequest->Length);
2256  if (CaptureBuffer == NULL)
2257  {
2258  DPRINT1("CsrAllocateCaptureBuffer failed!\n");
2260  return FALSE;
2261  }
2262 
2263  CsrCaptureMessageBuffer(CaptureBuffer,
2264  (PVOID)lpConsoleTitle,
2265  TitleRequest->Length,
2266  (PVOID*)&TitleRequest->Title);
2267 
2269  CaptureBuffer,
2271  sizeof(*TitleRequest));
2272 
2273  CsrFreeCaptureBuffer(CaptureBuffer);
2274 
2275  if (!NT_SUCCESS(ApiMessage.Status))
2276  {
2277  BaseSetLastNTError(ApiMessage.Status);
2278  return FALSE;
2279  }
2280 
2281  return TRUE;
2282 }
VOID NTAPI CsrFreeCaptureBuffer(IN PCSR_CAPTURE_BUFFER CaptureBuffer)
Definition: capture.c:210
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
#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:365
char CHAR
Definition: xmlstorage.h:175
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
NTSTATUS Status
Definition: csrmsg.h:110
VOID NTAPI CsrCaptureMessageBuffer(IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer, IN PVOID MessageBuffer OPTIONAL, IN ULONG MessageLength, OUT PVOID *CapturedData)
Definition: capture.c:190
#define FALSE
Definition: types.h:117
union _CONSOLE_API_MESSAGE::@3488 Data
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:611
#define NtCurrentPeb()
Definition: FLS.c:22
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
CONSOLE_GETSETCONSOLETITLE TitleRequest
Definition: conmsg.h:958
#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:101
#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:365
NTSTATUS Status
Definition: csrmsg.h:110
#define FALSE
Definition: types.h:117
union _CONSOLE_API_MESSAGE::@3488 Data
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:956
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:611
#define NtCurrentPeb()
Definition: FLS.c:22
#define NULL
Definition: types.h:112
#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:22

Referenced by _CrtDbgReportWindow(), 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:101
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:365
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:136
CONSOLE_OPENCONSOLE OpenConsoleRequest
Definition: conmsg.h:918
NTSTATUS Status
Definition: csrmsg.h:110
static BOOL bInheritHandle
Definition: pipe.c:82
union _CONSOLE_API_MESSAGE::@3488 Data
#define GENERIC_WRITE
Definition: nt_native.h:90
static LPCWSTR BaseConInputFileName
Definition: console.c:25
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:611
#define GENERIC_READ
Definition: compat.h:135
#define NtCurrentPeb()
Definition: FLS.c:22
#define NULL
Definition: types.h:112
HANDLE ConsoleHandle
Definition: conmsg.h:673
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#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 3036 of file console.c.

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

◆ RegisterConsoleOS2()

BOOL WINAPI DECLSPEC_HOTPATCH RegisterConsoleOS2 ( BOOL  bUnknown)

Definition at line 3045 of file console.c.

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

◆ RemoveConsoleCtrlHandler()

static BOOL RemoveConsoleCtrlHandler ( PHANDLER_ROUTINE  HandlerRoutine)
static

Definition at line 2072 of file console.c.

2073 {
2074  ULONG i;
2075 
2076  if (HandlerRoutine == NULL)
2077  {
2078  NtCurrentPeb()->ProcessParameters->ConsoleFlags = FALSE;
2079  return TRUE;
2080  }
2081 
2082  for (i = 0; i < NrCtrlHandlers; i++)
2083  {
2084  if (CtrlHandlers[i] == HandlerRoutine)
2085  {
2086  if (i < (NrCtrlHandlers - 1))
2087  {
2089  &CtrlHandlers[i+1],
2090  (NrCtrlHandlers - i + 1) * sizeof(PHANDLER_ROUTINE));
2091  }
2092 
2093  NrCtrlHandlers--;
2094  return TRUE;
2095  }
2096  }
2097 
2099  return FALSE;
2100 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define SetLastError(x)
Definition: compat.h:611
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NtCurrentPeb()
Definition: FLS.c:22
BOOL WINAPI HandlerRoutine(DWORD dwCtrlType)
#define NULL
Definition: types.h:112
static ULONG NrCtrlHandlers
Definition: console.c:31
unsigned int ULONG
Definition: retypes.h:1
BOOL(CALLBACK * PHANDLER_ROUTINE)(_In_ DWORD)
Definition: wincon.h:237
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 1929 of file console.c.

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

Referenced by testScroll().

◆ ScrollConsoleScreenBufferW()

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

Definition at line 1950 of file console.c.

1955 {
1956  return IntScrollConsoleScreenBuffer(hConsoleOutput,
1957  lpScrollRectangle,
1958  lpClipRectangle,
1959  dwDestinationOrigin,
1960  lpFill,
1961  TRUE);
1962 }
#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:1881

◆ SetConsoleActiveScreenBuffer()

BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleActiveScreenBuffer ( HANDLE  hConsoleOutput)

Definition at l