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.

422 lines
16 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. //
  21. // BUGBUG:: We can have only one instance of CMDGlobConfigSink.
  22. // ASP Just requires one instance of this object and because we signal a global variable
  23. // in its destructor. Having multiple instances will cause a bug. Evaluate a change of design, behaviour
  24. // in case it becomes absolutely necessary that this class needs more instances
  25. //
  26. class CMDGlobConfigSink : public IMSAdminBaseSinkW
  27. {
  28. private:
  29. INT m_cRef;
  30. public:
  31. CMDGlobConfigSink ();
  32. ~CMDGlobConfigSink();
  33. HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppv);
  34. ULONG STDMETHODCALLTYPE AddRef(void);
  35. ULONG STDMETHODCALLTYPE Release(void);
  36. HRESULT STDMETHODCALLTYPE SinkNotify(
  37. DWORD dwMDNumElements,
  38. MD_CHANGE_OBJECT __RPC_FAR pcoChangeList[]);
  39. HRESULT STDMETHODCALLTYPE ShutdownNotify( void)
  40. {
  41. return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
  42. }
  43. };
  44. #define IGlob_LogErrorRequests 0x0
  45. #define IGlob_ScriptFileCacheSize 0x1
  46. #define IGlob_ScriptEngineCacheMax 0x2
  47. #define IGlob_ExceptionCatchEnable 0x3
  48. #define IGlob_TrackThreadingModel 0x4
  49. #define IGlob_AllowOutOfProcCmpnts 0x5
  50. // IIS5.0
  51. #define IGlob_EnableAspHtmlFallback 0x6
  52. #define IGlob_EnableChunkedEncoding 0x7
  53. #define IGlob_EnableTypelibCache 0x8
  54. #define IGlob_ErrorsToNtLog 0x9
  55. #define IGlob_ProcessorThreadMax 0xa
  56. #define IGlob_RequestQueueMax 0xb
  57. #define IGlob_PersistTemplateMaxFiles 0xc
  58. #define IGlob_PersistTemplateDir 0xd
  59. #define IGlob_MAX 0xe
  60. //forward declaration
  61. class CAppConfig;
  62. // Glob data object
  63. class CGlob
  64. {
  65. private:
  66. // Friends that can access the private data, they are the functions setting the global data.
  67. friend HRESULT CacheStdTypeInfos();
  68. friend HRESULT ReadConfigFromMD(CIsapiReqInfo *pIReq, CAppConfig *pAppConfig, BOOL fLoadGlob);
  69. friend HRESULT SetConfigToDefaults(CAppConfig *pAppConfig, BOOL fLoadGlob);
  70. //Private Data
  71. ITypeLib *m_pITypeLibDenali; // Denali's type library
  72. ITypeLib *m_pITypeLibTxn; // Denali's type library
  73. DWORD m_dwNumberOfProcessors;
  74. BOOL m_fInited;
  75. BOOL m_fMDRead; // Has Metadata been read at least once
  76. BOOL m_fNeedUpdate; // FALSE, needs reload config data from metabase
  77. // Metadata configuration settings per dll
  78. DWORD m_dwScriptEngineCacheMax;
  79. DWORD m_dwScriptFileCacheSize;
  80. BOOL m_fLogErrorRequests;
  81. BOOL m_fExceptionCatchEnable;
  82. BOOL m_fAllowDebugging;
  83. BOOL m_fAllowOutOfProcCmpnts;
  84. BOOL m_fTrackThreadingModel;
  85. DWORD m_dwMDSinkCookie;
  86. CMDGlobConfigSink *m_pMetabaseSink;
  87. IMSAdminBase *m_pMetabase;
  88. BOOL m_fEnableAspHtmlFallBack;
  89. BOOL m_fEnableTypelibCache;
  90. BOOL m_fEnableChunkedEncoding;
  91. BOOL m_fDupIISLogToNTLog;
  92. DWORD m_dwRequestQueueMax;
  93. DWORD m_dwProcessorThreadMax;
  94. LPSTR m_pszPersistTemplateDir;
  95. DWORD m_dwPersistTemplateMaxFiles;
  96. CRITICAL_SECTION m_cs; // Glob Strings need to be protected by CriticalSection
  97. // Functions Pointers for WINNT & WIN95 singal binary compatibility
  98. //Private functions
  99. HRESULT SetGlobValue(unsigned int index, BYTE *lpByte);
  100. public:
  101. CGlob();
  102. HRESULT MDInit(void);
  103. HRESULT MDUnInit(void);
  104. public:
  105. ITypeLib* pITypeLibDenali() {return m_pITypeLibDenali;}; // Denali's type library
  106. ITypeLib* pITypeLibTxn() {return m_pITypeLibTxn;}; // Denali's type library
  107. DWORD dwNumberOfProcessors() {return m_dwNumberOfProcessors;};
  108. BOOL fNeedUpdate() {return (BOOLB)m_fNeedUpdate;};
  109. void NotifyNeedUpdate();
  110. DWORD dwScriptEngineCacheMax() {return m_dwScriptEngineCacheMax;};
  111. DWORD dwScriptFileCacheSize() {return m_dwScriptFileCacheSize;};
  112. BOOLB fLogErrorRequests() {return (BOOLB)m_fLogErrorRequests;};
  113. BOOLB fInited() {return (BOOLB)m_fInited;};
  114. BOOLB fMDRead() {return (BOOLB)m_fMDRead;};
  115. BOOLB fTrackThreadingModel() {return (BOOLB)m_fTrackThreadingModel;};
  116. BOOLB fExceptionCatchEnable() {return (BOOLB)m_fExceptionCatchEnable;};
  117. BOOLB fAllowOutOfProcCmpnts() {return (BOOLB)m_fAllowOutOfProcCmpnts;};
  118. BOOL fEnableAspHtmlFallBack() { return m_fEnableAspHtmlFallBack; }
  119. BOOL fEnableTypelibCache() { return m_fEnableTypelibCache; }
  120. BOOL fEnableChunkedEncoding() { return m_fEnableChunkedEncoding; } // UNDONE: temp.
  121. BOOL fDupIISLogToNTLog() { return m_fDupIISLogToNTLog; }
  122. DWORD dwRequestQueueMax() { return m_dwRequestQueueMax; }
  123. DWORD dwProcessorThreadMax() { return m_dwProcessorThreadMax; }
  124. DWORD dwPersistTemplateMaxFiles(){ return m_dwPersistTemplateMaxFiles; }
  125. LPSTR pszPersistTemplateDir() { return m_pszPersistTemplateDir; }
  126. void Lock() {EnterCriticalSection(&m_cs);};
  127. void UnLock() {LeaveCriticalSection(&m_cs);};
  128. HRESULT GlobInit(void);
  129. HRESULT GlobUnInit(void);
  130. //Used in Scriptmgr for hashing table setup.
  131. DWORD dwThreadMax() {return 10;};
  132. //Used in ScriptKiller for script killer thread to wake up, might rename this to be
  133. //ScriptCleanupInterval.
  134. DWORD dwScriptTimeout() {return 90;};
  135. HRESULT Update(CIsapiReqInfo *pIReq);
  136. };
  137. inline HRESULT CGlob::Update(CIsapiReqInfo *pIReq)
  138. {
  139. Lock();
  140. if (m_fNeedUpdate == TRUE)
  141. {
  142. InterlockedExchange((LPLONG)&m_fNeedUpdate, 0);
  143. }
  144. else
  145. {
  146. UnLock();
  147. return S_OK;
  148. }
  149. UnLock();
  150. return ReadConfigFromMD(pIReq, NULL, TRUE);
  151. }
  152. inline void CGlob::NotifyNeedUpdate(void)
  153. {
  154. InterlockedExchange((LPLONG)&m_fNeedUpdate, 1);
  155. }
  156. typedef class CGlob GLOB;
  157. extern class CGlob gGlob;
  158. // General Access functions.(Backward compatibility).
  159. // Any non-friends functions should use and only use the following methods. Same macros as before.
  160. // If elem is a glob string, then, GlobStringUseLock() should be called before the string usage.
  161. // And GlobStringUseUnLock() should be called after. The critical section is supposed to protect
  162. // not only the LPTSTR of global string, but also the memory that LPTSTR points to.
  163. // Making local copy of global string is recommended.
  164. #define Glob(elem) (gGlob.elem())
  165. #define GlobStringUseLock() (gGlob.Lock())
  166. #define GlobStringUseUnLock() (gGlob.UnLock())
  167. // class to hold registry based ASP Parameters
  168. class CAspRegistryParams
  169. {
  170. public:
  171. CAspRegistryParams()
  172. {
  173. m_fF5AttackValuePresent = FALSE;
  174. m_fHangDetRequestThresholdPresent = FALSE;
  175. m_fHangDetThreadHungThresholdPresent = FALSE;
  176. m_fHangDetConsecIllStatesThresholdPresent = FALSE;
  177. m_fHangDetEnabledPresent = FALSE;
  178. m_fChangeNotificationForUNCPresent = FALSE;
  179. m_fFileMonitoringEnabledPresent = FALSE;
  180. m_fFileMonitoringTimeoutSecondsPresent = FALSE;
  181. m_fMaxCSRPresent = FALSE;
  182. m_fMaxCPUPresent = FALSE;
  183. m_fDisableOOMRecyclePresent = FALSE;
  184. m_fDisableLazyContentPropagationPresent = FALSE;
  185. m_fTotalThreadMaxPresent = FALSE;
  186. m_fDisableComPlusCpuMetricPresent = FALSE;
  187. }
  188. void Init();
  189. HRESULT GetF5AttackValue(DWORD *pdwResult);
  190. HRESULT GetHangDetRequestThreshold(DWORD *pdwResult);
  191. HRESULT GetHangDetThreadHungThreshold(DWORD *pdwResult);
  192. HRESULT GetHangDetConsecIllStatesThreshold(DWORD *pdwResult);
  193. HRESULT GetHangDetEnabled(DWORD *pdwResult);
  194. HRESULT GetChangeNotificationForUNCEnabled(DWORD *pdwResult);
  195. HRESULT GetFileMonitoringEnabled(DWORD *pdwResult);
  196. HRESULT GetFileMonitoringTimeout(DWORD *pdwResult);
  197. HRESULT GetMaxCSR(DWORD *pdwResult);
  198. HRESULT GetMaxCPU(DWORD *pdwResult);
  199. HRESULT GetDisableOOMRecycle(DWORD *pdwResult);
  200. HRESULT GetDisableLazyContentPropagation(DWORD *pdwResult);
  201. HRESULT GetTotalThreadMax(DWORD *pdwResult);
  202. HRESULT GetDisableComPlusCpuMetric(DWORD *pdwResult);
  203. private:
  204. DWORD m_fF5AttackValuePresent : 1;
  205. DWORD m_fHangDetRequestThresholdPresent : 1;
  206. DWORD m_fHangDetThreadHungThresholdPresent : 1;
  207. DWORD m_fHangDetConsecIllStatesThresholdPresent : 1;
  208. DWORD m_fHangDetEnabledPresent : 1;
  209. DWORD m_fChangeNotificationForUNCPresent : 1;
  210. DWORD m_fFileMonitoringEnabledPresent : 1;
  211. DWORD m_fFileMonitoringTimeoutSecondsPresent : 1;
  212. DWORD m_fMaxCSRPresent : 1;
  213. DWORD m_fMaxCPUPresent : 1;
  214. DWORD m_fDisableOOMRecyclePresent : 1;
  215. DWORD m_fDisableLazyContentPropagationPresent : 1;
  216. DWORD m_fTotalThreadMaxPresent : 1;
  217. DWORD m_fDisableComPlusCpuMetricPresent : 1;
  218. DWORD m_dwF5AttackValue;
  219. DWORD m_dwHangDetRequestThreshold;
  220. DWORD m_dwHangDetThreadHungThreshold;
  221. DWORD m_dwHangDetConsecIllStatesThreshold;
  222. DWORD m_dwHangDetEnabled;
  223. DWORD m_dwChangeNotificationForUNC;
  224. DWORD m_dwFileMonitoringEnabled;
  225. DWORD m_dwFileMonitoringTimeoutSeconds;
  226. DWORD m_dwMaxCSR;
  227. DWORD m_dwMaxCPU;
  228. DWORD m_dwDisableOOMRecycle;
  229. DWORD m_dwDisableLazyContentPropagation;
  230. DWORD m_dwTotalThreadMax;
  231. DWORD m_dwDisableComPlusCpuMetric;
  232. };
  233. inline HRESULT CAspRegistryParams::GetF5AttackValue(DWORD *pdwResult)
  234. {
  235. if (m_fF5AttackValuePresent) {
  236. *pdwResult = m_dwF5AttackValue;
  237. return S_OK;
  238. }
  239. return HRESULT_FROM_WIN32( ERROR_NO_DATA );
  240. }
  241. inline HRESULT CAspRegistryParams::GetHangDetRequestThreshold(DWORD *pdwResult)
  242. {
  243. if (m_fHangDetRequestThresholdPresent) {
  244. *pdwResult = m_dwHangDetRequestThreshold;
  245. return S_OK;
  246. }
  247. return HRESULT_FROM_WIN32( ERROR_NO_DATA );
  248. }
  249. inline HRESULT CAspRegistryParams::GetHangDetThreadHungThreshold(DWORD *pdwResult)
  250. {
  251. if (m_fHangDetThreadHungThresholdPresent) {
  252. *pdwResult = m_dwHangDetThreadHungThreshold;
  253. return S_OK;
  254. }
  255. return HRESULT_FROM_WIN32( ERROR_NO_DATA );
  256. }
  257. inline HRESULT CAspRegistryParams::GetHangDetConsecIllStatesThreshold(DWORD *pdwResult)
  258. {
  259. if (m_fHangDetConsecIllStatesThresholdPresent) {
  260. *pdwResult = m_dwHangDetConsecIllStatesThreshold;
  261. return S_OK;
  262. }
  263. return HRESULT_FROM_WIN32( ERROR_NO_DATA );
  264. }
  265. inline HRESULT CAspRegistryParams::GetHangDetEnabled(DWORD *pdwResult)
  266. {
  267. if (m_fHangDetEnabledPresent) {
  268. *pdwResult = m_dwHangDetEnabled;
  269. return S_OK;
  270. }
  271. return HRESULT_FROM_WIN32( ERROR_NO_DATA );
  272. }
  273. inline HRESULT CAspRegistryParams::GetChangeNotificationForUNCEnabled(DWORD *pdwResult)
  274. {
  275. if (m_fChangeNotificationForUNCPresent) {
  276. *pdwResult = m_dwChangeNotificationForUNC;
  277. return S_OK;
  278. }
  279. return HRESULT_FROM_WIN32( ERROR_NO_DATA );
  280. }
  281. inline HRESULT CAspRegistryParams::GetFileMonitoringEnabled(DWORD *pdwResult)
  282. {
  283. if (m_fFileMonitoringEnabledPresent) {
  284. *pdwResult = m_dwFileMonitoringEnabled;
  285. return S_OK;
  286. }
  287. return HRESULT_FROM_WIN32( ERROR_NO_DATA );
  288. }
  289. inline HRESULT CAspRegistryParams::GetFileMonitoringTimeout(DWORD *pdwResult)
  290. {
  291. if (m_fFileMonitoringTimeoutSecondsPresent) {
  292. *pdwResult = m_dwFileMonitoringTimeoutSeconds;
  293. return S_OK;
  294. }
  295. return HRESULT_FROM_WIN32( ERROR_NO_DATA );
  296. }
  297. inline HRESULT CAspRegistryParams::GetMaxCSR(DWORD *pdwResult)
  298. {
  299. if (m_fMaxCSRPresent) {
  300. *pdwResult = m_dwMaxCSR;
  301. return S_OK;
  302. }
  303. return HRESULT_FROM_WIN32( ERROR_NO_DATA );
  304. }
  305. inline HRESULT CAspRegistryParams::GetMaxCPU(DWORD *pdwResult)
  306. {
  307. if (m_fMaxCPUPresent) {
  308. *pdwResult = m_dwMaxCPU;
  309. return S_OK;
  310. }
  311. return HRESULT_FROM_WIN32( ERROR_NO_DATA );
  312. }
  313. inline HRESULT CAspRegistryParams::GetDisableOOMRecycle(DWORD *pdwResult)
  314. {
  315. if (m_fDisableOOMRecyclePresent) {
  316. *pdwResult = m_dwDisableOOMRecycle;
  317. return S_OK;
  318. }
  319. return HRESULT_FROM_WIN32( ERROR_NO_DATA );
  320. }
  321. inline HRESULT CAspRegistryParams::GetDisableLazyContentPropagation(DWORD *pdwResult)
  322. {
  323. if (m_fDisableLazyContentPropagationPresent) {
  324. *pdwResult = m_dwDisableLazyContentPropagation;
  325. return S_OK;
  326. }
  327. return HRESULT_FROM_WIN32( ERROR_NO_DATA );
  328. }
  329. inline HRESULT CAspRegistryParams::GetTotalThreadMax(DWORD *pdwResult)
  330. {
  331. if (m_fTotalThreadMaxPresent) {
  332. *pdwResult = m_dwTotalThreadMax;
  333. return S_OK;
  334. }
  335. return HRESULT_FROM_WIN32( ERROR_NO_DATA );
  336. }
  337. inline HRESULT CAspRegistryParams::GetDisableComPlusCpuMetric(DWORD *pdwResult)
  338. {
  339. if (m_fDisableComPlusCpuMetricPresent) {
  340. *pdwResult = m_dwDisableComPlusCpuMetric;
  341. return S_OK;
  342. }
  343. return HRESULT_FROM_WIN32( ERROR_NO_DATA );
  344. }
  345. extern CAspRegistryParams g_AspRegistryParams;
  346. HRESULT GetMetabaseIF(IMSAdminBase **hMetabase);
  347. #endif // __Glob_H