[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_CONSOLE_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 LONG 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(pcsrprocess) \
66 ((PCONSOLE_PROCESS_DATA)((pcsrprocess)->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 bInheritHandles;
77 BOOL ConsoleApp; // TRUE if it is a CUI app, FALSE otherwise.
78
79 RTL_CRITICAL_SECTION HandleTableLock;
80 ULONG HandleTableSize;
81 PCONSOLE_IO_HANDLE HandleTable; // Length-varying table
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(SrvFreeConsole);
122 CSR_API(SrvSetConsoleMode);
123 CSR_API(SrvGetConsoleMode);
124 CSR_API(SrvSetConsoleTitle);
125 CSR_API(SrvGetConsoleTitle);
126 CSR_API(SrvGetConsoleHardwareState);
127 CSR_API(SrvSetConsoleHardwareState);
128 CSR_API(SrvGetConsoleWindow);
129 CSR_API(SrvSetConsoleIcon);
130 CSR_API(SrvGetConsoleCP);
131 CSR_API(SrvSetConsoleCP);
132 CSR_API(SrvGetConsoleProcessList);
133 CSR_API(SrvGenerateConsoleCtrlEvent);
134 CSR_API(SrvGetConsoleSelectionInfo);
135
136 /* handle.c */
137 CSR_API(SrvCloseHandle);
138 CSR_API(SrvVerifyConsoleIoHandle);
139 CSR_API(SrvDuplicateHandle);
140 /// CSR_API(CsrGetInputWaitHandle);
141
142 NTSTATUS FASTCALL Win32CsrInsertObject(PCONSOLE_PROCESS_DATA ProcessData,
143 PHANDLE Handle,
144 Object_t *Object,
145 DWORD Access,
146 BOOL Inheritable,
147 DWORD ShareMode);
148 NTSTATUS FASTCALL Win32CsrLockObject(PCONSOLE_PROCESS_DATA ProcessData,
149 HANDLE Handle,
150 Object_t **Object,
151 DWORD Access,
152 LONG Type);
153 VOID FASTCALL Win32CsrUnlockObject(Object_t *Object);
154 NTSTATUS FASTCALL Win32CsrReleaseObject(PCONSOLE_PROCESS_DATA ProcessData,
155 HANDLE Handle);
156
157 NTSTATUS NTAPI ConsoleNewProcess(PCSR_PROCESS SourceProcess,
158 PCSR_PROCESS TargetProcess);
159 NTSTATUS NTAPI ConsoleConnect(IN PCSR_PROCESS CsrProcess,
160 IN OUT PVOID ConnectionInfo,
161 IN OUT PULONG ConnectionInfoLength);
162 VOID NTAPI ConsoleDisconnect(PCSR_PROCESS Process);
163 VOID NTAPI Win32CsrReleaseConsole(PCSR_PROCESS Process);
164
165 /* lineinput.c */
166 CSR_API(SrvGetConsoleCommandHistoryLength);
167 CSR_API(SrvGetConsoleCommandHistory);
168 CSR_API(SrvExpungeConsoleCommandHistory);
169 CSR_API(SrvSetConsoleNumberOfCommands);
170 CSR_API(SrvGetConsoleHistory);
171 CSR_API(SrvSetConsoleHistory);
172
173 #endif // __CONSRV_H__
174
175 /* EOF */