ntoskrnl.exe: Implement KeGetCurrentThread.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45844
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-08 14:04:07 +02:00 committed by Alexandre Julliard
parent b0b89cb569
commit f680eda832
2 changed files with 32 additions and 11 deletions

View file

@ -961,6 +961,7 @@ NTSTATUS CDECL wine_ntoskrnl_main_loop( HANDLE stop_event )
for (;;)
{
NtCurrentTeb()->Reserved5[1] = NULL;
if (!in_buff && !(in_buff = HeapAlloc( GetProcessHeap(), 0, in_size )))
{
ERR( "failed to allocate buffer\n" );
@ -2506,8 +2507,22 @@ POBJECT_TYPE PsThreadType = &thread_type;
*/
PRKTHREAD WINAPI KeGetCurrentThread(void)
{
FIXME("() stub\n");
return NULL;
struct _KTHREAD *thread = NtCurrentTeb()->Reserved5[1];
if (!thread)
{
HANDLE handle = GetCurrentThread();
/* FIXME: we shouldn't need it, GetCurrentThread() should be client thread already */
if (GetCurrentThreadId() == request_thread) handle = OpenThread( 0, FALSE, client_tid );
kernel_object_from_handle( handle, PsThreadType, (void**)&thread );
if (handle != GetCurrentThread()) NtClose( handle );
NtCurrentTeb()->Reserved5[1] = thread;
}
return thread;
}
/***********************************************************************

View file

@ -210,15 +210,6 @@ static void *get_proc_address(const char *name)
return ret;
}
static void test_currentprocess(void)
{
PEPROCESS current;
current = IoGetCurrentProcess();
todo_wine
ok(current != NULL, "Expected current process to be non-NULL\n");
}
static FILE_OBJECT *last_created_file;
static void test_irp_struct(IRP *irp, DEVICE_OBJECT *device)
@ -316,6 +307,21 @@ static NTSTATUS wait_single_handle(HANDLE handle, ULONGLONG timeout)
return ZwWaitForSingleObject(handle, FALSE, &integer);
}
static void test_currentprocess(void)
{
PEPROCESS current;
PETHREAD thread;
NTSTATUS ret;
current = IoGetCurrentProcess();
todo_wine
ok(current != NULL, "Expected current process to be non-NULL\n");
thread = PsGetCurrentThread();
ret = wait_single( thread, 0 );
ok(ret == STATUS_TIMEOUT, "got %#x\n", ret);
}
static void run_thread(PKSTART_ROUTINE proc, void *arg)
{
OBJECT_ATTRIBUTES attr = {0};