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.

538 lines
13 KiB

  1. /*++ BUILD Version: 0002 // Increment this if a change has global effects
  2. Copyright (c) 1991-1999 Microsoft Corporation
  3. Module Name:
  4. lmsvc.h
  5. Abstract:
  6. This file contains structures, function prototypes, and definitions
  7. for the NetService API.
  8. [Environment:]
  9. User Mode -Win32
  10. [Notes:]
  11. You must include NETCONS.H before this file, since this file depends
  12. on values defined in NETCONS.H.
  13. --*/
  14. #ifndef _LMSVC_
  15. #define _LMSVC_
  16. #if _MSC_VER > 1000
  17. #pragma once
  18. #endif
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. //
  23. // Include the file which contains all the service name strings.
  24. //
  25. #include <lmsname.h>
  26. //
  27. // Data Structures
  28. //
  29. typedef struct _SERVICE_INFO_0 {
  30. LPWSTR svci0_name;
  31. } SERVICE_INFO_0, *PSERVICE_INFO_0, * LPSERVICE_INFO_0;
  32. typedef struct _SERVICE_INFO_1 {
  33. LPWSTR svci1_name;
  34. DWORD svci1_status;
  35. DWORD svci1_code;
  36. DWORD svci1_pid;
  37. } SERVICE_INFO_1, *PSERVICE_INFO_1, * LPSERVICE_INFO_1;
  38. typedef struct _SERVICE_INFO_2 {
  39. LPWSTR svci2_name;
  40. DWORD svci2_status;
  41. DWORD svci2_code;
  42. DWORD svci2_pid;
  43. LPWSTR svci2_text;
  44. DWORD svci2_specific_error;
  45. LPWSTR svci2_display_name;
  46. } SERVICE_INFO_2, *PSERVICE_INFO_2, * LPSERVICE_INFO_2;
  47. //
  48. // Function Prototypes
  49. //
  50. NET_API_STATUS NET_API_FUNCTION
  51. NetServiceControl (
  52. IN LPCWSTR servername OPTIONAL,
  53. IN LPCWSTR service,
  54. IN DWORD opcode,
  55. IN DWORD arg,
  56. OUT LPBYTE *bufptr
  57. );
  58. NET_API_STATUS NET_API_FUNCTION
  59. NetServiceEnum (
  60. IN LPCWSTR servername OPTIONAL,
  61. IN DWORD level,
  62. OUT LPBYTE *bufptr,
  63. IN DWORD prefmaxlen,
  64. OUT LPDWORD entriesread,
  65. OUT LPDWORD totalentries,
  66. IN OUT LPDWORD resume_handle OPTIONAL
  67. );
  68. NET_API_STATUS NET_API_FUNCTION
  69. NetServiceGetInfo (
  70. IN LPCWSTR servername OPTIONAL,
  71. IN LPCWSTR service,
  72. IN DWORD level,
  73. OUT LPBYTE *bufptr
  74. );
  75. NET_API_STATUS NET_API_FUNCTION
  76. NetServiceInstall (
  77. IN LPCWSTR servername OPTIONAL,
  78. IN LPCWSTR service,
  79. IN DWORD argc,
  80. IN LPCWSTR argv[],
  81. OUT LPBYTE *bufptr
  82. );
  83. //
  84. // Special Values and Constants
  85. //
  86. //
  87. // Bitmask and bit values for svci1_status, and svci2_status
  88. // fields. For each "subfield", there is a mask defined,
  89. // and a number of constants representing the value
  90. // obtained by doing (status & mask).
  91. //
  92. // Bits 0,1 -- general status
  93. #define SERVICE_INSTALL_STATE 0x03
  94. #define SERVICE_UNINSTALLED 0x00
  95. #define SERVICE_INSTALL_PENDING 0x01
  96. #define SERVICE_UNINSTALL_PENDING 0x02
  97. #define SERVICE_INSTALLED 0x03
  98. // Bits 2,3 -- paused/active status
  99. #define SERVICE_PAUSE_STATE 0x0C
  100. #define LM20_SERVICE_ACTIVE 0x00
  101. #define LM20_SERVICE_CONTINUE_PENDING 0x04
  102. #define LM20_SERVICE_PAUSE_PENDING 0x08
  103. #define LM20_SERVICE_PAUSED 0x0C
  104. // Bit 4 -- uninstallable indication
  105. #define SERVICE_NOT_UNINSTALLABLE 0x00
  106. #define SERVICE_UNINSTALLABLE 0x10
  107. // Bit 5 -- pausable indication
  108. #define SERVICE_NOT_PAUSABLE 0x00
  109. #define SERVICE_PAUSABLE 0x20
  110. // Workstation service only:
  111. // Bits 8,9,10 -- redirection paused/active
  112. #define SERVICE_REDIR_PAUSED 0x700
  113. #define SERVICE_REDIR_DISK_PAUSED 0x100
  114. #define SERVICE_REDIR_PRINT_PAUSED 0x200
  115. #define SERVICE_REDIR_COMM_PAUSED 0x400
  116. //
  117. // Additional standard LAN Manager for MS-DOS services
  118. //
  119. #define SERVICE_DOS_ENCRYPTION L"ENCRYPT"
  120. //
  121. // NetServiceControl opcodes.
  122. //
  123. #define SERVICE_CTRL_INTERROGATE 0
  124. #define SERVICE_CTRL_PAUSE 1
  125. #define SERVICE_CTRL_CONTINUE 2
  126. #define SERVICE_CTRL_UNINSTALL 3
  127. //
  128. // Workstation service only: Bits used in the "arg" parameter
  129. // to NetServiceControl in conjunction with the opcode
  130. // SERVICE_CTRL_PAUSE or SERVICE_CTRL_CONTINUE, to pause or
  131. // continue redirection.
  132. //
  133. #define SERVICE_CTRL_REDIR_DISK 0x1
  134. #define SERVICE_CTRL_REDIR_PRINT 0x2
  135. #define SERVICE_CTRL_REDIR_COMM 0x4
  136. //
  137. // Values for svci1_code, and svci2_code when status
  138. // of the service is SERVICE_INSTALL_PENDING or
  139. // SERVICE_UNINSTALL_PENDING.
  140. // A service can optionally provide a hint to the installer
  141. // that the install is proceeding and how long to wait
  142. // (in 0.1 second increments) before querying status again.
  143. //
  144. #define SERVICE_IP_NO_HINT 0x0
  145. #define SERVICE_CCP_NO_HINT 0x0
  146. #define SERVICE_IP_QUERY_HINT 0x10000
  147. #define SERVICE_CCP_QUERY_HINT 0x10000
  148. //
  149. // Mask for install proceeding checkpoint number
  150. //
  151. #define SERVICE_IP_CHKPT_NUM 0x0FF
  152. #define SERVICE_CCP_CHKPT_NUM 0x0FF
  153. //
  154. // Mask for wait time hint before querying again
  155. //
  156. #define SERVICE_IP_WAIT_TIME 0x0FF00
  157. #define SERVICE_CCP_WAIT_TIME 0x0FF00
  158. //
  159. // Shift count for building wait time _code values
  160. //
  161. #define SERVICE_IP_WAITTIME_SHIFT 8
  162. #define SERVICE_NTIP_WAITTIME_SHIFT 12
  163. //
  164. // Mask used for upper and lower portions of wait hint time.
  165. //
  166. #define UPPER_HINT_MASK 0x0000FF00
  167. #define LOWER_HINT_MASK 0x000000FF
  168. #define UPPER_GET_HINT_MASK 0x0FF00000
  169. #define LOWER_GET_HINT_MASK 0x0000FF00
  170. #define SERVICE_NT_MAXTIME 0x0000FFFF
  171. #define SERVICE_RESRV_MASK 0x0001FFFF
  172. #define SERVICE_MAXTIME 0x000000FF
  173. //
  174. // SERVICE_BASE is the base of service error codes,
  175. // chosen to avoid conflict with OS, redirector,
  176. // netapi, and errlog codes.
  177. //
  178. // Don't change the comments following the manifest constants without
  179. // understanding how mapmsg works.
  180. //
  181. #define SERVICE_BASE 3050
  182. #define SERVICE_UIC_NORMAL 0
  183. /*
  184. * Uninstall codes, to be used in high byte of 'code' on final NetStatus,
  185. * which sets the status to UNINSTALLED.
  186. */
  187. #define SERVICE_UIC_BADPARMVAL (SERVICE_BASE + 1)
  188. /*
  189. * The Registry or the information you just typed includes an illegal
  190. * value for "%1".
  191. */
  192. #define SERVICE_UIC_MISSPARM (SERVICE_BASE + 2)
  193. /*
  194. * The required parameter was not provided on the command
  195. * line or in the configuration file.
  196. */
  197. #define SERVICE_UIC_UNKPARM (SERVICE_BASE + 3)
  198. /*
  199. * LAN Manager does not recognize "%1" as a valid option.
  200. */
  201. #define SERVICE_UIC_RESOURCE (SERVICE_BASE + 4)
  202. /*
  203. * A request for resource could not be satisfied.
  204. */
  205. #define SERVICE_UIC_CONFIG (SERVICE_BASE + 5)
  206. /*
  207. * A problem exists with the system configuration.
  208. */
  209. #define SERVICE_UIC_SYSTEM (SERVICE_BASE + 6)
  210. /*
  211. * A system error has occurred.
  212. */
  213. #define SERVICE_UIC_INTERNAL (SERVICE_BASE + 7)
  214. /*
  215. * An internal consistency error has occurred.
  216. */
  217. #define SERVICE_UIC_AMBIGPARM (SERVICE_BASE + 8)
  218. /*
  219. * The configuration file or the command line has an ambiguous option.
  220. */
  221. #define SERVICE_UIC_DUPPARM (SERVICE_BASE + 9)
  222. /*
  223. * The configuration file or the command line has a duplicate parameter.
  224. */
  225. #define SERVICE_UIC_KILL (SERVICE_BASE + 10)
  226. /*
  227. * The service did not respond to control and was stopped with
  228. * the DosKillProc function.
  229. */
  230. #define SERVICE_UIC_EXEC (SERVICE_BASE + 11)
  231. /*
  232. * An error occurred when attempting to run the service program.
  233. */
  234. #define SERVICE_UIC_SUBSERV (SERVICE_BASE + 12)
  235. /*
  236. * The sub-service failed to start.
  237. */
  238. #define SERVICE_UIC_CONFLPARM (SERVICE_BASE + 13)
  239. /*
  240. * There is a conflict in the value or use of these options: %1.
  241. */
  242. #define SERVICE_UIC_FILE (SERVICE_BASE + 14)
  243. /*
  244. * There is a problem with the file.
  245. */
  246. //
  247. // The modifiers
  248. //
  249. //
  250. // General:
  251. //
  252. #define SERVICE_UIC_M_NULL 0
  253. //
  254. // RESOURCE:
  255. //
  256. #define SERVICE_UIC_M_MEMORY (SERVICE_BASE + 20) /* memory */
  257. #define SERVICE_UIC_M_DISK (SERVICE_BASE + 21) /* disk space */
  258. #define SERVICE_UIC_M_THREADS (SERVICE_BASE + 22) /* thread */
  259. #define SERVICE_UIC_M_PROCESSES (SERVICE_BASE + 23) /* process */
  260. //
  261. // CONFIG:
  262. //
  263. //
  264. // Security failure
  265. //
  266. #define SERVICE_UIC_M_SECURITY (SERVICE_BASE + 24)
  267. /* Security Failure. %0 */
  268. #define SERVICE_UIC_M_LANROOT (SERVICE_BASE + 25)
  269. /*
  270. * Bad or missing LAN Manager root directory.
  271. */
  272. #define SERVICE_UIC_M_REDIR (SERVICE_BASE + 26)
  273. /*
  274. * The network software is not installed.
  275. */
  276. #define SERVICE_UIC_M_SERVER (SERVICE_BASE + 27)
  277. /*
  278. * The server is not started.
  279. */
  280. #define SERVICE_UIC_M_SEC_FILE_ERR (SERVICE_BASE + 28)
  281. /*
  282. * The server cannot access the user accounts database (NET.ACC).
  283. */
  284. #define SERVICE_UIC_M_FILES (SERVICE_BASE + 29)
  285. /*
  286. * Incompatible files are installed in the LANMAN tree.
  287. */
  288. #define SERVICE_UIC_M_LOGS (SERVICE_BASE + 30)
  289. /*
  290. * The LANMAN\LOGS directory is invalid.
  291. */
  292. #define SERVICE_UIC_M_LANGROUP (SERVICE_BASE + 31)
  293. /*
  294. * The domain specified could not be used.
  295. */
  296. #define SERVICE_UIC_M_MSGNAME (SERVICE_BASE + 32)
  297. /*
  298. * The computer name is being used as a message alias on another computer.
  299. */
  300. #define SERVICE_UIC_M_ANNOUNCE (SERVICE_BASE + 33)
  301. /*
  302. * The announcement of the server name failed.
  303. */
  304. #define SERVICE_UIC_M_UAS (SERVICE_BASE + 34)
  305. /*
  306. * The user accounts database is not configured correctly.
  307. */
  308. #define SERVICE_UIC_M_SERVER_SEC_ERR (SERVICE_BASE + 35)
  309. /*
  310. * The server is not running with user-level security.
  311. */
  312. #define SERVICE_UIC_M_WKSTA (SERVICE_BASE + 37)
  313. /*
  314. * The workstation is not configured properly.
  315. */
  316. #define SERVICE_UIC_M_ERRLOG (SERVICE_BASE + 38)
  317. /*
  318. * View your error log for details.
  319. */
  320. #define SERVICE_UIC_M_FILE_UW (SERVICE_BASE + 39)
  321. /*
  322. * Unable to write to this file.
  323. */
  324. #define SERVICE_UIC_M_ADDPAK (SERVICE_BASE + 40)
  325. /*
  326. * ADDPAK file is corrupted. Delete LANMAN\NETPROG\ADDPAK.SER
  327. * and reapply all ADDPAKs.
  328. */
  329. #define SERVICE_UIC_M_LAZY (SERVICE_BASE + 41)
  330. /*
  331. * The LM386 server cannot be started because CACHE.EXE is not running.
  332. */
  333. #define SERVICE_UIC_M_UAS_MACHINE_ACCT (SERVICE_BASE + 42)
  334. /*
  335. * There is no account for this computer in the security database.
  336. */
  337. #define SERVICE_UIC_M_UAS_SERVERS_NMEMB (SERVICE_BASE + 43)
  338. /*
  339. * This computer is not a member of the group SERVERS.
  340. */
  341. #define SERVICE_UIC_M_UAS_SERVERS_NOGRP (SERVICE_BASE + 44)
  342. /*
  343. * The group SERVERS is not present in the local security database.
  344. */
  345. #define SERVICE_UIC_M_UAS_INVALID_ROLE (SERVICE_BASE + 45)
  346. /*
  347. * This computer is configured as a member of a workgroup, not as
  348. * a member of a domain. The Netlogon service does not need to run in this
  349. * configuration.
  350. */
  351. #define SERVICE_UIC_M_NETLOGON_NO_DC (SERVICE_BASE + 46)
  352. /*
  353. * The primary Domain Controller for this domain could not be located.
  354. */
  355. #define SERVICE_UIC_M_NETLOGON_DC_CFLCT (SERVICE_BASE + 47)
  356. /*
  357. * This computer is configured to be the primary domain controller of its domain.
  358. * However, the computer %1 is currently claiming to be the primary domain controller
  359. * of the domain.
  360. */
  361. #define SERVICE_UIC_M_NETLOGON_AUTH (SERVICE_BASE + 48)
  362. /*
  363. * The service failed to authenticate with the primary domain controller.
  364. */
  365. #define SERVICE_UIC_M_UAS_PROLOG (SERVICE_BASE + 49)
  366. /*
  367. * There is a problem with the security database creation date or serial number.
  368. */
  369. #define SERVICE2_BASE 5600
  370. /* new SEVICE_UIC messages go here */
  371. #define SERVICE_UIC_M_NETLOGON_MPATH (SERVICE2_BASE + 0)
  372. /*
  373. * Could not share the User or Script path.
  374. */
  375. #define SERVICE_UIC_M_LSA_MACHINE_ACCT (SERVICE2_BASE + 1)
  376. /*
  377. * The password for this computer is not found in the local security
  378. * database.
  379. */
  380. #define SERVICE_UIC_M_DATABASE_ERROR (SERVICE2_BASE + 2)
  381. /*
  382. * An internal error occurred while accessing the computer's
  383. * local or network security database.
  384. */
  385. //
  386. // End modifiers
  387. //
  388. //
  389. // Commonly used Macros:
  390. //
  391. #define SERVICE_IP_CODE(tt,nn) \
  392. ((long)SERVICE_IP_QUERY_HINT|(long)(nn|(tt<<SERVICE_IP_WAITTIME_SHIFT)))
  393. #define SERVICE_CCP_CODE(tt,nn) \
  394. ((long)SERVICE_CCP_QUERY_HINT|(long)(nn|(tt<<SERVICE_IP_WAITTIME_SHIFT)))
  395. #define SERVICE_UIC_CODE(cc,mm) \
  396. ((long)(((long)cc<<16)|(long)(unsigned short)mm))
  397. //
  398. // This macro takes a wait hint (tt) which can have a maximum value of
  399. // 0xFFFF and puts it into the service status code field.
  400. // 0x0FF1FFnn (where nn is the checkpoint information).
  401. //
  402. #define SERVICE_NT_CCP_CODE(tt,nn) \
  403. ( \
  404. ((long)SERVICE_CCP_QUERY_HINT) | \
  405. ((long)(nn)) | \
  406. (((tt)&LOWER_HINT_MASK) << SERVICE_IP_WAITTIME_SHIFT) | \
  407. (((tt)&UPPER_HINT_MASK) << SERVICE_NTIP_WAITTIME_SHIFT) \
  408. )
  409. //
  410. // This macro takes a status code field, and strips out the wait hint
  411. // from the upper and lower sections.
  412. // 0x0FF1FFnn results in 0x0000FFFF.
  413. //
  414. #define SERVICE_NT_WAIT_GET(code) \
  415. ( \
  416. (((code) & UPPER_GET_HINT_MASK) >> SERVICE_NTIP_WAITTIME_SHIFT) | \
  417. (((code) & LOWER_GET_HINT_MASK) >> SERVICE_IP_WAITTIME_SHIFT) \
  418. )
  419. #ifdef __cplusplus
  420. }
  421. #endif
  422. #endif // _LMSVC_