diff --git a/xtoskrnl/includes/ps/quota.hh b/xtoskrnl/includes/ps/quota.hh index 4129e93..08eba45 100644 --- a/xtoskrnl/includes/ps/quota.hh +++ b/xtoskrnl/includes/ps/quota.hh @@ -22,6 +22,7 @@ namespace PS STATIC KSPIN_LOCK QuotaLock; public: + STATIC VOID XTAPI InitializeQuota(VOID); STATIC XTFASTCALL VOID ReturnProcessQuota(IN PEPROCESS_QUOTA_BLOCK QuotaBlock, IN PEPROCESS Process, IN PS_QUOTA_TYPE QuotaType, diff --git a/xtoskrnl/ps/psmgr.cc b/xtoskrnl/ps/psmgr.cc index 54d2452..31a5214 100644 --- a/xtoskrnl/ps/psmgr.cc +++ b/xtoskrnl/ps/psmgr.cc @@ -77,4 +77,7 @@ PS::ProcessManager::InitializeProcessManager(VOID) ObjectTypeInitializer.GenericMapping = PS_THREAD_GENERIC_MAPPING; ObjectTypeInitializer.ValidAccessMask = SE_THREAD_ALL_ACCESS; OB::TypeRegistry::CreateObjectType(&ObjectTypeName, &ObjectTypeInitializer, NULLPTR, &ThreadType); + + /* Initialize system quota */ + PS::Quota::InitializeQuota(); } diff --git a/xtoskrnl/ps/quota.cc b/xtoskrnl/ps/quota.cc index 1aee55c..71990cf 100644 --- a/xtoskrnl/ps/quota.cc +++ b/xtoskrnl/ps/quota.cc @@ -67,6 +67,36 @@ PS::Quota::DereferenceQuotaBlock(IN PEPROCESS_QUOTA_BLOCK QuotaBlock) } } +/** + * Initializes the system-wide process quota subsystem. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +VOID +XTAPI +PS::Quota::InitializeQuota(VOID) +{ + /* Initialize the quota lock */ + KE::SpinLock::InitializeSpinLock(&QuotaLock); + + /* Clear the default quota block */ + RtlZeroMemory(&DefaultQuotaBlock, sizeof(DefaultQuotaBlock)); + + /* Set up the counters */ + DefaultQuotaBlock.ProcessCount = 1; + DefaultQuotaBlock.ReferenceCount = 1; + + /* Set up the limits */ + DefaultQuotaBlock.QuotaEntry[PsNonPagedPool].Limit = (SIZE_T)-1; + DefaultQuotaBlock.QuotaEntry[PsPagedPool].Limit = (SIZE_T)-1; + DefaultQuotaBlock.QuotaEntry[PsPageFile].Limit = (SIZE_T)-1; + + /* Assign the default quota block to the current process */ + PS::Process::GetCurrentProcess()->QuotaBlock = &DefaultQuotaBlock; +} + /** * Returns a specified amount of quota to a quota block and updates process usage. *