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.

201 lines
4.4 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1995-1996.
  5. //
  6. // File:
  7. // remact.hxx
  8. //
  9. // Contents:
  10. //
  11. // Definitions for binding handle cache to remote machines.
  12. //
  13. // History:
  14. //
  15. //--------------------------------------------------------------------------
  16. // wrapper\epts.c
  17. extern "C" {
  18. extern PROTSEQ_INFO gaProtseqInfo[];
  19. }
  20. class CRemoteMachineList;
  21. class CRemoteMachine;
  22. class CMachineBinding;
  23. extern CRemoteMachineList * gpRemoteMachineList;
  24. extern CSharedLock * gpRemoteMachineLock;
  25. const USHORT AUTHN_ANY = 0xffff;
  26. //
  27. // CRemoteMachineList
  28. //
  29. class CRemoteMachineList : public CList
  30. {
  31. public:
  32. CRemoteMachineList() :
  33. _dwCacheSize(0),
  34. _dwMaxCacheSize(gdwRemoteBindingHandleCacheMaxSize)
  35. {}
  36. CRemoteMachine* GetOrAdd(IN WCHAR * pwszMachine);
  37. HRESULT FlushSpecificBindings(WCHAR* pszMachine);
  38. void TryToFlushIdleOrTooOldElements();
  39. private:
  40. // private methods
  41. void RemoveOldestCacheElement();
  42. // private data
  43. DWORD _dwCacheSize; // count of elements in list
  44. DWORD _dwMaxCacheSize; // max size of list cache
  45. };
  46. //
  47. // CRemoteMachine
  48. //
  49. class CRemoteMachine : public CListElement
  50. {
  51. friend class CRemoteMachineList;
  52. public:
  53. CRemoteMachine( IN WCHAR * pwszMachine, IN WCHAR * pwszScmSPN );
  54. ~CRemoteMachine();
  55. ULONG AddRef();
  56. ULONG Release();
  57. HRESULT
  58. Activate(
  59. IN ACTIVATION_PARAMS * pActParams,
  60. IN WCHAR * pwszPathForServer
  61. );
  62. RPC_STATUS PickAuthnAndActivate(
  63. IN ACTIVATION_PARAMS * pActParams,
  64. IN WCHAR * pwszPathForServer,
  65. IN handle_t * pBinding,
  66. IN USHORT AuthnSvc,
  67. IN USHORT ProtseqId,
  68. OUT HRESULT * phr );
  69. CMachineBinding *
  70. LookupBinding(
  71. IN USHORT AuthnSvc,
  72. IN COAUTHINFO * pAuthInfo OPTIONAL
  73. );
  74. void
  75. InsertBinding(
  76. IN handle_t hBinding,
  77. IN USHORT ProtseqId,
  78. IN USHORT AuthnSvc,
  79. IN COAUTHINFO * pAuthInfo OPTIONAL,
  80. IN COAUTHIDENTITY* pAuthIdentity
  81. );
  82. void
  83. FlushBindings();
  84. void FlushBindingsNoLock();
  85. void
  86. RemoveBinding(
  87. IN CMachineBinding * pMachineBinding
  88. );
  89. private:
  90. WCHAR* _pwszMachine;
  91. WCHAR* _pwszScmSPN;
  92. CDualStringArray* _dsa;
  93. CList _BindingList;
  94. ULONG _ulRefCount;
  95. DWORD _dwLastUsedTickCount;
  96. DWORD _dwTickCountAtCreate;
  97. };
  98. class CMachineBinding : public CListElement, public CReferencedObject
  99. {
  100. friend class CRemoteMachine;
  101. public:
  102. CMachineBinding(
  103. IN handle_t hBinding,
  104. IN USHORT ProtseqId,
  105. IN USHORT AuthnSvc,
  106. IN COAUTHINFO * pAuthInfo OPTIONAL,
  107. IN COAUTHIDENTITY* pAuthIdentity
  108. );
  109. ~CMachineBinding();
  110. BOOL
  111. Equal(
  112. IN USHORT AuthnSvc,
  113. IN COAUTHINFO * pAuthInfo OPTIONAL
  114. );
  115. private:
  116. handle_t _hBinding;
  117. USHORT _ProtseqId;
  118. USHORT _AuthnSvc;
  119. COAUTHINFO * _pAuthInfo;
  120. COAUTHIDENTITY* _pAuthIdentity;
  121. };
  122. HRESULT
  123. RemoteActivationCall(
  124. IN ACTIVATION_PARAMS * pActParams,
  125. IN WCHAR * pwszServerName
  126. );
  127. RPC_STATUS
  128. CallRemoteMachine(
  129. IN handle_t hBinding,
  130. IN USHORT ProtseqId,
  131. IN ACTIVATION_PARAMS * pActParams,
  132. IN WCHAR * pwszPathForServer,
  133. IN WCHAR * pwszMachine,
  134. OUT HRESULT * phr
  135. );
  136. RPC_STATUS
  137. CreateRemoteBinding(
  138. IN WCHAR * pwszMachine,
  139. IN int ProtseqIndex,
  140. OUT handle_t * phBinding
  141. );
  142. BOOL
  143. EqualAuthInfo(
  144. IN COAUTHINFO * pAuthInfo,
  145. IN COAUTHINFO * pAuthInfoOther
  146. );
  147. BOOL
  148. EqualAuthIdentity(
  149. IN COAUTHIDENTITY * pAuthIdent,
  150. IN COAUTHIDENTITY * pAuthIdentOther
  151. );
  152. HRESULT
  153. CopyAuthInfo(
  154. IN COAUTHINFO * pAuthInfoSrc,
  155. IN COAUTHINFO ** ppAutInfoDest
  156. );
  157. HRESULT
  158. CopyAuthIdentity(
  159. IN COAUTHIDENTITY* pAuthIdentSrc,
  160. IN COAUTHIDENTITY** ppAuthIdentDest
  161. );
  162. void FreeAuthInfo(COAUTHINFO *pAuthInfo);
  163. void FreeAuthIdentity(void* pAuthIdentity);