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.

179 lines
4.3 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1991 - 1999
  3. Module Name:
  4. epmap.c
  5. Abstract:
  6. This file contains the EP Mapper startup code and process wide globals.
  7. Author:
  8. Bharat Shah (barats) 17-2-92
  9. Revision History:
  10. 06-16-95 MarioGo Much of the code replaced by ..\wrapper\start.c
  11. Renamed from server.c
  12. Jan 2000 KamenM Add debugging support
  13. --*/
  14. #include <sysinc.h>
  15. #include <wincrypt.h>
  16. #include <rpc.h>
  17. #include <winsvc.h>
  18. #include "epmp.h"
  19. #include "eptypes.h"
  20. #include "local.h"
  21. #include <DbgComn.h>
  22. #include <DbgIdl.h>
  23. #include <DbgSvr.hxx>
  24. #if DBG && !defined(DEBUGRPC)
  25. #define DEBUGRPC
  26. #endif
  27. //
  28. // Endpoint Mapper Functions
  29. //
  30. extern RPC_STATUS InitializeIpPortManager();
  31. extern RPC_STATUS RPC_ENTRY
  32. LocalEpmpSecurityCallback (
  33. IN RPC_IF_HANDLE InterfaceUuid,
  34. IN void *Context
  35. );
  36. //
  37. // Endpoint Mapper Globals
  38. //
  39. HANDLE hEpMapperHeap;
  40. CRITICAL_SECTION EpCritSec;
  41. PIFOBJNode IFObjList = NULL;
  42. PSAVEDCONTEXT GlobalContextList = NULL;
  43. unsigned long cTotalEpEntries = 0L;
  44. unsigned long GlobalIFOBJid = 0xFFL;
  45. unsigned long GlobalEPid = 0x00FFFFFFL;
  46. UUID NilUuid = { 0L, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0} };
  47. DWORD
  48. StartEndpointMapper(
  49. void
  50. )
  51. /*++
  52. Routine Description:
  53. Called during dcomss startup. Should call Updatestatus()
  54. if something will take very long.
  55. Arguments:
  56. None
  57. Return Value:
  58. 0 - success
  59. non-0 - will cause the service to fail.
  60. --*/
  61. {
  62. extern void RPC_ENTRY UpdateAddresses( PVOID arg );
  63. RPC_STATUS status = RPC_S_OK;
  64. BOOL fAuthInfoNotRegistered = FALSE;
  65. InitializeCriticalSectionAndSpinCount(&EpCritSec, PREALLOCATE_EVENT_MASK);
  66. hEpMapperHeap = GetProcessHeap();
  67. if (hEpMapperHeap == 0)
  68. {
  69. ASSERT(GetLastError() != 0);
  70. return(GetLastError());
  71. }
  72. // register snego & kerberos. During clean install, this code can
  73. // legally fail, as Rpcss is started before there are any
  74. // security providers. Therefore, we cannot fail Rpcss init if this
  75. // fails - we just don't register the debug interface, who is the
  76. // only user of this
  77. status = RpcServerRegisterAuthInfo(NULL, RPC_C_AUTHN_GSS_NEGOTIATE, NULL, NULL);
  78. if (status != RPC_S_OK)
  79. {
  80. fAuthInfoNotRegistered = TRUE;
  81. }
  82. status = RpcServerRegisterAuthInfo(NULL, RPC_C_AUTHN_GSS_KERBEROS, NULL, NULL);
  83. if (status != RPC_S_OK)
  84. {
  85. fAuthInfoNotRegistered = TRUE;
  86. }
  87. status = RpcServerRegisterIf2(epmp_ServerIfHandle,
  88. 0,
  89. 0,
  90. 0,
  91. RPC_C_LISTEN_MAX_CALLS_DEFAULT,
  92. epmp_MaxRpcSize,
  93. NULL);
  94. if (status != RPC_S_OK)
  95. {
  96. return(status);
  97. }
  98. status = RpcServerRegisterIf2(localepmp_ServerIfHandle,
  99. 0,
  100. 0,
  101. 0,
  102. RPC_C_LISTEN_MAX_CALLS_DEFAULT,
  103. localepmp_MaxRpcSize,
  104. LocalEpmpSecurityCallback);
  105. if (status != RPC_S_OK)
  106. {
  107. return(status);
  108. }
  109. if (fAuthInfoNotRegistered == FALSE)
  110. {
  111. status = RpcServerRegisterIf2(DbgIdl_ServerIfHandle,
  112. 0,
  113. 0,
  114. 0,
  115. RPC_C_LISTEN_MAX_CALLS_DEFAULT,
  116. DbgIdl_MaxRpcSize,
  117. DebugServerSecurityCallback);
  118. if (status != RPC_S_OK)
  119. {
  120. return(status);
  121. }
  122. }
  123. status = I_RpcServerRegisterForwardFunction( GetForwardEp );
  124. #ifndef DOSWIN32RPC
  125. if (status == RPC_S_OK)
  126. {
  127. status = InitializeIpPortManager();
  128. ASSERT(status == RPC_S_OK);
  129. }
  130. #endif
  131. status = I_RpcServerSetAddressChangeFn( UpdateAddresses );
  132. ASSERT( 0 == status );
  133. return(status);
  134. }