2005-04-15 16:12:54 +02:00
|
|
|
/* Unit test suite for *Information* Registry API functions
|
|
|
|
*
|
|
|
|
* Copyright 2005 Paul Vriens
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ntdll_test.h"
|
|
|
|
|
|
|
|
static NTSTATUS (WINAPI * pNtQuerySystemInformation)(SYSTEM_INFORMATION_CLASS, PVOID, ULONG, PULONG);
|
2005-06-14 14:25:02 +02:00
|
|
|
static NTSTATUS (WINAPI * pNtQueryInformationProcess)(HANDLE, PROCESSINFOCLASS, PVOID, ULONG, PULONG);
|
2005-04-15 16:12:54 +02:00
|
|
|
|
|
|
|
static HMODULE hntdll = 0;
|
|
|
|
|
2005-06-21 22:22:01 +02:00
|
|
|
/* one_before_last_pid is used to be able to compare values of a still running process
|
|
|
|
with the output of the test_query_process_times and test_query_process_handlecount tests.
|
|
|
|
*/
|
|
|
|
static DWORD one_before_last_pid = 0;
|
|
|
|
|
2005-04-15 16:12:54 +02:00
|
|
|
#define NTDLL_GET_PROC(func) \
|
|
|
|
p ## func = (void*)GetProcAddress(hntdll, #func); \
|
|
|
|
if(!p ## func) { \
|
|
|
|
trace("GetProcAddress(%s) failed\n", #func); \
|
|
|
|
FreeLibrary(hntdll); \
|
|
|
|
return FALSE; \
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL InitFunctionPtrs(void)
|
|
|
|
{
|
|
|
|
hntdll = LoadLibraryA("ntdll.dll");
|
|
|
|
if(!hntdll) {
|
|
|
|
trace("Could not load ntdll.dll\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (hntdll)
|
|
|
|
{
|
|
|
|
NTDLL_GET_PROC(NtQuerySystemInformation)
|
2005-06-14 14:25:02 +02:00
|
|
|
NTDLL_GET_PROC(NtQueryInformationProcess)
|
2005-04-15 16:12:54 +02:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-06-21 22:22:01 +02:00
|
|
|
static void test_query_basic(void)
|
2005-04-15 16:12:54 +02:00
|
|
|
{
|
|
|
|
DWORD status;
|
|
|
|
ULONG ReturnLength;
|
2005-05-10 15:16:36 +02:00
|
|
|
SYSTEM_BASIC_INFORMATION sbi;
|
2005-04-15 16:12:54 +02:00
|
|
|
|
|
|
|
/* This test also covers some basic parameter testing that should be the same for
|
|
|
|
* every information class
|
|
|
|
*/
|
|
|
|
|
2005-04-19 11:49:38 +02:00
|
|
|
/* Use a nonexistent info class */
|
|
|
|
trace("Check nonexistent info class\n");
|
2005-04-15 16:12:54 +02:00
|
|
|
status = pNtQuerySystemInformation(-1, NULL, 0, NULL);
|
|
|
|
ok( status == STATUS_INVALID_INFO_CLASS, "Expected STATUS_INVALID_INFO_CLASS, got %08lx\n", status);
|
|
|
|
|
2005-04-19 11:49:38 +02:00
|
|
|
/* Use an existing class but with a zero-length buffer */
|
2005-04-15 16:12:54 +02:00
|
|
|
trace("Check zero-length buffer\n");
|
|
|
|
status = pNtQuerySystemInformation(SystemBasicInformation, NULL, 0, NULL);
|
|
|
|
ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
|
|
|
|
|
2005-04-19 11:49:38 +02:00
|
|
|
/* Use an existing class, correct length but no SystemInformation buffer */
|
2005-04-15 16:12:54 +02:00
|
|
|
trace("Check no SystemInformation buffer\n");
|
2005-05-10 15:16:36 +02:00
|
|
|
status = pNtQuerySystemInformation(SystemBasicInformation, NULL, sizeof(sbi), NULL);
|
2005-04-15 16:12:54 +02:00
|
|
|
ok( status == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", status);
|
|
|
|
|
2005-04-19 11:49:38 +02:00
|
|
|
/* Use a existing class, correct length, a pointer to a buffer but no ReturnLength pointer */
|
2005-04-15 16:12:54 +02:00
|
|
|
trace("Check no ReturnLength pointer\n");
|
2005-05-10 15:16:36 +02:00
|
|
|
status = pNtQuerySystemInformation(SystemBasicInformation, &sbi, sizeof(sbi), NULL);
|
2005-04-15 16:12:54 +02:00
|
|
|
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
|
|
|
|
|
2005-06-15 12:19:34 +02:00
|
|
|
/* Check a too large buffer size */
|
|
|
|
trace("Check a too large buffer size\n");
|
|
|
|
status = pNtQuerySystemInformation(SystemBasicInformation, &sbi, sizeof(sbi) * 2, &ReturnLength);
|
|
|
|
ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
|
|
|
|
|
2005-04-15 16:12:54 +02:00
|
|
|
/* Finally some correct calls */
|
|
|
|
trace("Check with correct parameters\n");
|
2005-05-10 15:16:36 +02:00
|
|
|
status = pNtQuerySystemInformation(SystemBasicInformation, &sbi, sizeof(sbi), &ReturnLength);
|
|
|
|
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
|
2005-06-13 13:34:56 +02:00
|
|
|
ok( sizeof(sbi) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(sbi), ReturnLength);
|
2005-05-10 15:16:36 +02:00
|
|
|
|
|
|
|
/* Check if we have some return values */
|
|
|
|
trace("Number of Processors : %d\n", sbi.NumberOfProcessors);
|
|
|
|
ok( sbi.NumberOfProcessors > 0, "Expected more than 0 processors, got %d\n", sbi.NumberOfProcessors);
|
|
|
|
}
|
|
|
|
|
2005-06-21 22:22:01 +02:00
|
|
|
static void test_query_cpu(void)
|
2005-05-10 15:16:36 +02:00
|
|
|
{
|
|
|
|
DWORD status;
|
|
|
|
ULONG ReturnLength;
|
2005-06-10 21:52:32 +02:00
|
|
|
SYSTEM_CPU_INFORMATION sci;
|
2005-05-10 15:16:36 +02:00
|
|
|
|
2005-06-10 21:52:32 +02:00
|
|
|
status = pNtQuerySystemInformation(SystemCpuInformation, &sci, sizeof(sci), &ReturnLength);
|
2005-04-15 16:12:54 +02:00
|
|
|
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
|
2005-06-13 13:34:56 +02:00
|
|
|
ok( sizeof(sci) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(sci), ReturnLength);
|
2005-06-10 21:52:32 +02:00
|
|
|
|
2005-04-15 16:12:54 +02:00
|
|
|
/* Check if we have some return values */
|
2005-06-10 21:52:32 +02:00
|
|
|
trace("Processor FeatureSet : %08lx\n", sci.FeatureSet);
|
|
|
|
ok( sci.FeatureSet != 0, "Expected some features for this processor, got %08lx\n", sci.FeatureSet);
|
2005-04-15 16:12:54 +02:00
|
|
|
}
|
|
|
|
|
2005-06-21 22:22:01 +02:00
|
|
|
static void test_query_timeofday(void)
|
2005-06-13 13:34:56 +02:00
|
|
|
{
|
|
|
|
DWORD status;
|
|
|
|
ULONG ReturnLength;
|
|
|
|
|
|
|
|
/* Copy of our winternl.h structure turned into a private one */
|
|
|
|
typedef struct _SYSTEM_TIMEOFDAY_INFORMATION_PRIVATE {
|
|
|
|
LARGE_INTEGER liKeBootTime;
|
|
|
|
LARGE_INTEGER liKeSystemTime;
|
|
|
|
LARGE_INTEGER liExpTimeZoneBias;
|
|
|
|
ULONG uCurrentTimeZoneId;
|
|
|
|
DWORD dwUnknown1[5];
|
|
|
|
} SYSTEM_TIMEOFDAY_INFORMATION_PRIVATE, *PSYSTEM_TIMEOFDAY_INFORMATION_PRIVATE;
|
|
|
|
|
|
|
|
SYSTEM_TIMEOFDAY_INFORMATION_PRIVATE sti;
|
|
|
|
|
2005-06-17 22:55:40 +02:00
|
|
|
/* The struct size for NT (32 bytes) and Win2K/XP (48 bytes) differ.
|
2005-06-13 13:34:56 +02:00
|
|
|
*
|
|
|
|
* Windows 2000 and XP return STATUS_INFO_LENGTH_MISMATCH if the given buffer size is greater
|
|
|
|
* then 48 and 0 otherwise
|
|
|
|
* Windows NT returns STATUS_INFO_LENGTH_MISMATCH when the given buffer size is not correct
|
|
|
|
* and 0 otherwise
|
|
|
|
*
|
|
|
|
* Windows 2000 and XP copy the given buffer size into the provided buffer, if the return code is STATUS_SUCCESS
|
|
|
|
* NT only fills the buffer if the return code is STATUS_SUCCESS
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, sizeof(sti), &ReturnLength);
|
|
|
|
|
2005-06-17 22:55:40 +02:00
|
|
|
if (status == STATUS_INFO_LENGTH_MISMATCH)
|
2005-06-13 13:34:56 +02:00
|
|
|
{
|
|
|
|
trace("Windows version is NT, we have to cater for differences with W2K/WinXP\n");
|
|
|
|
|
|
|
|
status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, 0, &ReturnLength);
|
|
|
|
ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
|
|
|
|
ok( 0 == ReturnLength, "ReturnLength should be 0, it is (%ld)\n", ReturnLength);
|
|
|
|
|
|
|
|
sti.uCurrentTimeZoneId = 0xdeadbeef;
|
|
|
|
status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, 28, &ReturnLength);
|
|
|
|
ok( 0xdeadbeef == sti.uCurrentTimeZoneId, "This part of the buffer should not have been filled\n");
|
|
|
|
|
|
|
|
status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, 32, &ReturnLength);
|
|
|
|
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
|
|
|
|
ok( 32 == ReturnLength, "ReturnLength should be 0, it is (%ld)\n", ReturnLength);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, 0, &ReturnLength);
|
|
|
|
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
|
|
|
|
ok( 0 == ReturnLength, "ReturnLength should be 0, it is (%ld)\n", ReturnLength);
|
|
|
|
|
|
|
|
sti.uCurrentTimeZoneId = 0xdeadbeef;
|
|
|
|
status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, 24, &ReturnLength);
|
|
|
|
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
|
|
|
|
ok( 24 == ReturnLength, "ReturnLength should be 24, it is (%ld)\n", ReturnLength);
|
|
|
|
ok( 0xdeadbeef == sti.uCurrentTimeZoneId, "This part of the buffer should not have been filled\n");
|
|
|
|
|
|
|
|
sti.uCurrentTimeZoneId = 0xdeadbeef;
|
|
|
|
status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, 32, &ReturnLength);
|
|
|
|
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
|
|
|
|
ok( 32 == ReturnLength, "ReturnLength should be 32, it is (%ld)\n", ReturnLength);
|
|
|
|
ok( 0xdeadbeef != sti.uCurrentTimeZoneId, "Buffer should have been partially filled\n");
|
|
|
|
|
|
|
|
status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, 49, &ReturnLength);
|
|
|
|
ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
|
|
|
|
ok( 0 == ReturnLength, "ReturnLength should be 0, it is (%ld)\n", ReturnLength);
|
|
|
|
|
|
|
|
status = pNtQuerySystemInformation(SystemTimeOfDayInformation, &sti, sizeof(sti), &ReturnLength);
|
|
|
|
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
|
|
|
|
ok( sizeof(sti) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(sti), ReturnLength);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if we have some return values */
|
|
|
|
trace("uCurrentTimeZoneId : (%ld)\n", sti.uCurrentTimeZoneId);
|
|
|
|
}
|
|
|
|
|
2005-06-21 22:22:01 +02:00
|
|
|
static void test_query_process(void)
|
2005-06-09 12:03:25 +02:00
|
|
|
{
|
|
|
|
DWORD status;
|
2005-06-21 22:22:01 +02:00
|
|
|
DWORD last_pid;
|
2005-06-09 12:03:25 +02:00
|
|
|
ULONG ReturnLength;
|
|
|
|
int i = 0, j = 0, k = 0;
|
2005-06-17 22:55:40 +02:00
|
|
|
int is_nt = 0;
|
2005-06-09 12:03:25 +02:00
|
|
|
SYSTEM_BASIC_INFORMATION sbi;
|
|
|
|
|
|
|
|
/* Copy of our winternl.h structure turned into a private one */
|
|
|
|
typedef struct _SYSTEM_PROCESS_INFORMATION_PRIVATE {
|
|
|
|
DWORD dwOffset;
|
|
|
|
DWORD dwThreadCount;
|
|
|
|
DWORD dwUnknown1[6];
|
|
|
|
FILETIME ftCreationTime;
|
|
|
|
FILETIME ftUserTime;
|
|
|
|
FILETIME ftKernelTime;
|
|
|
|
UNICODE_STRING ProcessName;
|
|
|
|
DWORD dwBasePriority;
|
|
|
|
DWORD dwProcessID;
|
|
|
|
DWORD dwParentProcessID;
|
|
|
|
DWORD dwHandleCount;
|
|
|
|
DWORD dwUnknown3;
|
|
|
|
DWORD dwUnknown4;
|
|
|
|
VM_COUNTERS vmCounters;
|
|
|
|
IO_COUNTERS ioCounters;
|
|
|
|
SYSTEM_THREAD_INFORMATION ti[1];
|
|
|
|
} SYSTEM_PROCESS_INFORMATION_PRIVATE, *PSYSTEM_PROCESS_INFORMATION_PRIVATE;
|
|
|
|
|
|
|
|
ULONG SystemInformationLength = sizeof(SYSTEM_PROCESS_INFORMATION_PRIVATE);
|
|
|
|
SYSTEM_PROCESS_INFORMATION_PRIVATE* spi = HeapAlloc(GetProcessHeap(), 0, SystemInformationLength);
|
|
|
|
|
|
|
|
/* Only W2K3 returns the needed length, the rest returns 0, so we have to loop */
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
status = pNtQuerySystemInformation(SystemProcessInformation, spi, SystemInformationLength, &ReturnLength);
|
|
|
|
|
|
|
|
if (status != STATUS_INFO_LENGTH_MISMATCH) break;
|
|
|
|
|
|
|
|
spi = HeapReAlloc(GetProcessHeap(), 0, spi , SystemInformationLength *= 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
|
|
|
|
|
|
|
|
/* Get the first dwOffset, from this we can deduce the OS version we're running
|
|
|
|
*
|
|
|
|
* W2K/WinXP/W2K3:
|
|
|
|
* dwOffset for a process is 184 + (no. of threads) * sizeof(SYSTEM_THREAD_INFORMATION)
|
|
|
|
* NT:
|
|
|
|
* dwOffset for a process is 136 + (no. of threads) * sizeof(SYSTEM_THREAD_INFORMATION)
|
|
|
|
* Wine (with every windows version):
|
|
|
|
* dwOffset for a process is 0 if just this test is running
|
2005-06-10 21:52:32 +02:00
|
|
|
* dwOffset for a process is 184 + (no. of threads) * sizeof(SYSTEM_THREAD_INFORMATION) +
|
2005-06-09 12:03:25 +02:00
|
|
|
* ProcessName.MaximumLength
|
|
|
|
* if more wine processes are running
|
|
|
|
*
|
|
|
|
* Note : On windows the first process is in fact the Idle 'process' with a thread for every processor
|
|
|
|
*/
|
|
|
|
|
|
|
|
pNtQuerySystemInformation(SystemBasicInformation, &sbi, sizeof(sbi), &ReturnLength);
|
|
|
|
|
2005-06-17 22:55:40 +02:00
|
|
|
is_nt = ( spi->dwOffset - (sbi.NumberOfProcessors * sizeof(SYSTEM_THREAD_INFORMATION)) == 136);
|
2005-06-09 12:03:25 +02:00
|
|
|
|
2005-06-17 22:55:40 +02:00
|
|
|
if (is_nt) trace("Windows version is NT, we will skip thread tests\n");
|
2005-06-09 12:03:25 +02:00
|
|
|
|
|
|
|
/* Check if we have some return values
|
|
|
|
*
|
|
|
|
* On windows there will be several processes running (Including the always present Idle and System)
|
|
|
|
* On wine we only have one (if this test is the only wine process running)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Loop through the processes */
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
|
2005-06-21 22:22:01 +02:00
|
|
|
last_pid = spi->dwProcessID;
|
|
|
|
|
2005-06-09 12:03:25 +02:00
|
|
|
ok( spi->dwThreadCount > 0, "Expected some threads for this process, got 0\"");
|
|
|
|
|
|
|
|
/* Loop through the threads, skip NT4 for now */
|
|
|
|
|
2005-06-17 22:55:40 +02:00
|
|
|
if (!is_nt)
|
2005-06-09 12:03:25 +02:00
|
|
|
{
|
|
|
|
for ( j = 0; j < spi->dwThreadCount; j++)
|
|
|
|
{
|
|
|
|
k++;
|
|
|
|
ok ( spi->ti[j].dwOwningPID == spi->dwProcessID,
|
|
|
|
"The owning pid of the thread (%ld) doesn't equal the pid (%ld) of the process\n",
|
|
|
|
spi->ti[j].dwOwningPID, spi->dwProcessID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!spi->dwOffset) break;
|
2005-06-21 22:22:01 +02:00
|
|
|
|
|
|
|
one_before_last_pid = last_pid;
|
2005-06-09 12:03:25 +02:00
|
|
|
|
|
|
|
spi = (SYSTEM_PROCESS_INFORMATION_PRIVATE*)((char*)spi + spi->dwOffset);
|
|
|
|
}
|
|
|
|
trace("Total number of running processes : %d\n", i);
|
2005-06-17 22:55:40 +02:00
|
|
|
if (!is_nt) trace("Total number of running threads : %d\n", k);
|
2005-06-09 12:03:25 +02:00
|
|
|
|
2005-06-21 22:22:01 +02:00
|
|
|
if (one_before_last_pid == 0) one_before_last_pid = last_pid;
|
|
|
|
|
2005-06-09 12:03:25 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, spi);
|
|
|
|
}
|
2005-05-10 15:16:36 +02:00
|
|
|
|
2005-06-21 22:22:01 +02:00
|
|
|
static void test_query_handle(void)
|
2005-06-10 21:52:32 +02:00
|
|
|
{
|
|
|
|
DWORD status;
|
|
|
|
ULONG ReturnLength;
|
|
|
|
ULONG SystemInformationLength = sizeof(SYSTEM_HANDLE_INFORMATION);
|
|
|
|
SYSTEM_HANDLE_INFORMATION* shi = HeapAlloc(GetProcessHeap(), 0, SystemInformationLength);
|
|
|
|
|
|
|
|
/* Request the needed length : a SystemInformationLength greater than one struct sets ReturnLength */
|
|
|
|
status = pNtQuerySystemInformation(SystemHandleInformation, shi, SystemInformationLength, &ReturnLength);
|
|
|
|
|
|
|
|
/* The following check assumes more than one handle on any given system */
|
|
|
|
todo_wine
|
|
|
|
{
|
|
|
|
ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
|
|
|
|
}
|
|
|
|
ok( ReturnLength > 0, "Expected ReturnLength to be > 0, it was %ld\n", ReturnLength);
|
|
|
|
|
|
|
|
SystemInformationLength = ReturnLength;
|
|
|
|
shi = HeapReAlloc(GetProcessHeap(), 0, shi , SystemInformationLength);
|
|
|
|
status = pNtQuerySystemInformation(SystemHandleInformation, shi, SystemInformationLength, &ReturnLength);
|
|
|
|
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
|
|
|
|
|
|
|
|
/* Check if we have some return values */
|
|
|
|
trace("Number of Handles : %ld\n", shi->Count);
|
|
|
|
todo_wine
|
|
|
|
{
|
|
|
|
/* our implementation is a stub for now */
|
|
|
|
ok( shi->Count > 1, "Expected more than 1 handles, got (%ld)\n", shi->Count);
|
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree( GetProcessHeap(), 0, shi);
|
|
|
|
}
|
|
|
|
|
2005-06-21 22:22:01 +02:00
|
|
|
static void test_query_process_basic(void)
|
2005-06-14 14:25:02 +02:00
|
|
|
{
|
|
|
|
DWORD status;
|
|
|
|
ULONG ReturnLength;
|
|
|
|
|
|
|
|
typedef struct _PROCESS_BASIC_INFORMATION_PRIVATE {
|
|
|
|
DWORD ExitStatus;
|
|
|
|
DWORD PebBaseAddress;
|
|
|
|
DWORD AffinityMask;
|
|
|
|
DWORD BasePriority;
|
|
|
|
ULONG UniqueProcessId;
|
|
|
|
ULONG InheritedFromUniqueProcessId;
|
|
|
|
} PROCESS_BASIC_INFORMATION_PRIVATE, *PPROCESS_BASIC_INFORMATION_PRIVATE;
|
|
|
|
|
|
|
|
PROCESS_BASIC_INFORMATION_PRIVATE pbi;
|
|
|
|
|
|
|
|
/* This test also covers some basic parameter testing that should be the same for
|
|
|
|
* every information class
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Use a nonexistent info class */
|
|
|
|
trace("Check nonexistent info class\n");
|
|
|
|
status = pNtQueryInformationProcess(NULL, -1, NULL, 0, NULL);
|
|
|
|
ok( status == STATUS_INVALID_INFO_CLASS, "Expected STATUS_INVALID_INFO_CLASS, got %08lx\n", status);
|
|
|
|
|
|
|
|
/* Do not give a handle and buffer */
|
|
|
|
trace("Check NULL handle and buffer and zero-length buffersize\n");
|
|
|
|
status = pNtQueryInformationProcess(NULL, ProcessBasicInformation, NULL, 0, NULL);
|
|
|
|
ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
|
|
|
|
|
|
|
|
/* Use a correct info class and buffer size, but still no handle and buffer */
|
|
|
|
trace("Check NULL handle and buffer\n");
|
|
|
|
status = pNtQueryInformationProcess(NULL, ProcessBasicInformation, NULL, sizeof(pbi), NULL);
|
2005-06-16 11:43:59 +02:00
|
|
|
ok( status == STATUS_ACCESS_VIOLATION || status == STATUS_INVALID_HANDLE,
|
|
|
|
"Expected STATUS_ACCESS_VIOLATION or STATUS_INVALID_HANDLE(W2K3), got %08lx\n", status);
|
2005-06-14 14:25:02 +02:00
|
|
|
|
|
|
|
/* Use a correct info class and buffer size, but still no handle */
|
|
|
|
trace("Check NULL handle\n");
|
|
|
|
status = pNtQueryInformationProcess(NULL, ProcessBasicInformation, &pbi, sizeof(pbi), NULL);
|
|
|
|
ok( status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08lx\n", status);
|
|
|
|
|
|
|
|
/* Use a greater buffer size */
|
|
|
|
trace("Check NULL handle and too large buffersize\n");
|
|
|
|
status = pNtQueryInformationProcess(NULL, ProcessBasicInformation, &pbi, sizeof(pbi) * 2, NULL);
|
|
|
|
ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
|
|
|
|
|
|
|
|
/* Use no ReturnLength */
|
|
|
|
trace("Check NULL ReturnLength\n");
|
|
|
|
status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessBasicInformation, &pbi, sizeof(pbi), NULL);
|
|
|
|
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
|
|
|
|
|
|
|
|
/* Finally some correct calls */
|
|
|
|
trace("Check with correct parameters\n");
|
|
|
|
status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessBasicInformation, &pbi, sizeof(pbi), &ReturnLength);
|
|
|
|
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
|
|
|
|
ok( sizeof(pbi) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(pbi), ReturnLength);
|
2005-06-21 22:22:01 +02:00
|
|
|
|
|
|
|
/* Everything is correct except a too large buffersize */
|
|
|
|
trace("Too large buffersize\n");
|
|
|
|
status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessBasicInformation, &pbi, sizeof(pbi) * 2, &ReturnLength);
|
|
|
|
ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
|
|
|
|
ok( sizeof(pbi) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(pbi), ReturnLength);
|
2005-06-14 14:25:02 +02:00
|
|
|
|
|
|
|
/* Check if we have some return values */
|
|
|
|
trace("ProcessID : %ld\n", pbi.UniqueProcessId);
|
2005-06-21 22:22:01 +02:00
|
|
|
ok( pbi.UniqueProcessId > 0, "Expected a ProcessID > 0, got 0\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_query_process_vm(void)
|
|
|
|
{
|
|
|
|
DWORD status;
|
|
|
|
ULONG ReturnLength;
|
|
|
|
VM_COUNTERS pvi;
|
|
|
|
|
|
|
|
status = pNtQueryInformationProcess(NULL, ProcessVmCounters, NULL, sizeof(pvi), NULL);
|
|
|
|
ok( status == STATUS_ACCESS_VIOLATION || status == STATUS_INVALID_HANDLE,
|
|
|
|
"Expected STATUS_ACCESS_VIOLATION or STATUS_INVALID_HANDLE(W2K3), got %08lx\n", status);
|
|
|
|
|
|
|
|
status = pNtQueryInformationProcess(NULL, ProcessVmCounters, &pvi, sizeof(pvi), NULL);
|
|
|
|
ok( status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08lx\n", status);
|
|
|
|
|
|
|
|
/* Windows XP and W2K3 will report success for a size of 44 AND 48 !
|
|
|
|
Windows W2K will only report success for 44.
|
|
|
|
For now we only care for 44, which is sizeof(VM_COUNTERS)
|
|
|
|
If an app depends on it, we have to implement this in ntdll/process.c
|
|
|
|
*/
|
|
|
|
|
|
|
|
status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessVmCounters, &pvi, 24, &ReturnLength);
|
|
|
|
ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
|
|
|
|
|
|
|
|
status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessVmCounters, &pvi, sizeof(pvi), &ReturnLength);
|
|
|
|
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
|
|
|
|
ok( sizeof(pvi) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(pvi), ReturnLength);
|
|
|
|
|
|
|
|
status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessVmCounters, &pvi, 46, &ReturnLength);
|
|
|
|
ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
|
|
|
|
ok( sizeof(pvi) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(pvi), ReturnLength);
|
|
|
|
|
|
|
|
/* Check if we have some return values */
|
|
|
|
trace("WorkingSetSize : %ld\n", pvi.WorkingSetSize);
|
|
|
|
todo_wine
|
|
|
|
{
|
|
|
|
ok( pvi.WorkingSetSize > 0, "Expected a WorkingSetSize > 0\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_query_process_io(void)
|
|
|
|
{
|
|
|
|
DWORD status;
|
|
|
|
ULONG ReturnLength;
|
|
|
|
IO_COUNTERS pii;
|
|
|
|
|
2005-06-23 11:47:31 +02:00
|
|
|
/* NT4 doesn't support this information class, so check for it */
|
|
|
|
status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessIoCounters, &pii, sizeof(pii), &ReturnLength);
|
|
|
|
if (status == STATUS_NOT_SUPPORTED)
|
|
|
|
{
|
|
|
|
trace("ProcessIoCounters information class not supported, skipping tests\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-06-21 22:22:01 +02:00
|
|
|
status = pNtQueryInformationProcess(NULL, ProcessIoCounters, NULL, sizeof(pii), NULL);
|
|
|
|
ok( status == STATUS_ACCESS_VIOLATION || status == STATUS_INVALID_HANDLE,
|
|
|
|
"Expected STATUS_ACCESS_VIOLATION or STATUS_INVALID_HANDLE(W2K3), got %08lx\n", status);
|
|
|
|
|
|
|
|
status = pNtQueryInformationProcess(NULL, ProcessIoCounters, &pii, sizeof(pii), NULL);
|
|
|
|
ok( status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08lx\n", status);
|
|
|
|
|
|
|
|
status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessIoCounters, &pii, 24, &ReturnLength);
|
|
|
|
ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
|
|
|
|
|
|
|
|
status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessIoCounters, &pii, sizeof(pii), &ReturnLength);
|
|
|
|
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
|
|
|
|
ok( sizeof(pii) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(pii), ReturnLength);
|
|
|
|
|
|
|
|
status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessIoCounters, &pii, sizeof(pii) * 2, &ReturnLength);
|
|
|
|
ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
|
|
|
|
ok( sizeof(pii) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(pii), ReturnLength);
|
|
|
|
|
|
|
|
/* Check if we have some return values */
|
|
|
|
trace("OtherOperationCount : %lld\n", pii.OtherOperationCount);
|
|
|
|
todo_wine
|
|
|
|
{
|
|
|
|
ok( pii.OtherOperationCount > 0, "Expected an OtherOperationCount > 0\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_query_process_times(void)
|
|
|
|
{
|
|
|
|
DWORD status;
|
|
|
|
ULONG ReturnLength;
|
|
|
|
HANDLE process;
|
|
|
|
SYSTEMTIME UTC, Local;
|
|
|
|
KERNEL_USER_TIMES spti;
|
|
|
|
|
|
|
|
status = pNtQueryInformationProcess(NULL, ProcessTimes, NULL, sizeof(spti), NULL);
|
|
|
|
ok( status == STATUS_ACCESS_VIOLATION || status == STATUS_INVALID_HANDLE,
|
|
|
|
"Expected STATUS_ACCESS_VIOLATION or STATUS_INVALID_HANDLE(W2K3), got %08lx\n", status);
|
|
|
|
|
|
|
|
status = pNtQueryInformationProcess(NULL, ProcessTimes, &spti, sizeof(spti), NULL);
|
|
|
|
ok( status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08lx\n", status);
|
|
|
|
|
|
|
|
status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessTimes, &spti, 24, &ReturnLength);
|
|
|
|
ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
|
|
|
|
|
|
|
|
process = OpenProcess (PROCESS_QUERY_INFORMATION, TRUE, one_before_last_pid);
|
|
|
|
trace("ProcessTimes for process with ID : %ld\n", one_before_last_pid);
|
|
|
|
status = pNtQueryInformationProcess( process, ProcessTimes, &spti, sizeof(spti), &ReturnLength);
|
|
|
|
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
|
|
|
|
ok( sizeof(spti) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(spti), ReturnLength);
|
|
|
|
CloseHandle(process);
|
|
|
|
|
|
|
|
FileTimeToSystemTime((const FILETIME *)&spti.CreateTime, &UTC);
|
|
|
|
SystemTimeToTzSpecificLocalTime(NULL, &UTC, &Local);
|
|
|
|
trace("CreateTime : %02d/%02d/%04d %02d:%02d:%02d\n", Local.wMonth, Local.wDay, Local.wYear,
|
|
|
|
Local.wHour, Local.wMinute, Local.wSecond);
|
|
|
|
|
|
|
|
FileTimeToSystemTime((const FILETIME *)&spti.ExitTime, &UTC);
|
|
|
|
SystemTimeToTzSpecificLocalTime(NULL, &UTC, &Local);
|
|
|
|
trace("ExitTime : %02d/%02d/%04d %02d:%02d:%02d\n", Local.wMonth, Local.wDay, Local.wYear,
|
|
|
|
Local.wHour, Local.wMinute, Local.wSecond);
|
|
|
|
|
|
|
|
FileTimeToSystemTime((const FILETIME *)&spti.KernelTime, &Local);
|
|
|
|
trace("KernelTime : %02d:%02d:%02d.%03d\n", Local.wHour, Local.wMinute, Local.wSecond, Local.wMilliseconds);
|
|
|
|
|
|
|
|
FileTimeToSystemTime((const FILETIME *)&spti.UserTime, &Local);
|
|
|
|
trace("UserTime : %02d:%02d:%02d.%03d\n", Local.wHour, Local.wMinute, Local.wSecond, Local.wMilliseconds);
|
|
|
|
|
|
|
|
status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessTimes, &spti, sizeof(spti) * 2, &ReturnLength);
|
|
|
|
ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
|
|
|
|
ok( sizeof(spti) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(spti), ReturnLength);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_query_process_handlecount(void)
|
|
|
|
{
|
|
|
|
DWORD status;
|
|
|
|
ULONG ReturnLength;
|
|
|
|
DWORD handlecount;
|
|
|
|
HANDLE process;
|
|
|
|
|
|
|
|
status = pNtQueryInformationProcess(NULL, ProcessHandleCount, NULL, sizeof(handlecount), NULL);
|
|
|
|
ok( status == STATUS_ACCESS_VIOLATION || status == STATUS_INVALID_HANDLE,
|
|
|
|
"Expected STATUS_ACCESS_VIOLATION or STATUS_INVALID_HANDLE(W2K3), got %08lx\n", status);
|
|
|
|
|
|
|
|
status = pNtQueryInformationProcess(NULL, ProcessHandleCount, &handlecount, sizeof(handlecount), NULL);
|
|
|
|
ok( status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08lx\n", status);
|
|
|
|
|
|
|
|
status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessHandleCount, &handlecount, 2, &ReturnLength);
|
|
|
|
ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
|
|
|
|
|
|
|
|
process = OpenProcess (PROCESS_QUERY_INFORMATION, TRUE, one_before_last_pid);
|
|
|
|
trace("Handlecount for process with ID : %ld\n", one_before_last_pid);
|
|
|
|
status = pNtQueryInformationProcess( process, ProcessHandleCount, &handlecount, sizeof(handlecount), &ReturnLength);
|
|
|
|
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
|
|
|
|
ok( sizeof(handlecount) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(handlecount), ReturnLength);
|
|
|
|
CloseHandle(process);
|
|
|
|
|
|
|
|
status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessHandleCount, &handlecount, sizeof(handlecount) * 2, &ReturnLength);
|
|
|
|
ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
|
|
|
|
ok( sizeof(handlecount) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(handlecount), ReturnLength);
|
|
|
|
|
|
|
|
/* Check if we have some return values */
|
|
|
|
trace("HandleCount : %ld\n", handlecount);
|
|
|
|
todo_wine
|
|
|
|
{
|
|
|
|
ok( handlecount > 0, "Expected some handles, got 0\n");
|
|
|
|
}
|
2005-06-14 14:25:02 +02:00
|
|
|
}
|
|
|
|
|
2005-04-15 16:12:54 +02:00
|
|
|
START_TEST(info)
|
|
|
|
{
|
|
|
|
if(!InitFunctionPtrs())
|
|
|
|
return;
|
|
|
|
|
2005-06-14 14:25:02 +02:00
|
|
|
/* NtQuerySystemInformation */
|
|
|
|
|
2005-06-10 21:52:32 +02:00
|
|
|
/* 0x0 SystemBasicInformation */
|
2005-05-10 15:16:36 +02:00
|
|
|
trace("Starting test_query_basic()\n");
|
|
|
|
test_query_basic();
|
|
|
|
|
2005-06-10 21:52:32 +02:00
|
|
|
/* 0x1 SystemCpuInformation */
|
|
|
|
trace("Starting test_query_cpu()\n");
|
|
|
|
test_query_cpu();
|
|
|
|
|
2005-06-13 13:34:56 +02:00
|
|
|
/* 0x3 SystemCpuInformation */
|
|
|
|
trace("Starting test_query_timeofday()\n");
|
|
|
|
test_query_timeofday();
|
|
|
|
|
2005-06-10 21:52:32 +02:00
|
|
|
/* 0x5 SystemProcessInformation */
|
2005-06-09 12:03:25 +02:00
|
|
|
trace("Starting test_query_process()\n");
|
|
|
|
test_query_process();
|
|
|
|
|
2005-05-10 15:16:36 +02:00
|
|
|
/* 0x10 SystemHandleInformation */
|
|
|
|
trace("Starting test_query_handle()\n");
|
|
|
|
test_query_handle();
|
2005-04-15 16:12:54 +02:00
|
|
|
|
2005-06-14 14:25:02 +02:00
|
|
|
/* NtQueryInformationProcess */
|
|
|
|
|
2005-06-21 22:22:01 +02:00
|
|
|
/* 0x0 ProcessBasicInformation */
|
2005-06-14 14:25:02 +02:00
|
|
|
trace("Starting test_query_process_basic()\n");
|
|
|
|
test_query_process_basic();
|
|
|
|
|
2005-06-21 22:22:01 +02:00
|
|
|
/* 0x2 ProcessIoCounters */
|
|
|
|
trace("Starting test_query_process_io()\n");
|
|
|
|
test_query_process_io();
|
|
|
|
|
|
|
|
/* 0x3 ProcessVmCounters */
|
|
|
|
trace("Starting test_query_process_vm()\n");
|
|
|
|
test_query_process_vm();
|
|
|
|
|
|
|
|
/* 0x4 ProcessTimes */
|
|
|
|
trace("Starting test_query_process_times()\n");
|
|
|
|
test_query_process_times();
|
|
|
|
|
|
|
|
/* 0x14 ProcessHandleCount */
|
|
|
|
trace("Starting test_query_process_handlecount()\n");
|
|
|
|
test_query_process_handlecount();
|
|
|
|
|
2005-04-15 16:12:54 +02:00
|
|
|
FreeLibrary(hntdll);
|
|
|
|
}
|