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.

402 lines
11 KiB

  1. /*++=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. om.h
  5. Abstract:
  6. Object declarations for object model components.
  7. Author:
  8. Paul M Midgen (pmidge) 13-October-2000
  9. Revision History:
  10. 13-October-2000 pmidge
  11. Created on Friday the 13th!!
  12. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--*/
  13. #ifndef __OM_H__
  14. #define __OM_H__
  15. #include "common.h"
  16. class CSession : public ISession,
  17. public IProvideClassInfo,
  18. public IActiveScriptSite
  19. {
  20. public:
  21. DECLAREIUNKNOWN();
  22. DECLAREIDISPATCH();
  23. DECLAREIPROVIDECLASSINFO();
  24. public:
  25. // ISession
  26. HRESULT __stdcall get_Socket(IDispatch** ppdisp);
  27. HRESULT __stdcall get_Request(IDispatch** ppdisp);
  28. HRESULT __stdcall get_Response(IDispatch** ppdisp);
  29. HRESULT __stdcall get_KeepAlive(VARIANT* IsKA);
  30. HRESULT __stdcall GetPropertyBag(VARIANT Name, IDispatch** ppdisp);
  31. // IActiveScriptSite
  32. HRESULT __stdcall GetLCID(LCID* plcid);
  33. HRESULT __stdcall GetItemInfo(
  34. LPCOLESTR pstrName,
  35. DWORD dwReturnMask,
  36. IUnknown** ppunk,
  37. ITypeInfo** ppti
  38. );
  39. HRESULT __stdcall GetDocVersionString(BSTR* pbstrVersion);
  40. HRESULT __stdcall OnScriptTerminate(const VARIANT* pvarResult, const EXCEPINFO* pei);
  41. HRESULT __stdcall OnStateChange(SCRIPTSTATE ss);
  42. HRESULT __stdcall OnScriptError(IActiveScriptError* piase);
  43. HRESULT __stdcall OnEnterScript(void);
  44. HRESULT __stdcall OnLeaveScript(void);
  45. // CSession
  46. CSession();
  47. ~CSession();
  48. HRESULT Run(PIOCTX pioc);
  49. HRESULT Terminate(void);
  50. static HRESULT Create(PIOCTX pioc, IW3Spoof* pw3s);
  51. private:
  52. HRESULT _Initialize(PIOCTX pioc, IW3Spoof* pw3s);
  53. HRESULT _InitScriptEngine(void);
  54. HRESULT _LoadScript(void);
  55. HRESULT _SetScriptSite(BOOL bClone);
  56. HRESULT _ResetScriptEngine(void);
  57. HRESULT _LoadScriptDispids(void);
  58. HRESULT _InitSocketObject(PIOCTX pioc);
  59. HRESULT _InitRequestObject(void);
  60. void _SetKeepAlive(PIOCTX pioc);
  61. void _SetObjectState(STATE state);
  62. BOOL _SetNextServerState(SERVERSTATE state);
  63. void _Lock(void);
  64. void _Unlock(void);
  65. LONG m_cRefs;
  66. LPWSTR m_wszClient;
  67. LPWSTR m_wszClientId;
  68. BOOL m_bIsKeepAlive;
  69. SCRIPTDISPID m_CurrentHandler;
  70. LCID m_lcid;
  71. PSOCKETOBJ m_socketobj;
  72. PREQUESTOBJ m_requestobj;
  73. PRESPONSEOBJ m_responseobj;
  74. ITypeLib* m_ptl;
  75. IW3Spoof* m_pw3s;
  76. IActiveScript* m_pas;
  77. IDispatch* m_psd;
  78. DISPID m_arHandlerDispids[SCRIPTHANDLERS];
  79. CRITSEC m_lock;
  80. STATE m_objstate;
  81. };
  82. class CSocket : public ISocket,
  83. public IProvideClassInfo,
  84. public IObjectWithSite
  85. {
  86. public:
  87. DECLAREIUNKNOWN();
  88. DECLAREIDISPATCH();
  89. DECLAREIPROVIDECLASSINFO();
  90. DECLAREIOBJECTWITHSITE();
  91. public:
  92. // ISocket
  93. HRESULT __stdcall Send(VARIANT Data);
  94. HRESULT __stdcall Recv(VARIANT *Data);
  95. HRESULT __stdcall Close(VARIANT Method);
  96. HRESULT __stdcall Resolve(BSTR Host, BSTR *Address);
  97. HRESULT __stdcall get_Parent(IDispatch** ppdisp);
  98. HRESULT __stdcall get_LocalName(BSTR *Name);
  99. HRESULT __stdcall get_LocalAddress(BSTR *Address);
  100. HRESULT __stdcall get_LocalPort(VARIANT *Port);
  101. HRESULT __stdcall get_RemoteName(BSTR *Name);
  102. HRESULT __stdcall get_RemoteAddress(BSTR *Address);
  103. HRESULT __stdcall get_RemotePort(VARIANT *Port);
  104. HRESULT __stdcall get_Option(BSTR Option, VARIANT *Value);
  105. HRESULT __stdcall put_Option(BSTR Option, VARIANT Value);
  106. // CSocket
  107. CSocket();
  108. ~CSocket();
  109. HRESULT Run(PIOCTX pioc);
  110. HRESULT Terminate(void);
  111. SERVERSTATE GetServerState(void);
  112. void SetServerState(SERVERSTATE ss);
  113. static HRESULT Create(PIOCTX pioc, PSOCKETOBJ* ppsocketobj);
  114. friend class CSession;
  115. protected:
  116. void GetSendBuffer(WSABUF** ppwb);
  117. void GetRecvBuffer(WSABUF** ppwb);
  118. DWORD GetBytesSent(void);
  119. DWORD GetBytesReceived(void);
  120. private:
  121. HRESULT _Initialize(PIOCTX pioc);
  122. void _SetObjectState(STATE state);
  123. BOOL _ResizeBuffer(PIOCTX pioc, DWORD len);
  124. HRESULT _Send(PIOCTX pioc);
  125. HRESULT _Recv(PIOCTX pioc);
  126. BOOL _Flush(void);
  127. HRESULT _TestWinsockError(void);
  128. LONG m_cRefs;
  129. SOCKET m_socket;
  130. PHOSTINFO m_local;
  131. PHOSTINFO m_remote;
  132. PIOCTX m_rcvd;
  133. PIOCTX m_sent;
  134. IUnknown* m_pSite;
  135. LPWSTR m_wszClientId;
  136. SERVERSTATE m_serverstate;
  137. STATE m_objstate;
  138. };
  139. class CRequest : public IRequest,
  140. public IProvideClassInfo,
  141. public IObjectWithSite
  142. {
  143. public:
  144. DECLAREIUNKNOWN();
  145. DECLAREIDISPATCH();
  146. DECLAREIPROVIDECLASSINFO();
  147. DECLAREIOBJECTWITHSITE();
  148. public:
  149. // IRequest
  150. HRESULT __stdcall get_Parent(IDispatch **ppdisp);
  151. HRESULT __stdcall get_Headers(IDispatch **ppdisp);
  152. HRESULT __stdcall get_Entity(IDispatch **ppdisp);
  153. HRESULT __stdcall get_Url(IDispatch **ppdisp);
  154. HRESULT __stdcall get_Verb(BSTR *Verb);
  155. HRESULT __stdcall get_HttpVersion(BSTR *HttpVersion);
  156. // CRequest
  157. CRequest();
  158. ~CRequest();
  159. void Terminate(void);
  160. static HRESULT Create(CHAR* request, DWORD len, PREQUESTOBJ* ppreq);
  161. private:
  162. HRESULT _Initialize(CHAR* request, DWORD len);
  163. void _Cleanup(void);
  164. HRESULT _SiteMemberObjects(void);
  165. BOOL _CrackRequest(LPSTR request, DWORD len, LPSTR* reqline, LPSTR* headers, LPSTR* entity, LPDWORD contentlength);
  166. LPSTR* _CrackRequestLine(CHAR* buf, DWORD len);
  167. LONG m_cRefs;
  168. IUnknown* m_pSite;
  169. LPWSTR m_wszVerb;
  170. LPWSTR m_wszHTTPVersion;
  171. PURLOBJ m_urlobj;
  172. PHEADERSOBJ m_headersobj;
  173. PENTITYOBJ m_entityobj;
  174. };
  175. class CResponse : public IResponse,
  176. public IProvideClassInfo,
  177. public IObjectWithSite
  178. {
  179. public:
  180. DECLAREIUNKNOWN();
  181. DECLAREIDISPATCH();
  182. DECLAREIPROVIDECLASSINFO();
  183. DECLAREIOBJECTWITHSITE();
  184. public:
  185. // IResponse
  186. HRESULT __stdcall get_Parent(IDispatch **ppdisp);
  187. HRESULT __stdcall get_Headers(IDispatch **ppdisp);
  188. HRESULT __stdcall putref_Headers(IDispatch **ppdisp);
  189. HRESULT __stdcall get_Entity(IDispatch **ppdisp);
  190. HRESULT __stdcall putref_Entity(IDispatch **ppdisp);
  191. HRESULT __stdcall get_StatusCode(VARIANT *Code);
  192. HRESULT __stdcall put_StatusCode(VARIANT StatusCode);
  193. HRESULT __stdcall get_StatusText(BSTR *StatusText);
  194. HRESULT __stdcall put_StatusText(BSTR StatusText);
  195. // CResponse
  196. CResponse();
  197. ~CResponse();
  198. HRESULT Terminate(void);
  199. static HRESULT Create(CHAR* response, DWORD len, PRESPONSEOBJ* ppresponse);
  200. private:
  201. HRESULT _Initialize(CHAR* response, DWORD len);
  202. LONG m_cRefs;
  203. IUnknown* m_pSite;
  204. PHEADERSOBJ m_headersobj;
  205. PENTITYOBJ m_entityobj;
  206. };
  207. class CUrl : public IUrl,
  208. public IProvideClassInfo,
  209. public IObjectWithSite
  210. {
  211. public:
  212. DECLAREIUNKNOWN();
  213. DECLAREIDISPATCH();
  214. DECLAREIPROVIDECLASSINFO();
  215. DECLAREIOBJECTWITHSITE();
  216. public:
  217. // IUrl
  218. HRESULT __stdcall get_Parent(IDispatch **ppdisp);
  219. HRESULT __stdcall get_Encoding(BSTR *Encoding);
  220. HRESULT __stdcall get_Scheme(BSTR *Scheme);
  221. HRESULT __stdcall put_Scheme(BSTR Scheme);
  222. HRESULT __stdcall get_Server(BSTR *Server);
  223. HRESULT __stdcall put_Server(BSTR Server);
  224. HRESULT __stdcall get_Port(VARIANT *Port);
  225. HRESULT __stdcall put_Port(VARIANT Port);
  226. HRESULT __stdcall get_Path(BSTR *Path);
  227. HRESULT __stdcall put_Path(BSTR Path);
  228. HRESULT __stdcall get_Resource(BSTR *Resource);
  229. HRESULT __stdcall put_Resource(BSTR Resource);
  230. HRESULT __stdcall get_Query(BSTR *Query);
  231. HRESULT __stdcall put_Query(BSTR Query);
  232. HRESULT __stdcall get_Fragment(BSTR *Fragment);
  233. HRESULT __stdcall put_Fragment(BSTR Fragment);
  234. HRESULT __stdcall Escape(BSTR *Url);
  235. HRESULT __stdcall Unescape(BSTR *Url);
  236. HRESULT __stdcall Set(BSTR Url);
  237. HRESULT __stdcall Get(BSTR *Url);
  238. // CUrl
  239. CUrl();
  240. ~CUrl();
  241. static HRESULT Create(CHAR* url, BOOL bReadOnly, PURLOBJ* ppurl);
  242. void Terminate(void);
  243. private:
  244. HRESULT _Initialize(CHAR* url, BOOL bReadOnly);
  245. void _Cleanup(void);
  246. LONG m_cRefs;
  247. IUnknown* m_pSite;
  248. ITypeInfo* m_pti;
  249. BOOL m_bReadOnly;
  250. BOOL m_bEscaped;
  251. LPSTR m_szOriginalUrl;
  252. LPSTR m_szUnescapedUrl;
  253. LPWSTR m_wszUrl;
  254. LPWSTR m_wszScheme;
  255. USHORT m_usPort;
  256. LPWSTR m_wszServer;
  257. LPWSTR m_wszPath;
  258. LPWSTR m_wszResource;
  259. LPWSTR m_wszQuery;
  260. LPWSTR m_wszFragment;
  261. };
  262. class CHeaders : public IHeaders,
  263. public IProvideClassInfo,
  264. public IObjectWithSite
  265. {
  266. public:
  267. DECLAREIUNKNOWN();
  268. DECLAREIDISPATCH();
  269. DECLAREIPROVIDECLASSINFO();
  270. DECLAREIOBJECTWITHSITE();
  271. public:
  272. // IHeaders
  273. HRESULT __stdcall get_Parent(IDispatch **ppdisp);
  274. HRESULT __stdcall Get(BSTR *Headers);
  275. HRESULT __stdcall Set(VARIANT *Headers);
  276. HRESULT __stdcall GetHeader(BSTR Header, VARIANT *Value);
  277. HRESULT __stdcall SetHeader(BSTR Header, VARIANT *Value);
  278. // CHeaders
  279. CHeaders();
  280. ~CHeaders();
  281. static HRESULT Create(CHAR* headers, BOOL bReadOnly, PHEADERSOBJ* ppheaders);
  282. void Terminate(void);
  283. private:
  284. HRESULT _Initialize(CHAR* headers, BOOL bReadOnly);
  285. HRESULT _ParseHeaders(CHAR* headers);
  286. void _Cleanup(void);
  287. LONG m_cRefs;
  288. IUnknown* m_pSite;
  289. ITypeInfo* m_pti;
  290. BOOL m_bReadOnly;
  291. CHAR* m_pchHeaders;
  292. PHEADERLIST m_headerlist;
  293. };
  294. class CEntity : public IEntity,
  295. public IProvideClassInfo,
  296. public IObjectWithSite
  297. {
  298. public:
  299. DECLAREIUNKNOWN();
  300. DECLAREIDISPATCH();
  301. DECLAREIPROVIDECLASSINFO();
  302. DECLAREIOBJECTWITHSITE();
  303. public:
  304. // IEntity
  305. HRESULT __stdcall get_Parent(IDispatch **ppdisp);
  306. HRESULT __stdcall get_Length(VARIANT *Length);
  307. HRESULT __stdcall Get(VARIANT *Entity);
  308. HRESULT __stdcall Set(VARIANT Entity);
  309. HRESULT __stdcall Compress(BSTR Method);
  310. HRESULT __stdcall Decompress(VARIANT Method);
  311. // CEntity
  312. CEntity();
  313. ~CEntity();
  314. static HRESULT Create(LPBYTE data, DWORD length, BOOL bReadOnly, PENTITYOBJ* ppentity);
  315. void Terminate(void);
  316. private:
  317. HRESULT _Initialize(LPBYTE data, DWORD length, BOOL bReadOnly);
  318. void _Cleanup(void);
  319. LONG m_cRefs;
  320. IUnknown* m_pSite;
  321. ITypeInfo* m_pti;
  322. BOOL m_bReadOnly;
  323. LPBYTE m_pbData;
  324. DWORD m_cData;
  325. };
  326. #endif /* __OM_H__ */