Author: ion
Date: Tue Jul 18 02:18:44 2006
New Revision: 23131
URL:
http://svn.reactos.org/svn/reactos?rev=23131&view=rev
Log:
[AUDIT] - notify.c contains trivial (3 or 4 lines of code) implementations of adding a
pointer to an array, and then looping said array and calling a pointer. Your grandmother
could code this.
- Cleanup notify.c and fix the return value of PsSetCreateProcessNotifyRoutine.
- Create ps_x.h for inlined Ps routines and put the internal routines which call the
registered callbacks in it.
Added:
trunk/reactos/ntoskrnl/include/internal/ps_x.h
Modified:
trunk/reactos/include/ndk/pstypes.h
trunk/reactos/ntoskrnl/include/internal/ps.h
trunk/reactos/ntoskrnl/ps/notify.c (contents, props changed)
Modified: trunk/reactos/include/ndk/pstypes.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/pstypes.h?rev=…
==============================================================================
--- trunk/reactos/include/ndk/pstypes.h (original)
+++ trunk/reactos/include/ndk/pstypes.h Tue Jul 18 02:18:44 2006
@@ -449,6 +449,15 @@
struct _EPROCESS *Process,
PVOID Callback,
PVOID Context
+);
+
+//
+// Lego Callback
+//
+typedef
+VOID
+(NTAPI *PLEGO_NOTIFY_ROUTINE)(
+ IN PKTHREAD Thread
);
#endif
Modified: trunk/reactos/ntoskrnl/include/internal/ps.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/ps.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/ps.h Tue Jul 18 02:18:44 2006
@@ -7,6 +7,384 @@
struct _EJOB;
#include <internal/arch/ps.h>
+
+/* Top level irp definitions. */
+#define FSRTL_FSP_TOP_LEVEL_IRP (0x01)
+#define FSRTL_CACHE_TOP_LEVEL_IRP (0x02)
+#define FSRTL_MOD_WRITE_TOP_LEVEL_IRP (0x03)
+#define FSRTL_FAST_IO_TOP_LEVEL_IRP (0x04)
+#define FSRTL_MAX_TOP_LEVEL_IRP_FLAG (0x04)
+
+#define PSP_MAX_CREATE_THREAD_NOTIFY 8
+#define PSP_MAX_LOAD_IMAGE_NOTIFY 8
+#define PSP_MAX_CREATE_PROCESS_NOTIFY 8
+
+VOID
+NTAPI
+PiInitDefaultLocale(VOID);
+
+VOID
+NTAPI
+PiInitProcessManager(VOID);
+
+VOID
+NTAPI
+PspShutdownProcessManager(VOID);
+
+VOID
+NTAPI
+PsInitThreadManagment(VOID);
+
+VOID
+NTAPI
+PsInitProcessManagment(VOID);
+
+VOID
+NTAPI
+PsInitIdleThread(VOID);
+
+VOID
+NTAPI
+PiTerminateProcessThreads(
+ PEPROCESS Process,
+ NTSTATUS ExitStatus
+);
+
+VOID
+NTAPI
+PsTerminateCurrentThread(NTSTATUS ExitStatus);
+
+VOID
+NTAPI
+PsTerminateOtherThread(
+ PETHREAD Thread,
+ NTSTATUS ExitStatus
+);
+
+VOID
+NTAPI
+PsReleaseThread(PETHREAD Thread);
+
+VOID
+NTAPI
+PsBeginThread(
+ PKSTART_ROUTINE StartRoutine,
+ PVOID StartContext
+);
+
+VOID
+NTAPI
+PsBeginThreadWithContextInternal(VOID);
+
+VOID
+NTAPI
+PiKillMostProcesses(VOID);
+
+NTSTATUS
+STDCALL
+PiTerminateProcess(
+ PEPROCESS Process,
+ NTSTATUS ExitStatus
+);
+
+VOID
+NTAPI
+PiInitApcManagement(VOID);
+
+VOID
+STDCALL
+PiDeleteThread(PVOID ObjectBody);
+
+VOID
+NTAPI
+PsReapThreads(VOID);
+
+VOID
+NTAPI
+PsInitializeThreadReaper(VOID);
+
+VOID
+NTAPI
+PsQueueThreadReap(PETHREAD Thread);
+
+NTSTATUS
+NTAPI
+PsInitializeThread(
+ PEPROCESS Process,
+ PETHREAD* ThreadPtr,
+ POBJECT_ATTRIBUTES ObjectAttributes,
+ KPROCESSOR_MODE AccessMode,
+ BOOLEAN First
+);
+
+PACCESS_TOKEN
+STDCALL
+PsReferenceEffectiveToken(
+ PETHREAD Thread,
+ PTOKEN_TYPE TokenType,
+ PUCHAR b,
+ PSECURITY_IMPERSONATION_LEVEL Level
+);
+
+NTSTATUS
+STDCALL
+PsOpenTokenOfProcess(
+ HANDLE ProcessHandle,
+ PACCESS_TOKEN* Token
+);
+
+VOID
+STDCALL
+PspTerminateProcessThreads(
+ PEPROCESS Process,
+ NTSTATUS ExitStatus
+);
+
+NTSTATUS
+NTAPI
+PsSuspendThread(
+ PETHREAD Thread,
+ PULONG PreviousCount
+);
+
+NTSTATUS
+NTAPI
+PsResumeThread(
+ PETHREAD Thread,
+ PULONG PreviousCount
+);
+
+NTSTATUS
+STDCALL
+PspAssignPrimaryToken(
+ PEPROCESS Process,
+ HANDLE TokenHandle
+);
+
+PETHREAD
+NTAPI
+PsGetNextProcessThread(
+ IN PEPROCESS Process,
+ IN PETHREAD Thread OPTIONAL
+);
+
+VOID
+STDCALL
+PsExitSpecialApc(
+ PKAPC Apc,
+ PKNORMAL_ROUTINE *NormalRoutine,
+ PVOID *NormalContext,
+ PVOID *SystemArgument1,
+ PVOID *SystemArgument2
+);
+
+NTSTATUS
+STDCALL
+PspInitializeProcessSecurity(
+ PEPROCESS Process,
+ PEPROCESS Parent OPTIONAL
+);
+
+VOID
+STDCALL
+PspSystemThreadStartup(
+ PKSTART_ROUTINE StartRoutine,
+ PVOID StartContext
+);
+
+NTSTATUS
+NTAPI
+PsInitializeIdleOrFirstThread(
+ PEPROCESS Process,
+ PETHREAD* ThreadPtr,
+ PKSTART_ROUTINE StartRoutine,
+ KPROCESSOR_MODE AccessMode,
+ BOOLEAN First
+);
+
+VOID
+STDCALL
+PiDeleteProcess(PVOID ObjectBody);
+
+VOID
+STDCALL
+PspReapRoutine(PVOID Context);
+
+VOID
+STDCALL
+PspExitThread(NTSTATUS ExitStatus);
+
+NTSTATUS
+STDCALL
+PspTerminateThreadByPointer(
+ PETHREAD Thread,
+ NTSTATUS ExitStatus,
+ BOOLEAN bSelf
+);
+
+NTSTATUS
+NTAPI
+PsUnfreezeOtherThread(PETHREAD Thread);
+
+VOID
+NTAPI
+PsFreezeOtherThread(PETHREAD Thread);
+
+VOID
+NTAPI
+PsFreezeProcessThreads(PEPROCESS Process);
+
+VOID
+NTAPI
+PsUnfreezeProcessThreads(PEPROCESS Process);
+
+ULONG
+NTAPI
+PsEnumThreadsByProcess(PEPROCESS Process);
+
+PEPROCESS
+STDCALL
+PsGetNextProcess(PEPROCESS OldProcess);
+
+VOID
+NTAPI
+PsApplicationProcessorInit(VOID);
+
+VOID
+NTAPI
+PsPrepareForApplicationProcessorInit(ULONG Id);
+
+VOID
+STDCALL
+PsIdleThreadMain(PVOID Context);
+
+VOID
+STDCALL
+PiSuspendThreadRundownRoutine(PKAPC Apc);
+
+VOID
+STDCALL
+PiSuspendThreadKernelRoutine(
+ PKAPC Apc,
+ PKNORMAL_ROUTINE* NormalRoutine,
+ PVOID* NormalContext,
+ PVOID* SystemArgument1,
+ PVOID* SystemArguemnt2
+);
+
+VOID
+STDCALL
+PiSuspendThreadNormalRoutine(
+ PVOID NormalContext,
+ PVOID SystemArgument1,
+ PVOID SystemArgument2
+);
+
+VOID
+NTAPI
+PsInitialiseSuspendImplementation(VOID);
+
+VOID
+STDCALL
+PspExitProcess(BOOLEAN LastThread,
+ PEPROCESS Process);
+
+VOID
+STDCALL
+PspDeleteProcess(PVOID ObjectBody);
+
+VOID
+STDCALL
+PspDeleteThread(PVOID ObjectBody);
+
+
+NTSTATUS
+NTAPI
+PsInitWin32Thread(PETHREAD Thread);
+
+VOID
+NTAPI
+PsTerminateWin32Process(PEPROCESS Process);
+
+VOID
+NTAPI
+PsTerminateWin32Thread(PETHREAD Thread);
+
+VOID
+NTAPI
+PsInitialiseW32Call(VOID);
+
+VOID
+NTAPI
+INIT_FUNCTION
+PsInitJobManagment(VOID);
+
+VOID
+STDCALL
+PspInheritQuota(
+ PEPROCESS Process,
+ PEPROCESS ParentProcess
+);
+
+VOID
+STDCALL
+PspDestroyQuotaBlock(PEPROCESS Process);
+
+NTSTATUS
+STDCALL
+PspMapSystemDll(
+ PEPROCESS Process,
+ PVOID *DllBase
+);
+
+NTSTATUS
+STDCALL
+PsLocateSystemDll(VOID);
+
+NTSTATUS
+STDCALL
+PspGetSystemDllEntryPoints(VOID);
+
+NTSTATUS
+NTAPI
+PsLockProcess(
+ PEPROCESS Process,
+ BOOLEAN Timeout
+);
+
+VOID
+NTAPI
+PsUnlockProcess(PEPROCESS Process);
+
+VOID
+NTAPI
+PspRemoveProcessFromJob(
+ IN PEPROCESS Process,
+ IN PEJOB Job
+);
+
+NTSTATUS
+NTAPI
+PspDeleteLdt(IN PEPROCESS Process);
+
+NTSTATUS
+NTAPI
+PspDeleteVdmObjects(IN PEPROCESS Process);
+
+VOID
+NTAPI
+PspDeleteProcessSecurity(IN PEPROCESS Process);
+
+VOID
+NTAPI
+PspDeleteThreadSecurity(IN PETHREAD Thread);
+
+VOID
+NTAPI
+PspExitProcessFromJob(
+ IN PEJOB Job,
+ IN PEPROCESS Process
+);
extern LCID PsDefaultThreadLocaleId;
extern LCID PsDefaultSystemLocaleId;
@@ -19,400 +397,15 @@
extern FAST_MUTEX PspActiveProcessMutex;
extern LARGE_INTEGER ShortPsLockDelay, PsLockTimeout;
extern EPROCESS_QUOTA_BLOCK PspDefaultQuotaBlock;
-
-/* Top level irp definitions. */
-#define FSRTL_FSP_TOP_LEVEL_IRP (0x01)
-#define FSRTL_CACHE_TOP_LEVEL_IRP (0x02)
-#define FSRTL_MOD_WRITE_TOP_LEVEL_IRP (0x03)
-#define FSRTL_FAST_IO_TOP_LEVEL_IRP (0x04)
-#define FSRTL_MAX_TOP_LEVEL_IRP_FLAG (0x04)
-
-#define MAX_PROCESS_NOTIFY_ROUTINE_COUNT 8
-#define MAX_LOAD_IMAGE_NOTIFY_ROUTINE_COUNT 8
-
-VOID
-NTAPI
-PiInitDefaultLocale(VOID);
-
-VOID
-NTAPI
-PiInitProcessManager(VOID);
-
-VOID
-NTAPI
-PspShutdownProcessManager(VOID);
-
-VOID
-NTAPI
-PsInitThreadManagment(VOID);
-
-VOID
-NTAPI
-PsInitProcessManagment(VOID);
-
-VOID
-NTAPI
-PsInitIdleThread(VOID);
-
-VOID
-NTAPI
-PiTerminateProcessThreads(
- PEPROCESS Process,
- NTSTATUS ExitStatus
-);
-
-VOID
-NTAPI
-PsTerminateCurrentThread(NTSTATUS ExitStatus);
-
-VOID
-NTAPI
-PsTerminateOtherThread(
- PETHREAD Thread,
- NTSTATUS ExitStatus
-);
-
-VOID
-NTAPI
-PsReleaseThread(PETHREAD Thread);
-
-VOID
-NTAPI
-PsBeginThread(
- PKSTART_ROUTINE StartRoutine,
- PVOID StartContext
-);
-
-VOID
-NTAPI
-PsBeginThreadWithContextInternal(VOID);
-
-VOID
-NTAPI
-PiKillMostProcesses(VOID);
-
-NTSTATUS
-STDCALL
-PiTerminateProcess(
- PEPROCESS Process,
- NTSTATUS ExitStatus
-);
-
-VOID
-NTAPI
-PiInitApcManagement(VOID);
-
-VOID
-STDCALL
-PiDeleteThread(PVOID ObjectBody);
-
-VOID
-NTAPI
-PsReapThreads(VOID);
-
-VOID
-NTAPI
-PsInitializeThreadReaper(VOID);
-
-VOID
-NTAPI
-PsQueueThreadReap(PETHREAD Thread);
-
-NTSTATUS
-NTAPI
-PsInitializeThread(
- PEPROCESS Process,
- PETHREAD* ThreadPtr,
- POBJECT_ATTRIBUTES ObjectAttributes,
- KPROCESSOR_MODE AccessMode,
- BOOLEAN First
-);
-
-PACCESS_TOKEN
-STDCALL
-PsReferenceEffectiveToken(
- PETHREAD Thread,
- PTOKEN_TYPE TokenType,
- PUCHAR b,
- PSECURITY_IMPERSONATION_LEVEL Level
-);
-
-NTSTATUS
-STDCALL
-PsOpenTokenOfProcess(
- HANDLE ProcessHandle,
- PACCESS_TOKEN* Token
-);
-
-VOID
-STDCALL
-PspTerminateProcessThreads(
- PEPROCESS Process,
- NTSTATUS ExitStatus
-);
-
-NTSTATUS
-NTAPI
-PsSuspendThread(
- PETHREAD Thread,
- PULONG PreviousCount
-);
-
-NTSTATUS
-NTAPI
-PsResumeThread(
- PETHREAD Thread,
- PULONG PreviousCount
-);
-
-NTSTATUS
-STDCALL
-PspAssignPrimaryToken(
- PEPROCESS Process,
- HANDLE TokenHandle
-);
-
-PETHREAD
-NTAPI
-PsGetNextProcessThread(
- IN PEPROCESS Process,
- IN PETHREAD Thread OPTIONAL
-);
-
-VOID
-STDCALL
-PsExitSpecialApc(
- PKAPC Apc,
- PKNORMAL_ROUTINE *NormalRoutine,
- PVOID *NormalContext,
- PVOID *SystemArgument1,
- PVOID *SystemArgument2
-);
-
-NTSTATUS
-STDCALL
-PspInitializeProcessSecurity(
- PEPROCESS Process,
- PEPROCESS Parent OPTIONAL
-);
-
-VOID
-STDCALL
-PspSystemThreadStartup(
- PKSTART_ROUTINE StartRoutine,
- PVOID StartContext
-);
-
-NTSTATUS
-NTAPI
-PsInitializeIdleOrFirstThread(
- PEPROCESS Process,
- PETHREAD* ThreadPtr,
- PKSTART_ROUTINE StartRoutine,
- KPROCESSOR_MODE AccessMode,
- BOOLEAN First
-);
-
-VOID
-STDCALL
-PiDeleteProcess(PVOID ObjectBody);
-
-VOID
-STDCALL
-PspReapRoutine(PVOID Context);
-
-VOID
-STDCALL
-PspExitThread(NTSTATUS ExitStatus);
-
-NTSTATUS
-STDCALL
-PspTerminateThreadByPointer(
- PETHREAD Thread,
- NTSTATUS ExitStatus,
- BOOLEAN bSelf
-);
-
-NTSTATUS
-NTAPI
-PsUnfreezeOtherThread(PETHREAD Thread);
-
-VOID
-NTAPI
-PsFreezeOtherThread(PETHREAD Thread);
-
-VOID
-NTAPI
-PsFreezeProcessThreads(PEPROCESS Process);
-
-VOID
-NTAPI
-PsUnfreezeProcessThreads(PEPROCESS Process);
-
-ULONG
-NTAPI
-PsEnumThreadsByProcess(PEPROCESS Process);
-
-PEPROCESS
-STDCALL
-PsGetNextProcess(PEPROCESS OldProcess);
-
-VOID
-NTAPI
-PsApplicationProcessorInit(VOID);
-
-VOID
-NTAPI
-PsPrepareForApplicationProcessorInit(ULONG Id);
-
-VOID
-STDCALL
-PsIdleThreadMain(PVOID Context);
-
-VOID
-STDCALL
-PiSuspendThreadRundownRoutine(PKAPC Apc);
-
-VOID
-STDCALL
-PiSuspendThreadKernelRoutine(
- PKAPC Apc,
- PKNORMAL_ROUTINE* NormalRoutine,
- PVOID* NormalContext,
- PVOID* SystemArgument1,
- PVOID* SystemArguemnt2
-);
-
-VOID
-STDCALL
-PiSuspendThreadNormalRoutine(
- PVOID NormalContext,
- PVOID SystemArgument1,
- PVOID SystemArgument2
-);
-
-VOID
-NTAPI
-PsInitialiseSuspendImplementation(VOID);
-
-VOID
-STDCALL
-PspExitProcess(BOOLEAN LastThread,
- PEPROCESS Process);
-
-VOID
-STDCALL
-PspDeleteProcess(PVOID ObjectBody);
-
-VOID
-STDCALL
-PspDeleteThread(PVOID ObjectBody);
-
-
-NTSTATUS
-NTAPI
-PsInitWin32Thread(PETHREAD Thread);
-
-VOID
-NTAPI
-PsTerminateWin32Process(PEPROCESS Process);
-
-VOID
-NTAPI
-PsTerminateWin32Thread(PETHREAD Thread);
-
-VOID
-NTAPI
-PsInitialiseW32Call(VOID);
-
-VOID
-STDCALL
-PspRunCreateThreadNotifyRoutines(
- PETHREAD,
- BOOLEAN
-);
-
-VOID
-STDCALL
-PspRunCreateProcessNotifyRoutines(
- PEPROCESS,
- BOOLEAN
-);
-
-VOID
-STDCALL
-PspRunLegoRoutine(IN PKTHREAD Thread);
-
-VOID
-NTAPI
-INIT_FUNCTION
-PsInitJobManagment(VOID);
-
-VOID
-STDCALL
-PspInheritQuota(
- PEPROCESS Process,
- PEPROCESS ParentProcess
-);
-
-VOID
-STDCALL
-PspDestroyQuotaBlock(PEPROCESS Process);
-
-NTSTATUS
-STDCALL
-PspMapSystemDll(
- PEPROCESS Process,
- PVOID *DllBase
-);
-
-NTSTATUS
-STDCALL
-PsLocateSystemDll(VOID);
-
-NTSTATUS
-STDCALL
-PspGetSystemDllEntryPoints(VOID);
-
-NTSTATUS
-NTAPI
-PsLockProcess(
- PEPROCESS Process,
- BOOLEAN Timeout
-);
-
-VOID
-NTAPI
-PsUnlockProcess(PEPROCESS Process);
-
-VOID
-NTAPI
-PspRemoveProcessFromJob(
- IN PEPROCESS Process,
- IN PEJOB Job
-);
-
-NTSTATUS
-NTAPI
-PspDeleteLdt(IN PEPROCESS Process);
-
-NTSTATUS
-NTAPI
-PspDeleteVdmObjects(IN PEPROCESS Process);
-
-VOID
-NTAPI
-PspDeleteProcessSecurity(IN PEPROCESS Process);
-
-VOID
-NTAPI
-PspDeleteThreadSecurity(IN PETHREAD Thread);
-
-VOID
-NTAPI
-PspExitProcessFromJob(
- IN PEJOB Job,
- IN PEPROCESS Process
-);
+extern PCREATE_THREAD_NOTIFY_ROUTINE
+PspThreadNotifyRoutine[PSP_MAX_CREATE_THREAD_NOTIFY];
+extern PCREATE_PROCESS_NOTIFY_ROUTINE
+PspProcessNotifyRoutine[PSP_MAX_CREATE_PROCESS_NOTIFY];
+extern PLOAD_IMAGE_NOTIFY_ROUTINE
+PspLoadImageNotifyRoutine[PSP_MAX_LOAD_IMAGE_NOTIFY];
+extern PLEGO_NOTIFY_ROUTINE PspLegoNotifyRoutine;
+extern ULONG PspThreadNotifyRoutineCount;
+
+#include "ps_x.h"
#endif /* __INCLUDE_INTERNAL_PS_H */
Added: trunk/reactos/ntoskrnl/include/internal/ps_x.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/ps_x.h (added)
+++ trunk/reactos/ntoskrnl/include/internal/ps_x.h Tue Jul 18 02:18:44 2006
@@ -1,0 +1,74 @@
+/*
+* PROJECT: ReactOS Kernel
+* LICENSE: GPL - See COPYING in the top level directory
+* FILE: ntoskrnl/include/ps_x.h
+* PURPOSE: Intenral Inlined Functions for the Process Manager
+* PROGRAMMERS: Alex Ionescu (alex.ionescu(a)reactos.org)
+* Thomas Weidenmueller (w3seek(a)reactos.org)
+*/
+
+VOID
+FORCEINLINE
+PspRunCreateThreadNotifyRoutines(IN PETHREAD CurrentThread,
+ IN BOOLEAN Create)
+{
+ ULONG i;
+ CLIENT_ID Cid = CurrentThread->Cid;
+
+ /* Loop the notify routines */
+ for (i = 0; i < PspThreadNotifyRoutineCount; i++)
+ {
+ /* Call it */
+ PspThreadNotifyRoutine[i](Cid.UniqueProcess, Cid.UniqueThread, Create);
+ }
+}
+
+VOID
+FORCEINLINE
+PspRunCreateProcessNotifyRoutines(IN PEPROCESS CurrentProcess,
+ IN BOOLEAN Create)
+{
+ ULONG i;
+ HANDLE ProcessId = (HANDLE)CurrentProcess->UniqueProcessId;
+ HANDLE ParentId = CurrentProcess->InheritedFromUniqueProcessId;
+
+ /* Loop the notify routines */
+ for(i = 0; i < PSP_MAX_CREATE_PROCESS_NOTIFY; ++i)
+ {
+ /* Make sure it exists */
+ if(PspProcessNotifyRoutine[i])
+ {
+ /* Call it */
+ PspProcessNotifyRoutine[i](ParentId, ProcessId, Create);
+ }
+ }
+}
+
+VOID
+FORCEINLINE
+PspRunLoadImageNotifyRoutines(PUNICODE_STRING FullImageName,
+ HANDLE ProcessId,
+ PIMAGE_INFO ImageInfo)
+{
+ ULONG i;
+
+ /* Loop the notify routines */
+ for (i = 0; i < PSP_MAX_LOAD_IMAGE_NOTIFY; ++ i)
+ {
+ /* Make sure it exists */
+ if (PspLoadImageNotifyRoutine[i])
+ {
+ /* Call it */
+ PspLoadImageNotifyRoutine[i](FullImageName, ProcessId, ImageInfo);
+ }
+ }
+}
+
+VOID
+FORCEINLINE
+PspRunLegoRoutine(IN PKTHREAD Thread)
+{
+ /* Call it */
+ if (PspLegoNotifyRoutine) PspLegoNotifyRoutine(Thread);
+}
+
Modified: trunk/reactos/ntoskrnl/ps/notify.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/notify.c?rev=2…
==============================================================================
--- trunk/reactos/ntoskrnl/ps/notify.c (original)
+++ trunk/reactos/ntoskrnl/ps/notify.c Tue Jul 18 02:18:44 2006
@@ -1,42 +1,36 @@
/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
+ * PROJECT: ReactOS Kernel
+ * LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/ps/notify.c
- * PURPOSE: Notifications
- *
- * PROGRAMMERS: Alex Ionescu (alex(a)relsoft.net)
+ * PURPOSE: Process Manager: Callbacks to Registered Clients (Drivers)
+ * PROGRAMMERS: Alex Ionescu (alex.ionescu(a)reactos.org)
+ * Thomas Weidenmueller (w3seek(a)reactos.org)
*/
-/* INCLUDES ****************************************************************/
+/* INCLUDES ******************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
-/* GLOBAL *******************************************************************/
+/* GLOBALS *******************************************************************/
-#define MAX_THREAD_NOTIFY_ROUTINE_COUNT 8
+ULONG PspThreadNotifyRoutineCount;
+PCREATE_THREAD_NOTIFY_ROUTINE
+PspThreadNotifyRoutine[PSP_MAX_CREATE_THREAD_NOTIFY];
+PCREATE_PROCESS_NOTIFY_ROUTINE
+PspProcessNotifyRoutine[PSP_MAX_CREATE_PROCESS_NOTIFY];
+PLOAD_IMAGE_NOTIFY_ROUTINE
+PspLoadImageNotifyRoutine[PSP_MAX_LOAD_IMAGE_NOTIFY];
+PLEGO_NOTIFY_ROUTINE PspLegoNotifyRoutine;
-static ULONG PspThreadNotifyRoutineCount = 0;
-static PCREATE_THREAD_NOTIFY_ROUTINE
-PspThreadNotifyRoutine[MAX_THREAD_NOTIFY_ROUTINE_COUNT];
-
-static PCREATE_PROCESS_NOTIFY_ROUTINE
-PspProcessNotifyRoutine[MAX_PROCESS_NOTIFY_ROUTINE_COUNT];
-
-static PLOAD_IMAGE_NOTIFY_ROUTINE
-PspLoadImageNotifyRoutine[MAX_LOAD_IMAGE_NOTIFY_ROUTINE_COUNT];
-
-typedef VOID (STDCALL *PLEGO_NOTIFY_ROUTINE)(IN PKTHREAD Thread);
-static PLEGO_NOTIFY_ROUTINE PspLegoNotifyRoutine;
-
-/* FUNCTIONS ***************************************************************/
+/* PUBLIC FUNCTIONS **********************************************************/
/*
* @implemented
*/
NTSTATUS
-STDCALL
+NTAPI
PsSetCreateProcessNotifyRoutine(IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine,
IN BOOLEAN Remove)
{
@@ -46,24 +40,24 @@
if (Remove)
{
/* Loop the routines */
- for(i=0;i<MAX_PROCESS_NOTIFY_ROUTINE_COUNT;i++)
+ for(i = 0; i < PSP_MAX_CREATE_PROCESS_NOTIFY; i++)
{
/* Check for a match */
- if ((PVOID)PspProcessNotifyRoutine[i] == (PVOID)NotifyRoutine)
+ if (PspProcessNotifyRoutine[i] == NotifyRoutine)
{
/* Remove and return */
PspProcessNotifyRoutine[i] = NULL;
- return(STATUS_SUCCESS);
+ return STATUS_SUCCESS;
}
}
}
else
{
/* Loop the routines */
- for(i=0;i<MAX_PROCESS_NOTIFY_ROUTINE_COUNT;i++)
+ for(i = 0; i < PSP_MAX_CREATE_PROCESS_NOTIFY; i++)
{
/* Find an empty one */
- if (PspProcessNotifyRoutine[i] == NULL)
+ if (!PspProcessNotifyRoutine[i])
{
/* Add it */
PspProcessNotifyRoutine[i] = NotifyRoutine;
@@ -73,14 +67,14 @@
}
/* Nothing found */
- return STATUS_INVALID_PARAMETER;
+ return Remove ? STATUS_PROCEDURE_NOT_FOUND : STATUS_INVALID_PARAMETER;
}
/*
* @implemented
*/
ULONG
-STDCALL
+NTAPI
PsSetLegoNotifyRoutine(PVOID LegoNotifyRoutine)
{
/* Set the System-Wide Lego Routine */
@@ -94,20 +88,20 @@
* @implemented
*/
NTSTATUS
-STDCALL
+NTAPI
PsRemoveLoadImageNotifyRoutine(IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine)
{
ULONG i;
/* Loop the routines */
- for(i=0;i<MAX_LOAD_IMAGE_NOTIFY_ROUTINE_COUNT;i++)
+ for(i = 0; i < PSP_MAX_LOAD_IMAGE_NOTIFY; i++)
{
/* Check for a match */
- if ((PVOID)PspLoadImageNotifyRoutine[i] == (PVOID)NotifyRoutine)
+ if (PspLoadImageNotifyRoutine[i] == NotifyRoutine)
{
/* Remove and return */
PspLoadImageNotifyRoutine[i] = NULL;
- return(STATUS_SUCCESS);
+ return STATUS_SUCCESS;
}
}
@@ -119,16 +113,16 @@
* @implemented
*/
NTSTATUS
-STDCALL
+NTAPI
PsSetLoadImageNotifyRoutine(IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine)
{
ULONG i;
/* Loop the routines */
- for (i = 0; i < MAX_LOAD_IMAGE_NOTIFY_ROUTINE_COUNT; i++)
+ for (i = 0; i < PSP_MAX_LOAD_IMAGE_NOTIFY; i++)
{
/* Find an empty one */
- if (PspLoadImageNotifyRoutine[i] == NULL)
+ if (!PspLoadImageNotifyRoutine[i])
{
/* Add it */
PspLoadImageNotifyRoutine[i] = NotifyRoutine;
@@ -144,20 +138,20 @@
* @implemented
*/
NTSTATUS
-STDCALL
+NTAPI
PsRemoveCreateThreadNotifyRoutine(IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine)
{
ULONG i;
/* Loop the routines */
- for(i=0;i<MAX_THREAD_NOTIFY_ROUTINE_COUNT;i++)
+ for(i = 0; i < PSP_MAX_CREATE_THREAD_NOTIFY; i++)
{
/* Check for a match */
- if ((PVOID)PspThreadNotifyRoutine[i] == (PVOID)NotifyRoutine)
+ if (PspThreadNotifyRoutine[i] == NotifyRoutine)
{
/* Remove and return */
PspThreadNotifyRoutine[i] = NULL;
- return(STATUS_SUCCESS);
+ return STATUS_SUCCESS;
}
}
@@ -169,75 +163,19 @@
* @implemented
*/
NTSTATUS
-STDCALL
+NTAPI
PsSetCreateThreadNotifyRoutine(IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine)
{
- if (PspThreadNotifyRoutineCount >= MAX_THREAD_NOTIFY_ROUTINE_COUNT)
+ /* Make sure we didn't register too many */
+ if (PspThreadNotifyRoutineCount >= PSP_MAX_CREATE_THREAD_NOTIFY)
{
- return(STATUS_INSUFFICIENT_RESOURCES);
+ /* Fail */
+ return STATUS_INSUFFICIENT_RESOURCES;
}
- PspThreadNotifyRoutine[PspThreadNotifyRoutineCount] = NotifyRoutine;
- PspThreadNotifyRoutineCount++;
-
- return(STATUS_SUCCESS);
-}
-
-VOID
-STDCALL
-PspRunCreateThreadNotifyRoutines(PETHREAD CurrentThread,
- BOOLEAN Create)
-{
- ULONG i;
- CLIENT_ID Cid = CurrentThread->Cid;
-
- for (i = 0; i < PspThreadNotifyRoutineCount; i++)
- {
- PspThreadNotifyRoutine[i](Cid.UniqueProcess, Cid.UniqueThread, Create);
- }
-}
-
-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(PspProcessNotifyRoutine[i])
- {
- PspProcessNotifyRoutine[i](ParentId, ProcessId, Create);
- }
- }
-}
-
-VOID
-STDCALL
-PspRunLoadImageNotifyRoutines(PUNICODE_STRING FullImageName,
- HANDLE ProcessId,
- PIMAGE_INFO ImageInfo)
-{
- ULONG i;
-
- for (i = 0; i < MAX_PROCESS_NOTIFY_ROUTINE_COUNT; ++ i)
- {
- if (PspLoadImageNotifyRoutine[i])
- {
- PspLoadImageNotifyRoutine[i](FullImageName, ProcessId, ImageInfo);
- }
- }
-}
-
-VOID
-STDCALL
-PspRunLegoRoutine(IN PKTHREAD Thread)
-{
- /* Call it */
- if (PspLegoNotifyRoutine) (PspLegoNotifyRoutine)(Thread);
+ /* Register this one */
+ PspThreadNotifyRoutine[PspThreadNotifyRoutineCount++] = NotifyRoutine;
+ return STATUS_SUCCESS;
}
/* EOF */
Propchange: trunk/reactos/ntoskrnl/ps/notify.c
------------------------------------------------------------------------------
--- svn:needs-lock (original)
+++ svn:needs-lock (removed)
@@ -1,1 +1,0 @@
-*