[CONSRV]
[reactos.git] / win32ss / user / consrv / consrv.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Console Server DLL
4 * FILE: win32ss/user/consrv/consrv.h
5 * PURPOSE: Main header - Definitions
6 * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca@sfr.fr)
7 */
8
9 #ifndef __CONSRV_H__
10 #define __CONSRV_H__
11
12 #pragma once
13
14 /* PSDK/NDK Headers */
15 #define WIN32_NO_STATUS
16 #include <windows.h>
17 #define NTOS_MODE_USER
18 #include <ndk/ntndk.h>
19
20 /* Public Win32K Headers */
21 #include <ntuser.h>
22
23 /* CSRSS Header */
24 #include <csr/csrsrv.h>
25
26 /* CONSOLE Headers */
27 #include <win/console.h>
28 #include <win/conmsg.h>
29
30 #include "resource.h"
31
32 /* Shared header with console.dll */
33 #include "console.h"
34
35
36 extern HINSTANCE ConSrvDllInstance;
37 extern HANDLE ConSrvHeap;
38 // extern HANDLE BaseSrvSharedHeap;
39 // extern PBASE_STATIC_SERVER_DATA BaseStaticServerData;
40
41 /* Object type magic numbers */
42 #define CONIO_INPUT_BUFFER_MAGIC 0x00000001 // --> Input-type handles
43 #define CONIO_SCREEN_BUFFER_MAGIC 0x00000002 // --> Output-type handles
44
45 /* Common things to input/output/console objects */
46 typedef struct Object_tt
47 {
48 ULONG Type;
49 struct _CONSOLE *Console;
50 LONG AccessRead, AccessWrite;
51 LONG ExclusiveRead, ExclusiveWrite;
52 LONG HandleCount;
53 } Object_t;
54
55
56 typedef struct _CONSOLE_IO_HANDLE
57 {
58 Object_t *Object; /* The object on which the handle points to */
59 DWORD Access;
60 BOOL Inheritable;
61 DWORD ShareMode;
62 } CONSOLE_IO_HANDLE, *PCONSOLE_IO_HANDLE;
63
64
65 #define ConsoleGetPerProcessData(Process) \
66 ((PCONSOLE_PROCESS_DATA)((Process)->ServerData[CONSRV_SERVERDLL_INDEX]))
67
68 typedef struct _CONSOLE_PROCESS_DATA
69 {
70 LIST_ENTRY ConsoleLink;
71 PCSR_PROCESS Process; // Process owning this structure.
72 HANDLE ConsoleEvent;
73 /* PCONSOLE */ struct _CONSOLE* Console;
74 /* PCONSOLE */ struct _CONSOLE* ParentConsole;
75
76 BOOL ConsoleApp; // TRUE if it is a CUI app, FALSE otherwise.
77
78 RTL_CRITICAL_SECTION HandleTableLock;
79 ULONG HandleTableSize;
80 PCONSOLE_IO_HANDLE HandleTable; // Length-varying table
81
82 LPTHREAD_START_ROUTINE CtrlDispatcher;
83 } CONSOLE_PROCESS_DATA, *PCONSOLE_PROCESS_DATA;
84
85
86 /* alias.c */
87 CSR_API(SrvAddConsoleAlias);
88 CSR_API(SrvGetConsoleAlias);
89 CSR_API(SrvGetConsoleAliases);
90 CSR_API(SrvGetConsoleAliasesLength);
91 CSR_API(SrvGetConsoleAliasExes);
92 CSR_API(SrvGetConsoleAliasExesLength);
93
94 /* coninput.c */
95 CSR_API(SrvGetConsoleInput);
96 CSR_API(SrvWriteConsoleInput);
97 CSR_API(SrvReadConsole);
98 CSR_API(SrvFlushConsoleInputBuffer);
99 CSR_API(SrvGetConsoleNumberOfInputEvents);
100
101 /* conoutput.c */
102 CSR_API(SrvReadConsoleOutput);
103 CSR_API(SrvWriteConsoleOutput);
104 CSR_API(SrvReadConsoleOutputString);
105 CSR_API(SrvWriteConsoleOutputString);
106 CSR_API(SrvFillConsoleOutput);
107 CSR_API(SrvWriteConsole);
108 CSR_API(SrvSetConsoleCursorPosition);
109 CSR_API(SrvGetConsoleCursorInfo);
110 CSR_API(SrvSetConsoleCursorInfo);
111 CSR_API(SrvSetConsoleTextAttribute);
112 CSR_API(SrvCreateConsoleScreenBuffer);
113 CSR_API(SrvGetConsoleScreenBufferInfo);
114 CSR_API(SrvSetConsoleActiveScreenBuffer);
115 CSR_API(SrvScrollConsoleScreenBuffer);
116 CSR_API(SrvSetConsoleScreenBufferSize);
117
118 /* console.c */
119 CSR_API(SrvOpenConsole);
120 CSR_API(SrvAllocConsole);
121 CSR_API(SrvAttachConsole);
122 CSR_API(SrvFreeConsole);
123 CSR_API(SrvSetConsoleMode);
124 CSR_API(SrvGetConsoleMode);
125 CSR_API(SrvSetConsoleTitle);
126 CSR_API(SrvGetConsoleTitle);
127 CSR_API(SrvGetConsoleHardwareState);
128 CSR_API(SrvSetConsoleHardwareState);
129 CSR_API(SrvGetConsoleWindow);
130 CSR_API(SrvSetConsoleIcon);
131 CSR_API(SrvGetConsoleCP);
132 CSR_API(SrvSetConsoleCP);
133 CSR_API(SrvGetConsoleProcessList);
134 CSR_API(SrvGenerateConsoleCtrlEvent);
135 CSR_API(SrvGetConsoleSelectionInfo);
136
137 /* handle.c */
138 CSR_API(SrvCloseHandle);
139 CSR_API(SrvVerifyConsoleIoHandle);
140 CSR_API(SrvDuplicateHandle);
141 /// CSR_API(CsrGetInputWaitHandle);
142
143 NTSTATUS FASTCALL Win32CsrInitHandlesTable(IN OUT PCONSOLE_PROCESS_DATA ProcessData,
144 OUT PHANDLE pInputHandle,
145 OUT PHANDLE pOutputHandle,
146 OUT PHANDLE pErrorHandle);
147 NTSTATUS FASTCALL Win32CsrInheritHandlesTable(IN PCONSOLE_PROCESS_DATA SourceProcessData,
148 IN PCONSOLE_PROCESS_DATA TargetProcessData);
149 VOID FASTCALL Win32CsrFreeHandlesTable(PCONSOLE_PROCESS_DATA ProcessData);
150 NTSTATUS FASTCALL Win32CsrInsertObject(PCONSOLE_PROCESS_DATA ProcessData,
151 PHANDLE Handle,
152 Object_t *Object,
153 DWORD Access,
154 BOOL Inheritable,
155 DWORD ShareMode);
156 NTSTATUS FASTCALL Win32CsrLockObject(PCONSOLE_PROCESS_DATA ProcessData,
157 HANDLE Handle,
158 Object_t** Object,
159 PCONSOLE_IO_HANDLE* Entry OPTIONAL,
160 DWORD Access,
161 BOOL LockConsole,
162 ULONG Type);
163 VOID FASTCALL Win32CsrUnlockObject(Object_t *Object,
164 BOOL IsConsoleLocked);
165 VOID FASTCALL Win32CsrUnlockConsole(struct _CONSOLE* Console,
166 BOOL IsConsoleLocked);
167 NTSTATUS FASTCALL Win32CsrReleaseObject(PCONSOLE_PROCESS_DATA ProcessData,
168 HANDLE Handle);
169
170 NTSTATUS FASTCALL Win32CsrAllocateConsole(PCONSOLE_PROCESS_DATA ProcessData,
171 PHANDLE pInputHandle,
172 PHANDLE pOutputHandle,
173 PHANDLE pErrorHandle,
174 int ShowCmd,
175 PCSR_PROCESS CsrProcess);
176 VOID FASTCALL Win32CsrReleaseConsole(PCONSOLE_PROCESS_DATA ProcessData);
177 NTSTATUS FASTCALL ConioConsoleFromProcessData(PCONSOLE_PROCESS_DATA ProcessData,
178 struct _CONSOLE** Console,
179 BOOL LockConsole);
180
181 NTSTATUS NTAPI ConsoleNewProcess(PCSR_PROCESS SourceProcess,
182 PCSR_PROCESS TargetProcess);
183 NTSTATUS NTAPI ConsoleConnect(IN PCSR_PROCESS CsrProcess,
184 IN OUT PVOID ConnectionInfo,
185 IN OUT PULONG ConnectionInfoLength);
186 VOID NTAPI ConsoleDisconnect(PCSR_PROCESS Process);
187
188 /* lineinput.c */
189 CSR_API(SrvGetConsoleCommandHistoryLength);
190 CSR_API(SrvGetConsoleCommandHistory);
191 CSR_API(SrvExpungeConsoleCommandHistory);
192 CSR_API(SrvSetConsoleNumberOfCommands);
193 CSR_API(SrvGetConsoleHistory);
194 CSR_API(SrvSetConsoleHistory);
195
196 #endif // __CONSRV_H__
197
198 /* EOF */