ptos: thread: Bugcheck if root thread killed
Signed-off-by: Chloe M. <chloe@mensia.org>
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
#include <hal/thread.h>
|
#include <hal/thread.h>
|
||||||
#include <hal/prim.h>
|
#include <hal/prim.h>
|
||||||
#include <hal/kpcr.h>
|
#include <hal/kpcr.h>
|
||||||
|
#include <ke/bugcheck.h>
|
||||||
#include <ex/pool.h>
|
#include <ex/pool.h>
|
||||||
#include <atomic.h>
|
#include <atomic.h>
|
||||||
|
|
||||||
@@ -54,9 +55,22 @@ NO_RETURN VOID
|
|||||||
PsExitThread(ULONG ExitCode)
|
PsExitThread(ULONG ExitCode)
|
||||||
{
|
{
|
||||||
KPCR *Kpcr;
|
KPCR *Kpcr;
|
||||||
|
THREAD *CurrentThread;
|
||||||
|
PROCESS *CurrentProcess;
|
||||||
|
|
||||||
Kpcr = HalKpcrCurrent();
|
Kpcr = HalKpcrCurrent();
|
||||||
KeSchedEnqueue(&ReaperQueue, Kpcr->CurrentThread);
|
CurrentThread = Kpcr->CurrentThread;
|
||||||
|
CurrentProcess = CurrentThread->Parent;
|
||||||
|
|
||||||
|
/* Cannot kill the root thread */
|
||||||
|
if (CurrentThread->Tid == 1 && CurrentProcess->Pid == 1) {
|
||||||
|
KeBugCheck(
|
||||||
|
BUGCHECK_SYSTEMPROC_KILLED,
|
||||||
|
"crts.sys terminated\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
KeSchedEnqueue(&ReaperQueue, CurrentThread);
|
||||||
Kpcr->CurrentThread = NULL;
|
Kpcr->CurrentThread = NULL;
|
||||||
HalThreadYield();
|
HalThreadYield();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user