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.

608 lines
14 KiB

  1. /*++
  2. Copyright (c) 1995-1997 Microsoft Corporation
  3. Module Name :
  4. wamreq.hxx
  5. Abstract:
  6. This module implements the WAM_REQUEST object
  7. Author:
  8. David Kaplan ( DaveK ) 26-Feb-1997
  9. Environment:
  10. User Mode - Win32
  11. Project:
  12. W3 services DLL
  13. --*/
  14. #ifndef _WAMREQ_HXX_
  15. #define _WAMREQ_HXX_
  16. #include "string.hxx"
  17. #include "WamW3.hxx"
  18. #include "acache.hxx"
  19. #include <reftrace.h>
  20. #include "ftm.h"
  21. // MIDL-generated include files
  22. #include "iwr.h"
  23. #include "wam.h"
  24. #include <svmap.h>
  25. /************************************************************
  26. * Forward declarations
  27. ************************************************************/
  28. class WAM_EXEC_INFO;
  29. class W3_SERVER_STATISTICS;
  30. class HTTP_REQUEST;
  31. struct EXEC_DESCRIPTOR;
  32. class HTTP_FILTER;
  33. class CLIENT_CONN;
  34. class W3_SERVER_INSTANCE;
  35. interface IWam;
  36. struct ASYNC_IO_INFO;
  37. struct WAM_REQ_CORE_FIXED;
  38. class CWamInfo;
  39. // displays "WREQ" in debug
  40. # define WAM_REQUEST_SIGNATURE (DWORD )'QERW'
  41. // displays "WREf" in debug
  42. # define WAM_REQUEST_SIGNATURE_FREE (DWORD )'fERW'
  43. //
  44. // Ref count trace log sizes for per-request log and global log
  45. // (used for debugging ref count problems)
  46. //
  47. #define C_REFTRACES_PER_REQUEST 16
  48. #define C_REFTRACES_GLOBAL 1024
  49. /*-----------------------------------------------------------------------------*
  50. class WAM_REQUEST
  51. Class definition for the WAM_REQUEST object.
  52. */
  53. //class WAM_REQUEST : public IWamRequest, public CFTMImplementation
  54. class WAM_REQUEST : public IWamRequest
  55. {
  56. public:
  57. LIST_ENTRY m_leOOP; // List list field of this request
  58. /*-------------------------------------------------------------------------*
  59. * WAM_REQUEST allocation cache
  60. *
  61. *
  62. */
  63. public:
  64. static void * operator new (size_t s);
  65. static void operator delete(void * psi);
  66. static BOOL InitClass( VOID);
  67. static VOID CleanupClass( VOID);
  68. private:
  69. static ALLOC_CACHE_HANDLER * sm_pachWamRequest;
  70. #if DBG
  71. static PTRACE_LOG sm_pDbgRefTraceLog;
  72. #endif
  73. /*-------------------------------------------------------------------------*
  74. * Member variables
  75. *
  76. *
  77. */
  78. private:
  79. DWORD m_dwSignature;
  80. HTTP_REQUEST * m_pHttpRequest; // ptr to original http request
  81. EXEC_DESCRIPTOR * m_pExec; // ptr to exec descriptor of original http request
  82. long m_cRefs; // ref count
  83. DWORD m_dwRequestID; // unique ID for performance work
  84. static DWORD sm_dwRequestID; // class static last generated ID
  85. CWamInfo * m_pWamInfo; // ptr to wam-info which will process request
  86. DWORD m_dwWamVersion; // wam-info version stamp at the time this wamreq was initialized
  87. void * m_pWamExecInfo; // ptr to WAM_EXEC_INFO in wam.dll bound to this wam request
  88. // NOTE this is really a WAM_EXEC_INFO * but void * is better
  89. // because wamreq knows nothing about WAM_EXEC_INFO
  90. HANDLE m_hFileTfi; // file handle for TransmitFile ops
  91. BOOL m_fFinishWamRequest;// call FinishWamRequest() before we exit?
  92. BOOL m_fWriteHeaders; // should SendHeaders write headers to client (TRUE)
  93. // or only to our internal buffer (FALSE)
  94. IUnknown * m_pUnkFTM; // Free Threaded Marshaller pointer
  95. BYTE * m_pAsyncReadBuffer; // copy of async read buffer ptr
  96. DWORD m_dwAsyncReadBufferSize; // async read buffer size
  97. LPBYTE m_pbAsyncReadOopBuffer;
  98. BOOL m_fAsyncWrite; // TRUE means it was WRITE operation,
  99. // FALSE means it was READ operation
  100. STR m_strPathTrans; // path-translated
  101. STR m_strISADllPath; // ISA dll which will process request
  102. STR m_strUserAgent; // cached User-Agent: header
  103. STR m_strCookie; // cached Cookie: header
  104. STR m_strExpires; // cached Expires: header
  105. UCHAR * m_pszStatusTfi; // Status string for TransmitFile
  106. UCHAR * m_pszTailTfi; // Tail string for TransmitFile
  107. UCHAR * m_pszHeadTfi; // Head string for TransmitFile
  108. BOOL m_fExpectCleanup;
  109. BOOL m_fPrepCleanupCalled;
  110. BOOL m_fCleanupCalled;
  111. public:
  112. DWORD
  113. CbCachedSVStrings(
  114. IN SV_CACHE_LIST::BUFFER_ITEM * pCacheItems,
  115. IN DWORD cItems
  116. );
  117. HRESULT
  118. GetCachedSVStrings(
  119. IN OUT unsigned char * pbServerVariables,
  120. IN DWORD cchAvailable,
  121. IN SV_CACHE_LIST::BUFFER_ITEM * pCacheItems,
  122. IN DWORD cCacheItems
  123. );
  124. /*-------------------------------------------------------------------------*
  125. * Non-exported methods
  126. *
  127. *
  128. */
  129. public:
  130. WAM_REQUEST(
  131. HTTP_REQUEST * pHttpRequest
  132. , EXEC_DESCRIPTOR * pExec
  133. , CWamInfo * pWamInfo
  134. );
  135. ~WAM_REQUEST();
  136. HRESULT
  137. InitWamRequest(
  138. const STR * pstrPath
  139. );
  140. VOID
  141. BindHttpRequest(
  142. );
  143. VOID
  144. UnbindBeforeFinish(
  145. );
  146. VOID
  147. UnbindAfterFinish(
  148. );
  149. VOID
  150. WAM_REQUEST::FinishWamRequest(
  151. );
  152. inline VOID SetWamVersion( DWORD dwWamVersion )
  153. { m_dwWamVersion = dwWamVersion; }
  154. inline DWORD GetWamVersion() { return m_dwWamVersion; }
  155. BOOL IsChild( VOID ) const;
  156. PW3_METADATA QueryExecMetaData( VOID ) const;
  157. BOOL SetPathTrans( );
  158. DWORD CbWrcStrings( BOOL fInProcess );
  159. HRESULT
  160. ProcessAsyncGatewayIO( DWORD dwStatus,
  161. DWORD cbWritten );
  162. VOID
  163. SetDeniedFlags( DWORD dw);
  164. HRESULT
  165. SendEntireResponseFast(
  166. HSE_SEND_ENTIRE_RESPONSE_INFO * pHseResponseInfo
  167. );
  168. HRESULT
  169. SendEntireResponseNormal(
  170. HSE_SEND_ENTIRE_RESPONSE_INFO * pHseResponseInfo
  171. );
  172. BOOL
  173. WriteLogInfo(
  174. CHAR * szLogMessage
  175. , DWORD dwLogHttpResponse
  176. , DWORD dwLogWinError
  177. );
  178. VOID
  179. DisconnectOnServerError(
  180. DWORD dwHTHeader
  181. , DWORD dwError
  182. );
  183. LONG
  184. InterlockedNonZeroAddRef(
  185. VOID
  186. );
  187. VOID
  188. SetExpectCleanup( BOOL fExpectCleanup )
  189. {
  190. m_fExpectCleanup = fExpectCleanup;
  191. }
  192. BOOL
  193. QueryExpectCleanup( VOID )
  194. {
  195. return m_fExpectCleanup;
  196. }
  197. BOOL
  198. DoCleanupOnDestroy( VOID )
  199. {
  200. return ( m_fCleanupCalled || ( m_fExpectCleanup && !m_fPrepCleanupCalled ) );
  201. }
  202. /*-------------------------------------------------------------------------*
  203. * IWamRequest interface methods
  204. *
  205. *
  206. */
  207. public:
  208. virtual HRESULT STDMETHODCALLTYPE QueryInterface(
  209. REFIID riid,
  210. void __RPC_FAR *__RPC_FAR *ppvObject);
  211. virtual ULONG STDMETHODCALLTYPE AddRef( void);
  212. virtual ULONG STDMETHODCALLTYPE Release( void);
  213. STDMETHODIMP
  214. PrepCleanupWamRequest(
  215. unsigned char * szLogData
  216. , DWORD cbLogData
  217. , DWORD dwHttpStatusCode
  218. , DWORD dwIsaKeepConn
  219. );
  220. STDMETHODIMP
  221. CleanupWamRequest(
  222. unsigned char * szLogData
  223. , DWORD cbLogData
  224. , DWORD dwHttpStatusCode
  225. , DWORD dwIsaKeepConn
  226. );
  227. STDMETHODIMP
  228. GetCoreState
  229. (
  230. DWORD cbWrcData,
  231. unsigned char * pbWrcData,
  232. DWORD cbWRCF,
  233. unsigned char * pbWRCF
  234. );
  235. STDMETHODIMP
  236. QueryEntityBody
  237. (
  238. unsigned char ** ppbEntityBody
  239. );
  240. STDMETHODIMP
  241. SetKeepConn
  242. (
  243. int fKeepConn
  244. );
  245. STDMETHODIMP
  246. IsKeepConnSet
  247. (
  248. BOOL * pfKeepConn
  249. );
  250. STDMETHODIMP
  251. GetInfoForName
  252. (
  253. const unsigned char * szVarName,
  254. unsigned char * pchBuffer,
  255. DWORD cchBuffer,
  256. DWORD * pcchRequired
  257. );
  258. STDMETHODIMP
  259. AppendLogParameter
  260. (
  261. unsigned char * pszParam
  262. );
  263. STDMETHODIMP
  264. LookupVirtualRoot
  265. (
  266. unsigned char * pchBuffer,
  267. DWORD cchBuffer,
  268. DWORD * pcchRequired
  269. );
  270. STDMETHODIMP
  271. LookupVirtualRootEx
  272. (
  273. unsigned char * szURL,
  274. unsigned char * pchBuffer,
  275. DWORD cchBuffer,
  276. DWORD * pcchRequired,
  277. DWORD * pcchMatchingPath,
  278. DWORD * pcchMatchingURL,
  279. DWORD * pdwFlags
  280. );
  281. STDMETHODIMP
  282. GetVirtualPathToken
  283. (
  284. IN unsigned char * szURL,
  285. #ifdef _WIN64
  286. OUT UINT64 * phToken
  287. #else
  288. OUT ULONG_PTR * phToken
  289. #endif
  290. );
  291. STDMETHODIMP
  292. GetPrivatePtr
  293. (
  294. DWORD dwHSERequest,
  295. unsigned char ** ppData
  296. );
  297. // Support functions for ISA callbacks
  298. STDMETHODIMP
  299. AsyncReadClientExt(
  300. #ifdef _WIN64
  301. IN UINT64 pWamExecInfo
  302. #else
  303. IN ULONG_PTR pWamExecInfo
  304. #endif
  305. , OUT unsigned char * lpBuffer
  306. , IN DWORD nBytesToRead
  307. );
  308. STDMETHODIMP
  309. AsyncReadClientOop(
  310. #ifdef _WIN64
  311. IN UINT64 pWamExecInfo
  312. #else
  313. IN ULONG_PTR pWamExecInfo
  314. #endif
  315. , IN DWORD nBytesToRead
  316. );
  317. STDMETHODIMP
  318. AsyncWriteClient
  319. (
  320. #ifdef _WIN64
  321. IN UINT64 pWamExecInfo, // WAM_EXEC_INFO *
  322. #else
  323. IN ULONG_PTR pWamExecInfo, // WAM_EXEC_INFO *
  324. #endif
  325. IN unsigned char * lpBuffer,
  326. IN DWORD nBytesToWrite,
  327. IN DWORD dwFlags
  328. );
  329. STDMETHODIMP
  330. SyncReadClient
  331. (
  332. unsigned char * lpBuffer, // LPVOID lpBuffer,
  333. DWORD nBytesToRead,
  334. DWORD * pnBytesRead
  335. );
  336. STDMETHODIMP
  337. SyncWriteClient
  338. (
  339. DWORD nBytesToWrite,
  340. unsigned char * lpBuffer, // LPVOID lpBuffer,
  341. DWORD * pnBytesWritten,
  342. DWORD dwFlags
  343. );
  344. STDMETHODIMP
  345. TransmitFileInProc(
  346. #ifdef _WIN64
  347. IN UINT64 pWamExecInfo
  348. #else
  349. IN ULONG_PTR pWamExecInfo
  350. #endif
  351. , IN unsigned char * pHseTfIn
  352. );
  353. STDMETHODIMP
  354. TransmitFileOutProc(
  355. #ifdef _WIN64
  356. IN UINT64 pWamExecInfo
  357. , IN UINT64 hFile
  358. #else
  359. IN ULONG_PTR pWamExecInfo
  360. , IN ULONG_PTR hFile
  361. #endif
  362. , IN unsigned char * pszStatusCode
  363. , IN DWORD cbStatusCode
  364. , IN DWORD BytesToWrite
  365. , IN DWORD Offset
  366. , IN unsigned char * pHead
  367. , IN DWORD HeadLength
  368. , IN unsigned char * pTail
  369. , IN DWORD TailLength
  370. , IN DWORD dwFlags
  371. );
  372. STDMETHODIMP
  373. SendHeader(
  374. IN unsigned char * szStatus
  375. , IN DWORD cchStatus
  376. , IN unsigned char * szHeader
  377. , IN DWORD cchHeader
  378. , IN DWORD dwIsaKeepConn
  379. );
  380. STDMETHODIMP
  381. SendEntireResponse(
  382. unsigned char * pvHseResponseInfo
  383. );
  384. STDMETHODIMP
  385. SendEntireResponseAndCleanup(
  386. IN unsigned char * szStatus
  387. , IN DWORD cbStatus
  388. , IN unsigned char * szHeader
  389. , IN DWORD cbHeader
  390. , IN OOP_RESPONSE_INFO * pOopResponseInfo
  391. , IN unsigned char * szLogData
  392. , IN DWORD cbLogData
  393. , IN DWORD dwIsaKeepConn
  394. , OUT BOOL * pfDisconnected
  395. );
  396. STDMETHODIMP
  397. SendURLRedirectResponse
  398. (
  399. unsigned char * pData
  400. );
  401. STDMETHODIMP
  402. SendRedirectMessage
  403. (
  404. unsigned char * szRedirect // LPCSTR pszRedirect
  405. );
  406. STDMETHODIMP
  407. GetSslCtxt
  408. (
  409. DWORD cbCtxtHandle,
  410. unsigned char * pbCtxtHandle // PBYTE pbCtxtHandle
  411. );
  412. STDMETHODIMP
  413. GetClientCertInfoEx
  414. (
  415. IN DWORD cbAllocated,
  416. OUT DWORD * pdwCertEncodingType,
  417. OUT unsigned char * pbCertEncoded,
  418. OUT DWORD * pcbCertEncoded,
  419. OUT DWORD * pdwCertificateFlags
  420. );
  421. STDMETHODIMP
  422. GetSspiInfo
  423. (
  424. DWORD cbCtxtHandle,
  425. unsigned char * pbCtxtHandle, // PBYTE pbCtxtHandle
  426. DWORD cbCredHandle,
  427. unsigned char * pbCredHandle // PBYTE pbCredHandle
  428. );
  429. STDMETHODIMP
  430. RequestAbortiveClose( VOID );
  431. STDMETHODIMP
  432. CloseConnection( VOID );
  433. STDMETHODIMP
  434. SSIncExec
  435. (
  436. unsigned char *szCommand,
  437. DWORD dwExecType,
  438. unsigned char *szVerb
  439. );
  440. STDMETHODIMP
  441. GetAspMDData(
  442. IN unsigned char * pszMDPath
  443. , IN DWORD dwMDIdentifier
  444. , IN DWORD dwMDAttributes
  445. , IN DWORD dwMDUserType
  446. , IN DWORD dwMDDataType
  447. , IN DWORD dwMDDataLen
  448. , IN DWORD dwMDDataTag
  449. , OUT unsigned char * pbMDData
  450. , OUT DWORD * pdwRequiredBufferSize
  451. );
  452. STDMETHODIMP
  453. GetAspMDAllData(
  454. IN unsigned char * pszMDPath
  455. , IN DWORD dwMDUserType
  456. , IN DWORD dwDefaultBufferSize
  457. , OUT unsigned char * pBuffer
  458. , OUT DWORD * pdwRequiredBufferSize
  459. , OUT DWORD * pdwNumDataEntries
  460. );
  461. STDMETHODIMP
  462. GetCustomError(
  463. DWORD dwError,
  464. DWORD dwSubError,
  465. DWORD dwBufferSize,
  466. unsigned char *pbBuffer,
  467. DWORD *pdwRequiredBufferSize,
  468. BOOL *pfIsFileError
  469. );
  470. STDMETHODIMP
  471. TestConnection(
  472. BOOL *pfIsConnected
  473. );
  474. STDMETHODIMP
  475. ExtensionTrigger(
  476. unsigned char * pvContext,
  477. DWORD dwTriggerType
  478. );
  479. STDMETHODIMP
  480. LogEvent(
  481. DWORD dwEventId,
  482. unsigned char * szText
  483. );
  484. // UNDONE remove
  485. STDMETHOD( DbgRefCount ) ( void )
  486. #if DBG
  487. { return m_cRefs; }
  488. #else
  489. { return NOERROR; }
  490. #endif // DBG
  491. }; // class WAM_REQUEST
  492. #endif // _WAMREQ_HXX_
  493. /************************ End of File ***********************/