home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / lmsvc.h < prev    next >
C/C++ Source or Header  |  1998-04-25  |  13KB  |  533 lines

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