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.

113 lines
2.5 KiB

  1. /********************************************************************/
  2. /** Copyright(c) 1995 Microsoft Corporation. **/
  3. /********************************************************************/
  4. //***
  5. //
  6. // Filename: rpc.c
  7. //
  8. // Description: Contains code to initialize and terminate RPC
  9. //
  10. // History: May 11,1995 NarenG Created original version.
  11. //
  12. #include "dimsvcp.h"
  13. #include <rpc.h>
  14. #include <ntseapi.h>
  15. #include <ntlsa.h>
  16. #include <ntsam.h>
  17. #include <ntsamp.h>
  18. #include "dimsvc_s.c"
  19. //**
  20. //
  21. // Call: DimInitializeRPC
  22. //
  23. // Returns: NO_ERROR - success
  24. // ERROR_NOT_ENOUGH_MEMORY
  25. // nonzero returns from RPC APIs
  26. // RpcServerRegisterIf()
  27. // RpcServerUseProtseqEp()
  28. //
  29. // Description: Starts an RPC Server, adds the address (or port/pipe),
  30. // and adds the interface (dispatch table).
  31. //
  32. DWORD
  33. DimInitializeRPC(
  34. IN BOOL fLanOnlyMode
  35. )
  36. {
  37. RPC_STATUS RpcStatus;
  38. //
  39. // RASMAN is not around so we need to do this stuff
  40. //
  41. if ( fLanOnlyMode )
  42. {
  43. //
  44. // Ignore the second argument for now.
  45. //
  46. RpcStatus = RpcServerUseProtseqEpW( TEXT("ncacn_np"),
  47. 10,
  48. TEXT("\\PIPE\\ROUTER"),
  49. NULL );
  50. //
  51. // We need to ignore the RPC_S_DUPLICATE_ENDPOINT error
  52. // in case this DLL is reloaded within the same process.
  53. //
  54. if ( RpcStatus != RPC_S_OK && RpcStatus != RPC_S_DUPLICATE_ENDPOINT)
  55. {
  56. return( RpcStatus );
  57. }
  58. }
  59. RpcStatus = RpcServerRegisterIfEx( dimsvc_ServerIfHandle,
  60. 0,
  61. 0,
  62. RPC_IF_AUTOLISTEN,
  63. RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
  64. NULL );
  65. if ( ( RpcStatus == RPC_S_OK ) || ( RpcStatus == RPC_S_ALREADY_LISTENING ) )
  66. {
  67. return( NO_ERROR );
  68. }
  69. else
  70. {
  71. return( RpcStatus );
  72. }
  73. }
  74. //**
  75. //
  76. // Call: DimTerminateRPC
  77. //
  78. // Returns: none
  79. //
  80. // Description: Deletes the interface.
  81. //
  82. VOID
  83. DimTerminateRPC(
  84. VOID
  85. )
  86. {
  87. RPC_STATUS status;
  88. if(RPC_S_OK != (status = RpcServerUnregisterIf(
  89. dimsvc_ServerIfHandle, 0, 0 )))
  90. {
  91. #if DBG
  92. DbgPrint("REMOTEACCESS: DimTerminateRPC returned error"
  93. " 0x%x\n", status);
  94. #endif
  95. }
  96. return;
  97. }