ReactOS 0.4.16-dev-205-g7b2bb7e
ps.h
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/include/internal/ps.h
5 * PURPOSE: Internal header for the Process Manager
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7 */
8
9//
10// Define this if you want debugging support
11//
12#define _PS_DEBUG_ 0x00
13
14//
15// These define the Debug Masks Supported
16//
17#define PS_THREAD_DEBUG 0x01
18#define PS_PROCESS_DEBUG 0x02
19#define PS_SECURITY_DEBUG 0x04
20#define PS_JOB_DEBUG 0x08
21#define PS_NOTIFICATIONS_DEBUG 0x10
22#define PS_WIN32K_DEBUG 0x20
23#define PS_STATE_DEBUG 0x40
24#define PS_QUOTA_DEBUG 0x80
25#define PS_KILL_DEBUG 0x100
26#define PS_REF_DEBUG 0x200
27
28//
29// Debug/Tracing support
30//
31#if _PS_DEBUG_
32#ifdef NEW_DEBUG_SYSTEM_IMPLEMENTED // enable when Debug Filters are implemented
33#define PSTRACE(x, ...) \
34 { \
35 DbgPrintEx("%s [%.16s] - ", \
36 __FUNCTION__, \
37 PsGetCurrentProcess()->ImageFileName); \
38 DbgPrintEx(__VA_ARGS__); \
39 }
40#else
41#define PSTRACE(x, ...) \
42 if (x & PspTraceLevel) \
43 { \
44 DbgPrint("%s [%.16s] - ", \
45 __FUNCTION__, \
46 PsGetCurrentProcess()->ImageFileName); \
47 DbgPrint(__VA_ARGS__); \
48 }
49#endif
50#define PSREFTRACE(x) \
51 PSTRACE(PS_REF_DEBUG, \
52 "Pointer Count [%p] @%d: %lx\n", \
53 x, \
54 __LINE__, \
55 OBJECT_TO_OBJECT_HEADER(x)->PointerCount)
56#else
57#define PSTRACE(x, fmt, ...) DPRINT(fmt, ##__VA_ARGS__)
58#define PSREFTRACE(x)
59#endif
60
61//
62// Maximum Count of Notification Routines
63//
64#define PSP_MAX_CREATE_THREAD_NOTIFY 8
65#define PSP_MAX_LOAD_IMAGE_NOTIFY 8
66#define PSP_MAX_CREATE_PROCESS_NOTIFY 8
67
68//
69// Maximum Job Scheduling Classes
70//
71#define PSP_JOB_SCHEDULING_CLASSES 10
72
73//
74// Process Quota Threshold Values
75//
76#define PSP_NON_PAGED_POOL_QUOTA_THRESHOLD 0x10000
77#define PSP_PAGED_POOL_QUOTA_THRESHOLD 0x80000
78
79//
80// Thread "Set/Get Context" Context Structure
81//
83{
89
90//
91// Initialization Functions
92//
93VOID
96 VOID
97);
98
99CODE_SEG("INIT")
101NTAPI
103 IN PLOADER_PARAMETER_BLOCK LoaderBlock
104);
105
106//
107// Utility Routines
108//
110NTAPI
114);
115
117NTAPI
119 IN PEPROCESS OldProcess OPTIONAL
120);
121
123NTAPI
126 OUT PVOID *DllBase,
127 IN BOOLEAN UseLargePages
128);
129
130CODE_SEG("INIT")
132NTAPI
134 VOID
135);
136
137VOID
138NTAPI
140 IN BOOLEAN Immediate,
141 IN ULONG PrioritySeparation
142);
143
145NTAPI
149);
150
151//
152// Process Routines
153//
155NTAPI
160 IN HANDLE ParentProcess OPTIONAL,
161 IN ULONG Flags,
162 IN HANDLE SectionHandle OPTIONAL,
163 IN HANDLE DebugPort OPTIONAL,
164 IN HANDLE ExceptionPort OPTIONAL,
165 IN BOOLEAN InJob
166);
167
168//
169// Security Routines
170//
172NTAPI
178);
179
181NTAPI
185);
186
188NTAPI
193);
194
196NTAPI
200);
201
202VOID
203NTAPI
206);
207
208VOID
209NTAPI
212);
213
214//
215// Reaping and Deletion
216//
217VOID
218NTAPI
220 PKAPC Apc,
221 PKNORMAL_ROUTINE *NormalRoutine,
222 PVOID *NormalContext,
225);
226
227VOID
228NTAPI
231);
232
233VOID
234NTAPI
237);
238
240NTAPI
244 IN BOOLEAN bSelf
245);
246
247VOID
248NTAPI
252);
253
255NTAPI
259);
260
261VOID
262NTAPI
264 IN PVOID ObjectBody
265);
266
267VOID
268NTAPI
270 IN PVOID ObjectBody
271);
272
273//
274// Thread/Process Startup
275//
276VOID
277NTAPI
280 PVOID StartContext
281);
282
283VOID
284NTAPI
287);
288
289//
290// Quota Support
291//
292VOID
293NTAPI
296 _In_ PEPROCESS ParentProcess
297);
298
299VOID
300NTAPI
303 _In_ PEPROCESS_QUOTA_BLOCK QuotaBlock
304);
305
307NTAPI
311);
312
314NTAPI
318);
319
320VOID
321NTAPI
323 _In_ PEPROCESS_QUOTA_BLOCK QuotaBlock,
324 _In_ SIZE_T AmountToReturnPaged,
325 _In_ SIZE_T AmountToReturnNonPaged
326);
327
329NTAPI
332 _In_ SIZE_T AmountToChargePaged,
333 _In_ SIZE_T AmountToChargeNonPaged
334);
335
337NTAPI
341 _In_ PVOID QuotaLimits,
342 _In_ ULONG QuotaLimitsLength,
344
345#if defined(_X86_)
346//
347// VDM and LDT Support
348//
349VOID
350NTAPI
353);
354
355VOID
356NTAPI
359);
360
362NTAPI
365 IN PVOID ThreadInformation,
368);
369#endif
370
371//
372// Job Routines
373//
374VOID
375NTAPI
377 IN PEJOB Job,
379);
380
381VOID
382NTAPI
385 IN PEJOB Job
386);
387
388CODE_SEG("INIT")
389VOID
390NTAPI
392 VOID
393);
394
395VOID
396NTAPI
398 IN PVOID ObjectBody
399);
400
401//
402// State routines
403//
405NTAPI
408 OUT PULONG PreviousCount OPTIONAL
409);
410
412NTAPI
415 OUT PULONG PreviousCount OPTIONAL
416);
417
418VOID
419NTAPI
421 IN PKAPC Apc,
422 IN OUT PKNORMAL_ROUTINE* NormalRoutine,
423 IN OUT PVOID* NormalContext,
426);
427
429NTAPI
431
432//
433// Apphelp functions
434//
435CODE_SEG("INIT")
437NTAPI
439
440VOID
441NTAPI
443
444//
445// Global data inside the Process Manager
446//
447extern ULONG PspTraceLevel;
452extern BOOLEAN PspReaping;
483
484//
485// Inlined Functions
486//
487#include "ps_x.h"
#define CODE_SEG(...)
unsigned char BOOLEAN
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:732
LONG NTSTATUS
Definition: precomp.h:26
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:43
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
ULONG ERESOURCE
Definition: env_spec_w32.h:594
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
_Must_inspect_result_ _In_ LONGLONG _In_ LONGLONG Amount
Definition: fsrtlfuncs.h:551
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
VOID(NTAPI * PLEGO_NOTIFY_ROUTINE)(_In_ PKTHREAD Thread)
Definition: pstypes.h:618
NTSTATUS(NTAPI * PKWIN32_PROCESS_CALLOUT)(_In_ struct _EPROCESS *Process, _In_ BOOLEAN Create)
Definition: pstypes.h:525
NTSTATUS(NTAPI * PKWIN32_THREAD_CALLOUT)(_In_ struct _ETHREAD *Thread, _In_ PSW32THREADCALLOUTTYPE Type)
Definition: pstypes.h:532
#define Unused(x)
Definition: atlwin.h:28
enum _SECURITY_IMPERSONATION_LEVEL * PSECURITY_IMPERSONATION_LEVEL
#define _In_
Definition: ms_sal.h:308
#define _In_opt_
Definition: ms_sal.h:309
VOID(NTAPI * PKNORMAL_ROUTINE)(IN PVOID NormalContext OPTIONAL, IN PVOID SystemArgument1 OPTIONAL, IN PVOID SystemArgument2 OPTIONAL)
Definition: ketypes.h:744
_In_ HANDLE ProcessHandle
Definition: mmfuncs.h:403
_In_ NTSTATUS ExitStatus
Definition: psfuncs.h:867
_In_ ACCESS_MASK _In_ ULONG _Out_ PHANDLE TokenHandle
Definition: psfuncs.h:726
_In_ THREADINFOCLASS _In_ ULONG ThreadInformationLength
Definition: psfuncs.h:843
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_ BOOLEAN EffectiveOnly
Definition: sefuncs.h:410
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_ BOOLEAN _In_ TOKEN_TYPE TokenType
Definition: sefuncs.h:411
ULONG ACCESS_MASK
Definition: nt_native.h:40
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:455
PETHREAD LastThread
Definition: pinsup.c:109
NTSTATUS NTAPI PsOpenTokenOfProcess(IN HANDLE ProcessHandle, OUT PACCESS_TOKEN *Token)
Definition: security.c:471
VOID NTAPI PsReturnSharedPoolQuota(_In_ PEPROCESS_QUOTA_BLOCK QuotaBlock, _In_ SIZE_T AmountToReturnPaged, _In_ SIZE_T AmountToReturnNonPaged)
Returns the shared (paged and non paged) pool quotas. The function is used exclusively by the Object ...
Definition: quota.c:621
POBJECT_TYPE _PsProcessType
Definition: ps.h:473
LIST_ENTRY PspReaperListHead
Definition: kill.c:19
ULONG PspTraceLevel
Definition: query.c:18
NTSTATUS NTAPI PsSuspendThread(IN PETHREAD Thread, OUT PULONG PreviousCount OPTIONAL)
Definition: state.c:48
EX_CALLBACK PspLoadImageNotifyRoutine[PSP_MAX_LOAD_IMAGE_NOTIFY]
Definition: psnotify.c:23
PVOID PspSystemDllEntryPoint
Definition: psmgr.c:43
VOID NTAPI PspRemoveProcessFromJob(IN PEPROCESS Process, IN PEJOB Job)
Definition: job.c:138
KSPIN_LOCK PsLoadedModuleSpinLock
Definition: sysldr.c:23
LIST_ENTRY PsLoadedModuleList
Definition: sysldr.c:21
NTSTATUS NTAPI PspSetPrimaryToken(IN PEPROCESS Process, IN HANDLE TokenHandle OPTIONAL, IN PACCESS_TOKEN Token OPTIONAL)
Definition: security.c:215
NTSTATUS NTAPI PspSetQuotaLimits(_In_ PEPROCESS Process, _In_ ULONG Unused, _In_ PVOID QuotaLimits, _In_ ULONG QuotaLimitsLength, _In_ KPROCESSOR_MODE PreviousMode)
This function adjusts the working set limits of a process and sets up new quota limits when necessary...
Definition: quota.c:1045
VOID NTAPI ApphelpCacheShutdown(VOID)
Definition: apphelp.c:465
PLEGO_NOTIFY_ROUTINE PspLegoNotifyRoutine
Definition: psnotify.c:24
VOID NTAPI PspDeleteProcess(IN PVOID ObjectBody)
Definition: kill.c:253
PKWIN32_THREAD_CALLOUT PspW32ThreadCallout
Definition: win32.c:19
PACCESS_TOKEN NTAPI PsReferenceEffectiveToken(IN PETHREAD Thread, OUT IN PTOKEN_TYPE TokenType, OUT PBOOLEAN EffectiveOnly, OUT PSECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
Definition: security.c:802
NTSTATUS NTAPI PsTerminateProcess(IN PEPROCESS Process, IN NTSTATUS ExitStatus)
Definition: kill.c:126
NTSTATUS NTAPI PsChargeProcessPageFileQuota(_In_ PEPROCESS Process, _In_ SIZE_T Amount)
Charges the process page file quota. The function is used internally by the kernel.
Definition: quota.c:738
VOID NTAPI PspSystemThreadStartup(PKSTART_ROUTINE StartRoutine, PVOID StartContext)
VOID NTAPI PspExitProcessFromJob(IN PEJOB Job, IN PEPROCESS Process)
Definition: job.c:146
BOOLEAN NTAPI PspIsProcessExiting(IN PEPROCESS Process)
Definition: kill.c:1068
VOID NTAPI PspExitThread(IN NTSTATUS ExitStatus)
Definition: kill.c:450
VOID NTAPI PspInitializeJobStructures(VOID)
Definition: job.c:111
ERESOURCE PsLoadedModuleResource
Definition: sysldr.c:24
UNICODE_STRING PsNtDllPathName
Definition: psmgr.c:45
PKWIN32_PROCESS_CALLOUT PspW32ProcessCallout
Definition: win32.c:18
VOID NTAPI PspGetOrSetContextKernelRoutine(IN PKAPC Apc, IN OUT PKNORMAL_ROUTINE *NormalRoutine, IN OUT PVOID *NormalContext, IN OUT PVOID *SystemArgument1, IN OUT PVOID *SystemArgument2)
Definition: psctx.c:38
NTSTATUS NTAPI PspInitializeProcessSecurity(IN PEPROCESS Process, IN PEPROCESS Parent OPTIONAL)
Definition: security.c:71
#define PSP_MAX_CREATE_PROCESS_NOTIFY
Definition: ps.h:66
ULONG PspProcessNotifyRoutineCount
Definition: ps.h:463
PHANDLE_TABLE PspCidTable
Definition: psmgr.c:48
BOOLEAN NTAPI PsInitSystem(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: psmgr.c:532
EX_CALLBACK PspThreadNotifyRoutine[PSP_MAX_CREATE_THREAD_NOTIFY]
Definition: psnotify.c:21
NTSTATUS NTAPI PspTerminateThreadByPointer(IN PETHREAD Thread, IN NTSTATUS ExitStatus, IN BOOLEAN bSelf)
Definition: kill.c:988
VOID NTAPI PspShutdownProcessManager(VOID)
Definition: kill.c:135
LCID PsDefaultSystemLocaleId
Definition: locale.c:20
PEPROCESS_QUOTA_BLOCK NTAPI PsChargeSharedPoolQuota(_In_ PEPROCESS Process, _In_ SIZE_T AmountToChargePaged, _In_ SIZE_T AmountToChargeNonPaged)
Charges the shared (paged and non paged) pool quotas. The function is used exclusively by the Object ...
Definition: quota.c:674
VOID NTAPI PspDereferenceQuotaBlock(_In_opt_ PEPROCESS Process, _In_ PEPROCESS_QUOTA_BLOCK QuotaBlock)
De-references a quota block when quotas have been returned back because of an object de-allocation or...
Definition: quota.c:553
#define PSP_JOB_SCHEDULING_CLASSES
Definition: ps.h:71
NTSTATUS NTAPI PspCreateProcess(OUT PHANDLE ProcessHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN HANDLE ParentProcess OPTIONAL, IN ULONG Flags, IN HANDLE SectionHandle OPTIONAL, IN HANDLE DebugPort OPTIONAL, IN HANDLE ExceptionPort OPTIONAL, IN BOOLEAN InJob)
Definition: process.c:347
ULONG PspThreadNotifyRoutineCount
Definition: psnotify.c:19
NTSTATUS NTAPI PsReferenceProcessFilePointer(IN PEPROCESS Process, OUT PFILE_OBJECT *FileObject)
Definition: query.c:24
VOID NTAPI PspDeleteProcessSecurity(IN PEPROCESS Process)
Definition: security.c:30
PETHREAD NTAPI PsGetNextProcessThread(IN PEPROCESS Process, IN PETHREAD Thread OPTIONAL)
Definition: process.c:75
BOOLEAN PspUseJobSchedulingClasses
Definition: job.c:25
LIST_ENTRY PsActiveProcessHead
Definition: process.c:22
NTSTATUS NTAPI PsResumeThread(IN PETHREAD Thread, OUT PULONG PreviousCount OPTIONAL)
Definition: state.c:32
struct _GET_SET_CTX_CONTEXT GET_SET_CTX_CONTEXT
BOOLEAN PsImageNotifyEnabled
Definition: psnotify.c:18
NTSTATUS NTAPI PsReturnProcessPageFileQuota(_In_ PEPROCESS Process, _In_ SIZE_T Amount)
Returns the page file quota that the process was taking up. The function is used exclusively by the k...
Definition: quota.c:993
struct _GET_SET_CTX_CONTEXT * PGET_SET_CTX_CONTEXT
BOOLEAN PspReaping
ULONG PsPrioritySeparation
Definition: process.c:28
EPROCESS_QUOTA_BLOCK PspDefaultQuotaBlock
Definition: quota.c:16
VOID NTAPI PsChangeQuantumTable(IN BOOLEAN Immediate, IN ULONG PrioritySeparation)
Definition: process.c:235
NTSTATUS NTAPI ApphelpCacheInitialize(VOID)
Definition: apphelp.c:439
VOID NTAPI PspDeleteThread(IN PVOID ObjectBody)
Definition: kill.c:391
VOID NTAPI PspDeleteJob(IN PVOID ObjectBody)
VOID NTAPI PsIdleThreadMain(IN PVOID Context)
CHAR PspJobSchedulingClasses[PSP_JOB_SCHEDULING_CLASSES]
Definition: job.c:27
ULONG PsRawPrioritySeparation
Definition: process.c:27
PVOID PspSystemDllBase
Definition: psmgr.c:41
#define PSP_MAX_LOAD_IMAGE_NOTIFY
Definition: ps.h:65
#define PSP_MAX_CREATE_THREAD_NOTIFY
Definition: ps.h:64
LARGE_INTEGER ShortPsLockDelay
Definition: ps.h:477
LCID PsDefaultThreadLocaleId
Definition: locale.c:24
POBJECT_TYPE _PsThreadType
PTOKEN PspBootAccessToken
Definition: security.c:17
PEPROCESS NTAPI PsGetNextProcess(IN PEPROCESS OldProcess OPTIONAL)
Definition: process.c:128
VOID NTAPI PsExitSpecialApc(PKAPC Apc, PKNORMAL_ROUTINE *NormalRoutine, PVOID *NormalContext, PVOID *SystemArgument1, PVOID *SystemArgument2)
GENERIC_MAPPING PspJobMapping
Definition: job.c:41
WORK_QUEUE_ITEM PspReaperWorkItem
Definition: kill.c:20
VOID NTAPI PspReapRoutine(IN PVOID Context)
Definition: kill.c:167
NTSTATUS NTAPI PspMapSystemDll(IN PEPROCESS Process, OUT PVOID *DllBase, IN BOOLEAN UseLargePages)
KGUARDED_MUTEX PspActiveProcessMutex
Definition: process.c:23
VOID NTAPI PspInheritQuota(_In_ PEPROCESS Process, _In_ PEPROCESS ParentProcess)
PEPROCESS PsIdleProcess
Definition: psmgr.c:51
VOID NTAPI PspDeleteThreadSecurity(IN PETHREAD Thread)
Definition: security.c:46
VOID NTAPI PspExitProcess(IN BOOLEAN LastThread, IN PEPROCESS Process)
Definition: kill.c:1075
NTSTATUS NTAPI PsLocateSystemDll(VOID)
Definition: psmgr.c:187
ULONG_PTR PsNtosImageBase
Definition: sysldr.c:25
EX_CALLBACK PspProcessNotifyRoutine[PSP_MAX_CREATE_PROCESS_NOTIFY]
Definition: psnotify.c:22
POBJECT_TYPE PsJobType
Definition: job.c:20
VOID NTAPI PspDeleteLdt(PEPROCESS Process)
Definition: psldt.c:19
NTSTATUS NTAPI PspQueryDescriptorThread(IN PETHREAD Thread, IN PVOID ThreadInformation, IN ULONG ThreadInformationLength, OUT PULONG ReturnLength OPTIONAL)
Definition: psldt.c:43
VOID NTAPI PspDeleteVdmObjects(PEPROCESS Process)
Definition: psldt.c:27
DWORD LCID
Definition: nls.h:13
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
CONTEXT Context
Definition: ps.h:87
KEVENT Event
Definition: ps.h:85
KPROCESSOR_MODE Mode
Definition: ps.h:86
Definition: ketypes.h:547
Definition: typedefs.h:120
uint32_t * PULONG
Definition: typedefs.h:59
unsigned char * PBOOLEAN
Definition: typedefs.h:53
#define NTAPI
Definition: typedefs.h:36
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
* PFILE_OBJECT
Definition: iotypes.h:1998
KSTART_ROUTINE * PKSTART_ROUTINE
Definition: ketypes.h:499
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
_In_opt_ PVOID _In_opt_ PVOID SystemArgument1
Definition: ketypes.h:688
_In_opt_ PVOID _In_opt_ PVOID _In_opt_ PVOID SystemArgument2
Definition: ketypes.h:689
_Out_ PBOOLEAN _Out_ PBOOLEAN _Out_ PSECURITY_IMPERSONATION_LEVEL ImpersonationLevel
Definition: psfuncs.h:156
_In_ ULONG _In_opt_ POBJECT_ATTRIBUTES _In_opt_ HANDLE _Out_opt_ PCLIENT_ID _In_ PKSTART_ROUTINE StartRoutine
Definition: psfuncs.h:91
_In_ KPROCESSOR_MODE PreviousMode
Definition: sefuncs.h:103
enum _TOKEN_TYPE * PTOKEN_TYPE
char CHAR
Definition: xmlstorage.h:175