ReactOS 0.4.15-dev-8227-g32d615f
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
30typedef struct _SERVICE_GROUP
31{
34
39
42
43
44typedef struct _SERVICE_IMAGE
45{
50
57
58
59typedef struct _SERVICE
60{
69
74
77
79
81
83
86
87
88#define LOCK_TAG 0x4C697041 /* 'ApiL' */
89
90typedef struct _START_LOCK
91{
92 DWORD Tag; /* Must be LOCK_TAG */
93 DWORD TimeWhenLocked; /* Number of seconds since 1970 */
94 PSID LockOwnerSid; /* It is NULL if the SCM acquired the lock */
96
97
98/* VARIABLES ***************************************************************/
99
103extern BOOL ScmInitialize;
104extern BOOL ScmShutdown;
105extern BOOL ScmLiveSetup;
108
109
110/* FUNCTIONS ***************************************************************/
111
112/* config.c */
113
114DWORD ScmOpenServiceKey(LPWSTR lpServiceName,
115 REGSAM samDesired,
116 PHKEY phKey);
117
118DWORD ScmCreateServiceKey(LPCWSTR lpServiceName,
119 REGSAM samDesired,
120 PHKEY phKey);
121
123 LPCWSTR lpDependencies,
124 DWORD dwDependenciesLength);
125
127BOOL ScmIsDeleteFlagSet(HKEY hServiceKey);
128
129DWORD ScmReadString(HKEY hServiceKey,
130 LPCWSTR lpValueName,
131 LPWSTR *lpValue);
132
133DWORD
134ScmReadDependencies(HKEY hServiceKey,
135 LPWSTR *lpDependencies,
136 DWORD *lpdwDependenciesLength);
137
138DWORD
140 IN PCWSTR pszServiceName,
141 IN PCWSTR pszPassword);
142
143DWORD
145 _In_ HKEY hServiceKey,
146 _In_ PSECURITY_DESCRIPTOR pSecurityDescriptor);
147
148DWORD
150 _In_ HKEY hServiceKey,
151 _Out_ PSECURITY_DESCRIPTOR *ppSecurityDescriptor);
152
153DWORD
155 _In_ HKEY hKey,
156 _In_ PCWSTR pszSubKey);
157
158DWORD
160 _In_ PVOID ContextHandle,
161 _In_ PBYTE pPassword,
162 _In_ DWORD dwPasswordSize,
163 _Out_ PWSTR *pDecryptedPassword);
164
165
166/* controlset.c */
167
168DWORD
170
171DWORD
173
174DWORD
176
177
178/* database.c */
179
186 DWORD argc,
187 LPWSTR *argv);
188
194 PSERVICE *lpServiceRecord,
195 DWORD dwServiceType,
196 DWORD dwStartType);
199
200DWORD ScmControlService(HANDLE hControlPipe,
201 PWSTR pServiceName,
203 DWORD dwControl);
204
208
211
214
215DWORD ScmGenerateServiceTag(PSERVICE lpServiceRecord);
216
217/* driver.c */
218
219DWORD ScmStartDriver(PSERVICE lpService);
221 DWORD dwControl,
222 LPSERVICE_STATUS lpServiceStatus);
223
224
225/* groupdb.c */
226
229 _In_ LPCWSTR lpGroupName);
230
233 LPCWSTR lpGroupName);
234
235
236/* lock.c */
237
238DWORD ScmAcquireServiceStartLock(IN BOOL IsServiceController,
239 OUT LPSC_RPC_LOCK lpLock);
243
244
245/* rpcserver.c */
246
248
249
250/* security.c */
251
254
255DWORD
257 PSECURITY_DESCRIPTOR *ppSecurityDescriptor);
258
259
260/* services.c */
261
264VOID ScmLogEvent(DWORD dwEventId,
265 WORD wType,
266 WORD wStrings,
267 LPCWSTR *lpStrings);
269
270#endif /* _SERVICES_H */
static SERVICE_STATUS_HANDLE(WINAPI *pRegisterServiceCtrlHandlerExA)(LPCSTR
unsigned char BOOLEAN
static int argc
Definition: ServiceArgs.c:12
VOID ScmQueryServiceLockStatusW(OUT LPQUERY_SERVICE_LOCK_STATUSW lpLockStatus)
Definition: lock.c:127
DWORD ScmReadString(HKEY hServiceKey, LPCWSTR lpValueName, LPWSTR *lpValue)
Definition: config.c:270
DWORD ScmGetServiceNameFromTag(PTAG_INFO_NAME_FROM_TAG_IN_PARAMS InParams, PTAG_INFO_NAME_FROM_TAG_OUT_PARAMS *OutParams)
DWORD ScmRunLastKnownGood(VOID)
Definition: controlset.c:402
DWORD ScmStartDriver(PSERVICE lpService)
Definition: driver.c:314
DWORD ScmCreateLastKnownGoodControlSet(VOID)
Definition: controlset.c:275
VOID ScmAutoStartServices(VOID)
Definition: database.c:2171
PSERVICE ScmGetServiceEntryByResumeCount(DWORD dwResumeCount)
Definition: database.c:715
VOID ScmRemoveServiceImage(PSERVICE_IMAGE pServiceImage)
Definition: database.c:622
VOID PrintString(LPCSTR fmt,...)
Definition: services.c:39
DWORD ScmOpenServiceKey(LPWSTR lpServiceName, REGSAM samDesired, PHKEY phKey)
Definition: config.c:42
BOOL ScmIsDeleteFlagSet(HKEY hServiceKey)
Definition: config.c:251
VOID ScmUnlockDatabase(VOID)
Definition: database.c:2434
VOID ScmWaitForLsa(VOID)
Definition: services.c:207
DWORD ScmWriteSecurityDescriptor(_In_ HKEY hServiceKey, _In_ PSECURITY_DESCRIPTOR pSecurityDescriptor)
Definition: config.c:530
struct _SERVICE * PSERVICE
LIST_ENTRY ImageListHead
Definition: database.c:28
DWORD ScmControlService(HANDLE hControlPipe, PWSTR pServiceName, SERVICE_STATUS_HANDLE hServiceStatus, DWORD dwControl)
Definition: database.c:1314
VOID ScmShutdownSecurity(VOID)
Definition: security.c:398
BOOL ScmShutdown
Definition: services.c:29
DWORD ScmSetServicePassword(IN PCWSTR pszServiceName, IN PCWSTR pszPassword)
Definition: config.c:469
DWORD ScmGenerateServiceTag(PSERVICE lpServiceRecord)
Definition: database.c:744
BOOL ScmInitialize
Definition: services.c:28
struct _SERVICE_IMAGE SERVICE_IMAGE
struct _SERVICE_GROUP * PSERVICE_GROUP
struct _START_LOCK * PSTART_LOCK
DWORD ScmWriteDependencies(HKEY hServiceKey, LPCWSTR lpDependencies, DWORD dwDependenciesLength)
Definition: config.c:117
LIST_ENTRY GroupListHead
Definition: groupdb.c:19
struct _SERVICE_GROUP SERVICE_GROUP
VOID ScmInitNamedPipeCriticalSection(VOID)
Definition: database.c:2441
VOID ScmQueryServiceLockStatusA(OUT LPQUERY_SERVICE_LOCK_STATUSA lpLockStatus)
Definition: lock.c:159
DWORD ScmCreateServiceDatabase(VOID)
Definition: database.c:1088
VOID ScmDeleteServiceRecord(PSERVICE lpService)
Definition: database.c:816
VOID ScmAutoShutdownServices(VOID)
Definition: database.c:2382
BOOL ScmLockDatabaseExclusive(VOID)
Definition: database.c:2420
DWORD ScmReadSecurityDescriptor(_In_ HKEY hServiceKey, _Out_ PSECURITY_DESCRIPTOR *ppSecurityDescriptor)
Definition: config.c:566
VOID ScmGetBootAndSystemDriverState(VOID)
Definition: database.c:1285
DWORD ScmAcquireServiceStartLock(IN BOOL IsServiceController, OUT LPSC_RPC_LOCK lpLock)
Definition: lock.c:31
DWORD ScmCreateGroupList(VOID)
Definition: groupdb.c:235
DWORD ScmReleaseServiceStartLock(IN OUT LPSC_RPC_LOCK lpLock)
Definition: lock.c:82
DWORD ScmStartService(PSERVICE Service, DWORD argc, LPWSTR *argv)
Definition: database.c:2131
DWORD ScmCreateNewServiceRecord(LPCWSTR lpServiceName, PSERVICE *lpServiceRecord, DWORD dwServiceType, DWORD dwStartType)
Definition: database.c:767
PSERVICE ScmGetServiceEntryByName(LPCWSTR lpServiceName)
Definition: database.c:657
DWORD ScmAcceptBoot(VOID)
Definition: controlset.c:336
VOID ScmStartRpcServer(VOID)
Definition: rpcserver.c:107
DWORD ScmInitializeSecurity(VOID)
Definition: security.c:373
PSECURITY_DESCRIPTOR pPipeSD
Definition: security.c:27
BOOL ScmLockDatabaseShared(VOID)
Definition: database.c:2427
struct _SERVICE_IMAGE * PSERVICE_IMAGE
LIST_ENTRY ServiceListHead
Definition: database.c:29
DWORD ScmReadDependencies(HKEY hServiceKey, LPWSTR *lpDependencies, DWORD *lpdwDependenciesLength)
Definition: config.c:349
DWORD SetSecurityServicesEvent(VOID)
Definition: services.c:142
PSERVICE_GROUP ScmGetServiceGroupByName(_In_ LPCWSTR lpGroupName)
Definition: groupdb.c:26
BOOL ScmLiveSetup
Definition: services.c:30
DWORD ScmMarkServiceForDelete(PSERVICE pService)
Definition: config.c:223
BOOL ScmSetupInProgress
Definition: services.c:31
DWORD ScmDeleteRegKey(_In_ HKEY hKey, _In_ PCWSTR pszSubKey)
Definition: config.c:646
VOID ScmDeleteNamedPipeCriticalSection(VOID)
Definition: database.c:2469
struct _SERVICE SERVICE
VOID ScmShutdownServiceDatabase(VOID)
Definition: database.c:1175
PSERVICE ScmGetServiceEntryByDisplayName(LPCWSTR lpDisplayName)
Definition: database.c:686
DWORD ScmCreateDefaultServiceSD(PSECURITY_DESCRIPTOR *ppSecurityDescriptor)
Definition: security.c:320
DWORD ScmSetServiceGroup(PSERVICE lpService, LPCWSTR lpGroupName)
Definition: groupdb.c:61
DWORD ScmCreateServiceKey(LPCWSTR lpServiceName, REGSAM samDesired, PHKEY phKey)
Definition: config.c:72
DWORD ScmControlDriver(PSERVICE lpService, DWORD dwControl, LPSERVICE_STATUS lpServiceStatus)
Definition: driver.c:335
struct _START_LOCK START_LOCK
VOID ScmLogEvent(DWORD dwEventId, WORD wType, WORD wStrings, LPCWSTR *lpStrings)
Definition: services.c:174
DWORD ScmDecryptPassword(_In_ PVOID ContextHandle, _In_ PBYTE pPassword, _In_ DWORD dwPasswordSize, _Out_ PWSTR *pDecryptedPassword)
Definition: config.c:708
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
FxAutoRegKey hKey
#define argv
Definition: mplay32.c:18
#define _Out_
Definition: ms_sal.h:345
#define _In_
Definition: ms_sal.h:308
@ Service
Definition: ntsecapi.h:292
BYTE * PBYTE
Definition: pedump.c:66
Definition: typedefs.h:120
DWORD dwRefCount
Definition: services.h:35
WCHAR szGroupName[1]
Definition: services.h:40
PULONG TagArray
Definition: services.h:38
BOOLEAN ServicesRunning
Definition: services.h:36
LIST_ENTRY GroupListEntry
Definition: services.h:32
ULONG TagCount
Definition: services.h:37
LPWSTR lpGroupName
Definition: services.h:33
HANDLE hControlPipe
Definition: services.h:51
LPWSTR pszImagePath
Definition: services.h:47
LIST_ENTRY ImageListEntry
Definition: services.h:46
HANDLE hProfile
Definition: services.h:55
LPWSTR pszAccountName
Definition: services.h:48
HANDLE hToken
Definition: services.h:54
DWORD dwProcessId
Definition: services.h:53
DWORD dwImageRunCount
Definition: services.h:49
HANDLE hProcess
Definition: services.h:52
BOOL bDeleted
Definition: services.h:66
DWORD dwServiceTag
Definition: services.h:76
ULONG Flags
Definition: services.h:78
DWORD dwServiceBits
Definition: services.h:75
PSERVICE_GROUP lpGroup
Definition: services.h:64
PSECURITY_DESCRIPTOR pSecurityDescriptor
Definition: services.h:80
DWORD dwErrorControl
Definition: services.h:72
LPWSTR lpDisplayName
Definition: services.h:63
LIST_ENTRY ServiceListEntry
Definition: services.h:61
DWORD dwResumeCount
Definition: services.h:67
SERVICE_STATUS Status
Definition: services.h:70
BOOLEAN ServiceVisited
Definition: services.h:82
DWORD dwStartType
Definition: services.h:71
WCHAR szServiceName[1]
Definition: services.h:84
DWORD dwTag
Definition: services.h:73
PSERVICE_IMAGE lpImage
Definition: services.h:65
DWORD dwRefCount
Definition: services.h:68
LPWSTR lpServiceName
Definition: services.h:62
DWORD TimeWhenLocked
Definition: services.h:93
DWORD Tag
Definition: services.h:92
PSID LockOwnerSid
Definition: services.h:94
Definition: dsound.c:943
uint16_t * PWSTR
Definition: typedefs.h:56
uint32_t * PULONG
Definition: typedefs.h:59
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
SERVICE_STATUS_HANDLE hServiceStatus
Definition: main.c:10
_In_ LPCSTR _Out_writes_to_opt_ cchDisplayName LPSTR lpDisplayName
Definition: winbase.h:2790
ACCESS_MASK REGSAM
Definition: winreg.h:69
const char * LPCSTR
Definition: xmlstorage.h:183
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185