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.

228 lines
10 KiB

  1. /*===================================================================
  2. Microsoft Denali
  3. Microsoft Confidential.
  4. Copyright 1996 Microsoft Corporation. All Rights Reserved.
  5. Component: Globals
  6. File: glob.h
  7. Owner: AndrewS
  8. Useful globals
  9. ===================================================================*/
  10. #ifndef __Glob_H
  11. #define __Glob_H
  12. #include "util.h"
  13. #include <schnlsp.h>
  14. #include <wincrypt.h>
  15. #include <iadmw.h>
  16. extern "C" {
  17. #define SECURITY_WIN32
  18. #include <sspi.h> // Security Support Provider APIs
  19. }
  20. class CMDGlobConfigSink : public IMSAdminBaseSinkW
  21. {
  22. private:
  23. INT m_cRef;
  24. public:
  25. CMDGlobConfigSink () {m_cRef = 1;};
  26. HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppv);
  27. ULONG STDMETHODCALLTYPE AddRef(void);
  28. ULONG STDMETHODCALLTYPE Release(void);
  29. HRESULT STDMETHODCALLTYPE SinkNotify(
  30. DWORD dwMDNumElements,
  31. MD_CHANGE_OBJECT __RPC_FAR pcoChangeList[]);
  32. HRESULT STDMETHODCALLTYPE ShutdownNotify( void)
  33. {
  34. return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
  35. }
  36. };
  37. #define IGlob_LogErrorRequests 0x0
  38. #define IGlob_ScriptFileCacheSize 0x1
  39. #define IGlob_ScriptEngineCacheMax 0x2
  40. //#define IGlob_MemFreeFactor 0x3
  41. //#define IGlob_MinUsedBlocks 0x4
  42. //#define IGlob_StartConnectionPool 0x5
  43. #define IGlob_ExceptionCatchEnable 0x3
  44. #define IGlob_TrackThreadingModel 0x4
  45. #define IGlob_AllowOutOfProcCmpnts 0x5
  46. // IIS5.0
  47. #define IGlob_EnableAspHtmlFallback 0x6
  48. #define IGlob_EnableChunkedEncoding 0x7
  49. #define IGlob_EnableTypelibCache 0x8
  50. #define IGlob_ErrorsToNtLog 0x9
  51. #define IGlob_ProcessorThreadMax 0xa
  52. #define IGlob_RequestQueueMax 0xb
  53. #define IGlob_ThreadGateEnabled 0xc
  54. #define IGlob_ThreadGateTimeSlice 0xd
  55. #define IGlob_ThreadGateSleepDelay 0xe
  56. #define IGlob_ThreadGateSleepMax 0xf
  57. #define IGlob_ThreadGateLoadLow 0x10
  58. #define IGlob_ThreadGateLoadHigh 0x11
  59. #define IGlob_PersistTemplateMaxFiles 0x12
  60. #define IGlob_PersistTemplateDir 0x13
  61. #define IGlob_MAX 0x14
  62. //forward declaration
  63. class CAppConfig;
  64. // Glob data object
  65. class CGlob
  66. {
  67. private:
  68. // Friends that can access the private data, they are the functions setting the global data.
  69. friend HRESULT CacheStdTypeInfos();
  70. friend HRESULT ReadConfigFromMD(CIsapiReqInfo *pIReq, CAppConfig *pAppConfig, BOOL fLoadGlob);
  71. friend HRESULT SetConfigToDefaults(CAppConfig *pAppConfig, BOOL fLoadGlob);
  72. //Private Data
  73. ITypeLib *m_pITypeLibDenali; // Denali's type library
  74. ITypeLib *m_pITypeLibTxn; // Denali's type library
  75. BOOL m_fWinNT; // TRUE if this is Windows NT; false otherwise
  76. DWORD m_dwNumberOfProcessors;
  77. BOOL m_fInited;
  78. BOOL m_fMDRead; // Has Metadata been read at least once
  79. BOOL m_fNeedUpdate; // FALSE, needs reload config data from metabase
  80. // Metadata configuration settings per dll
  81. DWORD m_dwScriptEngineCacheMax;
  82. DWORD m_dwScriptFileCacheSize;
  83. BOOL m_fLogErrorRequests;
  84. BOOL m_fExceptionCatchEnable;
  85. BOOL m_fAllowDebugging;
  86. BOOL m_fAllowOutOfProcCmpnts;
  87. BOOL m_fTrackThreadingModel;
  88. DWORD m_dwMDSinkCookie;
  89. CMDGlobConfigSink *m_pMetabaseSink;
  90. IMSAdminBase *m_pMetabase;
  91. BOOL m_fEnableAspHtmlFallBack;
  92. BOOL m_fEnableTypelibCache;
  93. BOOL m_fEnableChunkedEncoding;
  94. BOOL m_fDupIISLogToNTLog;
  95. DWORD m_dwRequestQueueMax;
  96. DWORD m_dwProcessorThreadMax;
  97. BOOL m_fThreadGateEnabled;
  98. DWORD m_dwThreadGateTimeSlice;
  99. DWORD m_dwThreadGateSleepDelay;
  100. DWORD m_dwThreadGateSleepMax;
  101. DWORD m_dwThreadGateLoadLow;
  102. DWORD m_dwThreadGateLoadHigh;
  103. LPSTR m_pszPersistTemplateDir;
  104. DWORD m_dwPersistTemplateMaxFiles;
  105. CRITICAL_SECTION m_cs; // Glob Strings need to be protected by CriticalSection
  106. // Functions Pointers for WINNT & WIN95 singal binary compatibility
  107. //Private functions
  108. HRESULT SetGlobValue(unsigned int index, BYTE *lpByte);
  109. public:
  110. CGlob();
  111. HRESULT MDInit(void);
  112. HRESULT MDUnInit(void);
  113. public:
  114. ITypeLib* pITypeLibDenali() {return m_pITypeLibDenali;}; // Denali's type library
  115. ITypeLib* pITypeLibTxn() {return m_pITypeLibTxn;}; // Denali's type library
  116. BOOL fWinNT() {return m_fWinNT;}; // TRUE if this is Windows NT; false otherwise
  117. DWORD dwNumberOfProcessors() {return m_dwNumberOfProcessors;};
  118. BOOL fNeedUpdate() {return (BOOLB)m_fNeedUpdate;};
  119. void NotifyNeedUpdate();
  120. DWORD dwScriptEngineCacheMax() {return m_dwScriptEngineCacheMax;};
  121. DWORD dwScriptFileCacheSize() {return m_dwScriptFileCacheSize;};
  122. BOOLB fLogErrorRequests() {return (BOOLB)m_fLogErrorRequests;};
  123. BOOLB fInited() {return (BOOLB)m_fInited;};
  124. BOOLB fMDRead() {return (BOOLB)m_fMDRead;};
  125. BOOLB fTrackThreadingModel() {return (BOOLB)m_fTrackThreadingModel;};
  126. BOOLB fExceptionCatchEnable() {return (BOOLB)m_fExceptionCatchEnable;};
  127. BOOLB fAllowOutOfProcCmpnts() {return (BOOLB)m_fAllowOutOfProcCmpnts;};
  128. BOOL fEnableAspHtmlFallBack() { return m_fEnableAspHtmlFallBack; }
  129. BOOL fEnableTypelibCache() { return m_fEnableTypelibCache; }
  130. BOOL fEnableChunkedEncoding() { return m_fEnableChunkedEncoding; } // UNDONE: temp.
  131. BOOL fDupIISLogToNTLog() { return m_fDupIISLogToNTLog; }
  132. DWORD dwRequestQueueMax() { return m_dwRequestQueueMax; }
  133. DWORD dwProcessorThreadMax() { return m_dwProcessorThreadMax; }
  134. BOOL fThreadGateEnabled() { return m_fThreadGateEnabled; }
  135. DWORD dwThreadGateTimeSlice() { return m_dwThreadGateTimeSlice; }
  136. DWORD dwThreadGateSleepDelay() { return m_dwThreadGateSleepDelay; }
  137. DWORD dwThreadGateSleepMax() { return m_dwThreadGateSleepMax; }
  138. DWORD dwThreadGateLoadLow() { return m_dwThreadGateLoadLow; }
  139. DWORD dwThreadGateLoadHigh() { return m_dwThreadGateLoadHigh; }
  140. DWORD dwPersistTemplateMaxFiles(){ return m_dwPersistTemplateMaxFiles; }
  141. LPSTR pszPersistTemplateDir() { return m_pszPersistTemplateDir; }
  142. void Lock() {EnterCriticalSection(&m_cs);};
  143. void UnLock() {LeaveCriticalSection(&m_cs);};
  144. HRESULT GlobInit(void);
  145. HRESULT GlobUnInit(void);
  146. //Used in Scriptmgr for hashing table setup.
  147. DWORD dwThreadMax() {return 10;};
  148. //Used in ScriptKiller for script killer thread to wake up, might rename this to be
  149. //ScriptCleanupInterval.
  150. DWORD dwScriptTimeout() {return 90;};
  151. HRESULT Update(CIsapiReqInfo *pIReq);
  152. };
  153. inline HRESULT CGlob::Update(CIsapiReqInfo *pIReq)
  154. {
  155. Lock();
  156. if (m_fNeedUpdate == TRUE)
  157. {
  158. InterlockedExchange((LPLONG)&m_fNeedUpdate, 0);
  159. }
  160. else
  161. {
  162. UnLock();
  163. return S_OK;
  164. }
  165. UnLock();
  166. return ReadConfigFromMD(pIReq, NULL, TRUE);
  167. }
  168. inline void CGlob::NotifyNeedUpdate(void)
  169. {
  170. InterlockedExchange((LPLONG)&m_fNeedUpdate, 1);
  171. }
  172. typedef class CGlob GLOB;
  173. extern class CGlob gGlob;
  174. // General Access functions.(Backward compatibility).
  175. // Any non-friends functions should use and only use the following methods. Same macros as before.
  176. // If elem is a glob string, then, GlobStringUseLock() should be called before the string usage.
  177. // And GlobStringUseUnLock() should be called after. The critical section is supposed to protect
  178. // not only the LPTSTR of global string, but also the memory that LPTSTR points to.
  179. // Making local copy of global string is recommended.
  180. #define Glob(elem) (gGlob.elem())
  181. #define GlobStringUseLock() (gGlob.Lock())
  182. #define GlobStringUseUnLock() (gGlob.UnLock())
  183. #define FIsWinNT() (Glob(fWinNT))
  184. DWORD __stdcall RestartAppln(VOID *pAppln);
  185. #endif // __Glob_H