Implement OpenThread() winapi call.
Implement a few pthreads functions.
diff --git a/server/protocol.def b/server/protocol.def
index 0cc3f26..a13fcc7 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -462,6 +462,16 @@
@END
+/* Open a handle to a thread */
+@REQ(open_thread)
+ void* tid; /* thread id to open */
+ unsigned int access; /* wanted access rights */
+ int inherit; /* inherit flag */
+@REPLY
+ handle_t handle; /* handle to the thread */
+@END
+
+
/* Wait for handles */
@REQ(select)
int flags; /* wait flags (see below) */
diff --git a/server/request.h b/server/request.h
index 7e3b507..99bba36 100644
--- a/server/request.h
+++ b/server/request.h
@@ -125,6 +125,7 @@
DECL_HANDLER(set_handle_info);
DECL_HANDLER(dup_handle);
DECL_HANDLER(open_process);
+DECL_HANDLER(open_thread);
DECL_HANDLER(select);
DECL_HANDLER(create_event);
DECL_HANDLER(event_op);
@@ -284,6 +285,7 @@
(req_handler)req_set_handle_info,
(req_handler)req_dup_handle,
(req_handler)req_open_process,
+ (req_handler)req_open_thread,
(req_handler)req_select,
(req_handler)req_create_event,
(req_handler)req_event_op,
diff --git a/server/thread.c b/server/thread.c
index eba63e1..cf5dcf8 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -854,6 +854,19 @@
}
}
+/* open a handle to a thread */
+DECL_HANDLER(open_thread)
+{
+ struct thread *thread = get_thread_from_id( req->tid );
+
+ reply->handle = 0;
+ if (thread)
+ {
+ reply->handle = alloc_handle( current->process, thread, req->access, req->inherit );
+ release_object( thread );
+ }
+}
+
/* fetch information about a thread */
DECL_HANDLER(get_thread_info)
{
diff --git a/server/trace.c b/server/trace.c
index a8844f1..cb2f19f 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -638,6 +638,18 @@
fprintf( stderr, " handle=%d", req->handle );
}
+static void dump_open_thread_request( const struct open_thread_request *req )
+{
+ fprintf( stderr, " tid=%p,", req->tid );
+ fprintf( stderr, " access=%08x,", req->access );
+ fprintf( stderr, " inherit=%d", req->inherit );
+}
+
+static void dump_open_thread_reply( const struct open_thread_reply *req )
+{
+ fprintf( stderr, " handle=%d", req->handle );
+}
+
static void dump_select_request( const struct select_request *req )
{
fprintf( stderr, " flags=%d,", req->flags );
@@ -2177,6 +2189,7 @@
(dump_func)dump_set_handle_info_request,
(dump_func)dump_dup_handle_request,
(dump_func)dump_open_process_request,
+ (dump_func)dump_open_thread_request,
(dump_func)dump_select_request,
(dump_func)dump_create_event_request,
(dump_func)dump_event_op_request,
@@ -2333,6 +2346,7 @@
(dump_func)dump_set_handle_info_reply,
(dump_func)dump_dup_handle_reply,
(dump_func)dump_open_process_reply,
+ (dump_func)dump_open_thread_reply,
(dump_func)0,
(dump_func)dump_create_event_reply,
(dump_func)0,
@@ -2489,6 +2503,7 @@
"set_handle_info",
"dup_handle",
"open_process",
+ "open_thread",
"select",
"create_event",
"event_op",