[MSIEXEC] Sync with Wine Staging 2.16. CORE-13762
[reactos.git] / base / system / services / services.h
1 /*
2 * services.h
3 */
4
5 #ifndef _SERVICES_H
6 #define _SERVICES_H
7
8 #include <stdio.h>
9 #include <stdlib.h>
10
11 #define WIN32_NO_STATUS
12 #define _INC_WINDOWS
13 #define COM_NO_WINDOWS_H
14
15 #include <windef.h>
16 #include <winbase.h>
17 #include <winsvc.h>
18 #include <winreg.h>
19 #include <winuser.h>
20 #include <netevent.h>
21 #define NTOS_MODE_USER
22 #include <ndk/obfuncs.h>
23 #include <ndk/rtlfuncs.h>
24 #include <services/services.h>
25 #include <svcctl_s.h>
26
27 #include "resource.h"
28
29 typedef struct _SERVICE_GROUP
30 {
31 LIST_ENTRY GroupListEntry;
32 LPWSTR lpGroupName;
33
34 DWORD dwRefCount;
35 BOOLEAN ServicesRunning;
36 ULONG TagCount;
37 PULONG TagArray;
38
39 WCHAR szGroupName[1];
40 } SERVICE_GROUP, *PSERVICE_GROUP;
41
42
43 typedef struct _SERVICE_IMAGE
44 {
45 LIST_ENTRY ImageListEntry;
46 LPWSTR pszImagePath;
47 LPWSTR pszAccountName;
48 DWORD dwImageRunCount;
49
50 HANDLE hControlPipe;
51 HANDLE hProcess;
52 DWORD dwProcessId;
53 HANDLE hToken;
54 HANDLE hProfile;
55 } SERVICE_IMAGE, *PSERVICE_IMAGE;
56
57
58 typedef struct _SERVICE
59 {
60 LIST_ENTRY ServiceListEntry;
61 LPWSTR lpServiceName;
62 LPWSTR lpDisplayName;
63 PSERVICE_GROUP lpGroup;
64 PSERVICE_IMAGE lpImage;
65 BOOL bDeleted;
66 DWORD dwResumeCount;
67 DWORD dwRefCount;
68
69 SERVICE_STATUS Status;
70 DWORD dwStartType;
71 DWORD dwErrorControl;
72 DWORD dwTag;
73
74 ULONG Flags;
75
76 PSECURITY_DESCRIPTOR pSecurityDescriptor;
77
78 BOOLEAN ServiceVisited;
79
80 WCHAR szServiceName[1];
81 } SERVICE, *PSERVICE;
82
83
84 #define LOCK_TAG 0x4C697041 /* 'ApiL' */
85
86 typedef struct _START_LOCK
87 {
88 DWORD Tag; /* Must be LOCK_TAG */
89 DWORD TimeWhenLocked; /* Number of seconds since 1970 */
90 PSID LockOwnerSid; /* It is NULL if the SCM acquired the lock */
91 } START_LOCK, *PSTART_LOCK;
92
93
94 /* VARIABLES ***************************************************************/
95
96 extern LIST_ENTRY ServiceListHead;
97 extern LIST_ENTRY GroupListHead;
98 extern LIST_ENTRY ImageListHead;
99 extern BOOL ScmInitialize;
100 extern BOOL ScmShutdown;
101
102
103 /* FUNCTIONS ***************************************************************/
104
105 /* config.c */
106
107 DWORD ScmOpenServiceKey(LPWSTR lpServiceName,
108 REGSAM samDesired,
109 PHKEY phKey);
110
111 DWORD ScmCreateServiceKey(LPCWSTR lpServiceName,
112 REGSAM samDesired,
113 PHKEY phKey);
114
115 DWORD ScmWriteDependencies(HKEY hServiceKey,
116 LPCWSTR lpDependencies,
117 DWORD dwDependenciesLength);
118
119 DWORD ScmMarkServiceForDelete(PSERVICE pService);
120 BOOL ScmIsDeleteFlagSet(HKEY hServiceKey);
121
122 DWORD ScmReadString(HKEY hServiceKey,
123 LPCWSTR lpValueName,
124 LPWSTR *lpValue);
125
126 DWORD
127 ScmReadDependencies(HKEY hServiceKey,
128 LPWSTR *lpDependencies,
129 DWORD *lpdwDependenciesLength);
130
131 DWORD
132 ScmSetServicePassword(
133 IN PCWSTR pszServiceName,
134 IN PCWSTR pszPassword);
135
136 DWORD
137 ScmWriteSecurityDescriptor(
138 _In_ HKEY hServiceKey,
139 _In_ PSECURITY_DESCRIPTOR pSecurityDescriptor);
140
141 DWORD
142 ScmReadSecurityDescriptor(
143 _In_ HKEY hServiceKey,
144 _Out_ PSECURITY_DESCRIPTOR *ppSecurityDescriptor);
145
146 DWORD
147 ScmDeleteRegKey(
148 _In_ HKEY hKey,
149 _In_ PCWSTR pszSubKey);
150
151 /* controlset.c */
152
153 BOOL ScmGetControlSetValues(VOID);
154
155
156 /* database.c */
157
158 DWORD ScmCreateServiceDatabase(VOID);
159 VOID ScmShutdownServiceDatabase(VOID);
160 VOID ScmGetBootAndSystemDriverState(VOID);
161 VOID ScmAutoStartServices(VOID);
162 VOID ScmAutoShutdownServices(VOID);
163 DWORD ScmStartService(PSERVICE Service,
164 DWORD argc,
165 LPWSTR *argv);
166
167 PSERVICE ScmGetServiceEntryByName(LPCWSTR lpServiceName);
168 PSERVICE ScmGetServiceEntryByDisplayName(LPCWSTR lpDisplayName);
169 PSERVICE ScmGetServiceEntryByResumeCount(DWORD dwResumeCount);
170 DWORD ScmCreateNewServiceRecord(LPCWSTR lpServiceName,
171 PSERVICE *lpServiceRecord);
172 VOID ScmDeleteServiceRecord(PSERVICE lpService);
173 DWORD ScmMarkServiceForDelete(PSERVICE pService);
174
175 DWORD ScmControlService(PSERVICE Service,
176 DWORD dwControl);
177
178 BOOL ScmLockDatabaseExclusive(VOID);
179 BOOL ScmLockDatabaseShared(VOID);
180 VOID ScmUnlockDatabase(VOID);
181
182 VOID ScmInitNamedPipeCriticalSection(VOID);
183 VOID ScmDeleteNamedPipeCriticalSection(VOID);
184
185
186 /* driver.c */
187
188 DWORD ScmLoadDriver(PSERVICE lpService);
189 DWORD ScmUnloadDriver(PSERVICE lpService);
190 DWORD ScmControlDriver(PSERVICE lpService,
191 DWORD dwControl,
192 LPSERVICE_STATUS lpServiceStatus);
193
194
195 /* groupdb.c */
196
197 PSERVICE_GROUP
198 ScmGetServiceGroupByName(
199 _In_ LPCWSTR lpGroupName);
200
201 DWORD ScmCreateGroupList(VOID);
202 DWORD ScmSetServiceGroup(PSERVICE lpService,
203 LPCWSTR lpGroupName);
204
205
206 /* lock.c */
207
208 DWORD ScmAcquireServiceStartLock(IN BOOL IsServiceController,
209 OUT LPSC_RPC_LOCK lpLock);
210 DWORD ScmReleaseServiceStartLock(IN OUT LPSC_RPC_LOCK lpLock);
211 VOID ScmQueryServiceLockStatusW(OUT LPQUERY_SERVICE_LOCK_STATUSW lpLockStatus);
212 VOID ScmQueryServiceLockStatusA(OUT LPQUERY_SERVICE_LOCK_STATUSA lpLockStatus);
213
214
215 /* rpcserver.c */
216
217 VOID ScmStartRpcServer(VOID);
218
219
220 /* security.c */
221
222 DWORD ScmInitializeSecurity(VOID);
223 VOID ScmShutdownSecurity(VOID);
224
225 DWORD
226 ScmCreateDefaultServiceSD(
227 PSECURITY_DESCRIPTOR *ppSecurityDescriptor);
228
229
230 /* services.c */
231
232 VOID PrintString(LPCSTR fmt, ...);
233 VOID ScmLogEvent(DWORD dwEventId,
234 WORD wType,
235 WORD wStrings,
236 LPCWSTR *lpStrings);
237 VOID ScmWaitForLsa(VOID);
238
239 #endif /* _SERVICES_H */