Synchronize with trunk revision 59636 (just before Alex's CreateProcess revamp).
[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 ScmInitialize;
90 extern BOOL ScmShutdown;
91
92
93 /* FUNCTIONS ***************************************************************/
94
95 /* config.c */
96
97 DWORD ScmOpenServiceKey(LPWSTR lpServiceName,
98 REGSAM samDesired,
99 PHKEY phKey);
100
101 DWORD ScmCreateServiceKey(LPCWSTR lpServiceName,
102 REGSAM samDesired,
103 PHKEY phKey);
104
105 DWORD ScmWriteDependencies(HKEY hServiceKey,
106 LPCWSTR lpDependencies,
107 DWORD dwDependenciesLength);
108
109 DWORD ScmMarkServiceForDelete(PSERVICE pService);
110 BOOL ScmIsDeleteFlagSet(HKEY hServiceKey);
111
112 DWORD ScmReadString(HKEY hServiceKey,
113 LPCWSTR lpValueName,
114 LPWSTR *lpValue);
115
116 DWORD
117 ScmReadDependencies(HKEY hServiceKey,
118 LPWSTR *lpDependencies,
119 DWORD *lpdwDependenciesLength);
120
121
122 /* controlset.c */
123
124 BOOL ScmGetControlSetValues(VOID);
125
126
127 /* database.c */
128
129 DWORD ScmCreateServiceDatabase(VOID);
130 VOID ScmShutdownServiceDatabase(VOID);
131 VOID ScmGetBootAndSystemDriverState(VOID);
132 VOID ScmAutoStartServices(VOID);
133 VOID ScmAutoShutdownServices(VOID);
134 DWORD ScmStartService(PSERVICE Service,
135 DWORD argc,
136 LPWSTR *argv);
137
138 PSERVICE ScmGetServiceEntryByName(LPCWSTR lpServiceName);
139 PSERVICE ScmGetServiceEntryByDisplayName(LPCWSTR lpDisplayName);
140 PSERVICE ScmGetServiceEntryByResumeCount(DWORD dwResumeCount);
141 DWORD ScmCreateNewServiceRecord(LPCWSTR lpServiceName,
142 PSERVICE *lpServiceRecord);
143 VOID ScmDeleteServiceRecord(PSERVICE lpService);
144 DWORD ScmMarkServiceForDelete(PSERVICE pService);
145
146 DWORD ScmControlService(PSERVICE Service,
147 DWORD dwControl);
148
149 BOOL ScmLockDatabaseExclusive(VOID);
150 BOOL ScmLockDatabaseShared(VOID);
151 VOID ScmUnlockDatabase(VOID);
152
153 VOID ScmInitNamedPipeCriticalSection(VOID);
154 VOID ScmDeleteNamedPipeCriticalSection(VOID);
155
156
157 /* driver.c */
158
159 DWORD ScmLoadDriver(PSERVICE lpService);
160 DWORD ScmUnloadDriver(PSERVICE lpService);
161 DWORD ScmControlDriver(PSERVICE lpService,
162 DWORD dwControl,
163 LPSERVICE_STATUS lpServiceStatus);
164
165
166 /* groupdb.c */
167
168 DWORD ScmCreateGroupList(VOID);
169 DWORD ScmSetServiceGroup(PSERVICE lpService,
170 LPCWSTR lpGroupName);
171
172
173 /* lock.c */
174 DWORD ScmAcquireServiceStartLock(IN BOOL IsServiceController,
175 OUT LPSC_RPC_LOCK lpLock);
176 DWORD ScmReleaseServiceStartLock(IN OUT LPSC_RPC_LOCK lpLock);
177 VOID ScmQueryServiceLockStatusW(OUT LPQUERY_SERVICE_LOCK_STATUSW lpLockStatus);
178 VOID ScmQueryServiceLockStatusA(OUT LPQUERY_SERVICE_LOCK_STATUSA lpLockStatus);
179
180
181 /* rpcserver.c */
182
183 VOID ScmStartRpcServer(VOID);
184
185
186 /* services.c */
187
188 VOID PrintString(LPCSTR fmt, ...);
189 VOID ScmLogError(DWORD dwEventId,
190 WORD wStrings,
191 LPCWSTR *lpStrings);
192 VOID ScmWaitForLsa(VOID);
193
194 /* EOF */