Sync with trunk r63935.
[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
10 #define WIN32_NO_STATUS
11 #define _INC_WINDOWS
12 #define COM_NO_WINDOWS_H
13
14 #include <windef.h>
15 #include <winbase.h>
16 #include <winsvc.h>
17 #include <winreg.h>
18 #include <netevent.h>
19 #define NTOS_MODE_USER
20 #include <ndk/obfuncs.h>
21 #include <ndk/rtlfuncs.h>
22 #include <services/services.h>
23 #include <svcctl_s.h>
24
25 typedef struct _SERVICE_GROUP
26 {
27 LIST_ENTRY GroupListEntry;
28 LPWSTR lpGroupName;
29
30 DWORD dwRefCount;
31 BOOLEAN ServicesRunning;
32 ULONG TagCount;
33 PULONG TagArray;
34
35 WCHAR szGroupName[1];
36 } SERVICE_GROUP, *PSERVICE_GROUP;
37
38
39 typedef struct _SERVICE_IMAGE
40 {
41 LIST_ENTRY ImageListEntry;
42 DWORD dwImageRunCount;
43
44 HANDLE hControlPipe;
45 HANDLE hProcess;
46 DWORD dwProcessId;
47
48 WCHAR szImagePath[1];
49 } SERVICE_IMAGE, *PSERVICE_IMAGE;
50
51
52 typedef struct _SERVICE
53 {
54 LIST_ENTRY ServiceListEntry;
55 LPWSTR lpServiceName;
56 LPWSTR lpDisplayName;
57 PSERVICE_GROUP lpGroup;
58 PSERVICE_IMAGE lpImage;
59 BOOL bDeleted;
60 DWORD dwResumeCount;
61 DWORD dwRefCount;
62
63 SERVICE_STATUS Status;
64 DWORD dwStartType;
65 DWORD dwErrorControl;
66 DWORD dwTag;
67
68 ULONG Flags;
69
70 PSECURITY_DESCRIPTOR lpSecurityDescriptor;
71
72 BOOLEAN ServiceVisited;
73
74 WCHAR szServiceName[1];
75 } SERVICE, *PSERVICE;
76
77
78 #define LOCK_TAG 0x4C697041 /* 'ApiL' */
79
80 typedef struct _START_LOCK
81 {
82 DWORD Tag; /* Must be LOCK_TAG */
83 DWORD TimeWhenLocked; /* Number of seconds since 1970 */
84 PSID LockOwnerSid; /* It is NULL if the SCM aquired the lock */
85 } START_LOCK, *PSTART_LOCK;
86
87
88 /* VARIABLES ***************************************************************/
89
90 extern LIST_ENTRY ServiceListHead;
91 extern LIST_ENTRY GroupListHead;
92 extern LIST_ENTRY ImageListHead;
93 extern BOOL ScmInitialize;
94 extern BOOL ScmShutdown;
95
96
97 /* FUNCTIONS ***************************************************************/
98
99 /* config.c */
100
101 DWORD ScmOpenServiceKey(LPWSTR lpServiceName,
102 REGSAM samDesired,
103 PHKEY phKey);
104
105 DWORD ScmCreateServiceKey(LPCWSTR lpServiceName,
106 REGSAM samDesired,
107 PHKEY phKey);
108
109 DWORD ScmWriteDependencies(HKEY hServiceKey,
110 LPCWSTR lpDependencies,
111 DWORD dwDependenciesLength);
112
113 DWORD ScmMarkServiceForDelete(PSERVICE pService);
114 BOOL ScmIsDeleteFlagSet(HKEY hServiceKey);
115
116 DWORD ScmReadString(HKEY hServiceKey,
117 LPCWSTR lpValueName,
118 LPWSTR *lpValue);
119
120 DWORD
121 ScmReadDependencies(HKEY hServiceKey,
122 LPWSTR *lpDependencies,
123 DWORD *lpdwDependenciesLength);
124
125
126 /* controlset.c */
127
128 BOOL ScmGetControlSetValues(VOID);
129
130
131 /* database.c */
132
133 DWORD ScmCreateServiceDatabase(VOID);
134 VOID ScmShutdownServiceDatabase(VOID);
135 VOID ScmGetBootAndSystemDriverState(VOID);
136 VOID ScmAutoStartServices(VOID);
137 VOID ScmAutoShutdownServices(VOID);
138 DWORD ScmStartService(PSERVICE Service,
139 DWORD argc,
140 LPWSTR *argv);
141
142 PSERVICE ScmGetServiceEntryByName(LPCWSTR lpServiceName);
143 PSERVICE ScmGetServiceEntryByDisplayName(LPCWSTR lpDisplayName);
144 PSERVICE ScmGetServiceEntryByResumeCount(DWORD dwResumeCount);
145 DWORD ScmCreateNewServiceRecord(LPCWSTR lpServiceName,
146 PSERVICE *lpServiceRecord);
147 VOID ScmDeleteServiceRecord(PSERVICE lpService);
148 DWORD ScmMarkServiceForDelete(PSERVICE pService);
149
150 DWORD ScmControlService(PSERVICE Service,
151 DWORD dwControl);
152
153 BOOL ScmLockDatabaseExclusive(VOID);
154 BOOL ScmLockDatabaseShared(VOID);
155 VOID ScmUnlockDatabase(VOID);
156
157 VOID ScmInitNamedPipeCriticalSection(VOID);
158 VOID ScmDeleteNamedPipeCriticalSection(VOID);
159
160
161 /* driver.c */
162
163 DWORD ScmLoadDriver(PSERVICE lpService);
164 DWORD ScmUnloadDriver(PSERVICE lpService);
165 DWORD ScmControlDriver(PSERVICE lpService,
166 DWORD dwControl,
167 LPSERVICE_STATUS lpServiceStatus);
168
169
170 /* groupdb.c */
171
172 DWORD ScmCreateGroupList(VOID);
173 DWORD ScmSetServiceGroup(PSERVICE lpService,
174 LPCWSTR lpGroupName);
175
176
177 /* lock.c */
178 DWORD ScmAcquireServiceStartLock(IN BOOL IsServiceController,
179 OUT LPSC_RPC_LOCK lpLock);
180 DWORD ScmReleaseServiceStartLock(IN OUT LPSC_RPC_LOCK lpLock);
181 VOID ScmQueryServiceLockStatusW(OUT LPQUERY_SERVICE_LOCK_STATUSW lpLockStatus);
182 VOID ScmQueryServiceLockStatusA(OUT LPQUERY_SERVICE_LOCK_STATUSA lpLockStatus);
183
184
185 /* rpcserver.c */
186
187 VOID ScmStartRpcServer(VOID);
188
189
190 /* services.c */
191
192 VOID PrintString(LPCSTR fmt, ...);
193 VOID ScmLogError(DWORD dwEventId,
194 WORD wStrings,
195 LPCWSTR *lpStrings);
196 VOID ScmWaitForLsa(VOID);
197
198 #endif /* _SERVICES_H */