-/* $Id: psfuncs.h,v 1.17 2002/01/03 14:01:16 ekohl Exp $
+/* $Id: psfuncs.h,v 1.18 2002/01/03 17:58:44 ekohl Exp $
*/
#ifndef _INCLUDE_DDK_PSFUNCS_H
#define _INCLUDE_DDK_PSFUNCS_H
OUT struct _ETHREAD **Thread);
// OUT PETHREAD *Thread);
+NTSTATUS STDCALL
+PsSetCreateProcessNotifyRoutine(IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine,
+ IN BOOLEAN Remove);
+
+NTSTATUS STDCALL
+PsSetCreateThreadNotifyRoutine(IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine);
+
#endif
/* EOF */
typedef NTSTATUS STDCALL (*PKSTART_ROUTINE)(PVOID StartContext);
+typedef VOID STDCALL (*PCREATE_PROCESS_NOTIFY_ROUTINE)(HANDLE ParentId,
+ HANDLE ProcessId,
+ BOOLEAN Create);
+
+typedef VOID STDCALL (*PCREATE_THREAD_NOTIFY_ROUTINE)(HANDLE ProcessId,
+ HANDLE ThreadId,
+ BOOLEAN Create);
+
typedef struct _STACK_INFORMATION
{
PVOID BaseAddress;
-; $Id: ntoskrnl.def,v 1.121 2002/01/03 14:02:04 ekohl Exp $
+; $Id: ntoskrnl.def,v 1.122 2002/01/03 18:02:34 ekohl Exp $
;
; reactos/ntoskrnl/ntoskrnl.def
;
PsReferencePrimaryToken@4
;PsReturnPoolQuota@12
PsRevertToSelf@0
-;PsSetCreateProcessNotifyRoutine@8
-;PsSetCreateThreadNotifyRoutine@4
+PsSetCreateProcessNotifyRoutine@8
+PsSetCreateThreadNotifyRoutine@4
;PsSetLegoNotifyRoutine@4
;PsSetProcessPriorityByClass@8
PsTerminateSystemThread@4
-; $Id: ntoskrnl.edf,v 1.107 2002/01/03 14:02:04 ekohl Exp $
+; $Id: ntoskrnl.edf,v 1.108 2002/01/03 18:02:34 ekohl Exp $
;
; reactos/ntoskrnl/ntoskrnl.def
;
PsReferencePrimaryToken=PsReferencePrimaryToken@4
;PsReturnPoolQuota
PsRevertToSelf=PsRevertToSelf@0
-;PsSetCreateProcessNotifyRoutine
-;PsSetCreateThreadNotifyRoutine
+PsSetCreateProcessNotifyRoutine=PsSetCreateProcessNotifyRoutine@8
+PsSetCreateThreadNotifyRoutine=PsSetCreateThreadNotifyRoutine@4
;PsSetLegoNotifyRoutine
;PsSetProcessPriorityByClass
PsTerminateSystemThread=PsTerminateSystemThread@4
-/* $Id: create.c,v 1.41 2001/11/21 18:44:25 ekohl Exp $
+/* $Id: create.c,v 1.42 2002/01/03 17:59:09 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
extern LIST_ENTRY PiThreadListHead;
+#define MAX_THREAD_NOTIFY_ROUTINE_COUNT 8
+
+static ULONG PiThreadNotifyRoutineCount = 0;
+static PCREATE_THREAD_NOTIFY_ROUTINE
+PiThreadNotifyRoutine[MAX_THREAD_NOTIFY_ROUTINE_COUNT];
+
/* FUNCTIONS ***************************************************************/
NTSTATUS STDCALL
VOID STDCALL
PiDeleteThread(PVOID ObjectBody)
{
- KIRQL oldIrql;
-
- DPRINT("PiDeleteThread(ObjectBody %x)\n",ObjectBody);
-
- KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
- DPRINT("Process %x(%d)\n", ((PETHREAD)ObjectBody)->ThreadsProcess,
- ObGetReferenceCount(((PETHREAD)ObjectBody)->ThreadsProcess));
- ObDereferenceObject(((PETHREAD)ObjectBody)->ThreadsProcess);
- ((PETHREAD)ObjectBody)->ThreadsProcess = NULL;
- PiNrThreads--;
- RemoveEntryList(&((PETHREAD)ObjectBody)->Tcb.ThreadListEntry);
- HalReleaseTask((PETHREAD)ObjectBody);
- KeReleaseSpinLock(&PiThreadListLock, oldIrql);
- DPRINT("PiDeleteThread() finished\n");
+ KIRQL oldIrql;
+ PETHREAD Thread;
+ ULONG i;
+
+ DPRINT("PiDeleteThread(ObjectBody %x)\n",ObjectBody);
+
+ KeAcquireSpinLock(&PiThreadListLock, &oldIrql);
+ Thread = (PETHREAD)ObjectBody;
+
+ for (i = 0; i < PiThreadNotifyRoutineCount; i++)
+ {
+ PiThreadNotifyRoutine[i](Thread->Cid.UniqueProcess,
+ Thread->Cid.UniqueThread,
+ FALSE);
+ }
+
+ DPRINT("Process %x(%d)\n",
+ Thread->ThreadsProcess,
+ ObGetReferenceCount(Thread->ThreadsProcess));
+ ObDereferenceObject(Thread->ThreadsProcess);
+ Thread->ThreadsProcess = NULL;
+ PiNrThreads--;
+ RemoveEntryList(&Thread->Tcb.ThreadListEntry);
+ HalReleaseTask(Thread);
+ KeReleaseSpinLock(&PiThreadListLock, oldIrql);
+ DPRINT("PiDeleteThread() finished\n");
}
VOID STDCALL
NTSTATUS Status;
KIRQL oldIrql;
PEPROCESS Process;
+ ULONG i;
/*
* Reference process
Thread->Tcb.BasePriority = Thread->ThreadsProcess->Pcb.BasePriority;
Thread->Tcb.Priority = Thread->Tcb.BasePriority;
-
- return(STATUS_SUCCESS);
+
+ for (i = 0; i < PiThreadNotifyRoutineCount; i++)
+ {
+ PiThreadNotifyRoutine[i](Thread->Cid.UniqueProcess,
+ Thread->Cid.UniqueThread,
+ TRUE);
+ }
+
+ return(STATUS_SUCCESS);
}
return(STATUS_SUCCESS);
}
+
+NTSTATUS STDCALL
+PsSetCreateThreadNotifyRoutine(IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine)
+{
+ if (PiThreadNotifyRoutineCount >= MAX_THREAD_NOTIFY_ROUTINE_COUNT)
+ return(STATUS_INSUFFICIENT_RESOURCES);
+
+ PiThreadNotifyRoutine[PiThreadNotifyRoutineCount] = NotifyRoutine;
+ PiThreadNotifyRoutineCount++;
+
+ return(STATUS_SUCCESS);
+}
+
/* EOF */
-/* $Id: process.c,v 1.74 2002/01/03 14:03:05 ekohl Exp $
+/* $Id: process.c,v 1.75 2002/01/03 17:59:09 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
PROCESS_EXECUTE,
PROCESS_ALL_ACCESS};
+#define MAX_PROCESS_NOTIFY_ROUTINE_COUNT 8
+
+static ULONG PiProcessNotifyRoutineCount = 0;
+static PCREATE_PROCESS_NOTIFY_ROUTINE
+PiProcessNotifyRoutine[MAX_PROCESS_NOTIFY_ROUTINE_COUNT];
+
/* FUNCTIONS *****************************************************************/
VOID STDCALL
PiDeleteProcess(PVOID ObjectBody)
{
- KIRQL oldIrql;
-
- DPRINT("PiDeleteProcess(ObjectBody %x)\n",ObjectBody);
-
- KeAcquireSpinLock(&PsProcessListLock, &oldIrql);
- RemoveEntryList(&((PEPROCESS)ObjectBody)->ProcessListEntry);
+ KIRQL oldIrql;
+ PEPROCESS Process;
+ ULONG i;
+
+ DPRINT("PiDeleteProcess(ObjectBody %x)\n",ObjectBody);
+
+ Process = (PEPROCESS)Process;
+ KeAcquireSpinLock(&PsProcessListLock, &oldIrql);
+ for (i = 0; i < PiProcessNotifyRoutineCount; i++)
+ {
+ PiProcessNotifyRoutine[i](Process->InheritedFromUniqueProcessId,
+ (HANDLE)Process->UniqueProcessId,
+ FALSE);
+ }
+ RemoveEntryList(&Process->ProcessListEntry);
KeReleaseSpinLock(&PsProcessListLock, oldIrql);
#ifdef KDBG
- PiFreeSymbols(((PEPROCESS)ObjectBody)->Peb);
+ PiFreeSymbols(Process->Peb);
#endif /* KDBG */
- (VOID)MmReleaseMmInfo((PEPROCESS)ObjectBody);
- ObDeleteHandleTable((PEPROCESS)ObjectBody);
+ (VOID)MmReleaseMmInfo(Process);
+ ObDeleteHandleTable(Process);
}
PEPROCESS STDCALL
IoGetCurrentProcess(VOID)
{
- return(PsGetCurrentProcess());
+ return(PsGetCurrentProcess());
}
NTSTATUS STDCALL
PEPORT ExceptionPort;
PVOID BaseAddress;
PMEMORY_AREA MemoryArea;
+ ULONG i;
DPRINT("NtCreateProcess(ObjectAttributes %x)\n",ObjectAttributes);
MmCopyMmInfo(ParentProcess, Process);
KeAcquireSpinLock(&PsProcessListLock, &oldIrql);
+ for (i = 0; i < PiProcessNotifyRoutineCount; i++)
+ {
+ PiProcessNotifyRoutine[i](Process->InheritedFromUniqueProcessId,
+ (HANDLE)Process->UniqueProcessId,
+ TRUE);
+ }
InsertHeadList(&PsProcessListHead, &Process->ProcessListEntry);
InitializeListHead(&Process->ThreadListHead);
KeReleaseSpinLock(&PsProcessListLock, oldIrql);
return(STATUS_INVALID_PARAMETER);
}
+
+NTSTATUS STDCALL
+PsSetCreateProcessNotifyRoutine(IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine,
+ IN BOOLEAN Remove)
+{
+ if (PiProcessNotifyRoutineCount >= MAX_PROCESS_NOTIFY_ROUTINE_COUNT)
+ return(STATUS_INSUFFICIENT_RESOURCES);
+
+ PiProcessNotifyRoutine[PiProcessNotifyRoutineCount] = NotifyRoutine;
+ PiProcessNotifyRoutineCount++;
+
+ return(STATUS_SUCCESS);
+}
+
/* EOF */