2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/include/ps_x.h
5 * PURPOSE: Intenral Inlined Functions for the Process Manager
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7 * Thomas Weidenmueller (w3seek@reactos.org)
11 // Extract Quantum Settings from the Priority Separation Mask
13 #define PspPrioritySeparationFromMask(Mask) \
16 #define PspQuantumTypeFromMask(Mask) \
19 #define PspQuantumLengthFromMask(Mask) \
23 // Cross Thread Flag routines
25 #define PspSetCrossThreadFlag(Thread, Flag) \
26 InterlockedOr((PLONG)&Thread->CrossThreadFlags, Flag)
27 #define PspClearCrossThreadFlag(Thread, Flag) \
28 InterlockedAnd((PLONG)&Thread->CrossThreadFlags, ~Flag)
32 PspRunCreateThreadNotifyRoutines(IN PETHREAD CurrentThread
,
37 /* Check if we have registered routines */
38 if (PspThreadNotifyRoutineCount
)
41 for (i
= 0; i
< PSP_MAX_CREATE_THREAD_NOTIFY
; i
++)
44 ExDoCallBack(&PspThreadNotifyRoutine
[i
],
45 CurrentThread
->Cid
.UniqueProcess
,
46 CurrentThread
->Cid
.UniqueThread
,
47 (PVOID
)(ULONG_PTR
)Create
);
54 PspRunCreateProcessNotifyRoutines(IN PEPROCESS CurrentProcess
,
59 /* Check if we have registered routines */
60 if (PspProcessNotifyRoutineCount
)
63 for (i
= 0; i
< PSP_MAX_CREATE_PROCESS_NOTIFY
; i
++)
66 ExDoCallBack(&PspProcessNotifyRoutine
[i
],
67 CurrentProcess
->InheritedFromUniqueProcessId
,
68 (PVOID
)(ULONG_PTR
)Create
,
76 PspRunLoadImageNotifyRoutines(PUNICODE_STRING FullImageName
,
78 PIMAGE_INFO ImageInfo
)
82 /* Loop the notify routines */
83 for (i
= 0; i
< PSP_MAX_LOAD_IMAGE_NOTIFY
; ++ i
)
86 ExDoCallBack(&PspLoadImageNotifyRoutine
[i
],
95 PspRunLegoRoutine(IN PKTHREAD Thread
)
98 if (PspLegoNotifyRoutine
) PspLegoNotifyRoutine(Thread
);
103 PspLockProcessSecurityShared(IN PEPROCESS Process
)
105 /* Enter a Critical Region */
106 KeEnterCriticalRegion();
108 /* Lock the Process */
109 ExAcquirePushLockShared(&Process
->ProcessLock
);
114 PspUnlockProcessSecurityShared(IN PEPROCESS Process
)
116 /* Unlock the Process */
117 ExReleasePushLockShared(&Process
->ProcessLock
);
119 /* Leave Critical Region */
120 KeLeaveCriticalRegion();
125 PspLockProcessSecurityExclusive(IN PEPROCESS Process
)
127 /* Enter a Critical Region */
128 KeEnterCriticalRegion();
130 /* Lock the Process */
131 ExAcquirePushLockExclusive(&Process
->ProcessLock
);
136 PspUnlockProcessSecurityExclusive(IN PEPROCESS Process
)
138 /* Unlock the Process */
139 ExReleasePushLockExclusive(&Process
->ProcessLock
);
141 /* Leave Critical Region */
142 KeLeaveCriticalRegion();
147 PspLockThreadSecurityShared(IN PETHREAD Thread
)
149 /* Enter a Critical Region */
150 KeEnterCriticalRegion();
152 /* Lock the Thread */
153 ExAcquirePushLockShared(&Thread
->ThreadLock
);
158 PspUnlockThreadSecurityShared(IN PETHREAD Thread
)
160 /* Unlock the Thread */
161 ExReleasePushLockShared(&Thread
->ThreadLock
);
163 /* Leave Critical Region */
164 KeLeaveCriticalRegion();
169 PspLockThreadSecurityExclusive(IN PETHREAD Thread
)
171 /* Enter a Critical Region */
172 KeEnterCriticalRegion();
174 /* Lock the Thread */
175 ExAcquirePushLockExclusive(&Thread
->ThreadLock
);
180 PspUnlockThreadSecurityExclusive(IN PETHREAD Thread
)
182 /* Unlock the Process */
183 ExReleasePushLockExclusive(&Thread
->ThreadLock
);
185 /* Leave Critical Thread */
186 KeLeaveCriticalRegion();
191 _PsGetCurrentProcess(VOID
)
193 /* Get the current process */
194 return (PEPROCESS
)KeGetCurrentThread()->ApcState
.Process
;