diff --git a/reactos/ntoskrnl/include/internal/ps.h b/reactos/ntoskrnl/include/internal/ps.h index ea9d996828c..c9203771f19 100644 --- a/reactos/ntoskrnl/include/internal/ps.h +++ b/reactos/ntoskrnl/include/internal/ps.h @@ -200,9 +200,6 @@ typedef struct _ROS_EPROCESS UCHAR PriorityClass; MM_AVL_TABLE VadRoot; ULONG Cookie; - KEVENT LockEvent; - ULONG LockCount; - struct _KTHREAD *LockOwner; MADDRESS_SPACE AddressSpace; } ROS_EPROCESS, *PROS_EPROCESS; #include diff --git a/reactos/ntoskrnl/ps/kill.c b/reactos/ntoskrnl/ps/kill.c index 15796650be2..3905a7bccae 100644 --- a/reactos/ntoskrnl/ps/kill.c +++ b/reactos/ntoskrnl/ps/kill.c @@ -14,6 +14,11 @@ #define NDEBUG #include +#define LockEvent Spare0[0] +#define LockCount Spare0[1] +#define LockOwner Spare0[2] + + /* GLOBALS *******************************************************************/ PETHREAD PspReaperList = NULL; @@ -159,6 +164,9 @@ PspDeleteProcess(PVOID ObjectBody) ExDestroyHandle(PspCidTable, Process->UniqueProcessId); } + /* Delete the process lock */ + ExFreePool(((PROS_EPROCESS)Process)->LockEvent); + /* KDB hook */ KDB_DELETEPROCESS_HOOK(Process); diff --git a/reactos/ntoskrnl/ps/process.c b/reactos/ntoskrnl/ps/process.c index ef6cda37626..88a6ce777db 100644 --- a/reactos/ntoskrnl/ps/process.c +++ b/reactos/ntoskrnl/ps/process.c @@ -14,6 +14,10 @@ #define NDEBUG #include +#define LockEvent Spare0[0] +#define LockCount Spare0[1] +#define LockOwner Spare0[2] + /* GLOBALS ******************************************************************/ PEPROCESS PsInitialSystemProcess = NULL; @@ -52,7 +56,7 @@ PsLockProcess(PROS_EPROCESS Process, BOOLEAN Timeout) /* we got the lock or already locked it */ if(InterlockedIncrementUL(&Process->LockCount) == 1) { - KeClearEvent(&Process->LockEvent); + KeClearEvent(Process->LockEvent); } return STATUS_SUCCESS; @@ -61,7 +65,7 @@ PsLockProcess(PROS_EPROCESS Process, BOOLEAN Timeout) { if(++Attempts > 2) { - Status = KeWaitForSingleObject(&Process->LockEvent, + Status = KeWaitForSingleObject(Process->LockEvent, Executive, KernelMode, FALSE, @@ -99,7 +103,7 @@ PsUnlockProcess(PROS_EPROCESS Process) if(InterlockedDecrementUL(&Process->LockCount) == 0) { (void)InterlockedExchangePointer(&Process->LockOwner, NULL); - KeSetEvent(&Process->LockEvent, IO_NO_INCREMENT, FALSE); + KeSetEvent(Process->LockEvent, IO_NO_INCREMENT, FALSE); } KeLeaveCriticalRegion(); @@ -325,7 +329,10 @@ PspCreateProcess(OUT PHANDLE ProcessHandle, /* Setup the Lock Event */ DPRINT("Initialzing Process Lock\n"); - KeInitializeEvent(&((PROS_EPROCESS)Process)->LockEvent, SynchronizationEvent, FALSE); + ((PROS_EPROCESS)Process)->LockEvent = ExAllocatePoolWithTag(PagedPool, + sizeof(KEVENT), + TAG('P', 's', 'L', 'k')); + KeInitializeEvent(((PROS_EPROCESS)Process)->LockEvent, SynchronizationEvent, FALSE); /* Setup the Thread List Head */ DPRINT("Initialzing Process ThreadListHead\n"); diff --git a/reactos/ntoskrnl/ps/psmgr.c b/reactos/ntoskrnl/ps/psmgr.c index a2824c84282..afca4259e4e 100644 --- a/reactos/ntoskrnl/ps/psmgr.c +++ b/reactos/ntoskrnl/ps/psmgr.c @@ -14,6 +14,10 @@ #define NDEBUG #include +#define LockEvent Spare0[0] +#define LockCount Spare0[1] +#define LockOwner Spare0[2] + extern LARGE_INTEGER ShortPsLockDelay, PsLockTimeout; extern LIST_ENTRY PriorityListHead[MAXIMUM_PRIORITY]; @@ -253,7 +257,9 @@ PsInitProcessManagment(VOID) MmInitializeAddressSpace((PROS_EPROCESS)PsInitialSystemProcess, &((PROS_EPROCESS)PsInitialSystemProcess)->AddressSpace); - KeInitializeEvent(&((PROS_EPROCESS)PsInitialSystemProcess)->LockEvent, SynchronizationEvent, FALSE); + ((PROS_EPROCESS)PsInitialSystemProcess)->LockEvent = + ExAllocatePoolWithTag(PagedPool, sizeof(KEVENT), TAG('P', 's', 'L', 'k')); + KeInitializeEvent(((PROS_EPROCESS)PsInitialSystemProcess)->LockEvent, SynchronizationEvent, FALSE); #if defined(__GNUC__) KProcess->DirectoryTableBase =