Assorted spelling fixes.
[wine.git] / dlls / ntdll / tests / info.c
blobaf0040166f8d95abf3c85eb7f0561b1f6f20e161
1 /* Unit test suite for *Information* Registry API functions
3 * Copyright 2005 Paul Vriens
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "ntdll_test.h"
22 #include <winnls.h>
23 #include <stdio.h>
25 static NTSTATUS (WINAPI * pNtQuerySystemInformation)(SYSTEM_INFORMATION_CLASS, PVOID, ULONG, PULONG);
26 static NTSTATUS (WINAPI * pNtPowerInformation)(POWER_INFORMATION_LEVEL, PVOID, ULONG, PVOID, ULONG);
27 static NTSTATUS (WINAPI * pNtQueryInformationProcess)(HANDLE, PROCESSINFOCLASS, PVOID, ULONG, PULONG);
28 static NTSTATUS (WINAPI * pNtQueryInformationThread)(HANDLE, THREADINFOCLASS, PVOID, ULONG, PULONG);
29 static NTSTATUS (WINAPI * pNtSetInformationProcess)(HANDLE, PROCESSINFOCLASS, PVOID, ULONG);
30 static NTSTATUS (WINAPI * pNtSetInformationThread)(HANDLE, THREADINFOCLASS, PVOID, ULONG);
31 static NTSTATUS (WINAPI * pNtReadVirtualMemory)(HANDLE, const void*, void*, SIZE_T, SIZE_T*);
32 static NTSTATUS (WINAPI * pNtQueryVirtualMemory)(HANDLE, LPCVOID, MEMORY_INFORMATION_CLASS , PVOID , SIZE_T , SIZE_T *);
33 static NTSTATUS (WINAPI * pNtCreateSection)(HANDLE*,ACCESS_MASK,const OBJECT_ATTRIBUTES*,const LARGE_INTEGER*,ULONG,ULONG,HANDLE);
34 static NTSTATUS (WINAPI * pNtMapViewOfSection)(HANDLE,HANDLE,PVOID*,ULONG,SIZE_T,const LARGE_INTEGER*,SIZE_T*,SECTION_INHERIT,ULONG,ULONG);
35 static NTSTATUS (WINAPI * pNtUnmapViewOfSection)(HANDLE,PVOID);
36 static NTSTATUS (WINAPI * pNtClose)(HANDLE);
37 static ULONG (WINAPI * pNtGetCurrentProcessorNumber)(void);
38 static BOOL (WINAPI * pIsWow64Process)(HANDLE, PBOOL);
40 static BOOL is_wow64;
42 /* one_before_last_pid is used to be able to compare values of a still running process
43 with the output of the test_query_process_times and test_query_process_handlecount tests.
45 static DWORD one_before_last_pid = 0;
47 #define NTDLL_GET_PROC(func) do { \
48 p ## func = (void*)GetProcAddress(hntdll, #func); \
49 if(!p ## func) { \
50 trace("GetProcAddress(%s) failed\n", #func); \
51 return FALSE; \
52 } \
53 } while(0)
55 static BOOL InitFunctionPtrs(void)
57 /* All needed functions are NT based, so using GetModuleHandle is a good check */
58 HMODULE hntdll = GetModuleHandleA("ntdll");
59 if (!hntdll)
61 win_skip("Not running on NT\n");
62 return FALSE;
65 NTDLL_GET_PROC(NtQuerySystemInformation);
66 NTDLL_GET_PROC(NtPowerInformation);
67 NTDLL_GET_PROC(NtQueryInformationProcess);
68 NTDLL_GET_PROC(NtQueryInformationThread);
69 NTDLL_GET_PROC(NtSetInformationProcess);
70 NTDLL_GET_PROC(NtSetInformationThread);
71 NTDLL_GET_PROC(NtReadVirtualMemory);
72 NTDLL_GET_PROC(NtQueryVirtualMemory);
73 NTDLL_GET_PROC(NtClose);
74 NTDLL_GET_PROC(NtCreateSection);
75 NTDLL_GET_PROC(NtMapViewOfSection);
76 NTDLL_GET_PROC(NtUnmapViewOfSection);
78 /* not present before XP */
79 pNtGetCurrentProcessorNumber = (void *) GetProcAddress(hntdll, "NtGetCurrentProcessorNumber");
81 pIsWow64Process = (void *)GetProcAddress(GetModuleHandleA("kernel32.dll"), "IsWow64Process");
82 if (!pIsWow64Process || !pIsWow64Process( GetCurrentProcess(), &is_wow64 )) is_wow64 = FALSE;
83 return TRUE;
86 static void test_query_basic(void)
88 NTSTATUS status;
89 ULONG ReturnLength;
90 SYSTEM_BASIC_INFORMATION sbi;
92 /* This test also covers some basic parameter testing that should be the same for
93 * every information class
96 /* Use a nonexistent info class */
97 trace("Check nonexistent info class\n");
98 status = pNtQuerySystemInformation(-1, NULL, 0, NULL);
99 ok( status == STATUS_INVALID_INFO_CLASS || status == STATUS_NOT_IMPLEMENTED /* vista */,
100 "Expected STATUS_INVALID_INFO_CLASS or STATUS_NOT_IMPLEMENTED, got %08x\n", status);
102 /* Use an existing class but with a zero-length buffer */
103 trace("Check zero-length buffer\n");
104 status = pNtQuerySystemInformation(SystemBasicInformation, NULL, 0, NULL);
105 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
107 /* Use an existing class, correct length but no SystemInformation buffer */
108 trace("Check no SystemInformation buffer\n");
109 status = pNtQuerySystemInformation(SystemBasicInformation, NULL, sizeof(sbi), NULL);
110 ok( status == STATUS_ACCESS_VIOLATION || status == STATUS_INVALID_PARAMETER /* vista */,
111 "Expected STATUS_ACCESS_VIOLATION or STATUS_INVALID_PARAMETER, got %08x\n", status);
113 /* Use an existing class, correct length, a pointer to a buffer but no ReturnLength pointer */
114 trace("Check no ReturnLength pointer\n");
115 status = pNtQuerySystemInformation(SystemBasicInformation, &sbi, sizeof(sbi), NULL);
116 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
118 /* Check a too large buffer size */
119 trace("Check a too large buffer size\n");
120 status = pNtQuerySystemInformation(SystemBasicInformation, &sbi, sizeof(sbi) * 2, &ReturnLength);
121 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
123 /* Finally some correct calls */
124 trace("Check with correct parameters\n");
125 status = pNtQuerySystemInformation(SystemBasicInformation, &sbi, sizeof(sbi), &ReturnLength);
126 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
127 ok( sizeof(sbi) == ReturnLength, "Inconsistent length %d\n", ReturnLength);
129 /* Check if we have some return values */
130 trace("Number of Processors : %d\n", sbi.NumberOfProcessors);
131 ok( sbi.NumberOfProcessors > 0, "Expected more than 0 processors, got %d\n", sbi.NumberOfProcessors);
134 static void test_query_cpu(void)
136 DWORD status;
137 ULONG ReturnLength;
138 SYSTEM_CPU_INFORMATION sci;
140 status = pNtQuerySystemInformation(SystemCpuInformation, &sci, sizeof(sci), &ReturnLength);
141 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
142 ok( sizeof(sci) == ReturnLength, "Inconsistent length %d\n", ReturnLength);
144 /* Check if we have some return values */
145 trace("Processor FeatureSet : %08x\n", sci.FeatureSet);
146 ok( sci.FeatureSet != 0, "Expected some features for this processor, got %08x\n", sci.FeatureSet);
149 static void test_query_performance(void)
151 NTSTATUS status;
152 ULONG ReturnLength;
153 ULONGLONG buffer[sizeof(SYSTEM_PERFORMANCE_INFORMATION)/sizeof(ULONGLONG) + 5];
154 DWORD size = sizeof(SYSTEM_PERFORMANCE_INFORMATION);
156 status = pNtQuerySystemInformation(SystemPerformanceInformation, buffer, 0, &ReturnLength);
157 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
159 status = pNtQuerySystemInformation(SystemPerformanceInformation, buffer, size, &ReturnLength);
160 if (status == STATUS_INFO_LENGTH_MISMATCH && is_wow64)
162 /* size is larger on wow64 under w2k8/win7 */
163 size += 16;
164 status = pNtQuerySystemInformation(SystemPerformanceInformation, buffer, size, &ReturnLength);
166 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
167 ok( ReturnLength == size, "Inconsistent length %d\n", ReturnLength);
169 status = pNtQuerySystemInformation(SystemPerformanceInformation, buffer, size + 2, &ReturnLength);
170 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
171 ok( ReturnLength == size || ReturnLength == size + 2,
172 "Inconsistent length %d\n", ReturnLength);
174 /* Not return values yet, as struct members are unknown */
177 static void test_query_timeofday(void)
179 NTSTATUS status;
180 ULONG ReturnLength;
182 /* Copy of our winternl.h structure turned into a private one */
183 typedef struct _SYSTEM_TIMEOFDAY_INFORMATION_PRIVATE {
184 LARGE_INTEGER liKeBootTime;
185 LARGE_INTEGER liKeSystemTime;
186 LARGE_INTEGER liExpTimeZoneBias;
187 ULONG uCurrentTimeZoneId;
188 DWORD dwUnknown1[5];
189 } SYSTEM_TIMEOFDAY_INFORMATION_PRIVATE;
191 SYSTEM_TIMEOFDAY_INFORMATION_PRIVATE sti;
193 /* The struct size for NT (32 bytes) and Win2K/XP (48 bytes) differ.
195 * Windows 2000 and XP return STATUS_INFO_LENGTH_MISMATCH if the given buffer size is greater
196 * then 48 and 0 otherwise
197 * Windows NT returns STATUS_INFO_LENGTH_MISMATCH when the given buffer size is not correct
198 * and 0 otherwise
200 * Windows 2000 and XP copy the given buffer size into the provided buffer, if the return code is STATUS_SUCCESS
201 * NT only fills the buffer if the return code is STATUS_SUCCESS
205 status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, sizeof(sti), &ReturnLength);
207 if (status == STATUS_INFO_LENGTH_MISMATCH)
209 trace("Windows version is NT, we have to cater for differences with W2K/WinXP\n");
211 status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, 0, &ReturnLength);
212 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
213 ok( 0 == ReturnLength, "ReturnLength should be 0, it is (%d)\n", ReturnLength);
215 sti.uCurrentTimeZoneId = 0xdeadbeef;
216 status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, 28, &ReturnLength);
217 ok(status == STATUS_SUCCESS || broken(status == STATUS_INFO_LENGTH_MISMATCH /* NT4 */), "Expected STATUS_SUCCESS, got %08x\n", status);
218 ok( 0xdeadbeef == sti.uCurrentTimeZoneId, "This part of the buffer should not have been filled\n");
220 status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, 32, &ReturnLength);
221 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
222 ok( 32 == ReturnLength, "ReturnLength should be 0, it is (%d)\n", ReturnLength);
224 else
226 status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, 0, &ReturnLength);
227 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
228 ok( 0 == ReturnLength, "ReturnLength should be 0, it is (%d)\n", ReturnLength);
230 sti.uCurrentTimeZoneId = 0xdeadbeef;
231 status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, 24, &ReturnLength);
232 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
233 ok( 24 == ReturnLength, "ReturnLength should be 24, it is (%d)\n", ReturnLength);
234 ok( 0xdeadbeef == sti.uCurrentTimeZoneId, "This part of the buffer should not have been filled\n");
236 sti.uCurrentTimeZoneId = 0xdeadbeef;
237 status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, 32, &ReturnLength);
238 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
239 ok( 32 == ReturnLength, "ReturnLength should be 32, it is (%d)\n", ReturnLength);
240 ok( 0xdeadbeef != sti.uCurrentTimeZoneId, "Buffer should have been partially filled\n");
242 status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, 49, &ReturnLength);
243 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
244 ok( ReturnLength == 0 || ReturnLength == sizeof(sti) /* vista */,
245 "ReturnLength should be 0, it is (%d)\n", ReturnLength);
247 status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, sizeof(sti), &ReturnLength);
248 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
249 ok( sizeof(sti) == ReturnLength, "Inconsistent length %d\n", ReturnLength);
252 /* Check if we have some return values */
253 trace("uCurrentTimeZoneId : (%d)\n", sti.uCurrentTimeZoneId);
256 static void test_query_process(void)
258 NTSTATUS status;
259 DWORD last_pid;
260 ULONG ReturnLength;
261 int i = 0, k = 0;
262 BOOL is_nt = FALSE;
263 SYSTEM_BASIC_INFORMATION sbi;
265 /* Copy of our winternl.h structure turned into a private one */
266 typedef struct _SYSTEM_PROCESS_INFORMATION_PRIVATE {
267 ULONG NextEntryOffset;
268 DWORD dwThreadCount;
269 DWORD dwUnknown1[6];
270 FILETIME ftCreationTime;
271 FILETIME ftUserTime;
272 FILETIME ftKernelTime;
273 UNICODE_STRING ProcessName;
274 DWORD dwBasePriority;
275 HANDLE UniqueProcessId;
276 HANDLE ParentProcessId;
277 ULONG HandleCount;
278 DWORD dwUnknown3;
279 DWORD dwUnknown4;
280 VM_COUNTERS vmCounters;
281 IO_COUNTERS ioCounters;
282 SYSTEM_THREAD_INFORMATION ti[1];
283 } SYSTEM_PROCESS_INFORMATION_PRIVATE;
285 ULONG SystemInformationLength = sizeof(SYSTEM_PROCESS_INFORMATION_PRIVATE);
286 SYSTEM_PROCESS_INFORMATION_PRIVATE *spi, *spi_buf = HeapAlloc(GetProcessHeap(), 0, SystemInformationLength);
288 /* test ReturnLength */
289 ReturnLength = 0;
290 status = pNtQuerySystemInformation(SystemProcessInformation, NULL, 0, &ReturnLength);
291 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_LENGTH_MISMATCH got %08x\n", status);
292 ok( ReturnLength > 0 || broken(ReturnLength == 0) /* NT4, Win2K */,
293 "Expected a ReturnLength to show the needed length\n");
295 /* W2K3 and later returns the needed length, the rest returns 0, so we have to loop */
296 for (;;)
298 status = pNtQuerySystemInformation(SystemProcessInformation, spi_buf, SystemInformationLength, &ReturnLength);
300 if (status != STATUS_INFO_LENGTH_MISMATCH) break;
302 spi_buf = HeapReAlloc(GetProcessHeap(), 0, spi_buf , SystemInformationLength *= 2);
304 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
305 spi = spi_buf;
307 /* Get the first NextEntryOffset, from this we can deduce the OS version we're running
309 * W2K/WinXP/W2K3:
310 * NextEntryOffset for a process is 184 + (no. of threads) * sizeof(SYSTEM_THREAD_INFORMATION)
311 * NT:
312 * NextEntryOffset for a process is 136 + (no. of threads) * sizeof(SYSTEM_THREAD_INFORMATION)
313 * Wine (with every windows version):
314 * NextEntryOffset for a process is 0 if just this test is running
315 * NextEntryOffset for a process is 184 + (no. of threads) * sizeof(SYSTEM_THREAD_INFORMATION) +
316 * ProcessName.MaximumLength
317 * if more wine processes are running
319 * Note : On windows the first process is in fact the Idle 'process' with a thread for every processor
322 pNtQuerySystemInformation(SystemBasicInformation, &sbi, sizeof(sbi), &ReturnLength);
324 is_nt = ( spi->NextEntryOffset - (sbi.NumberOfProcessors * sizeof(SYSTEM_THREAD_INFORMATION)) == 136);
326 if (is_nt) win_skip("Windows version is NT, we will skip thread tests\n");
328 /* Check if we have some return values
330 * On windows there will be several processes running (Including the always present Idle and System)
331 * On wine we only have one (if this test is the only wine process running)
334 /* Loop through the processes */
336 for (;;)
338 i++;
340 last_pid = (DWORD_PTR)spi->UniqueProcessId;
342 ok( spi->dwThreadCount > 0, "Expected some threads for this process, got 0\n");
344 /* Loop through the threads, skip NT4 for now */
346 if (!is_nt)
348 DWORD j;
349 for ( j = 0; j < spi->dwThreadCount; j++)
351 k++;
352 ok ( spi->ti[j].ClientId.UniqueProcess == spi->UniqueProcessId,
353 "The owning pid of the thread (%p) doesn't equal the pid (%p) of the process\n",
354 spi->ti[j].ClientId.UniqueProcess, spi->UniqueProcessId);
358 if (!spi->NextEntryOffset) break;
360 one_before_last_pid = last_pid;
362 spi = (SYSTEM_PROCESS_INFORMATION_PRIVATE*)((char*)spi + spi->NextEntryOffset);
364 trace("Total number of running processes : %d\n", i);
365 if (!is_nt) trace("Total number of running threads : %d\n", k);
367 if (one_before_last_pid == 0) one_before_last_pid = last_pid;
369 HeapFree( GetProcessHeap(), 0, spi_buf);
372 static void test_query_procperf(void)
374 NTSTATUS status;
375 ULONG ReturnLength;
376 ULONG NeededLength;
377 SYSTEM_BASIC_INFORMATION sbi;
378 SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION* sppi;
380 /* Find out the number of processors */
381 status = pNtQuerySystemInformation(SystemBasicInformation, &sbi, sizeof(sbi), &ReturnLength);
382 ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
383 NeededLength = sbi.NumberOfProcessors * sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION);
385 sppi = HeapAlloc(GetProcessHeap(), 0, NeededLength);
387 status = pNtQuerySystemInformation(SystemProcessorPerformanceInformation, sppi, 0, &ReturnLength);
388 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
390 /* Try it for 1 processor */
391 sppi->KernelTime.QuadPart = 0xdeaddead;
392 sppi->UserTime.QuadPart = 0xdeaddead;
393 sppi->IdleTime.QuadPart = 0xdeaddead;
394 status = pNtQuerySystemInformation(SystemProcessorPerformanceInformation, sppi,
395 sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION), &ReturnLength);
396 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
397 ok( sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) == ReturnLength,
398 "Inconsistent length %d\n", ReturnLength);
399 ok (sppi->KernelTime.QuadPart != 0xdeaddead, "KernelTime unchanged\n");
400 ok (sppi->UserTime.QuadPart != 0xdeaddead, "UserTime unchanged\n");
401 ok (sppi->IdleTime.QuadPart != 0xdeaddead, "IdleTime unchanged\n");
403 /* Try it for all processors */
404 sppi->KernelTime.QuadPart = 0xdeaddead;
405 sppi->UserTime.QuadPart = 0xdeaddead;
406 sppi->IdleTime.QuadPart = 0xdeaddead;
407 status = pNtQuerySystemInformation(SystemProcessorPerformanceInformation, sppi, NeededLength, &ReturnLength);
408 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
409 ok( NeededLength == ReturnLength, "Inconsistent length (%d) <-> (%d)\n", NeededLength, ReturnLength);
410 ok (sppi->KernelTime.QuadPart != 0xdeaddead, "KernelTime unchanged\n");
411 ok (sppi->UserTime.QuadPart != 0xdeaddead, "UserTime unchanged\n");
412 ok (sppi->IdleTime.QuadPart != 0xdeaddead, "IdleTime unchanged\n");
414 /* A too large given buffer size */
415 sppi = HeapReAlloc(GetProcessHeap(), 0, sppi , NeededLength + 2);
416 sppi->KernelTime.QuadPart = 0xdeaddead;
417 sppi->UserTime.QuadPart = 0xdeaddead;
418 sppi->IdleTime.QuadPart = 0xdeaddead;
419 status = pNtQuerySystemInformation(SystemProcessorPerformanceInformation, sppi, NeededLength + 2, &ReturnLength);
420 ok( status == STATUS_SUCCESS || status == STATUS_INFO_LENGTH_MISMATCH /* vista */,
421 "Expected STATUS_SUCCESS or STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
422 ok( NeededLength == ReturnLength, "Inconsistent length (%d) <-> (%d)\n", NeededLength, ReturnLength);
423 if (status == STATUS_SUCCESS)
425 ok (sppi->KernelTime.QuadPart != 0xdeaddead, "KernelTime unchanged\n");
426 ok (sppi->UserTime.QuadPart != 0xdeaddead, "UserTime unchanged\n");
427 ok (sppi->IdleTime.QuadPart != 0xdeaddead, "IdleTime unchanged\n");
429 else /* vista and 2008 */
431 ok (sppi->KernelTime.QuadPart == 0xdeaddead, "KernelTime changed\n");
432 ok (sppi->UserTime.QuadPart == 0xdeaddead, "UserTime changed\n");
433 ok (sppi->IdleTime.QuadPart == 0xdeaddead, "IdleTime changed\n");
436 HeapFree( GetProcessHeap(), 0, sppi);
439 static void test_query_module(void)
441 NTSTATUS status;
442 ULONG ReturnLength;
443 ULONG ModuleCount, i;
445 ULONG SystemInformationLength = sizeof(SYSTEM_MODULE_INFORMATION);
446 SYSTEM_MODULE_INFORMATION* smi = HeapAlloc(GetProcessHeap(), 0, SystemInformationLength);
447 SYSTEM_MODULE* sm;
449 /* Request the needed length */
450 status = pNtQuerySystemInformation(SystemModuleInformation, smi, 0, &ReturnLength);
451 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
452 ok( ReturnLength > 0, "Expected a ReturnLength to show the needed length\n");
454 SystemInformationLength = ReturnLength;
455 smi = HeapReAlloc(GetProcessHeap(), 0, smi , SystemInformationLength);
456 status = pNtQuerySystemInformation(SystemModuleInformation, smi, SystemInformationLength, &ReturnLength);
457 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
459 ModuleCount = smi->ModulesCount;
460 sm = &smi->Modules[0];
461 /* our implementation is a stub for now */
462 ok( ModuleCount > 0, "Expected some modules to be loaded\n");
464 /* Loop through all the modules/drivers, Wine doesn't get here (yet) */
465 for (i = 0; i < ModuleCount ; i++)
467 ok( i == sm->Id, "Id (%d) should have matched %u\n", sm->Id, i);
468 sm++;
471 HeapFree( GetProcessHeap(), 0, smi);
474 static void test_query_handle(void)
476 NTSTATUS status;
477 ULONG ReturnLength;
478 ULONG SystemInformationLength = sizeof(SYSTEM_HANDLE_INFORMATION);
479 SYSTEM_HANDLE_INFORMATION* shi = HeapAlloc(GetProcessHeap(), 0, SystemInformationLength);
481 /* Request the needed length : a SystemInformationLength greater than one struct sets ReturnLength */
482 status = pNtQuerySystemInformation(SystemHandleInformation, shi, SystemInformationLength, &ReturnLength);
483 todo_wine ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
485 SystemInformationLength = ReturnLength;
486 shi = HeapReAlloc(GetProcessHeap(), 0, shi , SystemInformationLength);
487 status = pNtQuerySystemInformation(SystemHandleInformation, shi, SystemInformationLength, &ReturnLength);
488 if (status != STATUS_INFO_LENGTH_MISMATCH) /* vista */
490 ok( status == STATUS_SUCCESS,
491 "Expected STATUS_SUCCESS, got %08x\n", status);
493 /* Check if we have some return values */
494 trace("Number of Handles : %d\n", shi->Count);
495 todo_wine
497 /* our implementation is a stub for now */
498 ok( shi->Count > 1, "Expected more than 1 handles, got (%d)\n", shi->Count);
501 HeapFree( GetProcessHeap(), 0, shi);
504 static void test_query_cache(void)
506 NTSTATUS status;
507 ULONG ReturnLength;
508 BYTE buffer[128];
509 SYSTEM_CACHE_INFORMATION *sci = (SYSTEM_CACHE_INFORMATION *) buffer;
510 ULONG expected;
511 INT i;
513 /* the large SYSTEM_CACHE_INFORMATION on WIN64 is not documented */
514 expected = sizeof(SYSTEM_CACHE_INFORMATION);
515 for (i = sizeof(buffer); i>= expected; i--)
517 ReturnLength = 0xdeadbeef;
518 status = pNtQuerySystemInformation(SystemCacheInformation, sci, i, &ReturnLength);
519 ok(!status && (ReturnLength == expected),
520 "%d: got 0x%x and %u (expected STATUS_SUCCESS and %u)\n", i, status, ReturnLength, expected);
523 /* buffer too small for the full result.
524 Up to win7, the function succeeds with a partial result. */
525 status = pNtQuerySystemInformation(SystemCacheInformation, sci, i, &ReturnLength);
526 if (!status)
528 expected = offsetof(SYSTEM_CACHE_INFORMATION, MinimumWorkingSet);
529 for (; i>= expected; i--)
531 ReturnLength = 0xdeadbeef;
532 status = pNtQuerySystemInformation(SystemCacheInformation, sci, i, &ReturnLength);
533 ok(!status && (ReturnLength == expected),
534 "%d: got 0x%x and %u (expected STATUS_SUCCESS and %u)\n", i, status, ReturnLength, expected);
538 /* buffer too small for the result, this call will always fail */
539 ReturnLength = 0xdeadbeef;
540 status = pNtQuerySystemInformation(SystemCacheInformation, sci, i, &ReturnLength);
541 ok( status == STATUS_INFO_LENGTH_MISMATCH &&
542 ((ReturnLength == expected) || broken(!ReturnLength) || broken(ReturnLength == 0xfffffff0)),
543 "%d: got 0x%x and %u (expected STATUS_INFO_LENGTH_MISMATCH and %u)\n", i, status, ReturnLength, expected);
545 if (0) {
546 /* this crashes on some vista / win7 machines */
547 ReturnLength = 0xdeadbeef;
548 status = pNtQuerySystemInformation(SystemCacheInformation, sci, 0, &ReturnLength);
549 ok( status == STATUS_INFO_LENGTH_MISMATCH &&
550 ((ReturnLength == expected) || broken(!ReturnLength) || broken(ReturnLength == 0xfffffff0)),
551 "0: got 0x%x and %u (expected STATUS_INFO_LENGTH_MISMATCH and %u)\n", status, ReturnLength, expected);
555 static void test_query_interrupt(void)
557 NTSTATUS status;
558 ULONG ReturnLength;
559 ULONG NeededLength;
560 SYSTEM_BASIC_INFORMATION sbi;
561 SYSTEM_INTERRUPT_INFORMATION* sii;
563 /* Find out the number of processors */
564 status = pNtQuerySystemInformation(SystemBasicInformation, &sbi, sizeof(sbi), &ReturnLength);
565 ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
566 NeededLength = sbi.NumberOfProcessors * sizeof(SYSTEM_INTERRUPT_INFORMATION);
568 sii = HeapAlloc(GetProcessHeap(), 0, NeededLength);
570 status = pNtQuerySystemInformation(SystemInterruptInformation, sii, 0, &ReturnLength);
571 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
573 /* Try it for all processors */
574 status = pNtQuerySystemInformation(SystemInterruptInformation, sii, NeededLength, &ReturnLength);
575 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
577 /* Windows XP and W2K3 (and others?) always return 0 for the ReturnLength
578 * No test added for this as it's highly unlikely that an app depends on this
581 HeapFree( GetProcessHeap(), 0, sii);
584 static void test_query_kerndebug(void)
586 NTSTATUS status;
587 ULONG ReturnLength;
588 SYSTEM_KERNEL_DEBUGGER_INFORMATION skdi;
590 status = pNtQuerySystemInformation(SystemKernelDebuggerInformation, &skdi, 0, &ReturnLength);
591 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
593 status = pNtQuerySystemInformation(SystemKernelDebuggerInformation, &skdi, sizeof(skdi), &ReturnLength);
594 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
595 ok( sizeof(skdi) == ReturnLength, "Inconsistent length %d\n", ReturnLength);
597 status = pNtQuerySystemInformation(SystemKernelDebuggerInformation, &skdi, sizeof(skdi) + 2, &ReturnLength);
598 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
599 ok( sizeof(skdi) == ReturnLength, "Inconsistent length %d\n", ReturnLength);
602 static void test_query_regquota(void)
604 NTSTATUS status;
605 ULONG ReturnLength;
606 SYSTEM_REGISTRY_QUOTA_INFORMATION srqi;
608 status = pNtQuerySystemInformation(SystemRegistryQuotaInformation, &srqi, 0, &ReturnLength);
609 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
611 status = pNtQuerySystemInformation(SystemRegistryQuotaInformation, &srqi, sizeof(srqi), &ReturnLength);
612 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
613 ok( sizeof(srqi) == ReturnLength, "Inconsistent length %d\n", ReturnLength);
615 status = pNtQuerySystemInformation(SystemRegistryQuotaInformation, &srqi, sizeof(srqi) + 2, &ReturnLength);
616 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
617 ok( sizeof(srqi) == ReturnLength, "Inconsistent length %d\n", ReturnLength);
620 static void test_query_logicalproc(void)
622 NTSTATUS status;
623 ULONG len, i, proc_no;
624 SYSTEM_LOGICAL_PROCESSOR_INFORMATION *slpi;
625 SYSTEM_INFO si;
627 GetSystemInfo(&si);
629 status = pNtQuerySystemInformation(SystemLogicalProcessorInformation, NULL, 0, &len);
630 if(status == STATUS_INVALID_INFO_CLASS)
632 win_skip("SystemLogicalProcessorInformation is not supported\n");
633 return;
635 if(status == STATUS_NOT_IMPLEMENTED)
637 todo_wine ok(0, "SystemLogicalProcessorInformation is not implemented\n");
638 return;
640 ok(status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
641 ok(len%sizeof(*slpi) == 0, "Incorrect length %d\n", len);
643 slpi = HeapAlloc(GetProcessHeap(), 0, len);
644 status = pNtQuerySystemInformation(SystemLogicalProcessorInformation, slpi, len, &len);
645 ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
647 proc_no = 0;
648 for(i=0; i<len/sizeof(*slpi); i++) {
649 switch(slpi[i].Relationship) {
650 case RelationProcessorCore:
651 /* Get number of logical processors */
652 for(; slpi[i].ProcessorMask; slpi[i].ProcessorMask /= 2)
653 proc_no += slpi[i].ProcessorMask%2;
654 break;
655 default:
656 break;
659 ok(proc_no > 0, "No processors were found\n");
660 if(si.dwNumberOfProcessors <= 32)
661 ok(proc_no == si.dwNumberOfProcessors, "Incorrect number of logical processors: %d, expected %d\n",
662 proc_no, si.dwNumberOfProcessors);
664 HeapFree(GetProcessHeap(), 0, slpi);
667 static void test_query_processor_power_info(void)
669 NTSTATUS status;
670 PROCESSOR_POWER_INFORMATION* ppi;
671 ULONG size;
672 SYSTEM_INFO si;
673 int i;
675 GetSystemInfo(&si);
676 size = si.dwNumberOfProcessors * sizeof(PROCESSOR_POWER_INFORMATION);
677 ppi = HeapAlloc(GetProcessHeap(), 0, size);
679 /* If size < (sizeof(PROCESSOR_POWER_INFORMATION) * NumberOfProcessors), Win7 returns
680 * STATUS_BUFFER_TOO_SMALL. WinXP returns STATUS_SUCCESS for any value of size. It copies as
681 * many whole PROCESSOR_POWER_INFORMATION structures that there is room for. Even if there is
682 * not enough room for one structure, WinXP still returns STATUS_SUCCESS having done nothing.
684 * If ppi == NULL, Win7 returns STATUS_INVALID_PARAMETER while WinXP returns STATUS_SUCCESS
685 * and does nothing.
687 * The same behavior is seen with CallNtPowerInformation (in powrprof.dll).
690 if (si.dwNumberOfProcessors > 1)
692 for(i = 0; i < si.dwNumberOfProcessors; i++)
693 ppi[i].Number = 0xDEADBEEF;
695 /* Call with a buffer size that is large enough to hold at least one but not large
696 * enough to hold them all. This will be STATUS_SUCCESS on WinXP but not on Win7 */
697 status = pNtPowerInformation(ProcessorInformation, 0, 0, ppi, size - sizeof(PROCESSOR_POWER_INFORMATION));
698 if (status == STATUS_SUCCESS)
700 /* lax version found on older Windows like WinXP */
701 ok( (ppi[si.dwNumberOfProcessors - 2].Number != 0xDEADBEEF) &&
702 (ppi[si.dwNumberOfProcessors - 1].Number == 0xDEADBEEF),
703 "Expected all but the last record to be overwritten.\n");
705 status = pNtPowerInformation(ProcessorInformation, 0, 0, 0, size);
706 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
708 for(i = 0; i < si.dwNumberOfProcessors; i++)
709 ppi[i].Number = 0xDEADBEEF;
710 status = pNtPowerInformation(ProcessorInformation, 0, 0, ppi, sizeof(PROCESSOR_POWER_INFORMATION) - 1);
711 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
712 for(i = 0; i < si.dwNumberOfProcessors; i++)
713 if (ppi[i].Number != 0xDEADBEEF) break;
714 ok( i == si.dwNumberOfProcessors, "Expected untouched buffer\n");
716 else
718 /* picky version found on newer Windows like Win7 */
719 ok( ppi[1].Number == 0xDEADBEEF, "Expected untouched buffer.\n");
720 ok( status == STATUS_BUFFER_TOO_SMALL, "Expected STATUS_BUFFER_TOO_SMALL, got %08x\n", status);
722 status = pNtPowerInformation(ProcessorInformation, 0, 0, 0, size);
723 ok( status == STATUS_SUCCESS || status == STATUS_INVALID_PARAMETER, "Got %08x\n", status);
725 status = pNtPowerInformation(ProcessorInformation, 0, 0, ppi, 0);
726 ok( status == STATUS_BUFFER_TOO_SMALL || status == STATUS_INVALID_PARAMETER, "Got %08x\n", status);
729 else
731 skip("Test needs more than one processor.\n");
734 status = pNtPowerInformation(ProcessorInformation, 0, 0, ppi, size);
735 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
737 HeapFree(GetProcessHeap(), 0, ppi);
740 static void test_query_process_basic(void)
742 NTSTATUS status;
743 ULONG ReturnLength;
745 typedef struct _PROCESS_BASIC_INFORMATION_PRIVATE {
746 DWORD_PTR ExitStatus;
747 PPEB PebBaseAddress;
748 DWORD_PTR AffinityMask;
749 DWORD_PTR BasePriority;
750 ULONG_PTR UniqueProcessId;
751 ULONG_PTR InheritedFromUniqueProcessId;
752 } PROCESS_BASIC_INFORMATION_PRIVATE;
754 PROCESS_BASIC_INFORMATION_PRIVATE pbi;
756 /* This test also covers some basic parameter testing that should be the same for
757 * every information class
760 /* Use a nonexistent info class */
761 trace("Check nonexistent info class\n");
762 status = pNtQueryInformationProcess(NULL, -1, NULL, 0, NULL);
763 ok( status == STATUS_INVALID_INFO_CLASS || status == STATUS_NOT_IMPLEMENTED /* vista */,
764 "Expected STATUS_INVALID_INFO_CLASS or STATUS_NOT_IMPLEMENTED, got %08x\n", status);
766 /* Do not give a handle and buffer */
767 trace("Check NULL handle and buffer and zero-length buffersize\n");
768 status = pNtQueryInformationProcess(NULL, ProcessBasicInformation, NULL, 0, NULL);
769 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
771 /* Use a correct info class and buffer size, but still no handle and buffer */
772 trace("Check NULL handle and buffer\n");
773 status = pNtQueryInformationProcess(NULL, ProcessBasicInformation, NULL, sizeof(pbi), NULL);
774 ok( status == STATUS_ACCESS_VIOLATION || status == STATUS_INVALID_HANDLE,
775 "Expected STATUS_ACCESS_VIOLATION or STATUS_INVALID_HANDLE(W2K3), got %08x\n", status);
777 /* Use a correct info class and buffer size, but still no handle */
778 trace("Check NULL handle\n");
779 status = pNtQueryInformationProcess(NULL, ProcessBasicInformation, &pbi, sizeof(pbi), NULL);
780 ok( status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08x\n", status);
782 /* Use a greater buffer size */
783 trace("Check NULL handle and too large buffersize\n");
784 status = pNtQueryInformationProcess(NULL, ProcessBasicInformation, &pbi, sizeof(pbi) * 2, NULL);
785 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
787 /* Use no ReturnLength */
788 trace("Check NULL ReturnLength\n");
789 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessBasicInformation, &pbi, sizeof(pbi), NULL);
790 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
792 /* Finally some correct calls */
793 trace("Check with correct parameters\n");
794 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessBasicInformation, &pbi, sizeof(pbi), &ReturnLength);
795 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
796 ok( sizeof(pbi) == ReturnLength, "Inconsistent length %d\n", ReturnLength);
798 /* Everything is correct except a too large buffersize */
799 trace("Too large buffersize\n");
800 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessBasicInformation, &pbi, sizeof(pbi) * 2, &ReturnLength);
801 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
802 ok( sizeof(pbi) == ReturnLength, "Inconsistent length %d\n", ReturnLength);
804 /* Check if we have some return values */
805 trace("ProcessID : %lx\n", pbi.UniqueProcessId);
806 ok( pbi.UniqueProcessId > 0, "Expected a ProcessID > 0, got 0\n");
809 static void test_query_process_vm(void)
811 NTSTATUS status;
812 ULONG ReturnLength;
813 VM_COUNTERS pvi;
814 ULONG old_size = FIELD_OFFSET(VM_COUNTERS,PrivatePageCount);
816 status = pNtQueryInformationProcess(NULL, ProcessVmCounters, NULL, sizeof(pvi), NULL);
817 ok( status == STATUS_ACCESS_VIOLATION || status == STATUS_INVALID_HANDLE,
818 "Expected STATUS_ACCESS_VIOLATION or STATUS_INVALID_HANDLE(W2K3), got %08x\n", status);
820 status = pNtQueryInformationProcess(NULL, ProcessVmCounters, &pvi, old_size, NULL);
821 ok( status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08x\n", status);
823 /* Windows XP and W2K3 will report success for a size of 44 AND 48 !
824 Windows W2K will only report success for 44.
825 For now we only care for 44, which is FIELD_OFFSET(VM_COUNTERS,PrivatePageCount))
828 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessVmCounters, &pvi, 24, &ReturnLength);
829 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
831 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessVmCounters, &pvi, old_size, &ReturnLength);
832 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
833 ok( old_size == ReturnLength, "Inconsistent length %d\n", ReturnLength);
835 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessVmCounters, &pvi, 46, &ReturnLength);
836 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
837 ok( ReturnLength == old_size || ReturnLength == sizeof(pvi), "Inconsistent length %d\n", ReturnLength);
839 /* Check if we have some return values */
840 trace("WorkingSetSize : %ld\n", pvi.WorkingSetSize);
841 todo_wine
843 ok( pvi.WorkingSetSize > 0, "Expected a WorkingSetSize > 0\n");
847 static void test_query_process_io(void)
849 NTSTATUS status;
850 ULONG ReturnLength;
851 IO_COUNTERS pii;
853 /* NT4 doesn't support this information class, so check for it */
854 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessIoCounters, &pii, sizeof(pii), &ReturnLength);
855 if (status == STATUS_NOT_SUPPORTED)
857 win_skip("ProcessIoCounters information class is not supported\n");
858 return;
861 status = pNtQueryInformationProcess(NULL, ProcessIoCounters, NULL, sizeof(pii), NULL);
862 ok( status == STATUS_ACCESS_VIOLATION || status == STATUS_INVALID_HANDLE,
863 "Expected STATUS_ACCESS_VIOLATION or STATUS_INVALID_HANDLE(W2K3), got %08x\n", status);
865 status = pNtQueryInformationProcess(NULL, ProcessIoCounters, &pii, sizeof(pii), NULL);
866 ok( status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08x\n", status);
868 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessIoCounters, &pii, 24, &ReturnLength);
869 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
871 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessIoCounters, &pii, sizeof(pii), &ReturnLength);
872 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
873 ok( sizeof(pii) == ReturnLength, "Inconsistent length %d\n", ReturnLength);
875 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessIoCounters, &pii, sizeof(pii) * 2, &ReturnLength);
876 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
877 ok( sizeof(pii) == ReturnLength, "Inconsistent length %d\n", ReturnLength);
879 /* Check if we have some return values */
880 trace("OtherOperationCount : 0x%x%08x\n", (DWORD)(pii.OtherOperationCount >> 32), (DWORD)pii.OtherOperationCount);
881 todo_wine
883 ok( pii.OtherOperationCount > 0, "Expected an OtherOperationCount > 0\n");
887 static void test_query_process_times(void)
889 NTSTATUS status;
890 ULONG ReturnLength;
891 HANDLE process;
892 SYSTEMTIME UTC, Local;
893 KERNEL_USER_TIMES spti;
895 status = pNtQueryInformationProcess(NULL, ProcessTimes, NULL, sizeof(spti), NULL);
896 ok( status == STATUS_ACCESS_VIOLATION || status == STATUS_INVALID_HANDLE,
897 "Expected STATUS_ACCESS_VIOLATION or STATUS_INVALID_HANDLE(W2K3), got %08x\n", status);
899 status = pNtQueryInformationProcess(NULL, ProcessTimes, &spti, sizeof(spti), NULL);
900 ok( status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08x\n", status);
902 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessTimes, &spti, 24, &ReturnLength);
903 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
905 process = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, one_before_last_pid);
906 if (!process)
908 trace("Could not open process with ID : %d, error : %u. Going to use current one.\n", one_before_last_pid, GetLastError());
909 process = GetCurrentProcess();
910 trace("ProcessTimes for current process\n");
912 else
913 trace("ProcessTimes for process with ID : %d\n", one_before_last_pid);
915 status = pNtQueryInformationProcess( process, ProcessTimes, &spti, sizeof(spti), &ReturnLength);
916 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
917 ok( sizeof(spti) == ReturnLength, "Inconsistent length %d\n", ReturnLength);
918 CloseHandle(process);
920 FileTimeToSystemTime((const FILETIME *)&spti.CreateTime, &UTC);
921 SystemTimeToTzSpecificLocalTime(NULL, &UTC, &Local);
922 trace("CreateTime : %02d/%02d/%04d %02d:%02d:%02d\n", Local.wMonth, Local.wDay, Local.wYear,
923 Local.wHour, Local.wMinute, Local.wSecond);
925 FileTimeToSystemTime((const FILETIME *)&spti.ExitTime, &UTC);
926 SystemTimeToTzSpecificLocalTime(NULL, &UTC, &Local);
927 trace("ExitTime : %02d/%02d/%04d %02d:%02d:%02d\n", Local.wMonth, Local.wDay, Local.wYear,
928 Local.wHour, Local.wMinute, Local.wSecond);
930 FileTimeToSystemTime((const FILETIME *)&spti.KernelTime, &Local);
931 trace("KernelTime : %02d:%02d:%02d.%03d\n", Local.wHour, Local.wMinute, Local.wSecond, Local.wMilliseconds);
933 FileTimeToSystemTime((const FILETIME *)&spti.UserTime, &Local);
934 trace("UserTime : %02d:%02d:%02d.%03d\n", Local.wHour, Local.wMinute, Local.wSecond, Local.wMilliseconds);
936 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessTimes, &spti, sizeof(spti) * 2, &ReturnLength);
937 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
938 ok( sizeof(spti) == ReturnLength ||
939 ReturnLength == 0 /* vista */ ||
940 broken(is_wow64), /* returns garbage on wow64 */
941 "Inconsistent length %d\n", ReturnLength);
944 static void test_query_process_debug_port(int argc, char **argv)
946 DWORD_PTR debug_port = 0xdeadbeef;
947 char cmdline[MAX_PATH];
948 PROCESS_INFORMATION pi;
949 STARTUPINFOA si = { 0 };
950 NTSTATUS status;
951 BOOL ret;
953 sprintf(cmdline, "%s %s %s", argv[0], argv[1], "debuggee");
955 si.cb = sizeof(si);
956 ret = CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, DEBUG_PROCESS, NULL, NULL, &si, &pi);
957 ok(ret, "CreateProcess failed, last error %#x.\n", GetLastError());
958 if (!ret) return;
960 status = pNtQueryInformationProcess(NULL, ProcessDebugPort,
961 NULL, 0, NULL);
962 ok(status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %#x.\n", status);
964 status = pNtQueryInformationProcess(NULL, ProcessDebugPort,
965 NULL, sizeof(debug_port), NULL);
966 ok(status == STATUS_INVALID_HANDLE || status == STATUS_ACCESS_VIOLATION,
967 "Expected STATUS_INVALID_HANDLE, got %#x.\n", status);
969 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessDebugPort,
970 NULL, sizeof(debug_port), NULL);
971 ok(status == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got %#x.\n", status);
973 status = pNtQueryInformationProcess(NULL, ProcessDebugPort,
974 &debug_port, sizeof(debug_port), NULL);
975 ok(status == STATUS_INVALID_HANDLE, "Expected STATUS_ACCESS_VIOLATION, got %#x.\n", status);
977 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessDebugPort,
978 &debug_port, sizeof(debug_port) - 1, NULL);
979 ok(status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %#x.\n", status);
981 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessDebugPort,
982 &debug_port, sizeof(debug_port) + 1, NULL);
983 ok(status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %#x.\n", status);
985 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessDebugPort,
986 &debug_port, sizeof(debug_port), NULL);
987 ok(!status, "NtQueryInformationProcess failed, status %#x.\n", status);
988 ok(debug_port == 0, "Expected port 0, got %#lx.\n", debug_port);
990 status = pNtQueryInformationProcess(pi.hProcess, ProcessDebugPort,
991 &debug_port, sizeof(debug_port), NULL);
992 ok(!status, "NtQueryInformationProcess failed, status %#x.\n", status);
993 ok(debug_port == ~(DWORD_PTR)0, "Expected port %#lx, got %#lx.\n", ~(DWORD_PTR)0, debug_port);
995 for (;;)
997 DEBUG_EVENT ev;
999 ret = WaitForDebugEvent(&ev, INFINITE);
1000 ok(ret, "WaitForDebugEvent failed, last error %#x.\n", GetLastError());
1001 if (!ret) break;
1003 if (ev.dwDebugEventCode == EXIT_PROCESS_DEBUG_EVENT) break;
1005 ret = ContinueDebugEvent(ev.dwProcessId, ev.dwThreadId, DBG_CONTINUE);
1006 ok(ret, "ContinueDebugEvent failed, last error %#x.\n", GetLastError());
1007 if (!ret) break;
1010 ret = CloseHandle(pi.hThread);
1011 ok(ret, "CloseHandle failed, last error %#x.\n", GetLastError());
1012 ret = CloseHandle(pi.hProcess);
1013 ok(ret, "CloseHandle failed, last error %#x.\n", GetLastError());
1016 static void test_query_process_handlecount(void)
1018 NTSTATUS status;
1019 ULONG ReturnLength;
1020 DWORD handlecount;
1021 BYTE buffer[2 * sizeof(DWORD)];
1022 HANDLE process;
1024 status = pNtQueryInformationProcess(NULL, ProcessHandleCount, NULL, sizeof(handlecount), NULL);
1025 ok( status == STATUS_ACCESS_VIOLATION || status == STATUS_INVALID_HANDLE,
1026 "Expected STATUS_ACCESS_VIOLATION or STATUS_INVALID_HANDLE(W2K3), got %08x\n", status);
1028 status = pNtQueryInformationProcess(NULL, ProcessHandleCount, &handlecount, sizeof(handlecount), NULL);
1029 ok( status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08x\n", status);
1031 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessHandleCount, &handlecount, 2, &ReturnLength);
1032 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
1034 process = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, one_before_last_pid);
1035 if (!process)
1037 trace("Could not open process with ID : %d, error : %u. Going to use current one.\n", one_before_last_pid, GetLastError());
1038 process = GetCurrentProcess();
1039 trace("ProcessHandleCount for current process\n");
1041 else
1042 trace("ProcessHandleCount for process with ID : %d\n", one_before_last_pid);
1044 status = pNtQueryInformationProcess( process, ProcessHandleCount, &handlecount, sizeof(handlecount), &ReturnLength);
1045 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1046 ok( sizeof(handlecount) == ReturnLength, "Inconsistent length %d\n", ReturnLength);
1047 CloseHandle(process);
1049 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessHandleCount, buffer, sizeof(buffer), &ReturnLength);
1050 ok( status == STATUS_INFO_LENGTH_MISMATCH || status == STATUS_SUCCESS,
1051 "Expected STATUS_INFO_LENGTH_MISMATCH or STATUS_SUCCESS, got %08x\n", status);
1052 ok( sizeof(handlecount) == ReturnLength, "Inconsistent length %d\n", ReturnLength);
1054 /* Check if we have some return values */
1055 trace("HandleCount : %d\n", handlecount);
1056 todo_wine
1058 ok( handlecount > 0, "Expected some handles, got 0\n");
1062 static void test_query_process_image_file_name(void)
1064 NTSTATUS status;
1065 ULONG ReturnLength;
1066 UNICODE_STRING image_file_name;
1067 void *buffer;
1068 char *file_nameA;
1069 INT len;
1071 status = pNtQueryInformationProcess(NULL, ProcessImageFileName, &image_file_name, sizeof(image_file_name), NULL);
1072 if (status == STATUS_INVALID_INFO_CLASS)
1074 win_skip("ProcessImageFileName is not supported\n");
1075 return;
1077 ok( status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08x\n", status);
1079 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessImageFileName, &image_file_name, 2, &ReturnLength);
1080 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
1082 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessImageFileName, &image_file_name, sizeof(image_file_name), &ReturnLength);
1083 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
1085 buffer = HeapAlloc(GetProcessHeap(), 0, ReturnLength);
1086 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessImageFileName, buffer, ReturnLength, &ReturnLength);
1087 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1088 memcpy(&image_file_name, buffer, sizeof(image_file_name));
1089 len = WideCharToMultiByte(CP_ACP, 0, image_file_name.Buffer, image_file_name.Length/sizeof(WCHAR), NULL, 0, NULL, NULL);
1090 file_nameA = HeapAlloc(GetProcessHeap(), 0, len + 1);
1091 WideCharToMultiByte(CP_ACP, 0, image_file_name.Buffer, image_file_name.Length/sizeof(WCHAR), file_nameA, len, NULL, NULL);
1092 file_nameA[len] = '\0';
1093 HeapFree(GetProcessHeap(), 0, buffer);
1094 trace("process image file name: %s\n", file_nameA);
1095 todo_wine ok(strncmp(file_nameA, "\\Device\\", 8) == 0, "Process image name should be an NT path beginning with \\Device\\ (is %s)\n", file_nameA);
1096 HeapFree(GetProcessHeap(), 0, file_nameA);
1099 static void test_query_process_debug_object_handle(int argc, char **argv)
1101 char cmdline[MAX_PATH];
1102 STARTUPINFOA si = {0};
1103 PROCESS_INFORMATION pi;
1104 BOOL ret;
1105 HANDLE debug_object;
1106 NTSTATUS status;
1108 sprintf(cmdline, "%s %s %s", argv[0], argv[1], "debuggee");
1110 si.cb = sizeof(si);
1111 ret = CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, DEBUG_PROCESS, NULL,
1112 NULL, &si, &pi);
1113 ok(ret, "CreateProcess failed with last error %u\n", GetLastError());
1114 if (!ret) return;
1116 status = pNtQueryInformationProcess(NULL, ProcessDebugObjectHandle, NULL,
1117 0, NULL);
1118 if (status == STATUS_INVALID_INFO_CLASS || status == STATUS_NOT_IMPLEMENTED)
1120 win_skip("ProcessDebugObjectHandle is not supported\n");
1121 return;
1123 ok(status == STATUS_INFO_LENGTH_MISMATCH,
1124 "Expected NtQueryInformationProcess to return STATUS_INFO_LENGTH_MISMATCH, got 0x%08x\n",
1125 status);
1127 status = pNtQueryInformationProcess(NULL, ProcessDebugObjectHandle, NULL,
1128 sizeof(debug_object), NULL);
1129 ok(status == STATUS_INVALID_HANDLE ||
1130 status == STATUS_ACCESS_VIOLATION, /* XP */
1131 "Expected NtQueryInformationProcess to return STATUS_INVALID_HANDLE, got 0x%08x\n", status);
1133 status = pNtQueryInformationProcess(GetCurrentProcess(),
1134 ProcessDebugObjectHandle, NULL, sizeof(debug_object), NULL);
1135 ok(status == STATUS_ACCESS_VIOLATION,
1136 "Expected NtQueryInformationProcess to return STATUS_ACCESS_VIOLATION, got 0x%08x\n", status);
1138 status = pNtQueryInformationProcess(NULL, ProcessDebugObjectHandle,
1139 &debug_object, sizeof(debug_object), NULL);
1140 ok(status == STATUS_INVALID_HANDLE,
1141 "Expected NtQueryInformationProcess to return STATUS_ACCESS_VIOLATION, got 0x%08x\n", status);
1143 status = pNtQueryInformationProcess(GetCurrentProcess(),
1144 ProcessDebugObjectHandle, &debug_object,
1145 sizeof(debug_object) - 1, NULL);
1146 ok(status == STATUS_INFO_LENGTH_MISMATCH,
1147 "Expected NtQueryInformationProcess to return STATUS_INFO_LENGTH_MISMATCH, got 0x%08x\n", status);
1149 status = pNtQueryInformationProcess(GetCurrentProcess(),
1150 ProcessDebugObjectHandle, &debug_object,
1151 sizeof(debug_object) + 1, NULL);
1152 ok(status == STATUS_INFO_LENGTH_MISMATCH,
1153 "Expected NtQueryInformationProcess to return STATUS_INFO_LENGTH_MISMATCH, got 0x%08x\n", status);
1155 debug_object = (HANDLE)0xdeadbeef;
1156 status = pNtQueryInformationProcess(GetCurrentProcess(),
1157 ProcessDebugObjectHandle, &debug_object,
1158 sizeof(debug_object), NULL);
1159 ok(status == STATUS_PORT_NOT_SET,
1160 "Expected NtQueryInformationProcess to return STATUS_PORT_NOT_SET, got 0x%08x\n", status);
1161 ok(debug_object == NULL ||
1162 broken(debug_object == (HANDLE)0xdeadbeef), /* Wow64 */
1163 "Expected debug object handle to be NULL, got %p\n", debug_object);
1165 debug_object = (HANDLE)0xdeadbeef;
1166 status = pNtQueryInformationProcess(pi.hProcess, ProcessDebugObjectHandle,
1167 &debug_object, sizeof(debug_object), NULL);
1168 todo_wine
1169 ok(status == STATUS_SUCCESS,
1170 "Expected NtQueryInformationProcess to return STATUS_SUCCESS, got 0x%08x\n", status);
1171 todo_wine
1172 ok(debug_object != NULL,
1173 "Expected debug object handle to be non-NULL, got %p\n", debug_object);
1175 for (;;)
1177 DEBUG_EVENT ev;
1179 ret = WaitForDebugEvent(&ev, INFINITE);
1180 ok(ret, "WaitForDebugEvent failed with last error %u\n", GetLastError());
1181 if (!ret) break;
1183 if (ev.dwDebugEventCode == EXIT_PROCESS_DEBUG_EVENT) break;
1185 ret = ContinueDebugEvent(ev.dwProcessId, ev.dwThreadId, DBG_CONTINUE);
1186 ok(ret, "ContinueDebugEvent failed with last error %u\n", GetLastError());
1187 if (!ret) break;
1190 ret = CloseHandle(pi.hThread);
1191 ok(ret, "CloseHandle failed with last error %u\n", GetLastError());
1192 ret = CloseHandle(pi.hProcess);
1193 ok(ret, "CloseHandle failed with last error %u\n", GetLastError());
1196 static void test_query_process_debug_flags(int argc, char **argv)
1198 DWORD debug_flags = 0xdeadbeef;
1199 char cmdline[MAX_PATH];
1200 PROCESS_INFORMATION pi;
1201 STARTUPINFOA si = { 0 };
1202 NTSTATUS status;
1203 BOOL ret;
1205 sprintf(cmdline, "%s %s %s", argv[0], argv[1], "debuggee");
1207 si.cb = sizeof(si);
1208 ret = CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, DEBUG_PROCESS | DEBUG_ONLY_THIS_PROCESS, NULL, NULL, &si, &pi);
1209 ok(ret, "CreateProcess failed, last error %#x.\n", GetLastError());
1210 if (!ret) return;
1212 status = pNtQueryInformationProcess(NULL, ProcessDebugFlags,
1213 NULL, 0, NULL);
1214 ok(status == STATUS_INFO_LENGTH_MISMATCH || broken(status == STATUS_INVALID_INFO_CLASS) /* NT4 */, "Expected STATUS_INFO_LENGTH_MISMATCH, got %#x.\n", status);
1216 status = pNtQueryInformationProcess(NULL, ProcessDebugFlags,
1217 NULL, sizeof(debug_flags), NULL);
1218 ok(status == STATUS_INVALID_HANDLE || status == STATUS_ACCESS_VIOLATION || broken(status == STATUS_INVALID_INFO_CLASS) /* W7PROX64 (32-bit) */,
1219 "Expected STATUS_INVALID_HANDLE, got %#x.\n", status);
1221 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessDebugFlags,
1222 NULL, sizeof(debug_flags), NULL);
1223 ok(status == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got %#x.\n", status);
1225 status = pNtQueryInformationProcess(NULL, ProcessDebugFlags,
1226 &debug_flags, sizeof(debug_flags), NULL);
1227 ok(status == STATUS_INVALID_HANDLE || broken(status == STATUS_INVALID_INFO_CLASS) /* NT4 */, "Expected STATUS_ACCESS_VIOLATION, got %#x.\n", status);
1229 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessDebugFlags,
1230 &debug_flags, sizeof(debug_flags) - 1, NULL);
1231 ok(status == STATUS_INFO_LENGTH_MISMATCH || broken(status == STATUS_INVALID_INFO_CLASS) /* NT4 */, "Expected STATUS_INFO_LENGTH_MISMATCH, got %#x.\n", status);
1233 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessDebugFlags,
1234 &debug_flags, sizeof(debug_flags) + 1, NULL);
1235 ok(status == STATUS_INFO_LENGTH_MISMATCH || broken(status == STATUS_INVALID_INFO_CLASS) /* NT4 */, "Expected STATUS_INFO_LENGTH_MISMATCH, got %#x.\n", status);
1237 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessDebugFlags,
1238 &debug_flags, sizeof(debug_flags), NULL);
1239 ok(!status || broken(status == STATUS_INVALID_INFO_CLASS) /* NT4 */, "NtQueryInformationProcess failed, status %#x.\n", status);
1240 ok(debug_flags == TRUE|| broken(status == STATUS_INVALID_INFO_CLASS) /* NT4 */, "Expected flag TRUE, got %x.\n", debug_flags);
1242 status = pNtQueryInformationProcess(pi.hProcess, ProcessDebugFlags,
1243 &debug_flags, sizeof(debug_flags), NULL);
1244 ok(!status || broken(status == STATUS_INVALID_INFO_CLASS) /* NT4 */, "NtQueryInformationProcess failed, status %#x.\n", status);
1245 ok(debug_flags == FALSE || broken(status == STATUS_INVALID_INFO_CLASS) /* NT4 */, "Expected flag FALSE, got %x.\n", debug_flags);
1247 for (;;)
1249 DEBUG_EVENT ev;
1251 ret = WaitForDebugEvent(&ev, INFINITE);
1252 ok(ret, "WaitForDebugEvent failed, last error %#x.\n", GetLastError());
1253 if (!ret) break;
1255 if (ev.dwDebugEventCode == EXIT_PROCESS_DEBUG_EVENT) break;
1257 ret = ContinueDebugEvent(ev.dwProcessId, ev.dwThreadId, DBG_CONTINUE);
1258 ok(ret, "ContinueDebugEvent failed, last error %#x.\n", GetLastError());
1259 if (!ret) break;
1262 ret = CloseHandle(pi.hThread);
1263 ok(ret, "CloseHandle failed, last error %#x.\n", GetLastError());
1264 ret = CloseHandle(pi.hProcess);
1265 ok(ret, "CloseHandle failed, last error %#x.\n", GetLastError());
1268 static void test_readvirtualmemory(void)
1270 HANDLE process;
1271 NTSTATUS status;
1272 SIZE_T readcount;
1273 static const char teststring[] = "test string";
1274 char buffer[12];
1276 process = OpenProcess(PROCESS_VM_READ, FALSE, GetCurrentProcessId());
1277 ok(process != 0, "Expected to be able to open own process for reading memory\n");
1279 /* normal operation */
1280 status = pNtReadVirtualMemory(process, teststring, buffer, 12, &readcount);
1281 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1282 ok( readcount == 12, "Expected to read 12 bytes, got %ld\n",readcount);
1283 ok( strcmp(teststring, buffer) == 0, "Expected read memory to be the same as original memory\n");
1285 /* no number of bytes */
1286 memset(buffer, 0, 12);
1287 status = pNtReadVirtualMemory(process, teststring, buffer, 12, NULL);
1288 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1289 ok( strcmp(teststring, buffer) == 0, "Expected read memory to be the same as original memory\n");
1291 /* illegal remote address */
1292 todo_wine{
1293 status = pNtReadVirtualMemory(process, (void *) 0x1234, buffer, 12, &readcount);
1294 ok( status == STATUS_PARTIAL_COPY || broken(status == STATUS_ACCESS_VIOLATION), "Expected STATUS_PARTIAL_COPY, got %08x\n", status);
1295 if (status == STATUS_PARTIAL_COPY)
1296 ok( readcount == 0, "Expected to read 0 bytes, got %ld\n",readcount);
1299 /* 0 handle */
1300 status = pNtReadVirtualMemory(0, teststring, buffer, 12, &readcount);
1301 ok( status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08x\n", status);
1302 ok( readcount == 0, "Expected to read 0 bytes, got %ld\n",readcount);
1304 /* pseudo handle for current process*/
1305 memset(buffer, 0, 12);
1306 status = pNtReadVirtualMemory((HANDLE)-1, teststring, buffer, 12, &readcount);
1307 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1308 ok( readcount == 12, "Expected to read 12 bytes, got %ld\n",readcount);
1309 ok( strcmp(teststring, buffer) == 0, "Expected read memory to be the same as original memory\n");
1311 /* illegal local address */
1312 status = pNtReadVirtualMemory(process, teststring, (void *)0x1234, 12, &readcount);
1313 ok( status == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got %08x\n", status);
1314 ok( readcount == 0, "Expected to read 0 bytes, got %ld\n",readcount);
1316 CloseHandle(process);
1319 static void test_mapprotection(void)
1321 HANDLE h;
1322 void* addr;
1323 MEMORY_BASIC_INFORMATION info;
1324 ULONG oldflags, flagsize, flags = MEM_EXECUTE_OPTION_ENABLE;
1325 LARGE_INTEGER size, offset;
1326 NTSTATUS status;
1327 SIZE_T retlen, count;
1328 void (*f)(void);
1330 if (!pNtClose) {
1331 skip("No NtClose ... Win98\n");
1332 return;
1334 /* Switch to being a noexec unaware process */
1335 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessExecuteFlags, &oldflags, sizeof (oldflags), &flagsize);
1336 if (status == STATUS_INVALID_PARAMETER) {
1337 skip("Invalid Parameter on ProcessExecuteFlags query?\n");
1338 return;
1340 ok( (status == STATUS_SUCCESS) || (status == STATUS_INVALID_INFO_CLASS), "Expected STATUS_SUCCESS, got %08x\n", status);
1341 status = pNtSetInformationProcess( GetCurrentProcess(), ProcessExecuteFlags, &flags, sizeof(flags) );
1342 ok( (status == STATUS_SUCCESS) || (status == STATUS_INVALID_INFO_CLASS), "Expected STATUS_SUCCESS, got %08x\n", status);
1344 size.u.LowPart = 0x1000;
1345 size.u.HighPart = 0;
1346 status = pNtCreateSection ( &h,
1347 STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_READ | SECTION_MAP_WRITE | SECTION_MAP_EXECUTE,
1348 NULL,
1349 &size,
1350 PAGE_READWRITE,
1351 SEC_COMMIT | SEC_NOCACHE,
1354 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1356 offset.u.LowPart = 0;
1357 offset.u.HighPart = 0;
1358 count = 0x1000;
1359 addr = NULL;
1360 status = pNtMapViewOfSection ( h, GetCurrentProcess(), &addr, 0, 0, &offset, &count, ViewShare, 0, PAGE_READWRITE);
1361 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1363 #if defined(__x86_64__) || defined(__i386__)
1364 *(unsigned char*)addr = 0xc3; /* lret ... in both i386 and x86_64 */
1365 #elif defined(__arm__)
1366 *(unsigned long*)addr = 0xe12fff1e; /* bx lr */
1367 #else
1368 ok(0, "Add a return opcode for your architecture or expect a crash in this test\n");
1369 #endif
1370 trace("trying to execute code in the readwrite only mapped anon file...\n");
1371 f = addr;f();
1372 trace("...done.\n");
1374 status = pNtQueryVirtualMemory( GetCurrentProcess(), addr, MemoryBasicInformation, &info, sizeof(info), &retlen );
1375 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1376 ok( retlen == sizeof(info), "Expected STATUS_SUCCESS, got %08x\n", status);
1377 ok((info.Protect & ~PAGE_NOCACHE) == PAGE_READWRITE, "addr.Protect is not PAGE_READWRITE, but 0x%x\n", info.Protect);
1379 status = pNtUnmapViewOfSection (GetCurrentProcess(), addr);
1380 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1381 pNtClose (h);
1383 /* Switch back */
1384 pNtSetInformationProcess( GetCurrentProcess(), ProcessExecuteFlags, &oldflags, sizeof(oldflags) );
1387 static void test_queryvirtualmemory(void)
1389 NTSTATUS status;
1390 SIZE_T readcount;
1391 static const char teststring[] = "test string";
1392 static char datatestbuf[42] = "abc";
1393 static char rwtestbuf[42];
1394 MEMORY_BASIC_INFORMATION mbi;
1395 char stackbuf[42];
1396 HMODULE module;
1398 module = GetModuleHandleA( "ntdll.dll" );
1399 trace("Check flags of the PE header of NTDLL.DLL at %p\n", module);
1400 status = pNtQueryVirtualMemory(NtCurrentProcess(), module, MemoryBasicInformation, &mbi, sizeof(MEMORY_BASIC_INFORMATION), &readcount);
1401 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1402 ok( readcount == sizeof(MEMORY_BASIC_INFORMATION), "Expected to read %d bytes, got %ld\n",(int)sizeof(MEMORY_BASIC_INFORMATION),readcount);
1403 ok (mbi.AllocationBase == module, "mbi.AllocationBase is 0x%p, expected 0x%p\n", mbi.AllocationBase, module);
1404 ok (mbi.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "mbi.AllocationProtect is 0x%x, expected 0x%x\n", mbi.AllocationProtect, PAGE_EXECUTE_WRITECOPY);
1405 ok (mbi.State == MEM_COMMIT, "mbi.State is 0x%x, expected 0x%x\n", mbi.State, MEM_COMMIT);
1406 ok (mbi.Protect == PAGE_READONLY, "mbi.Protect is 0x%x, expected 0x%x\n", mbi.Protect, PAGE_READONLY);
1407 ok (mbi.Type == MEM_IMAGE, "mbi.Type is 0x%x, expected 0x%x\n", mbi.Type, MEM_IMAGE);
1409 trace("Check flags of a function entry in NTDLL.DLL at %p\n", pNtQueryVirtualMemory);
1410 module = GetModuleHandleA( "ntdll.dll" );
1411 status = pNtQueryVirtualMemory(NtCurrentProcess(), pNtQueryVirtualMemory, MemoryBasicInformation, &mbi, sizeof(MEMORY_BASIC_INFORMATION), &readcount);
1412 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1413 ok( readcount == sizeof(MEMORY_BASIC_INFORMATION), "Expected to read %d bytes, got %ld\n",(int)sizeof(MEMORY_BASIC_INFORMATION),readcount);
1414 ok (mbi.AllocationBase == module, "mbi.AllocationBase is 0x%p, expected 0x%p\n", mbi.AllocationBase, module);
1415 ok (mbi.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "mbi.AllocationProtect is 0x%x, expected 0x%x\n", mbi.AllocationProtect, PAGE_EXECUTE_WRITECOPY);
1416 ok (mbi.State == MEM_COMMIT, "mbi.State is 0x%x, expected 0x%x\n", mbi.State, MEM_COMMIT);
1417 ok (mbi.Protect == PAGE_EXECUTE_READ, "mbi.Protect is 0x%x, expected 0x%x\n", mbi.Protect, PAGE_EXECUTE_READ);
1419 trace("Check flags of heap at %p\n", GetProcessHeap());
1420 status = pNtQueryVirtualMemory(NtCurrentProcess(), GetProcessHeap(), MemoryBasicInformation, &mbi, sizeof(MEMORY_BASIC_INFORMATION), &readcount);
1421 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1422 ok( readcount == sizeof(MEMORY_BASIC_INFORMATION), "Expected to read %d bytes, got %ld\n",(int)sizeof(MEMORY_BASIC_INFORMATION),readcount);
1423 ok (mbi.AllocationProtect == PAGE_READWRITE || mbi.AllocationProtect == PAGE_EXECUTE_READWRITE,
1424 "mbi.AllocationProtect is 0x%x\n", mbi.AllocationProtect);
1425 ok (mbi.State == MEM_COMMIT, "mbi.State is 0x%x, expected 0x%x\n", mbi.State, MEM_COMMIT);
1426 ok (mbi.Protect == PAGE_READWRITE || mbi.Protect == PAGE_EXECUTE_READWRITE,
1427 "mbi.Protect is 0x%x\n", mbi.Protect);
1429 trace("Check flags of stack at %p\n", stackbuf);
1430 status = pNtQueryVirtualMemory(NtCurrentProcess(), stackbuf, MemoryBasicInformation, &mbi, sizeof(MEMORY_BASIC_INFORMATION), &readcount);
1431 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1432 ok( readcount == sizeof(MEMORY_BASIC_INFORMATION), "Expected to read %d bytes, got %ld\n",(int)sizeof(MEMORY_BASIC_INFORMATION),readcount);
1433 ok (mbi.AllocationProtect == PAGE_READWRITE, "mbi.AllocationProtect is 0x%x, expected 0x%x\n", mbi.AllocationProtect, PAGE_READWRITE);
1434 ok (mbi.State == MEM_COMMIT, "mbi.State is 0x%x, expected 0x%x\n", mbi.State, MEM_COMMIT);
1435 ok (mbi.Protect == PAGE_READWRITE, "mbi.Protect is 0x%x, expected 0x%x\n", mbi.Protect, PAGE_READWRITE);
1437 trace("Check flags of read-only data at %p\n", teststring);
1438 module = GetModuleHandleA( NULL );
1439 status = pNtQueryVirtualMemory(NtCurrentProcess(), teststring, MemoryBasicInformation, &mbi, sizeof(MEMORY_BASIC_INFORMATION), &readcount);
1440 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1441 ok( readcount == sizeof(MEMORY_BASIC_INFORMATION), "Expected to read %d bytes, got %ld\n",(int)sizeof(MEMORY_BASIC_INFORMATION),readcount);
1442 ok (mbi.AllocationBase == module, "mbi.AllocationBase is 0x%p, expected 0x%p\n", mbi.AllocationBase, module);
1443 ok (mbi.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "mbi.AllocationProtect is 0x%x, expected 0x%x\n", mbi.AllocationProtect, PAGE_EXECUTE_WRITECOPY);
1444 ok (mbi.State == MEM_COMMIT, "mbi.State is 0x%x, expected 0x%X\n", mbi.State, MEM_COMMIT);
1445 if (mbi.Protect != PAGE_READONLY)
1446 todo_wine ok( mbi.Protect == PAGE_READONLY, "mbi.Protect is 0x%x, expected 0x%X\n", mbi.Protect, PAGE_READONLY);
1448 trace("Check flags of read-write data at %p\n", datatestbuf);
1449 status = pNtQueryVirtualMemory(NtCurrentProcess(), datatestbuf, MemoryBasicInformation, &mbi, sizeof(MEMORY_BASIC_INFORMATION), &readcount);
1450 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1451 ok( readcount == sizeof(MEMORY_BASIC_INFORMATION), "Expected to read %d bytes, got %ld\n",(int)sizeof(MEMORY_BASIC_INFORMATION),readcount);
1452 ok (mbi.AllocationBase == module, "mbi.AllocationBase is 0x%p, expected 0x%p\n", mbi.AllocationBase, module);
1453 ok (mbi.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "mbi.AllocationProtect is 0x%x, expected 0x%x\n", mbi.AllocationProtect, PAGE_EXECUTE_WRITECOPY);
1454 ok (mbi.State == MEM_COMMIT, "mbi.State is 0x%x, expected 0x%X\n", mbi.State, MEM_COMMIT);
1455 ok (mbi.Protect == PAGE_READWRITE || mbi.Protect == PAGE_WRITECOPY,
1456 "mbi.Protect is 0x%x\n", mbi.Protect);
1458 trace("Check flags of read-write uninitialized data (.bss) at %p\n", rwtestbuf);
1459 status = pNtQueryVirtualMemory(NtCurrentProcess(), rwtestbuf, MemoryBasicInformation, &mbi, sizeof(MEMORY_BASIC_INFORMATION), &readcount);
1460 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1461 ok( readcount == sizeof(MEMORY_BASIC_INFORMATION), "Expected to read %d bytes, got %ld\n",(int)sizeof(MEMORY_BASIC_INFORMATION),readcount);
1462 if (mbi.AllocationBase == module)
1464 ok (mbi.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "mbi.AllocationProtect is 0x%x, expected 0x%x\n", mbi.AllocationProtect, PAGE_EXECUTE_WRITECOPY);
1465 ok (mbi.State == MEM_COMMIT, "mbi.State is 0x%x, expected 0x%X\n", mbi.State, MEM_COMMIT);
1466 ok (mbi.Protect == PAGE_READWRITE || mbi.Protect == PAGE_WRITECOPY,
1467 "mbi.Protect is 0x%x\n", mbi.Protect);
1469 else skip( "bss is outside of module\n" ); /* this can happen on Mac OS */
1472 static void test_affinity(void)
1474 NTSTATUS status;
1475 PROCESS_BASIC_INFORMATION pbi;
1476 DWORD_PTR proc_affinity, thread_affinity;
1477 THREAD_BASIC_INFORMATION tbi;
1478 SYSTEM_INFO si;
1480 GetSystemInfo(&si);
1481 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessBasicInformation, &pbi, sizeof(pbi), NULL );
1482 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1483 proc_affinity = pbi.AffinityMask;
1484 ok( proc_affinity == (1 << si.dwNumberOfProcessors) - 1, "Unexpected process affinity\n" );
1485 proc_affinity = 1 << si.dwNumberOfProcessors;
1486 status = pNtSetInformationProcess( GetCurrentProcess(), ProcessAffinityMask, &proc_affinity, sizeof(proc_affinity) );
1487 ok( status == STATUS_INVALID_PARAMETER,
1488 "Expected STATUS_INVALID_PARAMETER, got %08x\n", status);
1490 proc_affinity = 0;
1491 status = pNtSetInformationProcess( GetCurrentProcess(), ProcessAffinityMask, &proc_affinity, sizeof(proc_affinity) );
1492 ok( status == STATUS_INVALID_PARAMETER,
1493 "Expected STATUS_INVALID_PARAMETER, got %08x\n", status);
1495 status = pNtQueryInformationThread( GetCurrentThread(), ThreadBasicInformation, &tbi, sizeof(tbi), NULL );
1496 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1497 ok( tbi.AffinityMask == (1 << si.dwNumberOfProcessors) - 1, "Unexpected thread affinity\n" );
1498 thread_affinity = 1 << si.dwNumberOfProcessors;
1499 status = pNtSetInformationThread( GetCurrentThread(), ThreadAffinityMask, &thread_affinity, sizeof(thread_affinity) );
1500 ok( status == STATUS_INVALID_PARAMETER,
1501 "Expected STATUS_INVALID_PARAMETER, got %08x\n", status);
1502 thread_affinity = 0;
1503 status = pNtSetInformationThread( GetCurrentThread(), ThreadAffinityMask, &thread_affinity, sizeof(thread_affinity) );
1504 ok( status == STATUS_INVALID_PARAMETER,
1505 "Expected STATUS_INVALID_PARAMETER, got %08x\n", status);
1507 thread_affinity = 1;
1508 status = pNtSetInformationThread( GetCurrentThread(), ThreadAffinityMask, &thread_affinity, sizeof(thread_affinity) );
1509 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1510 status = pNtQueryInformationThread( GetCurrentThread(), ThreadBasicInformation, &tbi, sizeof(tbi), NULL );
1511 ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1512 ok( tbi.AffinityMask == 1, "Unexpected thread affinity\n" );
1514 /* NOTE: Pre-Vista does not recognize the "all processors" flag (all bits set) */
1515 thread_affinity = ~(DWORD_PTR)0;
1516 status = pNtSetInformationThread( GetCurrentThread(), ThreadAffinityMask, &thread_affinity, sizeof(thread_affinity) );
1517 ok( broken(status == STATUS_INVALID_PARAMETER) || status == STATUS_SUCCESS,
1518 "Expected STATUS_SUCCESS, got %08x\n", status);
1520 if (si.dwNumberOfProcessors <= 1)
1522 skip("only one processor, skipping affinity testing\n");
1523 return;
1526 /* Test thread affinity mask resulting from "all processors" flag */
1527 if (status == STATUS_SUCCESS)
1529 status = pNtQueryInformationThread( GetCurrentThread(), ThreadBasicInformation, &tbi, sizeof(tbi), NULL );
1530 ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1531 ok( broken(tbi.AffinityMask == 1) || tbi.AffinityMask == (1 << si.dwNumberOfProcessors) - 1,
1532 "Unexpected thread affinity\n" );
1534 else
1535 skip("Cannot test thread affinity mask for 'all processors' flag\n");
1537 proc_affinity = 2;
1538 status = pNtSetInformationProcess( GetCurrentProcess(), ProcessAffinityMask, &proc_affinity, sizeof(proc_affinity) );
1539 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1540 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessBasicInformation, &pbi, sizeof(pbi), NULL );
1541 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1542 proc_affinity = pbi.AffinityMask;
1543 ok( proc_affinity == 2, "Unexpected process affinity\n" );
1544 /* Setting the process affinity changes the thread affinity to match */
1545 status = pNtQueryInformationThread( GetCurrentThread(), ThreadBasicInformation, &tbi, sizeof(tbi), NULL );
1546 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1547 ok( tbi.AffinityMask == 2, "Unexpected thread affinity\n" );
1548 /* The thread affinity is restricted to the process affinity */
1549 thread_affinity = 1;
1550 status = pNtSetInformationThread( GetCurrentThread(), ThreadAffinityMask, &thread_affinity, sizeof(thread_affinity) );
1551 ok( status == STATUS_INVALID_PARAMETER,
1552 "Expected STATUS_INVALID_PARAMETER, got %08x\n", status);
1554 proc_affinity = (1 << si.dwNumberOfProcessors) - 1;
1555 status = pNtSetInformationProcess( GetCurrentProcess(), ProcessAffinityMask, &proc_affinity, sizeof(proc_affinity) );
1556 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1557 /* Resetting the process affinity also resets the thread affinity */
1558 status = pNtQueryInformationThread( GetCurrentThread(), ThreadBasicInformation, &tbi, sizeof(tbi), NULL );
1559 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
1560 ok( tbi.AffinityMask == (1 << si.dwNumberOfProcessors) - 1,
1561 "Unexpected thread affinity\n" );
1564 static void test_NtGetCurrentProcessorNumber(void)
1566 NTSTATUS status;
1567 SYSTEM_INFO si;
1568 PROCESS_BASIC_INFORMATION pbi;
1569 THREAD_BASIC_INFORMATION tbi;
1570 DWORD_PTR old_process_mask;
1571 DWORD_PTR old_thread_mask;
1572 DWORD_PTR new_mask;
1573 ULONG current_cpu;
1574 ULONG i;
1576 if (!pNtGetCurrentProcessorNumber) {
1577 win_skip("NtGetCurrentProcessorNumber not available\n");
1578 return;
1581 GetSystemInfo(&si);
1582 current_cpu = pNtGetCurrentProcessorNumber();
1583 trace("dwNumberOfProcessors: %d, current processor: %d\n", si.dwNumberOfProcessors, current_cpu);
1585 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessBasicInformation, &pbi, sizeof(pbi), NULL);
1586 old_process_mask = pbi.AffinityMask;
1587 ok(status == STATUS_SUCCESS, "got 0x%x (expected STATUS_SUCCESS)\n", status);
1589 status = pNtQueryInformationThread(GetCurrentThread(), ThreadBasicInformation, &tbi, sizeof(tbi), NULL);
1590 old_thread_mask = tbi.AffinityMask;
1591 ok(status == STATUS_SUCCESS, "got 0x%x (expected STATUS_SUCCESS)\n", status);
1593 /* allow the test to run on all processors */
1594 new_mask = (1 << si.dwNumberOfProcessors) - 1;
1595 status = pNtSetInformationProcess(GetCurrentProcess(), ProcessAffinityMask, &new_mask, sizeof(new_mask));
1596 ok(status == STATUS_SUCCESS, "got 0x%x (expected STATUS_SUCCESS)\n", status);
1598 for (i = 0; i < si.dwNumberOfProcessors; i++)
1600 new_mask = 1 << i;
1601 status = pNtSetInformationThread(GetCurrentThread(), ThreadAffinityMask, &new_mask, sizeof(new_mask));
1602 ok(status == STATUS_SUCCESS, "%d: got 0x%x (expected STATUS_SUCCESS)\n", i, status);
1604 status = pNtQueryInformationThread(GetCurrentThread(), ThreadBasicInformation, &tbi, sizeof(tbi), NULL);
1605 ok(status == STATUS_SUCCESS, "%d: got 0x%x (expected STATUS_SUCCESS)\n", i, status);
1607 current_cpu = pNtGetCurrentProcessorNumber();
1608 ok((current_cpu == i), "%d (new_mask 0x%lx): running on processor %d (AffinityMask: 0x%lx)\n",
1609 i, new_mask, current_cpu, tbi.AffinityMask);
1612 /* restore old values */
1613 status = pNtSetInformationProcess(GetCurrentProcess(), ProcessAffinityMask, &old_process_mask, sizeof(old_process_mask));
1614 ok(status == STATUS_SUCCESS, "got 0x%x (expected STATUS_SUCCESS)\n", status);
1616 status = pNtSetInformationThread(GetCurrentThread(), ThreadAffinityMask, &old_thread_mask, sizeof(old_thread_mask));
1617 ok(status == STATUS_SUCCESS, "got 0x%x (expected STATUS_SUCCESS)\n", status);
1620 START_TEST(info)
1622 char **argv;
1623 int argc;
1625 if(!InitFunctionPtrs())
1626 return;
1628 argc = winetest_get_mainargs(&argv);
1629 if (argc >= 3) return; /* Child */
1631 /* NtQuerySystemInformation */
1633 /* 0x0 SystemBasicInformation */
1634 trace("Starting test_query_basic()\n");
1635 test_query_basic();
1637 /* 0x1 SystemCpuInformation */
1638 trace("Starting test_query_cpu()\n");
1639 test_query_cpu();
1641 /* 0x2 SystemPerformanceInformation */
1642 trace("Starting test_query_performance()\n");
1643 test_query_performance();
1645 /* 0x3 SystemTimeOfDayInformation */
1646 trace("Starting test_query_timeofday()\n");
1647 test_query_timeofday();
1649 /* 0x5 SystemProcessInformation */
1650 trace("Starting test_query_process()\n");
1651 test_query_process();
1653 /* 0x8 SystemProcessorPerformanceInformation */
1654 trace("Starting test_query_procperf()\n");
1655 test_query_procperf();
1657 /* 0xb SystemModuleInformation */
1658 trace("Starting test_query_module()\n");
1659 test_query_module();
1661 /* 0x10 SystemHandleInformation */
1662 trace("Starting test_query_handle()\n");
1663 test_query_handle();
1665 /* 0x15 SystemCacheInformation */
1666 trace("Starting test_query_cache()\n");
1667 test_query_cache();
1669 /* 0x17 SystemInterruptInformation */
1670 trace("Starting test_query_interrupt()\n");
1671 test_query_interrupt();
1673 /* 0x23 SystemKernelDebuggerInformation */
1674 trace("Starting test_query_kerndebug()\n");
1675 test_query_kerndebug();
1677 /* 0x25 SystemRegistryQuotaInformation */
1678 trace("Starting test_query_regquota()\n");
1679 test_query_regquota();
1681 /* 0x49 SystemLogicalProcessorInformation */
1682 trace("Starting test_query_logicalproc()\n");
1683 test_query_logicalproc();
1685 /* NtPowerInformation */
1687 /* 0xb ProcessorInformation */
1688 trace("Starting test_query_processor_power_info()\n");
1689 test_query_processor_power_info();
1691 /* NtQueryInformationProcess */
1693 /* 0x0 ProcessBasicInformation */
1694 trace("Starting test_query_process_basic()\n");
1695 test_query_process_basic();
1697 /* 0x2 ProcessIoCounters */
1698 trace("Starting test_query_process_io()\n");
1699 test_query_process_io();
1701 /* 0x3 ProcessVmCounters */
1702 trace("Starting test_query_process_vm()\n");
1703 test_query_process_vm();
1705 /* 0x4 ProcessTimes */
1706 trace("Starting test_query_process_times()\n");
1707 test_query_process_times();
1709 /* 0x7 ProcessDebugPort */
1710 trace("Starting test_process_debug_port()\n");
1711 test_query_process_debug_port(argc, argv);
1713 /* 0x14 ProcessHandleCount */
1714 trace("Starting test_query_process_handlecount()\n");
1715 test_query_process_handlecount();
1717 /* 0x1B ProcessImageFileName */
1718 trace("Starting test_query_process_image_file_name()\n");
1719 test_query_process_image_file_name();
1721 /* 0x1E ProcessDebugObjectHandle */
1722 trace("Starting test_query_process_debug_object_handle()\n");
1723 test_query_process_debug_object_handle(argc, argv);
1725 /* 0x1F ProcessDebugFlags */
1726 trace("Starting test_process_debug_flags()\n");
1727 test_query_process_debug_flags(argc, argv);
1729 /* belongs to its own file */
1730 trace("Starting test_readvirtualmemory()\n");
1731 test_readvirtualmemory();
1733 trace("Starting test_queryvirtualmemory()\n");
1734 test_queryvirtualmemory();
1736 trace("Starting test_mapprotection()\n");
1737 test_mapprotection();
1739 trace("Starting test_affinity()\n");
1740 test_affinity();
1741 test_NtGetCurrentProcessorNumber();