Author: ion Date: Thu Jul 20 20:26:10 2006 New Revision: 23194
URL: http://svn.reactos.org/svn/reactos?rev=23194&view=rev Log: - Move a bunch of externs to ps.h and delete many dupped/tripped ones. - Change FAST_MUTEX PsActiveProcessMutex to KGUARDED_MUTEX. - Define PS Flags and use them, isntead of magic numbers. (For magic mushrooms, you'll have to wait a while, these aren't implemented yet).
Modified: trunk/reactos/include/ndk/pstypes.h trunk/reactos/ntoskrnl/include/internal/dbgk.h trunk/reactos/ntoskrnl/include/internal/ps.h trunk/reactos/ntoskrnl/ps/idle.c trunk/reactos/ntoskrnl/ps/kill.c trunk/reactos/ntoskrnl/ps/process.c trunk/reactos/ntoskrnl/ps/psmgr.c trunk/reactos/ntoskrnl/ps/thread.c
Modified: trunk/reactos/include/ndk/pstypes.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/pstypes.h?rev=2... ============================================================================== --- trunk/reactos/include/ndk/pstypes.h (original) +++ trunk/reactos/include/ndk/pstypes.h Thu Jul 20 20:26:10 2006 @@ -179,6 +179,37 @@ #define STA_LPC_EXIT_THREAD_CALLED_BIT 0x2 #define STA_ADDRESS_SPACE_OWNER_BIT 0x4 #endif + +// +// Process Flags +// +#define PSF_CREATE_REPORTED_BIT 0x1 +#define PSF_NO_DEBUG_INHERIT_BIT 0x2 +#define PSF_PROCESS_EXITING_BIT 0x4 +#define PSF_PROCESS_DELETE_BIT 0x8 +#define PSF_WOW64_SPLIT_PAGES_BIT 0x10 +#define PSF_VM_DELETED_BIT 0x20 +#define PSF_OUTSWAP_ENABLED_BIT 0x40 +#define PSF_OUTSWAPPED_BIT 0x80 +#define PSF_FORK_FAILED_BIT 0x100 +#define PSF_WOW64_VA_SPACE_4GB_BIT 0x200 +#define PSF_ADDRESS_SPACE_INITIALIZED_BIT 0x400 +#define PSF_SET_TIMER_RESOLUTION_BIT 0x1000 +#define PSF_BREAK_ON_TERMINATION_BIT 0x2000 +#define PSF_SESSION_CREATION_UNDERWAY_BIT 0x4000 +#define PSF_WRITE_WATCH_BIT 0x8000 +#define PSF_PROCESS_IN_SESSION_BIT 0x10000 +#define PSF_OVERRIDE_ADDRESS_SPACE_BIT 0x20000 +#define PSF_HAS_ADDRESS_SPACE_BIT 0x40000 +#define PSF_LAUNCH_PREFETCHED_BIT 0x80000 +#define PSF_INJECT_INPAGE_ERRORS_BIT 0x100000 +#define PSF_VM_TOP_DOWN_BIT 0x200000 +#define PSF_IMAGE_NOTIFY_DONE_BIT 0x400000 +#define PSF_PDE_UPDATE_NEEDED_BIT 0x800000 +#define PSF_VDM_ALLOWED_BIT 0x1000000 +#define PSF_SWAP_ALLOWED_BIT 0x2000000 +#define PSF_CREATE_FAILED_BIT 0x4000000 +#define PSF_DEFAULT_IO_PRIORITY_BIT 0x8000000
#ifdef NTOS_MODE_USER //
Modified: trunk/reactos/ntoskrnl/include/internal/dbgk.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/d... ============================================================================== --- trunk/reactos/ntoskrnl/include/internal/dbgk.h (original) +++ trunk/reactos/ntoskrnl/include/internal/dbgk.h Thu Jul 20 20:26:10 2006 @@ -20,6 +20,7 @@ IN PEPROCESS Parent );
+extern POBJECT_TYPE DbgkDebugObjectType; #endif
/* EOF */
Modified: trunk/reactos/ntoskrnl/include/internal/ps.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/p... ============================================================================== --- trunk/reactos/ntoskrnl/include/internal/ps.h (original) +++ trunk/reactos/ntoskrnl/include/internal/ps.h Thu Jul 20 20:26:10 2006 @@ -390,9 +390,10 @@ extern PEPROCESS PsInitialSystemProcess; extern PEPROCESS PsIdleProcess; extern LIST_ENTRY PsActiveProcessHead; -extern FAST_MUTEX PspActiveProcessMutex; +extern KGUARDED_MUTEX PspActiveProcessMutex; extern LARGE_INTEGER ShortPsLockDelay, PsLockTimeout; extern EPROCESS_QUOTA_BLOCK PspDefaultQuotaBlock; +extern PHANDLE_TABLE PspCidTable; extern PCREATE_THREAD_NOTIFY_ROUTINE PspThreadNotifyRoutine[PSP_MAX_CREATE_THREAD_NOTIFY]; extern PCREATE_PROCESS_NOTIFY_ROUTINE @@ -401,6 +402,10 @@ PspLoadImageNotifyRoutine[PSP_MAX_LOAD_IMAGE_NOTIFY]; extern PLEGO_NOTIFY_ROUTINE PspLegoNotifyRoutine; extern ULONG PspThreadNotifyRoutineCount; +extern PKWIN32_PROCESS_CALLOUT PspW32ProcessCallout; +extern PKWIN32_THREAD_CALLOUT PspW32ThreadCallout; +extern PVOID PspSystemDllEntryPoint; +extern PVOID PspSystemDllBase;
#include "ps_x.h"
Modified: trunk/reactos/ntoskrnl/ps/idle.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/idle.c?rev=2319... ============================================================================== --- trunk/reactos/ntoskrnl/ps/idle.c (original) +++ trunk/reactos/ntoskrnl/ps/idle.c Thu Jul 20 20:26:10 2006 @@ -17,10 +17,6 @@ #if defined (ALLOC_PRAGMA) #pragma alloc_text(INIT, PsInitIdleThread) #endif - -/* GLOBALS *******************************************************************/ - -extern PEPROCESS PsIdleProcess;
/* FUNCTIONS *****************************************************************/
Modified: trunk/reactos/ntoskrnl/ps/kill.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/kill.c?rev=2319... ============================================================================== --- trunk/reactos/ntoskrnl/ps/kill.c (original) +++ trunk/reactos/ntoskrnl/ps/kill.c Thu Jul 20 20:26:10 2006 @@ -18,13 +18,6 @@
LIST_ENTRY PspReaperListHead = {0}; WORK_QUEUE_ITEM PspReaperWorkItem; -extern LIST_ENTRY PsActiveProcessHead; -extern FAST_MUTEX PspActiveProcessMutex; -extern PHANDLE_TABLE PspCidTable; -extern PKWIN32_PROCESS_CALLOUT PspW32ProcessCallout; -extern PKWIN32_THREAD_CALLOUT PspW32ThreadCallout; -extern PEPROCESS PsInitialSystemProcess; -extern PEPROCESS PsIdleProcess;
/* PRIVATE FUNCTIONS *********************************************************/
@@ -45,7 +38,7 @@ }
/* Set the delete flag */ - InterlockedOr((PLONG)&Process->Flags, 8); + InterlockedOr((PLONG)&Process->Flags, PSF_PROCESS_DELETE_BIT);
/* Get the first thread */ Thread = PsGetNextProcessThread(Process, Thread); @@ -147,9 +140,9 @@ if (Process->ActiveProcessLinks.Flink) { /* Remove it from the Active List */ - ExAcquireFastMutex(&PspActiveProcessMutex); + KeAcquireGuardedMutex(&PspActiveProcessMutex); RemoveEntryList(&Process->ActiveProcessLinks); - ExReleaseFastMutex(&PspActiveProcessMutex); + KeReleaseGuardedMutex(&PspActiveProcessMutex); }
/* Check for Auditing information */ @@ -401,7 +394,7 @@ if (!(--CurrentProcess->ActiveThreads)) { /* Set the delete flag */ - InterlockedOr((PLONG)&CurrentProcess->Flags, 8); + InterlockedOr((PLONG)&CurrentProcess->Flags, PSF_PROCESS_DELETE_BIT);
/* Remember we are last */ Last = TRUE; @@ -820,7 +813,7 @@ ASSERT_IRQL(PASSIVE_LEVEL);
/* Mark it as terminated */ - InterlockedOr((PLONG)&Thread->CrossThreadFlags, 1); + InterlockedOr((PLONG)&Thread->CrossThreadFlags, CT_TERMINATED_BIT);
/* Directly terminate the thread */ PspExitThread(ExitStatus); @@ -878,8 +871,8 @@ ULONG Actual; PAGED_CODE();
- /* Set Process Delete flag */ - InterlockedOr((PLONG)&Process->Flags, 4); + /* Set Process Exit flag */ + InterlockedOr((PLONG)&Process->Flags, PSF_PROCESS_EXITING_BIT);
/* Check if we are the last thread */ if (LastThread) @@ -992,8 +985,9 @@ /* Lock the Process */ ExAcquireRundownProtection(&Process->RundownProtect);
- /* Set the exit flag */ - if (!KillByHandle) InterlockedOr((PLONG)&Process->Flags, 8); + /* Set the delete flag */ + if (!KillByHandle) InterlockedOr((PLONG)&Process->Flags, + PSF_PROCESS_DELETE_BIT);
/* Get the first thread */ Status = STATUS_NOTHING_TO_TERMINATE;
Modified: trunk/reactos/ntoskrnl/ps/process.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/process.c?rev=2... ============================================================================== --- trunk/reactos/ntoskrnl/ps/process.c (original) +++ trunk/reactos/ntoskrnl/ps/process.c Thu Jul 20 20:26:10 2006 @@ -18,14 +18,12 @@ PEPROCESS PsInitialSystemProcess = NULL; PEPROCESS PsIdleProcess = NULL; POBJECT_TYPE PsProcessType = NULL; -extern PHANDLE_TABLE PspCidTable; -extern POBJECT_TYPE DbgkDebugObjectType;
EPROCESS_QUOTA_BLOCK PspDefaultQuotaBlock; ULONG PsMinimumWorkingSet, PsMaximumWorkingSet;
LIST_ENTRY PsActiveProcessHead; -FAST_MUTEX PspActiveProcessMutex; +KGUARDED_MUTEX PspActiveProcessMutex;
#if 1 LARGE_INTEGER ShortPsLockDelay, PsLockTimeout; @@ -182,7 +180,7 @@ PAGED_CODE();
/* Acquire the Active Process Lock */ - ExAcquireFastMutex(&PspActiveProcessMutex); + KeAcquireGuardedMutex(&PspActiveProcessMutex);
/* Check if we're already starting somewhere */ if (OldProcess) @@ -209,7 +207,7 @@ }
/* Release the lock */ - ExReleaseFastMutex(&PspActiveProcessMutex); + KeReleaseGuardedMutex(&PspActiveProcessMutex);
/* Reference the Process we had referenced earlier */ if (OldProcess) ObDereferenceObject(OldProcess); @@ -396,7 +394,7 @@ if (Flags & PS_NO_DEBUG_INHERIT) { /* Set the process flag */ - InterlockedOr((PLONG)&Process->Flags, 2); + InterlockedOr((PLONG)&Process->Flags, PSF_NO_DEBUG_INHERIT_BIT); } } else @@ -444,7 +442,7 @@ &DirectoryTableBase);
/* We now have an address space */ - InterlockedOr((PLONG)&Process->Flags, 0x40000); + InterlockedOr((PLONG)&Process->Flags, PSF_HAS_ADDRESS_SPACE_BIT);
/* Set the maximum WS */ Process->Vm.MaximumWorkingSetSize = MaxWs; @@ -524,9 +522,9 @@ }
/* The process can now be activated */ - ExAcquireFastMutex(&PspActiveProcessMutex); + KeAcquireGuardedMutex(&PspActiveProcessMutex); InsertTailList(&PsActiveProcessHead, &Process->ActiveProcessLinks); - ExReleaseFastMutex(&PspActiveProcessMutex); + KeReleaseGuardedMutex(&PspActiveProcessMutex);
/* FIXME: SeCreateAccessStateEx */
Modified: trunk/reactos/ntoskrnl/ps/psmgr.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/psmgr.c?rev=231... ============================================================================== --- trunk/reactos/ntoskrnl/ps/psmgr.c (original) +++ trunk/reactos/ntoskrnl/ps/psmgr.c Thu Jul 20 20:26:10 2006 @@ -157,7 +157,7 @@ ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &PsProcessType);
InitializeListHead(&PsActiveProcessHead); - ExInitializeFastMutex(&PspActiveProcessMutex); + KeInitializeGuardedMutex(&PspActiveProcessMutex);
/* * Initialize the default quota block.
Modified: trunk/reactos/ntoskrnl/ps/thread.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/thread.c?rev=23... ============================================================================== --- trunk/reactos/ntoskrnl/ps/thread.c (original) +++ trunk/reactos/ntoskrnl/ps/thread.c Thu Jul 20 20:26:10 2006 @@ -15,9 +15,6 @@
/* GLOBALS ******************************************************************/
-extern PVOID PspSystemDllEntryPoint; -extern PVOID PspSystemDllBase; -extern PHANDLE_TABLE PspCidTable; extern BOOLEAN CcPfEnablePrefetcher; extern ULONG MmReadClusterSize; POBJECT_TYPE PsThreadType = NULL;