mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 17:12:57 +00:00
- Call create process notify routines from NtCreateProcess.
- Protect PiProcessNotifyRoutine by a spinlock. - Started PsSetLoadImageNotifyRoutine implementation, it just registers the callback, but doesn't call it. svn path=/trunk/; revision=8575
This commit is contained in:
parent
fa397a0e33
commit
877788b63b
4 changed files with 92 additions and 3 deletions
|
@ -23,6 +23,22 @@ struct _KTHREAD;
|
||||||
|
|
||||||
typedef struct _KTHREAD *PKTHREAD, *PRKTHREAD;
|
typedef struct _KTHREAD *PKTHREAD, *PRKTHREAD;
|
||||||
|
|
||||||
|
typedef struct _IMAGE_INFO {
|
||||||
|
union {
|
||||||
|
ULONG Properties;
|
||||||
|
struct {
|
||||||
|
ULONG ImageAddressingMode : 8;
|
||||||
|
ULONG SystemModeImage : 1;
|
||||||
|
ULONG ImageMappedToAllPids : 1;
|
||||||
|
ULONG Reserved : 22;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
PVOID ImageBase;
|
||||||
|
ULONG ImageSelector;
|
||||||
|
ULONG ImageSize;
|
||||||
|
ULONG ImageSectionNumber;
|
||||||
|
} IMAGE_INFO, *PIMAGE_INFO;
|
||||||
|
|
||||||
typedef VOID STDCALL_FUNC
|
typedef VOID STDCALL_FUNC
|
||||||
(*PKSTART_ROUTINE)(PVOID StartContext);
|
(*PKSTART_ROUTINE)(PVOID StartContext);
|
||||||
|
|
||||||
|
@ -36,6 +52,11 @@ typedef VOID STDCALL_FUNC
|
||||||
HANDLE ThreadId,
|
HANDLE ThreadId,
|
||||||
BOOLEAN Create);
|
BOOLEAN Create);
|
||||||
|
|
||||||
|
typedef VOID STDCALL_FUNC
|
||||||
|
(*PLOAD_IMAGE_NOTIFY_ROUTINE)(PUNICODE_STRING FullImageName,
|
||||||
|
HANDLE ProcessId,
|
||||||
|
PIMAGE_INFO ImageInfo);
|
||||||
|
|
||||||
typedef NTSTATUS STDCALL_FUNC
|
typedef NTSTATUS STDCALL_FUNC
|
||||||
(*PW32_PROCESS_CALLBACK)(struct _EPROCESS *Process,
|
(*PW32_PROCESS_CALLBACK)(struct _EPROCESS *Process,
|
||||||
BOOLEAN Create);
|
BOOLEAN Create);
|
||||||
|
@ -59,4 +80,6 @@ struct _KPROCESS;
|
||||||
#define HIGH_PRIORITY (31)
|
#define HIGH_PRIORITY (31)
|
||||||
#define MAXIMUM_PRIORITY (32)
|
#define MAXIMUM_PRIORITY (32)
|
||||||
|
|
||||||
|
#define IMAGE_ADDRESSING_MODE_32BIT (3)
|
||||||
|
|
||||||
#endif /* __INCLUDE_DDK_PSTYPES_H */
|
#endif /* __INCLUDE_DDK_PSTYPES_H */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
; $Id: ntoskrnl.def,v 1.176 2004/03/06 22:21:20 dwelch Exp $
|
; $Id: ntoskrnl.def,v 1.177 2004/03/07 20:31:53 navaraf Exp $
|
||||||
;
|
;
|
||||||
; reactos/ntoskrnl/ntoskrnl.def
|
; reactos/ntoskrnl/ntoskrnl.def
|
||||||
;
|
;
|
||||||
|
@ -672,6 +672,7 @@ PsRevertToSelf@0
|
||||||
PsSetCreateProcessNotifyRoutine@8
|
PsSetCreateProcessNotifyRoutine@8
|
||||||
PsSetCreateThreadNotifyRoutine@4
|
PsSetCreateThreadNotifyRoutine@4
|
||||||
;PsSetLegoNotifyRoutine@4
|
;PsSetLegoNotifyRoutine@4
|
||||||
|
PsSetLoadImageNotifyRoutine@4
|
||||||
;PsSetProcessPriorityByClass@8
|
;PsSetProcessPriorityByClass@8
|
||||||
PsTerminateSystemThread@4
|
PsTerminateSystemThread@4
|
||||||
PsThreadType DATA
|
PsThreadType DATA
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
; $Id: ntoskrnl.edf,v 1.162 2004/03/06 22:21:20 dwelch Exp $
|
; $Id: ntoskrnl.edf,v 1.163 2004/03/07 20:31:53 navaraf Exp $
|
||||||
;
|
;
|
||||||
; reactos/ntoskrnl/ntoskrnl.def
|
; reactos/ntoskrnl/ntoskrnl.def
|
||||||
;
|
;
|
||||||
|
@ -673,6 +673,7 @@ PsRevertToSelf=PsRevertToSelf@0
|
||||||
PsSetCreateProcessNotifyRoutine=PsSetCreateProcessNotifyRoutine@8
|
PsSetCreateProcessNotifyRoutine=PsSetCreateProcessNotifyRoutine@8
|
||||||
PsSetCreateThreadNotifyRoutine=PsSetCreateThreadNotifyRoutine@4
|
PsSetCreateThreadNotifyRoutine=PsSetCreateThreadNotifyRoutine@4
|
||||||
;PsSetLegoNotifyRoutine
|
;PsSetLegoNotifyRoutine
|
||||||
|
PsSetLoadImageNotifyRoutine=PsSetLoadImageNotifyRoutine@4
|
||||||
;PsSetProcessPriorityByClass
|
;PsSetProcessPriorityByClass
|
||||||
PsTerminateSystemThread=PsTerminateSystemThread@4
|
PsTerminateSystemThread=PsTerminateSystemThread@4
|
||||||
PsThreadType DATA
|
PsThreadType DATA
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: process.c,v 1.124 2004/01/05 14:28:21 weiden Exp $
|
/* $Id: process.c,v 1.125 2004/03/07 20:31:53 navaraf Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -53,9 +53,15 @@ static GENERIC_MAPPING PiProcessMapping = {PROCESS_READ,
|
||||||
PROCESS_ALL_ACCESS};
|
PROCESS_ALL_ACCESS};
|
||||||
|
|
||||||
#define MAX_PROCESS_NOTIFY_ROUTINE_COUNT 8
|
#define MAX_PROCESS_NOTIFY_ROUTINE_COUNT 8
|
||||||
|
#define MAX_LOAD_IMAGE_NOTIFY_ROUTINE_COUNT 8
|
||||||
|
|
||||||
|
static KSPIN_LOCK PsNotifyListLock;
|
||||||
|
|
||||||
static PCREATE_PROCESS_NOTIFY_ROUTINE
|
static PCREATE_PROCESS_NOTIFY_ROUTINE
|
||||||
PiProcessNotifyRoutine[MAX_PROCESS_NOTIFY_ROUTINE_COUNT];
|
PiProcessNotifyRoutine[MAX_PROCESS_NOTIFY_ROUTINE_COUNT];
|
||||||
|
static PLOAD_IMAGE_NOTIFY_ROUTINE
|
||||||
|
PiLoadImageNotifyRoutine[MAX_LOAD_IMAGE_NOTIFY_ROUTINE_COUNT];
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
@ -268,6 +274,10 @@ PsInitProcessManagment(VOID)
|
||||||
|
|
||||||
InitializeListHead(&PsProcessListHead);
|
InitializeListHead(&PsProcessListHead);
|
||||||
KeInitializeSpinLock(&PsProcessListLock);
|
KeInitializeSpinLock(&PsProcessListLock);
|
||||||
|
KeInitializeSpinLock(&PsNotifyListLock);
|
||||||
|
|
||||||
|
RtlZeroMemory(PiProcessNotifyRoutine, sizeof(PiProcessNotifyRoutine));
|
||||||
|
RtlZeroMemory(PiLoadImageNotifyRoutine, sizeof(PiLoadImageNotifyRoutine));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize the system process
|
* Initialize the system process
|
||||||
|
@ -913,6 +923,8 @@ NtCreateProcess(OUT PHANDLE ProcessHandle,
|
||||||
&Message);
|
&Message);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
PspRunCreateProcessNotifyRoutines(Process, TRUE);
|
||||||
|
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
ObDereferenceObject(ParentProcess);
|
ObDereferenceObject(ParentProcess);
|
||||||
|
@ -1572,10 +1584,13 @@ PspRunCreateProcessNotifyRoutines
|
||||||
ULONG i;
|
ULONG i;
|
||||||
HANDLE ProcessId = (HANDLE)CurrentProcess->UniqueProcessId;
|
HANDLE ProcessId = (HANDLE)CurrentProcess->UniqueProcessId;
|
||||||
HANDLE ParentId = CurrentProcess->InheritedFromUniqueProcessId;
|
HANDLE ParentId = CurrentProcess->InheritedFromUniqueProcessId;
|
||||||
|
KIRQL oldIrql;
|
||||||
|
|
||||||
|
KeAcquireSpinLock(&PsNotifyListLock, &oldIrql);
|
||||||
for(i = 0; i < MAX_PROCESS_NOTIFY_ROUTINE_COUNT; ++ i)
|
for(i = 0; i < MAX_PROCESS_NOTIFY_ROUTINE_COUNT; ++ i)
|
||||||
if(PiProcessNotifyRoutine[i])
|
if(PiProcessNotifyRoutine[i])
|
||||||
PiProcessNotifyRoutine[i](ParentId, ProcessId, Create);
|
PiProcessNotifyRoutine[i](ParentId, ProcessId, Create);
|
||||||
|
KeReleaseSpinLock(&PsNotifyListLock, oldIrql);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1586,7 +1601,9 @@ PsSetCreateProcessNotifyRoutine(IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine,
|
||||||
IN BOOLEAN Remove)
|
IN BOOLEAN Remove)
|
||||||
{
|
{
|
||||||
ULONG i;
|
ULONG i;
|
||||||
|
KIRQL oldIrql;
|
||||||
|
|
||||||
|
KeAcquireSpinLock(&PsNotifyListLock, &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++)
|
||||||
|
@ -1598,6 +1615,7 @@ PsSetCreateProcessNotifyRoutine(IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KeReleaseSpinLock(&PsNotifyListLock, oldIrql);
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1611,6 +1629,8 @@ PsSetCreateProcessNotifyRoutine(IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KeReleaseSpinLock(&PsNotifyListLock, oldIrql);
|
||||||
|
|
||||||
if (i == MAX_PROCESS_NOTIFY_ROUTINE_COUNT)
|
if (i == MAX_PROCESS_NOTIFY_ROUTINE_COUNT)
|
||||||
{
|
{
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
@ -1619,4 +1639,48 @@ PsSetCreateProcessNotifyRoutine(IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine,
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID STDCALL
|
||||||
|
PspRunLoadImageNotifyRoutines(
|
||||||
|
PUNICODE_STRING FullImageName,
|
||||||
|
HANDLE ProcessId,
|
||||||
|
PIMAGE_INFO ImageInfo)
|
||||||
|
{
|
||||||
|
ULONG i;
|
||||||
|
KIRQL oldIrql;
|
||||||
|
|
||||||
|
KeAcquireSpinLock(&PsNotifyListLock, &oldIrql);
|
||||||
|
for (i = 0; i < MAX_PROCESS_NOTIFY_ROUTINE_COUNT; ++ i)
|
||||||
|
if (PiLoadImageNotifyRoutine[i])
|
||||||
|
PiLoadImageNotifyRoutine[i](FullImageName, ProcessId, ImageInfo);
|
||||||
|
KeReleaseSpinLock(&PsNotifyListLock, oldIrql);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
NTSTATUS STDCALL
|
||||||
|
PsSetLoadImageNotifyRoutine(IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine)
|
||||||
|
{
|
||||||
|
ULONG i;
|
||||||
|
KIRQL oldIrql;
|
||||||
|
|
||||||
|
KeAcquireSpinLock(&PsNotifyListLock, &oldIrql);
|
||||||
|
for (i = 0; i < MAX_LOAD_IMAGE_NOTIFY_ROUTINE_COUNT; i++)
|
||||||
|
{
|
||||||
|
if (PiLoadImageNotifyRoutine[i] == NULL)
|
||||||
|
{
|
||||||
|
PiLoadImageNotifyRoutine[i] = NotifyRoutine;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
KeReleaseSpinLock(&PsNotifyListLock, oldIrql);
|
||||||
|
|
||||||
|
if (i == MAX_PROCESS_NOTIFY_ROUTINE_COUNT)
|
||||||
|
{
|
||||||
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
}
|
||||||
|
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue