ReactOS  0.4.13-dev-650-g34bf247
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/obfuncs.h>
23 #include <ndk/rtlfuncs.h>
24 #include <services/services.h>
25 #include <svcctl_s.h>
26 
27 #include "resource.h"
28 
29 typedef struct _SERVICE_GROUP
30 {
33 
38 
41 
42 
43 typedef struct _SERVICE_IMAGE
44 {
49 
56 
57 
58 typedef struct _SERVICE
59 {
68 
73 
75 
77 
79 
81 
83 } SERVICE, *PSERVICE;
84 
85 
86 #define LOCK_TAG 0x4C697041 /* 'ApiL' */
87 
88 typedef struct _START_LOCK
89 {
90  DWORD Tag; /* Must be LOCK_TAG */
91  DWORD TimeWhenLocked; /* Number of seconds since 1970 */
92  PSID LockOwnerSid; /* It is NULL if the SCM acquired the lock */
94 
95 
96 /* VARIABLES ***************************************************************/
97 
101 extern BOOL ScmInitialize;
102 extern BOOL ScmShutdown;
103 
104 
105 /* FUNCTIONS ***************************************************************/
106 
107 /* config.c */
108 
109 DWORD ScmOpenServiceKey(LPWSTR lpServiceName,
110  REGSAM samDesired,
111  PHKEY phKey);
112 
113 DWORD ScmCreateServiceKey(LPCWSTR lpServiceName,
114  REGSAM samDesired,
115  PHKEY phKey);
116 
117 DWORD ScmWriteDependencies(HKEY hServiceKey,
118  LPCWSTR lpDependencies,
119  DWORD dwDependenciesLength);
120 
122 BOOL ScmIsDeleteFlagSet(HKEY hServiceKey);
123 
124 DWORD ScmReadString(HKEY hServiceKey,
125  LPCWSTR lpValueName,
126  LPWSTR *lpValue);
127 
128 DWORD
129 ScmReadDependencies(HKEY hServiceKey,
130  LPWSTR *lpDependencies,
131  DWORD *lpdwDependenciesLength);
132 
133 DWORD
135  IN PCWSTR pszServiceName,
136  IN PCWSTR pszPassword);
137 
138 DWORD
140  _In_ HKEY hServiceKey,
141  _In_ PSECURITY_DESCRIPTOR pSecurityDescriptor);
142 
143 DWORD
145  _In_ HKEY hServiceKey,
146  _Out_ PSECURITY_DESCRIPTOR *ppSecurityDescriptor);
147 
148 DWORD
150  _In_ HKEY hKey,
151  _In_ PCWSTR pszSubKey);
152 
153 DWORD
155  _In_ PBYTE pPassword,
156  _In_ DWORD dwPasswordSize,
157  _Out_ PWSTR *pDecryptedPassword);
158 
159 
160 /* controlset.c */
161 
162 DWORD
164 
165 
166 /* database.c */
167 
174  DWORD argc,
175  LPWSTR *argv);
176 
182  PSERVICE *lpServiceRecord,
183  DWORD dwServiceType,
184  DWORD dwStartType);
187 
188 DWORD ScmControlService(HANDLE hControlPipe,
189  PWSTR pServiceName,
191  DWORD dwControl);
192 
196 
199 
202 
203 DWORD ScmGenerateServiceTag(PSERVICE lpServiceRecord);
204 
205 /* driver.c */
206 
207 DWORD ScmStartDriver(PSERVICE lpService);
209  DWORD dwControl,
210  LPSERVICE_STATUS lpServiceStatus);
211 
212 
213 /* groupdb.c */
214 
217  _In_ LPCWSTR lpGroupName);
218 
221  LPCWSTR lpGroupName);
222 
223 
224 /* lock.c */
225 
226 DWORD ScmAcquireServiceStartLock(IN BOOL IsServiceController,
227  OUT LPSC_RPC_LOCK lpLock);
231 
232 
233 /* rpcserver.c */
234 
236 
237 
238 /* security.c */
239 
242 
243 DWORD
245  PSECURITY_DESCRIPTOR *ppSecurityDescriptor);
246 
247 
248 /* services.c */
249 
250 VOID PrintString(LPCSTR fmt, ...);
251 VOID ScmLogEvent(DWORD dwEventId,
252  WORD wType,
253  WORD wStrings,
254  LPCWSTR *lpStrings);
256 
257 #endif /* _SERVICES_H */
DWORD dwProcessId
Definition: services.h:52
static int argc
Definition: ServiceArgs.c:12
const uint16_t * PCWSTR
Definition: typedefs.h:55
DWORD ScmInitializeSecurity(VOID)
Definition: security.c:288
#define IN
Definition: typedefs.h:38
SERVICE_STATUS Status
Definition: services.h:69
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:47
HANDLE hToken
Definition: services.h:53
LIST_ENTRY ImageListEntry
Definition: services.h:45
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
VOID ScmLogEvent(DWORD dwEventId, WORD wType, WORD wStrings, LPCWSTR *lpStrings)
Definition: services.c:52
DWORD ScmCreateDefaultServiceSD(PSECURITY_DESCRIPTOR *ppSecurityDescriptor)
Definition: security.c:235
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:987
struct _SERVICE SERVICE
DWORD ScmGenerateServiceTag(PSERVICE lpServiceRecord)
Definition: database.c:643
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:32
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
VOID ScmAutoShutdownServices(VOID)
Definition: database.c:2272
PSERVICE_GROUP lpGroup
Definition: services.h:63
DWORD ScmDecryptPassword(_In_ PBYTE pPassword, _In_ DWORD dwPasswordSize, _Out_ PWSTR *pDecryptedPassword)
Definition: config.c:701
LPWSTR lpDisplayName
Definition: services.h:62
#define argv
Definition: mplay32.c:18
VOID ScmDeleteServiceRecord(PSERVICE lpService)
Definition: database.c:715
DWORD ScmStartService(PSERVICE Service, DWORD argc, LPWSTR *argv)
Definition: database.c:2021
DWORD ScmCreateLastKnownGoodControlSet(VOID)
Definition: controlset.c:465
WCHAR szGroupName[1]
Definition: services.h:39
struct _SERVICE_IMAGE SERVICE_IMAGE
DWORD dwImageRunCount
Definition: services.h:48
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL ScmInitialize
Definition: services.c:28
DWORD dwRefCount
Definition: services.h:67
DWORD ScmAcquireServiceStartLock(IN BOOL IsServiceController, OUT LPSC_RPC_LOCK lpLock)
Definition: lock.c:31
VOID ScmDeleteNamedPipeCriticalSection(VOID)
Definition: database.c:2359
unsigned char BOOLEAN
LIST_ENTRY ServiceListHead
Definition: database.c:29
VOID PrintString(LPCSTR fmt,...)
Definition: services.c:36
#define _Out_
Definition: no_sal2.h:323
ULONG Flags
Definition: services.h:76
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:556
const char * LPCSTR
Definition: xmlstorage.h:183
VOID ScmInitNamedPipeCriticalSection(VOID)
Definition: database.c:2331
BOOL ScmLockDatabaseShared(VOID)
Definition: database.c:2317
static SERVICE_STATUS_HANDLE(WINAPI *pRegisterServiceCtrlHandlerExA)(LPCSTR
BOOLEAN ServicesRunning
Definition: services.h:35
struct _START_LOCK START_LOCK
DWORD ScmWriteDependencies(HKEY hServiceKey, LPCWSTR lpDependencies, DWORD dwDependenciesLength)
Definition: config.c:117
LIST_ENTRY ServiceListEntry
Definition: services.h:60
__wchar_t WCHAR
Definition: xmlstorage.h:180
HANDLE hProfile
Definition: services.h:54
unsigned short WORD
Definition: ntddk_ex.h:93
DWORD ScmControlService(HANDLE hControlPipe, PWSTR pServiceName, SERVICE_STATUS_HANDLE hServiceStatus, DWORD dwControl)
Definition: database.c:1213
unsigned long DWORD
Definition: ntddk_ex.h:95
PSERVICE_GROUP ScmGetServiceGroupByName(_In_ LPCWSTR lpGroupName)
Definition: groupdb.c:26
BOOLEAN ServiceVisited
Definition: services.h:80
DWORD dwResumeCount
Definition: services.h:66
DWORD ScmGetServiceNameFromTag(PTAG_INFO_NAME_FROM_TAG_IN_PARAMS InParams, PTAG_INFO_NAME_FROM_TAG_OUT_PARAMS *OutParams)
LPWSTR lpServiceName
Definition: services.h:61
VOID ScmGetBootAndSystemDriverState(VOID)
Definition: database.c:1184
PSID LockOwnerSid
Definition: services.h:92
DWORD TimeWhenLocked
Definition: services.h:91
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:78
SERVICE_STATUS_HANDLE hServiceStatus
Definition: main.c:10
DWORD dwRefCount
Definition: services.h:34
LIST_ENTRY GroupListEntry
Definition: services.h:31
PULONG TagArray
Definition: services.h:37
DWORD dwStartType
Definition: services.h:70
#define _In_
Definition: no_sal2.h:204
LPWSTR pszImagePath
Definition: services.h:46
ULONG TagCount
Definition: services.h:36
VOID ScmWaitForLsa(VOID)
Definition: services.c:85
VOID ScmShutdownSecurity(VOID)
Definition: security.c:309
LIST_ENTRY GroupListHead
Definition: groupdb.c:19
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:2310
DWORD ScmControlDriver(PSERVICE lpService, DWORD dwControl, LPSERVICE_STATUS lpServiceStatus)
Definition: driver.c:335
DWORD dwTag
Definition: services.h:72
DWORD dwErrorControl
Definition: services.h:71
PSERVICE ScmGetServiceEntryByResumeCount(DWORD dwResumeCount)
Definition: database.c:614
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:585
unsigned int ULONG
Definition: retypes.h:1
VOID ScmAutoStartServices(VOID)
Definition: database.c:2061
DWORD ScmReadString(HKEY hServiceKey, LPCWSTR lpValueName, LPWSTR *lpValue)
Definition: config.c:270
BOOL bDeleted
Definition: services.h:65
DWORD dwServiceBits
Definition: services.h:74
WCHAR * LPWSTR
Definition: xmlstorage.h:184
PSERVICE_IMAGE lpImage
Definition: services.h:64
WCHAR szServiceName[1]
Definition: services.h:82
VOID ScmStartRpcServer(VOID)
Definition: rpcserver.c:105
HANDLE hProcess
Definition: services.h:51
DWORD ScmStartDriver(PSERVICE lpService)
Definition: driver.c:314
struct _SERVICE_GROUP SERVICE_GROUP
HANDLE hControlPipe
Definition: services.h:50
BOOL ScmShutdown
Definition: services.c:29
DWORD ScmCreateNewServiceRecord(LPCWSTR lpServiceName, PSERVICE *lpServiceRecord, DWORD dwServiceType, DWORD dwStartType)
Definition: database.c:666
DWORD Tag
Definition: services.h:90
_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:525
VOID ScmUnlockDatabase(VOID)
Definition: database.c:2324
VOID ScmShutdownServiceDatabase(VOID)
Definition: database.c:1074