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