Setup quota blocks for processes. Modified: trunk/reactos/ntoskrnl/ps/kill.c Modified: trunk/reactos/ntoskrnl/ps/process.c Modified: trunk/reactos/ntoskrnl/ps/psmgr.c Modified: trunk/reactos/ntoskrnl/ps/quota.c _____
Modified: trunk/reactos/ntoskrnl/ps/kill.c --- trunk/reactos/ntoskrnl/ps/kill.c 2005-08-01 10:58:28 UTC (rev 16941) +++ trunk/reactos/ntoskrnl/ps/kill.c 2005-08-01 11:20:44 UTC (rev 16942) @@ -509,6 +509,8 @@
PspRunCreateProcessNotifyRoutines(Process, FALSE);
+ PspDestroyQuotaBlock(Process); + /* close all handles associated with our process, this needs to be done when the last thread still runs */ ObKillProcess(Process); _____
Modified: trunk/reactos/ntoskrnl/ps/process.c --- trunk/reactos/ntoskrnl/ps/process.c 2005-08-01 10:58:28 UTC (rev 16941) +++ trunk/reactos/ntoskrnl/ps/process.c 2005-08-01 11:20:44 UTC (rev 16942) @@ -20,6 +20,8 @@
PEPROCESS PsIdleProcess = NULL; POBJECT_TYPE EXPORTED PsProcessType = NULL;
+EPROCESS_QUOTA_BLOCK PspDefaultQuotaBlock; + LIST_ENTRY PsActiveProcessHead; FAST_MUTEX PspActiveProcessMutex; LARGE_INTEGER ShortPsLockDelay, PsLockTimeout; @@ -295,8 +297,8 @@ Process->Session = pParentProcess->Session; }
- /* FIXME: Set up the Quota Block from the Parent - PspInheritQuota(Parent, Process); */ + /* Set up the Quota Block from the Parent */ + PspInheritQuota(Process, pParentProcess);
/* FIXME: Set up Dos Device Map from the Parent ObInheritDeviceMap(Parent, Process) */ @@ -369,7 +371,7 @@ DPRINT1("Failed to create CID handle (unique process ID)! Status: 0x%x\n", Status); ObDereferenceObject(Process); goto exitdereferenceobjects; - } + }
/* FIXME: Insert into Job Object */
_____
Modified: trunk/reactos/ntoskrnl/ps/psmgr.c --- trunk/reactos/ntoskrnl/ps/psmgr.c 2005-08-01 10:58:28 UTC (rev 16941) +++ trunk/reactos/ntoskrnl/ps/psmgr.c 2005-08-01 11:20:44 UTC (rev 16942) @@ -126,22 +126,31 @@
DPRINT("Creating Process Object Type\n");
- /* Initialize the Thread type */ - RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer)); - RtlInitUnicodeString(&Name, L"Process"); - ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer); - ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(EPROCESS); - ObjectTypeInitializer.GenericMapping = PiProcessMapping; - ObjectTypeInitializer.PoolType = NonPagedPool; - ObjectTypeInitializer.ValidAccessMask = PROCESS_ALL_ACCESS; - ObjectTypeInitializer.UseDefaultObject = TRUE; - ObjectTypeInitializer.DeleteProcedure = PspDeleteProcess; - ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &PsProcessType); + /* Initialize the Process type */ + RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer)); + RtlInitUnicodeString(&Name, L"Process"); + ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer); + ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(EPROCESS); + ObjectTypeInitializer.GenericMapping = PiProcessMapping; + ObjectTypeInitializer.PoolType = NonPagedPool; + ObjectTypeInitializer.ValidAccessMask = PROCESS_ALL_ACCESS; + ObjectTypeInitializer.UseDefaultObject = TRUE; + ObjectTypeInitializer.DeleteProcedure = PspDeleteProcess; + ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &PsProcessType);
InitializeListHead(&PsActiveProcessHead); ExInitializeFastMutex(&PspActiveProcessMutex);
/* + * Initialize the default quota block. + */ + + RtlZeroMemory(&PspDefaultQuotaBlock, sizeof(PspDefaultQuotaBlock)); + PspDefaultQuotaBlock.QuotaEntry[PagedPool].Limit = (SIZE_T)-1; + PspDefaultQuotaBlock.QuotaEntry[NonPagedPool].Limit = (SIZE_T)-1; + PspDefaultQuotaBlock.QuotaEntry[2].Limit = (SIZE_T)-1; /* Page file */ + + /* * Initialize the idle process */ Status = ObCreateObject(KernelMode, @@ -175,6 +184,7 @@ FALSE); PsIdleProcess->Pcb.DirectoryTableBase.QuadPart = (ULONG_PTR)MmGetPageDirectory(); strcpy(PsIdleProcess->ImageFileName, "Idle"); + PspInheritQuota(PsIdleProcess, NULL);
/* * Initialize the system process @@ -207,6 +217,7 @@ sizeof(EPROCESS), FALSE); KProcess = &PsInitialSystemProcess->Pcb; + PspInheritQuota(PsInitialSystemProcess, NULL);
MmInitializeAddressSpace(PsInitialSystemProcess, &PsInitialSystemProcess->AddressSpace); _____
Modified: trunk/reactos/ntoskrnl/ps/quota.c --- trunk/reactos/ntoskrnl/ps/quota.c 2005-08-01 10:58:28 UTC (rev 16941) +++ trunk/reactos/ntoskrnl/ps/quota.c 2005-08-01 11:20:44 UTC (rev 16942) @@ -15,6 +15,36 @@
/* FUNCTIONS ***************************************************************/
+VOID +STDCALL +PspInheritQuota(PEPROCESS Process, PEPROCESS ParentProcess) +{ + PEPROCESS_QUOTA_BLOCK QuotaBlock; + + if (ParentProcess != NULL) + QuotaBlock = ParentProcess->QuotaBlock; + else + QuotaBlock = &PspDefaultQuotaBlock; + + ASSERT(QuotaBlock != NULL); + + InterlockedIncrement(&QuotaBlock->ReferenceCount); + Process->QuotaBlock = QuotaBlock; +} + +VOID +STDCALL +PspDestroyQuotaBlock(PEPROCESS Process) +{ + PEPROCESS_QUOTA_BLOCK QuotaBlock = Process->QuotaBlock; + + if (InterlockedDecrement(&QuotaBlock->ReferenceCount) == 0) + { + if (QuotaBlock != &PspDefaultQuotaBlock) + ExFreePool(QuotaBlock); + } +} + /* * @implemented */