Commit 95bd82ee authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

ntoskrnl.exe: Return error codes compatible with recent Windows versions in…

ntoskrnl.exe: Return error codes compatible with recent Windows versions in PsLookupThreadByThreadId. Signed-off-by: 's avatarJacek Caban <jacek@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent c448550e
...@@ -2558,13 +2558,18 @@ PRKTHREAD WINAPI KeGetCurrentThread(void) ...@@ -2558,13 +2558,18 @@ PRKTHREAD WINAPI KeGetCurrentThread(void)
*/ */
NTSTATUS WINAPI PsLookupThreadByThreadId( HANDLE threadid, PETHREAD *thread ) NTSTATUS WINAPI PsLookupThreadByThreadId( HANDLE threadid, PETHREAD *thread )
{ {
OBJECT_ATTRIBUTES attr;
CLIENT_ID cid;
NTSTATUS status; NTSTATUS status;
HANDLE handle; HANDLE handle;
TRACE( "(%p %p)\n", threadid, thread ); TRACE( "(%p %p)\n", threadid, thread );
if (!(handle = OpenThread( THREAD_QUERY_INFORMATION, FALSE, HandleToUlong(threadid) ))) cid.UniqueProcess = 0;
return STATUS_INVALID_PARAMETER; cid.UniqueThread = threadid;
InitializeObjectAttributes( &attr, NULL, 0, NULL, NULL );
status = NtOpenThread( &handle, THREAD_QUERY_INFORMATION, &attr, &cid );
if (status) return status;
status = ObReferenceObjectByHandle( handle, THREAD_ALL_ACCESS, PsThreadType, KernelMode, (void**)thread, NULL ); status = ObReferenceObjectByHandle( handle, THREAD_ALL_ACCESS, PsThreadType, KernelMode, (void**)thread, NULL );
......
...@@ -170,6 +170,11 @@ static void winetest_end_todo(void) ...@@ -170,6 +170,11 @@ static void winetest_end_todo(void)
todo_level >>= 1; todo_level >>= 1;
} }
static int broken(int condition)
{
return !running_under_wine && condition;
}
#define ok(condition, ...) ok_(__FILE__, __LINE__, condition, __VA_ARGS__) #define ok(condition, ...) ok_(__FILE__, __LINE__, condition, __VA_ARGS__)
#define todo_if(is_todo) for (winetest_start_todo(is_todo); \ #define todo_if(is_todo) for (winetest_start_todo(is_todo); \
winetest_loop_todo(); \ winetest_loop_todo(); \
...@@ -1179,7 +1184,8 @@ static void test_lookup_thread(void) ...@@ -1179,7 +1184,8 @@ static void test_lookup_thread(void)
if (thread) ObDereferenceObject(thread); if (thread) ObDereferenceObject(thread);
status = PsLookupThreadByThreadId(NULL, &thread); status = PsLookupThreadByThreadId(NULL, &thread);
ok(status == STATUS_INVALID_PARAMETER, "PsLookupThreadByThreadId returned %#x\n", status); ok(status == STATUS_INVALID_CID || broken(status == STATUS_INVALID_PARAMETER) /* winxp */,
"PsLookupThreadByThreadId returned %#x\n", status);
} }
static NTSTATUS main_test(DEVICE_OBJECT *device, IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info) static NTSTATUS main_test(DEVICE_OBJECT *device, IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info)
......
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