Jacek Caban : ntoskrnl.exe: Return error codes compatible with recent Windows versions in PsLookupThreadByThreadId.
Alexandre Julliard
julliard at winehq.org
Tue Apr 23 17:39:55 CDT 2019
Module: wine
Branch: master
Commit: 95bd82eee5dd822e404c623ed08eb2d4156657b4
URL: https://source.winehq.org/git/wine.git/?a=commit;h=95bd82eee5dd822e404c623ed08eb2d4156657b4
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue Apr 23 16:23:14 2019 +0200
ntoskrnl.exe: Return error codes compatible with recent Windows versions in PsLookupThreadByThreadId.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntoskrnl.exe/ntoskrnl.c | 9 +++++++--
dlls/ntoskrnl.exe/tests/driver.c | 8 +++++++-
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index 7f3ca05..f266dce 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -2558,13 +2558,18 @@ PRKTHREAD WINAPI KeGetCurrentThread(void)
*/
NTSTATUS WINAPI PsLookupThreadByThreadId( HANDLE threadid, PETHREAD *thread )
{
+ OBJECT_ATTRIBUTES attr;
+ CLIENT_ID cid;
NTSTATUS status;
HANDLE handle;
TRACE( "(%p %p)\n", threadid, thread );
- if (!(handle = OpenThread( THREAD_QUERY_INFORMATION, FALSE, HandleToUlong(threadid) )))
- return STATUS_INVALID_PARAMETER;
+ cid.UniqueProcess = 0;
+ 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 );
diff --git a/dlls/ntoskrnl.exe/tests/driver.c b/dlls/ntoskrnl.exe/tests/driver.c
index d7083f7..5f65f66 100644
--- a/dlls/ntoskrnl.exe/tests/driver.c
+++ b/dlls/ntoskrnl.exe/tests/driver.c
@@ -170,6 +170,11 @@ static void winetest_end_todo(void)
todo_level >>= 1;
}
+static int broken(int condition)
+{
+ return !running_under_wine && condition;
+}
+
#define ok(condition, ...) ok_(__FILE__, __LINE__, condition, __VA_ARGS__)
#define todo_if(is_todo) for (winetest_start_todo(is_todo); \
winetest_loop_todo(); \
@@ -1179,7 +1184,8 @@ static void test_lookup_thread(void)
if (thread) ObDereferenceObject(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)
More information about the wine-cvs
mailing list