1c2c66affSColin Finck /*
2c2c66affSColin Finck  * PROJECT:         ReactOS API tests
3c2c66affSColin Finck  * LICENSE:         LGPLv2.1+ - See COPYING.LIB in the top level directory
4c2c66affSColin Finck  * PURPOSE:         Tests for the NtQueryInformationProcess API
5c2c66affSColin Finck  * PROGRAMMER:      Thomas Faber <thomas.faber@reactos.org>
63b53b3d0SGeorge Bișoc  *                  George Bișoc <george.bisoc@reactos.org>
7c2c66affSColin Finck  */
8c2c66affSColin Finck 
9283bbe73SAmine Khaldi #include "precomp.h"
103b53b3d0SGeorge Bișoc #include <internal/ps_i.h>
11c2c66affSColin Finck 
12c2c66affSColin Finck static LARGE_INTEGER TestStartTime;
13c2c66affSColin Finck 
14c2c66affSColin Finck static
15c2c66affSColin Finck void
Test_ProcessTimes(void)16c2c66affSColin Finck Test_ProcessTimes(void)
17c2c66affSColin Finck {
18c2c66affSColin Finck #define SPIN_TIME 1000000
19c2c66affSColin Finck     NTSTATUS Status;
20c2c66affSColin Finck     KERNEL_USER_TIMES Times1;
21c2c66affSColin Finck     KERNEL_USER_TIMES Times2;
22c2c66affSColin Finck     ULONG Length;
23c2c66affSColin Finck     LARGE_INTEGER Time1, Time2;
24c2c66affSColin Finck 
25c2c66affSColin Finck     /* Everything is NULL */
26c2c66affSColin Finck     Status = NtQueryInformationProcess(NULL,
27c2c66affSColin Finck                                        ProcessTimes,
28c2c66affSColin Finck                                        NULL,
29c2c66affSColin Finck                                        0,
30c2c66affSColin Finck                                        NULL);
31c2c66affSColin Finck     ok_hex(Status, STATUS_INFO_LENGTH_MISMATCH);
32c2c66affSColin Finck 
33c2c66affSColin Finck     /* Right size, invalid process */
34c2c66affSColin Finck     Status = NtQueryInformationProcess(NULL,
35c2c66affSColin Finck                                        ProcessTimes,
36c2c66affSColin Finck                                        NULL,
37c2c66affSColin Finck                                        sizeof(KERNEL_USER_TIMES),
38c2c66affSColin Finck                                        NULL);
39c2c66affSColin Finck     ok_hex(Status, STATUS_INVALID_HANDLE);
40c2c66affSColin Finck 
41c2c66affSColin Finck     /* Valid process, no buffer */
42c2c66affSColin Finck     Status = NtQueryInformationProcess(NtCurrentProcess(),
43c2c66affSColin Finck                                        ProcessTimes,
44c2c66affSColin Finck                                        NULL,
45c2c66affSColin Finck                                        0,
46c2c66affSColin Finck                                        NULL);
47c2c66affSColin Finck     ok_hex(Status, STATUS_INFO_LENGTH_MISMATCH);
48c2c66affSColin Finck 
49c2c66affSColin Finck     /* Unaligned buffer, wrong size */
50c2c66affSColin Finck     Status = NtQueryInformationProcess(NtCurrentProcess(),
51c2c66affSColin Finck                                        ProcessTimes,
52c2c66affSColin Finck                                        (PVOID)2,
53c2c66affSColin Finck                                        0,
54c2c66affSColin Finck                                        NULL);
55c2c66affSColin Finck     ok_hex(Status, STATUS_INFO_LENGTH_MISMATCH);
56c2c66affSColin Finck 
57c2c66affSColin Finck     /* Unaligned buffer, correct size */
58c2c66affSColin Finck     Status = NtQueryInformationProcess(NtCurrentProcess(),
59c2c66affSColin Finck                                        ProcessTimes,
60c2c66affSColin Finck                                        (PVOID)2,
61c2c66affSColin Finck                                        sizeof(KERNEL_USER_TIMES),
62c2c66affSColin Finck                                        NULL);
63c2c66affSColin Finck     ok_hex(Status, STATUS_DATATYPE_MISALIGNMENT);
64c2c66affSColin Finck 
65c2c66affSColin Finck     /* Buffer too small */
66c2c66affSColin Finck     Status = NtQueryInformationProcess(NtCurrentProcess(),
67c2c66affSColin Finck                                        ProcessTimes,
68c2c66affSColin Finck                                        NULL,
69c2c66affSColin Finck                                        sizeof(KERNEL_USER_TIMES) - 1,
70c2c66affSColin Finck                                        NULL);
71c2c66affSColin Finck     ok_hex(Status, STATUS_INFO_LENGTH_MISMATCH);
72c2c66affSColin Finck 
73c2c66affSColin Finck     /* Right buffer size but NULL pointer */
74c2c66affSColin Finck     Status = NtQueryInformationProcess(NtCurrentProcess(),
75c2c66affSColin Finck                                        ProcessTimes,
76c2c66affSColin Finck                                        NULL,
77c2c66affSColin Finck                                        sizeof(KERNEL_USER_TIMES),
78c2c66affSColin Finck                                        NULL);
79c2c66affSColin Finck     ok_hex(Status, STATUS_ACCESS_VIOLATION);
80c2c66affSColin Finck 
81c2c66affSColin Finck     /* Buffer too large */
82c2c66affSColin Finck     Status = NtQueryInformationProcess(NtCurrentProcess(),
83c2c66affSColin Finck                                        ProcessTimes,
84c2c66affSColin Finck                                        NULL,
85c2c66affSColin Finck                                        sizeof(KERNEL_USER_TIMES) + 1,
86c2c66affSColin Finck                                        NULL);
87c2c66affSColin Finck     ok_hex(Status, STATUS_INFO_LENGTH_MISMATCH);
88c2c66affSColin Finck 
89c2c66affSColin Finck     /* Buffer too small, ask for length */
90c2c66affSColin Finck     Length = 0x55555555;
91c2c66affSColin Finck     Status = NtQueryInformationProcess(NtCurrentProcess(),
92c2c66affSColin Finck                                        ProcessTimes,
93c2c66affSColin Finck                                        NULL,
94c2c66affSColin Finck                                        sizeof(KERNEL_USER_TIMES) - 1,
95c2c66affSColin Finck                                        &Length);
96c2c66affSColin Finck     ok_hex(Status, STATUS_INFO_LENGTH_MISMATCH);
97c2c66affSColin Finck     ok_dec(Length, 0x55555555);
98c2c66affSColin Finck 
99c2c66affSColin Finck     Status = NtQuerySystemTime(&Time1);
100c2c66affSColin Finck     ok_hex(Status, STATUS_SUCCESS);
101c2c66affSColin Finck 
102c2c66affSColin Finck     /* Do some busy waiting to increase UserTime */
103c2c66affSColin Finck     do
104c2c66affSColin Finck     {
105c2c66affSColin Finck         Status = NtQuerySystemTime(&Time2);
106c2c66affSColin Finck         if (!NT_SUCCESS(Status))
107c2c66affSColin Finck         {
108c2c66affSColin Finck             ok(0, "NtQuerySystemTime failed with %lx\n", Status);
109c2c66affSColin Finck             break;
110c2c66affSColin Finck         }
111c2c66affSColin Finck     } while (Time2.QuadPart - Time1.QuadPart < SPIN_TIME);
112c2c66affSColin Finck 
113c2c66affSColin Finck     /* Valid parameters, no return length */
114c2c66affSColin Finck     Status = NtQuerySystemTime(&Time1);
115c2c66affSColin Finck     ok_hex(Status, STATUS_SUCCESS);
116c2c66affSColin Finck 
117c2c66affSColin Finck     RtlFillMemory(&Times1, sizeof(Times1), 0x55);
118c2c66affSColin Finck     Status = NtQueryInformationProcess(NtCurrentProcess(),
119c2c66affSColin Finck                                        ProcessTimes,
120c2c66affSColin Finck                                        &Times1,
121c2c66affSColin Finck                                        sizeof(KERNEL_USER_TIMES),
122c2c66affSColin Finck                                        NULL);
123c2c66affSColin Finck     ok_hex(Status, STATUS_SUCCESS);
124c2c66affSColin Finck     ok(Times1.CreateTime.QuadPart < TestStartTime.QuadPart,
125c2c66affSColin Finck        "CreateTime is %I64u, expected < %I64u\n", Times1.CreateTime.QuadPart, TestStartTime.QuadPart);
126c2c66affSColin Finck     ok(Times1.CreateTime.QuadPart > TestStartTime.QuadPart - 100000000LL,
127c2c66affSColin Finck        "CreateTime is %I64u, expected > %I64u\n", Times1.CreateTime.QuadPart, TestStartTime.QuadPart - 100000000LL);
128c2c66affSColin Finck     ok(Times1.ExitTime.QuadPart == 0,
129c2c66affSColin Finck        "ExitTime is %I64u, expected 0\n", Times1.ExitTime.QuadPart);
130c2c66affSColin Finck     ok(Times1.KernelTime.QuadPart != 0, "KernelTime is 0\n");
131e26c8bc6STimo Kreuzer     ros_skip_flaky
132c2c66affSColin Finck     ok(Times1.UserTime.QuadPart != 0, "UserTime is 0\n");
133c2c66affSColin Finck 
134c2c66affSColin Finck     /* Do some busy waiting to increase UserTime */
135c2c66affSColin Finck     do
136c2c66affSColin Finck     {
137c2c66affSColin Finck         Status = NtQuerySystemTime(&Time2);
138c2c66affSColin Finck         if (!NT_SUCCESS(Status))
139c2c66affSColin Finck         {
140c2c66affSColin Finck             ok(0, "NtQuerySystemTime failed with %lx\n", Status);
141c2c66affSColin Finck             break;
142c2c66affSColin Finck         }
143c2c66affSColin Finck     } while (Time2.QuadPart - Time1.QuadPart < SPIN_TIME);
144c2c66affSColin Finck 
145c2c66affSColin Finck     /* Again, this time with a return length */
146c2c66affSColin Finck     Length = 0x55555555;
147c2c66affSColin Finck     RtlFillMemory(&Times2, sizeof(Times2), 0x55);
148c2c66affSColin Finck     Status = NtQueryInformationProcess(NtCurrentProcess(),
149c2c66affSColin Finck                                        ProcessTimes,
150c2c66affSColin Finck                                        &Times2,
151c2c66affSColin Finck                                        sizeof(KERNEL_USER_TIMES),
152c2c66affSColin Finck                                        &Length);
153c2c66affSColin Finck     ok_hex(Status, STATUS_SUCCESS);
154c2c66affSColin Finck     ok_dec(Length, sizeof(KERNEL_USER_TIMES));
155c2c66affSColin Finck     ok(Times1.CreateTime.QuadPart == Times2.CreateTime.QuadPart,
156c2c66affSColin Finck        "CreateTimes not equal: %I64u != %I64u\n", Times1.CreateTime.QuadPart, Times2.CreateTime.QuadPart);
157c2c66affSColin Finck     ok(Times2.ExitTime.QuadPart == 0,
158c2c66affSColin Finck        "ExitTime is %I64u, expected 0\n", Times2.ExitTime.QuadPart);
159c2c66affSColin Finck     ok(Times2.KernelTime.QuadPart != 0, "KernelTime is 0\n");
160c2c66affSColin Finck     ok(Times2.UserTime.QuadPart != 0, "UserTime is 0\n");
161c2c66affSColin Finck 
162c2c66affSColin Finck     /* Compare the two sets of KernelTime/UserTime values */
163c2c66affSColin Finck     Status = NtQuerySystemTime(&Time2);
164c2c66affSColin Finck     ok_hex(Status, STATUS_SUCCESS);
165c2c66affSColin Finck     /* Time values must have increased */
166c2c66affSColin Finck     ok(Times2.KernelTime.QuadPart > Times1.KernelTime.QuadPart,
167c2c66affSColin Finck        "KernelTime values inconsistent. Expected %I64u > %I64u\n", Times2.KernelTime.QuadPart, Times1.KernelTime.QuadPart);
168e26c8bc6STimo Kreuzer     ros_skip_flaky
169c2c66affSColin Finck     ok(Times2.UserTime.QuadPart > Times1.UserTime.QuadPart,
170c2c66affSColin Finck        "UserTime values inconsistent. Expected %I64u > %I64u\n", Times2.UserTime.QuadPart, Times1.UserTime.QuadPart);
171c2c66affSColin Finck     /* They can't have increased by more than wall clock time difference (we only have one thread) */
172e26c8bc6STimo Kreuzer     ros_skip_flaky
173c2c66affSColin Finck     ok(Times2.KernelTime.QuadPart - Times1.KernelTime.QuadPart < Time2.QuadPart - Time1.QuadPart,
174c2c66affSColin Finck        "KernelTime values inconsistent. Expected %I64u - %I64u < %I64u\n",
175c2c66affSColin Finck        Times2.KernelTime.QuadPart, Times1.KernelTime.QuadPart, Time2.QuadPart - Time1.QuadPart);
176c2c66affSColin Finck     ok(Times2.UserTime.QuadPart - Times1.UserTime.QuadPart < Time2.QuadPart - Time1.QuadPart,
177c2c66affSColin Finck        "UserTime values inconsistent. Expected %I64u - %I64u < %I64u\n",
178c2c66affSColin Finck        Times2.UserTime.QuadPart, Times1.UserTime.QuadPart, Time2.QuadPart - Time1.QuadPart);
179c2c66affSColin Finck 
180c2c66affSColin Finck     trace("KernelTime1 = %I64u\n", Times1.KernelTime.QuadPart);
181c2c66affSColin Finck     trace("KernelTime2 = %I64u\n", Times2.KernelTime.QuadPart);
182c2c66affSColin Finck     trace("UserTime1 = %I64u\n", Times1.UserTime.QuadPart);
183c2c66affSColin Finck     trace("UserTime2 = %I64u\n", Times2.UserTime.QuadPart);
184c2c66affSColin Finck 
185c2c66affSColin Finck     /* TODO: Test ExitTime on a terminated process */
186c2c66affSColin Finck #undef SPIN_TIME
187c2c66affSColin Finck }
188c2c66affSColin Finck 
189fcb15638SBișoc George static
190fcb15638SBișoc George void
Test_ProcessPriorityClassAlignment(void)191fcb15638SBișoc George Test_ProcessPriorityClassAlignment(void)
192fcb15638SBișoc George {
193fcb15638SBișoc George     NTSTATUS Status;
194fcb15638SBișoc George     PPROCESS_PRIORITY_CLASS ProcPriority;
195fcb15638SBișoc George 
196fcb15638SBișoc George     /* Allocate some memory for the priority class structure */
197fcb15638SBișoc George     ProcPriority = malloc(sizeof(PROCESS_PRIORITY_CLASS));
198fcb15638SBișoc George     if (ProcPriority == NULL)
199fcb15638SBișoc George     {
200fcb15638SBișoc George         skip("Failed to allocate memory for PROCESS_PRIORITY_CLASS!\n");
201fcb15638SBișoc George         return;
202fcb15638SBișoc George     }
203fcb15638SBișoc George 
204fcb15638SBișoc George     /*
205fcb15638SBișoc George      * Initialize the PriorityClass member to ensure the test won't randomly succeed (if such data is uninitialized).
206fcb15638SBișoc George      * Filling 85 to the data member makes sure that if the test fails continously then NtQueryInformationProcess()
207fcb15638SBișoc George      * didn't initialize the structure with data.
208fcb15638SBișoc George      */
209fcb15638SBișoc George     RtlFillMemory(&ProcPriority->PriorityClass, sizeof(ProcPriority->PriorityClass), 0x55);
210fcb15638SBișoc George 
211fcb15638SBișoc George     /* Unaligned buffer -- wrong size */
212fcb15638SBișoc George     Status = NtQueryInformationProcess(NtCurrentProcess(),
213fcb15638SBișoc George                                        ProcessPriorityClass,
214fcb15638SBișoc George                                        (PVOID)1,
215fcb15638SBișoc George                                        0,
216fcb15638SBișoc George                                        NULL);
217fcb15638SBișoc George     ok_hex(Status, STATUS_INFO_LENGTH_MISMATCH);
218fcb15638SBișoc George 
219fcb15638SBișoc George     /* Unaligned buffer -- correct size */
220fcb15638SBișoc George     Status = NtQueryInformationProcess(NtCurrentProcess(),
221fcb15638SBișoc George                                        ProcessPriorityClass,
222fcb15638SBișoc George                                        (PVOID)1,
223fcb15638SBișoc George                                        sizeof(PROCESS_PRIORITY_CLASS),
224fcb15638SBișoc George                                        NULL);
225fcb15638SBișoc George     ok_hex(Status, STATUS_DATATYPE_MISALIGNMENT);
226fcb15638SBișoc George 
227fcb15638SBișoc George     /* Unaligned buffer -- wrong size (but this time do with an alignment of 2) */
228fcb15638SBișoc George     Status = NtQueryInformationProcess(NtCurrentProcess(),
229fcb15638SBișoc George                                        ProcessPriorityClass,
230fcb15638SBișoc George                                        (PVOID)2,
231fcb15638SBișoc George                                        0,
232fcb15638SBișoc George                                        NULL);
233fcb15638SBișoc George     ok_hex(Status, STATUS_INFO_LENGTH_MISMATCH);
234fcb15638SBișoc George 
235fcb15638SBișoc George     /* Unaligned buffer -- correct size (but this time do with an alignment of 2) */
236fcb15638SBișoc George     Status = NtQueryInformationProcess(NtCurrentProcess(),
237fcb15638SBișoc George                                        ProcessPriorityClass,
238fcb15638SBișoc George                                        (PVOID)2,
239fcb15638SBișoc George                                        sizeof(PROCESS_PRIORITY_CLASS),
240fcb15638SBișoc George                                        NULL);
241fcb15638SBișoc George     ok_hex(Status, STATUS_DATATYPE_MISALIGNMENT);
242fcb15638SBișoc George 
243fcb15638SBișoc George     /* Do not care for the length but expect to return the priority class */
244fcb15638SBișoc George     Status = NtQueryInformationProcess(NtCurrentProcess(),
245fcb15638SBișoc George                                        ProcessPriorityClass,
246fcb15638SBișoc George                                        ProcPriority,
247fcb15638SBișoc George                                        sizeof(PROCESS_PRIORITY_CLASS),
248fcb15638SBișoc George                                        NULL);
249fcb15638SBișoc George     ok_hex(Status, STATUS_SUCCESS);
250fcb15638SBișoc George 
251fcb15638SBișoc George     /* Make sure the returned priority class is a valid number (non negative) but also it should be within the PROCESS_PRIORITY_CLASS range */
252fcb15638SBișoc George     ok(ProcPriority->PriorityClass > PROCESS_PRIORITY_CLASS_INVALID && ProcPriority->PriorityClass <= PROCESS_PRIORITY_CLASS_ABOVE_NORMAL,
253fcb15638SBișoc George        "Expected a valid number from priority class range but got %d\n", ProcPriority->PriorityClass);
254fcb15638SBișoc George     free(ProcPriority);
255fcb15638SBișoc George }
256fcb15638SBișoc George 
25738c01a84SGeorge Bișoc static
25838c01a84SGeorge Bișoc void
Test_ProcessWx86Information(void)25938c01a84SGeorge Bișoc Test_ProcessWx86Information(void)
26038c01a84SGeorge Bișoc {
26138c01a84SGeorge Bișoc     NTSTATUS Status;
26238c01a84SGeorge Bișoc     ULONG VdmPower = 1, ReturnLength;
26338c01a84SGeorge Bișoc 
26438c01a84SGeorge Bișoc     /* Everything is NULL */
26538c01a84SGeorge Bișoc     Status = NtQueryInformationProcess(NULL,
26638c01a84SGeorge Bișoc                                        ProcessWx86Information,
26738c01a84SGeorge Bișoc                                        NULL,
26838c01a84SGeorge Bișoc                                        0,
26938c01a84SGeorge Bișoc                                        NULL);
27038c01a84SGeorge Bișoc     ok_hex(Status, STATUS_INFO_LENGTH_MISMATCH);
27138c01a84SGeorge Bișoc 
27238c01a84SGeorge Bișoc     /* Given an invalid process handle */
27338c01a84SGeorge Bișoc     Status = NtQueryInformationProcess(NULL,
27438c01a84SGeorge Bișoc                                        ProcessWx86Information,
27538c01a84SGeorge Bișoc                                        &VdmPower,
27638c01a84SGeorge Bișoc                                        sizeof(VdmPower),
27738c01a84SGeorge Bișoc                                        NULL);
27838c01a84SGeorge Bișoc     ok_hex(Status, STATUS_INVALID_HANDLE);
27938c01a84SGeorge Bișoc 
28038c01a84SGeorge Bișoc     /* Don't query anything */
28138c01a84SGeorge Bișoc     Status = NtQueryInformationProcess(NtCurrentProcess(),
28238c01a84SGeorge Bișoc                                        ProcessWx86Information,
28338c01a84SGeorge Bișoc                                        NULL,
28438c01a84SGeorge Bișoc                                        sizeof(VdmPower),
28538c01a84SGeorge Bișoc                                        NULL);
28638c01a84SGeorge Bișoc     ok_hex(Status, STATUS_ACCESS_VIOLATION);
28738c01a84SGeorge Bișoc 
28838c01a84SGeorge Bișoc     /* The buffer is misaligned and information length is wrong */
28938c01a84SGeorge Bișoc     Status = NtQueryInformationProcess(NtCurrentProcess(),
29038c01a84SGeorge Bișoc                                        ProcessWx86Information,
29138c01a84SGeorge Bișoc                                        (PVOID)1,
29238c01a84SGeorge Bișoc                                        0,
29338c01a84SGeorge Bișoc                                        NULL);
29438c01a84SGeorge Bișoc     ok_hex(Status, STATUS_INFO_LENGTH_MISMATCH);
29538c01a84SGeorge Bișoc 
29638c01a84SGeorge Bișoc     /* The buffer is misaligned */
29738c01a84SGeorge Bișoc     Status = NtQueryInformationProcess(NtCurrentProcess(),
29838c01a84SGeorge Bișoc                                        ProcessWx86Information,
29938c01a84SGeorge Bișoc                                        (PVOID)1,
30038c01a84SGeorge Bișoc                                        sizeof(VdmPower),
30138c01a84SGeorge Bișoc                                        NULL);
30238c01a84SGeorge Bișoc     ok_hex(Status, STATUS_DATATYPE_MISALIGNMENT);
30338c01a84SGeorge Bișoc 
30438c01a84SGeorge Bișoc     /* The buffer is misaligned -- try with an alignment size of 2 */
30538c01a84SGeorge Bișoc     Status = NtQueryInformationProcess(NtCurrentProcess(),
30638c01a84SGeorge Bișoc                                        ProcessWx86Information,
30738c01a84SGeorge Bișoc                                        (PVOID)2,
30838c01a84SGeorge Bișoc                                        sizeof(VdmPower),
30938c01a84SGeorge Bișoc                                        NULL);
31038c01a84SGeorge Bișoc     ok_hex(Status, STATUS_DATATYPE_MISALIGNMENT);
31138c01a84SGeorge Bișoc 
31238c01a84SGeorge Bișoc     /* Query the VDM power */
31338c01a84SGeorge Bișoc     Status = NtQueryInformationProcess(NtCurrentProcess(),
31438c01a84SGeorge Bișoc                                        ProcessWx86Information,
31538c01a84SGeorge Bișoc                                        &VdmPower,
31638c01a84SGeorge Bișoc                                        sizeof(VdmPower),
317*d575e828SHermès Bélusca-Maïto                                        NULL);
318*d575e828SHermès Bélusca-Maïto     ok_hex(Status, STATUS_SUCCESS);
319*d575e828SHermès Bélusca-Maïto     ok(VdmPower == 0 || VdmPower == 1, "The VDM power value must be within the boundary between 0 and 1, not anything else! Got %lu\n", VdmPower);
320*d575e828SHermès Bélusca-Maïto 
321*d575e828SHermès Bélusca-Maïto     /* Same but with ReturnLength */
322*d575e828SHermès Bélusca-Maïto     Status = NtQueryInformationProcess(NtCurrentProcess(),
323*d575e828SHermès Bélusca-Maïto                                        ProcessWx86Information,
324*d575e828SHermès Bélusca-Maïto                                        &VdmPower,
325*d575e828SHermès Bélusca-Maïto                                        sizeof(VdmPower),
32638c01a84SGeorge Bișoc                                        &ReturnLength);
32738c01a84SGeorge Bișoc     ok_hex(Status, STATUS_SUCCESS);
32838c01a84SGeorge Bișoc     ok(ReturnLength != 0, "ReturnLength shouldn't be 0!\n");
32938c01a84SGeorge Bișoc     ok(VdmPower == 0 || VdmPower == 1, "The VDM power value must be within the boundary between 0 and 1, not anything else! Got %lu\n", VdmPower);
33038c01a84SGeorge Bișoc 
33138c01a84SGeorge Bișoc     /* Trace the VDM power value and returned length */
33238c01a84SGeorge Bișoc     trace("ReturnLength = %lu\n", ReturnLength);
33338c01a84SGeorge Bișoc     trace("VdmPower = %lu\n", VdmPower);
33438c01a84SGeorge Bișoc }
33538c01a84SGeorge Bișoc 
3363b53b3d0SGeorge Bișoc static
3373b53b3d0SGeorge Bișoc void
Test_ProcQueryAlignmentProbe(void)3383b53b3d0SGeorge Bișoc Test_ProcQueryAlignmentProbe(void)
3393b53b3d0SGeorge Bișoc {
3403b53b3d0SGeorge Bișoc     ULONG InfoClass;
3413b53b3d0SGeorge Bișoc 
3423b53b3d0SGeorge Bișoc     /* Iterate over the process info classes and begin the tests */
3433b53b3d0SGeorge Bișoc     for (InfoClass = 0; InfoClass < _countof(PsProcessInfoClass); InfoClass++)
3443b53b3d0SGeorge Bișoc     {
3453b53b3d0SGeorge Bișoc         /* The buffer is misaligned */
3463b53b3d0SGeorge Bișoc         QuerySetProcessValidator(QUERY,
3473b53b3d0SGeorge Bișoc                                  InfoClass,
3483b53b3d0SGeorge Bișoc                                  (PVOID)(ULONG_PTR)1,
3493b53b3d0SGeorge Bișoc                                  PsProcessInfoClass[InfoClass].RequiredSizeQUERY,
3503b53b3d0SGeorge Bișoc                                  STATUS_DATATYPE_MISALIGNMENT);
3513b53b3d0SGeorge Bișoc 
3523b53b3d0SGeorge Bișoc         /* We query an invalid buffer address */
3533b53b3d0SGeorge Bișoc         QuerySetProcessValidator(QUERY,
3543b53b3d0SGeorge Bișoc                                  InfoClass,
3553b53b3d0SGeorge Bișoc                                  (PVOID)(ULONG_PTR)PsProcessInfoClass[InfoClass].AlignmentQUERY,
3563b53b3d0SGeorge Bișoc                                  PsProcessInfoClass[InfoClass].RequiredSizeQUERY,
3573b53b3d0SGeorge Bișoc                                  STATUS_ACCESS_VIOLATION);
3583b53b3d0SGeorge Bișoc 
3593b53b3d0SGeorge Bișoc         /* The information length is wrong */
3603b53b3d0SGeorge Bișoc         QuerySetProcessValidator(QUERY,
3613b53b3d0SGeorge Bișoc                                  InfoClass,
3623b53b3d0SGeorge Bișoc                                  (PVOID)(ULONG_PTR)PsProcessInfoClass[InfoClass].AlignmentQUERY,
3633b53b3d0SGeorge Bișoc                                  PsProcessInfoClass[InfoClass].RequiredSizeQUERY - 1,
3643b53b3d0SGeorge Bișoc                                  STATUS_INFO_LENGTH_MISMATCH);
3653b53b3d0SGeorge Bișoc     }
3663b53b3d0SGeorge Bișoc }
3673b53b3d0SGeorge Bișoc 
START_TEST(NtQueryInformationProcess)368c2c66affSColin Finck START_TEST(NtQueryInformationProcess)
369c2c66affSColin Finck {
370c2c66affSColin Finck     NTSTATUS Status;
371c2c66affSColin Finck 
372ec9f3d82SColin Finck     /* Make sure that some time has passed since process creation, even if the resolution of our NtQuerySystemTime is low. */
373ec9f3d82SColin Finck     Sleep(1);
374ec9f3d82SColin Finck 
375c2c66affSColin Finck     Status = NtQuerySystemTime(&TestStartTime);
376c2c66affSColin Finck     ok_hex(Status, STATUS_SUCCESS);
377c2c66affSColin Finck 
378c2c66affSColin Finck     Test_ProcessTimes();
379fcb15638SBișoc George     Test_ProcessPriorityClassAlignment();
38038c01a84SGeorge Bișoc     Test_ProcessWx86Information();
3813b53b3d0SGeorge Bișoc     Test_ProcQueryAlignmentProbe();
382c2c66affSColin Finck }
383