Leaked source code of windows server 2003
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.

122 lines
3.9 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. SvcCtrl.c
  5. Abstract:
  6. This file contains the RpcXlate code to handle the NetServiceControl API.
  7. Author:
  8. John Rogers (JohnRo) 13-Sep-1991
  9. Environment:
  10. Portable to any flat, 32-bit environment. (Uses Win32 typedefs.)
  11. Requires ANSI C extensions: slash-slash comments, long external names.
  12. Revision History:
  13. 13-Sep-1991 JohnRo
  14. Created.
  15. 25-Sep-1991 JohnRo
  16. Fixed bug which caused ERROR_INVALID_PARAMETER (rcv.buf.len trunc'ed).
  17. 07-Oct-1991 JohnRo
  18. Made changes suggested by PC-LINT.
  19. --*/
  20. // These must be included first:
  21. #include <windef.h> // IN, DWORD, etc.
  22. #include <lmcons.h> // DEVLEN, NET_API_STATUS, etc.
  23. // These may be included in any order:
  24. #include <apinums.h> // API_ equates.
  25. #include <lmerr.h> // ERROR_ and NERR_ equates.
  26. #include <lmsvc.h>
  27. #include <rxp.h> // RxpFatalErrorCode().
  28. #include <netdebug.h> // NetpKdPrint(()), FORMAT_ equates.
  29. #include <rap.h> // LPDESC.
  30. #include <remdef.h> // REM16_, REM32_, REMSmb_ equates.
  31. #include <rx.h> // RxRemoteApi().
  32. #include <rxsvc.h> // My prototype(s).
  33. #include <strucinf.h> // NetpServiceStructureInfo().
  34. NET_API_STATUS
  35. RxNetServiceControl (
  36. IN LPTSTR UncServerName,
  37. IN LPTSTR Service,
  38. IN DWORD OpCode,
  39. IN DWORD Arg,
  40. OUT LPBYTE *BufPtr
  41. )
  42. {
  43. const DWORD BufSize = 65535;
  44. LPDESC DataDesc16, DataDesc32, DataDescSmb;
  45. const DWORD Level = 2; // Implied by this API.
  46. LPSERVICE_INFO_2 serviceInfo2;
  47. NET_API_STATUS Status;
  48. NetpAssert(UncServerName != NULL);
  49. NetpAssert(*UncServerName != '\0');
  50. Status = NetpServiceStructureInfo (
  51. Level,
  52. PARMNUM_ALL, // want entire structure
  53. TRUE, // Want native sizes (actually don't care...)
  54. & DataDesc16,
  55. & DataDesc32,
  56. & DataDescSmb,
  57. NULL, // don't care about max size
  58. NULL, // don't care about fixed size
  59. NULL); // don't care about string size
  60. NetpAssert(Status == NERR_Success);
  61. Status = RxRemoteApi(
  62. API_WServiceControl, // API number
  63. UncServerName,
  64. REMSmb_NetServiceControl_P, // parm desc
  65. DataDesc16,
  66. DataDesc32,
  67. DataDescSmb,
  68. NULL, // no aux desc 16
  69. NULL, // no aux desc 32
  70. NULL, // no aux desc SMB
  71. ALLOCATE_RESPONSE, // flags: alloc response buffer for us
  72. // rest of API's arguments, in 32-bit LM2.x format:
  73. Service,
  74. OpCode,
  75. Arg,
  76. BufPtr,
  77. BufSize); // buffer size (ignored, mostly)
  78. if ((! RxpFatalErrorCode(Status)) && (Level == 2)) {
  79. serviceInfo2 = (LPSERVICE_INFO_2)*BufPtr;
  80. if (serviceInfo2 != NULL) {
  81. DWORD installState;
  82. serviceInfo2->svci2_display_name = serviceInfo2->svci2_name;
  83. //
  84. // if INSTALL or UNINSTALL is PENDING, then force the upper
  85. // bits to 0. This is to prevent the upper bits of the wait
  86. // hint from getting accidentally set. Downlevel should never
  87. // use more than FF for waithint.
  88. //
  89. installState = serviceInfo2->svci2_status & SERVICE_INSTALL_STATE;
  90. if ((installState == SERVICE_INSTALL_PENDING) ||
  91. (installState == SERVICE_UNINSTALL_PENDING)) {
  92. serviceInfo2->svci2_code &= SERVICE_RESRV_MASK;
  93. }
  94. }
  95. }
  96. return(Status);
  97. } // RxNetServiceControl