xref: /reactos/win32ss/user/winsrv/consrv/api.h (revision 92611107)
1 /*
2  * COPYRIGHT:       See COPYING in the top level directory
3  * PROJECT:         ReactOS Console Server DLL
4  * FILE:            win32ss/user/winsrv/consrv/api.h
5  * PURPOSE:         Public server APIs definitions
6  * PROGRAMMERS:     Hermes Belusca-Maito (hermes.belusca@sfr.fr)
7  */
8 
9 #pragma once
10 
11 /*
12  * Helper macros to define the CSR_API_ROUTINE-s defined in CONSRV,
13  * factoring out the common prologue and epilogue code, and including
14  * the necessary local variables.
15  */
16 
17 #define CON_API_NOCONSOLE_IMPL(Name, TYPE, RequestName)   \
18     NTSTATUS                                    \
19     Name##Impl(                                 \
20         IN PCONSOLE_PROCESS_DATA ProcessData,   \
21         IN OUT PCSR_API_MESSAGE ApiMessage,     \
22         IN TYPE* RequestName, /* Request */     \
23         IN OUT PCSR_REPLY_CODE ReplyCode OPTIONAL)
24 
25 // NTSTATUS NTAPI
26 // Name(
27     // IN OUT PCSR_API_MESSAGE ApiMessage,
28     // IN OUT PCSR_REPLY_CODE  ReplyCode OPTIONAL)
29 #define CON_API_NOCONSOLE_ENTRY(Name, TYPE, RequestName)    \
30     CON_API_NOCONSOLE_IMPL(Name, TYPE, RequestName);        \
31     CSR_API(Name)                               \
32     {                                           \
33         TYPE* RequestName = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.RequestName;  \
34         PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process);    \
35                                                 \
36         return Name##Impl(ProcessData, ApiMessage, RequestName, ReplyCode); \
37     }
38 
39 #define CON_API_NOCONSOLE(Name, TYPE, RequestName)      \
40     CON_API_NOCONSOLE_ENTRY(Name, TYPE, RequestName);   \
41     CON_API_NOCONSOLE_IMPL(Name, TYPE, RequestName)
42 
43 
44 
45 #define CON_API_IMPL(Name, TYPE, RequestName)   \
46     NTSTATUS                                    \
47     Name##Impl(                                 \
48         IN PCONSOLE_PROCESS_DATA ProcessData,   \
49         IN PCONSRV_CONSOLE Console,             \
50         IN OUT PCSR_API_MESSAGE ApiMessage,     \
51         IN TYPE* RequestName, /* Request */     \
52         IN OUT PCSR_REPLY_CODE ReplyCode OPTIONAL)
53 
54 // NTSTATUS NTAPI
55 // Name(
56     // IN OUT PCSR_API_MESSAGE ApiMessage,
57     // IN OUT PCSR_REPLY_CODE  ReplyCode OPTIONAL)
58 #define CON_API_ENTRY(Name, TYPE, RequestName)  \
59     CON_API_IMPL(Name, TYPE, RequestName);      \
60     CSR_API(Name)                               \
61     {                                           \
62         NTSTATUS Status;                        \
63         TYPE* RequestName = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.RequestName;  \
64         PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process);    \
65         PCONSRV_CONSOLE Console;                \
66                                                 \
67         Status = ConSrvGetConsole(ProcessData,  \
68                                   /* RequestName->ConsoleHandle, */   \
69                                   &Console, TRUE);              \
70         if (!NT_SUCCESS(Status))                \
71             return Status;                      \
72                                                 \
73         Status = Name##Impl(ProcessData, Console,                   \
74                             ApiMessage, RequestName, ReplyCode);    \
75                                                 \
76         ConSrvReleaseConsole(Console, TRUE);    \
77         return Status;                          \
78     }
79 
80 #define CON_API(Name, TYPE, RequestName)      \
81     CON_API_ENTRY(Name, TYPE, RequestName);   \
82     CON_API_IMPL(Name, TYPE, RequestName)
83 
84 
85 /*
86  * List of CSR_API_ROUTINE-s defined in this module.
87  */
88 
89 /* alias.c */
90 CSR_API(SrvAddConsoleAlias);
91 CSR_API(SrvGetConsoleAlias);
92 CSR_API(SrvGetConsoleAliases);
93 CSR_API(SrvGetConsoleAliasesLength);
94 CSR_API(SrvGetConsoleAliasExes);
95 CSR_API(SrvGetConsoleAliasExesLength);
96 
97 /* coninput.c */
98 CSR_API(SrvReadConsole);
99 CSR_API(SrvGetConsoleInput);
100 CSR_API(SrvWriteConsoleInput);
101 CSR_API(SrvFlushConsoleInputBuffer);
102 CSR_API(SrvGetConsoleNumberOfInputEvents);
103 
104 /* conoutput.c */
105 CSR_API(SrvInvalidateBitMapRect);
106 CSR_API(SrvSetConsolePalette);
107 CSR_API(SrvReadConsoleOutput);
108 CSR_API(SrvWriteConsole);
109 CSR_API(SrvWriteConsoleOutput);
110 CSR_API(SrvReadConsoleOutputString);
111 CSR_API(SrvWriteConsoleOutputString);
112 CSR_API(SrvFillConsoleOutput);
113 CSR_API(SrvGetConsoleCursorInfo);
114 CSR_API(SrvSetConsoleCursorInfo);
115 CSR_API(SrvSetConsoleCursorPosition);
116 CSR_API(SrvSetConsoleTextAttribute);
117 CSR_API(SrvCreateConsoleScreenBuffer);
118 CSR_API(SrvGetConsoleScreenBufferInfo);
119 CSR_API(SrvSetConsoleActiveScreenBuffer);
120 CSR_API(SrvSetConsoleScreenBufferSize);
121 CSR_API(SrvScrollConsoleScreenBuffer);
122 CSR_API(SrvSetConsoleWindowInfo);
123 
124 /* console.c */
125 CSR_API(SrvAllocConsole);
126 CSR_API(SrvAttachConsole);
127 CSR_API(SrvFreeConsole);
128 CSR_API(SrvGetConsoleMode);
129 CSR_API(SrvSetConsoleMode);
130 CSR_API(SrvGetConsoleTitle);
131 CSR_API(SrvSetConsoleTitle);
132 CSR_API(SrvGetConsoleCP);
133 CSR_API(SrvSetConsoleCP);
134 CSR_API(SrvGetConsoleProcessList);
135 CSR_API(SrvGenerateConsoleCtrlEvent);
136 CSR_API(SrvConsoleNotifyLastClose);
137 
138 CSR_API(SrvGetConsoleMouseInfo);
139 CSR_API(SrvSetConsoleKeyShortcuts);
140 CSR_API(SrvGetConsoleKeyboardLayoutName);
141 CSR_API(SrvGetConsoleCharType);
142 CSR_API(SrvSetConsoleLocalEUDC);
143 CSR_API(SrvSetConsoleCursorMode);
144 CSR_API(SrvGetConsoleCursorMode);
145 CSR_API(SrvGetConsoleNlsMode);
146 CSR_API(SrvSetConsoleNlsMode);
147 CSR_API(SrvGetConsoleLangId);
148 
149 /* frontendctl.c */
150 CSR_API(SrvGetConsoleHardwareState);
151 CSR_API(SrvSetConsoleHardwareState);
152 CSR_API(SrvGetConsoleDisplayMode);
153 CSR_API(SrvSetConsoleDisplayMode);
154 CSR_API(SrvGetLargestConsoleWindowSize);
155 CSR_API(SrvShowConsoleCursor);
156 CSR_API(SrvSetConsoleCursor);
157 CSR_API(SrvConsoleMenuControl);
158 CSR_API(SrvSetConsoleMenuClose);
159 
160 /* Used by USERSRV!SrvGetThreadConsoleDesktop() */
161 NTSTATUS
162 NTAPI
163 GetThreadConsoleDesktop(
164     IN ULONG_PTR ThreadId,
165     OUT HDESK* ConsoleDesktop);
166 
167 CSR_API(SrvGetConsoleWindow);
168 CSR_API(SrvSetConsoleIcon);
169 CSR_API(SrvGetConsoleSelectionInfo);
170 
171 CSR_API(SrvGetConsoleNumberOfFonts);
172 CSR_API(SrvGetConsoleFontInfo);
173 CSR_API(SrvGetConsoleFontSize);
174 CSR_API(SrvGetConsoleCurrentFont);
175 CSR_API(SrvSetConsoleFont);
176 
177 /* handle.c */
178 CSR_API(SrvOpenConsole);
179 CSR_API(SrvDuplicateHandle);
180 CSR_API(SrvGetHandleInformation);
181 CSR_API(SrvSetHandleInformation);
182 CSR_API(SrvCloseHandle);
183 CSR_API(SrvVerifyConsoleIoHandle);
184 
185 /* history.c */
186 CSR_API(SrvGetConsoleCommandHistory);
187 CSR_API(SrvGetConsoleCommandHistoryLength);
188 CSR_API(SrvExpungeConsoleCommandHistory);
189 CSR_API(SrvSetConsoleNumberOfCommands);
190 CSR_API(SrvGetConsoleHistory);
191 CSR_API(SrvSetConsoleHistory);
192 CSR_API(SrvSetConsoleCommandHistoryMode);
193 
194 /* subsysreg.c */
195 CSR_API(SrvRegisterConsoleVDM);
196 CSR_API(SrvVDMConsoleOperation);
197 CSR_API(SrvRegisterConsoleOS2);
198 CSR_API(SrvSetConsoleOS2OemFormat);
199 CSR_API(SrvRegisterConsoleIME);
200 CSR_API(SrvUnregisterConsoleIME);
201 
202 /* EOF */
203