6 #include <csrss/csrss.h>
8 /* Object type magic numbers */
10 #define CSRSS_CONSOLE_MAGIC 1
11 #define CSRSS_SCREEN_BUFFER_MAGIC 2
13 typedef struct Object_tt
19 typedef struct ConsoleInput_t
22 INPUT_RECORD InputEvent;
23 BOOLEAN Echoed; // already been echoed or not
27 /************************************************************************
28 * Screen buffer structure represents the win32 screen buffer object. *
29 * Internally, the portion of the buffer being shown CAN loop past the *
30 * bottom of the virtual buffer and wrap around to the top. Win32 does *
31 * not do this. I decided to do this because it eliminates the need to *
32 * do a massive memcpy() to scroll the contents of the buffer up to *
33 * scroll the screen on output, instead I just shift down the position *
34 * to be displayed, and let it wrap around to the top again. *
35 * The VirtualX member keeps track of the top X coord that win32 *
36 * clients THINK is currently being displayed, because they think that *
37 * when the display reaches the bottom of the buffer and another line *
38 * being printed causes another line to scroll down, that the buffer IS *
39 * memcpy()'s up, and the bottom of the buffer is still displayed, but *
40 * internally, I just wrap back to the top of the buffer. *
41 ***********************************************************************/
43 typedef struct CSRSS_SCREEN_BUFFER_t
45 Object_t Header; /* Object header */
46 BYTE *Buffer; /* pointer to screen buffer */
47 USHORT MaxX, MaxY; /* size of the entire scrollback buffer */
48 USHORT ShowX, ShowY; /* beginning offset for the actual display area */
49 ULONG CurrentX; /* Current X cursor position */
50 ULONG CurrentY; /* Current Y cursor position */
51 BYTE DefaultAttrib; /* default char attribute */
52 USHORT VirtualX; /* top row of buffer being displayed, reported to callers */
53 CONSOLE_CURSOR_INFO CursorInfo;
55 } CSRSS_SCREEN_BUFFER, *PCSRSS_SCREEN_BUFFER;
57 typedef struct CSRSS_CONSOLE_t
59 Object_t Header; /* Object header */
60 struct CSRSS_CONSOLE_t *Prev, *Next; /* Next and Prev consoles in console wheel */
62 LIST_ENTRY InputEvents; /* List head for input event queue */
64 WORD WaitingLines; /* number of chars and lines in input queue */
65 PCSRSS_SCREEN_BUFFER ActiveBuffer; /* Pointer to currently active screen buffer */
66 WORD Mode; /* Console mode flags */
67 WORD EchoCount; /* count of chars to echo, in line buffered mode */
68 UNICODE_STRING Title; /* Title of console */
69 struct { /* active code pages */
73 BOOL EarlyReturn; /* wake client and return data, even if we are in line buffered mode, and we don't have a complete line */
74 } CSRSS_CONSOLE, *PCSRSS_CONSOLE;
76 typedef struct _CSRSS_PROCESS_DATA
78 PCSRSS_CONSOLE Console;
79 ULONG HandleTableSize;
80 Object_t ** HandleTable;
85 PVOID CsrSectionViewBase;
86 ULONG CsrSectionViewSize;
87 struct _CSRSS_PROCESS_DATA * next;
88 } CSRSS_PROCESS_DATA, *PCSRSS_PROCESS_DATA;
90 #define CSR_API(n) NTSTATUS n (\
91 PCSRSS_PROCESS_DATA ProcessData,\
92 PCSRSS_API_REQUEST Request,\
93 PCSRSS_API_REPLY Reply)
96 CSR_API(CsrConnectProcess);
97 CSR_API(CsrCreateProcess);
98 CSR_API(CsrTerminateProcess);
101 CSR_API(CsrWriteConsole);
102 CSR_API(CsrAllocConsole);
103 CSR_API(CsrFreeConsole);
104 CSR_API(CsrReadConsole);
105 CSR_API(CsrConnectProcess);
106 CSR_API(CsrGetScreenBufferInfo);
107 CSR_API(CsrSetCursor);
108 CSR_API(CsrFillOutputChar);
109 CSR_API(CsrReadInputEvent);
110 CSR_API(CsrWriteConsoleOutputChar);
111 CSR_API(CsrWriteConsoleOutputAttrib);
112 CSR_API(CsrFillOutputAttrib);
113 CSR_API(CsrGetCursorInfo);
114 CSR_API(CsrSetCursorInfo);
115 CSR_API(CsrSetTextAttrib);
116 CSR_API(CsrSetConsoleMode);
117 CSR_API(CsrGetConsoleMode);
118 CSR_API(CsrCreateScreenBuffer);
119 CSR_API(CsrSetScreenBuffer);
120 CSR_API(CsrSetTitle);
121 CSR_API(CsrGetTitle);
122 CSR_API(CsrWriteConsoleOutput);
123 CSR_API(CsrFlushInputBuffer);
124 CSR_API(CsrScrollConsoleScreenBuffer);
125 CSR_API(CsrReadConsoleOutputChar);
126 CSR_API(CsrReadConsoleOutputAttrib);
127 CSR_API(CsrGetNumberOfConsoleInputEvents);
128 CSR_API(CsrRegisterServicesProcess);
129 CSR_API(CsrExitReactos);
130 CSR_API(CsrGetShutdownParameters);
131 CSR_API(CsrSetShutdownParameters);
132 CSR_API(CsrPeekConsoleInput);
133 CSR_API(CsrReadConsoleOutput);
134 CSR_API(CsrWriteConsoleInput);
137 VOID STDCALL DisplayString(LPCWSTR lpwString);
138 VOID STDCALL PrintString (char* fmt, ...);
141 VOID Thread_Api(PVOID PortHandle);
142 VOID Console_Api( DWORD Ignored );
144 extern HANDLE CsrssApiHeap;
147 NTSTATUS STDCALL CsrInitConsole(PCSRSS_CONSOLE Console);
148 VOID STDCALL CsrDeleteConsole( PCSRSS_CONSOLE Console );
149 VOID STDCALL CsrDeleteScreenBuffer( PCSRSS_SCREEN_BUFFER Buffer );
150 NTSTATUS STDCALL CsrInitConsoleScreenBuffer( PCSRSS_SCREEN_BUFFER Console );
151 VOID STDCALL CsrInitConsoleSupport(VOID);
154 VOID STDCALL CsrInitProcessData(VOID);
155 PCSRSS_PROCESS_DATA STDCALL CsrGetProcessData(ULONG ProcessId);
156 NTSTATUS STDCALL CsrFreeProcessData( ULONG Pid );
159 NTSTATUS STDCALL CsrInsertObject( PCSRSS_PROCESS_DATA ProcessData, PHANDLE Handle, Object_t *Object );
160 NTSTATUS STDCALL CsrGetObject( PCSRSS_PROCESS_DATA ProcessData, HANDLE Handle, Object_t **Object );
161 BOOL STDCALL CsrServerInitialization (ULONG ArgumentCount, PWSTR *ArgumentArray);
162 NTSTATUS STDCALL CsrReleaseObject( PCSRSS_PROCESS_DATA ProcessData, HANDLE Object );
163 VOID STDCALL CsrDrawConsole( PCSRSS_SCREEN_BUFFER Console );
164 NTSTATUS STDCALL CsrpWriteConsole( PCSRSS_SCREEN_BUFFER Buff, CHAR *Buffer, DWORD Length, BOOL Attrib );
166 #endif /* ndef _CSRSS_API_H */