mirror of
https://github.com/reactos/reactos.git
synced 2025-07-28 01:41:48 +00:00
Screw branches, I'm committing to HEAD. Life is too short
svn path=/trunk/; revision=7320
This commit is contained in:
parent
699d3efcd8
commit
c8f27683f0
6 changed files with 84 additions and 145 deletions
|
@ -1,4 +1,4 @@
|
||||||
# $Id: makefile,v 1.71 2003/09/20 23:37:56 weiden Exp $
|
# $Id: makefile,v 1.72 2003/12/30 00:12:47 hyperion Exp $
|
||||||
|
|
||||||
PATH_TO_TOP = ../..
|
PATH_TO_TOP = ../..
|
||||||
|
|
||||||
|
@ -51,7 +51,8 @@ THREAD_OBJECTS = \
|
||||||
thread/fls.o
|
thread/fls.o
|
||||||
|
|
||||||
THREAD_I386_OBJECTS = \
|
THREAD_I386_OBJECTS = \
|
||||||
thread/i386/fiber.o
|
thread/i386/fiber.o \
|
||||||
|
thread/i386/exit.o
|
||||||
|
|
||||||
PROCESS_OBJECTS = \
|
PROCESS_OBJECTS = \
|
||||||
process/proc.o \
|
process/proc.o \
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: thread.c,v 1.45 2003/09/12 17:51:47 vizzini Exp $
|
/* $Id: thread.c,v 1.46 2003/12/30 00:12:47 hyperion Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Tls functions are modified from WINE
|
* Tls functions are modified from WINE
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* Created 01/11/98
|
* Created 01/11/98
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES ******************************************************************/
|
/* INCLUDES ******************************************************************/
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: ps.h,v 1.55 2003/12/14 18:02:34 hbirr Exp $
|
/* $Id: ps.h,v 1.56 2003/12/30 00:12:47 hyperion Exp $
|
||||||
*
|
*
|
||||||
* FILE: ntoskrnl/ke/kthread.c
|
* FILE: ntoskrnl/ke/kthread.c
|
||||||
* PURPOSE: Process manager definitions
|
* PURPOSE: Process manager definitions
|
||||||
|
@ -543,6 +543,14 @@ PsTerminateWin32Thread (PETHREAD Thread);
|
||||||
VOID
|
VOID
|
||||||
PsInitialiseW32Call(VOID);
|
PsInitialiseW32Call(VOID);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
STDCALL
|
||||||
|
PspRunCreateThreadNotifyRoutines(PETHREAD, BOOLEAN);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
STDCALL
|
||||||
|
PspRunCreateProcessNotifyRoutines(PEPROCESS, BOOLEAN);
|
||||||
|
|
||||||
#endif /* ASSEMBLER */
|
#endif /* ASSEMBLER */
|
||||||
|
|
||||||
#endif /* __INCLUDE_INTERNAL_PS_H */
|
#endif /* __INCLUDE_INTERNAL_PS_H */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: create.c,v 1.67 2003/09/25 20:08:36 ekohl Exp $
|
/* $Id: create.c,v 1.68 2003/12/30 00:12:47 hyperion Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -288,38 +288,19 @@ PiDeleteThread(PVOID ObjectBody)
|
||||||
{
|
{
|
||||||
KIRQL oldIrql;
|
KIRQL oldIrql;
|
||||||
PETHREAD Thread;
|
PETHREAD Thread;
|
||||||
ULONG i;
|
|
||||||
PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine[MAX_THREAD_NOTIFY_ROUTINE_COUNT];
|
|
||||||
ULONG NotifyRoutineCount;
|
|
||||||
|
|
||||||
Thread = (PETHREAD)ObjectBody;
|
Thread = (PETHREAD)ObjectBody;
|
||||||
|
|
||||||
DPRINT("PiDeleteThread(ObjectBody %x)\n",ObjectBody);
|
DPRINT("PiDeleteThread(ObjectBody %x)\n",ObjectBody);
|
||||||
|
|
||||||
/* Terminate Win32 thread */
|
|
||||||
PsTerminateWin32Thread (Thread);
|
|
||||||
|
|
||||||
ObDereferenceObject(Thread->ThreadsProcess);
|
ObDereferenceObject(Thread->ThreadsProcess);
|
||||||
Thread->ThreadsProcess = NULL;
|
Thread->ThreadsProcess = NULL;
|
||||||
|
|
||||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
||||||
for (i = 0; i < PiThreadNotifyRoutineCount; i++)
|
|
||||||
{
|
|
||||||
NotifyRoutine[i] = PiThreadNotifyRoutine[i];
|
|
||||||
}
|
|
||||||
NotifyRoutineCount = PiThreadNotifyRoutineCount;
|
|
||||||
PiNrThreads--;
|
PiNrThreads--;
|
||||||
RemoveEntryList(&Thread->Tcb.ThreadListEntry);
|
RemoveEntryList(&Thread->Tcb.ThreadListEntry);
|
||||||
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
||||||
|
|
||||||
for (i = 0; i < NotifyRoutineCount; i++)
|
|
||||||
{
|
|
||||||
//must be called below DISPATCH_LVL
|
|
||||||
NotifyRoutine[i](Thread->Cid.UniqueProcess,
|
|
||||||
Thread->Cid.UniqueThread,
|
|
||||||
FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
KeReleaseThread(Thread);
|
KeReleaseThread(Thread);
|
||||||
DPRINT("PiDeleteThread() finished\n");
|
DPRINT("PiDeleteThread() finished\n");
|
||||||
}
|
}
|
||||||
|
@ -336,9 +317,6 @@ PsInitializeThread(HANDLE ProcessHandle,
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
KIRQL oldIrql;
|
KIRQL oldIrql;
|
||||||
PEPROCESS Process;
|
PEPROCESS Process;
|
||||||
ULONG i;
|
|
||||||
ULONG NotifyRoutineCount;
|
|
||||||
PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine[MAX_THREAD_NOTIFY_ROUTINE_COUNT];
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reference process
|
* Reference process
|
||||||
|
@ -421,24 +399,11 @@ PsInitializeThread(HANDLE ProcessHandle,
|
||||||
|
|
||||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
||||||
InsertTailList(&PiThreadListHead, &Thread->Tcb.ThreadListEntry);
|
InsertTailList(&PiThreadListHead, &Thread->Tcb.ThreadListEntry);
|
||||||
for (i = 0; i < PiThreadNotifyRoutineCount; i++)
|
|
||||||
{
|
|
||||||
NotifyRoutine[i] = PiThreadNotifyRoutine[i];
|
|
||||||
}
|
|
||||||
NotifyRoutineCount = PiThreadNotifyRoutineCount;
|
|
||||||
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
||||||
|
|
||||||
Thread->Tcb.BasePriority = Thread->ThreadsProcess->Pcb.BasePriority;
|
Thread->Tcb.BasePriority = Thread->ThreadsProcess->Pcb.BasePriority;
|
||||||
Thread->Tcb.Priority = Thread->Tcb.BasePriority;
|
Thread->Tcb.Priority = Thread->Tcb.BasePriority;
|
||||||
|
|
||||||
for (i = 0; i < NotifyRoutineCount; i++)
|
|
||||||
{
|
|
||||||
//must be called below DISPATCH_LVL
|
|
||||||
NotifyRoutine[i](Thread->Cid.UniqueProcess,
|
|
||||||
Thread->Cid.UniqueThread,
|
|
||||||
TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -735,6 +700,20 @@ PsCreateSystemThread(PHANDLE ThreadHandle,
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
STDCALL
|
||||||
|
PspRunCreateThreadNotifyRoutines
|
||||||
|
(
|
||||||
|
PETHREAD CurrentThread,
|
||||||
|
BOOLEAN Create
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ULONG i;
|
||||||
|
CLIENT_ID Cid = CurrentThread->Cid;
|
||||||
|
|
||||||
|
for(i = 0; i < PiThreadNotifyRoutineCount; ++ i)
|
||||||
|
PiThreadNotifyRoutine[i](Cid.UniqueProcess, Cid.UniqueThread, Create);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
|
@ -742,18 +721,13 @@ PsCreateSystemThread(PHANDLE ThreadHandle,
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
PsSetCreateThreadNotifyRoutine(IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine)
|
PsSetCreateThreadNotifyRoutine(IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine)
|
||||||
{
|
{
|
||||||
KIRQL oldIrql;
|
if (PiThreadNotifyRoutineCount >= MAX_THREAD_NOTIFY_ROUTINE_COUNT)
|
||||||
|
|
||||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
|
||||||
if (PiThreadNotifyRoutineCount >= MAX_THREAD_NOTIFY_ROUTINE_COUNT)
|
|
||||||
{
|
{
|
||||||
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
|
||||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
return(STATUS_INSUFFICIENT_RESOURCES);
|
||||||
}
|
}
|
||||||
|
|
||||||
PiThreadNotifyRoutine[PiThreadNotifyRoutineCount] = NotifyRoutine;
|
PiThreadNotifyRoutine[PiThreadNotifyRoutineCount] = NotifyRoutine;
|
||||||
PiThreadNotifyRoutineCount++;
|
PiThreadNotifyRoutineCount++;
|
||||||
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: kill.c,v 1.67 2003/11/02 03:09:06 ekohl Exp $
|
/* $Id: kill.c,v 1.68 2003/12/30 00:12:47 hyperion Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -95,52 +95,18 @@ PsReapThreads(VOID)
|
||||||
|
|
||||||
if (current->Tcb.State == THREAD_STATE_TERMINATED_1)
|
if (current->Tcb.State == THREAD_STATE_TERMINATED_1)
|
||||||
{
|
{
|
||||||
PEPROCESS Process = current->ThreadsProcess;
|
|
||||||
NTSTATUS Status = current->ExitStatus;
|
|
||||||
BOOLEAN Last;
|
|
||||||
|
|
||||||
PiNrThreadsAwaitingReaping--;
|
PiNrThreadsAwaitingReaping--;
|
||||||
current->Tcb.State = THREAD_STATE_TERMINATED_2;
|
current->Tcb.State = THREAD_STATE_TERMINATED_2;
|
||||||
RemoveEntryList(¤t->Tcb.ProcessThreadListEntry);
|
|
||||||
Last = IsListEmpty(&Process->ThreadListHead);
|
/*
|
||||||
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
An unbelievably complex chain of events would cause a system crash
|
||||||
|
if PiThreadListLock was still held when the thread object is about
|
||||||
if (Last)
|
to be destroyed
|
||||||
{
|
*/
|
||||||
PiTerminateProcess(Process, Status);
|
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (current->Tcb.Teb)
|
|
||||||
{
|
|
||||||
/* If this is not the last thread for the process then free the memory
|
|
||||||
from user stack and teb. */
|
|
||||||
NTSTATUS Status;
|
|
||||||
ULONG Length;
|
|
||||||
ULONG Offset;
|
|
||||||
PVOID DeallocationStack;
|
|
||||||
HANDLE ProcessHandle;
|
|
||||||
Status = ObCreateHandle(PsGetCurrentProcess(), Process, PROCESS_ALL_ACCESS, FALSE, &ProcessHandle);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT1("ObCreateHandle failed, status = %x\n", Status);
|
|
||||||
KEBUGCHECK(0);
|
|
||||||
}
|
|
||||||
Offset = FIELD_OFFSET(TEB, DeallocationStack);
|
|
||||||
Length = 0;
|
|
||||||
NtReadVirtualMemory(ProcessHandle, (PVOID)current->Tcb.Teb + Offset,
|
|
||||||
(PVOID)&DeallocationStack, sizeof(PVOID), &Length);
|
|
||||||
if (DeallocationStack && Length == sizeof(PVOID))
|
|
||||||
{
|
|
||||||
NtFreeVirtualMemory(ProcessHandle, &DeallocationStack, &Length, MEM_RELEASE);
|
|
||||||
}
|
|
||||||
Length = PAGE_SIZE;
|
|
||||||
NtFreeVirtualMemory(ProcessHandle, (PVOID*)¤t->Tcb.Teb, &Length, MEM_RELEASE);
|
|
||||||
NtClose(ProcessHandle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ObDereferenceObject(current);
|
ObDereferenceObject(current);
|
||||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
||||||
|
|
||||||
current_entry = PiThreadListHead.Flink;
|
current_entry = PiThreadListHead.Flink;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -155,23 +121,35 @@ PsTerminateCurrentThread(NTSTATUS ExitStatus)
|
||||||
{
|
{
|
||||||
KIRQL oldIrql;
|
KIRQL oldIrql;
|
||||||
PETHREAD CurrentThread;
|
PETHREAD CurrentThread;
|
||||||
PKTHREAD Thread;
|
|
||||||
PLIST_ENTRY current_entry;
|
PLIST_ENTRY current_entry;
|
||||||
PKMUTANT Mutant;
|
PKMUTANT Mutant;
|
||||||
|
BOOLEAN Last;
|
||||||
|
PEPROCESS CurrentProcess;
|
||||||
|
|
||||||
|
KeLowerIrql(PASSIVE_LEVEL);
|
||||||
|
|
||||||
|
CurrentThread = PsGetCurrentThread();
|
||||||
|
CurrentProcess = CurrentThread->ThreadsProcess;
|
||||||
|
|
||||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
||||||
|
|
||||||
CurrentThread = PsGetCurrentThread();
|
|
||||||
DPRINT("terminating %x\n",CurrentThread);
|
DPRINT("terminating %x\n",CurrentThread);
|
||||||
|
|
||||||
CurrentThread->ExitStatus = ExitStatus;
|
CurrentThread->ExitStatus = ExitStatus;
|
||||||
Thread = KeGetCurrentThread();
|
KeCancelTimer(&CurrentThread->Tcb.Timer);
|
||||||
KeCancelTimer(&Thread->Timer);
|
|
||||||
|
/* Remove the thread from the thread list of its process */
|
||||||
|
RemoveEntryList(&CurrentThread->Tcb.ProcessThreadListEntry);
|
||||||
|
Last = IsListEmpty(&CurrentProcess->ThreadListHead);
|
||||||
|
|
||||||
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
||||||
|
|
||||||
|
PspRunCreateThreadNotifyRoutines(CurrentThread, FALSE);
|
||||||
|
PsTerminateWin32Thread(CurrentThread);
|
||||||
|
|
||||||
/* abandon all owned mutants */
|
/* abandon all owned mutants */
|
||||||
current_entry = Thread->MutantListHead.Flink;
|
current_entry = CurrentThread->Tcb.MutantListHead.Flink;
|
||||||
while (current_entry != &Thread->MutantListHead)
|
while (current_entry != &CurrentThread->Tcb.MutantListHead)
|
||||||
{
|
{
|
||||||
Mutant = CONTAINING_RECORD(current_entry, KMUTANT,
|
Mutant = CONTAINING_RECORD(current_entry, KMUTANT,
|
||||||
MutantListEntry);
|
MutantListEntry);
|
||||||
|
@ -179,7 +157,7 @@ PsTerminateCurrentThread(NTSTATUS ExitStatus)
|
||||||
MUTANT_INCREMENT,
|
MUTANT_INCREMENT,
|
||||||
TRUE,
|
TRUE,
|
||||||
FALSE);
|
FALSE);
|
||||||
current_entry = Thread->MutantListHead.Flink;
|
current_entry = CurrentThread->Tcb.MutantListHead.Flink;
|
||||||
}
|
}
|
||||||
|
|
||||||
oldIrql = KeAcquireDispatcherDatabaseLock();
|
oldIrql = KeAcquireDispatcherDatabaseLock();
|
||||||
|
@ -187,6 +165,14 @@ PsTerminateCurrentThread(NTSTATUS ExitStatus)
|
||||||
KeDispatcherObjectWake(&CurrentThread->Tcb.DispatcherHeader);
|
KeDispatcherObjectWake(&CurrentThread->Tcb.DispatcherHeader);
|
||||||
KeReleaseDispatcherDatabaseLock (oldIrql);
|
KeReleaseDispatcherDatabaseLock (oldIrql);
|
||||||
|
|
||||||
|
/* The last thread shall close the door on exit */
|
||||||
|
if(Last)
|
||||||
|
{
|
||||||
|
PspRunCreateProcessNotifyRoutines(CurrentProcess, FALSE);
|
||||||
|
PsTerminateWin32Process(CurrentProcess);
|
||||||
|
PiTerminateProcess(CurrentProcess, ExitStatus);
|
||||||
|
}
|
||||||
|
|
||||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
||||||
|
|
||||||
ExpSwapThreadEventPair(CurrentThread, NULL); /* Release the associated eventpair object, if there was one */
|
ExpSwapThreadEventPair(CurrentThread, NULL); /* Release the associated eventpair object, if there was one */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: process.c,v 1.120 2003/11/17 02:12:51 hyperion Exp $
|
/* $Id: process.c,v 1.121 2003/12/30 00:12:47 hyperion Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -329,9 +329,6 @@ VOID STDCALL
|
||||||
PiDeleteProcessWorker(PVOID pContext)
|
PiDeleteProcessWorker(PVOID pContext)
|
||||||
{
|
{
|
||||||
KIRQL oldIrql;
|
KIRQL oldIrql;
|
||||||
ULONG i;
|
|
||||||
PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine[MAX_PROCESS_NOTIFY_ROUTINE_COUNT];
|
|
||||||
ULONG NotifyRoutineCount;
|
|
||||||
PDEL_CONTEXT Context;
|
PDEL_CONTEXT Context;
|
||||||
PEPROCESS CurrentProcess;
|
PEPROCESS CurrentProcess;
|
||||||
PEPROCESS Process;
|
PEPROCESS Process;
|
||||||
|
@ -347,29 +344,10 @@ PiDeleteProcessWorker(PVOID pContext)
|
||||||
KeAttachProcess(Process);
|
KeAttachProcess(Process);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Terminate Win32 Process */
|
|
||||||
PsTerminateWin32Process (Process);
|
|
||||||
|
|
||||||
KeAcquireSpinLock(&PsProcessListLock, &oldIrql);
|
KeAcquireSpinLock(&PsProcessListLock, &oldIrql);
|
||||||
NotifyRoutineCount = 0;
|
|
||||||
for (i = 0; i < MAX_PROCESS_NOTIFY_ROUTINE_COUNT; i++)
|
|
||||||
{
|
|
||||||
if (PiProcessNotifyRoutine[i])
|
|
||||||
{
|
|
||||||
NotifyRoutine[NotifyRoutineCount++] = PiProcessNotifyRoutine[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
RemoveEntryList(&Process->ProcessListEntry);
|
RemoveEntryList(&Process->ProcessListEntry);
|
||||||
KeReleaseSpinLock(&PsProcessListLock, oldIrql);
|
KeReleaseSpinLock(&PsProcessListLock, oldIrql);
|
||||||
|
|
||||||
for (i = 0;i < NotifyRoutineCount; i++)
|
|
||||||
{
|
|
||||||
/* must be called below DISPATCH_LVL */
|
|
||||||
NotifyRoutine[i](Process->InheritedFromUniqueProcessId,
|
|
||||||
(HANDLE)Process->UniqueProcessId,
|
|
||||||
FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* KDB hook */
|
/* KDB hook */
|
||||||
KDB_DELETEPROCESS_HOOK(Process);
|
KDB_DELETEPROCESS_HOOK(Process);
|
||||||
|
|
||||||
|
@ -586,9 +564,6 @@ NtCreateProcess(OUT PHANDLE ProcessHandle,
|
||||||
PEPORT ExceptionPort;
|
PEPORT ExceptionPort;
|
||||||
PVOID BaseAddress;
|
PVOID BaseAddress;
|
||||||
PMEMORY_AREA MemoryArea;
|
PMEMORY_AREA MemoryArea;
|
||||||
ULONG i;
|
|
||||||
PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine[MAX_PROCESS_NOTIFY_ROUTINE_COUNT];
|
|
||||||
ULONG NotifyRoutineCount;
|
|
||||||
|
|
||||||
DPRINT("NtCreateProcess(ObjectAttributes %x)\n",ObjectAttributes);
|
DPRINT("NtCreateProcess(ObjectAttributes %x)\n",ObjectAttributes);
|
||||||
|
|
||||||
|
@ -696,26 +671,10 @@ NtCreateProcess(OUT PHANDLE ProcessHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
KeAcquireSpinLock(&PsProcessListLock, &oldIrql);
|
KeAcquireSpinLock(&PsProcessListLock, &oldIrql);
|
||||||
NotifyRoutineCount = 0;
|
|
||||||
for (i = 0; i < MAX_PROCESS_NOTIFY_ROUTINE_COUNT; i++)
|
|
||||||
{
|
|
||||||
if (PiProcessNotifyRoutine[i])
|
|
||||||
{
|
|
||||||
NotifyRoutine[NotifyRoutineCount++] = PiProcessNotifyRoutine[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
InsertHeadList(&PsProcessListHead, &Process->ProcessListEntry);
|
InsertHeadList(&PsProcessListHead, &Process->ProcessListEntry);
|
||||||
InitializeListHead(&Process->ThreadListHead);
|
InitializeListHead(&Process->ThreadListHead);
|
||||||
KeReleaseSpinLock(&PsProcessListLock, oldIrql);
|
KeReleaseSpinLock(&PsProcessListLock, oldIrql);
|
||||||
|
|
||||||
for (i = 0;i < NotifyRoutineCount; i++)
|
|
||||||
{
|
|
||||||
//must be called below DISPATCH_LVL
|
|
||||||
NotifyRoutine[i](Process->InheritedFromUniqueProcessId,
|
|
||||||
(HANDLE)Process->UniqueProcessId,
|
|
||||||
TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
Process->Pcb.State = PROCESS_STATE_ACTIVE;
|
Process->Pcb.State = PROCESS_STATE_ACTIVE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1581,6 +1540,22 @@ PsLookupProcessByProcessId(IN PVOID ProcessId,
|
||||||
return(STATUS_INVALID_PARAMETER);
|
return(STATUS_INVALID_PARAMETER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
STDCALL
|
||||||
|
PspRunCreateProcessNotifyRoutines
|
||||||
|
(
|
||||||
|
PEPROCESS CurrentProcess,
|
||||||
|
BOOLEAN Create
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ULONG i;
|
||||||
|
HANDLE ProcessId = (HANDLE)CurrentProcess->UniqueProcessId;
|
||||||
|
HANDLE ParentId = CurrentProcess->InheritedFromUniqueProcessId;
|
||||||
|
|
||||||
|
for(i = 0; i < MAX_PROCESS_NOTIFY_ROUTINE_COUNT; ++ i)
|
||||||
|
if(PiProcessNotifyRoutine[i])
|
||||||
|
PiProcessNotifyRoutine[i](ParentId, ProcessId, Create);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
|
@ -1589,11 +1564,8 @@ NTSTATUS STDCALL
|
||||||
PsSetCreateProcessNotifyRoutine(IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine,
|
PsSetCreateProcessNotifyRoutine(IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine,
|
||||||
IN BOOLEAN Remove)
|
IN BOOLEAN Remove)
|
||||||
{
|
{
|
||||||
KIRQL oldIrql;
|
|
||||||
ULONG i;
|
ULONG i;
|
||||||
|
|
||||||
KeAcquireSpinLock(&PsProcessListLock, &oldIrql);
|
|
||||||
|
|
||||||
if (Remove)
|
if (Remove)
|
||||||
{
|
{
|
||||||
for(i=0;i<MAX_PROCESS_NOTIFY_ROUTINE_COUNT;i++)
|
for(i=0;i<MAX_PROCESS_NOTIFY_ROUTINE_COUNT;i++)
|
||||||
|
@ -1605,7 +1577,6 @@ PsSetCreateProcessNotifyRoutine(IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KeReleaseSpinLock(&PsProcessListLock, oldIrql);
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1619,8 +1590,6 @@ PsSetCreateProcessNotifyRoutine(IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KeReleaseSpinLock(&PsProcessListLock, oldIrql);
|
|
||||||
|
|
||||||
if (i == MAX_PROCESS_NOTIFY_ROUTINE_COUNT)
|
if (i == MAX_PROCESS_NOTIFY_ROUTINE_COUNT)
|
||||||
{
|
{
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue