Setup quota blocks for processes.

svn path=/trunk/; revision=16942
This commit is contained in:
Filip Navara 2005-08-01 11:20:44 +00:00
parent 50398b7a03
commit f28b5f7302
4 changed files with 59 additions and 14 deletions

View file

@ -509,6 +509,8 @@ PspExitProcess(PEPROCESS Process)
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);

View file

@ -20,6 +20,8 @@ PEPROCESS EXPORTED PsInitialSystemProcess = NULL;
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 @@ PspCreateProcess(OUT PHANDLE ProcessHandle,
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 @@ PspCreateProcess(OUT PHANDLE ProcessHandle,
DPRINT1("Failed to create CID handle (unique process ID)! Status: 0x%x\n", Status);
ObDereferenceObject(Process);
goto exitdereferenceobjects;
}
}
/* FIXME: Insert into Job Object */

View file

@ -126,21 +126,30 @@ PsInitProcessManagment(VOID)
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
*/
@ -175,6 +184,7 @@ PsInitProcessManagment(VOID)
FALSE);
PsIdleProcess->Pcb.DirectoryTableBase.QuadPart = (ULONG_PTR)MmGetPageDirectory();
strcpy(PsIdleProcess->ImageFileName, "Idle");
PspInheritQuota(PsIdleProcess, NULL);
/*
* Initialize the system process
@ -207,6 +217,7 @@ PsInitProcessManagment(VOID)
sizeof(EPROCESS),
FALSE);
KProcess = &PsInitialSystemProcess->Pcb;
PspInheritQuota(PsInitialSystemProcess, NULL);
MmInitializeAddressSpace(PsInitialSystemProcess,
&PsInitialSystemProcess->AddressSpace);

View file

@ -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
*/