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.

179 lines
4.0 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. IN BOOL bAnoymous = FALSE
  70. );
  71. BOOL
  72. Match(
  73. IN CToken * pToken,
  74. IN BOOL bRemoteActivation,
  75. IN BOOL bClientImpersonating,
  76. IN WCHAR* pwszWinstaDesktop,
  77. IN BOOL bSurrogate,
  78. IN LONG lThreadToken = 0,
  79. IN LONG lSessionID = INVALID_SESSION_ID,
  80. IN DWORD pid = 0,
  81. IN DWORD dwProcessReqType = PRT_IGNORE,
  82. IN DWORD dwFlags = 0
  83. );
  84. BOOL
  85. CallServer(
  86. IN PACTIVATION_PARAMS pActParams,
  87. IN HRESULT * phr
  88. );
  89. inline void
  90. AddToProcess(
  91. IN GUID Guid
  92. )
  93. {
  94. _pServerProcess->AddClassReg( Guid, _RegistrationKey );
  95. }
  96. inline void
  97. RemoveFromProcess()
  98. {
  99. _pServerProcess->RemoveClassReg( _RegistrationKey );
  100. }
  101. inline DWORD
  102. RegistrationKey()
  103. {
  104. return _RegistrationKey;
  105. }
  106. inline CProcess * GetProcess()
  107. {
  108. return _pServerProcess;
  109. }
  110. inline void SetThreadToken(LONG lThreadToken)
  111. {
  112. InterlockedExchange(&_lThreadToken, lThreadToken);
  113. }
  114. void Suspend() { _pServerProcess->Suspend(); }
  115. void Unsuspend() { _pServerProcess->Unsuspend(); }
  116. void Retire() { _pServerProcess->Retire(); }
  117. void BeginInit() { _pServerProcess->BeginInit(); }
  118. void EndInit() { _pServerProcess->EndInit(); }
  119. BOOL IsInitializing() { return _pServerProcess->IsInitializing(); }
  120. BOOL IsReadyForActivations() { return !(_State & SERVERSTATE_SUSPENDED); }
  121. void IncServerFaults() { InterlockedIncrement((PLONG)&_dwServerFaults); }
  122. BOOL ServerDied();
  123. private:
  124. CServerTableEntry * _pServerTableEntry;
  125. CProcess * _pServerProcess;
  126. HANDLE _hRpc;
  127. HANDLE _hRpcAnonymous;
  128. IPID _ipid;
  129. UCHAR _Context;
  130. UCHAR _State;
  131. USHORT _NumCalls;
  132. DWORD _RegistrationKey;
  133. LONG _lThreadToken;
  134. UCHAR _SubContext;
  135. LONG _lSingleUseStatus;
  136. DWORD _dwServerFaults; // # of times a call to the server threw an exception
  137. BOOL RetryableError(HRESULT hr);
  138. };
  139. #endif