#include <internal/string.h>
#include <internal/hal.h>
#include <internal/ps.h>
+#include <internal/ob.h>
#define NDEBUG
#include <internal/debug.h>
static PETHREAD CurrentThread = NULL;
-static ULONG NextThreadUniqueId = 0;
-//static ULONG NextProcessUniqueId = 0;
+static ULONG NextUniqueThreadId = 0;
/* FUNCTIONS ***************************************************************/
PETHREAD PsGetCurrentThread(VOID)
{
- return((PETHREAD)KeGetCurrentThread());
+ return(CurrentThread);
}
VOID PiTerminateProcessThreads(PEPROCESS Process, NTSTATUS ExitStatus)
KeReleaseSpinLock(&ThreadListLock,PASSIVE_LEVEL);
Ret = StartRoutine(StartContext);
PsTerminateSystemThread(Ret);
- for(;;);
+ KeBugCheck(0);
}
static PETHREAD PsScanThreadList(KPRIORITY Priority)
{
DPRINT("Scheduling current thread\n");
KeQueryTickCount(&TickCount);
- CurrentThread->Tcb.LastTick = GET_LARGE_INTEGER_LOW_PART(TickCount);
+ CurrentThread->Tcb.LastTick = TickCount.LowPart;
CurrentThread->Tcb.ThreadState = THREAD_STATE_RUNNING;
KeReleaseSpinLock(&ThreadListLock,irql);
return;
Candidate->Tcb.ThreadState = THREAD_STATE_RUNNING;
KeQueryTickCount(&TickCount);
- CurrentThread->Tcb.LastTick = GET_LARGE_INTEGER_LOW_PART(TickCount);
+ CurrentThread->Tcb.LastTick = TickCount.LowPart;
CurrentThread = Candidate;
Thread->Tcb.CurrentPriority=THREAD_PRIORITY_NORMAL;
Thread->Tcb.ApcList=ExAllocatePool(NonPagedPool,sizeof(LIST_ENTRY));
Thread->Tcb.SuspendCount = 1;
- if (ProcessHandle!=NULL)
+ if (ProcessHandle != NULL)
{
Status = ObReferenceObjectByHandle(ProcessHandle,
PROCESS_CREATE_THREAD,
}
else
{
- Thread->ThreadsProcess=SystemProcess;
+ Thread->ThreadsProcess = SystemProcess;
ObReferenceObjectByPointer(Thread->ThreadsProcess,
PROCESS_CREATE_THREAD,
PsProcessType,
InitializeListHead(Thread->Tcb.ApcList);
InitializeListHead(&(Thread->IrpList));
Thread->Cid.UniqueThread = (HANDLE)InterlockedIncrement(
- &NextThreadUniqueId);
- DbgPrint("Thread->Cid.UniqueThread %d\n",Thread->Cid.UniqueThread);
+ &NextUniqueThreadId);
+ Thread->Cid.UniqueProcess = (HANDLE)Thread->ThreadsProcess->UniqueProcessId;
+ DbgPrint("Thread->Cid.UniqueThread %d\nThread->Cid.UniqueProcess %d\n",
+ Thread->Cid.UniqueThread, Thread->Cid.UniqueThread);
ObReferenceObjectByPointer(Thread,
THREAD_ALL_ACCESS,
PsThreadType,
*ThreadPtr = Thread;
- ObDereferenceObject(Thread->ThreadsProcess);
+ ObDereferenceObject(Thread->ThreadsProcess);
return(STATUS_SUCCESS);
}
}
}
-void PsInitThreadManagment(void)
+VOID PiDeleteThread(PVOID ObjectBody)
+{
+ DbgPrint("PiDeleteThread(ObjectBody %x)\n",ObjectBody);
+}
+
+VOID PsInitThreadManagment(VOID)
/*
* FUNCTION: Initialize thread managment
*/
PsThreadType->Dump = NULL;
PsThreadType->Open = NULL;
PsThreadType->Close = NULL;
- PsThreadType->Delete = NULL;
+ PsThreadType->Delete = PiDeleteThread;
PsThreadType->Parse = NULL;
PsThreadType->Security = NULL;
PsThreadType->QueryName = NULL;