[CSRSS]: Split off CSRSS into a more Windows-friendly model. CSRSS.EXE is simply...
[reactos.git] / reactos / subsystems / win32 / csrss / include / api.h
1 /* $Id$
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS system libraries
5 * FILE: subsys/csrss/include/api.h
6 * PURPOSE: CSRSS API interface
7 */
8
9 #pragma once
10
11 #define NTOS_MODE_USER
12 #include <ndk/ntndk.h>
13
14 #include <csrss/csrss.h>
15
16 typedef enum _CSR_THREAD_FLAGS
17 {
18 CsrThreadAltertable = 0x1,
19 CsrThreadInTermination = 0x2,
20 CsrThreadTerminated = 0x4,
21 CsrThreadIsServerThread = 0x10
22 } CSR_THREAD_FLAGS, *PCSR_THREAD_FLAGS;
23
24 typedef enum _SHUTDOWN_RESULT
25 {
26 CsrShutdownCsrProcess = 1,
27 CsrShutdownNonCsrProcess,
28 CsrShutdownCancelled
29 } SHUTDOWN_RESULT, *PSHUTDOWN_RESULT;
30
31 typedef enum _CSR_SHUTDOWN_FLAGS
32 {
33 CsrShutdownSystem = 4,
34 CsrShutdownOther = 8
35 } CSR_SHUTDOWN_FLAGS, *PCSR_SHUTDOWN_FLAGS;
36
37 typedef enum _CSR_PROCESS_FLAGS
38 {
39 CsrProcessTerminating = 0x1,
40 CsrProcessSkipShutdown = 0x2,
41 CsrProcessCreateNewGroup = 0x100,
42 CsrProcessTerminated = 0x200,
43 CsrProcessLastThreadTerminated = 0x400,
44 CsrProcessIsConsoleApp = 0x800
45 } CSR_PROCESS_FLAGS, *PCSR_PROCESS_FLAGS;
46
47 typedef struct Object_tt
48 {
49 LONG Type;
50 LONG ReferenceCount;
51 CRITICAL_SECTION Lock;
52 } Object_t;
53
54 typedef struct ConsoleInput_t
55 {
56 LIST_ENTRY ListEntry;
57 INPUT_RECORD InputEvent;
58 BOOLEAN Echoed; // already been echoed or not
59 BOOLEAN Fake; // synthesized, not a real event
60 BOOLEAN NotChar; // message should not be used to return a character
61 } ConsoleInput;
62
63 typedef struct tagCSRSS_CONSOLE *PCSRSS_CONSOLE;
64
65 typedef struct _CSRSS_HANDLE
66 {
67 Object_t *Object;
68 DWORD Access;
69 BOOL Inheritable;
70 } CSRSS_HANDLE, *PCSRSS_HANDLE;
71
72 typedef struct _CSRSS_PROCESS_DATA
73 {
74 PCSRSS_CONSOLE Console;
75 PCSRSS_CONSOLE ParentConsole;
76 BOOL bInheritHandles;
77 RTL_CRITICAL_SECTION HandleTableLock;
78 ULONG HandleTableSize;
79 PCSRSS_HANDLE HandleTable;
80 HANDLE ProcessId;
81 DWORD ProcessGroup;
82 HANDLE Process;
83 ULONG ShutdownLevel;
84 ULONG ShutdownFlags;
85 HANDLE ConsoleEvent;
86 PVOID CsrSectionViewBase;
87 ULONG CsrSectionViewSize;
88 HANDLE ServerCommunicationPort;
89 struct _CSRSS_PROCESS_DATA * next;
90 LIST_ENTRY ProcessEntry;
91 PCONTROLDISPATCHER CtrlDispatcher;
92 BOOL Terminated;
93 ULONG Flags;
94 ULONG ThreadCount;
95 LIST_ENTRY ThreadList;
96 } CSRSS_PROCESS_DATA, *PCSRSS_PROCESS_DATA;
97
98 typedef struct _CSR_THREAD
99 {
100 LARGE_INTEGER CreateTime;
101 LIST_ENTRY Link;
102 LIST_ENTRY HashLinks;
103 CLIENT_ID ClientId;
104 PCSRSS_PROCESS_DATA Process;
105 //struct _CSR_WAIT_BLOCK *WaitBlock;
106 HANDLE ThreadHandle;
107 ULONG Flags;
108 ULONG ReferenceCount;
109 ULONG ImpersonationCount;
110 } CSR_THREAD, *PCSR_THREAD;
111
112 typedef VOID (WINAPI *CSR_CLEANUP_OBJECT_PROC)(Object_t *Object);
113
114 typedef struct tagCSRSS_OBJECT_DEFINITION
115 {
116 LONG Type;
117 CSR_CLEANUP_OBJECT_PROC CsrCleanupObjectProc;
118 } CSRSS_OBJECT_DEFINITION, *PCSRSS_OBJECT_DEFINITION;
119
120 typedef NTSTATUS (WINAPI *CSRSS_API_PROC)(PCSRSS_PROCESS_DATA ProcessData,
121 PCSR_API_MESSAGE Request);
122
123 typedef struct _CSRSS_API_DEFINITION
124 {
125 ULONG Type;
126 ULONG MinRequestSize;
127 CSRSS_API_PROC Handler;
128 } CSRSS_API_DEFINITION, *PCSRSS_API_DEFINITION;
129
130 #define CSRSS_DEFINE_API(Func, Handler) \
131 { Func, sizeof(CSRSS_##Func), Handler }
132
133 typedef struct _CSRSS_LISTEN_DATA
134 {
135 HANDLE ApiPortHandle;
136 ULONG ApiDefinitionsCount;
137 PCSRSS_API_DEFINITION *ApiDefinitions;
138 } CSRSS_LISTEN_DATA, *PCSRSS_LISTEN_DATA;
139
140 #define CSR_API(n) NTSTATUS WINAPI n (\
141 PCSRSS_PROCESS_DATA ProcessData,\
142 PCSR_API_MESSAGE Request)
143
144 /* init.c */
145 extern HANDLE hBootstrapOk;
146
147 /* api/process.c */
148 CSR_API(CsrConnectProcess);
149 CSR_API(CsrCreateProcess);
150 CSR_API(CsrTerminateProcess);
151 CSR_API(CsrCreateThread);
152
153 /* print.c */
154 VOID WINAPI DisplayString(LPCWSTR lpwString);
155 VOID WINAPI PrintString (char* fmt, ...);
156
157 /* api/wapi.c */
158 NTSTATUS FASTCALL CsrApiRegisterDefinitions(PCSRSS_API_DEFINITION NewDefinitions);
159 VOID FASTCALL CsrApiCallHandler(PCSRSS_PROCESS_DATA ProcessData,
160 PCSR_API_MESSAGE Request);
161 DWORD WINAPI ServerApiPortThread (PVOID PortHandle);
162 DWORD WINAPI ServerSbApiPortThread (PVOID PortHandle);
163 DWORD WINAPI Console_Api( PVOID unused );
164 VOID
165 NTAPI
166 ClientConnectionThread(HANDLE ServerPort);
167
168 extern HANDLE CsrssApiHeap;
169
170 /* api/conio.c */
171 VOID WINAPI CsrInitConsoleSupport(VOID);
172
173 /* api/process.c */
174 typedef NTSTATUS (WINAPI *CSRSS_ENUM_PROCESS_PROC)(PCSRSS_PROCESS_DATA ProcessData,
175 PVOID Context);
176 VOID WINAPI CsrInitProcessData(VOID);
177 PCSRSS_PROCESS_DATA WINAPI CsrGetProcessData(HANDLE ProcessId);
178 PCSRSS_PROCESS_DATA WINAPI CsrCreateProcessData(HANDLE ProcessId);
179 NTSTATUS WINAPI CsrFreeProcessData( HANDLE Pid );
180 NTSTATUS WINAPI CsrEnumProcesses(CSRSS_ENUM_PROCESS_PROC EnumProc, PVOID Context);
181 PCSR_THREAD NTAPI CsrAddStaticServerThread(IN HANDLE hThread, IN PCLIENT_ID ClientId, IN ULONG ThreadFlags);
182 PCSR_THREAD NTAPI CsrLocateThreadInProcess(IN PCSRSS_PROCESS_DATA CsrProcess OPTIONAL, IN PCLIENT_ID Cid);
183 PCSR_THREAD NTAPI CsrLocateThreadByClientId(OUT PCSRSS_PROCESS_DATA *Process OPTIONAL, IN PCLIENT_ID ClientId);
184
185 /* api/handle.c */
186 NTSTATUS FASTCALL CsrRegisterObjectDefinitions(PCSRSS_OBJECT_DEFINITION NewDefinitions);
187 NTSTATUS WINAPI CsrInsertObject( PCSRSS_PROCESS_DATA ProcessData, PHANDLE Handle, Object_t *Object, DWORD Access, BOOL Inheritable );
188 NTSTATUS WINAPI CsrDuplicateHandleTable(PCSRSS_PROCESS_DATA SourceProcessData, PCSRSS_PROCESS_DATA TargetProcessData);
189 NTSTATUS WINAPI CsrGetObject( PCSRSS_PROCESS_DATA ProcessData, HANDLE Handle, Object_t **Object, DWORD Access );
190 NTSTATUS NTAPI CsrServerInitialization(ULONG ArgumentCount, PCHAR Arguments[]);
191 NTSTATUS WINAPI CsrReleaseObjectByPointer(Object_t *Object);
192 NTSTATUS WINAPI CsrReleaseObject( PCSRSS_PROCESS_DATA ProcessData, HANDLE Object );
193 NTSTATUS WINAPI CsrVerifyObject( PCSRSS_PROCESS_DATA ProcessData, HANDLE Object );
194
195 CSR_API(CsrGetInputHandle);
196 CSR_API(CsrGetOutputHandle);
197 CSR_API(CsrCloseHandle);
198 CSR_API(CsrVerifyHandle);
199 CSR_API(CsrDuplicateHandle);
200 CSR_API(CsrGetInputWaitHandle);
201
202 /* api/user.c */
203 CSR_API(CsrRegisterServicesProcess);
204 CSR_API(CsrExitReactos);
205 CSR_API(CsrGetShutdownParameters);
206 CSR_API(CsrSetShutdownParameters);
207
208 CSR_API(CsrSetLogonNotifyWindow);
209 CSR_API(CsrRegisterLogonProcess);
210
211 /* EOF */