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