Brendan Shanks : ntdll: Use +threadname channel for SetThreadDescription().

Alexandre Julliard julliard at winehq.org
Thu Jun 30 16:34:20 CDT 2022


Module: wine
Branch: master
Commit: ee0fd30e58677654fb4339180c0b31360fd31a4b
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=ee0fd30e58677654fb4339180c0b31360fd31a4b

Author: Brendan Shanks <bshanks at codeweavers.com>
Date:   Fri Jun 17 14:25:56 2022 -0700

ntdll: Use +threadname channel for SetThreadDescription().

Signed-off-by: Brendan Shanks <bshanks at codeweavers.com>

---

 dlls/ntdll/unix/thread.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/dlls/ntdll/unix/thread.c b/dlls/ntdll/unix/thread.c
index ad47a5fce74..ca1d1293d10 100644
--- a/dlls/ntdll/unix/thread.c
+++ b/dlls/ntdll/unix/thread.c
@@ -70,6 +70,7 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(thread);
 WINE_DECLARE_DEBUG_CHANNEL(seh);
+WINE_DECLARE_DEBUG_CHANNEL(threadname);
 
 static int nb_threads = 1;
 
@@ -2232,11 +2233,19 @@ NTSTATUS WINAPI NtSetInformationThread( HANDLE handle, THREADINFOCLASS class,
     case ThreadNameInformation:
     {
         const THREAD_NAME_INFORMATION *info = data;
+        THREAD_BASIC_INFORMATION tbi;
 
         if (length != sizeof(*info)) return STATUS_INFO_LENGTH_MISMATCH;
         if (!info) return STATUS_ACCESS_VIOLATION;
         if (info->ThreadName.Length && !info->ThreadName.Buffer) return STATUS_ACCESS_VIOLATION;
 
+        if (handle == GetCurrentThread())
+            WARN_(threadname)( "Thread renamed to %s\n", debugstr_us(&info->ThreadName) );
+        else if (!NtQueryInformationThread( handle, ThreadBasicInformation, &tbi, sizeof(tbi), NULL ))
+            WARN_(threadname)( "Thread ID %04x renamed to %s\n", HandleToULong( tbi.ClientId.UniqueThread ), debugstr_us(&info->ThreadName) );
+        else
+            WARN_(threadname)( "Thread handle %p renamed to %s\n", handle, debugstr_us(&info->ThreadName) );
+
         SERVER_START_REQ( set_thread_info )
         {
             req->handle = wine_server_obj_handle( handle );




More information about the wine-cvs mailing list