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.

560 lines
14 KiB

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