From 286fc7657774172f780f813aa25e6ee75e8fafed Mon Sep 17 00:00:00 2001 From: belliash Date: Sun, 26 Feb 2023 22:08:02 +0100 Subject: [PATCH] First attempt on SEH usage; currently this does not take an effect due to missing exception dispatcher --- xtoskrnl/ke/kthread.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/xtoskrnl/ke/kthread.c b/xtoskrnl/ke/kthread.c index ef5e3c5..c302632 100644 --- a/xtoskrnl/ke/kthread.c +++ b/xtoskrnl/ke/kthread.c @@ -124,8 +124,16 @@ KeInitializeThread(IN PKPROCESS Process, Thread->StackBase = Stack; Thread->StackLimit = Stack - KERNEL_STACK_SIZE; - /* Initialize thread context */ - KepInitializeThreadContext(Thread, SystemRoutine, StartRoutine, StartContext, Context); + __try + { + /* Initialize thread context */ + KepInitializeThreadContext(Thread, SystemRoutine, StartRoutine, StartContext, Context); + } + __except(EXCEPTION_EXECUTE_HANDLER) + { + /* Failed to initialize thread context */ + return STATUS_UNSUCCESSFUL; + } /* Mark thread as initialized and run it */ Thread->State = Initialized;