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.

189 lines
6.2 KiB

  1. /****************************************************************************/
  2. // tssdjet.h
  3. //
  4. // Terminal Server Session Directory Interface Jet RPC provider header.
  5. //
  6. // Copyright (C) 2000 Microsoft Corporation
  7. /****************************************************************************/
  8. #ifndef __TSSDJET_H
  9. #define __TSSDJET_H
  10. #include <tchar.h>
  11. #include "tssd.h"
  12. #include "tssdcommon.h"
  13. #include "tssdshrd.h"
  14. #include "srvsetex.h"
  15. #include "jetrpc.h"
  16. #include "synch.h"
  17. /****************************************************************************/
  18. // Defines
  19. /****************************************************************************/
  20. /****************************************************************************/
  21. // Types
  22. /****************************************************************************/
  23. // CTSSessionDirectory
  24. //
  25. // C++ class instantiation of ITSSessionDirectory.
  26. class CTSSessionDirectory : public ITSSessionDirectory,
  27. public IExtendServerSettings, public ITSSessionDirectoryEx
  28. {
  29. private:
  30. long m_RefCount;
  31. BOOL m_bConnected;
  32. HCLIENTINFO m_hCI;
  33. RPC_BINDING_HANDLE m_hRPCBinding;
  34. WCHAR m_StoreServerName[64];
  35. WCHAR m_LocalServerAddress[64];
  36. WCHAR m_ClusterName[64];
  37. // Flags passed in from Termsrv
  38. DWORD m_Flags;
  39. // Private data for UI menus
  40. BOOL m_fEnabled;
  41. // Autorecovery variables
  42. //
  43. // Events
  44. // * m_hSDServerDown - Event that is signalled to awaken recovery thread,
  45. // which wakes up, polls the session directory until it comes back up,
  46. // and then refreshes the database.
  47. // * m_hTerminateRecovery - Recovery thread, when it enters waits, can be
  48. // terminated by the use of this event
  49. //
  50. // Thread Information
  51. // * m_hRecoveryThread - Handle to the recovery thread.
  52. // * m_RecoveryTid - Thread identifier for recovery thread.
  53. //
  54. // Boolean
  55. // * m_bSDIsUp - If this is on then we think the session directory is up.
  56. // * m_sr - Protects m_SDIsUp.
  57. //
  58. // DWORD
  59. // * m_RecoveryTimeout - time in ms between attempts to reestablish
  60. // connection with the session directory.
  61. //
  62. // Function pointer
  63. // * m_repopfn - pointer to the repopulation function in termsrv to call
  64. // when we want an update.
  65. OVERLAPPED m_OverLapped;
  66. HANDLE m_hIPChange;
  67. HANDLE m_NotifyIPChange;
  68. HANDLE m_hSDServerDown;
  69. HANDLE m_hTerminateRecovery;
  70. uintptr_t m_hRecoveryThread;
  71. unsigned m_RecoveryTid;
  72. // m_sr protects SDIsUp flag
  73. SHAREDRESOURCE m_sr;
  74. volatile LONG m_SDIsUp;
  75. HANDLE m_hInRepopulate; // Signal if not in repopulate,
  76. // non-signal if repopulate is in progress
  77. LONG m_ConnectionEstablished;
  78. // Flag for whether shared reader/writer lock init succeeded. If it doesn't
  79. // succeed, we can't do anything.
  80. BOOL m_LockInitializationSuccessful;
  81. BOOL m_bStartRPCListener;
  82. DWORD m_RecoveryTimeout;
  83. DWORD (*m_repopfn)();
  84. // Autorecovery thread
  85. unsigned static __stdcall RecoveryThread(void *);
  86. VOID RecoveryThreadEx();
  87. // Helper functions
  88. DWORD RequestSessDirUpdate();
  89. DWORD ReestablishSessionDirectoryConnection();
  90. void Terminate();
  91. void StartupSD();
  92. void NotifySDServerDown();
  93. boolean EnterSDRpc();
  94. void LeaveSDRpc();
  95. void DisableSDRpcs();
  96. void EnableSDRpcs();
  97. void SetSDConnectionDown() {
  98. InterlockedExchange( &m_ConnectionEstablished, FALSE );
  99. }
  100. void SetSDConnectionReady() {
  101. InterlockedExchange( &m_ConnectionEstablished, TRUE );
  102. }
  103. BOOL IsSDConnectionReady() {
  104. return (BOOL) InterlockedExchangeAdd( &m_ConnectionEstablished, 0 );
  105. }
  106. public:
  107. CTSSessionDirectory();
  108. ~CTSSessionDirectory();
  109. // Standard COM methods
  110. HRESULT STDMETHODCALLTYPE QueryInterface(REFIID, void **);
  111. ULONG STDMETHODCALLTYPE AddRef();
  112. ULONG STDMETHODCALLTYPE Release();
  113. // ITSSessionDirectory COM interface
  114. HRESULT STDMETHODCALLTYPE Initialize(LPWSTR, LPWSTR, LPWSTR, LPWSTR,
  115. DWORD, DWORD (*)(), DWORD (*)(DWORD));
  116. HRESULT STDMETHODCALLTYPE Update(LPWSTR, LPWSTR, LPWSTR, LPWSTR, DWORD, BOOL);
  117. HRESULT STDMETHODCALLTYPE GetUserDisconnectedSessions(LPWSTR, LPWSTR,
  118. DWORD __RPC_FAR *, TSSD_DisconnectedSessionInfo __RPC_FAR
  119. [TSSD_MaxDisconnectedSessions]);
  120. HRESULT STDMETHODCALLTYPE NotifyCreateLocalSession(
  121. TSSD_CreateSessionInfo __RPC_FAR *);
  122. HRESULT STDMETHODCALLTYPE NotifyDestroyLocalSession(DWORD);
  123. HRESULT STDMETHODCALLTYPE NotifyDisconnectLocalSession(DWORD, FILETIME);
  124. HRESULT STDMETHODCALLTYPE NotifyReconnectLocalSession(
  125. TSSD_ReconnectSessionInfo __RPC_FAR *);
  126. HRESULT STDMETHODCALLTYPE NotifyReconnectPending(WCHAR *);
  127. HRESULT STDMETHODCALLTYPE Repopulate(DWORD, TSSD_RepopulateSessionInfo *);
  128. HRESULT STDMETHODCALLTYPE GetLoadBalanceInfo(LPWSTR, BSTR*);
  129. HRESULT STDMETHODCALLTYPE PingSD(PWCHAR pszServerName);
  130. HRESULT STDMETHODCALLTYPE WaitForRepopulate(DWORD dwTimeOut);
  131. // IExtendServerSettings COM interface
  132. STDMETHOD(GetAttributeName)(WCHAR *);
  133. STDMETHOD(GetDisplayableValueName)(WCHAR *);
  134. STDMETHOD(InvokeUI)(HWND,PDWORD);
  135. STDMETHOD(GetMenuItems)(int *, PMENUEXTENSION *);
  136. STDMETHOD(ExecMenuCmd)(UINT, HWND, PDWORD);
  137. STDMETHOD(OnHelp)(int *);
  138. BOOL CTSSessionDirectory::CheckSessionDirectorySetting(WCHAR *Setting);
  139. BOOL CTSSessionDirectory::CheckIfSessionDirectoryNameEmpty(WCHAR *Setting);
  140. BOOL IsSessionDirectoryEnabled();
  141. BOOL CTSSessionDirectory::IsSessionDirectoryExposeServerIPEnabled();
  142. DWORD SetSessionDirectoryState(WCHAR *, BOOL);
  143. DWORD SetSessionDirectoryEnabledState(BOOL);
  144. DWORD SetSessionDirectoryExposeIPState(BOOL);
  145. void ErrorMessage(HWND hwnd , UINT res , DWORD);
  146. BOOL SDJETInitRPC();
  147. public:
  148. TCHAR m_tchProvider[64];
  149. TCHAR m_tchDataSource[64];
  150. TCHAR m_tchUserId[64];
  151. TCHAR m_tchPassword[64];
  152. };
  153. RPC_STATUS RPC_ENTRY JetRpcAccessCheck(RPC_IF_HANDLE idIF, void *Binding);
  154. #endif // __TSSDJET_H