📄 info.c
字号:
/* 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++;
last_pid = spi->dwProcessID;
ok( spi->dwThreadCount > 0, "Expected some threads for this process, got 0\n");
/* Loop through the threads, skip NT4 for now */
if (!is_nt)
{
DWORD j;
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;
one_before_last_pid = last_pid;
spi = (SYSTEM_PROCESS_INFORMATION_PRIVATE*)((char*)spi + spi->dwOffset);
}
trace("Total number of running processes : %d\n", i);
if (!is_nt) trace("Total number of running threads : %d\n", k);
if (one_before_last_pid == 0) one_before_last_pid = last_pid;
HeapFree( GetProcessHeap(), 0, spi);
}
static void test_query_procperf(void)
{
DWORD status;
ULONG ReturnLength;
ULONG NeededLength;
SYSTEM_BASIC_INFORMATION sbi;
SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION* sppi;
/* Find out the number of processors */
status = pNtQuerySystemInformation(SystemBasicInformation, &sbi, sizeof(sbi), &ReturnLength);
NeededLength = sbi.NumberOfProcessors * sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION);
sppi = HeapAlloc(GetProcessHeap(), 0, NeededLength);
status = pNtQuerySystemInformation(SystemProcessorPerformanceInformation, sppi, 0, &ReturnLength);
ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
/* Try it for 1 processor */
status = pNtQuerySystemInformation(SystemProcessorPerformanceInformation, sppi,
sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION), &ReturnLength);
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
ok( sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) == ReturnLength,
"Inconsistent length (%d) <-> (%ld)\n", sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION), ReturnLength);
/* Try it for all processors */
status = pNtQuerySystemInformation(SystemProcessorPerformanceInformation, sppi, NeededLength, &ReturnLength);
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
ok( NeededLength == ReturnLength, "Inconsistent length (%ld) <-> (%ld)\n", NeededLength, ReturnLength);
/* A too large given buffer size */
sppi = HeapReAlloc(GetProcessHeap(), 0, sppi , NeededLength + 2);
status = pNtQuerySystemInformation(SystemProcessorPerformanceInformation, sppi, NeededLength + 2, &ReturnLength);
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
ok( NeededLength == ReturnLength, "Inconsistent length (%ld) <-> (%ld)\n", NeededLength, ReturnLength);
HeapFree( GetProcessHeap(), 0, sppi);
}
static void test_query_module(void)
{
DWORD status;
ULONG ReturnLength;
ULONG ModuleCount, i;
ULONG SystemInformationLength = sizeof(SYSTEM_MODULE_INFORMATION);
SYSTEM_MODULE_INFORMATION* smi = HeapAlloc(GetProcessHeap(), 0, SystemInformationLength);
SYSTEM_MODULE* sm;
/* Request the needed length */
status = pNtQuerySystemInformation(SystemModuleInformation, smi, 0, &ReturnLength);
ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
ok( ReturnLength > 0, "Expected a ReturnLength to show the needed length\n");
SystemInformationLength = ReturnLength;
smi = HeapReAlloc(GetProcessHeap(), 0, smi , SystemInformationLength);
status = pNtQuerySystemInformation(SystemModuleInformation, smi, SystemInformationLength, &ReturnLength);
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
ModuleCount = smi->ModulesCount;
sm = &smi->Modules[0];
todo_wine{
/* our implementation is a stub for now */
ok( ModuleCount > 0, "Expected some modules to be loaded\n");
}
/* Loop through all the modules/drivers, Wine doesn't get here (yet) */
for (i = 0; i < ModuleCount ; i++)
{
ok( i == sm->Id, "Id (%d) should have matched %lu\n", sm->Id, i);
sm++;
}
HeapFree( GetProcessHeap(), 0, smi);
}
static void test_query_handle(void)
{
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);
}
static void test_query_cache(void)
{
DWORD status;
ULONG ReturnLength;
SYSTEM_CACHE_INFORMATION sci;
status = pNtQuerySystemInformation(SystemCacheInformation, &sci, 0, &ReturnLength);
ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
status = pNtQuerySystemInformation(SystemCacheInformation, &sci, sizeof(sci), &ReturnLength);
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
ok( sizeof(sci) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(sci), ReturnLength);
status = pNtQuerySystemInformation(SystemCacheInformation, &sci, sizeof(sci) + 2, &ReturnLength);
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
ok( sizeof(sci) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(sci), ReturnLength);
}
static void test_query_interrupt(void)
{
DWORD status;
ULONG ReturnLength;
ULONG NeededLength;
SYSTEM_BASIC_INFORMATION sbi;
SYSTEM_INTERRUPT_INFORMATION* sii;
/* Find out the number of processors */
status = pNtQuerySystemInformation(SystemBasicInformation, &sbi, sizeof(sbi), &ReturnLength);
NeededLength = sbi.NumberOfProcessors * sizeof(SYSTEM_INTERRUPT_INFORMATION);
sii = HeapAlloc(GetProcessHeap(), 0, NeededLength);
status = pNtQuerySystemInformation(SystemInterruptInformation, sii, 0, &ReturnLength);
ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
/* Try it for all processors */
status = pNtQuerySystemInformation(SystemInterruptInformation, sii, NeededLength, &ReturnLength);
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
/* Windows XP and W2K3 (and others?) always return 0 for the ReturnLength
* No test added for this as it's highly unlikely that an app depends on this
*/
HeapFree( GetProcessHeap(), 0, sii);
}
static void test_query_kerndebug(void)
{
DWORD status;
ULONG ReturnLength;
SYSTEM_KERNEL_DEBUGGER_INFORMATION skdi;
status = pNtQuerySystemInformation(SystemKernelDebuggerInformation, &skdi, 0, &ReturnLength);
ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
status = pNtQuerySystemInformation(SystemKernelDebuggerInformation, &skdi, sizeof(skdi), &ReturnLength);
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
ok( sizeof(skdi) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(skdi), ReturnLength);
status = pNtQuerySystemInformation(SystemKernelDebuggerInformation, &skdi, sizeof(skdi) + 2, &ReturnLength);
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
ok( sizeof(skdi) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(skdi), ReturnLength);
}
static void test_query_regquota(void)
{
DWORD status;
ULONG ReturnLength;
SYSTEM_REGISTRY_QUOTA_INFORMATION srqi;
status = pNtQuerySystemInformation(SystemRegistryQuotaInformation, &srqi, 0, &ReturnLength);
ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
status = pNtQuerySystemInformation(SystemRegistryQuotaInformation, &srqi, sizeof(srqi), &ReturnLength);
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
ok( sizeof(srqi) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(srqi), ReturnLength);
status = pNtQuerySystemInformation(SystemRegistryQuotaInformation, &srqi, sizeof(srqi) + 2, &ReturnLength);
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
ok( sizeof(srqi) == ReturnLength, "Inconsistent length (%d) <-> (%ld)\n", sizeof(srqi), ReturnLength);
}
static void test_query_process_basic(void)
{
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);
ok( status == STATUS_ACCESS_VIOLATION || status == STATUS_INVALID_HANDLE,
"Expected STATUS_ACCESS_VIOLATION or STATUS_INVALID_HANDLE(W2K3), got %08lx\n", status);
/* 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);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -