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.

121 lines
3.1 KiB

  1. /*--
  2. Copyright (c) 1995-1998 Microsoft Corporation
  3. Module Name: ISAPI.H
  4. Author: Arul Menezes
  5. Abstract: ISAPI Exten & Filter handling classes
  6. --*/
  7. typedef enum
  8. {
  9. SCRIPT_TYPE_NONE = 0,
  10. SCRIPT_TYPE_EXTENSION,
  11. SCRIPT_TYPE_ASP,
  12. SCRIPT_TYPE_FILTER
  13. }
  14. SCRIPT_TYPE;
  15. typedef DWORD (WINAPI *PFN_HTTPFILTERPROC)(HTTP_FILTER_CONTEXT* pfc, DWORD NotificationType, VOID* pvNotification);
  16. typedef BOOL (WINAPI *PFN_GETFILTERVERSION)(HTTP_FILTER_VERSION* pVer);
  17. typedef BOOL (WINAPI *PFN_TERMINATEFILTER)(DWORD dwFlags);
  18. typedef void (WINAPI *PFN_TERMINATEASP)();
  19. typedef DWORD (WINAPI *PFN_EXECUTEASP)(PASP_CONTROL_BLOCK pASPBlock);
  20. class CISAPICache;
  21. BOOL InitExtensions(CISAPICache **ppISAPICache, DWORD *pdwCacheSleep);
  22. int RecvToBuf(SOCKET socket,PVOID pv, DWORD dw,DWORD dwTimeout=RECVTIMEOUT);
  23. class CISAPI
  24. {
  25. friend CISAPICache;
  26. // ISAPI extension & filter handling data members
  27. SCRIPT_TYPE m_scriptType; // Extension, Filter, or ASP?
  28. HINSTANCE m_hinst;
  29. FARPROC m_pfnGetVersion;
  30. FARPROC m_pfnHttpProc;
  31. FARPROC m_pfnTerminate;
  32. DWORD dwFilterFlags; // Flags negotiated on GetFilterVersion
  33. // Used by the caching class
  34. PWSTR m_wszDLLName; // full path of ISAPI Dll
  35. DWORD m_cRef; // Reference Count
  36. __int64 m_ftLastUsed; // Last used, treat as FILETIME struct
  37. public:
  38. CISAPI(SCRIPT_TYPE st)
  39. {
  40. ZEROMEM(this);
  41. m_scriptType = st;
  42. }
  43. ~CISAPI() { MyFree(m_wszDLLName); }
  44. void Unload(PWSTR wszDLLName=NULL);
  45. BOOL Load(PWSTR wszPath);
  46. void CoFreeUnusedLibrariesIfASP()
  47. {
  48. if (m_scriptType == SCRIPT_TYPE_ASP)
  49. {
  50. // calls into ASP exported function, which calls CoFreeUnusedLibraries
  51. // but does nothing else. We don't call CoFreeUnusedLibraries from the web
  52. // server directly because we don't want to have to link it to COM.
  53. // Does not free asp.dll, because we have a reference to it in the server.
  54. ((PFN_TERMINATEASP)m_pfnTerminate)();
  55. }
  56. }
  57. DWORD CallExtension(EXTENSION_CONTROL_BLOCK * pECB) { return ((PFN_HTTPEXTENSIONPROC)m_pfnHttpProc)(pECB); }
  58. DWORD CallFilter(HTTP_FILTER_CONTEXT* pfc, DWORD n, VOID* pv) { return ((PFN_HTTPFILTERPROC)m_pfnHttpProc)(pfc, n, pv); }
  59. DWORD CallASP(PASP_CONTROL_BLOCK pACB) { return ((PFN_EXECUTEASP) m_pfnHttpProc)(pACB); }
  60. DWORD GetFilterFlags() { return dwFilterFlags; }
  61. };
  62. typedef struct _isapi_node
  63. {
  64. CISAPI *m_pISAPI; // class has library and entry point functions
  65. struct _isapi_node *m_pNext;
  66. } ISAPINODE, *PISAPINODE;
  67. class CISAPICache
  68. {
  69. private:
  70. PISAPINODE m_pHead;
  71. CRITICAL_SECTION m_CritSec;
  72. public:
  73. CISAPICache()
  74. {
  75. ZEROMEM(this);
  76. InitializeCriticalSection(&m_CritSec);
  77. }
  78. ~CISAPICache()
  79. {
  80. DeleteCriticalSection(&m_CritSec);
  81. }
  82. HINSTANCE Load(PWSTR wszDLLName, CISAPI **ppISAPI, SCRIPT_TYPE st=SCRIPT_TYPE_EXTENSION);
  83. void Unload(CISAPI *pISAPI)
  84. {
  85. SYSTEMTIME st;
  86. if (NULL == pISAPI)
  87. return;
  88. EnterCriticalSection(&m_CritSec);
  89. GetSystemTime(&st);
  90. SystemTimeToFileTime(&st,(FILETIME *) &pISAPI->m_ftLastUsed);
  91. pISAPI->m_cRef--;
  92. LeaveCriticalSection(&m_CritSec);
  93. }
  94. void RemoveUnusedISAPIs(BOOL fRemoveAll);
  95. friend DWORD WINAPI RemoveUnusedISAPIs(LPVOID lpv);
  96. };