[SERVICES]
[reactos.git] / reactos / 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 DWORD dwImageRunCount;
47
48 HANDLE hControlPipe;
49 HANDLE hProcess;
50 DWORD dwProcessId;
51
52 WCHAR szImagePath[1];
53 } SERVICE_IMAGE, *PSERVICE_IMAGE;
54
55
56 typedef struct _SERVICE
57 {
58 LIST_ENTRY ServiceListEntry;
59 LPWSTR lpServiceName;
60 LPWSTR lpDisplayName;
61 PSERVICE_GROUP lpGroup;
62 PSERVICE_IMAGE lpImage;
63 BOOL bDeleted;
64 DWORD dwResumeCount;
65 DWORD dwRefCount;
66
67 SERVICE_STATUS Status;
68 DWORD dwStartType;
69 DWORD dwErrorControl;
70 DWORD dwTag;
71
72 ULONG Flags;
73
74 PSECURITY_DESCRIPTOR lpSecurityDescriptor;
75
76 BOOLEAN ServiceVisited;
77
78 WCHAR szServiceName[1];
79 } SERVICE, *PSERVICE;
80
81
82 #define LOCK_TAG 0x4C697041 /* 'ApiL' */
83
84 typedef struct _START_LOCK
85 {
86 DWORD Tag; /* Must be LOCK_TAG */
87 DWORD TimeWhenLocked; /* Number of seconds since 1970 */
88 PSID LockOwnerSid; /* It is NULL if the SCM aquired the lock */
89 } START_LOCK, *PSTART_LOCK;
90
91
92 /* VARIABLES ***************************************************************/
93
94 extern LIST_ENTRY ServiceListHead;
95 extern LIST_ENTRY GroupListHead;
96 extern LIST_ENTRY ImageListHead;
97 extern BOOL ScmInitialize;
98 extern BOOL ScmShutdown;
99
100
101 /* FUNCTIONS ***************************************************************/
102
103 /* config.c */
104
105 DWORD ScmOpenServiceKey(LPWSTR lpServiceName,
106 REGSAM samDesired,
107 PHKEY phKey);
108
109 DWORD ScmCreateServiceKey(LPCWSTR lpServiceName,
110 REGSAM samDesired,
111 PHKEY phKey);
112
113 DWORD ScmWriteDependencies(HKEY hServiceKey,
114 LPCWSTR lpDependencies,
115 DWORD dwDependenciesLength);
116
117 DWORD ScmMarkServiceForDelete(PSERVICE pService);
118 BOOL ScmIsDeleteFlagSet(HKEY hServiceKey);
119
120 DWORD ScmReadString(HKEY hServiceKey,
121 LPCWSTR lpValueName,
122 LPWSTR *lpValue);
123
124 DWORD
125 ScmReadDependencies(HKEY hServiceKey,
126 LPWSTR *lpDependencies,
127 DWORD *lpdwDependenciesLength);
128
129 DWORD
130 ScmSetServicePassword(
131 IN PCWSTR pszServiceName,
132 IN PCWSTR pszPassword);
133
134 /* controlset.c */
135
136 BOOL ScmGetControlSetValues(VOID);
137
138
139 /* database.c */
140
141 DWORD ScmCreateServiceDatabase(VOID);
142 VOID ScmShutdownServiceDatabase(VOID);
143 VOID ScmGetBootAndSystemDriverState(VOID);
144 VOID ScmAutoStartServices(VOID);
145 VOID ScmAutoShutdownServices(VOID);
146 DWORD ScmStartService(PSERVICE Service,
147 DWORD argc,
148 LPWSTR *argv);
149
150 PSERVICE ScmGetServiceEntryByName(LPCWSTR lpServiceName);
151 PSERVICE ScmGetServiceEntryByDisplayName(LPCWSTR lpDisplayName);
152 PSERVICE ScmGetServiceEntryByResumeCount(DWORD dwResumeCount);
153 DWORD ScmCreateNewServiceRecord(LPCWSTR lpServiceName,
154 PSERVICE *lpServiceRecord);
155 VOID ScmDeleteServiceRecord(PSERVICE lpService);
156 DWORD ScmMarkServiceForDelete(PSERVICE pService);
157
158 DWORD ScmControlService(PSERVICE Service,
159 DWORD dwControl);
160
161 BOOL ScmLockDatabaseExclusive(VOID);
162 BOOL ScmLockDatabaseShared(VOID);
163 VOID ScmUnlockDatabase(VOID);
164
165 VOID ScmInitNamedPipeCriticalSection(VOID);
166 VOID ScmDeleteNamedPipeCriticalSection(VOID);
167
168
169 /* driver.c */
170
171 DWORD ScmLoadDriver(PSERVICE lpService);
172 DWORD ScmUnloadDriver(PSERVICE lpService);
173 DWORD ScmControlDriver(PSERVICE lpService,
174 DWORD dwControl,
175 LPSERVICE_STATUS lpServiceStatus);
176
177
178 /* groupdb.c */
179
180 DWORD ScmCreateGroupList(VOID);
181 DWORD ScmSetServiceGroup(PSERVICE lpService,
182 LPCWSTR lpGroupName);
183
184
185 /* lock.c */
186
187 DWORD ScmAcquireServiceStartLock(IN BOOL IsServiceController,
188 OUT LPSC_RPC_LOCK lpLock);
189 DWORD ScmReleaseServiceStartLock(IN OUT LPSC_RPC_LOCK lpLock);
190 VOID ScmQueryServiceLockStatusW(OUT LPQUERY_SERVICE_LOCK_STATUSW lpLockStatus);
191 VOID ScmQueryServiceLockStatusA(OUT LPQUERY_SERVICE_LOCK_STATUSA lpLockStatus);
192
193
194 /* rpcserver.c */
195
196 VOID ScmStartRpcServer(VOID);
197
198
199 /* services.c */
200
201 VOID PrintString(LPCSTR fmt, ...);
202 VOID ScmLogEvent(DWORD dwEventId,
203 WORD wType,
204 WORD wStrings,
205 LPCWSTR *lpStrings);
206 VOID ScmWaitForLsa(VOID);
207
208 #endif /* _SERVICES_H */