ntoskrnl.exe: Implement IoGetCurrentProcess.

Based on patch by Derek Lesho.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=29460
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2019-04-29 16:00:32 +02:00 committed by Alexandre Julliard
parent 2be769d648
commit 6ebc223955
3 changed files with 17 additions and 3 deletions

View File

@ -2477,8 +2477,7 @@ POBJECT_TYPE PsProcessType = &process_type;
*/
PEPROCESS WINAPI IoGetCurrentProcess(void)
{
FIXME("() stub\n");
return NULL;
return KeGetCurrentThread()->process;
}
/***********************************************************************
@ -2505,6 +2504,7 @@ static void *create_thread_object( HANDLE handle )
{
THREAD_BASIC_INFORMATION info;
struct _KTHREAD *thread;
HANDLE process;
if (!(thread = alloc_kernel_object( PsThreadType, handle, sizeof(*thread), 0 ))) return NULL;
@ -2512,7 +2512,15 @@ static void *create_thread_object( HANDLE handle )
thread->header.WaitListHead.Blink = INVALID_HANDLE_VALUE; /* mark as kernel object */
if (!NtQueryInformationThread( handle, ThreadBasicInformation, &info, sizeof(info), NULL ))
{
thread->id = info.ClientId;
if ((process = OpenProcess( PROCESS_QUERY_INFORMATION, FALSE, HandleToUlong(thread->id.UniqueProcess) )))
{
kernel_object_from_handle( process, PsProcessType, (void**)&thread->process );
NtClose( process );
}
}
return thread;
}

View File

@ -35,6 +35,7 @@ struct _EPROCESS {
struct _KTHREAD
{
DISPATCHER_HEADER header;
PEPROCESS process;
CLIENT_ID id;
};

View File

@ -321,14 +321,19 @@ static NTSTATUS wait_single_handle(HANDLE handle, ULONGLONG timeout)
static void test_currentprocess(void)
{
DISPATCHER_HEADER *header;
PEPROCESS current;
PETHREAD thread;
NTSTATUS ret;
current = IoGetCurrentProcess();
todo_wine
ok(current != NULL, "Expected current process to be non-NULL\n");
header = (DISPATCHER_HEADER*)current;
ok(header->Type == 3, "header->Type != 3, = %u\n", header->Type);
ret = wait_single(current, 0);
ok(ret == STATUS_TIMEOUT, "got %#x\n", ret);
thread = PsGetCurrentThread();
ret = wait_single( thread, 0 );
ok(ret == STATUS_TIMEOUT, "got %#x\n", ret);