NtDll: AmILastThread thread info class

Eric Pouech eric.pouech at wanadoo.fr
Wed Jun 14 14:18:41 CDT 2006


-------------- next part --------------
>From nobody Mon Sep 17 00:00:00 2001
From: Eric Pouech <eric.pouech at wanadoo.fr>
Date: Wed, 14 Jun 2006 20:50:42 +0200
Subject: [PATCH] [NtDll]: NtQueryInformationiThread (AmILastThread)

- implemented AmILastThread information class for
  NtQueryInformationThread

---

 dlls/ntdll/thread.c            |   18 +++++++++++++++++-
 include/wine/server_protocol.h |    3 ++-
 server/protocol.def            |    1 +
 server/thread.c                |    3 +++
 server/trace.c                 |    3 ++-
 5 files changed, 25 insertions(+), 3 deletions(-)

5c5d81cde8101c5d85490ebe87264231cfba5f2e
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index 10cb72b..7f82a88 100644
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -1134,6 +1134,23 @@ #else
 #endif
             return status;
         }
+    case ThreadAmILastThread:
+        {
+            SERVER_START_REQ(get_thread_info)
+            {
+                req->handle = handle;
+                req->tid_in = 0;
+                status = wine_server_call( req );
+                if (status == STATUS_SUCCESS)
+                {
+                    BOOLEAN last = reply->num_siblings == 1;
+                    if (data) memcpy( data, &last, min( length, sizeof(last) ));
+                    if (ret_len) *ret_len = min( length, sizeof(last) );
+                }
+            }
+            SERVER_END_REQ;
+            return status;
+        }
     case ThreadPriority:
     case ThreadBasePriority:
     case ThreadAffinityMask:
@@ -1143,7 +1160,6 @@ #endif
     case ThreadQuerySetWin32StartAddress:
     case ThreadZeroTlsCell:
     case ThreadPerformanceCount:
-    case ThreadAmILastThread:
     case ThreadIdealProcessor:
     case ThreadPriorityBoost:
     case ThreadSetTlsArrayAddress:
diff --git a/server/protocol.def b/server/protocol.def
index daade07..cd3f90d 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -343,6 +343,7 @@ #define SET_PROCESS_INFO_AFFINITY 0x02
     int          affinity;      /* thread affinity mask */
     time_t       creation_time; /* thread creation time */
     time_t       exit_time;     /* thread exit time */
+    int          num_siblings;  /* num threads in process (including self) */
 @END
 
 
diff --git a/server/thread.c b/server/thread.c
index 40b9615..209bc33 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -948,6 +950,7 @@ DECL_HANDLER(get_thread_info)
         reply->affinity       = thread->affinity;
         reply->creation_time  = thread->creation_time;
         reply->exit_time      = thread->exit_time;
+        reply->num_siblings   = thread->process->running_threads;
 
         release_object( thread );
     }
diff --git a/server/trace.c b/server/trace.c
index 624da75..fde6b90 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -762,7 +762,8 @@ static void dump_get_thread_info_reply( 
     fprintf( stderr, " priority=%d,", req->priority );
     fprintf( stderr, " affinity=%d,", req->affinity );
     fprintf( stderr, " creation_time=%ld,", (long)req->creation_time );
-    fprintf( stderr, " exit_time=%ld", (long)req->exit_time );
+    fprintf( stderr, " exit_time=%ld,", (long)req->exit_time );
+    fprintf( stderr, " num_siblings=%d", req->num_siblings );
 }
 
 static void dump_set_thread_info_request( const struct set_thread_info_request *req )
-- 
1.3.3



More information about the wine-patches mailing list