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.

176 lines
4.1 KiB

  1. /*++
  2. Copyright (c) 1995-1997 Microsoft Corporation
  3. Module Name:
  4. servers.hxx
  5. Abstract:
  6. Author:
  7. DKays
  8. Revision History:
  9. --*/
  10. #ifndef __SERVERS_HXX__
  11. #define __SERVERS_HXX__
  12. class CServerList;
  13. class CServerListEntry;
  14. //
  15. // A CServerList maintains a list of all process objects for servers who have
  16. // registered a particular CLSID.
  17. //
  18. class CServerList : public CList
  19. {
  20. public:
  21. CServerList() {}
  22. ~CServerList() {}
  23. BOOL
  24. InList(
  25. IN CServerListEntry * pServerListEntry
  26. );
  27. inline BOOL
  28. IsEmpty() { return First() == NULL; }
  29. private:
  30. };
  31. // _State values.
  32. #define SERVERSTATE_SINGLEUSE 0x1
  33. #define SERVERSTATE_SUSPENDED 0x2
  34. #define SERVERSTATE_SURROGATE 0x4
  35. #define SERVERSTATE_NOTSTARTED 0x8
  36. #define SERVERSTATE_READY 0x10
  37. // _Context values.
  38. #define SERVER_ACTIVATOR 1
  39. #define SERVER_SERVICE 2
  40. #define SERVER_RUNAS 3
  41. // _SubContext values.
  42. #define SUB_CONTEXT_RUNAS_THIS_USER 1
  43. #define SUB_CONTEXT_RUNAS_INTERACTIVE 2
  44. // _lSingleUseStatus values
  45. #define SINGLE_USE_AVAILABLE 0
  46. #define SINGLE_USE_TAKEN 1
  47. // Values
  48. #define MATCHFLAG_ALLOW_SUSPENDED 1
  49. //
  50. // CServerListEntry
  51. //
  52. class CServerListEntry : public CListElement, public CReferencedObject
  53. {
  54. friend class CServerList;
  55. friend class CServerTableEntry;
  56. friend class CSurrogateListEntry;
  57. public:
  58. CServerListEntry(
  59. IN CServerTableEntry * pServerTableEntry,
  60. IN CProcess * pServerProcess,
  61. IN IPID ipid,
  62. IN UCHAR Context,
  63. IN UCHAR State,
  64. IN UCHAR SubContext
  65. );
  66. ~CServerListEntry();
  67. HANDLE
  68. RpcHandle();
  69. BOOL
  70. Match(
  71. IN CToken * pToken,
  72. IN BOOL bRemoteActivation,
  73. IN BOOL bClientImpersonating,
  74. IN WCHAR* pwszWinstaDesktop,
  75. IN BOOL bSurrogate,
  76. IN LONG lThreadToken = 0,
  77. IN LONG lSessionID = INVALID_SESSION_ID,
  78. IN DWORD pid = 0,
  79. IN DWORD dwProcessReqType = PRT_IGNORE,
  80. IN DWORD dwFlags = 0
  81. );
  82. BOOL
  83. CallServer(
  84. IN PACTIVATION_PARAMS pActParams,
  85. IN HRESULT * phr
  86. );
  87. inline void
  88. AddToProcess(
  89. IN GUID Guid
  90. )
  91. {
  92. _pServerProcess->AddClassReg( Guid, _RegistrationKey );
  93. }
  94. inline void
  95. RemoveFromProcess()
  96. {
  97. _pServerProcess->RemoveClassReg( _RegistrationKey );
  98. }
  99. inline DWORD
  100. RegistrationKey()
  101. {
  102. return _RegistrationKey;
  103. }
  104. inline CProcess * GetProcess()
  105. {
  106. return _pServerProcess;
  107. }
  108. inline void SetThreadToken(LONG lThreadToken)
  109. {
  110. InterlockedExchange(&_lThreadToken, lThreadToken);
  111. }
  112. void Suspend() { _pServerProcess->Suspend(); }
  113. void Unsuspend() { _pServerProcess->Unsuspend(); }
  114. void Retire() { _pServerProcess->Retire(); }
  115. void BeginInit() { _pServerProcess->BeginInit(); }
  116. void EndInit() { _pServerProcess->EndInit(); }
  117. BOOL IsInitializing() { return _pServerProcess->IsInitializing(); }
  118. BOOL IsReadyForActivations() { return !(_State & SERVERSTATE_SUSPENDED); }
  119. void IncServerFaults() { InterlockedIncrement((PLONG)&_dwServerFaults); }
  120. BOOL ServerDied();
  121. private:
  122. CServerTableEntry * _pServerTableEntry;
  123. CProcess * _pServerProcess;
  124. HANDLE _hRpc;
  125. IPID _ipid;
  126. UCHAR _Context;
  127. UCHAR _State;
  128. USHORT _NumCalls;
  129. DWORD _RegistrationKey;
  130. LONG _lThreadToken;
  131. UCHAR _SubContext;
  132. LONG _lSingleUseStatus;
  133. DWORD _dwServerFaults; // # of times a call to the server threw an exception
  134. BOOL RetryableError(HRESULT hr);
  135. };
  136. #endif