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.

226 lines
9.8 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. BOOL m_fWinNT; // TRUE if this is Windows NT; false otherwise
  75. DWORD m_dwNumberOfProcessors;
  76. BOOL m_fInited;
  77. BOOL m_fMDRead; // Has Metadata been read at least once
  78. BOOL m_fNeedUpdate; // FALSE, needs reload config data from metabase
  79. // Metadata configuration settings per dll
  80. DWORD m_dwScriptEngineCacheMax;
  81. DWORD m_dwScriptFileCacheSize;
  82. BOOL m_fLogErrorRequests;
  83. BOOL m_fExceptionCatchEnable;
  84. BOOL m_fAllowDebugging;
  85. BOOL m_fAllowOutOfProcCmpnts;
  86. BOOL m_fTrackThreadingModel;
  87. DWORD m_dwMDSinkCookie;
  88. CMDGlobConfigSink *m_pMetabaseSink;
  89. IMSAdminBase *m_pMetabase;
  90. BOOL m_fEnableAspHtmlFallBack;
  91. BOOL m_fEnableTypelibCache;
  92. BOOL m_fEnableChunkedEncoding;
  93. BOOL m_fDupIISLogToNTLog;
  94. DWORD m_dwRequestQueueMax;
  95. DWORD m_dwProcessorThreadMax;
  96. BOOL m_fThreadGateEnabled;
  97. DWORD m_dwThreadGateTimeSlice;
  98. DWORD m_dwThreadGateSleepDelay;
  99. DWORD m_dwThreadGateSleepMax;
  100. DWORD m_dwThreadGateLoadLow;
  101. DWORD m_dwThreadGateLoadHigh;
  102. LPSTR m_pszPersistTemplateDir;
  103. DWORD m_dwPersistTemplateMaxFiles;
  104. CRITICAL_SECTION m_cs; // Glob Strings need to be protected by CriticalSection
  105. // Functions Pointers for WINNT & WIN95 singal binary compatibility
  106. //Private functions
  107. HRESULT SetGlobValue(unsigned int index, BYTE *lpByte);
  108. public:
  109. CGlob();
  110. HRESULT MDInit(void);
  111. HRESULT MDUnInit(void);
  112. public:
  113. ITypeLib* pITypeLibDenali() {return m_pITypeLibDenali;}; // Denali's type library
  114. BOOL fWinNT() {return m_fWinNT;}; // TRUE if this is Windows NT; false otherwise
  115. DWORD dwNumberOfProcessors() {return m_dwNumberOfProcessors;};
  116. BOOL fNeedUpdate() {return (BOOLB)m_fNeedUpdate;};
  117. void NotifyNeedUpdate();
  118. DWORD dwScriptEngineCacheMax() {return m_dwScriptEngineCacheMax;};
  119. DWORD dwScriptFileCacheSize() {return m_dwScriptFileCacheSize;};
  120. BOOLB fLogErrorRequests() {return (BOOLB)m_fLogErrorRequests;};
  121. BOOLB fInited() {return (BOOLB)m_fInited;};
  122. BOOLB fMDRead() {return (BOOLB)m_fMDRead;};
  123. BOOLB fTrackThreadingModel() {return (BOOLB)m_fTrackThreadingModel;};
  124. BOOLB fExceptionCatchEnable() {return (BOOLB)m_fExceptionCatchEnable;};
  125. BOOLB fAllowOutOfProcCmpnts() {return (BOOLB)m_fAllowOutOfProcCmpnts;};
  126. BOOL fEnableAspHtmlFallBack() { return m_fEnableAspHtmlFallBack; }
  127. BOOL fEnableTypelibCache() { return m_fEnableTypelibCache; }
  128. BOOL fEnableChunkedEncoding() { return m_fEnableChunkedEncoding; } // UNDONE: temp.
  129. BOOL fDupIISLogToNTLog() { return m_fDupIISLogToNTLog; }
  130. DWORD dwRequestQueueMax() { return m_dwRequestQueueMax; }
  131. DWORD dwProcessorThreadMax() { return m_dwProcessorThreadMax; }
  132. BOOL fThreadGateEnabled() { return m_fThreadGateEnabled; }
  133. DWORD dwThreadGateTimeSlice() { return m_dwThreadGateTimeSlice; }
  134. DWORD dwThreadGateSleepDelay() { return m_dwThreadGateSleepDelay; }
  135. DWORD dwThreadGateSleepMax() { return m_dwThreadGateSleepMax; }
  136. DWORD dwThreadGateLoadLow() { return m_dwThreadGateLoadLow; }
  137. DWORD dwThreadGateLoadHigh() { return m_dwThreadGateLoadHigh; }
  138. DWORD dwPersistTemplateMaxFiles(){ return m_dwPersistTemplateMaxFiles; }
  139. LPSTR pszPersistTemplateDir() { return m_pszPersistTemplateDir; }
  140. void Lock() {EnterCriticalSection(&m_cs);};
  141. void UnLock() {LeaveCriticalSection(&m_cs);};
  142. HRESULT GlobInit(void);
  143. HRESULT GlobUnInit(void);
  144. //Used in Scriptmgr for hashing table setup.
  145. DWORD dwThreadMax() {return 10;};
  146. //Used in ScriptKiller for script killer thread to wake up, might rename this to be
  147. //ScriptCleanupInterval.
  148. DWORD dwScriptTimeout() {return 90;};
  149. HRESULT Update(CIsapiReqInfo *pIReq);
  150. };
  151. inline HRESULT CGlob::Update(CIsapiReqInfo *pIReq)
  152. {
  153. Lock();
  154. if (m_fNeedUpdate == TRUE)
  155. {
  156. InterlockedExchange((LPLONG)&m_fNeedUpdate, 0);
  157. }
  158. else
  159. {
  160. UnLock();
  161. return S_OK;
  162. }
  163. UnLock();
  164. return ReadConfigFromMD(pIReq, NULL, TRUE);
  165. }
  166. inline void CGlob::NotifyNeedUpdate(void)
  167. {
  168. InterlockedExchange((LPLONG)&m_fNeedUpdate, 1);
  169. }
  170. typedef class CGlob GLOB;
  171. extern class CGlob gGlob;
  172. // General Access functions.(Backward compatibility).
  173. // Any non-friends functions should use and only use the following methods. Same macros as before.
  174. // If elem is a glob string, then, GlobStringUseLock() should be called before the string usage.
  175. // And GlobStringUseUnLock() should be called after. The critical section is supposed to protect
  176. // not only the LPTSTR of global string, but also the memory that LPTSTR points to.
  177. // Making local copy of global string is recommended.
  178. #define Glob(elem) (gGlob.elem())
  179. #define GlobStringUseLock() (gGlob.Lock())
  180. #define GlobStringUseUnLock() (gGlob.UnLock())
  181. #define FIsWinNT() (Glob(fWinNT))
  182. DWORD __stdcall RestartAppln(VOID *pAppln);
  183. #endif // __Glob_H