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.

274 lines
6.8 KiB

  1. /*++
  2. Copyright (c) 1995-1997 Microsoft Corporation
  3. Module Name :
  4. wamobj.hxx
  5. Abstract:
  6. Header file for the WAM (web application manager) object
  7. Author:
  8. David Kaplan ( DaveK ) 11-Mar-1997
  9. Environment:
  10. User Mode - Win32
  11. Project:
  12. Wam DLL
  13. --*/
  14. # ifndef _WAMOBJ_HXX_
  15. # define _WAMOBJ_HXX_
  16. # define WAM_SIGNATURE (DWORD )' MAW' // will become "WAM " on debug
  17. # define WAM_SIGNATURE_FREE (DWORD )'fMAW' // will become "WAMf" on debug
  18. /************************************************************
  19. * Include Headers
  20. ************************************************************/
  21. # include "wam.h"
  22. # include "wamstats.hxx"
  23. # include "resource.h"
  24. /************************************************************
  25. * Forward References
  26. ************************************************************/
  27. class HSE_BASE;
  28. class WAM_EXEC_INFO;
  29. /************************************************************
  30. * Type Definitions
  31. ************************************************************/
  32. /*++
  33. class WAM
  34. Class definition for the WAM object.
  35. --*/
  36. class ATL_NO_VTABLE WAM :
  37. public CComObjectRootEx<CComMultiThreadModel>,
  38. public CComCoClass<WAM, &CLSID_Wam>,
  39. public IWam
  40. {
  41. public:
  42. WAM()
  43. : m_WamStats(),
  44. m_dwSignature( WAM_SIGNATURE),
  45. m_fShuttingDown( FALSE ),
  46. m_pUnkMarshaler(NULL)
  47. {
  48. }
  49. ~WAM()
  50. {
  51. // check for memory corruption and dangling pointers
  52. m_dwSignature = WAM_SIGNATURE_FREE;
  53. }
  54. DECLARE_GET_CONTROLLING_UNKNOWN()
  55. DECLARE_REGISTRY_RESOURCEID(IDR_WAM)
  56. BEGIN_COM_MAP(WAM)
  57. COM_INTERFACE_ENTRY(IWam)
  58. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
  59. END_COM_MAP()
  60. HRESULT FinalConstruct()
  61. {
  62. return CoCreateFreeThreadedMarshaler(
  63. GetControllingUnknown(), &m_pUnkMarshaler.p);
  64. }
  65. void FinalRelease()
  66. {
  67. m_pUnkMarshaler.Release();
  68. }
  69. CComPtr<IUnknown> m_pUnkMarshaler;
  70. public:
  71. //------------------------------------------------------------
  72. // Methods for IWam interface
  73. //------------------------------------------------------------
  74. STDMETHODIMP
  75. InitWam
  76. (
  77. BOOL fInProcess, // are we in-proc or out-of-proc?
  78. BOOL fInPool, // !Isolated
  79. BOOL fEnableTryExcept, // catch exceptions in ISAPI calls?
  80. int pt, // PLATFORM_TYPE - are we running on Win95?
  81. DWORD *pPID // Process Id of the process the wam was created in
  82. );
  83. STDMETHODIMP
  84. StartShutdown
  85. (
  86. );
  87. STDMETHODIMP
  88. UninitWam
  89. (
  90. );
  91. STDMETHODIMP
  92. ProcessRequest
  93. (
  94. IWamRequest * pIWamRequest,
  95. DWORD cbWrcStrings,
  96. OOP_CORE_STATE * pOopCoreState,
  97. BOOL * pfHandled
  98. );
  99. STDMETHODIMP
  100. ProcessAsyncIO
  101. (
  102. #ifdef _WIN64
  103. UINT64 pWamExecInfoIn, // WAM_EXEC_INFO *
  104. #else
  105. DWORD_PTR pWamExecInfoIn, // WAM_EXEC_INFO *
  106. #endif
  107. DWORD dwStatus,
  108. DWORD cbWritten
  109. );
  110. STDMETHODIMP
  111. ProcessAsyncReadOop
  112. (
  113. #ifdef _WIN64
  114. UINT64 pWamExecInfoIn, // WAM_EXEC_INFO *
  115. #else
  116. DWORD_PTR pWamExecInfoIn, // WAM_EXEC_INFO *
  117. #endif
  118. DWORD dwStatus,
  119. DWORD cbRead,
  120. unsigned char * lpDataRead
  121. );
  122. STDMETHOD( GetStatistics )(
  123. /*[in]*/ DWORD Level,
  124. /*[out, switch_is(Level)]*/
  125. LPWAM_STATISTICS_INFO pWamStatsInfo
  126. );
  127. //------------------------------------------------------------
  128. // Local methods of the object
  129. //------------------------------------------------------------
  130. BOOL IsValid( VOID) const { return (m_dwSignature == WAM_SIGNATURE);}
  131. WAM_STATISTICS & QueryWamStats(VOID) { return ( m_WamStats); }
  132. VOID Lock(VOID) { EnterCriticalSection( &m_csWamExecInfoList); }
  133. VOID Unlock(VOID) { LeaveCriticalSection( &m_csWamExecInfoList); }
  134. BOOL FInProcess(VOID) { return ( m_fInProcess ); }
  135. BOOL FInPool(VOID) { return m_fInPool; }
  136. inline VOID RemoveFromList( PLIST_ENTRY pl);
  137. inline VOID InsertIntoList( PLIST_ENTRY pl);
  138. inline BOOL FWin95( VOID );
  139. private:
  140. VOID HseReleaseExtension( IN HSE_BASE * psExt);
  141. DWORD InvokeExtension(
  142. IN HSE_BASE * psExt,
  143. const char * szISADllPath,
  144. WAM_EXEC_INFO * pWamExecInfo
  145. );
  146. HRESULT
  147. ProcessAsyncIOImpl
  148. (
  149. #ifdef _WIN64
  150. UINT64 pWamExecInfoIn,
  151. #else
  152. DWORD_PTR pWamExecInfoIn,
  153. #endif
  154. DWORD dwStatus,
  155. DWORD cbRead,
  156. LPBYTE lpDataRead = NULL
  157. );
  158. private:
  159. DWORD m_dwSignature;
  160. BOOL m_fInProcess; // inproc or oop?
  161. BOOL m_fInPool; // can have multiple WAMs
  162. BOOL m_fShuttingDown; // shutting down?
  163. // list of wamexecinfo's currently running in this wam
  164. LIST_ENTRY m_WamExecInfoListHead;
  165. // critical section for accessing list
  166. CRITICAL_SECTION m_csWamExecInfoList;
  167. WAM_STATISTICS m_WamStats; // wam stats object
  168. PLATFORM_TYPE m_pt; // win95, nt, etc.
  169. }; // class WAM
  170. typedef WAM * PWAM;
  171. inline VOID WAM::InsertIntoList( PLIST_ENTRY pl)
  172. {
  173. Lock();
  174. InsertHeadList( &m_WamExecInfoListHead, pl );
  175. Unlock();
  176. } // WAM::InsertIntoList()
  177. inline VOID WAM::RemoveFromList( PLIST_ENTRY pl)
  178. {
  179. Lock();
  180. RemoveEntryList( pl );
  181. Unlock();
  182. } // WAM::RemoveFromList()
  183. inline BOOL WAM::FWin95( VOID )
  184. {
  185. return ( m_pt == PtWindows95 || m_pt == PtWindows9x );
  186. }
  187. /************************************************************
  188. * Function Prototypes
  189. ************************************************************/
  190. typedef
  191. LONG
  192. (WINAPI * PFN_INTERLOCKED_COMPARE_EXCHANGE)(
  193. LONG *Destination,
  194. LONG Exchange,
  195. LONG Comperand
  196. );
  197. extern PFN_INTERLOCKED_COMPARE_EXCHANGE g_pfnInterlockedCompareExchange;
  198. // Macro for interlocked compare exchange so that things are smooth.
  199. # define INTERLOCKED_COMPARE_EXCHANGE( pvDest, pvNewValue, pvComparand) \
  200. (g_pfnInterlockedCompareExchange)( pvDest, pvNewValue, pvComparand)
  201. HRESULT DoGlobalInitializations(IN BOOL fInProc, IN BOOL fEnableTryExcept);
  202. HRESULT DoGlobalCleanup(VOID);
  203. // Global flag to enable try/except
  204. extern BOOL g_fEnableTryExcept;
  205. # endif // _WAMOBJ_HXX_
  206. /************************ End of File ***********************/