[PATCH] [NtDll]: NtQueryInformationiThread (AmILastThread)

Eric Pouech eric.pouech at wanadoo.fr
Sun Oct 1 01:17:27 CDT 2006


- implemented AmILastThread information class for
  NtQueryInformationThread

A+
---

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

diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index 364c86d..151ff1e 100644
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -1167,6 +1167,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->last;
+                    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:
@@ -1176,7 +1193,6 @@ #endif
     case ThreadQuerySetWin32StartAddress:
     case ThreadZeroTlsCell:
     case ThreadPerformanceCount:
-    case ThreadAmILastThread:
     case ThreadIdealProcessor:
     case ThreadPriorityBoost:
     case ThreadSetTlsArrayAddress:
diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h
index db1de31..b0f7367 100644
--- a/include/wine/server_protocol.h
+++ b/include/wine/server_protocol.h
@@ -388,6 +388,7 @@ struct get_thread_info_reply
     int          affinity;
     abs_time_t   creation_time;
     abs_time_t   exit_time;
+    int          last;
 };
 
 
@@ -4431,6 +4432,6 @@ union generic_reply
     struct query_virtual_memory_info_reply query_virtual_memory_info_reply;
 };
 
-#define SERVER_PROTOCOL_VERSION 246
+#define SERVER_PROTOCOL_VERSION 247
 
 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */
diff --git a/server/protocol.def b/server/protocol.def
index 8ce7d28..d23de7d 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -347,6 +347,7 @@ #define SET_PROCESS_INFO_AFFINITY 0x02
     int          affinity;      /* thread affinity mask */
     abs_time_t   creation_time; /* thread creation time */
     abs_time_t   exit_time;     /* thread exit time */
+    int          last;          /* last thread in process */
 @END
 
 
diff --git a/server/thread.c b/server/thread.c
index 56cdbd2..6090a13 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -952,6 +952,7 @@ DECL_HANDLER(get_thread_info)
         reply->creation_time.usec = thread->creation_time.tv_usec;
         reply->exit_time.sec      = thread->exit_time.tv_sec;
         reply->exit_time.usec     = thread->exit_time.tv_usec;
+        reply->last           = thread->process->running_threads == 1;
 
         release_object( thread );
     }
diff --git a/server/trace.c b/server/trace.c
index 5462276..8002714 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -772,6 +772,8 @@ static void dump_get_thread_info_reply( 
     fprintf( stderr, "," );
     fprintf( stderr, " exit_time=" );
     dump_abs_time( &req->exit_time );
+    fprintf( stderr, "," );
+    fprintf( stderr, " last=%d", req->last );
 }
 
 static void dump_set_thread_info_request( const struct set_thread_info_request *req )



More information about the wine-patches mailing list