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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "ntdll_test.h"
23 static NTSTATUS (WINAPI * pNtQuerySystemInformation)(SYSTEM_INFORMATION_CLASS, PVOID, ULONG, PULONG);
24 static NTSTATUS (WINAPI * pNtQueryInformationProcess)(HANDLE, PROCESSINFOCLASS, PVOID, ULONG, PULONG);
26 static HMODULE hntdll = 0;
28 /* one_before_last_pid is used to be able to compare values of a still running process
29 with the output of the test_query_process_times and test_query_process_handlecount tests.
31 static DWORD one_before_last_pid = 0;
33 #define NTDLL_GET_PROC(func) \
34 p ## func = (void*)GetProcAddress(hntdll, #func); \
36 trace("GetProcAddress(%s) failed\n", #func); \
37 FreeLibrary(hntdll); \
41 static BOOL InitFunctionPtrs(void)
43 hntdll = LoadLibraryA("ntdll.dll");
45 trace("Could not load ntdll.dll\n");
50 NTDLL_GET_PROC(NtQuerySystemInformation)
51 NTDLL_GET_PROC(NtQueryInformationProcess)
56 static void test_query_basic(void)
60 SYSTEM_BASIC_INFORMATION sbi;
62 /* This test also covers some basic parameter testing that should be the same for
63 * every information class
66 /* Use a nonexistent info class */
67 trace("Check nonexistent info class\n");
68 status = pNtQuerySystemInformation(-1, NULL, 0, NULL);
69 ok( status == STATUS_INVALID_INFO_CLASS, "Expected STATUS_INVALID_INFO_CLASS, got %08lx\n", status);
71 /* Use an existing class but with a zero-length buffer */
72 trace("Check zero-length buffer\n");
73 status = pNtQuerySystemInformation(SystemBasicInformation, NULL, 0, NULL);
74 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
76 /* Use an existing class, correct length but no SystemInformation buffer */
77 trace("Check no SystemInformation buffer\n");
78 status = pNtQuerySystemInformation(SystemBasicInformation, NULL, sizeof(sbi), NULL);
79 ok( status == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", status);
81 /* Use a existing class, correct length, a pointer to a buffer but no ReturnLength pointer */
82 trace("Check no ReturnLength pointer\n");
83 status = pNtQuerySystemInformation(SystemBasicInformation, &sbi, sizeof(sbi), NULL);
84 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
86 /* Check a too large buffer size */
87 trace("Check a too large buffer size\n");
88 status = pNtQuerySystemInformation(SystemBasicInformation, &sbi, sizeof(sbi) * 2, &ReturnLength);
89 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
91 /* Finally some correct calls */
92 trace("Check with correct parameters\n");
93 status = pNtQuerySystemInformation(SystemBasicInformation, &sbi, sizeof(sbi), &ReturnLength);
94 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
95 ok( sizeof(sbi) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(sbi), ReturnLength);
97 /* Check if we have some return values */
98 trace("Number of Processors : %d\n", sbi.NumberOfProcessors);
99 ok( sbi.NumberOfProcessors > 0, "Expected more than 0 processors, got %d\n", sbi.NumberOfProcessors);
102 static void test_query_cpu(void)
106 SYSTEM_CPU_INFORMATION sci;
108 status = pNtQuerySystemInformation(SystemCpuInformation, &sci, sizeof(sci), &ReturnLength);
109 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
110 ok( sizeof(sci) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(sci), ReturnLength);
112 /* Check if we have some return values */
113 trace("Processor FeatureSet : %08lx\n", sci.FeatureSet);
114 ok( sci.FeatureSet != 0, "Expected some features for this processor, got %08lx\n", sci.FeatureSet);
117 static void test_query_timeofday(void)
122 /* Copy of our winternl.h structure turned into a private one */
123 typedef struct _SYSTEM_TIMEOFDAY_INFORMATION_PRIVATE {
124 LARGE_INTEGER liKeBootTime;
125 LARGE_INTEGER liKeSystemTime;
126 LARGE_INTEGER liExpTimeZoneBias;
127 ULONG uCurrentTimeZoneId;
129 } SYSTEM_TIMEOFDAY_INFORMATION_PRIVATE, *PSYSTEM_TIMEOFDAY_INFORMATION_PRIVATE;
131 SYSTEM_TIMEOFDAY_INFORMATION_PRIVATE sti;
133 /* The struct size for NT (32 bytes) and Win2K/XP (48 bytes) differ.
135 * Windows 2000 and XP return STATUS_INFO_LENGTH_MISMATCH if the given buffer size is greater
136 * then 48 and 0 otherwise
137 * Windows NT returns STATUS_INFO_LENGTH_MISMATCH when the given buffer size is not correct
140 * Windows 2000 and XP copy the given buffer size into the provided buffer, if the return code is STATUS_SUCCESS
141 * NT only fills the buffer if the return code is STATUS_SUCCESS
145 status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, sizeof(sti), &ReturnLength);
147 if (status == STATUS_INFO_LENGTH_MISMATCH)
149 trace("Windows version is NT, we have to cater for differences with W2K/WinXP\n");
151 status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, 0, &ReturnLength);
152 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
153 ok( 0 == ReturnLength, "ReturnLength should be 0, it is (%ld)\n", ReturnLength);
155 sti.uCurrentTimeZoneId = 0xdeadbeef;
156 status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, 28, &ReturnLength);
157 ok( 0xdeadbeef == sti.uCurrentTimeZoneId, "This part of the buffer should not have been filled\n");
159 status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, 32, &ReturnLength);
160 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
161 ok( 32 == ReturnLength, "ReturnLength should be 0, it is (%ld)\n", ReturnLength);
165 status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, 0, &ReturnLength);
166 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
167 ok( 0 == ReturnLength, "ReturnLength should be 0, it is (%ld)\n", ReturnLength);
169 sti.uCurrentTimeZoneId = 0xdeadbeef;
170 status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, 24, &ReturnLength);
171 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
172 ok( 24 == ReturnLength, "ReturnLength should be 24, it is (%ld)\n", ReturnLength);
173 ok( 0xdeadbeef == sti.uCurrentTimeZoneId, "This part of the buffer should not have been filled\n");
175 sti.uCurrentTimeZoneId = 0xdeadbeef;
176 status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, 32, &ReturnLength);
177 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
178 ok( 32 == ReturnLength, "ReturnLength should be 32, it is (%ld)\n", ReturnLength);
179 ok( 0xdeadbeef != sti.uCurrentTimeZoneId, "Buffer should have been partially filled\n");
181 status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, 49, &ReturnLength);
182 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
183 ok( 0 == ReturnLength, "ReturnLength should be 0, it is (%ld)\n", ReturnLength);
185 status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, sizeof(sti), &ReturnLength);
186 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
187 ok( sizeof(sti) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(sti), ReturnLength);
190 /* Check if we have some return values */
191 trace("uCurrentTimeZoneId : (%ld)\n", sti.uCurrentTimeZoneId);
194 static void test_query_process(void)
199 int i = 0, j = 0, k = 0;
201 SYSTEM_BASIC_INFORMATION sbi;
203 /* Copy of our winternl.h structure turned into a private one */
204 typedef struct _SYSTEM_PROCESS_INFORMATION_PRIVATE {
208 FILETIME ftCreationTime;
210 FILETIME ftKernelTime;
211 UNICODE_STRING ProcessName;
212 DWORD dwBasePriority;
214 DWORD dwParentProcessID;
218 VM_COUNTERS vmCounters;
219 IO_COUNTERS ioCounters;
220 SYSTEM_THREAD_INFORMATION ti[1];
221 } SYSTEM_PROCESS_INFORMATION_PRIVATE, *PSYSTEM_PROCESS_INFORMATION_PRIVATE;
223 ULONG SystemInformationLength = sizeof(SYSTEM_PROCESS_INFORMATION_PRIVATE);
224 SYSTEM_PROCESS_INFORMATION_PRIVATE* spi = HeapAlloc(GetProcessHeap(), 0, SystemInformationLength);
226 /* Only W2K3 returns the needed length, the rest returns 0, so we have to loop */
230 status = pNtQuerySystemInformation(SystemProcessInformation, spi, SystemInformationLength, &ReturnLength);
232 if (status != STATUS_INFO_LENGTH_MISMATCH) break;
234 spi = HeapReAlloc(GetProcessHeap(), 0, spi , SystemInformationLength *= 2);
237 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
239 /* Get the first dwOffset, from this we can deduce the OS version we're running
242 * dwOffset for a process is 184 + (no. of threads) * sizeof(SYSTEM_THREAD_INFORMATION)
244 * dwOffset for a process is 136 + (no. of threads) * sizeof(SYSTEM_THREAD_INFORMATION)
245 * Wine (with every windows version):
246 * dwOffset for a process is 0 if just this test is running
247 * dwOffset for a process is 184 + (no. of threads) * sizeof(SYSTEM_THREAD_INFORMATION) +
248 * ProcessName.MaximumLength
249 * if more wine processes are running
251 * Note : On windows the first process is in fact the Idle 'process' with a thread for every processor
254 pNtQuerySystemInformation(SystemBasicInformation, &sbi, sizeof(sbi), &ReturnLength);
256 is_nt = ( spi->dwOffset - (sbi.NumberOfProcessors * sizeof(SYSTEM_THREAD_INFORMATION)) == 136);
258 if (is_nt) trace("Windows version is NT, we will skip thread tests\n");
260 /* Check if we have some return values
262 * On windows there will be several processes running (Including the always present Idle and System)
263 * On wine we only have one (if this test is the only wine process running)
266 /* Loop through the processes */
272 last_pid = spi->dwProcessID;
274 ok( spi->dwThreadCount > 0, "Expected some threads for this process, got 0\"");
276 /* Loop through the threads, skip NT4 for now */
280 for ( j = 0; j < spi->dwThreadCount; j++)
283 ok ( spi->ti[j].dwOwningPID == spi->dwProcessID,
284 "The owning pid of the thread (%ld) doesn't equal the pid (%ld) of the process\n",
285 spi->ti[j].dwOwningPID, spi->dwProcessID);
289 if (!spi->dwOffset) break;
291 one_before_last_pid = last_pid;
293 spi = (SYSTEM_PROCESS_INFORMATION_PRIVATE*)((char*)spi + spi->dwOffset);
295 trace("Total number of running processes : %d\n", i);
296 if (!is_nt) trace("Total number of running threads : %d\n", k);
298 if (one_before_last_pid == 0) one_before_last_pid = last_pid;
300 HeapFree( GetProcessHeap(), 0, spi);
303 static void test_query_handle(void)
307 ULONG SystemInformationLength = sizeof(SYSTEM_HANDLE_INFORMATION);
308 SYSTEM_HANDLE_INFORMATION* shi = HeapAlloc(GetProcessHeap(), 0, SystemInformationLength);
310 /* Request the needed length : a SystemInformationLength greater than one struct sets ReturnLength */
311 status = pNtQuerySystemInformation(SystemHandleInformation, shi, SystemInformationLength, &ReturnLength);
313 /* The following check assumes more than one handle on any given system */
316 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
318 ok( ReturnLength > 0, "Expected ReturnLength to be > 0, it was %ld\n", ReturnLength);
320 SystemInformationLength = ReturnLength;
321 shi = HeapReAlloc(GetProcessHeap(), 0, shi , SystemInformationLength);
322 status = pNtQuerySystemInformation(SystemHandleInformation, shi, SystemInformationLength, &ReturnLength);
323 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
325 /* Check if we have some return values */
326 trace("Number of Handles : %ld\n", shi->Count);
329 /* our implementation is a stub for now */
330 ok( shi->Count > 1, "Expected more than 1 handles, got (%ld)\n", shi->Count);
333 HeapFree( GetProcessHeap(), 0, shi);
336 static void test_query_process_basic(void)
341 typedef struct _PROCESS_BASIC_INFORMATION_PRIVATE {
343 DWORD PebBaseAddress;
346 ULONG UniqueProcessId;
347 ULONG InheritedFromUniqueProcessId;
348 } PROCESS_BASIC_INFORMATION_PRIVATE, *PPROCESS_BASIC_INFORMATION_PRIVATE;
350 PROCESS_BASIC_INFORMATION_PRIVATE pbi;
352 /* This test also covers some basic parameter testing that should be the same for
353 * every information class
356 /* Use a nonexistent info class */
357 trace("Check nonexistent info class\n");
358 status = pNtQueryInformationProcess(NULL, -1, NULL, 0, NULL);
359 ok( status == STATUS_INVALID_INFO_CLASS, "Expected STATUS_INVALID_INFO_CLASS, got %08lx\n", status);
361 /* Do not give a handle and buffer */
362 trace("Check NULL handle and buffer and zero-length buffersize\n");
363 status = pNtQueryInformationProcess(NULL, ProcessBasicInformation, NULL, 0, NULL);
364 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
366 /* Use a correct info class and buffer size, but still no handle and buffer */
367 trace("Check NULL handle and buffer\n");
368 status = pNtQueryInformationProcess(NULL, ProcessBasicInformation, NULL, sizeof(pbi), NULL);
369 ok( status == STATUS_ACCESS_VIOLATION || status == STATUS_INVALID_HANDLE,
370 "Expected STATUS_ACCESS_VIOLATION or STATUS_INVALID_HANDLE(W2K3), got %08lx\n", status);
372 /* Use a correct info class and buffer size, but still no handle */
373 trace("Check NULL handle\n");
374 status = pNtQueryInformationProcess(NULL, ProcessBasicInformation, &pbi, sizeof(pbi), NULL);
375 ok( status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08lx\n", status);
377 /* Use a greater buffer size */
378 trace("Check NULL handle and too large buffersize\n");
379 status = pNtQueryInformationProcess(NULL, ProcessBasicInformation, &pbi, sizeof(pbi) * 2, NULL);
380 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
382 /* Use no ReturnLength */
383 trace("Check NULL ReturnLength\n");
384 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessBasicInformation, &pbi, sizeof(pbi), NULL);
385 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
387 /* Finally some correct calls */
388 trace("Check with correct parameters\n");
389 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessBasicInformation, &pbi, sizeof(pbi), &ReturnLength);
390 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
391 ok( sizeof(pbi) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(pbi), ReturnLength);
393 /* Everything is correct except a too large buffersize */
394 trace("Too large buffersize\n");
395 status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessBasicInformation, &pbi, sizeof(pbi) * 2, &ReturnLength);
396 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
397 ok( sizeof(pbi) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(pbi), ReturnLength);
399 /* Check if we have some return values */
400 trace("ProcessID : %ld\n", pbi.UniqueProcessId);
401 ok( pbi.UniqueProcessId > 0, "Expected a ProcessID > 0, got 0\n");
404 static void test_query_process_vm(void)
410 status = pNtQueryInformationProcess(NULL, ProcessVmCounters, NULL, sizeof(pvi), NULL);
411 ok( status == STATUS_ACCESS_VIOLATION || status == STATUS_INVALID_HANDLE,
412 "Expected STATUS_ACCESS_VIOLATION or STATUS_INVALID_HANDLE(W2K3), got %08lx\n", status);
414 status = pNtQueryInformationProcess(NULL, ProcessVmCounters, &pvi, sizeof(pvi), NULL);
415 ok( status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08lx\n", status);
417 /* Windows XP and W2K3 will report success for a size of 44 AND 48 !
418 Windows W2K will only report success for 44.
419 For now we only care for 44, which is sizeof(VM_COUNTERS)
420 If an app depends on it, we have to implement this in ntdll/process.c
423 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessVmCounters, &pvi, 24, &ReturnLength);
424 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
426 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessVmCounters, &pvi, sizeof(pvi), &ReturnLength);
427 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
428 ok( sizeof(pvi) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(pvi), ReturnLength);
430 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessVmCounters, &pvi, 46, &ReturnLength);
431 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
432 ok( sizeof(pvi) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(pvi), ReturnLength);
434 /* Check if we have some return values */
435 trace("WorkingSetSize : %ld\n", pvi.WorkingSetSize);
438 ok( pvi.WorkingSetSize > 0, "Expected a WorkingSetSize > 0\n");
442 static void test_query_process_io(void)
448 status = pNtQueryInformationProcess(NULL, ProcessIoCounters, NULL, sizeof(pii), NULL);
449 ok( status == STATUS_ACCESS_VIOLATION || status == STATUS_INVALID_HANDLE,
450 "Expected STATUS_ACCESS_VIOLATION or STATUS_INVALID_HANDLE(W2K3), got %08lx\n", status);
452 status = pNtQueryInformationProcess(NULL, ProcessIoCounters, &pii, sizeof(pii), NULL);
453 ok( status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08lx\n", status);
455 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessIoCounters, &pii, 24, &ReturnLength);
456 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
458 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessIoCounters, &pii, sizeof(pii), &ReturnLength);
459 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
460 ok( sizeof(pii) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(pii), ReturnLength);
462 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessIoCounters, &pii, sizeof(pii) * 2, &ReturnLength);
463 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
464 ok( sizeof(pii) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(pii), ReturnLength);
466 /* Check if we have some return values */
467 trace("OtherOperationCount : %lld\n", pii.OtherOperationCount);
470 ok( pii.OtherOperationCount > 0, "Expected an OtherOperationCount > 0\n");
474 static void test_query_process_times(void)
479 SYSTEMTIME UTC, Local;
480 KERNEL_USER_TIMES spti;
482 status = pNtQueryInformationProcess(NULL, ProcessTimes, NULL, sizeof(spti), NULL);
483 ok( status == STATUS_ACCESS_VIOLATION || status == STATUS_INVALID_HANDLE,
484 "Expected STATUS_ACCESS_VIOLATION or STATUS_INVALID_HANDLE(W2K3), got %08lx\n", status);
486 status = pNtQueryInformationProcess(NULL, ProcessTimes, &spti, sizeof(spti), NULL);
487 ok( status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08lx\n", status);
489 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessTimes, &spti, 24, &ReturnLength);
490 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
492 process = OpenProcess (PROCESS_QUERY_INFORMATION, TRUE, one_before_last_pid);
493 trace("ProcessTimes for process with ID : %ld\n", one_before_last_pid);
494 status = pNtQueryInformationProcess( process, ProcessTimes, &spti, sizeof(spti), &ReturnLength);
495 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
496 ok( sizeof(spti) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(spti), ReturnLength);
497 CloseHandle(process);
499 FileTimeToSystemTime((const FILETIME *)&spti.CreateTime, &UTC);
500 SystemTimeToTzSpecificLocalTime(NULL, &UTC, &Local);
501 trace("CreateTime : %02d/%02d/%04d %02d:%02d:%02d\n", Local.wMonth, Local.wDay, Local.wYear,
502 Local.wHour, Local.wMinute, Local.wSecond);
504 FileTimeToSystemTime((const FILETIME *)&spti.ExitTime, &UTC);
505 SystemTimeToTzSpecificLocalTime(NULL, &UTC, &Local);
506 trace("ExitTime : %02d/%02d/%04d %02d:%02d:%02d\n", Local.wMonth, Local.wDay, Local.wYear,
507 Local.wHour, Local.wMinute, Local.wSecond);
509 FileTimeToSystemTime((const FILETIME *)&spti.KernelTime, &Local);
510 trace("KernelTime : %02d:%02d:%02d.%03d\n", Local.wHour, Local.wMinute, Local.wSecond, Local.wMilliseconds);
512 FileTimeToSystemTime((const FILETIME *)&spti.UserTime, &Local);
513 trace("UserTime : %02d:%02d:%02d.%03d\n", Local.wHour, Local.wMinute, Local.wSecond, Local.wMilliseconds);
515 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessTimes, &spti, sizeof(spti) * 2, &ReturnLength);
516 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
517 ok( sizeof(spti) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(spti), ReturnLength);
520 static void test_query_process_handlecount(void)
527 status = pNtQueryInformationProcess(NULL, ProcessHandleCount, NULL, sizeof(handlecount), NULL);
528 ok( status == STATUS_ACCESS_VIOLATION || status == STATUS_INVALID_HANDLE,
529 "Expected STATUS_ACCESS_VIOLATION or STATUS_INVALID_HANDLE(W2K3), got %08lx\n", status);
531 status = pNtQueryInformationProcess(NULL, ProcessHandleCount, &handlecount, sizeof(handlecount), NULL);
532 ok( status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08lx\n", status);
534 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessHandleCount, &handlecount, 2, &ReturnLength);
535 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
537 process = OpenProcess (PROCESS_QUERY_INFORMATION, TRUE, one_before_last_pid);
538 trace("Handlecount for process with ID : %ld\n", one_before_last_pid);
539 status = pNtQueryInformationProcess( process, ProcessHandleCount, &handlecount, sizeof(handlecount), &ReturnLength);
540 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
541 ok( sizeof(handlecount) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(handlecount), ReturnLength);
542 CloseHandle(process);
544 status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessHandleCount, &handlecount, sizeof(handlecount) * 2, &ReturnLength);
545 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
546 ok( sizeof(handlecount) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(handlecount), ReturnLength);
548 /* Check if we have some return values */
549 trace("HandleCount : %ld\n", handlecount);
552 ok( handlecount > 0, "Expected some handles, got 0\n");
558 if(!InitFunctionPtrs())
561 /* NtQuerySystemInformation */
563 /* 0x0 SystemBasicInformation */
564 trace("Starting test_query_basic()\n");
567 /* 0x1 SystemCpuInformation */
568 trace("Starting test_query_cpu()\n");
571 /* 0x3 SystemCpuInformation */
572 trace("Starting test_query_timeofday()\n");
573 test_query_timeofday();
575 /* 0x5 SystemProcessInformation */
576 trace("Starting test_query_process()\n");
577 test_query_process();
579 /* 0x10 SystemHandleInformation */
580 trace("Starting test_query_handle()\n");
583 /* NtQueryInformationProcess */
585 /* 0x0 ProcessBasicInformation */
586 trace("Starting test_query_process_basic()\n");
587 test_query_process_basic();
589 /* 0x2 ProcessIoCounters */
590 trace("Starting test_query_process_io()\n");
591 test_query_process_io();
593 /* 0x3 ProcessVmCounters */
594 trace("Starting test_query_process_vm()\n");
595 test_query_process_vm();
597 /* 0x4 ProcessTimes */
598 trace("Starting test_query_process_times()\n");
599 test_query_process_times();
601 /* 0x14 ProcessHandleCount */
602 trace("Starting test_query_process_handlecount()\n");
603 test_query_process_handlecount();