crypt32: Implement streamed encoding of an indefinite-length data message.
[wine] / include / winsvc.h
1 /*
2  * Copyright (C) the Wine project
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #ifndef __WINE_WINSVC_H
20 #define __WINE_WINSVC_H
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif /* defined(__cplusplus) */
25
26 /* Service database names */
27 #define SERVICES_ACTIVE_DATABASEA     "ServicesActive"
28 #define SERVICES_FAILED_DATABASEA     "ServicesFailed"
29
30 #if defined(__GNUC__)
31 # define SERVICES_ACTIVE_DATABASEW    (const WCHAR []){ 'S','e','r','v','i','c','e','s','A','c','t','i','v','e',0 }
32 # define SERVICES_FAILED_DATABASEW    (const WCHAR []){ 'S','e','r','v','i','c','e','s','F','a','i','l','e','d',0 }
33 #elif defined(_MSC_VER)
34 # define SERVICES_ACTIVE_DATABASEW    L"ServicesActive"
35 # define SERVICES_FAILED_DATABASEW    L"ServicesFailed"
36 #endif
37
38 #define SERVICES_ACTIVE_DATABASE      WINELIB_NAME_AW( SERVICES_ACTIVE_DATABASE )
39 #define SERVICES_FAILED_DATABASE      WINELIB_NAME_AW( SERVICES_FAILED_DATABASE )
40
41 /* Service State requests */
42 #define SERVICE_ACTIVE                        0x00000001
43 #define SERVICE_INACTIVE                      0x00000002
44 #define SERVICE_STATE_ALL                     (SERVICE_ACTIVE | SERVICE_INACTIVE)
45
46 /* Controls */
47 #define SERVICE_CONTROL_STOP                  0x00000001
48 #define SERVICE_CONTROL_PAUSE                 0x00000002
49 #define SERVICE_CONTROL_CONTINUE              0x00000003
50 #define SERVICE_CONTROL_INTERROGATE           0x00000004
51 #define SERVICE_CONTROL_SHUTDOWN              0x00000005
52 #define SERVICE_CONTROL_PARAMCHANGE           0x00000006
53 #define SERVICE_CONTROL_NETBINDADD            0x00000007
54 #define SERVICE_CONTROL_NETBINDREMOVE         0x00000008
55 #define SERVICE_CONTROL_NETBINDENABLE         0x00000009
56 #define SERVICE_CONTROL_NETBINDDISABLE        0x0000000A
57 #define SERVICE_CONTROL_DEVICEEVENT           0x0000000B
58 #define SERVICE_CONTROL_HARDWAREPROFILECHANGE 0x0000000C
59 #define SERVICE_CONTROL_POWEREVENT            0x0000000D
60 #define SERVICE_CONTROL_SESSIONCHANGE         0x0000000E
61
62 /* Service State */
63 #define SERVICE_STOPPED          0x00000001
64 #define SERVICE_START_PENDING    0x00000002
65 #define SERVICE_STOP_PENDING     0x00000003
66 #define SERVICE_RUNNING          0x00000004
67 #define SERVICE_CONTINUE_PENDING 0x00000005
68 #define SERVICE_PAUSE_PENDING    0x00000006
69 #define SERVICE_PAUSED           0x00000007
70
71 /* Controls Accepted */
72 #define SERVICE_ACCEPT_STOP                  0x00000001
73 #define SERVICE_ACCEPT_PAUSE_CONTINUE        0x00000002
74 #define SERVICE_ACCEPT_SHUTDOWN              0x00000004
75 #define SERVICE_ACCEPT_PARAMCHANGE           0x00000008
76 #define SERVICE_ACCEPT_NETBINDCHANGE         0x00000010
77 #define SERVICE_ACCEPT_HARDWAREPROFILECHANGE 0x00000020
78 #define SERVICE_ACCEPT_POWEREVENT            0x00000040
79 #define SERVICE_ACCEPT_SESSIONCHANGE         0x00000080
80
81 /* Service Control Manager Object access types */
82 #define SC_MANAGER_CONNECT            0x0001
83 #define SC_MANAGER_CREATE_SERVICE     0x0002
84 #define SC_MANAGER_ENUMERATE_SERVICE  0x0004
85 #define SC_MANAGER_LOCK               0x0008
86 #define SC_MANAGER_QUERY_LOCK_STATUS  0x0010
87 #define SC_MANAGER_MODIFY_BOOT_CONFIG 0x0020
88 #define SC_MANAGER_ALL_ACCESS         ( STANDARD_RIGHTS_REQUIRED      | \
89                                         SC_MANAGER_CONNECT            | \
90                                         SC_MANAGER_CREATE_SERVICE     | \
91                                         SC_MANAGER_ENUMERATE_SERVICE  | \
92                                         SC_MANAGER_LOCK               | \
93                                         SC_MANAGER_QUERY_LOCK_STATUS  | \
94                                         SC_MANAGER_MODIFY_BOOT_CONFIG )
95
96 #define SERVICE_QUERY_CONFIG         0x0001
97 #define SERVICE_CHANGE_CONFIG        0x0002
98 #define SERVICE_QUERY_STATUS         0x0004
99 #define SERVICE_ENUMERATE_DEPENDENTS 0x0008
100 #define SERVICE_START                0x0010
101 #define SERVICE_STOP                 0x0020
102 #define SERVICE_PAUSE_CONTINUE       0x0040
103 #define SERVICE_INTERROGATE          0x0080
104 #define SERVICE_USER_DEFINED_CONTROL 0x0100
105
106 #define SERVICE_ALL_ACCESS           ( STANDARD_RIGHTS_REQUIRED     | \
107                                        SERVICE_QUERY_CONFIG         | \
108                                        SERVICE_CHANGE_CONFIG        | \
109                                        SERVICE_QUERY_STATUS         | \
110                                        SERVICE_ENUMERATE_DEPENDENTS | \
111                                        SERVICE_START                | \
112                                        SERVICE_STOP                 | \
113                                        SERVICE_PAUSE_CONTINUE       | \
114                                        SERVICE_INTERROGATE          | \
115                                        SERVICE_USER_DEFINED_CONTROL )
116
117 #define SERVICE_NO_CHANGE 0xffffffff
118
119
120 /* Handle types */
121
122 DECLARE_HANDLE(SC_HANDLE);
123 typedef SC_HANDLE *LPSC_HANDLE;
124 DECLARE_HANDLE(SERVICE_STATUS_HANDLE);
125 typedef LPVOID SC_LOCK;
126
127 /* Service status structure */
128
129 typedef struct _SERVICE_STATUS {
130   DWORD dwServiceType;
131   DWORD dwCurrentState;
132   DWORD dwControlsAccepted;
133   DWORD dwWin32ExitCode;
134   DWORD dwServiceSpecificExitCode;
135   DWORD dwCheckPoint;
136   DWORD dwWaitHint;
137 } SERVICE_STATUS, *LPSERVICE_STATUS;
138
139 /* Service status process structure */
140
141 typedef struct _SERVICE_STATUS_PROCESS
142 {
143   DWORD dwServiceType;
144   DWORD dwCurrentState;
145   DWORD dwControlsAccepted;
146   DWORD dwWin32ExitCode;
147   DWORD dwServiceSpecificExitCode;
148   DWORD dwCheckPoint;
149   DWORD dwWaitHint;
150   DWORD dwProcessId;
151   DWORD dwServiceFlags;
152 } SERVICE_STATUS_PROCESS, *LPSERVICE_STATUS_PROCESS;
153
154 typedef enum _SC_STATUS_TYPE {
155   SC_STATUS_PROCESS_INFO      = 0
156 } SC_STATUS_TYPE;
157
158 /* Service main function prototype */
159
160 typedef VOID (CALLBACK *LPSERVICE_MAIN_FUNCTIONA)(DWORD,LPSTR*);
161 typedef VOID (CALLBACK *LPSERVICE_MAIN_FUNCTIONW)(DWORD,LPWSTR*);
162 DECL_WINELIB_TYPE_AW(LPSERVICE_MAIN_FUNCTION)
163
164 /* Service start table */
165
166 typedef struct _SERVICE_TABLE_ENTRYA {
167     LPSTR                    lpServiceName;
168     LPSERVICE_MAIN_FUNCTIONA lpServiceProc;
169 } SERVICE_TABLE_ENTRYA, *LPSERVICE_TABLE_ENTRYA;
170
171 typedef struct _SERVICE_TABLE_ENTRYW {
172   LPWSTR                   lpServiceName;
173   LPSERVICE_MAIN_FUNCTIONW lpServiceProc;
174 } SERVICE_TABLE_ENTRYW, *LPSERVICE_TABLE_ENTRYW;
175
176 DECL_WINELIB_TYPE_AW(SERVICE_TABLE_ENTRY)
177 DECL_WINELIB_TYPE_AW(LPSERVICE_TABLE_ENTRY)
178
179 /* Service status enumeration structure */
180
181 typedef struct _ENUM_SERVICE_STATUSA {
182   LPSTR          lpServiceName;
183   LPSTR          lpDisplayName;
184   SERVICE_STATUS ServiceStatus;
185 } ENUM_SERVICE_STATUSA, *LPENUM_SERVICE_STATUSA;
186
187 typedef struct _ENUM_SERVICE_STATUSW {
188     LPWSTR         lpServiceName;
189     LPWSTR         lpDisplayName;
190     SERVICE_STATUS ServiceStatus;
191 } ENUM_SERVICE_STATUSW, *LPENUM_SERVICE_STATUSW;
192
193 DECL_WINELIB_TYPE_AW(ENUM_SERVICE_STATUS)
194 DECL_WINELIB_TYPE_AW(LPENUM_SERVICE_STATUS)
195
196 typedef struct _ENUM_SERVICE_STATUS_PROCESSA {
197   LPSTR          lpServiceName;
198   LPSTR          lpDisplayName;
199   SERVICE_STATUS_PROCESS ServiceStatusProcess;
200 } ENUM_SERVICE_STATUS_PROCESSA, *LPENUM_SERVICE_STATUS_PROCESSA;
201
202 typedef struct _ENUM_SERVICE_STATUS_PROCESSW {
203     LPWSTR         lpServiceName;
204     LPWSTR         lpDisplayName;
205     SERVICE_STATUS_PROCESS ServiceStatusProcess;
206 } ENUM_SERVICE_STATUS_PROCESSW, *LPENUM_SERVICE_STATUS_PROCESSW;
207
208 DECL_WINELIB_TYPE_AW(ENUM_SERVICE_STATUS_PROCESS)
209 DECL_WINELIB_TYPE_AW(LPENUM_SERVICE_STATUS_PROCESS)
210
211 typedef enum _SC_ENUM_TYPE {
212     SC_ENUM_PROCESS_INFO      = 0
213 } SC_ENUM_TYPE;
214
215 typedef struct _QUERY_SERVICE_CONFIGA {
216     DWORD   dwServiceType;
217     DWORD   dwStartType;
218     DWORD   dwErrorControl;
219     LPSTR   lpBinaryPathName;
220     LPSTR   lpLoadOrderGroup;
221     DWORD   dwTagId;
222     LPSTR   lpDependencies;
223     LPSTR   lpServiceStartName;
224     LPSTR   lpDisplayName;
225 } QUERY_SERVICE_CONFIGA, *LPQUERY_SERVICE_CONFIGA;
226
227 typedef struct _QUERY_SERVICE_CONFIGW {
228     DWORD   dwServiceType;
229     DWORD   dwStartType;
230     DWORD   dwErrorControl;
231     LPWSTR  lpBinaryPathName;
232     LPWSTR  lpLoadOrderGroup;
233     DWORD   dwTagId;
234     LPWSTR  lpDependencies;
235     LPWSTR  lpServiceStartName;
236     LPWSTR  lpDisplayName;
237 } QUERY_SERVICE_CONFIGW, *LPQUERY_SERVICE_CONFIGW;
238
239 /* defines and structures for ChangeServiceConfig2 */
240 #define SERVICE_CONFIG_DESCRIPTION     1
241 #define SERVICE_CONFIG_FAILURE_ACTIONS 2
242
243 typedef struct _SERVICE_DESCRIPTIONA {
244    LPSTR lpDescription;
245 } SERVICE_DESCRIPTIONA,*LPSERVICE_DESCRIPTIONA;
246
247 typedef struct _SERVICE_DESCRIPTIONW {
248    LPWSTR lpDescription;
249 } SERVICE_DESCRIPTIONW,*LPSERVICE_DESCRIPTIONW;
250
251 DECL_WINELIB_TYPE_AW(SERVICE_DESCRIPTION)
252 DECL_WINELIB_TYPE_AW(LPSERVICE_DESCRIPTION)
253
254 typedef enum _SC_ACTION_TYPE {
255     SC_ACTION_NONE        = 0,
256     SC_ACTION_RESTART     = 1,
257     SC_ACTION_REBOOT      = 2,
258     SC_ACTION_RUN_COMMAND = 3
259 } SC_ACTION_TYPE;
260
261 typedef struct _SC_ACTION {
262    SC_ACTION_TYPE  Type;
263    DWORD       Delay;
264 } SC_ACTION,*LPSC_ACTION;
265
266 typedef struct _SERVICE_FAILURE_ACTIONSA {
267    DWORD   dwResetPeriod;
268    LPSTR   lpRebootMsg;
269    LPSTR   lpCommand;
270    DWORD   cActions;
271    SC_ACTION * lpsaActions;
272 } SERVICE_FAILURE_ACTIONSA,*LPSERVICE_FAILURE_ACTIONSA;
273
274 typedef struct _SERVICE_FAILURE_ACTIONSW {
275    DWORD   dwResetPeriod;
276    LPWSTR  lpRebootMsg;
277    LPWSTR  lpCommand;
278    DWORD   cActions;
279    SC_ACTION * lpsaActions;
280 } SERVICE_FAILURE_ACTIONSW,*LPSERVICE_FAILURE_ACTIONSW;
281
282 DECL_WINELIB_TYPE_AW(SERVICE_FAILURE_ACTIONS)
283 DECL_WINELIB_TYPE_AW(LPSERVICE_FAILURE_ACTIONS)
284
285 typedef struct _QUERY_SERVICE_LOCK_STATUSA
286 {
287   DWORD fIsLocked;
288   LPSTR lpLockOwner;
289   DWORD dwLockDuration;
290 } QUERY_SERVICE_LOCK_STATUSA, *LPQUERY_SERVICE_LOCK_STATUSA;
291
292 typedef struct _QUERY_SERVICE_LOCK_STATUSW
293 {
294   DWORD fIsLocked;
295   LPWSTR lpLockOwner;
296   DWORD dwLockDuration;
297 } QUERY_SERVICE_LOCK_STATUSW, *LPQUERY_SERVICE_LOCK_STATUSW;
298
299 DECL_WINELIB_TYPE_AW(QUERY_SERVICE_LOCK_STATUS)
300
301 /* Service control handler function prototype */
302
303 typedef VOID (WINAPI *LPHANDLER_FUNCTION)(DWORD);
304 typedef DWORD (WINAPI *LPHANDLER_FUNCTION_EX)(DWORD,DWORD,LPVOID,LPVOID);
305
306 /* API function prototypes */
307
308 BOOL        WINAPI ChangeServiceConfigA(SC_HANDLE,DWORD,DWORD,DWORD,LPCSTR,LPCSTR,LPDWORD,LPCSTR,LPCSTR,LPCSTR,LPCSTR);
309 BOOL        WINAPI ChangeServiceConfigW(SC_HANDLE,DWORD,DWORD,DWORD,LPCWSTR,LPCWSTR,LPDWORD,LPCWSTR,LPCWSTR,LPCWSTR,LPCWSTR);
310 #define     ChangeServiceConfig WINELIB_NAME_AW(ChangeServiceConfig)
311 BOOL        WINAPI ChangeServiceConfig2A(SC_HANDLE,DWORD,LPVOID);
312 BOOL        WINAPI ChangeServiceConfig2W(SC_HANDLE,DWORD,LPVOID);
313 #define     ChangeServiceConfig2 WINELIB_NAME_AW(ChangeServiceConfig2)
314 BOOL        WINAPI CloseServiceHandle(SC_HANDLE);
315 BOOL        WINAPI ControlService(SC_HANDLE,DWORD,LPSERVICE_STATUS);
316 SC_HANDLE   WINAPI CreateServiceA(SC_HANDLE,LPCSTR,LPCSTR,DWORD,DWORD,DWORD,DWORD,LPCSTR,
317                                   LPCSTR,LPDWORD,LPCSTR,LPCSTR,LPCSTR);
318 SC_HANDLE   WINAPI CreateServiceW(SC_HANDLE,LPCWSTR,LPCWSTR,DWORD,DWORD,DWORD,DWORD,LPCWSTR,
319                                   LPCWSTR,LPDWORD,LPCWSTR,LPCWSTR,LPCWSTR);
320 #define     CreateService WINELIB_NAME_AW(CreateService)
321 BOOL        WINAPI DeleteService(SC_HANDLE);
322 BOOL        WINAPI EnumDependentServicesA(SC_HANDLE,DWORD,LPENUM_SERVICE_STATUSA,DWORD,LPDWORD,LPDWORD);
323 BOOL        WINAPI EnumDependentServicesW(SC_HANDLE,DWORD,LPENUM_SERVICE_STATUSW,DWORD,LPDWORD,LPDWORD);
324 #define     EnumDependentServices WINELIB_NAME_AW(EnumDependentServices)
325 BOOL        WINAPI EnumServicesStatusA(SC_HANDLE,DWORD,DWORD,LPENUM_SERVICE_STATUSA,
326                                        DWORD,LPDWORD,LPDWORD,LPDWORD);
327 BOOL        WINAPI EnumServicesStatusW(SC_HANDLE,DWORD,DWORD,LPENUM_SERVICE_STATUSW,
328                                        DWORD,LPDWORD,LPDWORD,LPDWORD);
329 #define     EnumServicesStatus WINELIB_NAME_AW(EnumServicesStatus)
330 BOOL        WINAPI EnumServicesStatusExA(SC_HANDLE,SC_ENUM_TYPE,DWORD,DWORD,LPBYTE,
331                                          DWORD,LPDWORD,LPDWORD,LPDWORD,LPCSTR);
332 BOOL        WINAPI EnumServicesStatusExW(SC_HANDLE,SC_ENUM_TYPE,DWORD,DWORD,LPBYTE,
333                                          DWORD,LPDWORD,LPDWORD,LPDWORD,LPCWSTR);
334 #define     EnumServicesStatus WINELIB_NAME_AW(EnumServicesStatus)
335 BOOL        WINAPI GetServiceDisplayNameA(SC_HANDLE,LPCSTR,LPSTR,LPDWORD);
336 BOOL        WINAPI GetServiceDisplayNameW(SC_HANDLE,LPCWSTR,LPWSTR,LPDWORD);
337 #define     GetServiceDisplayName WINELIB_NAME_AW(GetServiceDisplayName)
338 BOOL        WINAPI GetServiceKeyNameA(SC_HANDLE,LPCSTR,LPSTR,LPDWORD);
339 BOOL        WINAPI GetServiceKeyNameW(SC_HANDLE,LPCWSTR,LPWSTR,LPDWORD);
340 #define     GetServiceKeyName WINELIB_NAME_AW(GetServiceKeyName)
341 SC_LOCK     WINAPI LockServiceDatabase(SC_HANDLE);
342 BOOL        WINAPI NotifyBootConfigStatus(BOOL);
343 SC_HANDLE   WINAPI OpenSCManagerA(LPCSTR,LPCSTR,DWORD);
344 SC_HANDLE   WINAPI OpenSCManagerW(LPCWSTR,LPCWSTR,DWORD);
345 #define     OpenSCManager WINELIB_NAME_AW(OpenSCManager)
346 SC_HANDLE   WINAPI OpenServiceA(SC_HANDLE,LPCSTR,DWORD);
347 SC_HANDLE   WINAPI OpenServiceW(SC_HANDLE,LPCWSTR,DWORD);
348 #define     OpenService WINELIB_NAME_AW(OpenService)
349 BOOL        WINAPI QueryServiceStatus(SC_HANDLE,LPSERVICE_STATUS);
350 BOOL        WINAPI QueryServiceStatusEx(SC_HANDLE,SC_STATUS_TYPE,LPBYTE,DWORD,LPDWORD);
351 BOOL        WINAPI QueryServiceConfigA(SC_HANDLE,LPQUERY_SERVICE_CONFIGA,DWORD,LPDWORD);
352 BOOL        WINAPI QueryServiceConfigW(SC_HANDLE,LPQUERY_SERVICE_CONFIGW,DWORD,LPDWORD);
353 #define     QueryServiceConfig WINELIB_NAME_AW(QueryServiceConfig)
354 BOOL        WINAPI QueryServiceLockStatusA(SC_HANDLE,LPQUERY_SERVICE_LOCK_STATUSA,DWORD,LPDWORD);
355 BOOL        WINAPI QueryServiceLockStatusW(SC_HANDLE,LPQUERY_SERVICE_LOCK_STATUSW,DWORD,LPDWORD);
356 #define     QueryServiceLockStatus WINELIB_NAME_AW(QueryServiceLockStatus)
357 BOOL        WINAPI QueryServiceObjectSecurity(SC_HANDLE,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR,DWORD,LPDWORD);
358 SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerA(LPCSTR,LPHANDLER_FUNCTION);
359 SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerW(LPCWSTR,LPHANDLER_FUNCTION);
360 #define     RegisterServiceCtrlHandler WINELIB_NAME_AW(RegisterServiceCtrlHandler)
361 SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExA(LPCSTR,LPHANDLER_FUNCTION_EX,LPVOID);
362 SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExW(LPCWSTR,LPHANDLER_FUNCTION_EX,LPVOID);
363 #define     RegisterServiceCtrlHandlerEx WINELIB_NAME_AW(RegisterServiceCtrlHandlerEx)
364 BOOL        WINAPI SetServiceObjectSecurity(SC_HANDLE,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR);
365 BOOL        WINAPI SetServiceStatus(SERVICE_STATUS_HANDLE,LPSERVICE_STATUS);
366 BOOL        WINAPI StartServiceA(SC_HANDLE,DWORD,LPCSTR*);
367 BOOL        WINAPI StartServiceW(SC_HANDLE,DWORD,LPCWSTR*);
368 #define     StartService WINELIB_NAME_AW(StartService)
369 BOOL        WINAPI StartServiceCtrlDispatcherA(const SERVICE_TABLE_ENTRYA*);
370 BOOL        WINAPI StartServiceCtrlDispatcherW(const SERVICE_TABLE_ENTRYW*);
371 #define     StartServiceCtrlDispatcher WINELIB_NAME_AW(StartServiceCtrlDispatcher)
372 BOOL        WINAPI UnlockServiceDatabase(SC_LOCK);
373
374 #ifdef __cplusplus
375 } /* extern "C" */
376 #endif /* defined(__cplusplus) */
377
378 #endif /* !defined(__WINE_WINSVC_H) */