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