ReactOS  0.4.14-dev-55-g2da92ac
services.h
Go to the documentation of this file.
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/setypes.h>
23 #include <ndk/obfuncs.h>
24 #include <ndk/rtlfuncs.h>
25 #include <services/services.h>
26 #include <svcctl_s.h>
27 
28 #include "resource.h"
29 
30 typedef struct _SERVICE_GROUP
31 {
34 
39 
42 
43 
44 typedef struct _SERVICE_IMAGE
45 {
50 
57 
58 
59 typedef struct _SERVICE
60 {
69 
74 
76 
78 
80 
82 
84 } SERVICE, *PSERVICE;
85 
86 
87 #define LOCK_TAG 0x4C697041 /* 'ApiL' */
88 
89 typedef struct _START_LOCK
90 {
91  DWORD Tag; /* Must be LOCK_TAG */
92  DWORD TimeWhenLocked; /* Number of seconds since 1970 */
93  PSID LockOwnerSid; /* It is NULL if the SCM acquired the lock */
95 
96 
97 /* VARIABLES ***************************************************************/
98 
102 extern BOOL ScmInitialize;
103 extern BOOL ScmShutdown;
105 
106 
107 /* FUNCTIONS ***************************************************************/
108 
109 /* config.c */
110 
111 DWORD ScmOpenServiceKey(LPWSTR lpServiceName,
112  REGSAM samDesired,
113  PHKEY phKey);
114 
115 DWORD ScmCreateServiceKey(LPCWSTR lpServiceName,
116  REGSAM samDesired,
117  PHKEY phKey);
118 
119 DWORD ScmWriteDependencies(HKEY hServiceKey,
120  LPCWSTR lpDependencies,
121  DWORD dwDependenciesLength);
122 
124 BOOL ScmIsDeleteFlagSet(HKEY hServiceKey);
125 
126 DWORD ScmReadString(HKEY hServiceKey,
127  LPCWSTR lpValueName,
128  LPWSTR *lpValue);
129 
130 DWORD
131 ScmReadDependencies(HKEY hServiceKey,
132  LPWSTR *lpDependencies,
133  DWORD *lpdwDependenciesLength);
134 
135 DWORD
137  IN PCWSTR pszServiceName,
138  IN PCWSTR pszPassword);
139 
140 DWORD
142  _In_ HKEY hServiceKey,
143  _In_ PSECURITY_DESCRIPTOR pSecurityDescriptor);
144 
145 DWORD
147  _In_ HKEY hServiceKey,
148  _Out_ PSECURITY_DESCRIPTOR *ppSecurityDescriptor);
149 
150 DWORD
152  _In_ HKEY hKey,
153  _In_ PCWSTR pszSubKey);
154 
155 DWORD
157  _In_ PBYTE pPassword,
158  _In_ DWORD dwPasswordSize,
159  _Out_ PWSTR *pDecryptedPassword);
160 
161 
162 /* controlset.c */
163 
164 DWORD
166 
167 DWORD
169 
170 DWORD
172 
173 
174 /* database.c */
175 
182  DWORD argc,
183  LPWSTR *argv);
184 
190  PSERVICE *lpServiceRecord,
191  DWORD dwServiceType,
192  DWORD dwStartType);
195 
196 DWORD ScmControlService(HANDLE hControlPipe,
197  PWSTR pServiceName,
199  DWORD dwControl);
200 
204 
207 
210 
211 DWORD ScmGenerateServiceTag(PSERVICE lpServiceRecord);
212 
213 /* driver.c */
214 
215 DWORD ScmStartDriver(PSERVICE lpService);
217  DWORD dwControl,
218  LPSERVICE_STATUS lpServiceStatus);
219 
220 
221 /* groupdb.c */
222 
225  _In_ LPCWSTR lpGroupName);
226 
229  LPCWSTR lpGroupName);
230 
231 
232 /* lock.c */
233 
234 DWORD ScmAcquireServiceStartLock(IN BOOL IsServiceController,
235  OUT LPSC_RPC_LOCK lpLock);
239 
240 
241 /* rpcserver.c */
242 
244 
245 
246 /* security.c */
247 
250 
251 DWORD
253  PSECURITY_DESCRIPTOR *ppSecurityDescriptor);
254 
255 
256 /* services.c */
257 
258 VOID PrintString(LPCSTR fmt, ...);
260 VOID ScmLogEvent(DWORD dwEventId,
261  WORD wType,
262  WORD wStrings,
263  LPCWSTR *lpStrings);
265 
266 #endif /* _SERVICES_H */
DWORD ScmRunLastKnownGood(VOID)
Definition: controlset.c:740
DWORD dwProcessId
Definition: services.h:53
static int argc
Definition: ServiceArgs.c:12
const uint16_t * PCWSTR
Definition: typedefs.h:55
DWORD ScmInitializeSecurity(VOID)
Definition: security.c:372
#define IN
Definition: typedefs.h:38
SERVICE_STATUS Status
Definition: services.h:70
DWORD ScmReleaseServiceStartLock(IN OUT LPSC_RPC_LOCK lpLock)
Definition: lock.c:82
DWORD ScmWriteSecurityDescriptor(_In_ HKEY hServiceKey, _In_ PSECURITY_DESCRIPTOR pSecurityDescriptor)
Definition: config.c:523
VOID ScmQueryServiceLockStatusW(OUT LPQUERY_SERVICE_LOCK_STATUSW lpLockStatus)
Definition: lock.c:127
LPWSTR pszAccountName
Definition: services.h:48
HANDLE hToken
Definition: services.h:54
LIST_ENTRY ImageListEntry
Definition: services.h:46
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
VOID ScmLogEvent(DWORD dwEventId, WORD wType, WORD wStrings, LPCWSTR *lpStrings)
Definition: services.c:85
DWORD ScmCreateDefaultServiceSD(PSECURITY_DESCRIPTOR *ppSecurityDescriptor)
Definition: security.c:319
DWORD ScmSetServiceGroup(PSERVICE lpService, LPCWSTR lpGroupName)
Definition: groupdb.c:61
struct _SERVICE * PSERVICE
uint16_t * PWSTR
Definition: typedefs.h:54
DWORD ScmCreateServiceDatabase(VOID)
Definition: database.c:1088
struct _SERVICE SERVICE
DWORD ScmGenerateServiceTag(PSERVICE lpServiceRecord)
Definition: database.c:744
DWORD ScmOpenServiceKey(LPWSTR lpServiceName, REGSAM samDesired, PHKEY phKey)
Definition: config.c:42
BOOL ScmIsDeleteFlagSet(HKEY hServiceKey)
Definition: config.c:251
LPWSTR lpGroupName
Definition: services.h:33
DWORD ScmSetServicePassword(IN PCWSTR pszServiceName, IN PCWSTR pszPassword)
Definition: config.c:469
DWORD ScmDeleteRegKey(_In_ HKEY hKey, _In_ PCWSTR pszSubKey)
Definition: config.c:639
LIST_ENTRY ImageListHead
Definition: database.c:28
PSECURITY_DESCRIPTOR pPipeSD
Definition: security.c:27
VOID ScmAutoShutdownServices(VOID)
Definition: database.c:2382
PSERVICE_GROUP lpGroup
Definition: services.h:64
DWORD ScmDecryptPassword(_In_ PBYTE pPassword, _In_ DWORD dwPasswordSize, _Out_ PWSTR *pDecryptedPassword)
Definition: config.c:701
LPWSTR lpDisplayName
Definition: services.h:63
#define argv
Definition: mplay32.c:18
VOID ScmDeleteServiceRecord(PSERVICE lpService)
Definition: database.c:816
DWORD ScmStartService(PSERVICE Service, DWORD argc, LPWSTR *argv)
Definition: database.c:2131
DWORD ScmCreateLastKnownGoodControlSet(VOID)
Definition: controlset.c:613
WCHAR szGroupName[1]
Definition: services.h:40
struct _SERVICE_IMAGE SERVICE_IMAGE
DWORD dwImageRunCount
Definition: services.h:49
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL ScmInitialize
Definition: services.c:28
DWORD dwRefCount
Definition: services.h:68
DWORD ScmAcquireServiceStartLock(IN BOOL IsServiceController, OUT LPSC_RPC_LOCK lpLock)
Definition: lock.c:31
VOID ScmDeleteNamedPipeCriticalSection(VOID)
Definition: database.c:2469
unsigned char BOOLEAN
LIST_ENTRY ServiceListHead
Definition: database.c:29
VOID PrintString(LPCSTR fmt,...)
Definition: services.c:37
#define _Out_
Definition: no_sal2.h:323
ULONG Flags
Definition: services.h:77
struct _START_LOCK * PSTART_LOCK
DWORD ScmMarkServiceForDelete(PSERVICE pService)
Definition: config.c:223
VOID ScmQueryServiceLockStatusA(OUT LPQUERY_SERVICE_LOCK_STATUSA lpLockStatus)
Definition: lock.c:159
PSERVICE ScmGetServiceEntryByName(LPCWSTR lpServiceName)
Definition: database.c:657
const char * LPCSTR
Definition: xmlstorage.h:183
VOID ScmInitNamedPipeCriticalSection(VOID)
Definition: database.c:2441
BOOL ScmLockDatabaseShared(VOID)
Definition: database.c:2427
static SERVICE_STATUS_HANDLE(WINAPI *pRegisterServiceCtrlHandlerExA)(LPCSTR
BOOLEAN ServicesRunning
Definition: services.h:36
struct _START_LOCK START_LOCK
DWORD ScmWriteDependencies(HKEY hServiceKey, LPCWSTR lpDependencies, DWORD dwDependenciesLength)
Definition: config.c:117
LIST_ENTRY ServiceListEntry
Definition: services.h:61
__wchar_t WCHAR
Definition: xmlstorage.h:180
HANDLE hProfile
Definition: services.h:55
unsigned short WORD
Definition: ntddk_ex.h:93
DWORD ScmControlService(HANDLE hControlPipe, PWSTR pServiceName, SERVICE_STATUS_HANDLE hServiceStatus, DWORD dwControl)
Definition: database.c:1314
unsigned long DWORD
Definition: ntddk_ex.h:95
PSERVICE_GROUP ScmGetServiceGroupByName(_In_ LPCWSTR lpGroupName)
Definition: groupdb.c:26
BOOLEAN ServiceVisited
Definition: services.h:81
DWORD dwResumeCount
Definition: services.h:67
DWORD ScmGetServiceNameFromTag(PTAG_INFO_NAME_FROM_TAG_IN_PARAMS InParams, PTAG_INFO_NAME_FROM_TAG_OUT_PARAMS *OutParams)
LPWSTR lpServiceName
Definition: services.h:62
VOID ScmGetBootAndSystemDriverState(VOID)
Definition: database.c:1285
PSID LockOwnerSid
Definition: services.h:93
DWORD TimeWhenLocked
Definition: services.h:92
DWORD ScmReadDependencies(HKEY hServiceKey, LPWSTR *lpDependencies, DWORD *lpdwDependenciesLength)
Definition: config.c:349
struct _SERVICE_GROUP * PSERVICE_GROUP
Definition: typedefs.h:117
PSECURITY_DESCRIPTOR pSecurityDescriptor
Definition: services.h:79
SERVICE_STATUS_HANDLE hServiceStatus
Definition: main.c:10
DWORD dwRefCount
Definition: services.h:35
LIST_ENTRY GroupListEntry
Definition: services.h:32
PULONG TagArray
Definition: services.h:38
DWORD dwStartType
Definition: services.h:71
#define _In_
Definition: no_sal2.h:204
LPWSTR pszImagePath
Definition: services.h:47
ULONG TagCount
Definition: services.h:37
VOID ScmWaitForLsa(VOID)
Definition: services.c:118
VOID ScmShutdownSecurity(VOID)
Definition: security.c:397
LIST_ENTRY GroupListHead
Definition: groupdb.c:19
DWORD ScmAcceptBoot(VOID)
Definition: controlset.c:674
DWORD ScmCreateGroupList(VOID)
Definition: groupdb.c:235
ACCESS_MASK REGSAM
Definition: winreg.h:69
unsigned int * PULONG
Definition: retypes.h:1
BOOL ScmLockDatabaseExclusive(VOID)
Definition: database.c:2420
DWORD ScmControlDriver(PSERVICE lpService, DWORD dwControl, LPSERVICE_STATUS lpServiceStatus)
Definition: driver.c:335
DWORD dwTag
Definition: services.h:73
DWORD dwErrorControl
Definition: services.h:72
PSERVICE ScmGetServiceEntryByResumeCount(DWORD dwResumeCount)
Definition: database.c:715
DWORD ScmReadSecurityDescriptor(_In_ HKEY hServiceKey, _Out_ PSECURITY_DESCRIPTOR *ppSecurityDescriptor)
Definition: config.c:559
#define OUT
Definition: typedefs.h:39
struct _SERVICE_IMAGE * PSERVICE_IMAGE
DWORD ScmCreateServiceKey(LPCWSTR lpServiceName, REGSAM samDesired, PHKEY phKey)
Definition: config.c:72
PSERVICE ScmGetServiceEntryByDisplayName(LPCWSTR lpDisplayName)
Definition: database.c:686
unsigned int ULONG
Definition: retypes.h:1
VOID ScmAutoStartServices(VOID)
Definition: database.c:2171
DWORD ScmReadString(HKEY hServiceKey, LPCWSTR lpValueName, LPWSTR *lpValue)
Definition: config.c:270
BOOL bDeleted
Definition: services.h:66
DWORD dwServiceBits
Definition: services.h:75
WCHAR * LPWSTR
Definition: xmlstorage.h:184
PSERVICE_IMAGE lpImage
Definition: services.h:65
WCHAR szServiceName[1]
Definition: services.h:83
VOID ScmStartRpcServer(VOID)
Definition: rpcserver.c:105
HANDLE hProcess
Definition: services.h:52
DWORD ScmStartDriver(PSERVICE lpService)
Definition: driver.c:314
struct _SERVICE_GROUP SERVICE_GROUP
HANDLE hControlPipe
Definition: services.h:51
BOOL ScmShutdown
Definition: services.c:29
DWORD ScmCreateNewServiceRecord(LPCWSTR lpServiceName, PSERVICE *lpServiceRecord, DWORD dwServiceType, DWORD dwStartType)
Definition: database.c:767
DWORD Tag
Definition: services.h:91
_In_ LPCSTR _Out_writes_to_opt_ cchDisplayName LPSTR lpDisplayName
Definition: winbase.h:2730
BYTE * PBYTE
Definition: pedump.c:66
Definition: dsound.c:943
VOID ScmRemoveServiceImage(PSERVICE_IMAGE pServiceImage)
Definition: database.c:622
VOID ScmUnlockDatabase(VOID)
Definition: database.c:2434
VOID ScmShutdownServiceDatabase(VOID)
Definition: database.c:1175
DWORD SetSecurityServicesEvent(VOID)
Definition: services.c:53