kernel32/tests: Add some tests for the behavior of queries on a dead process.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2021-03-11 18:04:48 +01:00
parent 4393438ab3
commit fdf6d7de2e
1 changed files with 69 additions and 2 deletions

View File

@ -4171,6 +4171,72 @@ static void test_handle_list_attribute(BOOL child, HANDLE handle1, HANDLE handle
CloseHandle(pipe[1]);
}
static void test_dead_process(void)
{
DWORD_PTR data[256];
PROCESS_BASIC_INFORMATION basic;
SYSTEM_PROCESS_INFORMATION *spi;
SECTION_IMAGE_INFORMATION image;
PROCESS_INFORMATION pi;
PROCESS_PRIORITY_CLASS *prio = (PROCESS_PRIORITY_CLASS *)data;
BYTE *buffer = NULL;
BOOL found;
ULONG size = 0;
DWORD offset = 0;
NTSTATUS status;
create_process("exit", &pi);
wait_child_process(pi.hProcess);
Sleep(100);
memset( data, 0, sizeof(data) );
status = NtQueryInformationProcess( pi.hProcess, ProcessImageFileName, data, sizeof(data), NULL);
ok( !status, "ProcessImageFileName failed %x\n", status );
todo_wine
ok( ((UNICODE_STRING *)data)->Length, "ProcessImageFileName not set\n" );
todo_wine
ok( ((UNICODE_STRING *)data)->Buffer[0] == '\\', "ProcessImageFileName not set\n" );
memset( prio, 0xcc, sizeof(*prio) );
status = NtQueryInformationProcess( pi.hProcess, ProcessPriorityClass, prio, sizeof(*prio), NULL);
ok( !status, "ProcessPriorityClass failed %x\n", status );
ok( prio->PriorityClass != 0xcc, "ProcessPriorityClass not set\n" );
memset( &basic, 0xcc, sizeof(basic) );
status = NtQueryInformationProcess( pi.hProcess, ProcessBasicInformation, &basic, sizeof(basic), NULL);
ok( !status, "ProcessBasicInformation failed %x\n", status );
ok( basic.ExitStatus == 0, "ProcessBasicInformation info modified\n" );
memset( &image, 0xcc, sizeof(image) );
status = NtQueryInformationProcess( pi.hProcess, ProcessImageInformation, &image, sizeof(image), NULL);
todo_wine
ok( status == STATUS_PROCESS_IS_TERMINATING, "ProcessImageInformation wrong error %x\n", status );
todo_wine
ok( image.Machine == 0xcccc, "ProcessImageInformation info modified\n" );
while ((status = NtQuerySystemInformation(SystemProcessInformation, buffer, size, &size)) == STATUS_INFO_LENGTH_MISMATCH)
{
free(buffer);
buffer = malloc(size);
}
ok(status == STATUS_SUCCESS, "got %#x\n", status);
found = FALSE;
do
{
spi = (SYSTEM_PROCESS_INFORMATION *)(buffer + offset);
if (spi->UniqueProcessId == ULongToHandle(pi.dwProcessId))
{
found = TRUE;
break;
}
offset += spi->NextEntryOffset;
} while (spi->NextEntryOffset);
todo_wine
ok( !found, "process still enumerated\n" );
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
}
START_TEST(process)
{
HANDLE job, hproc, h, h2;
@ -4291,6 +4357,9 @@ START_TEST(process)
test_ProcThreadAttributeList();
test_SuspendProcessState();
test_SuspendProcessNewThread();
test_parent_process_attribute(0, NULL);
test_handle_list_attribute(FALSE, NULL, NULL);
test_dead_process();
/* things that can be tested:
* lookup: check the way program to be executed is searched
@ -4314,6 +4383,4 @@ START_TEST(process)
test_jobInheritance(job);
test_BreakawayOk(job);
CloseHandle(job);
test_parent_process_attribute(0, NULL);
test_handle_list_attribute(FALSE, NULL, NULL);
}