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.

106 lines
2.8 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 2000.
  5. //
  6. // File: W S D P S V C . C P P
  7. //
  8. // Contents: Start/stop Winsock Direct Path Service.
  9. //
  10. // Notes: The service is actually implemented in MS TCP Winsock provider
  11. //
  12. // Author: VadimE 24 Jan 2000
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "pch.h"
  16. #pragma hdrstop
  17. #include "wsdpsvc.h"
  18. #define MSTCP_PROVIDER_DLL TEXT("mswsock.dll")
  19. #define START_WSDP_FUNCTION_NAME "StartWsdpService"
  20. #define STOP_WSDP_FUNCTION_NAME "StopWsdpService"
  21. // MS TCP Winsock provider module handle
  22. HINSTANCE ghMsTcpDll;
  23. // Service start function pointer
  24. typedef INT (WINAPI *PFN_START_WSDP_SVC) (VOID);
  25. PFN_START_WSDP_SVC gpfnStartWsdpSvc;
  26. // Service stop function pointer
  27. typedef VOID (WINAPI *PFN_STOP_WSDP_SVC) (VOID);
  28. PFN_STOP_WSDP_SVC gpfnStopWsdpSvc;
  29. //+---------------------------------------------------------------------------
  30. // StartWsdpService - start WSDP service if running on DTC
  31. //
  32. //
  33. VOID
  34. StartWsdpService (
  35. VOID
  36. ) throw()
  37. {
  38. NTSTATUS status;
  39. NT_PRODUCT_TYPE product;
  40. //
  41. // First check if we are running Server build
  42. //
  43. status = RtlGetNtProductType (&product);
  44. if (!NT_SUCCESS (status) ||
  45. (product == NtProductWinNt)) {
  46. return;
  47. }
  48. //
  49. // Load MS TCP provider and get WSDP service entry points
  50. //
  51. ghMsTcpDll = LoadLibrary (MSTCP_PROVIDER_DLL);
  52. if (ghMsTcpDll!=NULL) {
  53. gpfnStartWsdpSvc = (PFN_START_WSDP_SVC) GetProcAddress (
  54. ghMsTcpDll,
  55. START_WSDP_FUNCTION_NAME);
  56. gpfnStopWsdpSvc = (PFN_STOP_WSDP_SVC) GetProcAddress (
  57. ghMsTcpDll,
  58. STOP_WSDP_FUNCTION_NAME);
  59. if (gpfnStartWsdpSvc != NULL && gpfnStopWsdpSvc != NULL) {
  60. //
  61. // Launch the service and return if succeded
  62. //
  63. INT err = (*gpfnStartWsdpSvc)();
  64. if (err==0) {
  65. return;
  66. }
  67. }
  68. //
  69. // Cleanup if anything fails
  70. //
  71. FreeLibrary (ghMsTcpDll);
  72. ghMsTcpDll = NULL;
  73. }
  74. }
  75. //+---------------------------------------------------------------------------
  76. // StopWsdpService - stop WSDP service if it was started
  77. //
  78. //
  79. VOID
  80. StopWsdpService (
  81. VOID
  82. ) throw()
  83. {
  84. if (ghMsTcpDll!=NULL) {
  85. //
  86. // Tell the service to stop and unload the provider
  87. //
  88. (*gpfnStopWsdpSvc)();
  89. FreeLibrary (ghMsTcpDll);
  90. ghMsTcpDll = NULL;
  91. }
  92. }