📄 info.c
字号:
/* 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);
/* 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);
/* Check if we have some return values */
trace("ProcessID : %ld\n", pbi.UniqueProcessId);
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;
/* 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;
}
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, FALSE, one_before_last_pid);
if (!process)
{
trace("Could not open process with ID : %ld, error : %08lx. Going to use current one.\n", one_before_last_pid, GetLastError());
process = GetCurrentProcess();
trace("ProcessTimes for current process\n");
}
else
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, FALSE, one_before_last_pid);
if (!process)
{
trace("Could not open process with ID : %ld, error : %08lx. Going to use current one.\n", one_before_last_pid, GetLastError());
process = GetCurrentProcess();
trace("ProcessHandleCount for current process\n");
}
else
trace("ProcessHandleCount 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");
}
}
START_TEST(info)
{
if(!InitFunctionPtrs())
return;
/* NtQuerySystemInformation */
/* 0x0 SystemBasicInformation */
trace("Starting test_query_basic()\n");
test_query_basic();
/* 0x1 SystemCpuInformation */
trace("Starting test_query_cpu()\n");
test_query_cpu();
/* 0x2 SystemPerformanceInformation */
trace("Starting test_query_performance()\n");
test_query_performance();
/* 0x3 SystemTimeOfDayInformation */
trace("Starting test_query_timeofday()\n");
test_query_timeofday();
/* 0x5 SystemProcessInformation */
trace("Starting test_query_process()\n");
test_query_process();
/* 0x8 SystemProcessorPerformanceInformation */
trace("Starting test_query_procperf()\n");
test_query_procperf();
/* 0xb SystemModuleInformation */
trace("Starting test_query_module()\n");
test_query_module();
/* 0x10 SystemHandleInformation */
trace("Starting test_query_handle()\n");
test_query_handle();
/* 0x15 SystemCacheInformation */
trace("Starting test_query_cache()\n");
test_query_cache();
/* 0x17 SystemInterruptInformation */
trace("Starting test_query_interrupt()\n");
test_query_interrupt();
/* 0x23 SystemKernelDebuggerInformation */
trace("Starting test_query_kerndebug()\n");
test_query_kerndebug();
/* 0x25 SystemRegistryQuotaInformation */
trace("Starting test_query_regquota()\n");
test_query_regquota();
/* NtQueryInformationProcess */
/* 0x0 ProcessBasicInformation */
trace("Starting test_query_process_basic()\n");
test_query_process_basic();
/* 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();
FreeLibrary(hntdll);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -