summaryrefslogtreecommitdiffhomepage
path: root/dev/ZKA/Sources/ThreadLocalStorage.cxx
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-08-24 17:30:52 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-08-24 17:30:52 +0200
commitfdc8aaab2ad3c2f2f3f4bb4ffb71bc2d797366aa (patch)
treeda3e628e1c4862c424a2deebae6966d6fc262592 /dev/ZKA/Sources/ThreadLocalStorage.cxx
parent30e5aa322bf253cdf48cddf53a1c8a1e9720e705 (diff)
[IMP] Better kernel design.
+ If the process has a parent, and it's exited, that means that the thread must go down as well. Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/ZKA/Sources/ThreadLocalStorage.cxx')
-rw-r--r--dev/ZKA/Sources/ThreadLocalStorage.cxx52
1 files changed, 40 insertions, 12 deletions
diff --git a/dev/ZKA/Sources/ThreadLocalStorage.cxx b/dev/ZKA/Sources/ThreadLocalStorage.cxx
index f258fa11..a29f153e 100644
--- a/dev/ZKA/Sources/ThreadLocalStorage.cxx
+++ b/dev/ZKA/Sources/ThreadLocalStorage.cxx
@@ -21,7 +21,41 @@
using namespace Kernel;
-Kernel::Property cTLSEnforceCheck;
+namespace Detail
+{
+ /// \brief Process thread information header.
+ struct THREAD_HEADER_BLOCK final
+ {
+ STATIC constexpr SizeT cMaxLen = 256;
+
+ Char fName[cMaxLen] = {"THREAD #0 (PROCESS 0)"};
+ ProcessStatus fThreadStatus;
+ Int64 fThreadID;
+ UIntPtr fCode{0};
+ UIntPtr fStack{0};
+ UIntPtr fData{0};
+
+ Void Exit() noexcept
+ {
+ this->fThreadStatus = ProcessStatus::kKilled;
+ }
+
+ UIntPtr GetStack() noexcept
+ {
+ return fStack;
+ }
+
+ UIntPtr GetData() noexcept
+ {
+ return fData;
+ }
+
+ UIntPtr GetPC() noexcept
+ {
+ return fCode;
+ }
+ };
+} // namespace Detail
/**
* @brief Checks for cookie inside the TIB.
@@ -31,7 +65,8 @@ Kernel::Property cTLSEnforceCheck;
Boolean tls_check_tib(THREAD_INFORMATION_BLOCK* the_tib)
{
- if (!the_tib)
+ if (!the_tib ||
+ !the_tib->f_ThreadRecord)
return false;
Encoder encoder;
@@ -45,22 +80,15 @@ Boolean tls_check_tib(THREAD_INFORMATION_BLOCK* the_tib)
/**
* @brief System call implementation of the TLS check.
- * @param stackPtr The call frame.
+ * @param tib_ptr The TIB record.
* @return
*/
EXTERN_C Bool tls_check_syscall_impl(Kernel::VoidPtr tib_ptr) noexcept
{
if (!tib_ptr)
{
- if (cTLSEnforceCheck.GetValue() == No)
- {
- return true;
- }
- else
- {
- kcout << "newoskrnl: failing because of an invalid TIB...\r";
- return false;
- }
+ kcout << "newoskrnl: failing because of an invalid TIB...\r";
+ return false;
}
THREAD_INFORMATION_BLOCK* tib_struct = (THREAD_INFORMATION_BLOCK*)tib_ptr;