Signed-off-by: Derek Lesho dereklesho52@Gmail.com --- dlls/ntoskrnl.exe/ntoskrnl.c | 13 ++++++++ dlls/ntoskrnl.exe/ntoskrnl_private.h | 4 +++ server/thread.c | 46 ++++++++++++++++------------ server/thread.h | 1 + 4 files changed, 45 insertions(+), 19 deletions(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c index 77a610d7db..fd75cdc886 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/ntoskrnl.c @@ -2484,15 +2484,28 @@ PEPROCESS WINAPI IoGetCurrentProcess(void) }
+static void *create_thread_object( HANDLE handle ); + static const WCHAR thread_type_name[] = {'T','h','r','e','a','d',0};
static struct _OBJECT_TYPE thread_type = { thread_type_name, + create_thread_object };
POBJECT_TYPE PsThreadType = &thread_type;
+static void *create_thread_object( HANDLE handle ) +{ + PETHREAD thread; + + if (!(thread = alloc_kernel_object( PsThreadType, handle, sizeof(*thread), 0 ))) return NULL; + + thread->Header.WaitListHead.Blink = INVALID_HANDLE_VALUE; + return thread; +} +
/*********************************************************************** * KeGetCurrentThread / PsGetCurrentThread (NTOSKRNL.EXE.@) diff --git a/dlls/ntoskrnl.exe/ntoskrnl_private.h b/dlls/ntoskrnl.exe/ntoskrnl_private.h index 82ee18e56a..700738adc3 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl_private.h +++ b/dlls/ntoskrnl.exe/ntoskrnl_private.h @@ -40,6 +40,10 @@ extern POBJECT_TYPE PsThreadType; extern POBJECT_TYPE SeTokenObjectType;
+struct _ETHREAD { + DISPATCHER_HEADER Header; +}; + #ifdef __i386__ #define DEFINE_FASTCALL1_WRAPPER(func) \ __ASM_STDCALL_FUNC( __fastcall_ ## func, 4, \ diff --git a/server/thread.c b/server/thread.c index f5f98ebef1..b524c64452 100644 --- a/server/thread.c +++ b/server/thread.c @@ -134,28 +134,29 @@ static int thread_signaled( struct object *obj, struct wait_queue_entry *entry ) static unsigned int thread_map_access( struct object *obj, unsigned int access ); static void thread_poll_event( struct fd *fd, int event ); static void destroy_thread( struct object *obj ); +static struct list *thread_get_kernel_object_list( struct object *obj );
static const struct object_ops thread_ops = { - sizeof(struct thread), /* size */ - dump_thread, /* dump */ - thread_get_type, /* get_type */ - add_queue, /* add_queue */ - remove_queue, /* remove_queue */ - thread_signaled, /* signaled */ - no_satisfied, /* satisfied */ - no_signal, /* signal */ - no_get_fd, /* get_fd */ - thread_map_access, /* map_access */ - default_get_sd, /* get_sd */ - default_set_sd, /* set_sd */ - no_lookup_name, /* lookup_name */ - no_link_name, /* link_name */ - NULL, /* unlink_name */ - no_open_file, /* open_file */ - no_kernel_obj_list, /* get_kernel_obj_list */ - no_close_handle, /* close_handle */ - destroy_thread /* destroy */ + sizeof(struct thread), /* size */ + dump_thread, /* dump */ + thread_get_type, /* get_type */ + add_queue, /* add_queue */ + remove_queue, /* remove_queue */ + thread_signaled, /* signaled */ + no_satisfied, /* satisfied */ + no_signal, /* signal */ + no_get_fd, /* get_fd */ + thread_map_access, /* map_access */ + default_get_sd, /* get_sd */ + default_set_sd, /* set_sd */ + no_lookup_name, /* lookup_name */ + no_link_name, /* link_name */ + NULL, /* unlink_name */ + no_open_file, /* open_file */ + thread_get_kernel_object_list, /* get_kernel_obj_list */ + no_close_handle, /* close_handle */ + destroy_thread /* destroy */ };
static const struct fd_ops thread_fd_ops = @@ -206,6 +207,7 @@ static inline void init_thread_structure( struct thread *thread ) thread->creation_time = current_time; thread->exit_time = 0;
+ list_init( &thread->kernel_object ); list_init( &thread->mutex_list ); list_init( &thread->system_apc ); list_init( &thread->user_apc ); @@ -391,6 +393,12 @@ static unsigned int thread_map_access( struct object *obj, unsigned int access ) return access & ~(GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | GENERIC_ALL); }
+static struct list *thread_get_kernel_object_list( struct object *obj ) +{ + struct thread *thread = (struct thread *)obj; + return &thread->kernel_object; +} + static void dump_thread_apc( struct object *obj, int verbose ) { struct thread_apc *apc = (struct thread_apc *)obj; diff --git a/server/thread.h b/server/thread.h index e4332df4ab..758bbf7c8c 100644 --- a/server/thread.h +++ b/server/thread.h @@ -49,6 +49,7 @@ struct inflight_fd struct thread { struct object obj; /* object header */ + struct list kernel_object; /* list of kernel object pointers */ struct list entry; /* entry in system-wide thread list */ struct list proc_entry; /* entry in per-process thread list */ struct process *process;