From 68e08d30657477fa1b0d108d54c382756d5fd6e1 Mon Sep 17 00:00:00 2001 From: Aiken Harris Date: Tue, 14 Jul 2026 23:00:49 +0200 Subject: [PATCH] Implement accessor for the currently executing executive thread --- xtoskrnl/includes/ps/thread.hh | 1 + xtoskrnl/ps/thread.cc | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/xtoskrnl/includes/ps/thread.hh b/xtoskrnl/includes/ps/thread.hh index dd3ff57..a6a0f2c 100644 --- a/xtoskrnl/includes/ps/thread.hh +++ b/xtoskrnl/includes/ps/thread.hh @@ -21,6 +21,7 @@ namespace PS STATIC XTAPI XTSTATUS CreateIdleThread(IN PKPROCESSOR_CONTROL_BLOCK Prcb, IN PVOID Stack); STATIC XTAPI VOID DeleteThread(IN PVOID ThreadObject); + STATIC XTAPI PETHREAD GetCurrentThread(VOID); }; } diff --git a/xtoskrnl/ps/thread.cc b/xtoskrnl/ps/thread.cc index 2e08821..2d93b52 100644 --- a/xtoskrnl/ps/thread.cc +++ b/xtoskrnl/ps/thread.cc @@ -78,3 +78,18 @@ PS::Thread::DeleteThread(IN PVOID ThreadObject) { UNIMPLEMENTED; } + +/** + * Retrieves a pointer to the currently executing executive thread object. + * + * @return This routine returns the address of the current executive thread object. + * + * @since XT 1.0 + */ +XTAPI +PETHREAD +PS::Thread::GetCurrentThread(VOID) +{ + /* Retrieve the active kernel thread and cast it to the executive thread */ + return (PETHREAD)KE::Processor::GetCurrentThread(); +}