1 /*
2  * PROJECT:         ReactOS api tests
3  * LICENSE:         GPL - See COPYING in the top level directory
4  * PURPOSE:         Test for NtQuery/SetSystemInformation
5  * PROGRAMMERS:     Timo Kreuzer
6  *                  Thomas Faber <thomas.faber@reactos.org>
7  */
8 
9 #include "precomp.h"
10 #include <versionhelpers.h>
11 
12 #define ntv6(x) (LOBYTE(LOWORD(GetVersion())) >= 6 ? (x) : 0)
13 
14 static
15 void
Test_Flags(void)16 Test_Flags(void)
17 {
18     NTSTATUS Status;
19     ULONG ReturnLength;
20     ULONG Flags;
21     ULONG Buffer[2];
22     ULONG Buffer2[2];
23     PSYSTEM_FLAGS_INFORMATION FlagsInfo = (PVOID)Buffer;
24     BOOLEAN PrivilegeEnabled;
25 
26     /* Make sure we don't have debug privileges initially, otherwise WHS testbot fails */
27     Status = RtlAdjustPrivilege(SE_SYSTEMTIME_PRIVILEGE, FALSE, FALSE, &PrivilegeEnabled);
28     ok(Status == STATUS_SUCCESS, "RtlAdjustPrivilege returned %lx\n", Status);
29 
30     /* Query */
31     ReturnLength = 0x55555555;
32     Status = NtQuerySystemInformation(SystemFlagsInformation, NULL, 0, &ReturnLength);
33     ok(Status == STATUS_INFO_LENGTH_MISMATCH, "NtQuerySystemInformation returned %lx\n", Status);
34     ok(ReturnLength == 0 ||
35        ntv6(ReturnLength == sizeof(SYSTEM_FLAGS_INFORMATION)), "ReturnLength = %lu\n", ReturnLength);
36 
37     ReturnLength = 0x55555555;
38     Status = NtQuerySystemInformation(SystemFlagsInformation, NULL, sizeof(SYSTEM_FLAGS_INFORMATION) - 1, &ReturnLength);
39     ok(Status == STATUS_ACCESS_VIOLATION, "NtQuerySystemInformation returned %lx\n", Status);
40     ok(ReturnLength == 0x55555555, "ReturnLength = %lu\n", ReturnLength);
41 
42     ReturnLength = 0x55555555;
43     Status = NtQuerySystemInformation(SystemFlagsInformation, (PVOID)2, 0, &ReturnLength);
44     ok(Status == STATUS_INFO_LENGTH_MISMATCH, "NtQuerySystemInformation returned %lx\n", Status);
45     ok(ReturnLength == 0 ||
46        ntv6(ReturnLength == sizeof(SYSTEM_FLAGS_INFORMATION)), "ReturnLength = %lu\n", ReturnLength);
47 
48     ReturnLength = 0x55555555;
49     Status = NtQuerySystemInformation(SystemFlagsInformation, (PVOID)4, 0, &ReturnLength);
50     ok(Status == STATUS_INFO_LENGTH_MISMATCH, "NtQuerySystemInformation returned %lx\n", Status);
51     ok(ReturnLength == 0 ||
52        ntv6(ReturnLength == sizeof(SYSTEM_FLAGS_INFORMATION)), "ReturnLength = %lu\n", ReturnLength);
53 
54     ReturnLength = 0x55555555;
55     RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
56     Status = NtQuerySystemInformation(SystemFlagsInformation, (PUCHAR)FlagsInfo + 2, sizeof(SYSTEM_FLAGS_INFORMATION), &ReturnLength);
57     ok(Status == STATUS_DATATYPE_MISALIGNMENT, "NtQuerySystemInformation returned %lx\n", Status);
58     ok(ReturnLength == 0x55555555, "ReturnLength = %lu\n", ReturnLength);
59     ok(Buffer[0] == 0x55555555, "Buffer[0] = %lx\n", Buffer[0]);
60     ok(Buffer[1] == 0x55555555, "Buffer[1] = %lx\n", Buffer[1]);
61 
62     ReturnLength = 0x55555555;
63     RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
64     Status = NtQuerySystemInformation(SystemFlagsInformation, (PUCHAR)FlagsInfo + 2, sizeof(SYSTEM_FLAGS_INFORMATION) - 1, &ReturnLength);
65     ok(Status == STATUS_DATATYPE_MISALIGNMENT, "NtQuerySystemInformation returned %lx\n", Status);
66     ok(ReturnLength == 0x55555555, "ReturnLength = %lu\n", ReturnLength);
67     ok(Buffer[0] == 0x55555555, "Buffer[0] = %lx\n", Buffer[0]);
68     ok(Buffer[1] == 0x55555555, "Buffer[1] = %lx\n", Buffer[1]);
69 
70     ReturnLength = 0x55555555;
71     RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
72     Status = NtQuerySystemInformation(SystemFlagsInformation, FlagsInfo, sizeof(SYSTEM_FLAGS_INFORMATION) - 1, &ReturnLength);
73     ok(Status == STATUS_INFO_LENGTH_MISMATCH, "NtQuerySystemInformation returned %lx\n", Status);
74     ok(ReturnLength == 0 ||
75        ntv6(ReturnLength == sizeof(SYSTEM_FLAGS_INFORMATION)), "ReturnLength = %lu\n", ReturnLength);
76     ok(Buffer[0] == 0x55555555, "Buffer[0] = %lx\n", Buffer[0]);
77     ok(Buffer[1] == 0x55555555, "Buffer[1] = %lx\n", Buffer[1]);
78 
79     ReturnLength = 0x55555555;
80     RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
81     Status = NtQuerySystemInformation(SystemFlagsInformation, FlagsInfo, sizeof(SYSTEM_FLAGS_INFORMATION), &ReturnLength);
82     ok(Status == STATUS_SUCCESS, "NtQuerySystemInformation returned %lx\n", Status);
83     ok(ReturnLength == sizeof(SYSTEM_FLAGS_INFORMATION), "ReturnLength = %lu\n", ReturnLength);
84     ok(FlagsInfo->Flags != 0x55555555, "Flags = %lx\n", FlagsInfo->Flags);
85     ok(Buffer[1] == 0x55555555, "Buffer[1] = %lx\n", Buffer[1]);
86     Flags = FlagsInfo->Flags;
87 
88     ReturnLength = 0x55555555;
89     RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
90     Status = NtQuerySystemInformation(SystemFlagsInformation, FlagsInfo, sizeof(SYSTEM_FLAGS_INFORMATION) + 1, &ReturnLength);
91     ok(Status == STATUS_INFO_LENGTH_MISMATCH, "NtQuerySystemInformation returned %lx\n", Status);
92     ok(ReturnLength == 0 ||
93        ntv6(ReturnLength == sizeof(SYSTEM_FLAGS_INFORMATION)), "ReturnLength = %lu\n", ReturnLength);
94     ok(Buffer[0] == 0x55555555, "Buffer[0] = %lx\n", Buffer[0]);
95     ok(Buffer[1] == 0x55555555, "Buffer[1] = %lx\n", Buffer[1]);
96 
97     RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
98     Status = NtQuerySystemInformation(SystemFlagsInformation, FlagsInfo, sizeof(SYSTEM_FLAGS_INFORMATION), NULL);
99     ok(Status == STATUS_SUCCESS, "NtQuerySystemInformation returned %lx\n", Status);
100     ok(FlagsInfo->Flags == Flags, "Flags = %lx, expected %lx\n", FlagsInfo->Flags, Flags);
101     ok(Buffer[1] == 0x55555555, "Buffer[1] = %lx\n", Buffer[1]);
102 
103     RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
104     Status = NtQuerySystemInformation(SystemFlagsInformation, FlagsInfo, sizeof(SYSTEM_FLAGS_INFORMATION), (PVOID)4);
105     ok(Status == STATUS_ACCESS_VIOLATION, "NtQuerySystemInformation returned %lx\n", Status);
106     ok(Buffer[0] == 0x55555555, "Buffer[0] = %lx\n", Buffer[0]);
107     ok(Buffer[1] == 0x55555555, "Buffer[1] = %lx\n", Buffer[1]);
108 
109     RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
110     Status = NtQuerySystemInformation(SystemFlagsInformation, FlagsInfo, sizeof(SYSTEM_FLAGS_INFORMATION), (PVOID)2);
111     ok(Status == STATUS_ACCESS_VIOLATION, "NtQuerySystemInformation returned %lx\n", Status);
112     ok(Buffer[0] == 0x55555555, "Buffer[0] = %lx\n", Buffer[0]);
113     ok(Buffer[1] == 0x55555555, "Buffer[1] = %lx\n", Buffer[1]);
114 
115     RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
116     Status = NtQuerySystemInformation(SystemFlagsInformation, FlagsInfo, sizeof(SYSTEM_FLAGS_INFORMATION), (PVOID)1);
117     ok(Status == STATUS_ACCESS_VIOLATION, "NtQuerySystemInformation returned %lx\n", Status);
118     ok(Buffer[0] == 0x55555555, "Buffer[0] = %lx\n", Buffer[0]);
119     ok(Buffer[1] == 0x55555555, "Buffer[1] = %lx\n", Buffer[1]);
120 
121     RtlFillMemory(Buffer2, sizeof(Buffer2), 0x55);
122     RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
123     Status = NtQuerySystemInformation(SystemFlagsInformation, FlagsInfo, sizeof(SYSTEM_FLAGS_INFORMATION), (PULONG)((PUCHAR)Buffer2 + 1));
124     ok(Status == STATUS_SUCCESS, "NtQuerySystemInformation returned %lx\n", Status);
125     ok(FlagsInfo->Flags == Flags, "Flags = %lx, expected %lx\n", FlagsInfo->Flags, Flags);
126     ok(Buffer[1] == 0x55555555, "Buffer[1] = %lx\n", Buffer[1]);
127     ok(Buffer2[0] == 0x00000455, "Buffer2[0] = %lx\n", Buffer2[0]);
128     ok(Buffer2[1] == 0x55555500, "Buffer2[1] = %lx\n", Buffer2[1]);
129 
130     /* Set */
131     Status = NtSetSystemInformation(SystemFlagsInformation, NULL, 0);
132     ok(Status == STATUS_INFO_LENGTH_MISMATCH, "NtSetSystemInformation returned %lx\n", Status);
133 
134     Status = NtSetSystemInformation(SystemFlagsInformation, NULL, sizeof(SYSTEM_FLAGS_INFORMATION) - 1);
135     ok(Status == STATUS_INFO_LENGTH_MISMATCH, "NtSetSystemInformation returned %lx\n", Status);
136 
137     Status = NtSetSystemInformation(SystemFlagsInformation, NULL, sizeof(SYSTEM_FLAGS_INFORMATION));
138     ok(Status == (IsWindows7OrGreater() ? STATUS_ACCESS_DENIED : STATUS_ACCESS_VIOLATION), "NtSetSystemInformation returned %lx\n", Status);
139 
140     Status = NtSetSystemInformation(SystemFlagsInformation, (PVOID)2, sizeof(SYSTEM_FLAGS_INFORMATION));
141     ok(Status == STATUS_DATATYPE_MISALIGNMENT, "NtSetSystemInformation returned %lx\n", Status);
142 
143     Status = RtlAdjustPrivilege(SE_DEBUG_PRIVILEGE, TRUE, FALSE, &PrivilegeEnabled);
144     if (!NT_SUCCESS(Status))
145     {
146         skip("Cannot acquire SeDebugPrivilege\n");
147         return;
148     }
149 
150     Status = NtSetSystemInformation(SystemFlagsInformation, NULL, sizeof(SYSTEM_FLAGS_INFORMATION));
151     ok(Status == STATUS_ACCESS_VIOLATION, "NtSetSystemInformation returned %lx\n", Status);
152 
153     Status = NtSetSystemInformation(SystemFlagsInformation, (PVOID)2, sizeof(SYSTEM_FLAGS_INFORMATION));
154     ok(Status == STATUS_DATATYPE_MISALIGNMENT, "NtSetSystemInformation returned %lx\n", Status);
155 
156     Status = NtSetSystemInformation(SystemFlagsInformation, (PVOID)4, sizeof(SYSTEM_FLAGS_INFORMATION));
157     ok(Status == STATUS_ACCESS_VIOLATION, "NtSetSystemInformation returned %lx\n", Status);
158 
159     FlagsInfo->Flags = Flags;
160     Status = NtSetSystemInformation(SystemFlagsInformation, (PUCHAR)FlagsInfo + 2, sizeof(SYSTEM_FLAGS_INFORMATION));
161     ok(Status == STATUS_DATATYPE_MISALIGNMENT, "NtSetSystemInformation returned %lx\n", Status);
162 
163     Status = NtSetSystemInformation(SystemFlagsInformation, (PUCHAR)FlagsInfo + 2, sizeof(SYSTEM_FLAGS_INFORMATION) - 1);
164     ok(Status == STATUS_DATATYPE_MISALIGNMENT, "NtSetSystemInformation returned %lx\n", Status);
165 
166     Status = NtSetSystemInformation(SystemFlagsInformation, FlagsInfo, sizeof(SYSTEM_FLAGS_INFORMATION) - 1);
167     ok(Status == STATUS_INFO_LENGTH_MISMATCH, "NtSetSystemInformation returned %lx\n", Status);
168 
169     Status = NtSetSystemInformation(SystemFlagsInformation, FlagsInfo, sizeof(SYSTEM_FLAGS_INFORMATION) + 1);
170     ok(Status == STATUS_INFO_LENGTH_MISMATCH, "NtSetSystemInformation returned %lx\n", Status);
171 
172     Status = NtSetSystemInformation(SystemFlagsInformation, FlagsInfo, sizeof(SYSTEM_FLAGS_INFORMATION));
173     ok(Status == STATUS_SUCCESS, "NtSetSystemInformation returned %lx\n", Status);
174 
175     ok(FlagsInfo->Flags == Flags, "Flags = %lx, expected %lu\n", FlagsInfo->Flags, Flags);
176 
177     Status = RtlAdjustPrivilege(SE_DEBUG_PRIVILEGE, PrivilegeEnabled, FALSE, &PrivilegeEnabled);
178     ok(Status == STATUS_SUCCESS, "RtlAdjustPrivilege returned %lx\n", Status);
179 }
180 
181 static
182 void
Test_TimeAdjustment(void)183 Test_TimeAdjustment(void)
184 {
185     SYSTEM_QUERY_TIME_ADJUST_INFORMATION TimeInfoOrg, GetTimeInfo;
186     SYSTEM_SET_TIME_ADJUST_INFORMATION SetTimeInfo;
187     NTSTATUS Status;
188     ULONG ReturnLength;
189     BOOLEAN PrivilegeEnabled;
190 
191     /* Make sure we don't have debug privileges initially, otherwise WHS testbot fails */
192     Status = RtlAdjustPrivilege(SE_SYSTEMTIME_PRIVILEGE, FALSE, FALSE, &PrivilegeEnabled);
193     ok(Status == STATUS_SUCCESS, "RtlAdjustPrivilege returned %lx\n", Status);
194 
195     SetTimeInfo.TimeAdjustment = 0;
196     SetTimeInfo.Enable = 0;
197 
198     /* Query original values */
199     Status = NtQuerySystemInformation(SystemTimeAdjustmentInformation,
200                                       &TimeInfoOrg,
201                                       sizeof(TimeInfoOrg),
202                                       &ReturnLength);
203 
204     /* Test without privilege */
205     Status = NtSetSystemInformation(SystemTimeAdjustmentInformation,
206                                     &SetTimeInfo,
207                                     sizeof(SetTimeInfo));
208     ok_ntstatus(Status, STATUS_PRIVILEGE_NOT_HELD);
209 
210     /* Get the required privilege */
211     Status = RtlAdjustPrivilege(SE_SYSTEMTIME_PRIVILEGE, TRUE, FALSE, &PrivilegeEnabled);
212     if (!NT_SUCCESS(Status))
213     {
214         skip("Cannot acquire SeSystemTimePrivilege\n");
215         return;
216     }
217 
218     /* Test wrong length */
219     Status = NtSetSystemInformation(SystemTimeAdjustmentInformation,
220                                     &SetTimeInfo,
221                                     sizeof(SetTimeInfo) + 1);
222     ok_ntstatus(Status, STATUS_INFO_LENGTH_MISMATCH);
223 
224     /* Test both members 0 */
225     Status = NtSetSystemInformation(SystemTimeAdjustmentInformation,
226                                     &SetTimeInfo,
227                                     sizeof(SetTimeInfo));
228     ok_ntstatus(Status, IsWindows7OrGreater() ? STATUS_INTEGER_DIVIDE_BY_ZERO : STATUS_INVALID_PARAMETER_2);
229 
230     /* Set huge value */
231     SetTimeInfo.TimeAdjustment = -1;
232     SetTimeInfo.Enable = 0;
233     Status = NtSetSystemInformation(SystemTimeAdjustmentInformation,
234                                     &SetTimeInfo,
235                                     sizeof(SetTimeInfo));
236     ok_ntstatus(Status, STATUS_SUCCESS);
237 
238     /* Query the result */
239     Status = NtQuerySystemInformation(SystemTimeAdjustmentInformation,
240                                       &GetTimeInfo,
241                                       sizeof(GetTimeInfo),
242                                       &ReturnLength);
243     ok_ntstatus(Status, STATUS_SUCCESS);
244     ok_long(GetTimeInfo.TimeAdjustment, IsWindows7OrGreater() ? 0x7076cc : -1);
245     ok_long(GetTimeInfo.Enable, 0);
246 
247     /* set Enable to 1 */
248     SetTimeInfo.TimeAdjustment = -1;
249     SetTimeInfo.Enable = 1;
250     Status = NtSetSystemInformation(SystemTimeAdjustmentInformation,
251                                     &SetTimeInfo,
252                                     sizeof(SetTimeInfo));
253     ok_ntstatus(Status, STATUS_SUCCESS);
254 
255     /* Query the result */
256     Status = NtQuerySystemInformation(SystemTimeAdjustmentInformation,
257                                       &GetTimeInfo,
258                                       sizeof(GetTimeInfo),
259                                       &ReturnLength);
260     ok_ntstatus(Status, STATUS_SUCCESS);
261     ok_long(GetTimeInfo.TimeAdjustment, GetTimeInfo.TimeIncrement);
262     ok_long(GetTimeInfo.Enable, 1);
263 
264     /* Restore original values */
265     SetTimeInfo.TimeAdjustment = TimeInfoOrg.TimeAdjustment;
266     SetTimeInfo.Enable = TimeInfoOrg.Enable;
267     Status = NtSetSystemInformation(SystemTimeAdjustmentInformation,
268                                     &SetTimeInfo,
269                                     sizeof(SetTimeInfo));
270     ok_ntstatus(Status, STATUS_SUCCESS);
271 
272     Status = RtlAdjustPrivilege(SE_SYSTEMTIME_PRIVILEGE, PrivilegeEnabled, FALSE, &PrivilegeEnabled);
273     ok(Status == STATUS_SUCCESS, "RtlAdjustPrivilege returned %lx\n", Status);
274 }
275 
276 static
277 void
Test_KernelDebugger(void)278 Test_KernelDebugger(void)
279 {
280     NTSTATUS Status;
281     ULONG ReturnLength;
282     ULONG Buffer[2];
283     PSYSTEM_KERNEL_DEBUGGER_INFORMATION DebuggerInfo = (PVOID)Buffer;
284 
285     /* Query */
286     ReturnLength = 0x55555555;
287     Status = NtQuerySystemInformation(SystemKernelDebuggerInformation, NULL, 0, &ReturnLength);
288     ok(Status == STATUS_INFO_LENGTH_MISMATCH, "NtQuerySystemInformation returned %lx\n", Status);
289     ok(ReturnLength == 0 ||
290        ntv6(ReturnLength == sizeof(SYSTEM_KERNEL_DEBUGGER_INFORMATION)), "ReturnLength = %lu\n", ReturnLength);
291 
292     ReturnLength = 0x55555555;
293     RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
294     Status = NtQuerySystemInformation(SystemKernelDebuggerInformation, DebuggerInfo, sizeof(SYSTEM_KERNEL_DEBUGGER_INFORMATION) - 1, &ReturnLength);
295     ok(Status == STATUS_INFO_LENGTH_MISMATCH, "NtQuerySystemInformation returned %lx\n", Status);
296     ok(ReturnLength == 0 ||
297        ntv6(ReturnLength == sizeof(SYSTEM_KERNEL_DEBUGGER_INFORMATION)), "ReturnLength = %lu\n", ReturnLength);
298     ok(Buffer[0] == 0x55555555, "Buffer[0] = %lx\n", Buffer[0]);
299     ok(Buffer[1] == 0x55555555, "Buffer[1] = %lx\n", Buffer[1]);
300 
301     ReturnLength = 0x55555555;
302     RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
303     Status = NtQuerySystemInformation(SystemKernelDebuggerInformation, (PUCHAR)DebuggerInfo + 1, sizeof(SYSTEM_KERNEL_DEBUGGER_INFORMATION), &ReturnLength);
304     ok(Status == STATUS_SUCCESS, "NtQuerySystemInformation returned %lx\n", Status);
305     ok(ReturnLength == sizeof(SYSTEM_KERNEL_DEBUGGER_INFORMATION), "ReturnLength = %lu\n", ReturnLength);
306     ok((Buffer[0] & 0x55fefe55) == 0x55000055, "Buffer[0] = %lx\n", Buffer[0]);
307     ok(Buffer[1] == 0x55555555, "Buffer[1] = %lx\n", Buffer[1]);
308 
309     ReturnLength = 0x55555555;
310     RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
311     Status = NtQuerySystemInformation(SystemKernelDebuggerInformation, DebuggerInfo, sizeof(SYSTEM_KERNEL_DEBUGGER_INFORMATION), &ReturnLength);
312     ok(Status == STATUS_SUCCESS, "NtQuerySystemInformation returned %lx\n", Status);
313     ok(ReturnLength == sizeof(SYSTEM_KERNEL_DEBUGGER_INFORMATION), "ReturnLength = %lu\n", ReturnLength);
314     ok(DebuggerInfo->KernelDebuggerEnabled == FALSE ||
315        DebuggerInfo->KernelDebuggerEnabled == TRUE, "KernelDebuggerEnabled = %u\n", DebuggerInfo->KernelDebuggerEnabled);
316     ok(DebuggerInfo->KernelDebuggerNotPresent == FALSE ||
317        DebuggerInfo->KernelDebuggerNotPresent == TRUE, "KernelDebuggerNotPresent = %u\n", DebuggerInfo->KernelDebuggerNotPresent);
318 
319     /* Set - not supported */
320     DebuggerInfo->KernelDebuggerEnabled = FALSE;
321     DebuggerInfo->KernelDebuggerNotPresent = TRUE;
322     Status = NtSetSystemInformation(SystemKernelDebuggerInformation, DebuggerInfo, sizeof(SYSTEM_KERNEL_DEBUGGER_INFORMATION));
323     ok(Status == STATUS_INVALID_INFO_CLASS, "NtSetSystemInformation returned %lx\n", Status);
324 }
325 
START_TEST(NtSystemInformation)326 START_TEST(NtSystemInformation)
327 {
328     NTSTATUS Status;
329     ULONG ReturnLength;
330 
331     Status = NtQuerySystemInformation(9999, NULL, 0, NULL);
332     ok(Status == STATUS_INVALID_INFO_CLASS, "NtQuerySystemInformation returned %lx\n", Status);
333 
334     Status = NtQuerySystemInformation(9999, NULL, 0, (PVOID)1);
335     ok(Status == STATUS_ACCESS_VIOLATION ||
336        ntv6(Status == STATUS_INVALID_INFO_CLASS), "NtQuerySystemInformation returned %lx\n", Status);
337 
338     ReturnLength = 0x55555555;
339     Status = NtQuerySystemInformation(9999, NULL, 0, &ReturnLength);
340     ok(Status == STATUS_INVALID_INFO_CLASS, "NtQuerySystemInformation returned %lx\n", Status);
341     ok(ReturnLength == 0 ||
342        ntv6(ReturnLength == 0x55555555), "ReturnLength = %lu\n", ReturnLength);
343 
344     ReturnLength = 0x55555555;
345     Status = NtQuerySystemInformation(9999, NULL, 1, &ReturnLength);
346     ok(Status == STATUS_ACCESS_VIOLATION ||
347        ntv6(Status == STATUS_INVALID_INFO_CLASS), "NtQuerySystemInformation returned %lx\n", Status);
348     ok(ReturnLength == 0x55555555, "ReturnLength = %lu\n", ReturnLength);
349 
350     ReturnLength = 0x55555555;
351     Status = NtQuerySystemInformation(9999, (PVOID)1, 1, &ReturnLength);
352     ok(Status == STATUS_DATATYPE_MISALIGNMENT ||
353        ntv6(Status == STATUS_INVALID_INFO_CLASS), "NtQuerySystemInformation returned %lx\n", Status);
354     ok(ReturnLength == 0x55555555, "ReturnLength = %lu\n", ReturnLength);
355 
356     Status = NtQuerySystemInformation(9999, NULL, 1, (PVOID)1);
357     ok(Status == STATUS_ACCESS_VIOLATION ||
358        ntv6(Status == STATUS_INVALID_INFO_CLASS), "NtQuerySystemInformation returned %lx\n", Status);
359 
360     Status = NtQuerySystemInformation(9999, (PVOID)1, 1, (PVOID)1);
361     ok(Status == STATUS_DATATYPE_MISALIGNMENT ||
362        ntv6(Status == STATUS_INVALID_INFO_CLASS), "NtQuerySystemInformation returned %lx\n", Status);
363 
364     Test_Flags();
365     Test_TimeAdjustment();
366     Test_KernelDebugger();
367 }
368