ed5a18ea496c8a6c26bb25059ae512d1bc3b3f40
[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 /* CSRSS Header */
21 #include <csr/csrsrv.h>
22
23 /* CONSOLE Headers */
24 #include <win/console.h>
25 #include <win/conmsg.h>
26
27 #include "resource.h"
28
29 /* Shared header with console.dll */
30 #include "console.h"
31
32
33 extern HINSTANCE ConSrvDllInstance;
34 extern HANDLE ConSrvHeap;
35 // extern HANDLE BaseSrvSharedHeap;
36 // extern PBASE_STATIC_SERVER_DATA BaseStaticServerData;
37
38 /* Object type magic numbers */
39 #define CONIO_CONSOLE_MAGIC 0x00000001 // --> Input-type handles
40 #define CONIO_SCREEN_BUFFER_MAGIC 0x00000002 // --> Output-type handles
41
42 /* Common things to input/output/console objects */
43 typedef struct Object_tt
44 {
45 LONG Type;
46 struct tagCSRSS_CONSOLE *Console;
47 LONG AccessRead, AccessWrite;
48 LONG ExclusiveRead, ExclusiveWrite;
49 LONG HandleCount;
50 } Object_t;
51
52
53 typedef struct _CSRSS_HANDLE
54 {
55 Object_t *Object; /* The object on which the handle points to */
56 DWORD Access;
57 BOOL Inheritable;
58 DWORD ShareMode;
59 } CSRSS_HANDLE, *PCSRSS_HANDLE;
60
61
62 #define ConsoleGetPerProcessData(pcsrprocess) \
63 ((PCONSOLE_PROCESS_DATA)((pcsrprocess)->ServerData[CONSRV_SERVERDLL_INDEX]))
64
65 typedef struct _CONSOLE_PROCESS_DATA
66 {
67 LIST_ENTRY ConsoleLink;
68 PCSR_PROCESS Process; // Process owning this structure.
69 HANDLE ConsoleEvent;
70 /* PCSRSS_CONSOLE */ struct tagCSRSS_CONSOLE* Console;
71 /* PCSRSS_CONSOLE */ struct tagCSRSS_CONSOLE* ParentConsole;
72
73 // BOOL bInheritHandles;
74 BOOL ConsoleApp; // TRUE if it is a CUI app, FALSE otherwise.
75
76 RTL_CRITICAL_SECTION HandleTableLock;
77 ULONG HandleTableSize;
78 PCSRSS_HANDLE HandleTable; // Length-varying table
79 LPTHREAD_START_ROUTINE CtrlDispatcher;
80 } CONSOLE_PROCESS_DATA, *PCONSOLE_PROCESS_DATA;
81
82
83 /* alias.c */
84 CSR_API(SrvAddConsoleAlias);
85 CSR_API(SrvGetConsoleAlias);
86 CSR_API(SrvGetConsoleAliases);
87 CSR_API(SrvGetConsoleAliasesLength);
88 CSR_API(SrvGetConsoleAliasExes);
89 CSR_API(SrvGetConsoleAliasExesLength);
90
91 /* coninput.c */
92 CSR_API(SrvGetConsoleInput);
93 CSR_API(SrvWriteConsoleInput);
94 CSR_API(SrvReadConsole);
95 CSR_API(SrvFlushConsoleInputBuffer);
96 CSR_API(SrvGetConsoleNumberOfInputEvents);
97
98 /* conoutput.c */
99 CSR_API(SrvReadConsoleOutput);
100 CSR_API(SrvWriteConsoleOutput);
101 CSR_API(SrvReadConsoleOutputString);
102 CSR_API(SrvWriteConsoleOutputString);
103 CSR_API(SrvFillConsoleOutput);
104 CSR_API(SrvWriteConsole);
105 CSR_API(SrvSetConsoleCursorPosition);
106 CSR_API(SrvGetConsoleCursorInfo);
107 CSR_API(SrvSetConsoleCursorInfo);
108 CSR_API(SrvSetConsoleTextAttribute);
109 CSR_API(SrvCreateConsoleScreenBuffer);
110 CSR_API(SrvGetConsoleScreenBufferInfo);
111 CSR_API(SrvSetConsoleActiveScreenBuffer);
112 CSR_API(SrvScrollConsoleScreenBuffer);
113 CSR_API(SrvSetConsoleScreenBufferSize);
114
115 /* console.c */
116 CSR_API(SrvOpenConsole);
117 CSR_API(SrvAllocConsole);
118 CSR_API(SrvFreeConsole);
119 CSR_API(SrvSetConsoleMode);
120 CSR_API(SrvGetConsoleMode);
121 CSR_API(SrvSetConsoleTitle);
122 CSR_API(SrvGetConsoleTitle);
123 CSR_API(SrvGetConsoleHardwareState);
124 CSR_API(SrvSetConsoleHardwareState);
125 CSR_API(SrvGetConsoleWindow);
126 CSR_API(SrvSetConsoleIcon);
127 CSR_API(SrvGetConsoleCP);
128 CSR_API(SrvSetConsoleCP);
129 CSR_API(SrvGetConsoleProcessList);
130 CSR_API(SrvGenerateConsoleCtrlEvent);
131 CSR_API(SrvGetConsoleSelectionInfo);
132
133 /* handle.c */
134 CSR_API(SrvCloseHandle);
135 CSR_API(SrvVerifyConsoleIoHandle);
136 CSR_API(SrvDuplicateHandle);
137 /// CSR_API(CsrGetInputWaitHandle);
138
139 NTSTATUS FASTCALL Win32CsrInsertObject(PCONSOLE_PROCESS_DATA ProcessData,
140 PHANDLE Handle,
141 Object_t *Object,
142 DWORD Access,
143 BOOL Inheritable,
144 DWORD ShareMode);
145 NTSTATUS FASTCALL Win32CsrLockObject(PCONSOLE_PROCESS_DATA ProcessData,
146 HANDLE Handle,
147 Object_t **Object,
148 DWORD Access,
149 LONG Type);
150 VOID FASTCALL Win32CsrUnlockObject(Object_t *Object);
151 NTSTATUS FASTCALL Win32CsrReleaseObject(PCONSOLE_PROCESS_DATA ProcessData,
152 HANDLE Handle);
153
154 NTSTATUS NTAPI ConsoleNewProcess(PCSR_PROCESS SourceProcess,
155 PCSR_PROCESS TargetProcess);
156 NTSTATUS NTAPI ConsoleConnect(IN PCSR_PROCESS CsrProcess,
157 IN OUT PVOID ConnectionInfo,
158 IN OUT PULONG ConnectionInfoLength);
159 VOID NTAPI ConsoleDisconnect(PCSR_PROCESS Process);
160 VOID NTAPI Win32CsrReleaseConsole(PCSR_PROCESS Process);
161
162 /* lineinput.c */
163 CSR_API(SrvGetConsoleCommandHistoryLength);
164 CSR_API(SrvGetConsoleCommandHistory);
165 CSR_API(SrvExpungeConsoleCommandHistory);
166 CSR_API(SrvSetConsoleNumberOfCommands);
167 CSR_API(SrvGetConsoleHistory);
168 CSR_API(SrvSetConsoleHistory);
169
170 #endif // __CONSRV_H__
171
172 /* EOF */