Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

497 lines
9.8 KiB

  1. /*++
  2. Copyright (c) 1991, 1992 Microsoft Corporation
  3. Module Name:
  4. scconfig.h
  5. Abstract:
  6. Service configuration related function prototypes.
  7. Author:
  8. Dan Lafferty (danl) 03-Apr-1991
  9. Revision History:
  10. 22-Apr-1992 JohnRo
  11. Added ScAllocateAndReadConfigValue(), ScOpenServiceConfigKey(),
  12. and ScWriteServiceType(). Added CreateIfMissing flag to
  13. ScOpenServiceConfigKey(). Added ScWriteImageFileName(),
  14. ScWriteDependencies(), ScWriteGroupForThisService().
  15. 24-Apr-1992 RitaW
  16. ScAllocateAndReadConfigValue() returns DWORD.
  17. --*/
  18. #ifndef SCCONFIG_INCLUDED
  19. #define SCCONFIG_INCLUDED
  20. #include <winreg.h> // HKEY, PHKEY.
  21. #include <scwow.h> // 32/64-bit interop structures
  22. //
  23. // Macros
  24. //
  25. #define ScRegCloseKey(handle) RtlNtStatusToDosError(NtClose((HANDLE)handle))
  26. #define ScRegFlushKey(handle) RtlNtStatusToDosError(NtFlushKey((HANDLE)handle))
  27. //
  28. // Value names in registry
  29. //
  30. #define START_VALUENAME_W L"Start"
  31. #define GROUP_VALUENAME_W L"Group"
  32. #define TAG_VALUENAME_W L"Tag"
  33. #define DEPENDONSERVICE_VALUENAME_W L"DependOnService"
  34. #define DEPENDONGROUP_VALUENAME_W L"DependOnGroup"
  35. #define ERRORCONTROL_VALUENAME_W L"ErrorControl"
  36. #define IMAGE_VALUENAME_W L"ImagePath"
  37. #define SERVICETYPE_VALUENAME_W L"Type"
  38. #define STARTNAME_VALUENAME_W L"ObjectName"
  39. #define DISPLAYNAME_VALUENAME_W L"DisplayName"
  40. #define DESCRIPTION_VALUENAME_W L"Description"
  41. #define REBOOTMESSAGE_VALUENAME_W L"RebootMessage"
  42. #define FAILURECOMMAND_VALUENAME_W L"FailureCommand"
  43. #define FAILUREACTIONS_VALUENAME_W L"FailureActions"
  44. #define SD_VALUENAME_W L"Security"
  45. #define LOAD_ORDER_GROUP_LIST_KEY L"System\\CurrentControlSet\\Control\\ServiceGroupOrder"
  46. #define GROUP_VECTORS_KEY L"System\\CurrentControlSet\\Control\\GroupOrderList"
  47. #define GROUPLIST_VALUENAME_W L"List"
  48. #define CONTROL_WINDOWS_KEY_W L"System\\CurrentControlSet\\Control\\Windows"
  49. #define NOINTERACTIVE_VALUENAME_W L"NoInteractiveServices"
  50. #define NOBOOTPOPUPS_VALUENAME_W L"NoPopupsOnBoot"
  51. #define ENVIRONMENT_VALUENAME_W L"Environment"
  52. #define PROVIDER_KEY_BASE L"System\\CurrentControlSet\\Control\\NetworkProvider"
  53. #define PROVIDER_KEY_ORDER L"Order"
  54. #define PROVIDER_KEY_HW L"HwOrder"
  55. #define PROVIDER_VALUE L"ProviderOrder"
  56. //
  57. // Function Prototypes
  58. //
  59. DWORD
  60. ScGetEnvironment (
  61. IN LPWSTR ServiceName,
  62. OUT LPVOID *Environment
  63. );
  64. DWORD
  65. ScGetImageFileName (
  66. LPWSTR ServiceName,
  67. LPWSTR *ImageNamePtr
  68. );
  69. BOOL
  70. ScGenerateServiceDB(
  71. VOID
  72. );
  73. #ifndef _CAIRO_
  74. BOOL
  75. ScInitSecurityProcess(
  76. LPSERVICE_RECORD ServiceRecord
  77. );
  78. #endif // _CAIRO_
  79. DWORD
  80. ScAllocateAndReadConfigValue(
  81. IN HKEY Key,
  82. IN LPCWSTR ValueName,
  83. OUT LPWSTR *Value,
  84. OUT LPDWORD BytesReturned OPTIONAL
  85. );
  86. DWORD
  87. ScReadOptionalString(
  88. IN HKEY ServiceNameKey,
  89. IN LPCWSTR ValueName,
  90. OUT LPWSTR *Value,
  91. IN OUT LPDWORD TotalBytes = NULL
  92. );
  93. BOOL
  94. ScCreateLoadOrderGroupList(
  95. VOID
  96. );
  97. DWORD
  98. ScGetGroupVector(
  99. IN LPWSTR Group,
  100. OUT LPBYTE *Buffer,
  101. OUT LPDWORD BufferSize
  102. );
  103. BOOL
  104. ScGetToken(
  105. IN OUT LPWSTR *CurrentPtr,
  106. OUT LPWSTR *TokenPtr
  107. );
  108. DWORD
  109. ScOpenServiceConfigKey(
  110. IN LPWSTR ServiceName,
  111. IN DWORD DesiredAccess,
  112. IN BOOL CreateIfMissing,
  113. OUT PHKEY ServiceKey
  114. );
  115. DWORD
  116. ScReadServiceType(
  117. IN HKEY ServiceNameKey,
  118. OUT LPDWORD ServiceTypePtr
  119. );
  120. DWORD
  121. ScReadStartType(
  122. IN HKEY ServiceNameKey,
  123. OUT LPDWORD StartTypePtr
  124. );
  125. DWORD
  126. ScReadTag(
  127. IN HKEY ServiceNameKey,
  128. OUT LPDWORD TagPtr
  129. );
  130. DWORD
  131. ScReadFailureActions(
  132. IN HKEY ServiceNameKey,
  133. OUT LPSERVICE_FAILURE_ACTIONS_WOW64 * FailActPtr,
  134. IN OUT LPDWORD TotalBytes = NULL
  135. );
  136. DWORD
  137. ScReadErrorControl(
  138. IN HKEY ServiceNameKey,
  139. OUT LPDWORD ErrorControlPtr
  140. );
  141. DWORD
  142. ScReadStartName(
  143. IN HKEY ServiceNameKey,
  144. OUT LPWSTR *AccountName
  145. );
  146. DWORD
  147. ScWriteOptionalString(
  148. IN HKEY ServiceNameKey,
  149. IN LPCWSTR ValueName,
  150. IN LPCWSTR Value
  151. );
  152. DWORD
  153. ScWriteDependencies(
  154. IN HKEY ServiceNameKey,
  155. IN LPWSTR Dependencies,
  156. IN DWORD DependSize
  157. );
  158. DWORD
  159. ScWriteDisplayName(
  160. IN HKEY ServiceNameKey,
  161. IN LPWSTR DisplayName
  162. );
  163. DWORD
  164. ScWriteErrorControl(
  165. IN HKEY hServiceKey,
  166. IN DWORD dwErrorControl
  167. );
  168. DWORD
  169. ScWriteSd(
  170. IN HKEY ServiceNameKey,
  171. IN PSECURITY_DESCRIPTOR Security
  172. );
  173. DWORD
  174. ScWriteGroupForThisService(
  175. IN HKEY ServiceNameKey,
  176. IN LPWSTR Group
  177. );
  178. DWORD
  179. ScWriteImageFileName(
  180. IN HKEY hServiceKey,
  181. IN LPWSTR ImageFileName
  182. );
  183. DWORD
  184. ScWriteServiceType(
  185. IN HKEY hServiceKey,
  186. IN DWORD dwServiceType
  187. );
  188. DWORD
  189. ScWriteStartType(
  190. IN HKEY hServiceKey,
  191. IN DWORD lpStartType
  192. );
  193. DWORD
  194. ScWriteTag(
  195. IN HKEY hServiceKey,
  196. IN DWORD dwTag
  197. );
  198. DWORD
  199. ScWriteFailureActions(
  200. IN HKEY ServiceNameKey,
  201. IN LPSERVICE_FAILURE_ACTIONSW psfa
  202. );
  203. DWORD
  204. ScWriteCurrentServiceValue(
  205. OUT LPDWORD lpdwID
  206. );
  207. VOID
  208. ScDeleteTag(
  209. IN HKEY hServiceKey
  210. );
  211. DWORD
  212. ScWriteStartName(
  213. IN HKEY ServiceNameKey,
  214. IN LPWSTR StartName
  215. );
  216. DWORD
  217. ScOpenServicesKey(
  218. OUT PHKEY ServicesKey
  219. );
  220. DWORD
  221. ScRegCreateKeyExW(
  222. IN HKEY hKey,
  223. IN LPWSTR lpSubKey,
  224. IN DWORD dwReserved,
  225. IN LPWSTR lpClass,
  226. IN DWORD dwOptions,
  227. IN REGSAM samDesired,
  228. IN LPSECURITY_ATTRIBUTES lpSecurityAttributes,
  229. OUT PHKEY phkResult,
  230. OUT LPDWORD lpdwDisposition
  231. );
  232. DWORD
  233. ScRegOpenKeyExW(
  234. IN HKEY hKey,
  235. IN LPWSTR lpSubKey,
  236. IN DWORD dwOptions,
  237. IN REGSAM samDesired,
  238. OUT PHKEY phkResult
  239. );
  240. DWORD
  241. ScRegQueryValueExW(
  242. IN HKEY hKey,
  243. IN LPCWSTR lpValueName,
  244. OUT LPDWORD lpReserved,
  245. OUT LPDWORD lpType,
  246. OUT LPBYTE lpData,
  247. IN OUT LPDWORD lpcbData
  248. );
  249. DWORD
  250. ScRegSetValueExW(
  251. IN HKEY hKey,
  252. IN LPCWSTR lpValueName,
  253. IN DWORD lpReserved,
  254. IN DWORD dwType,
  255. IN LPVOID lpData,
  256. IN DWORD cbData
  257. );
  258. DWORD
  259. ScRegDeleteValue(
  260. IN HKEY hKey,
  261. IN LPCWSTR lpValueName
  262. );
  263. DWORD
  264. ScRegEnumKeyW(
  265. HKEY hKey,
  266. DWORD dwIndex,
  267. LPWSTR lpName,
  268. DWORD cbName
  269. );
  270. DWORD
  271. ScRegDeleteKeyW (
  272. HKEY hKey,
  273. LPWSTR lpSubKey
  274. );
  275. DWORD
  276. ScRegQueryInfoKeyW (
  277. HKEY hKey,
  278. LPWSTR lpClass,
  279. LPDWORD lpcbClass,
  280. LPDWORD lpReserved,
  281. LPDWORD lpcSubKeys,
  282. LPDWORD lpcbMaxSubKeyLen,
  283. LPDWORD lpcbMaxClassLen,
  284. LPDWORD lpcValues,
  285. LPDWORD lpcbMaxValueNameLen,
  286. LPDWORD lpcbMaxValueLen,
  287. LPDWORD lpcbSecurityDescriptor,
  288. PFILETIME lpftLastWriteTime
  289. );
  290. DWORD
  291. ScRegGetKeySecurity (
  292. HKEY hKey,
  293. SECURITY_INFORMATION SecurityInformation,
  294. PSECURITY_DESCRIPTOR pSecurityDescriptor,
  295. LPDWORD lpcbSecurityDescriptor
  296. );
  297. DWORD
  298. ScRegSetKeySecurity (
  299. HKEY hKey,
  300. SECURITY_INFORMATION SecurityInformation,
  301. PSECURITY_DESCRIPTOR pSecurityDescriptor
  302. );
  303. DWORD
  304. ScRegEnumValueW (
  305. HKEY hKey,
  306. DWORD dwIndex,
  307. LPWSTR lpValueName,
  308. LPDWORD lpcbValueName,
  309. LPDWORD lpReserved,
  310. LPDWORD lpType,
  311. LPBYTE lpData,
  312. LPDWORD lpcbData
  313. );
  314. VOID
  315. ScHandleProviderChange(
  316. PVOID pContext,
  317. BOOLEAN fWaitStatus
  318. );
  319. VOID
  320. ScMarkForDelete(
  321. LPSERVICE_RECORD ServiceRecord
  322. );
  323. DWORD
  324. ScReadDependencies(
  325. HKEY ServiceNameKey,
  326. LPWSTR *Dependencies,
  327. LPWSTR ServiceName
  328. );
  329. DWORD
  330. ScReadConfigFromReg(
  331. LPSERVICE_RECORD ServiceRecord,
  332. LPDWORD lpdwServiceType,
  333. LPDWORD lpdwStartType,
  334. LPDWORD lpdwErrorControl,
  335. LPDWORD lpdwTagId,
  336. LPWSTR *Dependencies,
  337. LPWSTR *LoadOrderGroup,
  338. LPWSTR *DisplayName
  339. );
  340. inline DWORD
  341. ScReadDisplayName(
  342. IN HKEY ServiceNameKey,
  343. OUT LPWSTR *DisplayName
  344. )
  345. {
  346. return (ScReadOptionalString(
  347. ServiceNameKey,
  348. DISPLAYNAME_VALUENAME_W,
  349. DisplayName
  350. ));
  351. }
  352. inline DWORD
  353. ScWriteDisplayName(
  354. IN HKEY ServiceNameKey,
  355. IN LPWSTR DisplayName
  356. )
  357. {
  358. return (ScWriteOptionalString(
  359. ServiceNameKey,
  360. DISPLAYNAME_VALUENAME_W,
  361. DisplayName
  362. ));
  363. }
  364. DWORD
  365. ScReadNoInteractiveFlag(
  366. IN HKEY ServiceNameKey,
  367. OUT LPDWORD NoInteractivePtr
  368. );
  369. inline DWORD
  370. ScReadDescription(
  371. IN HKEY ServiceNameKey,
  372. OUT LPWSTR *Description,
  373. IN OUT LPDWORD TotalBytes = NULL
  374. )
  375. {
  376. return (ScReadOptionalString(
  377. ServiceNameKey,
  378. DESCRIPTION_VALUENAME_W,
  379. Description,
  380. TotalBytes
  381. ));
  382. }
  383. inline DWORD
  384. ScWriteDescription(
  385. IN HKEY ServiceNameKey,
  386. IN LPWSTR Description
  387. )
  388. {
  389. return (ScWriteOptionalString(
  390. ServiceNameKey,
  391. DESCRIPTION_VALUENAME_W,
  392. Description
  393. ));
  394. }
  395. inline DWORD
  396. ScReadRebootMessage(
  397. IN HKEY ServiceNameKey,
  398. OUT LPWSTR *RebootMessage,
  399. IN OUT LPDWORD TotalBytes = NULL
  400. )
  401. {
  402. return (ScReadOptionalString(
  403. ServiceNameKey,
  404. REBOOTMESSAGE_VALUENAME_W,
  405. RebootMessage,
  406. TotalBytes
  407. ));
  408. }
  409. inline DWORD
  410. ScReadFailureCommand(
  411. IN HKEY ServiceNameKey,
  412. OUT LPWSTR *FailureCommand,
  413. IN OUT LPDWORD TotalBytes = NULL
  414. )
  415. {
  416. return (ScReadOptionalString(
  417. ServiceNameKey,
  418. FAILURECOMMAND_VALUENAME_W,
  419. FailureCommand,
  420. TotalBytes
  421. ));
  422. }
  423. #endif // #ifndef SCCONFIG_INCLUDED