Commit f680eda8 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

ntoskrnl.exe: Implement KeGetCurrentThread.

parent b0b89cb5
......@@ -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;
}
/***********************************************************************
......
......@@ -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};
......
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