[ADVAPI32][SERVICES] Add (dummy) password encryption/decryption functions to CreateSe...
[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 DWORD dwServiceBits;
75
76 ULONG Flags;
77
78 PSECURITY_DESCRIPTOR pSecurityDescriptor;
79
80 BOOLEAN ServiceVisited;
81
82 WCHAR szServiceName[1];
83 } SERVICE, *PSERVICE;
84
85
86 #define LOCK_TAG 0x4C697041 /* 'ApiL' */
87
88 typedef struct _START_LOCK
89 {
90 DWORD Tag; /* Must be LOCK_TAG */
91 DWORD TimeWhenLocked; /* Number of seconds since 1970 */
92 PSID LockOwnerSid; /* It is NULL if the SCM acquired the lock */
93 } START_LOCK, *PSTART_LOCK;
94
95
96 /* VARIABLES ***************************************************************/
97
98 extern LIST_ENTRY ServiceListHead;
99 extern LIST_ENTRY GroupListHead;
100 extern LIST_ENTRY ImageListHead;
101 extern BOOL ScmInitialize;
102 extern BOOL ScmShutdown;
103
104
105 /* FUNCTIONS ***************************************************************/
106
107 /* config.c */
108
109 DWORD ScmOpenServiceKey(LPWSTR lpServiceName,
110 REGSAM samDesired,
111 PHKEY phKey);
112
113 DWORD ScmCreateServiceKey(LPCWSTR lpServiceName,
114 REGSAM samDesired,
115 PHKEY phKey);
116
117 DWORD ScmWriteDependencies(HKEY hServiceKey,
118 LPCWSTR lpDependencies,
119 DWORD dwDependenciesLength);
120
121 DWORD ScmMarkServiceForDelete(PSERVICE pService);
122 BOOL ScmIsDeleteFlagSet(HKEY hServiceKey);
123
124 DWORD ScmReadString(HKEY hServiceKey,
125 LPCWSTR lpValueName,
126 LPWSTR *lpValue);
127
128 DWORD
129 ScmReadDependencies(HKEY hServiceKey,
130 LPWSTR *lpDependencies,
131 DWORD *lpdwDependenciesLength);
132
133 DWORD
134 ScmSetServicePassword(
135 IN PCWSTR pszServiceName,
136 IN PCWSTR pszPassword);
137
138 DWORD
139 ScmWriteSecurityDescriptor(
140 _In_ HKEY hServiceKey,
141 _In_ PSECURITY_DESCRIPTOR pSecurityDescriptor);
142
143 DWORD
144 ScmReadSecurityDescriptor(
145 _In_ HKEY hServiceKey,
146 _Out_ PSECURITY_DESCRIPTOR *ppSecurityDescriptor);
147
148 DWORD
149 ScmDeleteRegKey(
150 _In_ HKEY hKey,
151 _In_ PCWSTR pszSubKey);
152
153 DWORD
154 ScmDecryptPassword(
155 _In_ PBYTE pPassword,
156 _In_ DWORD dwPasswordSize,
157 _Out_ PWSTR *pDecryptedPassword);
158
159
160 /* controlset.c */
161
162 BOOL ScmGetControlSetValues(VOID);
163
164
165 /* database.c */
166
167 DWORD ScmCreateServiceDatabase(VOID);
168 VOID ScmShutdownServiceDatabase(VOID);
169 VOID ScmGetBootAndSystemDriverState(VOID);
170 VOID ScmAutoStartServices(VOID);
171 VOID ScmAutoShutdownServices(VOID);
172 DWORD ScmStartService(PSERVICE Service,
173 DWORD argc,
174 LPWSTR *argv);
175
176 VOID ScmRemoveServiceImage(PSERVICE_IMAGE pServiceImage);
177 PSERVICE ScmGetServiceEntryByName(LPCWSTR lpServiceName);
178 PSERVICE ScmGetServiceEntryByDisplayName(LPCWSTR lpDisplayName);
179 PSERVICE ScmGetServiceEntryByResumeCount(DWORD dwResumeCount);
180 DWORD ScmCreateNewServiceRecord(LPCWSTR lpServiceName,
181 PSERVICE *lpServiceRecord,
182 DWORD dwServiceType,
183 DWORD dwStartType);
184 VOID ScmDeleteServiceRecord(PSERVICE lpService);
185 DWORD ScmMarkServiceForDelete(PSERVICE pService);
186
187 DWORD ScmControlService(HANDLE hControlPipe,
188 PWSTR pServiceName,
189 SERVICE_STATUS_HANDLE hServiceStatus,
190 DWORD dwControl);
191
192 BOOL ScmLockDatabaseExclusive(VOID);
193 BOOL ScmLockDatabaseShared(VOID);
194 VOID ScmUnlockDatabase(VOID);
195
196 VOID ScmInitNamedPipeCriticalSection(VOID);
197 VOID ScmDeleteNamedPipeCriticalSection(VOID);
198
199
200 /* driver.c */
201
202 DWORD ScmStartDriver(PSERVICE lpService);
203 DWORD ScmControlDriver(PSERVICE lpService,
204 DWORD dwControl,
205 LPSERVICE_STATUS lpServiceStatus);
206
207
208 /* groupdb.c */
209
210 PSERVICE_GROUP
211 ScmGetServiceGroupByName(
212 _In_ LPCWSTR lpGroupName);
213
214 DWORD ScmCreateGroupList(VOID);
215 DWORD ScmSetServiceGroup(PSERVICE lpService,
216 LPCWSTR lpGroupName);
217
218
219 /* lock.c */
220
221 DWORD ScmAcquireServiceStartLock(IN BOOL IsServiceController,
222 OUT LPSC_RPC_LOCK lpLock);
223 DWORD ScmReleaseServiceStartLock(IN OUT LPSC_RPC_LOCK lpLock);
224 VOID ScmQueryServiceLockStatusW(OUT LPQUERY_SERVICE_LOCK_STATUSW lpLockStatus);
225 VOID ScmQueryServiceLockStatusA(OUT LPQUERY_SERVICE_LOCK_STATUSA lpLockStatus);
226
227
228 /* rpcserver.c */
229
230 VOID ScmStartRpcServer(VOID);
231
232
233 /* security.c */
234
235 DWORD ScmInitializeSecurity(VOID);
236 VOID ScmShutdownSecurity(VOID);
237
238 DWORD
239 ScmCreateDefaultServiceSD(
240 PSECURITY_DESCRIPTOR *ppSecurityDescriptor);
241
242
243 /* services.c */
244
245 VOID PrintString(LPCSTR fmt, ...);
246 VOID ScmLogEvent(DWORD dwEventId,
247 WORD wType,
248 WORD wStrings,
249 LPCWSTR *lpStrings);
250 VOID ScmWaitForLsa(VOID);
251
252 #endif /* _SERVICES_H */