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.

181 lines
4.5 KiB

  1. #ifndef _ISAPICONTEXT_HXX_
  2. #define _ISAPICONTEXT_HXX_
  3. /*++
  4. Copyright (c) 1998 Microsoft Corporation
  5. Module Name :
  6. isapicontext.hxx
  7. Abstract:
  8. ISAPI stream context
  9. - used for Raw ISAPI notifications
  10. (applies only in the IIS backward compatibility mode)
  11. Author:
  12. Bilal Alam (BAlam) 29-March-2000
  13. Environment:
  14. Win32 - User Mode
  15. Project:
  16. Stream Filter Worker Process
  17. --*/
  18. class ISAPI_STREAM_CONTEXT : public STREAM_CONTEXT
  19. {
  20. public:
  21. static
  22. HRESULT
  23. ISAPI_STREAM_CONTEXT::CreateContext(
  24. IN FILTER_CHANNEL_CONTEXT * pFilterChannelContext,
  25. OUT STREAM_CONTEXT ** pIsapiContext
  26. );
  27. virtual ~ISAPI_STREAM_CONTEXT()
  28. {
  29. if ( _pvContext != NULL )
  30. {
  31. sm_pfnReleaseContext( _pvContext );
  32. _pvContext = NULL;
  33. }
  34. EnterCriticalSection( &sm_csIsapiStreamContexts );
  35. RemoveEntryList( &_ListEntry );
  36. sm_lIsapiContexts--;
  37. LeaveCriticalSection( &sm_csIsapiStreamContexts );
  38. }
  39. VOID *
  40. operator new(
  41. size_t size
  42. )
  43. {
  44. UNREFERENCED_PARAMETER( size );
  45. DBG_ASSERT( size == sizeof( ISAPI_STREAM_CONTEXT ) );
  46. DBG_ASSERT( sm_pachIsapiStreamContexts != NULL );
  47. return sm_pachIsapiStreamContexts->Alloc();
  48. }
  49. VOID
  50. operator delete(
  51. VOID * pIsapiStreamContext
  52. )
  53. {
  54. DBG_ASSERT( pIsapiStreamContext != NULL );
  55. DBG_ASSERT( sm_pachIsapiStreamContexts != NULL );
  56. DBG_REQUIRE( sm_pachIsapiStreamContexts->Free( pIsapiStreamContext ) );
  57. }
  58. HRESULT
  59. ProcessRawReadData(
  60. RAW_STREAM_INFO * pRawStreamInfo,
  61. BOOL * pfReadMore,
  62. BOOL * pfComplete
  63. );
  64. static
  65. HRESULT
  66. Initialize(
  67. VOID
  68. );
  69. static
  70. VOID
  71. Terminate(
  72. VOID
  73. );
  74. HRESULT
  75. ProcessRawWriteData(
  76. RAW_STREAM_INFO * pRawStreamInfo,
  77. BOOL * pfComplete
  78. );
  79. VOID
  80. ProcessConnectionClose(
  81. VOID
  82. );
  83. HRESULT
  84. ProcessNewConnection(
  85. CONNECTION_INFO * pConnectionInfo,
  86. ENDPOINT_CONFIG * pEndpointConfig
  87. );
  88. static
  89. HRESULT
  90. EnableISAPIFilters(
  91. ISAPI_FILTERS_CALLBACKS * pCallbacks
  92. );
  93. static
  94. VOID
  95. DisableISAPIFilters(
  96. VOID
  97. );
  98. static
  99. HRESULT
  100. SendDataBack(
  101. PVOID pvStreamContext,
  102. RAW_STREAM_INFO * pRawStreamInfo
  103. );
  104. FILTER_CHANNEL_CONTEXT *
  105. QueryFilterChannelContext(
  106. VOID
  107. ) const
  108. {
  109. return _pFilterChannelContext;
  110. }
  111. static
  112. VOID
  113. DisconnectAllConnectionsWithIsapiStreamContext(
  114. VOID
  115. );
  116. private:
  117. //
  118. // private constructor (use CreateContext() method for creation)
  119. //
  120. ISAPI_STREAM_CONTEXT( FILTER_CHANNEL_CONTEXT * pFiltChannelContext )
  121. : STREAM_CONTEXT( pFiltChannelContext ),
  122. _pvContext( NULL ),
  123. _pFilterChannelContext( NULL )
  124. {
  125. }
  126. LIST_ENTRY _ListEntry;
  127. PVOID _pvContext;
  128. // FILTER_CHANNEL_CONTEXT representing connection
  129. FILTER_CHANNEL_CONTEXT * _pFilterChannelContext;
  130. static PFN_PROCESS_RAW_READ sm_pfnRawRead;
  131. static PFN_PROCESS_RAW_WRITE sm_pfnRawWrite;
  132. static PFN_PROCESS_CONNECTION_CLOSE sm_pfnConnectionClose;
  133. static PFN_PROCESS_NEW_CONNECTION sm_pfnNewConnection;
  134. static PFN_RELEASE_CONTEXT sm_pfnReleaseContext;
  135. // list of ISAPI contexts
  136. static LIST_ENTRY sm_ListHead;
  137. // CS to synchronize access to ISAPI contexts list
  138. static CRITICAL_SECTION sm_csIsapiStreamContexts;
  139. // flag that CS was initialized
  140. static BOOL sm_fInitcsIsapiStreamContexts;
  141. // number of active ISAPI contexts
  142. static LONG sm_lIsapiContexts;
  143. // flag that all connections with ISAPI context on them are disconnecting
  144. // no new connections should be created with ISAPI context
  145. static BOOL sm_fEnabledISAPIFilters;
  146. // Lookaside
  147. static ALLOC_CACHE_HANDLER * sm_pachIsapiStreamContexts;
  148. };
  149. #endif