Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

cmgquota.c File Reference

#include "cmp.h"

Go to the source code of this file.

Defines

#define CM_DEFAULT_RATIO   (3)
#define CM_LIMIT_RATIO(x)   ((x / 10) * 8)
#define CM_MINIMUM_GLOBAL_QUOTA   (16 *1024 * 1024)
#define CM_REGISTRY_WARNING_LEVEL   (95)

Functions

VOID CmQueryRegistryQuotaInformation (IN PSYSTEM_REGISTRY_QUOTA_INFORMATION RegistryQuotaInformation)
VOID CmSetRegistryQuotaInformation (IN PSYSTEM_REGISTRY_QUOTA_INFORMATION RegistryQuotaInformation)
VOID CmpQuotaWarningWorker (IN PVOID WorkItem)
BOOLEAN CmpClaimGlobalQuota (IN ULONG Size)
VOID CmpReleaseGlobalQuota (IN ULONG Size)
VOID CmpComputeGlobalQuotaAllowed (VOID)
VOID CmpSetGlobalQuotaAllowed (VOID)

Variables

ULONG CmRegistrySizeLimit
ULONG CmRegistrySizeLimitLength
ULONG CmRegistrySizeLimitType
ULONG MmSizeOfPagedPoolInBytes
ULONG CmpGlobalQuota
ULONG CmpGlobalQuotaAllowed
ULONG CmpGlobalQuotaWarning
BOOLEAN CmpQuotaWarningPopupDisplayed
ULONG CmpGlobalQuotaUsed


Define Documentation

#define CM_DEFAULT_RATIO   (3)
 

Definition at line 51 of file cmgquota.c.

Referenced by CmpComputeGlobalQuotaAllowed().

#define CM_LIMIT_RATIO  )     ((x / 10) * 8)
 

Definition at line 52 of file cmgquota.c.

Referenced by CmpComputeGlobalQuotaAllowed().

#define CM_MINIMUM_GLOBAL_QUOTA   (16 *1024 * 1024)
 

Definition at line 53 of file cmgquota.c.

Referenced by CmpComputeGlobalQuotaAllowed(), and CmSetRegistryQuotaInformation().

#define CM_REGISTRY_WARNING_LEVEL   (95)
 

Definition at line 59 of file cmgquota.c.

Referenced by CmpComputeGlobalQuotaAllowed(), and CmSetRegistryQuotaInformation().


Function Documentation

BOOLEAN CmpClaimGlobalQuota IN ULONG  Size  ) 
 

Definition at line 204 of file cmgquota.c.

References CmpGlobalQuotaAllowed, CmpGlobalQuotaUsed, CmpGlobalQuotaWarning, CmpQuotaWarningPopupDisplayed, CmpQuotaWarningWorker(), DelayedWorkQueue, ExAllocatePool, ExInitializeWorkItem, ExQueueWorkItem(), ExReadyForErrors, FALSE, NonPagedPool, NULL, PWORK_QUEUE_ITEM, Size, and TRUE.

Referenced by CmpAllocate().

00209 : 00210 00211 If CmpGlobalQuotaUsed + Size >= CmpGlobalQuotaAllowed, return 00212 false. Otherwise, increment CmpGlobalQuotaUsed, in effect claiming 00213 the requested GlobalQuota. 00214 00215 Arguments: 00216 00217 Size - number of bytes of GlobalQuota caller wants to claim 00218 00219 Return Value: 00220 00221 TRUE - Claim succeeded, and has been counted in Used GQ 00222 00223 FALSE - Claim failed, nothing counted in GQ. 00224 00225 --*/ 00226 { 00227 LONG available; 00228 PWORK_QUEUE_ITEM WorkItem; 00229 00230 // 00231 // compute available space, then see if size <. This prevents overflows. 00232 // Note that this must be signed. Since quota is not enforced until logon, 00233 // it is possible for the available bytes to be negative. 00234 // 00235 00236 available = (LONG)CmpGlobalQuotaAllowed - (LONG)CmpGlobalQuotaUsed; 00237 00238 if ((LONG)Size < available) { 00239 CmpGlobalQuotaUsed += Size; 00240 if ((CmpGlobalQuotaUsed > CmpGlobalQuotaWarning) && 00241 (!CmpQuotaWarningPopupDisplayed) && 00242 (ExReadyForErrors)) { 00243 00244 // 00245 // Queue work item to display popup 00246 // 00247 WorkItem = ExAllocatePool(NonPagedPool, sizeof(WORK_QUEUE_ITEM)); 00248 if (WorkItem != NULL) { 00249 00250 CmpQuotaWarningPopupDisplayed = TRUE; 00251 ExInitializeWorkItem(WorkItem, 00252 CmpQuotaWarningWorker, 00253 WorkItem); 00254 ExQueueWorkItem(WorkItem, DelayedWorkQueue); 00255 } 00256 } 00257 return TRUE; 00258 } else { 00259 return FALSE; 00260 } 00261 }

VOID CmpComputeGlobalQuotaAllowed VOID   ) 
 

Definition at line 293 of file cmgquota.c.

References CM_DEFAULT_RATIO, CM_LIMIT_RATIO, CM_MINIMUM_GLOBAL_QUOTA, CM_REGISTRY_WARNING_LEVEL, CM_WRAP_LIMIT, CmpGlobalQuota, CmpGlobalQuotaWarning, CmRegistrySizeLimit, CmRegistrySizeLimitLength, CmRegistrySizeLimitType, and MmSizeOfPagedPoolInBytes.

Referenced by CmInitSystem1().

00299 : 00300 00301 Compute CmpGlobalQuota based on: 00302 (a) Size of paged pool 00303 (b) Explicit user registry commands to set registry GQ 00304 00305 Return Value: 00306 00307 NONE. 00308 00309 --*/ 00310 00311 { 00312 ULONG PagedLimit; 00313 00314 PagedLimit = CM_LIMIT_RATIO(MmSizeOfPagedPoolInBytes); 00315 00316 if ((CmRegistrySizeLimitLength != 4) || 00317 (CmRegistrySizeLimitType != REG_DWORD) || 00318 (CmRegistrySizeLimit == 0)) 00319 { 00320 // 00321 // If no value at all, or value of wrong type, or set to 00322 // zero, use internally computed default 00323 // 00324 CmpGlobalQuota = MmSizeOfPagedPoolInBytes / CM_DEFAULT_RATIO; 00325 00326 } else if (CmRegistrySizeLimit >= PagedLimit) { 00327 // 00328 // If more than computed upper bound, use computed upper bound 00329 // 00330 CmpGlobalQuota = PagedLimit; 00331 00332 } else { 00333 // 00334 // Use the set size 00335 // 00336 CmpGlobalQuota = CmRegistrySizeLimit; 00337 00338 } 00339 00340 if (CmpGlobalQuota > CM_WRAP_LIMIT) { 00341 CmpGlobalQuota = CM_WRAP_LIMIT; 00342 } 00343 if (CmpGlobalQuota < CM_MINIMUM_GLOBAL_QUOTA) { 00344 CmpGlobalQuota = CM_MINIMUM_GLOBAL_QUOTA; 00345 } 00346 00347 CmpGlobalQuotaWarning = CM_REGISTRY_WARNING_LEVEL * (CmpGlobalQuota / 100); 00348 00349 return; 00350 }

VOID CmpQuotaWarningWorker IN PVOID  WorkItem  ) 
 

Definition at line 166 of file cmgquota.c.

References ExFreePool(), ExRaiseHardError(), NTSTATUS(), NULL, and Status.

Referenced by CmpClaimGlobalQuota().

00172 : 00173 00174 Displays hard error popup that indicates the registry quota is 00175 running out. 00176 00177 Arguments: 00178 00179 WorkItem - Supplies pointer to the work item. This routine will 00180 free the work item. 00181 00182 Return Value: 00183 00184 None. 00185 00186 --*/ 00187 00188 { 00189 NTSTATUS Status; 00190 ULONG Response; 00191 00192 ExFreePool(WorkItem); 00193 00194 Status = ExRaiseHardError(STATUS_REGISTRY_QUOTA_LIMIT, 00195 0, 00196 0, 00197 NULL, 00198 OptionOk, 00199 &Response); 00200 }

VOID CmpReleaseGlobalQuota IN ULONG  Size  ) 
 

Definition at line 265 of file cmgquota.c.

References CmpGlobalQuotaUsed, KeBugCheckEx(), and Size.

Referenced by CmpAllocate(), CmpFree(), HvFreeHivePartial(), HvInitializeHive(), and HvWriteHive().

00270 : 00271 00272 If Size <= CmpGlobalQuotaUsed, then decrement it. Else BugCheck. 00273 00274 Arguments: 00275 00276 Size - number of bytes of GlobalQuota caller wants to release 00277 00278 Return Value: 00279 00280 NONE. 00281 00282 --*/ 00283 { 00284 if (Size > CmpGlobalQuotaUsed) { 00285 KeBugCheckEx(REGISTRY_ERROR,2,1,0,0); 00286 } 00287 00288 CmpGlobalQuotaUsed -= Size; 00289 }

VOID CmpSetGlobalQuotaAllowed VOID   ) 
 

Definition at line 354 of file cmgquota.c.

References CmpGlobalQuota, and CmpGlobalQuotaAllowed.

Referenced by CmLoadKey(), CmpLoadHiveVolatile(), and CmRestoreKey().

00359 : 00360 00361 Enables registry quota 00362 00363 NOTE: Do NOT put this in init segment, we call it after 00364 that code has been freed! 00365 00366 Return Value: 00367 00368 NONE. 00369 00370 --*/ 00371 { 00372 CmpGlobalQuotaAllowed = CmpGlobalQuota; 00373 } }

VOID CmQueryRegistryQuotaInformation IN PSYSTEM_REGISTRY_QUOTA_INFORMATION  RegistryQuotaInformation  ) 
 

Definition at line 92 of file cmgquota.c.

References CmpGlobalQuota, CmpGlobalQuotaUsed, and MmSizeOfPagedPoolInBytes.

Referenced by NtQuerySystemInformation().

00098 : 00099 00100 Returns the registry quota information 00101 00102 Arguments: 00103 00104 RegistryQuotaInformation - Supplies pointer to buffer that will return 00105 the registry quota information. 00106 00107 Return Value: 00108 00109 None. 00110 00111 --*/ 00112 00113 { 00114 RegistryQuotaInformation->RegistryQuotaAllowed = CmpGlobalQuota; 00115 RegistryQuotaInformation->RegistryQuotaUsed = CmpGlobalQuotaUsed; 00116 RegistryQuotaInformation->PagedPoolSize = MmSizeOfPagedPoolInBytes; 00117 }

VOID CmSetRegistryQuotaInformation IN PSYSTEM_REGISTRY_QUOTA_INFORMATION  RegistryQuotaInformation  ) 
 

Definition at line 121 of file cmgquota.c.

References CM_MINIMUM_GLOBAL_QUOTA, CM_REGISTRY_WARNING_LEVEL, CM_WRAP_LIMIT, CmpGlobalQuota, CmpGlobalQuotaAllowed, and CmpGlobalQuotaWarning.

Referenced by NtSetSystemInformation().

00127 : 00128 00129 Sets the registry quota information. The caller is assumed to have 00130 completed the necessary security checks already. 00131 00132 Arguments: 00133 00134 RegistryQuotaInformation - Supplies pointer to buffer that provides 00135 the new registry quota information. 00136 00137 Return Value: 00138 00139 None. 00140 00141 --*/ 00142 00143 { 00144 CmpGlobalQuota = RegistryQuotaInformation->RegistryQuotaAllowed; 00145 00146 // 00147 // Sanity checks against insane values 00148 // 00149 if (CmpGlobalQuota > CM_WRAP_LIMIT) { 00150 CmpGlobalQuota = CM_WRAP_LIMIT; 00151 } 00152 if (CmpGlobalQuota < CM_MINIMUM_GLOBAL_QUOTA) { 00153 CmpGlobalQuota = CM_MINIMUM_GLOBAL_QUOTA; 00154 } 00155 00156 // 00157 // Recompute the warning level 00158 // 00159 CmpGlobalQuotaWarning = CM_REGISTRY_WARNING_LEVEL * (CmpGlobalQuota / 100); 00160 00161 CmpGlobalQuotaAllowed = CmpGlobalQuota; 00162 }


Variable Documentation

ULONG CmpGlobalQuota
 

Definition at line 72 of file cmgquota.c.

Referenced by CmpComputeGlobalQuotaAllowed(), CmpSetGlobalQuotaAllowed(), CmQueryRegistryQuotaInformation(), and CmSetRegistryQuotaInformation().

ULONG CmpGlobalQuotaAllowed
 

Definition at line 73 of file cmgquota.c.

ULONG CmpGlobalQuotaUsed
 

Definition at line 88 of file cmgquota.c.

ULONG CmpGlobalQuotaWarning
 

Definition at line 78 of file cmgquota.c.

BOOLEAN CmpQuotaWarningPopupDisplayed
 

Definition at line 83 of file cmgquota.c.

Referenced by CmpClaimGlobalQuota().

ULONG CmRegistrySizeLimit
 

Definition at line 61 of file cmgquota.c.

Referenced by CmpComputeGlobalQuotaAllowed().

ULONG CmRegistrySizeLimitLength
 

Definition at line 62 of file cmgquota.c.

Referenced by CmpComputeGlobalQuotaAllowed().

ULONG CmRegistrySizeLimitType
 

Definition at line 63 of file cmgquota.c.

Referenced by CmpComputeGlobalQuotaAllowed().

ULONG MmSizeOfPagedPoolInBytes
 

Definition at line 65 of file cmgquota.c.


Generated on Sat May 15 19:43:08 2004 for test by doxygen 1.3.7