ReactOS 0.4.15-dev-7842-g558ab78
PsQuota.c File Reference
#include <kmt_test.h>
Include dependency graph for PsQuota.c:

Go to the source code of this file.

Functions

 START_TEST (PsQuota)
 

Function Documentation

◆ START_TEST()

START_TEST ( PsQuota  )

Definition at line 10 of file PsQuota.c.

11{
13 VM_COUNTERS VmCounters;
14 QUOTA_LIMITS QuotaLimits;
15 SIZE_T NonPagedUsage, PagedUsage;
17
18 /* Guard the quota operations in a guarded region */
20
21 /* Report the current process' quota limits */
24 &QuotaLimits,
25 sizeof(QuotaLimits),
26 NULL);
27 if (skip(NT_SUCCESS(Status), "Failed to query quota limits -- %lx\n", Status))
28 {
29 return;
30 }
31
32 trace("Process paged pool quota limit -- %lu\n", QuotaLimits.PagedPoolLimit);
33 trace("Process non paged pool quota limit -- %lu\n", QuotaLimits.NonPagedPoolLimit);
34 trace("Process page file quota limit -- %lu\n\n", QuotaLimits.PagefileLimit);
35
36 /* Query the quota usage */
39 &VmCounters,
40 sizeof(VmCounters),
41 NULL);
42 if (skip(NT_SUCCESS(Status), "Failed to query quota usage -- %lx\n", Status))
43 {
44 return;
45 }
46
47 /* Test that quotas usage are within limits */
48 ok(VmCounters.QuotaNonPagedPoolUsage < QuotaLimits.NonPagedPoolLimit, "Non paged quota over limits (usage -> %lu || limit -> %lu)\n",
49 VmCounters.QuotaNonPagedPoolUsage, QuotaLimits.NonPagedPoolLimit);
50 ok(VmCounters.QuotaPagedPoolUsage < QuotaLimits.PagedPoolLimit, "Paged quota over limits (usage -> %lu || limit -> %lu)\n",
51 VmCounters.QuotaPagedPoolUsage, QuotaLimits.PagedPoolLimit);
52
53 /* Cache the quota usage pools for later checks */
54 NonPagedUsage = VmCounters.QuotaNonPagedPoolUsage;
55 PagedUsage = VmCounters.QuotaPagedPoolUsage;
56
57 /* Charge some paged and non paged quotas */
59 ok_irql(PASSIVE_LEVEL);
61
63 ok_irql(PASSIVE_LEVEL);
65
66 /* Query the quota usage again */
69 &VmCounters,
70 sizeof(VmCounters),
71 NULL);
72 if (skip(NT_SUCCESS(Status), "Failed to query quota usage -- %lx\n", Status))
73 {
74 return;
75 }
76
77
78 /* Test again the usage that's within limits */
79 ok(VmCounters.QuotaNonPagedPoolUsage < QuotaLimits.NonPagedPoolLimit, "Non paged quota over limits (usage -> %lu || limit -> %lu)\n",
80 VmCounters.QuotaNonPagedPoolUsage, QuotaLimits.NonPagedPoolLimit);
81 ok(VmCounters.QuotaPagedPoolUsage < QuotaLimits.PagedPoolLimit, "Paged quota over limits (usage -> %lu || limit -> %lu)\n",
82 VmCounters.QuotaPagedPoolUsage, QuotaLimits.PagedPoolLimit);
83
84 /*
85 * Make sure the results are consistent, that nobody else
86 * is charging quotas other than us.
87 */
88 ok_eq_size(VmCounters.QuotaNonPagedPoolUsage, NonPagedUsage + 0x200);
89 ok_eq_size(VmCounters.QuotaPagedPoolUsage, PagedUsage + 0x500);
90
91 /* Report the quota usage */
92 trace("=== QUOTA USAGE AFTER CHARGE ===\n\n");
93 trace("Process paged pool quota usage -- %lu\n", VmCounters.QuotaPagedPoolUsage);
94 trace("Process paged pool quota peak -- %lu\n", VmCounters.QuotaPeakPagedPoolUsage);
95 trace("Process non paged pool quota usage -- %lu\n", VmCounters.QuotaNonPagedPoolUsage);
96 trace("Process non paged pool quota peak -- %lu\n", VmCounters.QuotaPeakNonPagedPoolUsage);
97 trace("Process page file quota usage -- %lu\n", VmCounters.PagefileUsage);
98 trace("Process page file quota peak -- %lu\n\n", VmCounters.PeakPagefileUsage);
99
100 /* Return the quotas we've charged up */
103
104 /* Query the quota usage again */
107 &VmCounters,
108 sizeof(VmCounters),
109 NULL);
110 if (skip(NT_SUCCESS(Status), "Failed to query quota usage -- %lx\n", Status))
111 {
112 return;
113 }
114
115 /*
116 * Check that nobody else has returned quotas
117 * but only us.
118 */
119 ok_eq_size(VmCounters.QuotaNonPagedPoolUsage, NonPagedUsage);
120 ok_eq_size(VmCounters.QuotaPagedPoolUsage, PagedUsage);
121
122 /* Report the usage again */
123 trace("=== QUOTA USAGE AFTER RETURN ===\n\n");
124 trace("Process paged pool quota usage -- %lu\n", VmCounters.QuotaPagedPoolUsage);
125 trace("Process paged pool quota peak -- %lu\n", VmCounters.QuotaPeakPagedPoolUsage);
126 trace("Process non paged pool quota usage -- %lu\n", VmCounters.QuotaNonPagedPoolUsage);
127 trace("Process non paged pool quota peak -- %lu\n", VmCounters.QuotaPeakNonPagedPoolUsage);
128 trace("Process page file quota usage -- %lu\n", VmCounters.PagefileUsage);
129 trace("Process page file quota peak -- %lu\n\n", VmCounters.PeakPagefileUsage);
130
131 /* We're done, leave the region */
133}
#define ok_eq_hex(value, expected)
Definition: apitest.h:76
#define ok_eq_size(value, expected)
Definition: apitest.h:68
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
Status
Definition: gdiplustypes.h:25
@ ProcessVmCounters
Definition: winternl.h:859
@ ProcessQuotaLimits
Definition: winternl.h:857
#define KeLeaveGuardedRegion()
Definition: ke_x.h:68
#define KeEnterGuardedRegion()
Definition: ke_x.h:39
NTSYSAPI NTSTATUS NTAPI ZwQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_ PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
#define NtCurrentProcess()
Definition: nt_native.h:1657
NTSTATUS NTAPI PsChargeProcessNonPagedPoolQuota(_In_ PEPROCESS Process, _In_ SIZE_T Amount)
Charges the non paged pool quota of a given process.
Definition: quota.c:811
VOID NTAPI PsReturnProcessNonPagedPoolQuota(_In_ PEPROCESS Process, _In_ SIZE_T Amount)
Returns the non paged quota pool that the process was taking up.
Definition: quota.c:938
VOID NTAPI PsReturnProcessPagedPoolQuota(_In_ PEPROCESS Process, _In_ SIZE_T Amount)
Returns the paged pool quota that the process was taking up.
Definition: quota.c:965
NTSTATUS NTAPI PsChargeProcessPagedPoolQuota(_In_ PEPROCESS Process, _In_ SIZE_T Amount)
Charges the paged pool quota of a given process.
Definition: quota.c:839
#define STATUS_SUCCESS
Definition: shellext.h:65
INT64 NonPagedPoolLimit
Definition: lsa.idl:288
INT64 PagefileLimit
Definition: lsa.idl:291
INT64 PagedPoolLimit
Definition: lsa.idl:287
SIZE_T QuotaPeakPagedPoolUsage
Definition: winternl.h:1610
SIZE_T QuotaPeakNonPagedPoolUsage
Definition: winternl.h:1612
SIZE_T PeakPagefileUsage
Definition: winternl.h:1615
SIZE_T QuotaNonPagedPoolUsage
Definition: winternl.h:1613
SIZE_T PagefileUsage
Definition: winternl.h:1614
SIZE_T QuotaPagedPoolUsage
Definition: winternl.h:1611
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define PsGetCurrentProcess
Definition: psfuncs.h:17