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.

381 lines
12 KiB

  1. /*===================================================================
  2. Microsoft Denali
  3. Microsoft Confidential.
  4. Copyright 1996 Microsoft Corporation. All Rights Reserved.
  5. Component: CIsapiReqInfo Object
  6. File: IsapiReq.h
  7. Owner: AndyMorr
  8. ===================================================================*/
  9. #ifndef ISAPIREQ_H
  10. #define ISAPIREQ_H
  11. #include <iadmw.h>
  12. #include <string.hxx>
  13. #include "memcls.h"
  14. #include "dbllink.h"
  15. /*
  16. Mappings of CIsapiReqInfo methods to the proper routines based
  17. on the UNICODE setting
  18. */
  19. #ifdef UNICODE
  20. #define QueryPszPathInfo QueryPszPathInfoW
  21. #define QueryCchPathInfo QueryCchPathInfoW
  22. #define QueryPszPathTranslated QueryPszPathTranslatedW
  23. #define QueryCchPathTranslated QueryCchPathTranslatedW
  24. #define QueryPszApplnMDPath QueryPszApplnMDPathW
  25. #define QueryCchApplnMDPath QueryCchApplnMDPathW
  26. #define MapUrlToPath MapUrlToPathW
  27. #define GetCustomError GetCustomErrorW
  28. #define GetAspMDData GetAspMDDataW
  29. #define GetAspMDAllData GetAspMDAllDataW
  30. #define GetServerVariable GetServerVariableW
  31. #define GetVirtualPathToken GetVirtualPathTokenW
  32. #else
  33. #define QueryPszPathInfo QueryPszPathInfoA
  34. #define QueryCchPathInfo QueryCchPathInfoA
  35. #define QueryPszPathTranslated QueryPszPathTranslatedA
  36. #define QueryCchPathTranslated QueryCchPathTranslatedA
  37. #define QueryPszApplnMDPath QueryPszApplnMDPathA
  38. #define QueryCchApplnMDPath QueryCchApplnMDPathA
  39. #define MapUrlToPath MapUrlToPathA
  40. #define GetCustomError GetCustomErrorA
  41. #define GetAspMDData GetAspMDDataA
  42. #define GetAspMDAllData GetAspMDAllDataA
  43. #define GetServerVariable GetServerVariableA
  44. #define GetVirtualPathToken GetVirtualPathTokenA
  45. #endif
  46. // this structure helps passing the vectors of WSABUF without reallocating
  47. // continuous memory
  48. typedef struct
  49. {
  50. LPWSABUF pVector1;
  51. LPWSABUF pVector2;
  52. DWORD dwVectorLen1;
  53. DWORD dwVectorLen2;
  54. } WSABUF_VECTORS, *LPWSABUF_VECTORS;
  55. class CIsapiReqInfo;
  56. class CAsyncVectorSendCB;
  57. typedef VOID (*PFN_CLIENT_IO_COMPLETION)( CIsapiReqInfo *pReqInfo,
  58. PVOID pContext,
  59. DWORD cbIO,
  60. DWORD dwError);
  61. /*===================================================================
  62. C I s a p i R e q I n f o
  63. Class which encapsulates Request info we need from the ISAPI interface.
  64. Information either comes from the public ISAPI interfaces (SSE and
  65. ServerVariables) or from the private WAM_EXEC_INFO.
  66. ===================================================================*/
  67. class CIsapiReqInfo {
  68. private:
  69. LONG m_cRefs;
  70. EXTENSION_CONTROL_BLOCK *m_pECB;
  71. int m_cchQueryString;
  72. int m_cchApplnMDPathA;
  73. int m_cchPathTranslatedA;
  74. int m_cchPathInfoA;
  75. int m_cchApplnMDPathW;
  76. int m_cchPathTranslatedW;
  77. int m_cchPathInfoW;
  78. int m_cchAppPoolIdA;
  79. int m_cchAppPoolIdW;
  80. DWORD m_fApplnMDPathAInited : 1;
  81. DWORD m_fApplnMDPathWInited : 1;
  82. DWORD m_fAppPoolIdAInited : 1;
  83. DWORD m_fAppPoolIdWInited : 1;
  84. DWORD m_fPathInfoWInited : 1;
  85. DWORD m_fPathTranslatedWInited : 1;
  86. DWORD m_fCookieInited : 1;
  87. DWORD m_fUserAgentInited : 1;
  88. DWORD m_fInstanceIDInited : 1;
  89. DWORD m_fVersionInited : 1;
  90. DWORD m_fFKeepConnInited : 1;
  91. DWORD m_fPendSendCSInited : 1;
  92. DWORD m_fIOCompletionRegistered: 1;
  93. DWORD m_fHeadersWritten : 1;
  94. DWORD m_dwInstanceID;
  95. DWORD m_dwVersionMajor;
  96. DWORD m_dwVersionMinor;
  97. BOOL m_fKeepConn;
  98. BUFFER m_ApplnMDPathA;
  99. BUFFER m_ApplnMDPathW;
  100. BUFFER m_AppPoolIdA;
  101. BUFFER m_AppPoolIdW;
  102. BUFFER m_PathInfoW;
  103. BUFFER m_PathTranslatedW;
  104. BUFFER m_Cookie;
  105. BUFFER m_UserAgent;
  106. DWORD m_dwRequestStatus;
  107. DWORD m_dwAsyncError;
  108. CRITICAL_SECTION m_csPendingSendCS;
  109. CDblLink m_listPendingSends;
  110. IMSAdminBase *m_pIAdminBase;
  111. public:
  112. CIsapiReqInfo(EXTENSION_CONTROL_BLOCK *pECB);
  113. ~CIsapiReqInfo();
  114. LONG AddRef() {
  115. LONG cRefs = InterlockedIncrement(&m_cRefs);
  116. return cRefs;
  117. }
  118. LONG Release() {
  119. LONG cRefs = InterlockedDecrement(&m_cRefs);
  120. if (cRefs == 0) {
  121. delete this;
  122. }
  123. return cRefs;
  124. }
  125. BOOL FHeadersWritten() { return m_fHeadersWritten; }
  126. EXTENSION_CONTROL_BLOCK *ECB() { return m_pECB; }
  127. LPSTR QueryPszQueryString();
  128. DWORD QueryCchQueryString();
  129. LPSTR QueryPszApplnMDPathA();
  130. DWORD QueryCchApplnMDPathA();
  131. LPWSTR QueryPszApplnMDPathW();
  132. DWORD QueryCchApplnMDPathW();
  133. LPSTR QueryPszAppPoolIdA();
  134. DWORD QueryCchAppPoolIdA();
  135. LPWSTR QueryPszAppPoolIdW();
  136. DWORD QueryCchAppPoolIdW();
  137. LPSTR QueryPszPathInfoA();
  138. DWORD QueryCchPathInfoA();
  139. LPWSTR QueryPszPathInfoW();
  140. DWORD QueryCchPathInfoW();
  141. LPSTR QueryPszPathTranslatedA();
  142. DWORD QueryCchPathTranslatedA();
  143. LPWSTR QueryPszPathTranslatedW();
  144. DWORD QueryCchPathTranslatedW();
  145. LPSTR QueryPszCookie();
  146. VOID SetDwHttpStatusCode( DWORD dwStatus );
  147. LPBYTE QueryPbData();
  148. DWORD QueryCbAvailable();
  149. DWORD QueryCbTotalBytes();
  150. LPSTR QueryPszContentType();
  151. LPSTR QueryPszMethod();
  152. LPSTR QueryPszUserAgent();
  153. DWORD QueryInstanceId();
  154. BOOL IsChild();
  155. BOOL FInPool();
  156. BOOL FKeepConn();
  157. DWORD QueryHttpVersionMajor();
  158. DWORD QueryHttpVersionMinor();
  159. HRESULT GetAspMDDataA(CHAR * pszMDPath,
  160. DWORD dwMDIdentifier,
  161. DWORD dwMDAttributes,
  162. DWORD dwMDUserType,
  163. DWORD dwMDDataType,
  164. DWORD dwMDDataLen,
  165. DWORD dwMDDataTag,
  166. unsigned char * pbMDData,
  167. DWORD * pdwRequiredBufferSize);
  168. HRESULT GetAspMDDataW(WCHAR * pszMDPath,
  169. DWORD dwMDIdentifier,
  170. DWORD dwMDAttributes,
  171. DWORD dwMDUserType,
  172. DWORD dwMDDataType,
  173. DWORD dwMDDataLen,
  174. DWORD dwMDDataTag,
  175. unsigned char * pbMDData,
  176. DWORD * pdwRequiredBufferSize);
  177. HRESULT GetAspMDAllDataA(CHAR * pszMDPath,
  178. DWORD dwMDUserType,
  179. DWORD dwDefaultBufferSize,
  180. LPVOID pvBuffer,
  181. DWORD * pdwRequiredBufferSize,
  182. DWORD * pdwNumDataEntries);
  183. HRESULT GetAspMDAllDataW(WCHAR * pszMDPath,
  184. DWORD dwMDUserType,
  185. DWORD dwDefaultBufferSize,
  186. LPVOID pvBuffer,
  187. DWORD * pdwRequiredBufferSize,
  188. DWORD * pdwNumDataEntries);
  189. BOOL GetCustomErrorA(DWORD dwError,
  190. DWORD dwSubError,
  191. DWORD dwBufferSize,
  192. CHAR *pvBuffer,
  193. DWORD *pdwRequiredBufferSize,
  194. BOOL *pfIsFileError,
  195. BOOL *pfSendErrorBody = NULL);
  196. BOOL GetCustomErrorW(DWORD dwError,
  197. DWORD dwSubError,
  198. DWORD dwBufferSize,
  199. WCHAR *pvBuffer,
  200. DWORD *pdwRequiredBufferSize,
  201. BOOL *pfIsFileError,
  202. BOOL *pfSendErrorBody = NULL);
  203. HANDLE QueryImpersonationToken();
  204. HRESULT AppendLogParameter( LPSTR szExtraParam );
  205. BOOL SendHeader(LPVOID pvStatus,
  206. DWORD cchStatus,
  207. LPVOID pvHeader,
  208. DWORD cchHeader,
  209. BOOL fIsaKeepConn);
  210. BOOL GetServerVariableA(LPSTR szVarName,
  211. LPSTR pBuffer,
  212. LPDWORD pdwSize );
  213. BOOL GetServerVariableW(LPSTR szVarName,
  214. LPWSTR pBuffer,
  215. LPDWORD pdwSize);
  216. HRESULT GetVirtualPathTokenA(LPCSTR szPath,
  217. HANDLE *hToken);
  218. HRESULT GetVirtualPathTokenW(LPCWSTR szPath,
  219. HANDLE *hToken);
  220. BOOL ServerSupportFunction(DWORD dwHSERequest,
  221. LPVOID pvData,
  222. LPDWORD pdwSize,
  223. LPDWORD pdwDataType);
  224. BOOL SendClientResponse(PFN_CLIENT_IO_COMPLETION pComplFunc,
  225. VOID *pComplArg,
  226. LPHSE_SEND_ENTIRE_RESPONSE_INFO pHseResponseInfo,
  227. LPWSABUF_VECTORS pResponseVectors = NULL);
  228. BOOL TestConnection(BOOL *pfIsConnected);
  229. BOOL MapUrlToPathA(LPSTR pBuffer, LPDWORD pdwBytes);
  230. BOOL MapUrlToPathW(LPWSTR pBuffer, LPDWORD pdwBytes);
  231. BOOL SyncReadClient(LPVOID pvBuffer, LPDWORD pdwBytes );
  232. BOOL SyncWriteClient(LPVOID pvBuffer, LPDWORD pdwBytes);
  233. VOID SetRequestStatus(DWORD dwRequestStatus) { m_dwRequestStatus = dwRequestStatus; }
  234. DWORD GetRequestStatus() { return m_dwRequestStatus; }
  235. HRESULT AddToPendingList(CAsyncVectorSendCB *pVectorCB);
  236. void IssueNextSend();
  237. static WINAPI AsyncCompletion(EXTENSION_CONTROL_BLOCK * pECB,
  238. PVOID pContext,
  239. DWORD cbIO,
  240. DWORD dwError);
  241. private:
  242. void InitVersionInfo();
  243. IMSAdminBase *GetMetabaseIF (HRESULT *pHr);
  244. BOOL InternalGetServerVariable(LPSTR pszVar, BUFFER *pBuffer);
  245. // Cache on per-class basis
  246. ACACHE_INCLASS_DEFINITIONS()
  247. };
  248. /*===================================================================
  249. C A s y n c V e c t o r S e n d C B
  250. Class used internally by SendClientResponse to handle async calls
  251. with VectorSend.
  252. ===================================================================*/
  253. class CAsyncVectorSendCB : public CDblLink
  254. {
  255. public:
  256. CAsyncVectorSendCB();
  257. CAsyncVectorSendCB(CIsapiReqInfo *pIReq,
  258. void *pContext,
  259. PFN_CLIENT_IO_COMPLETION pFunc);
  260. ~CAsyncVectorSendCB();
  261. HRESULT SetElementCount(DWORD nElements);
  262. CIsapiReqInfo *m_pIReq;
  263. HSE_RESPONSE_VECTOR m_hseResponseVector;
  264. void *m_pCallerContext;
  265. PFN_CLIENT_IO_COMPLETION m_pCallerFunc;
  266. HSE_VECTOR_ELEMENT *m_pVectorElements;
  267. HSE_VECTOR_ELEMENT m_aVectorElements[16];
  268. // Cache on per-class basis
  269. ACACHE_INCLASS_DEFINITIONS()
  270. };
  271. #endif