ReactOS  0.4.14-dev-1296-g56aa513
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;
104 extern BOOL ScmLiveSetup;
106 
107 
108 /* FUNCTIONS ***************************************************************/
109 
110 /* config.c */
111 
112 DWORD ScmOpenServiceKey(LPWSTR lpServiceName,
113  REGSAM samDesired,
114  PHKEY phKey);
115 
116 DWORD ScmCreateServiceKey(LPCWSTR lpServiceName,
117  REGSAM samDesired,
118  PHKEY phKey);
119 
120 DWORD ScmWriteDependencies(HKEY hServiceKey,
121  LPCWSTR lpDependencies,
122  DWORD dwDependenciesLength);
123 
125 BOOL ScmIsDeleteFlagSet(HKEY hServiceKey);
126 
127 DWORD ScmReadString(HKEY hServiceKey,
128  LPCWSTR lpValueName,
129  LPWSTR *lpValue);
130 
131 DWORD
132 ScmReadDependencies(HKEY hServiceKey,
133  LPWSTR *lpDependencies,
134  DWORD *lpdwDependenciesLength);
135 
136 DWORD
138  IN PCWSTR pszServiceName,
139  IN PCWSTR pszPassword);
140 
141 DWORD
143  _In_ HKEY hServiceKey,
144  _In_ PSECURITY_DESCRIPTOR pSecurityDescriptor);
145 
146 DWORD
148  _In_ HKEY hServiceKey,
149  _Out_ PSECURITY_DESCRIPTOR *ppSecurityDescriptor);
150 
151 DWORD
153  _In_ HKEY hKey,
154  _In_ PCWSTR pszSubKey);
155 
156 DWORD
158  _In_ PBYTE pPassword,
159  _In_ DWORD dwPasswordSize,
160  _Out_ PWSTR *pDecryptedPassword);
161 
162 
163 /* controlset.c */
164 
165 DWORD
167 
168 DWORD
170 
171 DWORD
173 
174 
175 /* database.c */
176 
183  DWORD argc,
184  LPWSTR *argv);
185 
191  PSERVICE *lpServiceRecord,
192  DWORD dwServiceType,
193  DWORD dwStartType);
196 
197 DWORD ScmControlService(HANDLE hControlPipe,
198  PWSTR pServiceName,
200  DWORD dwControl);
201 
205 
208 
211 
212 DWORD ScmGenerateServiceTag(PSERVICE lpServiceRecord);
213 
214 /* driver.c */
215 
216 DWORD ScmStartDriver(PSERVICE lpService);
218  DWORD dwControl,
219  LPSERVICE_STATUS lpServiceStatus);
220 
221 
222 /* groupdb.c */
223 
226  _In_ LPCWSTR lpGroupName);
227 
230  LPCWSTR lpGroupName);
231 
232 
233 /* lock.c */
234 
235 DWORD ScmAcquireServiceStartLock(IN BOOL IsServiceController,
236  OUT LPSC_RPC_LOCK lpLock);
240 
241 
242 /* rpcserver.c */
243 
245 
246 
247 /* security.c */
248 
251 
252 DWORD
254  PSECURITY_DESCRIPTOR *ppSecurityDescriptor);
255 
256 
257 /* services.c */
258 
259 VOID PrintString(LPCSTR fmt, ...);
261 VOID ScmLogEvent(DWORD dwEventId,
262  WORD wType,
263  WORD wStrings,
264  LPCWSTR *lpStrings);
266 
267 #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:56
DWORD ScmInitializeSecurity(VOID)
Definition: security.c:372
#define IN
Definition: typedefs.h:39
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:150
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:55
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
BOOL ScmLiveSetup
Definition: services.c:30
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:38
#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:118
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:183
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:40
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:2753
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:118