ReactOS  r75907
quota.c File Reference
#include <ntoskrnl.h>
#include <ntintsafe.h>
#include <debug.h>
Include dependency graph for quota.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define TAG_QUOTA_BLOCK   'bQsP'
 
#define VALID_QUOTA_FLAGS
 

Functions

NTSTATUS NTAPI PspChargeProcessQuotaSpecifiedPool (IN PEPROCESS Process, IN UCHAR PoolIndex, IN SIZE_T Amount)
 
VOID NTAPI PspReturnProcessQuotaSpecifiedPool (IN PEPROCESS Process, IN UCHAR PoolIndex, IN SIZE_T Amount)
 
VOID NTAPI INIT_FUNCTION PsInitializeQuotaSystem (VOID)
 
VOID NTAPI PspInheritQuota (PEPROCESS Process, PEPROCESS ParentProcess)
 
VOID NTAPI PspInsertQuotaBlock (PEPROCESS_QUOTA_BLOCK QuotaBlock)
 
VOID NTAPI PspDestroyQuotaBlock (PEPROCESS Process)
 
NTSTATUS NTAPI PsChargeProcessPageFileQuota (IN PEPROCESS Process, IN SIZE_T Amount)
 
VOID NTAPI PsChargePoolQuota (IN PEPROCESS Process, IN POOL_TYPE PoolType, IN SIZE_T Amount)
 
NTSTATUS NTAPI PsChargeProcessNonPagedPoolQuota (IN PEPROCESS Process, IN SIZE_T Amount)
 
NTSTATUS NTAPI PsChargeProcessPagedPoolQuota (IN PEPROCESS Process, IN SIZE_T Amount)
 
NTSTATUS NTAPI PsChargeProcessPoolQuota (IN PEPROCESS Process, IN POOL_TYPE PoolType, IN SIZE_T Amount)
 
VOID NTAPI PsReturnPoolQuota (IN PEPROCESS Process, IN POOL_TYPE PoolType, IN SIZE_T Amount)
 
VOID NTAPI PsReturnProcessNonPagedPoolQuota (IN PEPROCESS Process, IN SIZE_T Amount)
 
VOID NTAPI PsReturnProcessPagedPoolQuota (IN PEPROCESS Process, IN SIZE_T Amount)
 
NTSTATUS NTAPI PsReturnProcessPageFileQuota (IN PEPROCESS Process, IN SIZE_T Amount)
 
NTSTATUS NTAPI PspSetQuotaLimits (_In_ PEPROCESS Process, _In_ ULONG Unused, _In_ PVOID QuotaLimits, _In_ ULONG QuotaLimitsLength, _In_ KPROCESSOR_MODE PreviousMode)
 

Variables

EPROCESS_QUOTA_BLOCK PspDefaultQuotaBlock
 
static LIST_ENTRY PspQuotaBlockList = {&PspQuotaBlockList, &PspQuotaBlockList}
 
static KSPIN_LOCK PspQuotaLock
 

Macro Definition Documentation

#define NDEBUG

Definition at line 15 of file quota.c.

#define TAG_QUOTA_BLOCK   'bQsP'

Definition at line 22 of file quota.c.

Referenced by PspSetQuotaLimits().

#define VALID_QUOTA_FLAGS
Value:
#define QUOTA_LIMITS_HARDWS_MAX_ENABLE
#define QUOTA_LIMITS_HARDWS_MAX_DISABLE
#define QUOTA_LIMITS_HARDWS_MIN_ENABLE
#define QUOTA_LIMITS_HARDWS_MIN_DISABLE

Definition at line 23 of file quota.c.

Referenced by PspSetQuotaLimits().

Function Documentation

VOID NTAPI PsChargePoolQuota ( IN PEPROCESS  Process,
IN POOL_TYPE  PoolType,
IN SIZE_T  Amount 
)

Definition at line 176 of file quota.c.

Referenced by FsRtlCancelNotify(), and FsRtlNotifyFilterReportChange().

179 {
182 
183  /* Don't do anything for the system process */
184  if (Process == PsInitialSystemProcess) return;
185 
186  /* Charge the usage */
188  if (!NT_SUCCESS(Status)) ExRaiseStatus(Status);
189 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
_Must_inspect_result_ _In_ LONGLONG _In_ LONGLONG Amount
Definition: fsrtlfuncs.h:550
NTSTATUS NTAPI PsChargeProcessPoolQuota(IN PEPROCESS Process, IN POOL_TYPE PoolType, IN SIZE_T Amount)
Definition: quota.c:220
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
#define ExRaiseStatus
Definition: ntoskrnl.h:94
PEPROCESS PsInitialSystemProcess
Definition: psmgr.c:50
IN REFCLSID IN PUNKNOWN IN POOL_TYPE PoolType
Definition: unknown.h:68
Status
Definition: gdiplustypes.h:24
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define NT_SUCCESS(StatCode)
Definition: cmd.c:149
LONG NTSTATUS
Definition: DriverTester.h:11
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
NTSTATUS NTAPI PsChargeProcessNonPagedPoolQuota ( IN PEPROCESS  Process,
IN SIZE_T  Amount 
)

Definition at line 196 of file quota.c.

198 {
199  /* Call the general function */
201 }
_Must_inspect_result_ _In_ LONGLONG _In_ LONGLONG Amount
Definition: fsrtlfuncs.h:550
NTSTATUS NTAPI PsChargeProcessPoolQuota(IN PEPROCESS Process, IN POOL_TYPE PoolType, IN SIZE_T Amount)
Definition: quota.c:220
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
NTSTATUS NTAPI PsChargeProcessPagedPoolQuota ( IN PEPROCESS  Process,
IN SIZE_T  Amount 
)

Definition at line 208 of file quota.c.

210 {
211  /* Call the general function */
213 }
_Must_inspect_result_ _In_ LONGLONG _In_ LONGLONG Amount
Definition: fsrtlfuncs.h:550
NTSTATUS NTAPI PsChargeProcessPoolQuota(IN PEPROCESS Process, IN POOL_TYPE PoolType, IN SIZE_T Amount)
Definition: quota.c:220
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
NTSTATUS NTAPI PsChargeProcessPageFileQuota ( IN PEPROCESS  Process,
IN SIZE_T  Amount 
)

Definition at line 162 of file quota.c.

164 {
165  /* Don't do anything for the system process */
167 
169 }
_Must_inspect_result_ _In_ LONGLONG _In_ LONGLONG Amount
Definition: fsrtlfuncs.h:550
return STATUS_SUCCESS
Definition: btrfs.c:2664
PEPROCESS PsInitialSystemProcess
Definition: psmgr.c:50
NTSTATUS NTAPI PspChargeProcessQuotaSpecifiedPool(IN PEPROCESS Process, IN UCHAR PoolIndex, IN SIZE_T Amount)
Definition: quota.c:40
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
NTSTATUS NTAPI PsChargeProcessPoolQuota ( IN PEPROCESS  Process,
IN POOL_TYPE  PoolType,
IN SIZE_T  Amount 
)

Definition at line 220 of file quota.c.

Referenced by ExAllocatePoolWithQuotaTag(), PsChargePoolQuota(), PsChargeProcessNonPagedPoolQuota(), and PsChargeProcessPagedPoolQuota().

223 {
224  /* Don't do anything for the system process */
226 
229  Amount);
230 }
_Must_inspect_result_ _In_ LONGLONG _In_ LONGLONG Amount
Definition: fsrtlfuncs.h:550
return STATUS_SUCCESS
Definition: btrfs.c:2664
#define PAGED_POOL_MASK
Definition: mm.h:96
PEPROCESS PsInitialSystemProcess
Definition: psmgr.c:50
NTSTATUS NTAPI PspChargeProcessQuotaSpecifiedPool(IN PEPROCESS Process, IN UCHAR PoolIndex, IN SIZE_T Amount)
Definition: quota.c:40
IN REFCLSID IN PUNKNOWN IN POOL_TYPE PoolType
Definition: unknown.h:68
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
VOID NTAPI INIT_FUNCTION PsInitializeQuotaSystem ( VOID  )

Definition at line 101 of file quota.c.

Referenced by ObInitSystem().

102 {
106  PspDefaultQuotaBlock.QuotaEntry[2].Limit = (SIZE_T)-1; /* Page file */
107  PsGetCurrentProcess()->QuotaBlock = &PspDefaultQuotaBlock;
108 }
EPROCESS_QUOTA_ENTRY QuotaEntry[3]
Definition: pstypes.h:978
EPROCESS_QUOTA_BLOCK PspDefaultQuotaBlock
Definition: quota.c:18
#define PsGetCurrentProcess
Definition: psfuncs.h:17
ULONG_PTR SIZE_T
Definition: typedefs.h:79
SIZE_T Limit
Definition: pstypes.h:971
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
NTSTATUS NTAPI PspChargeProcessQuotaSpecifiedPool ( IN PEPROCESS  Process,
IN UCHAR  PoolIndex,
IN SIZE_T  Amount 
)

Definition at line 40 of file quota.c.

Referenced by PsChargeProcessPageFileQuota(), and PsChargeProcessPoolQuota().

43 {
44  ASSERT(Process);
46  ASSERT(PoolIndex <= 2);
47  ASSERT(Process->QuotaBlock);
48 
49  /* Note: Race warning. TODO: Needs to add/use lock for this */
50  if (Process->QuotaUsage[PoolIndex] + Amount >
51  Process->QuotaBlock->QuotaEntry[PoolIndex].Limit)
52  {
53  DPRINT1("Quota exceeded, but ROS will let it slide...\n");
54  return STATUS_SUCCESS;
55  //return STATUS_QUOTA_EXCEEDED; /* caller raises the exception */
56  }
57 
58  InterlockedExchangeAdd((LONG*)&Process->QuotaUsage[PoolIndex], Amount);
59 
60  /* Note: Race warning. TODO: Needs to add/use lock for this */
61  if (Process->QuotaPeak[PoolIndex] < Process->QuotaUsage[PoolIndex])
62  {
63  Process->QuotaPeak[PoolIndex] = Process->QuotaUsage[PoolIndex];
64  }
65 
66  return STATUS_SUCCESS;
67 }
_Must_inspect_result_ _In_ LONGLONG _In_ LONGLONG Amount
Definition: fsrtlfuncs.h:550
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
return STATUS_SUCCESS
Definition: btrfs.c:2664
PEPROCESS PsInitialSystemProcess
Definition: psmgr.c:50
long LONG
Definition: pedump.c:60
#define InterlockedExchangeAdd
Definition: interlocked.h:181
#define DPRINT1
Definition: precomp.h:8
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
VOID NTAPI PspDestroyQuotaBlock ( PEPROCESS  Process)

Definition at line 142 of file quota.c.

143 {
144  PEPROCESS_QUOTA_BLOCK QuotaBlock = Process->QuotaBlock;
145  KIRQL OldIrql;
146 
147  if (QuotaBlock != &PspDefaultQuotaBlock &&
148  InterlockedDecrementUL(&QuotaBlock->ReferenceCount) == 0)
149  {
150  KeAcquireSpinLock(&PspQuotaLock, &OldIrql);
151  RemoveEntryList(&QuotaBlock->QuotaList);
152  KeReleaseSpinLock(&PspQuotaLock, OldIrql);
153  ExFreePool(QuotaBlock);
154  }
155 }
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
EPROCESS_QUOTA_BLOCK PspDefaultQuotaBlock
Definition: quota.c:18
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
PEPROCESS_QUOTA_BLOCK QuotaBlock
Definition: pstypes.h:1238
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
#define InterlockedDecrementUL(Addend)
Definition: ex.h:1452
LIST_ENTRY QuotaList
Definition: pstypes.h:979
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
static KSPIN_LOCK PspQuotaLock
Definition: quota.c:20
VOID NTAPI PspInheritQuota ( PEPROCESS  Process,
PEPROCESS  ParentProcess 
)

Definition at line 112 of file quota.c.

113 {
114  if (ParentProcess != NULL)
115  {
116  PEPROCESS_QUOTA_BLOCK QuotaBlock = ParentProcess->QuotaBlock;
117 
118  ASSERT(QuotaBlock != NULL);
119 
121 
122  Process->QuotaBlock = QuotaBlock;
123  }
124  else
125  Process->QuotaBlock = &PspDefaultQuotaBlock;
126 }
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
EPROCESS_QUOTA_BLOCK PspDefaultQuotaBlock
Definition: quota.c:18
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
smooth NULL
Definition: ftsmooth.c:513
PEPROCESS_QUOTA_BLOCK QuotaBlock
Definition: pstypes.h:1238
#define InterlockedIncrementUL(Addend)
Definition: ex.h:1455
VOID NTAPI PspInsertQuotaBlock ( PEPROCESS_QUOTA_BLOCK  QuotaBlock)

Definition at line 130 of file quota.c.

Referenced by PspSetQuotaLimits().

132 {
133  KIRQL OldIrql;
134 
135  KeAcquireSpinLock(&PspQuotaLock, &OldIrql);
137  KeReleaseSpinLock(&PspQuotaLock, OldIrql);
138 }
#define InsertTailList(ListHead, Entry)
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
LIST_ENTRY QuotaList
Definition: pstypes.h:979
static LIST_ENTRY PspQuotaBlockList
Definition: quota.c:19
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
static KSPIN_LOCK PspQuotaLock
Definition: quota.c:20
VOID NTAPI PspReturnProcessQuotaSpecifiedPool ( IN PEPROCESS  Process,
IN UCHAR  PoolIndex,
IN SIZE_T  Amount 
)

Definition at line 77 of file quota.c.

Referenced by PsReturnPoolQuota(), and PsReturnProcessPageFileQuota().

80 {
81  ASSERT(Process);
83  ASSERT(PoolIndex <= 2);
84  ASSERT(!(Amount & 0x80000000)); /* we need to be able to negate it */
85  if (Process->QuotaUsage[PoolIndex] < Amount)
86  {
87  DPRINT1("WARNING: Process->QuotaUsage sanity check failed.\n");
88  }
89  else
90  {
91  InterlockedExchangeAdd((LONG*)&Process->QuotaUsage[PoolIndex],
92  -(LONG)Amount);
93  }
94 }
_Must_inspect_result_ _In_ LONGLONG _In_ LONGLONG Amount
Definition: fsrtlfuncs.h:550
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
PEPROCESS PsInitialSystemProcess
Definition: psmgr.c:50
long LONG
Definition: pedump.c:60
#define InterlockedExchangeAdd
Definition: interlocked.h:181
#define DPRINT1
Definition: precomp.h:8
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
NTSTATUS NTAPI PspSetQuotaLimits ( _In_ PEPROCESS  Process,
_In_ ULONG  Unused,
_In_ PVOID  QuotaLimits,
_In_ ULONG  QuotaLimitsLength,
_In_ KPROCESSOR_MODE  PreviousMode 
)

Definition at line 294 of file quota.c.

Referenced by NtSetInformationProcess().

300 {
301  QUOTA_LIMITS_EX CapturedQuotaLimits;
302  PEPROCESS_QUOTA_BLOCK QuotaBlock, OldQuotaBlock;
303  BOOLEAN IncreaseOkay;
304  KAPC_STATE SavedApcState;
306 
308 
309  _SEH2_TRY
310  {
311  ProbeForRead(QuotaLimits, QuotaLimitsLength, sizeof(ULONG));
312 
313  /* Check if we have the basic or extended structure */
314  if (QuotaLimitsLength == sizeof(QUOTA_LIMITS))
315  {
316  /* Copy the basic structure, zero init the remaining fields */
317  RtlCopyMemory(&CapturedQuotaLimits, QuotaLimits, sizeof(QUOTA_LIMITS));
318  CapturedQuotaLimits.WorkingSetLimit = 0;
319  CapturedQuotaLimits.Reserved2 = 0;
320  CapturedQuotaLimits.Reserved3 = 0;
321  CapturedQuotaLimits.Reserved4 = 0;
322  CapturedQuotaLimits.CpuRateLimit.RateData = 0;
323  CapturedQuotaLimits.Flags = 0;
324  }
325  else if (QuotaLimitsLength == sizeof(QUOTA_LIMITS_EX))
326  {
327  /* Copy the full structure */
328  RtlCopyMemory(&CapturedQuotaLimits, QuotaLimits, sizeof(QUOTA_LIMITS_EX));
329 
330  /* Verify that the caller passed valid flags */
331  if ((CapturedQuotaLimits.Flags & ~VALID_QUOTA_FLAGS) ||
332  ((CapturedQuotaLimits.Flags & QUOTA_LIMITS_HARDWS_MIN_ENABLE) &&
333  (CapturedQuotaLimits.Flags & QUOTA_LIMITS_HARDWS_MIN_DISABLE)) ||
334  ((CapturedQuotaLimits.Flags & QUOTA_LIMITS_HARDWS_MAX_ENABLE) &&
335  (CapturedQuotaLimits.Flags & QUOTA_LIMITS_HARDWS_MAX_DISABLE)))
336  {
337  DPRINT1("Invalid quota flags: 0x%lx\n", CapturedQuotaLimits.Flags);
339  }
340 
341  /* Verify that the caller didn't pass reserved values */
342  if ((CapturedQuotaLimits.WorkingSetLimit != 0) ||
343  (CapturedQuotaLimits.Reserved2 != 0) ||
344  (CapturedQuotaLimits.Reserved3 != 0) ||
345  (CapturedQuotaLimits.Reserved4 != 0) ||
346  (CapturedQuotaLimits.CpuRateLimit.RateData != 0))
347  {
348  DPRINT1("Invalid value: (%lx,%lx,%lx,%lx,%lx)\n",
349  CapturedQuotaLimits.WorkingSetLimit,
350  CapturedQuotaLimits.Reserved2,
351  CapturedQuotaLimits.Reserved3,
352  CapturedQuotaLimits.Reserved4,
353  CapturedQuotaLimits.CpuRateLimit.RateData);
355  }
356  }
357  else
358  {
359  DPRINT1("Invalid quota size: 0x%lx\n", QuotaLimitsLength);
361  }
362  }
364  {
365  DPRINT1("Exception while copying data\n");
367  }
368  _SEH2_END;
369 
370  /* Check the caller changes the working set size limits */
371  if ((CapturedQuotaLimits.MinimumWorkingSetSize != 0) &&
372  (CapturedQuotaLimits.MaximumWorkingSetSize != 0))
373  {
374  /* Check for special case: trimming the WS */
375  if ((CapturedQuotaLimits.MinimumWorkingSetSize == SIZE_T_MAX) &&
376  (CapturedQuotaLimits.MaximumWorkingSetSize == SIZE_T_MAX))
377  {
378  /* No increase allowed */
379  IncreaseOkay = FALSE;
380  }
381  else
382  {
383  /* Check if the caller has the required privilege */
385  PreviousMode);
386  }
387 
388  /* Attach to the target process and disable APCs */
389  KeStackAttachProcess(&Process->Pcb, &SavedApcState);
391 
392  /* Call Mm to adjust the process' working set size */
393  Status = MmAdjustWorkingSetSize(CapturedQuotaLimits.MinimumWorkingSetSize,
394  CapturedQuotaLimits.MaximumWorkingSetSize,
395  0,
396  IncreaseOkay);
397 
398  /* Bring back APCs and detach from the process */
400  KeUnstackDetachProcess(&SavedApcState);
401  }
402  else if (Process->QuotaBlock == &PspDefaultQuotaBlock)
403  {
404  /* Check if the caller has the required privilege */
406  {
408  }
409 
410  /* Allocate a new quota block */
411  QuotaBlock = ExAllocatePoolWithTag(NonPagedPool,
412  sizeof(EPROCESS_QUOTA_BLOCK),
414  if (QuotaBlock == NULL)
415  {
417  return STATUS_NO_MEMORY;
418  }
419 
420  /* Initialize the quota block */
421  QuotaBlock->ReferenceCount = 1;
422  QuotaBlock->ProcessCount = 1;
423  QuotaBlock->QuotaEntry[0].Peak = Process->QuotaPeak[0];
424  QuotaBlock->QuotaEntry[1].Peak = Process->QuotaPeak[1];
425  QuotaBlock->QuotaEntry[2].Peak = Process->QuotaPeak[2];
429 
430  /* Try to exchange the quota block, if that failed, just drop it */
431  OldQuotaBlock = InterlockedCompareExchangePointer((PVOID*)&Process->QuotaBlock,
432  QuotaBlock,
434  if (OldQuotaBlock == &PspDefaultQuotaBlock)
435  {
436  /* Success, insert the new quota block */
437  PspInsertQuotaBlock(QuotaBlock);
438  }
439  else
440  {
441  /* Failed, free the quota block and ignore it */
442  ExFreePoolWithTag(QuotaBlock, TAG_QUOTA_BLOCK);
443  }
444 
445  Status = STATUS_SUCCESS;
446  }
447 
448  return Status;
449 }
DWORD *typedef PVOID
Definition: winlogon.h:52
#define QUOTA_LIMITS_HARDWS_MAX_ENABLE
_Must_inspect_result_ typedef _In_ PVOID Unused
Definition: iotypes.h:1128
#define STATUS_PRIVILEGE_NOT_HELD
Definition: DriverTester.h:9
#define QUOTA_LIMITS_HARDWS_MAX_DISABLE
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
KAPC_STATE
Definition: ketypes.h:1258
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
const LUID SeIncreaseQuotaPrivilege
Definition: priv.c:26
SIZE_T Reserved2
Definition: pstypes.h:75
#define SIZE_T_MAX
Definition: dhcpd.h:91
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:315
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
return STATUS_SUCCESS
Definition: btrfs.c:2664
#define VALID_QUOTA_FLAGS
Definition: quota.c:23
VOID NTAPI PspInsertQuotaBlock(PEPROCESS_QUOTA_BLOCK QuotaBlock)
Definition: quota.c:130
BOOLEAN NTAPI SeSinglePrivilegeCheck(IN LUID PrivilegeValue, IN KPROCESSOR_MODE PreviousMode)
Definition: priv.c:524
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:267
#define QUOTA_LIMITS_HARDWS_MIN_ENABLE
NTSTATUS NTAPI MmAdjustWorkingSetSize(IN SIZE_T WorkingSetMinimumInBytes, IN SIZE_T WorkingSetMaximumInBytes, IN ULONG SystemCache, IN BOOLEAN IncreaseOkay)
Definition: mmsup.c:44
EPROCESS_QUOTA_ENTRY QuotaEntry[3]
Definition: pstypes.h:978
EPROCESS_QUOTA_BLOCK PspDefaultQuotaBlock
Definition: quota.c:18
#define FALSE
Definition: types.h:117
VOID NTAPI KeStackAttachProcess(IN PKPROCESS Process, OUT PRKAPC_STATE ApcState)
Definition: procobj.c:649
#define _SEH2_END
Definition: pseh2_64.h:7
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:513
#define KeLeaveGuardedRegion()
Definition: ke_x.h:63
unsigned char BOOLEAN
_In_ KPROCESSOR_MODE PreviousMode
Definition: sefuncs.h:103
ULONG RateData
Definition: pstypes.h:60
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
#define KeEnterGuardedRegion()
Definition: ke_x.h:34
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
Status
Definition: gdiplustypes.h:24
SIZE_T MaximumWorkingSetSize
Definition: pstypes.h:71
#define TAG_QUOTA_BLOCK
Definition: quota.c:22
LONG NTSTATUS
Definition: DriverTester.h:11
SIZE_T MinimumWorkingSetSize
Definition: pstypes.h:70
SIZE_T WorkingSetLimit
Definition: pstypes.h:74
VOID NTAPI KeUnstackDetachProcess(IN PRKAPC_STATE ApcState)
Definition: procobj.c:701
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define _SEH2_TRY
Definition: pseh2_64.h:5
SIZE_T Limit
Definition: pstypes.h:971
#define QUOTA_LIMITS_HARDWS_MIN_DISABLE
#define DPRINT1
Definition: precomp.h:8
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
RATE_QUOTA_LIMIT CpuRateLimit
Definition: pstypes.h:79
unsigned int ULONG
Definition: retypes.h:1
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1097
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
SIZE_T Reserved3
Definition: pstypes.h:76
SIZE_T Peak
Definition: pstypes.h:972
SIZE_T Reserved4
Definition: pstypes.h:77
VOID NTAPI PsReturnPoolQuota ( IN PEPROCESS  Process,
IN POOL_TYPE  PoolType,
IN SIZE_T  Amount 
)

Definition at line 237 of file quota.c.

Referenced by ExFreePoolWithTag(), ExReturnPoolQuota(), PsReturnProcessNonPagedPoolQuota(), and PsReturnProcessPagedPoolQuota().

240 {
241  /* Don't do anything for the system process */
242  if (Process == PsInitialSystemProcess) return;
243 
246  Amount);
247 }
_Must_inspect_result_ _In_ LONGLONG _In_ LONGLONG Amount
Definition: fsrtlfuncs.h:550
#define PAGED_POOL_MASK
Definition: mm.h:96
VOID NTAPI PspReturnProcessQuotaSpecifiedPool(IN PEPROCESS Process, IN UCHAR PoolIndex, IN SIZE_T Amount)
Definition: quota.c:77
PEPROCESS PsInitialSystemProcess
Definition: psmgr.c:50
IN REFCLSID IN PUNKNOWN IN POOL_TYPE PoolType
Definition: unknown.h:68
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
VOID NTAPI PsReturnProcessNonPagedPoolQuota ( IN PEPROCESS  Process,
IN SIZE_T  Amount 
)

Definition at line 254 of file quota.c.

Referenced by PspDeleteProcess().

256 {
257  /* Don't do anything for the system process */
258  if (Process == PsInitialSystemProcess) return;
259 
261 }
_Must_inspect_result_ _In_ LONGLONG _In_ LONGLONG Amount
Definition: fsrtlfuncs.h:550
PEPROCESS PsInitialSystemProcess
Definition: psmgr.c:50
VOID NTAPI PsReturnPoolQuota(IN PEPROCESS Process, IN POOL_TYPE PoolType, IN SIZE_T Amount)
Definition: quota.c:237
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
VOID NTAPI PsReturnProcessPagedPoolQuota ( IN PEPROCESS  Process,
IN SIZE_T  Amount 
)

Definition at line 268 of file quota.c.

Referenced by FsRtlCancelNotify(), FsRtlNotifyCleanup(), FsRtlNotifyCompleteIrp(), and FsRtlNotifyFilterReportChange().

270 {
271  /* Don't do anything for the system process */
272  if (Process == PsInitialSystemProcess) return;
273 
275 }
_Must_inspect_result_ _In_ LONGLONG _In_ LONGLONG Amount
Definition: fsrtlfuncs.h:550
PEPROCESS PsInitialSystemProcess
Definition: psmgr.c:50
VOID NTAPI PsReturnPoolQuota(IN PEPROCESS Process, IN POOL_TYPE PoolType, IN SIZE_T Amount)
Definition: quota.c:237
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
NTSTATUS NTAPI PsReturnProcessPageFileQuota ( IN PEPROCESS  Process,
IN SIZE_T  Amount 
)

Definition at line 282 of file quota.c.

284 {
285  /* Don't do anything for the system process */
287 
289  return STATUS_SUCCESS;
290 }
_Must_inspect_result_ _In_ LONGLONG _In_ LONGLONG Amount
Definition: fsrtlfuncs.h:550
return STATUS_SUCCESS
Definition: btrfs.c:2664
VOID NTAPI PspReturnProcessQuotaSpecifiedPool(IN PEPROCESS Process, IN UCHAR PoolIndex, IN SIZE_T Amount)
Definition: quota.c:77
PEPROCESS PsInitialSystemProcess
Definition: psmgr.c:50
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219

Variable Documentation

EPROCESS_QUOTA_BLOCK PspDefaultQuotaBlock

Definition at line 18 of file quota.c.

Referenced by NtQueryInformationProcess(), PsInitializeQuotaSystem(), and PspInheritQuota().

LIST_ENTRY PspQuotaBlockList = {&PspQuotaBlockList, &PspQuotaBlockList}
static

Definition at line 19 of file quota.c.

KSPIN_LOCK PspQuotaLock
static

Definition at line 20 of file quota.c.

Referenced by PspDestroyQuotaBlock(), and PspInsertQuotaBlock().