mirror of
https://github.com/reactos/reactos.git
synced 2024-09-28 21:44:31 +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
|
@ -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 = ../..
|
||||
|
||||
|
@ -51,7 +51,8 @@ THREAD_OBJECTS = \
|
|||
thread/fls.o
|
||||
|
||||
THREAD_I386_OBJECTS = \
|
||||
thread/i386/fiber.o
|
||||
thread/i386/fiber.o \
|
||||
thread/i386/exit.o
|
||||
|
||||
PROCESS_OBJECTS = \
|
||||
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
|
||||
* PROJECT: ReactOS system libraries
|
||||
|
@ -8,6 +8,7 @@
|
|||
* Tls functions are modified from WINE
|
||||
* UPDATE HISTORY:
|
||||
* Created 01/11/98
|
||||
*
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* 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
|
||||
* PURPOSE: Process manager definitions
|
||||
|
@ -543,6 +543,14 @@ PsTerminateWin32Thread (PETHREAD Thread);
|
|||
VOID
|
||||
PsInitialiseW32Call(VOID);
|
||||
|
||||
VOID
|
||||
STDCALL
|
||||
PspRunCreateThreadNotifyRoutines(PETHREAD, BOOLEAN);
|
||||
|
||||
VOID
|
||||
STDCALL
|
||||
PspRunCreateProcessNotifyRoutines(PEPROCESS, BOOLEAN);
|
||||
|
||||
#endif /* ASSEMBLER */
|
||||
|
||||
#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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -288,38 +288,19 @@ PiDeleteThread(PVOID ObjectBody)
|
|||
{
|
||||
KIRQL oldIrql;
|
||||
PETHREAD Thread;
|
||||
ULONG i;
|
||||
PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine[MAX_THREAD_NOTIFY_ROUTINE_COUNT];
|
||||
ULONG NotifyRoutineCount;
|
||||
|
||||
Thread = (PETHREAD)ObjectBody;
|
||||
|
||||
DPRINT("PiDeleteThread(ObjectBody %x)\n",ObjectBody);
|
||||
|
||||
/* Terminate Win32 thread */
|
||||
PsTerminateWin32Thread (Thread);
|
||||
|
||||
ObDereferenceObject(Thread->ThreadsProcess);
|
||||
Thread->ThreadsProcess = NULL;
|
||||
|
||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
||||
for (i = 0; i < PiThreadNotifyRoutineCount; i++)
|
||||
{
|
||||
NotifyRoutine[i] = PiThreadNotifyRoutine[i];
|
||||
}
|
||||
NotifyRoutineCount = PiThreadNotifyRoutineCount;
|
||||
PiNrThreads--;
|
||||
RemoveEntryList(&Thread->Tcb.ThreadListEntry);
|
||||
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);
|
||||
DPRINT("PiDeleteThread() finished\n");
|
||||
}
|
||||
|
@ -336,9 +317,6 @@ PsInitializeThread(HANDLE ProcessHandle,
|
|||
NTSTATUS Status;
|
||||
KIRQL oldIrql;
|
||||
PEPROCESS Process;
|
||||
ULONG i;
|
||||
ULONG NotifyRoutineCount;
|
||||
PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine[MAX_THREAD_NOTIFY_ROUTINE_COUNT];
|
||||
|
||||
/*
|
||||
* Reference process
|
||||
|
@ -421,24 +399,11 @@ PsInitializeThread(HANDLE ProcessHandle,
|
|||
|
||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
||||
InsertTailList(&PiThreadListHead, &Thread->Tcb.ThreadListEntry);
|
||||
for (i = 0; i < PiThreadNotifyRoutineCount; i++)
|
||||
{
|
||||
NotifyRoutine[i] = PiThreadNotifyRoutine[i];
|
||||
}
|
||||
NotifyRoutineCount = PiThreadNotifyRoutineCount;
|
||||
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
||||
|
||||
Thread->Tcb.BasePriority = Thread->ThreadsProcess->Pcb.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);
|
||||
}
|
||||
|
||||
|
@ -735,6 +700,20 @@ PsCreateSystemThread(PHANDLE ThreadHandle,
|
|||
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
|
||||
|
@ -742,18 +721,13 @@ PsCreateSystemThread(PHANDLE ThreadHandle,
|
|||
NTSTATUS STDCALL
|
||||
PsSetCreateThreadNotifyRoutine(IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine)
|
||||
{
|
||||
KIRQL oldIrql;
|
||||
|
||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
||||
if (PiThreadNotifyRoutineCount >= MAX_THREAD_NOTIFY_ROUTINE_COUNT)
|
||||
if (PiThreadNotifyRoutineCount >= MAX_THREAD_NOTIFY_ROUTINE_COUNT)
|
||||
{
|
||||
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
||||
}
|
||||
|
||||
PiThreadNotifyRoutine[PiThreadNotifyRoutineCount] = NotifyRoutine;
|
||||
PiThreadNotifyRoutineCount++;
|
||||
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
||||
|
||||
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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -95,52 +95,18 @@ PsReapThreads(VOID)
|
|||
|
||||
if (current->Tcb.State == THREAD_STATE_TERMINATED_1)
|
||||
{
|
||||
PEPROCESS Process = current->ThreadsProcess;
|
||||
NTSTATUS Status = current->ExitStatus;
|
||||
BOOLEAN Last;
|
||||
|
||||
PiNrThreadsAwaitingReaping--;
|
||||
current->Tcb.State = THREAD_STATE_TERMINATED_2;
|
||||
RemoveEntryList(¤t->Tcb.ProcessThreadListEntry);
|
||||
Last = IsListEmpty(&Process->ThreadListHead);
|
||||
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
||||
|
||||
if (Last)
|
||||
{
|
||||
PiTerminateProcess(Process, Status);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
An unbelievably complex chain of events would cause a system crash
|
||||
if PiThreadListLock was still held when the thread object is about
|
||||
to be destroyed
|
||||
*/
|
||||
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
||||
ObDereferenceObject(current);
|
||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
||||
|
||||
current_entry = PiThreadListHead.Flink;
|
||||
}
|
||||
}
|
||||
|
@ -155,23 +121,35 @@ PsTerminateCurrentThread(NTSTATUS ExitStatus)
|
|||
{
|
||||
KIRQL oldIrql;
|
||||
PETHREAD CurrentThread;
|
||||
PKTHREAD Thread;
|
||||
PLIST_ENTRY current_entry;
|
||||
PKMUTANT Mutant;
|
||||
BOOLEAN Last;
|
||||
PEPROCESS CurrentProcess;
|
||||
|
||||
KeLowerIrql(PASSIVE_LEVEL);
|
||||
|
||||
CurrentThread = PsGetCurrentThread();
|
||||
CurrentProcess = CurrentThread->ThreadsProcess;
|
||||
|
||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
||||
|
||||
CurrentThread = PsGetCurrentThread();
|
||||
DPRINT("terminating %x\n",CurrentThread);
|
||||
|
||||
CurrentThread->ExitStatus = ExitStatus;
|
||||
Thread = KeGetCurrentThread();
|
||||
KeCancelTimer(&Thread->Timer);
|
||||
KeCancelTimer(&CurrentThread->Tcb.Timer);
|
||||
|
||||
/* Remove the thread from the thread list of its process */
|
||||
RemoveEntryList(&CurrentThread->Tcb.ProcessThreadListEntry);
|
||||
Last = IsListEmpty(&CurrentProcess->ThreadListHead);
|
||||
|
||||
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
||||
|
||||
PspRunCreateThreadNotifyRoutines(CurrentThread, FALSE);
|
||||
PsTerminateWin32Thread(CurrentThread);
|
||||
|
||||
/* abandon all owned mutants */
|
||||
current_entry = Thread->MutantListHead.Flink;
|
||||
while (current_entry != &Thread->MutantListHead)
|
||||
current_entry = CurrentThread->Tcb.MutantListHead.Flink;
|
||||
while (current_entry != &CurrentThread->Tcb.MutantListHead)
|
||||
{
|
||||
Mutant = CONTAINING_RECORD(current_entry, KMUTANT,
|
||||
MutantListEntry);
|
||||
|
@ -179,7 +157,7 @@ PsTerminateCurrentThread(NTSTATUS ExitStatus)
|
|||
MUTANT_INCREMENT,
|
||||
TRUE,
|
||||
FALSE);
|
||||
current_entry = Thread->MutantListHead.Flink;
|
||||
current_entry = CurrentThread->Tcb.MutantListHead.Flink;
|
||||
}
|
||||
|
||||
oldIrql = KeAcquireDispatcherDatabaseLock();
|
||||
|
@ -187,6 +165,14 @@ PsTerminateCurrentThread(NTSTATUS ExitStatus)
|
|||
KeDispatcherObjectWake(&CurrentThread->Tcb.DispatcherHeader);
|
||||
KeReleaseDispatcherDatabaseLock (oldIrql);
|
||||
|
||||
/* The last thread shall close the door on exit */
|
||||
if(Last)
|
||||
{
|
||||
PspRunCreateProcessNotifyRoutines(CurrentProcess, FALSE);
|
||||
PsTerminateWin32Process(CurrentProcess);
|
||||
PiTerminateProcess(CurrentProcess, ExitStatus);
|
||||
}
|
||||
|
||||
KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
|
||||
|
||||
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
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -329,9 +329,6 @@ VOID STDCALL
|
|||
PiDeleteProcessWorker(PVOID pContext)
|
||||
{
|
||||
KIRQL oldIrql;
|
||||
ULONG i;
|
||||
PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine[MAX_PROCESS_NOTIFY_ROUTINE_COUNT];
|
||||
ULONG NotifyRoutineCount;
|
||||
PDEL_CONTEXT Context;
|
||||
PEPROCESS CurrentProcess;
|
||||
PEPROCESS Process;
|
||||
|
@ -347,29 +344,10 @@ PiDeleteProcessWorker(PVOID pContext)
|
|||
KeAttachProcess(Process);
|
||||
}
|
||||
|
||||
/* Terminate Win32 Process */
|
||||
PsTerminateWin32Process (Process);
|
||||
|
||||
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);
|
||||
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_DELETEPROCESS_HOOK(Process);
|
||||
|
||||
|
@ -586,9 +564,6 @@ NtCreateProcess(OUT PHANDLE ProcessHandle,
|
|||
PEPORT ExceptionPort;
|
||||
PVOID BaseAddress;
|
||||
PMEMORY_AREA MemoryArea;
|
||||
ULONG i;
|
||||
PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine[MAX_PROCESS_NOTIFY_ROUTINE_COUNT];
|
||||
ULONG NotifyRoutineCount;
|
||||
|
||||
DPRINT("NtCreateProcess(ObjectAttributes %x)\n",ObjectAttributes);
|
||||
|
||||
|
@ -696,26 +671,10 @@ NtCreateProcess(OUT PHANDLE ProcessHandle,
|
|||
}
|
||||
|
||||
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);
|
||||
InitializeListHead(&Process->ThreadListHead);
|
||||
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;
|
||||
|
||||
/*
|
||||
|
@ -1581,6 +1540,22 @@ PsLookupProcessByProcessId(IN PVOID ProcessId,
|
|||
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
|
||||
|
@ -1589,11 +1564,8 @@ NTSTATUS STDCALL
|
|||
PsSetCreateProcessNotifyRoutine(IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine,
|
||||
IN BOOLEAN Remove)
|
||||
{
|
||||
KIRQL oldIrql;
|
||||
ULONG i;
|
||||
|
||||
KeAcquireSpinLock(&PsProcessListLock, &oldIrql);
|
||||
|
||||
if (Remove)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -1619,8 +1590,6 @@ PsSetCreateProcessNotifyRoutine(IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine,
|
|||
}
|
||||
}
|
||||
|
||||
KeReleaseSpinLock(&PsProcessListLock, oldIrql);
|
||||
|
||||
if (i == MAX_PROCESS_NOTIFY_ROUTINE_COUNT)
|
||||
{
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
|
Loading…
Reference in a new issue