Implemented KeAreApcsDisabled, KeFlushEntireTb, KeIsExecutingDpc, KeSetKernelStackSwa...
[reactos.git] / reactos / ntoskrnl / include / internal / ps.h
1 /*
2 * ReactOS kernel
3 * Copyright (C) 2000 David Welch <welch@cwcom.net>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 /* $Id: ps.h,v 1.71 2004/10/13 01:42:14 ion Exp $
20 *
21 * FILE: ntoskrnl/ke/kthread.c
22 * PURPOSE: Process manager definitions
23 * PROGRAMMER: David Welch (welch@cwcom.net)
24 * UPDATE HISTORY:
25 * Created 22/05/98
26 */
27
28 #ifndef __INCLUDE_INTERNAL_PS_H
29 #define __INCLUDE_INTERNAL_PS_H
30
31 #ifndef __ASM__
32
33 /* Forward declarations. */
34 struct _KTHREAD;
35 struct _KTRAPFRAME;
36 struct _EJOB;
37
38 #endif /* __ASM__ */
39
40 #include <internal/arch/ps.h>
41
42 #ifndef __ASM__
43
44 #include <internal/mm.h>
45 #include <napi/teb.h>
46
47 #ifndef KeGetCurrentProcessorNumber
48 #define KeGetCurrentProcessorNumber() (KeGetCurrentKPCR()->ProcessorNumber)
49 #endif
50
51 extern HANDLE SystemProcessHandle;
52
53 extern LCID PsDefaultThreadLocaleId;
54 extern LCID PsDefaultSystemLocaleId;
55
56 #ifndef __USE_W32API
57
58 #include <pshpack1.h>
59
60 typedef struct _KAPC_STATE
61 {
62 LIST_ENTRY ApcListHead[2];
63 struct _KPROCESS* Process;
64 UCHAR KernelApcInProgress;
65 UCHAR KernelApcPending;
66 UCHAR UserApcPending;
67 UCHAR Reserved;
68 } KAPC_STATE, *PKAPC_STATE, *__restrict PRKAPC_STATE;
69
70 #include <poppack.h>
71
72 #endif /* __USE_W32API */
73
74 #include <pshpack1.h>
75
76 typedef struct _KTHREAD
77 {
78 /* For waiting on thread exit */
79 DISPATCHER_HEADER DispatcherHeader; /* 00 */
80
81 /* List of mutants owned by the thread */
82 LIST_ENTRY MutantListHead; /* 10 */
83 PVOID InitialStack; /* 18 */
84 ULONG StackLimit; /* 1C */
85
86 /* Pointer to the thread's environment block in user memory */
87 PTEB Teb; /* 20 */
88
89 /* Pointer to the thread's TLS array */
90 PVOID TlsArray; /* 24 */
91 PVOID KernelStack; /* 28 */
92 UCHAR DebugActive; /* 2C */
93
94 /* Thread state (one of THREAD_STATE_xxx constants below) */
95 UCHAR State; /* 2D */
96 UCHAR Alerted[2]; /* 2E */
97 UCHAR Iopl; /* 30 */
98 UCHAR NpxState; /* 31 */
99 CHAR Saturation; /* 32 */
100 CHAR Priority; /* 33 */
101 KAPC_STATE ApcState; /* 34 */
102 ULONG ContextSwitches; /* 4C */
103 LONG WaitStatus; /* 50 */
104 KIRQL WaitIrql; /* 54 */
105 CHAR WaitMode; /* 55 */
106 UCHAR WaitNext; /* 56 */
107 UCHAR WaitReason; /* 57 */
108 PKWAIT_BLOCK WaitBlockList; /* 58 */
109 LIST_ENTRY WaitListEntry; /* 5C */
110 ULONG WaitTime; /* 64 */
111 CHAR BasePriority; /* 68 */
112 UCHAR DecrementCount; /* 69 */
113 UCHAR PriorityDecrement; /* 6A */
114 UCHAR Quantum; /* 6B */
115 KWAIT_BLOCK WaitBlock[4]; /* 6C */
116 PVOID LegoData; /* CC */
117 ULONG KernelApcDisable; /* D0 */
118 KAFFINITY UserAffinity; /* D4 */
119 UCHAR SystemAffinityActive;/* D8 */
120 UCHAR PowerState; /* D9 */
121 UCHAR NpxIrql; /* DA */
122 UCHAR Pad[1]; /* DB */
123 SSDT_ENTRY *ServiceTable; /* DC */
124 PKQUEUE Queue; /* E0 */
125 KSPIN_LOCK ApcQueueLock; /* E4 */
126 KTIMER Timer; /* E8 */
127 LIST_ENTRY QueueListEntry; /* 110 */
128 KAFFINITY Affinity; /* 118 */
129 UCHAR Preempted; /* 11C */
130 UCHAR ProcessReadyQueue; /* 11D */
131 UCHAR KernelStackResident; /* 11E */
132 UCHAR NextProcessor; /* 11F */
133 PVOID CallbackStack; /* 120 */
134 struct _W32THREAD *Win32Thread; /* 124 */
135 struct _KTRAP_FRAME *TrapFrame; /* 128 */
136 PKAPC_STATE ApcStatePointer[2]; /* 12C */
137 UCHAR EnableStackSwap; /* 134 */
138 UCHAR LargeStack; /* 135 */
139 UCHAR ResourceIndex; /* 136 */
140 UCHAR PreviousMode; /* 137 */
141 ULONG KernelTime; /* 138 */
142 ULONG UserTime; /* 13C */
143 KAPC_STATE SavedApcState; /* 140 */
144 UCHAR Alertable; /* 158 */
145 UCHAR ApcStateIndex; /* 159 */
146 UCHAR ApcQueueable; /* 15A */
147 UCHAR AutoAlignment; /* 15B */
148 PVOID StackBase; /* 15C */
149 KAPC SuspendApc; /* 160 */
150 KSEMAPHORE SuspendSemaphore; /* 190 */
151 LIST_ENTRY ThreadListEntry; /* 1A4 */
152 CHAR FreezeCount; /* 1AC */
153 UCHAR SuspendCount; /* 1AD */
154 UCHAR IdealProcessor; /* 1AE */
155 UCHAR DisableBoost; /* 1AF */
156 } KTHREAD;
157
158 #include <poppack.h>
159
160 /* Top level irp definitions. */
161 #define FSRTL_FSP_TOP_LEVEL_IRP (0x01)
162 #define FSRTL_CACHE_TOP_LEVEL_IRP (0x02)
163 #define FSRTL_MOD_WRITE_TOP_LEVEL_IRP (0x03)
164 #define FSRTL_FAST_IO_TOP_LEVEL_IRP (0x04)
165 #define FSRTL_MAX_TOP_LEVEL_IRP_FLAG (0x04)
166
167 #ifndef __USE_W32API
168 typedef struct
169 {
170 PACCESS_TOKEN Token;
171 BOOLEAN CopyOnOpen;
172 BOOLEAN EffectiveOnly;
173 SECURITY_IMPERSONATION_LEVEL Level;
174 } PS_IMPERSONATION_INFORMATION, *PPS_IMPERSONATION_INFORMATION;
175 #endif
176
177 #include <pshpack1.h>
178
179 typedef struct _ETHREAD
180 {
181 KTHREAD Tcb;
182 TIME CreateTime;
183 USHORT NestedFaultCount;
184 UCHAR ApcNeeded;
185 TIME ExitTime;
186 LIST_ENTRY LpcReplyChain;
187 NTSTATUS ExitStatus;
188 PVOID OfsChain;
189 LIST_ENTRY PostBlockList;
190 LIST_ENTRY TerminationPortList;
191 KSPIN_LOCK ActiveTimerListLock;
192 LIST_ENTRY ActiveTimerListHead;
193 CLIENT_ID Cid;
194 KSEMAPHORE LpcReplySemaphore;
195 PVOID LpcReplyMessage;
196 ULONG LpcReplyMessageId;
197 ULONG PerformanceCountLow;
198 PPS_IMPERSONATION_INFORMATION ImpersonationInfo;
199 LIST_ENTRY IrpList;
200 PIRP TopLevelIrp;
201 PDEVICE_OBJECT DeviceToVerify;
202 ULONG ReadClusterSize;
203 UCHAR ForwardClusterOnly;
204 UCHAR DisablePageFaultClustering;
205 UCHAR DeadThread;
206 UCHAR HideFromDebugger;
207 ULONG HasTerminated;
208 #ifdef _ENABLE_THRDEVTPAIR
209 PVOID EventPair;
210 #endif /* _ENABLE_THRDEVTPAIR */
211 ACCESS_MASK GrantedAccess;
212 struct _EPROCESS *ThreadsProcess;
213 PKSTART_ROUTINE StartAddress;
214 LPTHREAD_START_ROUTINE Win32StartAddress;
215 ULONG LpcReceivedMessageId;
216 UCHAR LpcExitThreadCalled;
217 UCHAR HardErrorsAreDisabled;
218 UCHAR LpcReceivedMsgIdValid;
219 UCHAR ActiveImpersonationInfo;
220 ULONG PerformanceCountHigh;
221 LIST_ENTRY ThreadListEntry;
222 } ETHREAD;
223
224 #include <poppack.h>
225
226
227 #ifndef __USE_W32API
228
229 typedef struct _ETHREAD *PETHREAD;
230
231 #endif /* __USE_W32API */
232
233
234 typedef struct _KPROCESS
235 {
236 /* So it's possible to wait for the process to terminate */
237 DISPATCHER_HEADER DispatcherHeader; /* 000 */
238 /*
239 * Presumably a list of profile objects associated with this process,
240 * currently unused.
241 */
242 LIST_ENTRY ProfileListHead; /* 010 */
243 /*
244 * We use the first member of this array to hold the physical address of
245 * the page directory for this process.
246 */
247 PHYSICAL_ADDRESS DirectoryTableBase; /* 018 */
248 /*
249 * Presumably a descriptor for the process's LDT, currently unused.
250 */
251 ULONG LdtDescriptor[2]; /* 020 */
252 /*
253 * Virtual Dos Machine flag.
254 */
255 ULONG NtVdmFlag; /* 028 */
256 ULONG VdmUnused; /* 02C */
257 /* Is the i/o permission map enabled for the process. */
258 USHORT IopmOffset; /* 030 */
259 /*
260 * Presumably I/O privilege level to be used for this process, currently
261 * unused.
262 */
263 UCHAR Iopl; /* 032 */
264 /* Set if this process is a virtual dos machine? */
265 UCHAR VdmFlag; /* 033 */
266 /* Bitmask of the processors being used by this process's threads? */
267 ULONG ActiveProcessors; /* 034 */
268 /* Aggregate of the time this process's threads have spent in kernel mode? */
269 ULONG KernelTime; /* 038 */
270 /* Aggregate of the time this process's threads have spent in user mode? */
271 ULONG UserTime; /* 03C */
272 /* List of this process's threads that are ready for execution? */
273 LIST_ENTRY ReadyListHead; /* 040 */
274 /* List of this process's threads that have their stacks swapped out? */
275 LIST_ENTRY SwapListEntry; /* 048 */
276 /* List of this process's threads? */
277 LIST_ENTRY ThreadListHead; /* 050 */
278 /* Maybe a lock for this data structure, the type is assumed. */
279 KSPIN_LOCK ProcessLock; /* 058 */
280 /* Default affinity mask for this process's threads? */
281 ULONG Affinity; /* 05C */
282 /* Count of the stacks allocated for this process's threads? */
283 USHORT StackCount; /* 060 */
284 /* Base priority for this process's threads? */
285 KPRIORITY BasePriority; /* 062 */
286 /* Default quantum for this process's threads */
287 UCHAR ThreadQuantum; /* 063 */
288 /* Unknown. */
289 UCHAR AutoAlignment; /* 064 */
290 /* Process execution state, currently either active or terminated. */
291 UCHAR State; /* 065 */
292 /* Seed for generating thread ids for this process's threads? */
293 UCHAR ThreadSeed; /* 066 */
294 /* Disable priority boosts? */
295 UCHAR DisableBoost; /* 067 */
296 } KPROCESS;
297
298 #ifndef __USE_W32API
299
300 typedef struct _KPROCESS *PKPROCESS;
301
302 #endif /* __USE_W32API */
303
304 struct _EPROCESS
305 {
306 /* Microkernel specific process state. */
307 KPROCESS Pcb; /* 000 */
308 /* Exit status of the process. */
309 NTSTATUS ExitStatus; /* 068 */
310 /* Unknown. */
311 KEVENT LockEvent; /* 06C */
312 /* Unknown. */
313 ULONG LockCount; /* 07C */
314
315 /* Time of process creation. */
316 #ifdef __USE_W32API
317 LARGE_INTEGER CreateTime; /* 080 */
318 #else
319 TIME CreateTime; /* 080 */
320 #endif
321
322 /* Time of process exit. */
323 TIME ExitTime; /* 088 */
324 /* Unknown. */
325 PVOID LockOwner; /* 090 */
326 /* Process id. */
327 ULONG UniqueProcessId; /* 094 */
328 /* Unknown. */
329 LIST_ENTRY ActiveProcessLinks; /* 098 */
330 /* Unknown. */
331 ULONG QuotaPeakPoolUsage[2]; /* 0A0 */
332 /* Unknown. */
333 ULONG QuotaPoolUsage[2]; /* 0A8 */
334 /* Unknown. */
335 ULONG PagefileUsage; /* 0B0 */
336 /* Unknown. */
337 ULONG CommitCharge; /* 0B4 */
338 /* Unknown. */
339 ULONG PeakPagefileUsage; /* 0B8 */
340 /* Unknown. */
341 ULONG PeakVirtualSize; /* 0BC */
342 /* Unknown. */
343 LARGE_INTEGER VirtualSize; /* 0C0 */
344 struct
345 {
346 ULONG LastTrimTime;
347 ULONG LastTrimFaultCount;
348 ULONG PageFaultCount;
349 ULONG PeakWorkingSetSize;
350 ULONG WorkingSetSize;
351 ULONG MinimumWorkingSetSize;
352 ULONG MaximumWorkingSetSize;
353 ULONG VmWorkingSetList;
354 LIST_ENTRY WorkingSetExpansionList;
355 UCHAR AllowWorkingSetAdjustment;
356 UCHAR AddressSpaceBeingDeleted;
357 UCHAR ForegroundPrioritySwitch;
358 UCHAR MemoryPriority;
359 } Vm;
360 PVOID LastProtoPteFault;
361 struct _EPORT* DebugPort;
362 struct _EPORT* ExceptionPort;
363 PVOID ObjectTable;
364 PVOID Token;
365 /* FAST_MUTEX WorkingSetLock; */
366 KMUTEX WorkingSetLock;
367 PVOID WorkingSetPage;
368 UCHAR ProcessOutswapEnabled;
369 UCHAR ProcessOutswapped;
370 UCHAR AddressSpaceInitialized;
371 UCHAR AddressSpaceDeleted;
372 FAST_MUTEX AddressCreationLock;
373 KSPIN_LOCK HyperSpaceLock;
374 PETHREAD ForkInProgress;
375 USHORT VmOperation;
376 UCHAR ForkWasSuccessful;
377 UCHAR MmAgressiveWsTrimMask;
378 PKEVENT VmOperationEvent;
379 PVOID PageDirectoryPte;
380 ULONG LastFaultCount;
381 PVOID VadRoot;
382 PVOID VadHint;
383 PVOID CloneRoot;
384 ULONG NumberOfPrivatePages;
385 ULONG NumberOfLockedPages;
386 USHORT NextProcessColour;
387 UCHAR ExitProcessCalled;
388 UCHAR CreateProcessReported;
389 HANDLE SectionHandle;
390 PPEB Peb;
391 PVOID SectionBaseAddress;
392 PEPROCESS_QUOTA_BLOCK QuotaBlock;
393 NTSTATUS LastThreadExitStatus;
394 PVOID WorkingSetWatch;
395 HANDLE InheritedFromUniqueProcessId;
396 ACCESS_MASK GrantedAccess;
397 ULONG DefaultHardErrorProcessing;
398 PVOID LdtInformation;
399 ULONG VadFreeHint;
400 PVOID VdmObjects;
401 KMUTANT ProcessMutant;
402 CHAR ImageFileName[16];
403 ULONG VmTrimFaultValue;
404 UCHAR SetTimerResolution;
405 UCHAR PriorityClass;
406 UCHAR SubSystemMinorVersion;
407 UCHAR SubSystemMajorVersion;
408 USHORT SubSystemVersion;
409 struct _W32PROCESS* Win32Process;
410 HANDLE Win32WindowStation;
411
412 /*
413 * Added by David Welch (welch@mcmail.com)
414 */
415 HANDLE Win32Desktop;
416 MADDRESS_SPACE AddressSpace;
417 HANDLE_TABLE HandleTable;
418 LIST_ENTRY ProcessListEntry;
419
420 /*
421 * Added by Philip Susi for list of threads in process
422 */
423 LIST_ENTRY ThreadListHead;
424
425 /* Added by Alex Ionescu (alex@relsoft.net)*/
426 ULONG SessionId;
427 struct _EPORT* SecurityPort;
428
429 struct _EJOB* Job;
430 UINT JobStatus;
431
432 FAST_MUTEX TebLock;
433 PVOID TebBlock;
434 PVOID TebLastAllocated;
435 };
436
437 #define PROCESS_STATE_TERMINATED (1)
438 #define PROCESS_STATE_ACTIVE (2)
439
440 VOID PiInitDefaultLocale(VOID);
441 VOID PiInitProcessManager(VOID);
442 VOID PiShutdownProcessManager(VOID);
443 VOID PsInitThreadManagment(VOID);
444 VOID PsInitProcessManagment(VOID);
445 VOID PsInitIdleThread(VOID);
446 VOID PsDispatchThreadNoLock(ULONG NewThreadStatus);
447 VOID PiTerminateProcessThreads(PEPROCESS Process, NTSTATUS ExitStatus);
448 VOID PsTerminateCurrentThread(NTSTATUS ExitStatus);
449 VOID PsTerminateOtherThread(PETHREAD Thread, NTSTATUS ExitStatus);
450 VOID PsReleaseThread(PETHREAD Thread);
451 VOID PsBeginThread(PKSTART_ROUTINE StartRoutine, PVOID StartContext);
452 VOID PsBeginThreadWithContextInternal(VOID);
453 VOID PiKillMostProcesses(VOID);
454 NTSTATUS STDCALL PiTerminateProcess(PEPROCESS Process, NTSTATUS ExitStatus);
455 VOID PiInitApcManagement(VOID);
456 VOID STDCALL PiDeleteThread(PVOID ObjectBody);
457 VOID PsReapThreads(VOID);
458 VOID PsInitializeThreadReaper(VOID);
459 VOID PsQueueThreadReap(PETHREAD Thread);
460 NTSTATUS
461 PsInitializeThread(PEPROCESS Process,
462 PETHREAD* ThreadPtr,
463 PHANDLE ThreadHandle,
464 ACCESS_MASK DesiredAccess,
465 POBJECT_ATTRIBUTES ObjectAttributes,
466 BOOLEAN First);
467
468 PACCESS_TOKEN PsReferenceEffectiveToken(PETHREAD Thread,
469 PTOKEN_TYPE TokenType,
470 PUCHAR b,
471 PSECURITY_IMPERSONATION_LEVEL Level);
472
473 NTSTATUS PsOpenTokenOfProcess(HANDLE ProcessHandle,
474 PACCESS_TOKEN* Token);
475
476 NTSTATUS PsSuspendThread(PETHREAD Thread, PULONG PreviousCount);
477 NTSTATUS PsResumeThread(PETHREAD Thread, PULONG PreviousCount);
478
479
480 #define THREAD_STATE_INITIALIZED (0)
481 #define THREAD_STATE_READY (1)
482 #define THREAD_STATE_RUNNING (2)
483 #define THREAD_STATE_SUSPENDED (3)
484 #define THREAD_STATE_FROZEN (4)
485 #define THREAD_STATE_TERMINATED_1 (5)
486 #define THREAD_STATE_TERMINATED_2 (6)
487 #define THREAD_STATE_BLOCKED (7)
488 #define THREAD_STATE_MAX (8)
489
490
491 /*
492 * Internal thread priorities, added by Phillip Susi
493 * TODO: rebalence these to make use of all priorities... the ones above 16
494 * can not all be used right now
495 */
496 #define PROCESS_PRIO_IDLE 3
497 #define PROCESS_PRIO_NORMAL 8
498 #define PROCESS_PRIO_HIGH 13
499 #define PROCESS_PRIO_RT 18
500
501
502 VOID
503 KeInitializeThread(PKPROCESS Process, PKTHREAD Thread, BOOLEAN First);
504 NTSTATUS KeReleaseThread(PKTHREAD Thread);
505
506 VOID
507 STDCALL
508 KeStackAttachProcess (
509 IN PKPROCESS Process,
510 OUT PKAPC_STATE ApcState
511 );
512
513 VOID
514 STDCALL
515 KeUnstackDetachProcess (
516 IN PKAPC_STATE ApcState
517 );
518
519 VOID STDCALL PiDeleteProcess(PVOID ObjectBody);
520 VOID PsReapThreads(VOID);
521 VOID PsInitializeThreadReaper(VOID);
522 VOID PsQueueThreadReap(PETHREAD Thread);
523 VOID PsUnfreezeOtherThread(PETHREAD Thread);
524 VOID PsFreezeOtherThread(PETHREAD Thread);
525 VOID PsFreezeProcessThreads(PEPROCESS Process);
526 VOID PsUnfreezeProcessThreads(PEPROCESS Process);
527 ULONG PsEnumThreadsByProcess(PEPROCESS Process);
528 PEPROCESS PsGetNextProcess(PEPROCESS OldProcess);
529 VOID
530 PsBlockThread(PNTSTATUS Status, UCHAR Alertable, ULONG WaitMode,
531 BOOLEAN DispatcherLock, KIRQL WaitIrql, UCHAR WaitReason);
532 VOID
533 PsUnblockThread(PETHREAD Thread, PNTSTATUS WaitStatus);
534 VOID
535 PsApplicationProcessorInit(VOID);
536 VOID
537 PsPrepareForApplicationProcessorInit(ULONG Id);
538 VOID STDCALL
539 PsIdleThreadMain(PVOID Context);
540
541 VOID STDCALL
542 PiSuspendThreadRundownRoutine(PKAPC Apc);
543 VOID STDCALL
544 PiSuspendThreadKernelRoutine(PKAPC Apc,
545 PKNORMAL_ROUTINE* NormalRoutine,
546 PVOID* NormalContext,
547 PVOID* SystemArgument1,
548 PVOID* SystemArguemnt2);
549 VOID STDCALL
550 PiSuspendThreadNormalRoutine(PVOID NormalContext,
551 PVOID SystemArgument1,
552 PVOID SystemArgument2);
553 VOID STDCALL
554 PsDispatchThread(ULONG NewThreadStatus);
555 VOID
556 PsInitialiseSuspendImplementation(VOID);
557
558 extern LONG PiNrThreadsAwaitingReaping;
559
560 NTSTATUS
561 PsInitWin32Thread (PETHREAD Thread);
562
563 VOID
564 PsTerminateWin32Process (PEPROCESS Process);
565
566 VOID
567 PsTerminateWin32Thread (PETHREAD Thread);
568
569 VOID
570 PsInitialiseW32Call(VOID);
571
572 VOID
573 STDCALL
574 PspRunCreateThreadNotifyRoutines(PETHREAD, BOOLEAN);
575
576 VOID
577 STDCALL
578 PspRunCreateProcessNotifyRoutines(PEPROCESS, BOOLEAN);
579
580 #include <pshpack1.h>
581 typedef struct _PS_JOB_TOKEN_FILTER
582 {
583 UINT CapturedSidCount;
584 PSID_AND_ATTRIBUTES CapturedSids;
585 UINT CapturedSidsLength;
586 UINT CapturedGroupCount;
587 PSID_AND_ATTRIBUTES CapturedGroups;
588 UINT CapturedGroupsLength;
589 UINT CapturedPrivilegeCount;
590 PLUID_AND_ATTRIBUTES CapturedPrivileges;
591 UINT CapturedPrivilegesLength;
592 } PS_JOB_TOKEN_FILTER, *PPS_JOB_TOKEN_FILTER;
593 #include <poppack.h>
594
595 #include <pshpack1.h>
596 typedef struct _EJOB
597 {
598 KEVENT Event;
599 LIST_ENTRY JobLinks;
600 LIST_ENTRY ProcessListHead;
601 ERESOURCE JobLock;
602 LARGE_INTEGER TotalUserTime;
603 LARGE_INTEGER TotalKernelTime;
604 LARGE_INTEGER ThisPeriodTotalUserTime;
605 LARGE_INTEGER ThisPeriodTotalKernelTime;
606 UINT TotalPageFaultCount;
607 UINT TotalProcesses;
608 UINT ActiveProcesses;
609 UINT TotalTerminatedProcesses;
610 LARGE_INTEGER PerProcessUserTimeLimit;
611 LARGE_INTEGER PerJobUserTimeLimit;
612 UINT LimitFlags;
613 UINT MinimumWorkingSetSize;
614 UINT MaximumWorkingSetSize;
615 UINT ActiveProcessLimit;
616 UINT Affinity;
617 BYTE PriorityClass;
618 UINT UIRestrictionsClass;
619 UINT SecurityLimitFlags;
620 PVOID Token;
621 PPS_JOB_TOKEN_FILTER Filter;
622 UINT EndOfJobTimeAction;
623 PVOID CompletionPort;
624 PVOID CompletionKey;
625 UINT SessionId;
626 UINT SchedulingClass;
627 ULONGLONG ReadOperationCount;
628 ULONGLONG WriteOperationCount;
629 ULONGLONG OtherOperationCount;
630 ULONGLONG ReadTransferCount;
631 ULONGLONG WriteTransferCount;
632 ULONGLONG OtherTransferCount;
633 IO_COUNTERS IoInfo;
634 UINT ProcessMemoryLimit;
635 UINT JobMemoryLimit;
636 UINT PeakProcessMemoryUsed;
637 UINT PeakJobMemoryUsed;
638 UINT CurrentJobMemoryUsed;
639 FAST_MUTEX MemoryLimitsLock;
640 } EJOB;
641 #include <poppack.h>
642
643 VOID INIT_FUNCTION PsInitJobManagment(VOID);
644
645 /* CID */
646
647 typedef struct _CID_OBJECT
648 {
649 LONG ref;
650 HANDLE Handle;
651 LIST_ENTRY Entry;
652 LONG Lock;
653 union
654 {
655 struct _EPROCESS *Process;
656 struct _ETHREAD *Thread;
657 PVOID Object;
658 } Obj;
659 } CID_OBJECT, *PCID_OBJECT;
660
661 NTSTATUS PsCreateCidHandle(PVOID Object, POBJECT_TYPE ObjectType, PHANDLE Handle);
662 NTSTATUS PsDeleteCidHandle(HANDLE CidHandle, POBJECT_TYPE ObjectType);
663 PCID_OBJECT PsLockCidHandle(HANDLE CidHandle, POBJECT_TYPE ObjectType);
664 VOID PsUnlockCidObject(PCID_OBJECT CidObject);
665
666 #define ETHREAD_TO_KTHREAD(pEThread) (&(pEThread)->Tcb)
667 #define KTHREAD_TO_ETHREAD(pKThread) (CONTAINING_RECORD((pKThread), ETHREAD, Tcb))
668 #define EPROCESS_TO_KPROCESS(pEProcess) (&(pEProcess)->Pcb)
669 #define KPROCESS_TO_EPROCESS(pKProcess) (CONTAINING_RECORD((pKProcess), EPROCESS, Pcb))
670
671 #endif /* ASSEMBLER */
672
673 #endif /* __INCLUDE_INTERNAL_PS_H */