11 #define WIN32_NO_STATUS
13 #define COM_NO_WINDOWS_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>
30 typedef struct _SERVICE_GROUP
32 LIST_ENTRY GroupListEntry
;
36 BOOLEAN ServicesRunning
;
41 } SERVICE_GROUP
, *PSERVICE_GROUP
;
44 typedef struct _SERVICE_IMAGE
46 LIST_ENTRY ImageListEntry
;
48 LPWSTR pszAccountName
;
49 DWORD dwImageRunCount
;
56 } SERVICE_IMAGE
, *PSERVICE_IMAGE
;
59 typedef struct _SERVICE
61 LIST_ENTRY ServiceListEntry
;
64 PSERVICE_GROUP lpGroup
;
65 PSERVICE_IMAGE lpImage
;
70 SERVICE_STATUS Status
;
79 PSECURITY_DESCRIPTOR pSecurityDescriptor
;
81 BOOLEAN ServiceVisited
;
83 WCHAR szServiceName
[1];
87 #define LOCK_TAG 0x4C697041 /* 'ApiL' */
89 typedef struct _START_LOCK
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 */
94 } START_LOCK
, *PSTART_LOCK
;
97 /* VARIABLES ***************************************************************/
99 extern LIST_ENTRY ServiceListHead
;
100 extern LIST_ENTRY GroupListHead
;
101 extern LIST_ENTRY ImageListHead
;
102 extern BOOL ScmInitialize
;
103 extern BOOL ScmShutdown
;
104 extern PSECURITY_DESCRIPTOR pPipeSD
;
107 /* FUNCTIONS ***************************************************************/
111 DWORD
ScmOpenServiceKey(LPWSTR lpServiceName
,
115 DWORD
ScmCreateServiceKey(LPCWSTR lpServiceName
,
119 DWORD
ScmWriteDependencies(HKEY hServiceKey
,
120 LPCWSTR lpDependencies
,
121 DWORD dwDependenciesLength
);
123 DWORD
ScmMarkServiceForDelete(PSERVICE pService
);
124 BOOL
ScmIsDeleteFlagSet(HKEY hServiceKey
);
126 DWORD
ScmReadString(HKEY hServiceKey
,
131 ScmReadDependencies(HKEY hServiceKey
,
132 LPWSTR
*lpDependencies
,
133 DWORD
*lpdwDependenciesLength
);
136 ScmSetServicePassword(
137 IN PCWSTR pszServiceName
,
138 IN PCWSTR pszPassword
);
141 ScmWriteSecurityDescriptor(
142 _In_ HKEY hServiceKey
,
143 _In_ PSECURITY_DESCRIPTOR pSecurityDescriptor
);
146 ScmReadSecurityDescriptor(
147 _In_ HKEY hServiceKey
,
148 _Out_ PSECURITY_DESCRIPTOR
*ppSecurityDescriptor
);
153 _In_ PCWSTR pszSubKey
);
157 _In_ PBYTE pPassword
,
158 _In_ DWORD dwPasswordSize
,
159 _Out_ PWSTR
*pDecryptedPassword
);
165 ScmCreateLastKnownGoodControlSet(VOID
);
170 DWORD
ScmCreateServiceDatabase(VOID
);
171 VOID
ScmShutdownServiceDatabase(VOID
);
172 VOID
ScmGetBootAndSystemDriverState(VOID
);
173 VOID
ScmAutoStartServices(VOID
);
174 VOID
ScmAutoShutdownServices(VOID
);
175 DWORD
ScmStartService(PSERVICE Service
,
179 VOID
ScmRemoveServiceImage(PSERVICE_IMAGE pServiceImage
);
180 PSERVICE
ScmGetServiceEntryByName(LPCWSTR lpServiceName
);
181 PSERVICE
ScmGetServiceEntryByDisplayName(LPCWSTR lpDisplayName
);
182 PSERVICE
ScmGetServiceEntryByResumeCount(DWORD dwResumeCount
);
183 DWORD
ScmCreateNewServiceRecord(LPCWSTR lpServiceName
,
184 PSERVICE
*lpServiceRecord
,
187 VOID
ScmDeleteServiceRecord(PSERVICE lpService
);
188 DWORD
ScmMarkServiceForDelete(PSERVICE pService
);
190 DWORD
ScmControlService(HANDLE hControlPipe
,
192 SERVICE_STATUS_HANDLE hServiceStatus
,
195 BOOL
ScmLockDatabaseExclusive(VOID
);
196 BOOL
ScmLockDatabaseShared(VOID
);
197 VOID
ScmUnlockDatabase(VOID
);
199 VOID
ScmInitNamedPipeCriticalSection(VOID
);
200 VOID
ScmDeleteNamedPipeCriticalSection(VOID
);
202 DWORD
ScmGetServiceNameFromTag(PTAG_INFO_NAME_FROM_TAG_IN_PARAMS InParams
,
203 PTAG_INFO_NAME_FROM_TAG_OUT_PARAMS
*OutParams
);
205 DWORD
ScmGenerateServiceTag(PSERVICE lpServiceRecord
);
209 DWORD
ScmStartDriver(PSERVICE lpService
);
210 DWORD
ScmControlDriver(PSERVICE lpService
,
212 LPSERVICE_STATUS lpServiceStatus
);
218 ScmGetServiceGroupByName(
219 _In_ LPCWSTR lpGroupName
);
221 DWORD
ScmCreateGroupList(VOID
);
222 DWORD
ScmSetServiceGroup(PSERVICE lpService
,
223 LPCWSTR lpGroupName
);
228 DWORD
ScmAcquireServiceStartLock(IN BOOL IsServiceController
,
229 OUT LPSC_RPC_LOCK lpLock
);
230 DWORD
ScmReleaseServiceStartLock(IN OUT LPSC_RPC_LOCK lpLock
);
231 VOID
ScmQueryServiceLockStatusW(OUT LPQUERY_SERVICE_LOCK_STATUSW lpLockStatus
);
232 VOID
ScmQueryServiceLockStatusA(OUT LPQUERY_SERVICE_LOCK_STATUSA lpLockStatus
);
237 VOID
ScmStartRpcServer(VOID
);
242 DWORD
ScmInitializeSecurity(VOID
);
243 VOID
ScmShutdownSecurity(VOID
);
246 ScmCreateDefaultServiceSD(
247 PSECURITY_DESCRIPTOR
*ppSecurityDescriptor
);
252 VOID
PrintString(LPCSTR fmt
, ...);
253 VOID
ScmLogEvent(DWORD dwEventId
,
257 VOID
ScmWaitForLsa(VOID
);
259 #endif /* _SERVICES_H */