ReactOS  0.4.15-dev-3297-g037c744
quota.c File Reference
#include <ntoskrnl.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 PS_QUOTA_TYPE QuotaType, IN SIZE_T Amount)
 
VOID NTAPI PspReturnProcessQuotaSpecifiedPool (IN PEPROCESS Process, IN PS_QUOTA_TYPE QuotaType, IN SIZE_T Amount)
 
VOID NTAPI 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

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file quota.c.

◆ TAG_QUOTA_BLOCK

#define TAG_QUOTA_BLOCK   'bQsP'

Definition at line 21 of file quota.c.

◆ VALID_QUOTA_FLAGS

#define VALID_QUOTA_FLAGS
Value:
QUOTA_LIMITS_HARDWS_MIN_DISABLE | \
QUOTA_LIMITS_HARDWS_MAX_ENABLE | \
QUOTA_LIMITS_HARDWS_MAX_DISABLE)
#define QUOTA_LIMITS_HARDWS_MIN_ENABLE

Definition at line 22 of file quota.c.

Function Documentation

◆ PsChargePoolQuota()

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

Definition at line 182 of file quota.c.

185 {
188 
189  /* Don't do anything for the system process */
190  if (Process == PsInitialSystemProcess) return;
191 
192  /* Charge the usage */
195 }
#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:226
LONG NTSTATUS
Definition: precomp.h:26
#define ExRaiseStatus
Definition: ntoskrnl.h:104
PEPROCESS PsInitialSystemProcess
Definition: psmgr.c:50
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3810

Referenced by FsRtlCancelNotify(), and FsRtlNotifyFilterReportChange().

◆ PsChargeProcessNonPagedPoolQuota()

NTSTATUS NTAPI PsChargeProcessNonPagedPoolQuota ( IN PEPROCESS  Process,
IN SIZE_T  Amount 
)

Definition at line 202 of file quota.c.

204 {
205  /* Call the general function */
207 }
_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:226
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219

◆ PsChargeProcessPagedPoolQuota()

NTSTATUS NTAPI PsChargeProcessPagedPoolQuota ( IN PEPROCESS  Process,
IN SIZE_T  Amount 
)

Definition at line 214 of file quota.c.

216 {
217  /* Call the general function */
219 }
_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:226
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219

◆ PsChargeProcessPageFileQuota()

NTSTATUS NTAPI PsChargeProcessPageFileQuota ( IN PEPROCESS  Process,
IN SIZE_T  Amount 
)

Definition at line 168 of file quota.c.

170 {
171  /* Don't do anything for the system process */
173 
175 }
_Must_inspect_result_ _In_ LONGLONG _In_ LONGLONG Amount
Definition: fsrtlfuncs.h:550
PEPROCESS PsInitialSystemProcess
Definition: psmgr.c:50
NTSTATUS NTAPI PspChargeProcessQuotaSpecifiedPool(IN PEPROCESS Process, IN PS_QUOTA_TYPE QuotaType, IN SIZE_T Amount)
Definition: quota.c:37
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ PsChargeProcessPoolQuota()

NTSTATUS NTAPI PsChargeProcessPoolQuota ( IN PEPROCESS  Process,
IN POOL_TYPE  PoolType,
IN SIZE_T  Amount 
)

Definition at line 226 of file quota.c.

229 {
230  /* Don't do anything for the system process */
232 
235  Amount);
236 }
_Must_inspect_result_ _In_ LONGLONG _In_ LONGLONG Amount
Definition: fsrtlfuncs.h:550
#define PAGED_POOL_MASK
Definition: mm.h:107
PEPROCESS PsInitialSystemProcess
Definition: psmgr.c:50
NTSTATUS NTAPI PspChargeProcessQuotaSpecifiedPool(IN PEPROCESS Process, IN PS_QUOTA_TYPE QuotaType, IN SIZE_T Amount)
Definition: quota.c:37
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3810
#define STATUS_SUCCESS
Definition: shellext.h:65

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

◆ PsInitializeQuotaSystem()

VOID NTAPI PsInitializeQuotaSystem ( VOID  )

Definition at line 107 of file quota.c.

108 {
113  PsGetCurrentProcess()->QuotaBlock = &PspDefaultQuotaBlock;
114 }
EPROCESS_QUOTA_ENTRY QuotaEntry[PsQuotaTypes]
Definition: pstypes.h:1046
EPROCESS_QUOTA_BLOCK PspDefaultQuotaBlock
Definition: quota.c:17
#define PsGetCurrentProcess
Definition: psfuncs.h:17
ULONG_PTR SIZE_T
Definition: typedefs.h:80
SIZE_T Limit
Definition: pstypes.h:1039
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

Referenced by ObInitSystem().

◆ PspChargeProcessQuotaSpecifiedPool()

NTSTATUS NTAPI PspChargeProcessQuotaSpecifiedPool ( IN PEPROCESS  Process,
IN PS_QUOTA_TYPE  QuotaType,
IN SIZE_T  Amount 
)

Definition at line 37 of file quota.c.

40 {
41  KIRQL OldIrql;
42  ASSERT(Process);
44  ASSERT(QuotaType < PsQuotaTypes);
45  ASSERT(Process->QuotaBlock);
46 
47  /* Guard our quota in a spin lock */
49 
50  if (Process->QuotaUsage[QuotaType] + Amount >
51  Process->QuotaBlock->QuotaEntry[QuotaType].Limit)
52  {
53  DPRINT1("Quota exceeded, but ROS will let it slide...\n");
55  return STATUS_SUCCESS;
56  //return STATUS_QUOTA_EXCEEDED; /* caller raises the exception */
57  }
58 
59  InterlockedExchangeAdd((LONG*)&Process->QuotaUsage[QuotaType], Amount);
60 
61  if (Process->QuotaPeak[QuotaType] < Process->QuotaUsage[QuotaType])
62  {
63  Process->QuotaPeak[QuotaType] = Process->QuotaUsage[QuotaType];
64  }
65 
67  return STATUS_SUCCESS;
68 }
_Must_inspect_result_ _In_ LONGLONG _In_ LONGLONG Amount
Definition: fsrtlfuncs.h:550
VOID NTAPI KeAcquireSpinLock(PKSPIN_LOCK SpinLock, PKIRQL OldIrql)
Definition: spinlock.c:50
UCHAR KIRQL
Definition: env_spec_w32.h:591
PEPROCESS PsInitialSystemProcess
Definition: psmgr.c:50
long LONG
Definition: pedump.c:60
#define InterlockedExchangeAdd
Definition: interlocked.h:181
KIRQL OldIrql
Definition: mm.h:1502
#define ASSERT(a)
Definition: mode.c:44
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#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
#define STATUS_SUCCESS
Definition: shellext.h:65
static KSPIN_LOCK PspQuotaLock
Definition: quota.c:19

Referenced by PsChargeProcessPageFileQuota(), and PsChargeProcessPoolQuota().

◆ PspDestroyQuotaBlock()

VOID NTAPI PspDestroyQuotaBlock ( PEPROCESS  Process)

Definition at line 148 of file quota.c.

149 {
150  PEPROCESS_QUOTA_BLOCK QuotaBlock = Process->QuotaBlock;
151  KIRQL OldIrql;
152 
153  if (QuotaBlock != &PspDefaultQuotaBlock &&
154  InterlockedDecrementUL(&QuotaBlock->ReferenceCount) == 0)
155  {
157  RemoveEntryList(&QuotaBlock->QuotaList);
159  ExFreePool(QuotaBlock);
160  }
161 }
VOID NTAPI KeAcquireSpinLock(PKSPIN_LOCK SpinLock, PKIRQL OldIrql)
Definition: spinlock.c:50
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
EPROCESS_QUOTA_BLOCK PspDefaultQuotaBlock
Definition: quota.c:17
UCHAR KIRQL
Definition: env_spec_w32.h:591
KIRQL OldIrql
Definition: mm.h:1502
#define InterlockedDecrementUL(Addend)
Definition: ex.h:1522
LIST_ENTRY QuotaList
Definition: pstypes.h:1047
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
static KSPIN_LOCK PspQuotaLock
Definition: quota.c:19

◆ PspInheritQuota()

VOID NTAPI PspInheritQuota ( PEPROCESS  Process,
PEPROCESS  ParentProcess 
)

Definition at line 118 of file quota.c.

119 {
120  if (ParentProcess != NULL)
121  {
122  PEPROCESS_QUOTA_BLOCK QuotaBlock = ParentProcess->QuotaBlock;
123 
124  ASSERT(QuotaBlock != NULL);
125 
127 
128  Process->QuotaBlock = QuotaBlock;
129  }
130  else
131  Process->QuotaBlock = &PspDefaultQuotaBlock;
132 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
EPROCESS_QUOTA_BLOCK PspDefaultQuotaBlock
Definition: quota.c:17
#define ASSERT(a)
Definition: mode.c:44
PEPROCESS_QUOTA_BLOCK QuotaBlock
Definition: pstypes.h:1306
#define InterlockedIncrementUL(Addend)
Definition: ex.h:1525
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219

◆ PspInsertQuotaBlock()

VOID NTAPI PspInsertQuotaBlock ( PEPROCESS_QUOTA_BLOCK  QuotaBlock)

Definition at line 136 of file quota.c.

138 {
139  KIRQL OldIrql;
140 
144 }
VOID NTAPI KeAcquireSpinLock(PKSPIN_LOCK SpinLock, PKIRQL OldIrql)
Definition: spinlock.c:50
#define InsertTailList(ListHead, Entry)
UCHAR KIRQL
Definition: env_spec_w32.h:591
KIRQL OldIrql
Definition: mm.h:1502
LIST_ENTRY QuotaList
Definition: pstypes.h:1047
static LIST_ENTRY PspQuotaBlockList
Definition: quota.c:18
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
static KSPIN_LOCK PspQuotaLock
Definition: quota.c:19

Referenced by PspSetQuotaLimits().

◆ PspReturnProcessQuotaSpecifiedPool()

VOID NTAPI PspReturnProcessQuotaSpecifiedPool ( IN PEPROCESS  Process,
IN PS_QUOTA_TYPE  QuotaType,
IN SIZE_T  Amount 
)

Definition at line 76 of file quota.c.

79 {
80  KIRQL OldIrql;
81  ASSERT(Process);
83  ASSERT(QuotaType < PsQuotaTypes);
84  ASSERT(!(Amount & 0x80000000)); /* we need to be able to negate it */
85 
86  /* Guard our quota in a spin lock */
88 
89  if (Process->QuotaUsage[QuotaType] < Amount)
90  {
91  DPRINT1("WARNING: Process->QuotaUsage sanity check failed.\n");
92  }
93  else
94  {
95  InterlockedExchangeAdd((LONG*)&Process->QuotaUsage[QuotaType],
96  -(LONG)Amount);
97  }
98 
100 }
_Must_inspect_result_ _In_ LONGLONG _In_ LONGLONG Amount
Definition: fsrtlfuncs.h:550
VOID NTAPI KeAcquireSpinLock(PKSPIN_LOCK SpinLock, PKIRQL OldIrql)
Definition: spinlock.c:50
UCHAR KIRQL
Definition: env_spec_w32.h:591
PEPROCESS PsInitialSystemProcess
Definition: psmgr.c:50
long LONG
Definition: pedump.c:60
#define InterlockedExchangeAdd
Definition: interlocked.h:181
KIRQL OldIrql
Definition: mm.h:1502
#define ASSERT(a)
Definition: mode.c:44
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#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
static KSPIN_LOCK PspQuotaLock
Definition: quota.c:19

Referenced by PsReturnPoolQuota(), and PsReturnProcessPageFileQuota().

◆ PspSetQuotaLimits()

NTSTATUS NTAPI PspSetQuotaLimits ( _In_ PEPROCESS  Process,
_In_ ULONG  Unused,
_In_ PVOID  QuotaLimits,
_In_ ULONG  QuotaLimitsLength,
_In_ KPROCESSOR_MODE  PreviousMode 
)

Definition at line 300 of file quota.c.

306 {
307  QUOTA_LIMITS_EX CapturedQuotaLimits;
308  PEPROCESS_QUOTA_BLOCK QuotaBlock, OldQuotaBlock;
309  BOOLEAN IncreaseOkay;
310  KAPC_STATE SavedApcState;
312 
314 
315  _SEH2_TRY
316  {
317  ProbeForRead(QuotaLimits, QuotaLimitsLength, sizeof(ULONG));
318 
319  /* Check if we have the basic or extended structure */
320  if (QuotaLimitsLength == sizeof(QUOTA_LIMITS))
321  {
322  /* Copy the basic structure, zero init the remaining fields */
323  RtlCopyMemory(&CapturedQuotaLimits, QuotaLimits, sizeof(QUOTA_LIMITS));
324  CapturedQuotaLimits.WorkingSetLimit = 0;
325  CapturedQuotaLimits.Reserved2 = 0;
326  CapturedQuotaLimits.Reserved3 = 0;
327  CapturedQuotaLimits.Reserved4 = 0;
328  CapturedQuotaLimits.CpuRateLimit.RateData = 0;
329  CapturedQuotaLimits.Flags = 0;
330  }
331  else if (QuotaLimitsLength == sizeof(QUOTA_LIMITS_EX))
332  {
333  /* Copy the full structure */
334  RtlCopyMemory(&CapturedQuotaLimits, QuotaLimits, sizeof(QUOTA_LIMITS_EX));
335 
336  /* Verify that the caller passed valid flags */
337  if ((CapturedQuotaLimits.Flags & ~VALID_QUOTA_FLAGS) ||
338  ((CapturedQuotaLimits.Flags & QUOTA_LIMITS_HARDWS_MIN_ENABLE) &&
339  (CapturedQuotaLimits.Flags & QUOTA_LIMITS_HARDWS_MIN_DISABLE)) ||
340  ((CapturedQuotaLimits.Flags & QUOTA_LIMITS_HARDWS_MAX_ENABLE) &&
341  (CapturedQuotaLimits.Flags & QUOTA_LIMITS_HARDWS_MAX_DISABLE)))
342  {
343  DPRINT1("Invalid quota flags: 0x%lx\n", CapturedQuotaLimits.Flags);
345  }
346 
347  /* Verify that the caller didn't pass reserved values */
348  if ((CapturedQuotaLimits.WorkingSetLimit != 0) ||
349  (CapturedQuotaLimits.Reserved2 != 0) ||
350  (CapturedQuotaLimits.Reserved3 != 0) ||
351  (CapturedQuotaLimits.Reserved4 != 0) ||
352  (CapturedQuotaLimits.CpuRateLimit.RateData != 0))
353  {
354  DPRINT1("Invalid value: (%lx,%lx,%lx,%lx,%lx)\n",
355  CapturedQuotaLimits.WorkingSetLimit,
356  CapturedQuotaLimits.Reserved2,
357  CapturedQuotaLimits.Reserved3,
358  CapturedQuotaLimits.Reserved4,
359  CapturedQuotaLimits.CpuRateLimit.RateData);
361  }
362  }
363  else
364  {
365  DPRINT1("Invalid quota size: 0x%lx\n", QuotaLimitsLength);
367  }
368  }
370  {
371  DPRINT1("Exception while copying data\n");
373  }
374  _SEH2_END;
375 
376  /* Check the caller changes the working set size limits */
377  if ((CapturedQuotaLimits.MinimumWorkingSetSize != 0) &&
378  (CapturedQuotaLimits.MaximumWorkingSetSize != 0))
379  {
380  /* Check for special case: trimming the WS */
381  if ((CapturedQuotaLimits.MinimumWorkingSetSize == SIZE_T_MAX) &&
382  (CapturedQuotaLimits.MaximumWorkingSetSize == SIZE_T_MAX))
383  {
384  /* No increase allowed */
385  IncreaseOkay = FALSE;
386  }
387  else
388  {
389  /* Check if the caller has the required privilege */
391  PreviousMode);
392  }
393 
394  /* Attach to the target process and disable APCs */
395  KeStackAttachProcess(&Process->Pcb, &SavedApcState);
397 
398  /* Call Mm to adjust the process' working set size */
400  CapturedQuotaLimits.MaximumWorkingSetSize,
401  0,
402  IncreaseOkay);
403 
404  /* Bring back APCs and detach from the process */
406  KeUnstackDetachProcess(&SavedApcState);
407  }
408  else if (Process->QuotaBlock == &PspDefaultQuotaBlock)
409  {
410  /* Check if the caller has the required privilege */
412  {
414  }
415 
416  /* Allocate a new quota block */
417  QuotaBlock = ExAllocatePoolWithTag(NonPagedPool,
418  sizeof(EPROCESS_QUOTA_BLOCK),
420  if (QuotaBlock == NULL)
421  {
423  return STATUS_NO_MEMORY;
424  }
425 
426  /* Initialize the quota block */
427  QuotaBlock->ReferenceCount = 1;
428  QuotaBlock->ProcessCount = 1;
429  QuotaBlock->QuotaEntry[PsNonPagedPool].Peak = Process->QuotaPeak[PsNonPagedPool];
430  QuotaBlock->QuotaEntry[PsPagedPool].Peak = Process->QuotaPeak[PsPagedPool];
431  QuotaBlock->QuotaEntry[PsPageFile].Peak = Process->QuotaPeak[PsPageFile];
435 
436  /* Try to exchange the quota block, if that failed, just drop it */
437  OldQuotaBlock = InterlockedCompareExchangePointer((PVOID*)&Process->QuotaBlock,
438  QuotaBlock,
440  if (OldQuotaBlock == &PspDefaultQuotaBlock)
441  {
442  /* Success, insert the new quota block */
443  PspInsertQuotaBlock(QuotaBlock);
444  }
445  else
446  {
447  /* Failed, free the quota block and ignore it */
448  ExFreePoolWithTag(QuotaBlock, TAG_QUOTA_BLOCK);
449  }
450 
452  }
453  else
454  {
456  }
457 
458  return Status;
459 }
_Must_inspect_result_ typedef _In_ PVOID Unused
Definition: iotypes.h:1166
#define STATUS_PRIVILEGE_NOT_HELD
Definition: DriverTester.h:9
KAPC_STATE
Definition: ketypes.h:1280
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
const LUID SeIncreaseQuotaPrivilege
Definition: priv.c:24
EPROCESS_QUOTA_ENTRY QuotaEntry[PsQuotaTypes]
Definition: pstypes.h:1046
SIZE_T Reserved2
Definition: pstypes.h:75
#define QUOTA_LIMITS_HARDWS_MAX_ENABLE
#define SIZE_T_MAX
Definition: dhcpd.h:91
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define VALID_QUOTA_FLAGS
Definition: quota.c:22
LONG NTSTATUS
Definition: precomp.h:26
#define QUOTA_LIMITS_HARDWS_MIN_DISABLE
VOID NTAPI PspInsertQuotaBlock(PEPROCESS_QUOTA_BLOCK QuotaBlock)
Definition: quota.c:136
NTSTATUS NTAPI MmAdjustWorkingSetSize(IN SIZE_T WorkingSetMinimumInBytes, IN SIZE_T WorkingSetMaximumInBytes, IN ULONG SystemCache, IN BOOLEAN IncreaseOkay)
Definition: mmsup.c:44
_SEH2_TRY
Definition: create.c:4226
EPROCESS_QUOTA_BLOCK PspDefaultQuotaBlock
Definition: quota.c:17
#define FALSE
Definition: types.h:117
VOID NTAPI KeStackAttachProcess(IN PKPROCESS Process, OUT PRKAPC_STATE ApcState)
Definition: procobj.c:704
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
unsigned char BOOLEAN
#define KeLeaveGuardedRegion()
Definition: ke_x.h:68
Status
Definition: gdiplustypes.h:24
_In_ KPROCESSOR_MODE PreviousMode
Definition: sefuncs.h:103
ULONG RateData
Definition: pstypes.h:60
#define QUOTA_LIMITS_HARDWS_MIN_ENABLE
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define ObDereferenceObject
Definition: obfuncs.h:203
#define QUOTA_LIMITS_HARDWS_MAX_DISABLE
#define KeEnterGuardedRegion()
Definition: ke_x.h:39
#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
SIZE_T MaximumWorkingSetSize
Definition: pstypes.h:71
#define TAG_QUOTA_BLOCK
Definition: quota.c:21
_SEH2_END
Definition: create.c:4400
SIZE_T MinimumWorkingSetSize
Definition: pstypes.h:70
SIZE_T WorkingSetLimit
Definition: pstypes.h:74
VOID NTAPI KeUnstackDetachProcess(IN PRKAPC_STATE ApcState)
Definition: procobj.c:756
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
SIZE_T Limit
Definition: pstypes.h:1039
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
BOOLEAN NTAPI SeSinglePrivilegeCheck(_In_ LUID PrivilegeValue, _In_ KPROCESSOR_MODE PreviousMode)
Checks if a single privilege is present in the context of the calling thread.
Definition: priv.c:744
_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 RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
#define STATUS_SUCCESS
Definition: shellext.h:65
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:168
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
SIZE_T Reserved3
Definition: pstypes.h:76
SIZE_T Peak
Definition: pstypes.h:1040
SIZE_T Reserved4
Definition: pstypes.h:77

Referenced by NtSetInformationProcess().

◆ PsReturnPoolQuota()

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

Definition at line 243 of file quota.c.

246 {
247  /* Don't do anything for the system process */
248  if (Process == PsInitialSystemProcess) return;
249 
252  Amount);
253 }
_Must_inspect_result_ _In_ LONGLONG _In_ LONGLONG Amount
Definition: fsrtlfuncs.h:550
#define PAGED_POOL_MASK
Definition: mm.h:107
PEPROCESS PsInitialSystemProcess
Definition: psmgr.c:50
VOID NTAPI PspReturnProcessQuotaSpecifiedPool(IN PEPROCESS Process, IN PS_QUOTA_TYPE QuotaType, IN SIZE_T Amount)
Definition: quota.c:76
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3810

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

◆ PsReturnProcessNonPagedPoolQuota()

VOID NTAPI PsReturnProcessNonPagedPoolQuota ( IN PEPROCESS  Process,
IN SIZE_T  Amount 
)

Definition at line 260 of file quota.c.

262 {
263  /* Don't do anything for the system process */
264  if (Process == PsInitialSystemProcess) return;
265 
267 }
_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:243
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219

Referenced by PspDeleteProcess().

◆ PsReturnProcessPagedPoolQuota()

VOID NTAPI PsReturnProcessPagedPoolQuota ( IN PEPROCESS  Process,
IN SIZE_T  Amount 
)

Definition at line 274 of file quota.c.

276 {
277  /* Don't do anything for the system process */
278  if (Process == PsInitialSystemProcess) return;
279 
281 }
_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:243
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219

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

◆ PsReturnProcessPageFileQuota()

NTSTATUS NTAPI PsReturnProcessPageFileQuota ( IN PEPROCESS  Process,
IN SIZE_T  Amount 
)

Definition at line 288 of file quota.c.

290 {
291  /* Don't do anything for the system process */
293 
295  return STATUS_SUCCESS;
296 }
_Must_inspect_result_ _In_ LONGLONG _In_ LONGLONG Amount
Definition: fsrtlfuncs.h:550
PEPROCESS PsInitialSystemProcess
Definition: psmgr.c:50
VOID NTAPI PspReturnProcessQuotaSpecifiedPool(IN PEPROCESS Process, IN PS_QUOTA_TYPE QuotaType, IN SIZE_T Amount)
Definition: quota.c:76
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
#define STATUS_SUCCESS
Definition: shellext.h:65

Variable Documentation

◆ PspDefaultQuotaBlock

◆ PspQuotaBlockList

LIST_ENTRY PspQuotaBlockList = {&PspQuotaBlockList, &PspQuotaBlockList}
static

Definition at line 18 of file quota.c.

Referenced by PspInsertQuotaBlock().

◆ PspQuotaLock