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.

432 lines
9.9 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name :
  4. isapi_request.hxx
  5. Abstract:
  6. IIS+ ISAPI interface implementation.
  7. Author:
  8. Wade Hilmo (wadeh) 29-Aug-2000
  9. Project:
  10. w3core.dll
  11. --*/
  12. #ifndef _ISAPI_REQUEST_HXX_
  13. #define _ISAPI_REQUEST_HXX_
  14. #include "precomp.hxx"
  15. #include "wam_process.hxx"
  16. #define ISAPI_REQUEST_SIGNATURE (DWORD)'ISRQ'
  17. #define ISAPI_REQUEST_SIGNATURE_FREE (DWORD)'ISRf'
  18. class ISAPI_REQUEST : public IIsapiCore
  19. {
  20. //
  21. // ACACHE stuff
  22. //
  23. public:
  24. static BOOL InitClass( VOID );
  25. static VOID CleanupClass( VOID );
  26. ISAPI_REQUEST( W3_CONTEXT * pW3Context, BOOL fIsOop )
  27. : _dwSignature( ISAPI_REQUEST_SIGNATURE ),
  28. _cRefs( 1 ),
  29. _pUnkFTM( NULL ),
  30. _IsapiContext( 0 ),
  31. _LastIsapiContext( 0 ),
  32. _pW3Context( pW3Context ),
  33. _fAsyncIoPending( FALSE ),
  34. _hTfFile( INVALID_HANDLE_VALUE ),
  35. _pTfHead( NULL ),
  36. _pTfTail( NULL ),
  37. _pAsyncReadBuffer( NULL ),
  38. _pAsyncWriteBuffer( NULL ),
  39. _nElementCount( 0 ),
  40. _pbExecUrlEntity( NULL ),
  41. _hExecUrlToken( NULL ),
  42. _fIsOop( fIsOop ),
  43. _fCacheResponse( FALSE ),
  44. _pWamProcess( NULL )
  45. {
  46. DBG_ASSERT( _pW3Context );
  47. }
  48. BOOL
  49. CheckSignature(
  50. VOID
  51. )
  52. {
  53. return ( _dwSignature == ISAPI_REQUEST_SIGNATURE );
  54. }
  55. VOID *
  56. operator new(
  57. size_t uiSize,
  58. VOID * pPlacement
  59. )
  60. {
  61. W3_CONTEXT * pContext;
  62. pContext = (W3_CONTEXT*) pPlacement;
  63. DBG_ASSERT( pContext != NULL );
  64. DBG_ASSERT( pContext->CheckSignature() );
  65. return pContext->ContextAlloc( (UINT)uiSize );
  66. }
  67. VOID
  68. operator delete(
  69. VOID *
  70. )
  71. {
  72. }
  73. BOOL
  74. QueryAsyncIoPending(
  75. VOID
  76. )
  77. {
  78. DBG_ASSERT( CheckSignature() );
  79. return _fAsyncIoPending;
  80. }
  81. VOID
  82. SetAsyncIoPending(
  83. BOOL fPending
  84. )
  85. {
  86. DBG_ASSERT( CheckSignature() );
  87. _fAsyncIoPending = fPending;
  88. }
  89. VOID
  90. SetAssociatedWamProcess(
  91. WAM_PROCESS * pWamProcess
  92. )
  93. {
  94. DBG_ASSERT( _fIsOop );
  95. DBG_ASSERT( _pWamProcess == NULL );
  96. _pWamProcess = pWamProcess;
  97. _pWamProcess->AddRef();
  98. _pWamProcess->AddIsapiRequestToList( this );
  99. }
  100. DWORD64
  101. QueryIsapiContext(
  102. VOID
  103. )
  104. {
  105. return _IsapiContext;
  106. }
  107. //
  108. // Housekeeping
  109. //
  110. HRESULT
  111. Create(
  112. VOID
  113. );
  114. HRESULT STDMETHODCALLTYPE
  115. QueryInterface(
  116. REFIID riid,
  117. void __RPC_FAR *__RPC_FAR *ppvObject
  118. );
  119. ULONG STDMETHODCALLTYPE
  120. AddRef(
  121. void
  122. );
  123. ULONG STDMETHODCALLTYPE
  124. Release(
  125. void
  126. );
  127. //
  128. // IIsapiCore implementation
  129. //
  130. HRESULT STDMETHODCALLTYPE
  131. GetServerVariable(
  132. LPSTR szVariableName,
  133. BYTE * szBuffer,
  134. DWORD cbBuffer,
  135. DWORD * pcbBufferRequired
  136. );
  137. HRESULT STDMETHODCALLTYPE
  138. ReadClient(
  139. DWORD64 IsaContext,
  140. BYTE *pBuffer,
  141. DWORD cbBuffer,
  142. DWORD dwBytesToRead,
  143. DWORD *pdwSyncBytesRead,
  144. DWORD dwFlags
  145. );
  146. HRESULT STDMETHODCALLTYPE
  147. WriteClient(
  148. DWORD64 IsaContext,
  149. BYTE * pBuffer,
  150. DWORD cbBuffer,
  151. DWORD dwFlags
  152. );
  153. HRESULT STDMETHODCALLTYPE
  154. SendResponseHeaders(
  155. BOOL fDisconnect,
  156. LPSTR szStatus,
  157. LPSTR szHeaders,
  158. DWORD dwFlags
  159. );
  160. HRESULT STDMETHODCALLTYPE
  161. MapPath(
  162. BYTE * szPath,
  163. DWORD cbPath,
  164. DWORD * pcbBufferRequired,
  165. BOOL fUnicode
  166. );
  167. HRESULT STDMETHODCALLTYPE
  168. MapPathEx(
  169. BYTE * szUrl,
  170. DWORD cbUrl,
  171. BYTE * szPath,
  172. DWORD cbPath,
  173. DWORD * pcbBufferRequired,
  174. DWORD * pcchMatchingPath,
  175. DWORD * pcchMatchingUrl,
  176. DWORD * pdwFlags,
  177. BOOL fUnicode
  178. );
  179. HRESULT STDMETHODCALLTYPE
  180. TransmitFile(
  181. DWORD64 IsaContext,
  182. DWORD_PTR hFile,
  183. DWORD64 cbOffset,
  184. DWORD64 cbWrite,
  185. LPSTR szStatusCode,
  186. BYTE * pHead,
  187. DWORD cbHead,
  188. BYTE * pTail,
  189. DWORD cbTail,
  190. DWORD dwFlags
  191. );
  192. HRESULT STDMETHODCALLTYPE
  193. SetConnectionClose(
  194. BOOL fClose
  195. );
  196. HRESULT STDMETHODCALLTYPE
  197. SendRedirect(
  198. LPCSTR szLocation,
  199. BOOL fDisconnect
  200. );
  201. HRESULT STDMETHODCALLTYPE
  202. GetCertificateInfoEx(
  203. DWORD cbAllocated,
  204. DWORD * pdwCertEncodingType,
  205. BYTE * pbCertEncoded,
  206. DWORD * pcbCertEncoded,
  207. DWORD * pdwCertificateFlags
  208. );
  209. HRESULT STDMETHODCALLTYPE
  210. AppendLog(
  211. LPSTR szExtraParam,
  212. USHORT StatusCode
  213. );
  214. HRESULT STDMETHODCALLTYPE
  215. ExecuteUrl(
  216. DWORD64 IsaContext,
  217. EXEC_URL_INFO * pExecUrlInfo
  218. );
  219. HRESULT STDMETHODCALLTYPE
  220. GetExecuteUrlStatus(
  221. USHORT * pChildStatusCode,
  222. USHORT * pChildSubErrorCode,
  223. DWORD * pChildWin32Error
  224. );
  225. HRESULT STDMETHODCALLTYPE
  226. SendCustomError(
  227. DWORD64 IsaContext,
  228. CHAR * pszStatus,
  229. USHORT uHttpSubError
  230. );
  231. HRESULT STDMETHODCALLTYPE
  232. VectorSend(
  233. DWORD64 IsaContext,
  234. BOOL fDisconnect,
  235. LPSTR pszStatus,
  236. LPSTR pszHeaders,
  237. VECTOR_ELEMENT *pElements,
  238. DWORD nElementCount,
  239. BOOL fFinalSend,
  240. BOOL fCacheResponse
  241. );
  242. HRESULT
  243. PreprocessIoCompletion(
  244. DWORD cbIo
  245. );
  246. VOID
  247. ResetIsapiContext(
  248. VOID
  249. )
  250. {
  251. DBG_ASSERT( _IsapiContext != 0 );
  252. _LastIsapiContext = _IsapiContext;
  253. _IsapiContext = 0;
  254. }
  255. HRESULT STDMETHODCALLTYPE
  256. GetCustomError(
  257. DWORD dwError,
  258. DWORD dwSubError,
  259. DWORD dwBufferSize,
  260. BYTE *pvBuffer,
  261. DWORD *pdwRequiredBufferSize,
  262. BOOL *pfIsFileError,
  263. BOOL *pfSendErrorBody);
  264. HRESULT STDMETHODCALLTYPE
  265. TestConnection(
  266. BOOL *pfIsConnected
  267. );
  268. HRESULT STDMETHODCALLTYPE
  269. GetSspiInfo(
  270. BYTE *pCredHandle,
  271. DWORD cbCredHandle,
  272. BYTE *pCtxtHandle,
  273. DWORD cbCtxtHandle);
  274. HRESULT STDMETHODCALLTYPE
  275. QueryToken(
  276. BYTE *szUrl,
  277. DWORD cbUrl,
  278. DWORD dwTokenType,
  279. DWORD64 *pToken,
  280. BOOL fUnicode);
  281. HRESULT STDMETHODCALLTYPE
  282. ReportAsUnhealthy(
  283. BYTE *szImage,
  284. DWORD cbImage,
  285. BYTE *szReason,
  286. DWORD cbReason);
  287. HRESULT STDMETHODCALLTYPE
  288. AddFragmentToCache(
  289. VECTOR_ELEMENT * pVectorElement,
  290. WCHAR * pszFragmentName);
  291. HRESULT STDMETHODCALLTYPE
  292. ReadFragmentFromCache(
  293. WCHAR * pszFragmentName,
  294. BYTE * pvBuffer,
  295. DWORD cbSize,
  296. DWORD * pcbCopied);
  297. HRESULT STDMETHODCALLTYPE
  298. RemoveFragmentFromCache(
  299. WCHAR * pszFragmentName);
  300. HRESULT STDMETHODCALLTYPE
  301. GetMetadataProperty(
  302. DWORD dwPropertyId,
  303. BYTE * pvBuffer,
  304. DWORD cbBuffer,
  305. DWORD * pcbBufferRequired);
  306. HRESULT STDMETHODCALLTYPE
  307. GetCacheInvalidationCallback(
  308. DWORD64 * pfnCallback);
  309. HRESULT STDMETHODCALLTYPE
  310. CloseConnection(
  311. VOID
  312. );
  313. HRESULT STDMETHODCALLTYPE
  314. AllocateMemory(
  315. DWORD cbSize,
  316. DWORD64 * ppvBuffer
  317. );
  318. BOOL
  319. QueryCacheResponse()
  320. {
  321. return _fCacheResponse;
  322. }
  323. LIST_ENTRY _leRequest; // for linking to the owning process
  324. private:
  325. ~ISAPI_REQUEST(); // Destructor can only be called through Release
  326. static ALLOC_CACHE_HANDLER * sm_pachIsapiRequest;
  327. static PTRACE_LOG sm_pTraceLog;
  328. //
  329. // Member variables
  330. //
  331. DWORD _dwSignature;
  332. LONG _cRefs;
  333. IUnknown * _pUnkFTM;
  334. DWORD64 _IsapiContext;
  335. DWORD64 _LastIsapiContext;
  336. W3_CONTEXT * _pW3Context;
  337. BOOL _fAsyncIoPending;
  338. HANDLE _hTfFile;
  339. LPBYTE _pTfHead;
  340. LPBYTE _pTfTail;
  341. LPBYTE _pAsyncReadBuffer;
  342. LPBYTE _pAsyncWriteBuffer;
  343. BOOL _fIsOop;
  344. WAM_PROCESS * _pWamProcess;
  345. //
  346. // Temprary buffer to store copied over handles/buffers for OOP+async
  347. // vector send
  348. BUFFER _bufVectorElements;
  349. DWORD _nElementCount;
  350. //
  351. // ExecuteURL stuff
  352. //
  353. HANDLE _hExecUrlToken;
  354. PVOID _pbExecUrlEntity;
  355. //
  356. // Do we allow http.sys to cache the response for this ISAPI request
  357. //
  358. BOOL _fCacheResponse;
  359. };
  360. #endif // _ISAPI_REQUEST_HXX_