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