Commit 6ebc2239 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

ntoskrnl.exe: Implement IoGetCurrentProcess.

Based on patch by Derek Lesho. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=29460Signed-off-by: 's avatarJacek Caban <jacek@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 2be769d6
...@@ -2477,8 +2477,7 @@ POBJECT_TYPE PsProcessType = &process_type; ...@@ -2477,8 +2477,7 @@ POBJECT_TYPE PsProcessType = &process_type;
*/ */
PEPROCESS WINAPI IoGetCurrentProcess(void) PEPROCESS WINAPI IoGetCurrentProcess(void)
{ {
FIXME("() stub\n"); return KeGetCurrentThread()->process;
return NULL;
} }
/*********************************************************************** /***********************************************************************
...@@ -2505,6 +2504,7 @@ static void *create_thread_object( HANDLE handle ) ...@@ -2505,6 +2504,7 @@ static void *create_thread_object( HANDLE handle )
{ {
THREAD_BASIC_INFORMATION info; THREAD_BASIC_INFORMATION info;
struct _KTHREAD *thread; struct _KTHREAD *thread;
HANDLE process;
if (!(thread = alloc_kernel_object( PsThreadType, handle, sizeof(*thread), 0 ))) return NULL; if (!(thread = alloc_kernel_object( PsThreadType, handle, sizeof(*thread), 0 ))) return NULL;
...@@ -2512,7 +2512,15 @@ static void *create_thread_object( HANDLE handle ) ...@@ -2512,7 +2512,15 @@ static void *create_thread_object( HANDLE handle )
thread->header.WaitListHead.Blink = INVALID_HANDLE_VALUE; /* mark as kernel object */ thread->header.WaitListHead.Blink = INVALID_HANDLE_VALUE; /* mark as kernel object */
if (!NtQueryInformationThread( handle, ThreadBasicInformation, &info, sizeof(info), NULL )) if (!NtQueryInformationThread( handle, ThreadBasicInformation, &info, sizeof(info), NULL ))
{
thread->id = info.ClientId; 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; return thread;
} }
......
...@@ -35,6 +35,7 @@ struct _EPROCESS { ...@@ -35,6 +35,7 @@ struct _EPROCESS {
struct _KTHREAD struct _KTHREAD
{ {
DISPATCHER_HEADER header; DISPATCHER_HEADER header;
PEPROCESS process;
CLIENT_ID id; CLIENT_ID id;
}; };
......
...@@ -321,14 +321,19 @@ static NTSTATUS wait_single_handle(HANDLE handle, ULONGLONG timeout) ...@@ -321,14 +321,19 @@ static NTSTATUS wait_single_handle(HANDLE handle, ULONGLONG timeout)
static void test_currentprocess(void) static void test_currentprocess(void)
{ {
DISPATCHER_HEADER *header;
PEPROCESS current; PEPROCESS current;
PETHREAD thread; PETHREAD thread;
NTSTATUS ret; NTSTATUS ret;
current = IoGetCurrentProcess(); current = IoGetCurrentProcess();
todo_wine
ok(current != NULL, "Expected current process to be non-NULL\n"); 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(); thread = PsGetCurrentThread();
ret = wait_single( thread, 0 ); ret = wait_single( thread, 0 );
ok(ret == STATUS_TIMEOUT, "got %#x\n", ret); ok(ret == STATUS_TIMEOUT, "got %#x\n", ret);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment