- NDK 0.98, now with versionned headers. Too many changes to list, see the TinyKRNL...
[reactos.git] / reactos / ntoskrnl / include / internal / ps.h
1 #ifndef __INCLUDE_INTERNAL_PS_H
2 #define __INCLUDE_INTERNAL_PS_H
3
4 /* Forward declarations. */
5 struct _KTHREAD;
6 struct _KTRAPFRAME;
7 struct _EJOB;
8
9 #include <internal/arch/ps.h>
10
11 //
12 // ROS Process
13 //
14 #include <pshpack4.h>
15 typedef struct _ROS_EPROCESS
16 {
17 KPROCESS Pcb;
18 EX_PUSH_LOCK ProcessLock;
19 LARGE_INTEGER CreateTime;
20 LARGE_INTEGER ExitTime;
21 EX_RUNDOWN_REF RundownProtect;
22 HANDLE UniqueProcessId;
23 LIST_ENTRY ActiveProcessLinks;
24 ULONG QuotaUsage[3];
25 ULONG QuotaPeak[3];
26 ULONG CommitCharge;
27 ULONG PeakVirtualSize;
28 ULONG VirtualSize;
29 LIST_ENTRY SessionProcessLinks;
30 PVOID DebugPort;
31 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
32 union
33 {
34 PVOID ExceptionPortData;
35 ULONG ExceptionPortValue;
36 UCHAR ExceptionPortState:3;
37 };
38 #else
39 PVOID ExceptionPort;
40 #endif
41 PHANDLE_TABLE ObjectTable;
42 EX_FAST_REF Token;
43 ULONG WorkingSetPage;
44 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
45 EX_PUSH_LOCK AddressCreationLock;
46 PETHREAD RotateInProgress;
47 #else
48 KGUARDED_MUTEX AddressCreationLock;
49 KSPIN_LOCK HyperSpaceLock;
50 #endif
51 PETHREAD ForkInProgress;
52 ULONG HardwareTrigger;
53 MM_AVL_TABLE PhysicalVadroot;
54 PVOID CloneRoot;
55 ULONG NumberOfPrivatePages;
56 ULONG NumberOfLockedPages;
57 PVOID *Win32Process;
58 struct _EJOB *Job;
59 PVOID SectionObject;
60 PVOID SectionBaseAddress;
61 PEPROCESS_QUOTA_BLOCK QuotaBlock;
62 PPAGEFAULT_HISTORY WorkingSetWatch;
63 PVOID Win32WindowStation;
64 HANDLE InheritedFromUniqueProcessId;
65 PVOID LdtInformation;
66 PVOID VadFreeHint;
67 PVOID VdmObjects;
68 PVOID DeviceMap;
69 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
70 ULONG AlpcPagedPoolQuotaCache;
71 PVOID EtwDataSource;
72 PVOID FreeTebHint;
73 #else
74 PVOID Spare0[3];
75 #endif
76 union
77 {
78 HARDWARE_PTE_X86 PagedirectoryPte;
79 ULONGLONG Filler;
80 };
81 ULONG Session;
82 CHAR ImageFileName[16];
83 LIST_ENTRY JobLinks;
84 PVOID LockedPagesList;
85 LIST_ENTRY ThreadListHead;
86 PVOID SecurityPort;
87 PVOID PaeTop;
88 ULONG ActiveThreads;
89 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
90 ULONG ImagePathHash;
91 #else
92 ACCESS_MASK GrantedAccess;
93 #endif
94 ULONG DefaultHardErrorProcessing;
95 NTSTATUS LastThreadExitStatus;
96 struct _PEB* Peb;
97 EX_FAST_REF PrefetchTrace;
98 LARGE_INTEGER ReadOperationCount;
99 LARGE_INTEGER WriteOperationCount;
100 LARGE_INTEGER OtherOperationCount;
101 LARGE_INTEGER ReadTransferCount;
102 LARGE_INTEGER WriteTransferCount;
103 LARGE_INTEGER OtherTransferCount;
104 ULONG CommitChargeLimit;
105 ULONG CommitChargePeak;
106 PVOID AweInfo;
107 SE_AUDIT_PROCESS_CREATION_INFO SeAuditProcessCreationInfo;
108 MMSUPPORT Vm;
109 LIST_ENTRY MmProcessLinks;
110 ULONG ModifiedPageCount;
111 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
112 union
113 {
114 struct
115 {
116 ULONG JobNotReallyActive:1;
117 ULONG AccountingFolded:1;
118 ULONG NewProcessReported:1;
119 ULONG ExitProcessReported:1;
120 ULONG ReportCommitChanges:1;
121 ULONG LastReportMemory:1;
122 ULONG ReportPhysicalPageChanges:1;
123 ULONG HandleTableRundown:1;
124 ULONG NeedsHandleRundown:1;
125 ULONG RefTraceEnabled:1;
126 ULONG NumaAware:1;
127 ULONG ProtectedProcess:1;
128 ULONG DefaultPagePriority:3;
129 ULONG ProcessDeleteSelf:1;
130 ULONG ProcessVerifierTarget:1;
131 };
132 ULONG Flags2;
133 };
134 #else
135 ULONG JobStatus;
136 #endif
137 union
138 {
139 struct
140 {
141 ULONG CreateReported:1;
142 ULONG NoDebugInherit:1;
143 ULONG ProcessExiting:1;
144 ULONG ProcessDelete:1;
145 ULONG Wow64SplitPages:1;
146 ULONG VmDeleted:1;
147 ULONG OutswapEnabled:1;
148 ULONG Outswapped:1;
149 ULONG ForkFailed:1;
150 ULONG Wow64VaSpace4Gb:1;
151 ULONG AddressSpaceInitialized:2;
152 ULONG SetTimerResolution:1;
153 ULONG BreakOnTermination:1;
154 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
155 ULONG DeprioritizeViews:1;
156 #else
157 ULONG SessionCreationUnderway:1;
158 #endif
159 ULONG WriteWatch:1;
160 ULONG ProcessInSession:1;
161 ULONG OverrideAddressSpace:1;
162 ULONG HasAddressSpace:1;
163 ULONG LaunchPrefetched:1;
164 ULONG InjectInpageErrors:1;
165 ULONG VmTopDown:1;
166 ULONG ImageNotifyDone:1;
167 ULONG PdeUpdateNeeded:1;
168 ULONG VdmAllowed:1;
169 ULONG SmapAllowed:1;
170 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
171 ULONG ProcessInserted:1;
172 #else
173 ULONG CreateFailed:1;
174 #endif
175 ULONG DefaultIoPriority:3;
176 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
177 ULONG SparePsFlags1:2;
178 #else
179 ULONG Spare1:1;
180 ULONG Spare2:1;
181 #endif
182 };
183 ULONG Flags;
184 };
185 NTSTATUS ExitStatus;
186 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
187 USHORT Spare7;
188 #else
189 USHORT NextPageColor;
190 #endif
191 union
192 {
193 struct
194 {
195 UCHAR SubSystemMinorVersion;
196 UCHAR SubSystemMajorVersion;
197 };
198 USHORT SubSystemVersion;
199 };
200 UCHAR PriorityClass;
201 MM_AVL_TABLE VadRoot;
202 ULONG Cookie;
203 KEVENT LockEvent;
204 ULONG LockCount;
205 struct _KTHREAD *LockOwner;
206 MADDRESS_SPACE AddressSpace;
207 } ROS_EPROCESS, *PROS_EPROCESS;
208 #include <poppack.h>
209
210 extern LCID PsDefaultThreadLocaleId;
211 extern LCID PsDefaultSystemLocaleId;
212 extern LIST_ENTRY PspReaperListHead;
213 extern WORK_QUEUE_ITEM PspReaperWorkItem;
214 extern BOOLEAN PspReaping;
215 extern PEPROCESS PsInitialSystemProcess;
216 extern PEPROCESS PsIdleProcess;
217 extern LIST_ENTRY PsActiveProcessHead;
218 extern FAST_MUTEX PspActiveProcessMutex;
219 extern LARGE_INTEGER ShortPsLockDelay, PsLockTimeout;
220 extern EPROCESS_QUOTA_BLOCK PspDefaultQuotaBlock;
221
222 /* Top level irp definitions. */
223 #define FSRTL_FSP_TOP_LEVEL_IRP (0x01)
224 #define FSRTL_CACHE_TOP_LEVEL_IRP (0x02)
225 #define FSRTL_MOD_WRITE_TOP_LEVEL_IRP (0x03)
226 #define FSRTL_FAST_IO_TOP_LEVEL_IRP (0x04)
227 #define FSRTL_MAX_TOP_LEVEL_IRP_FLAG (0x04)
228
229 #define MAX_PROCESS_NOTIFY_ROUTINE_COUNT 8
230 #define MAX_LOAD_IMAGE_NOTIFY_ROUTINE_COUNT 8
231
232 VOID
233 NTAPI
234 PiInitDefaultLocale(VOID);
235
236 VOID
237 NTAPI
238 PiInitProcessManager(VOID);
239
240 VOID
241 NTAPI
242 PiShutdownProcessManager(VOID);
243
244 VOID
245 NTAPI
246 PsInitThreadManagment(VOID);
247
248 VOID
249 NTAPI
250 PsInitProcessManagment(VOID);
251
252 VOID
253 NTAPI
254 PsInitIdleThread(VOID);
255
256 VOID
257 NTAPI
258 PiTerminateProcessThreads(
259 PEPROCESS Process,
260 NTSTATUS ExitStatus
261 );
262
263 VOID
264 NTAPI
265 PsTerminateCurrentThread(NTSTATUS ExitStatus);
266
267 VOID
268 NTAPI
269 PsTerminateOtherThread(
270 PETHREAD Thread,
271 NTSTATUS ExitStatus
272 );
273
274 VOID
275 NTAPI
276 PsReleaseThread(PETHREAD Thread);
277
278 VOID
279 NTAPI
280 PsBeginThread(
281 PKSTART_ROUTINE StartRoutine,
282 PVOID StartContext
283 );
284
285 VOID
286 NTAPI
287 PsBeginThreadWithContextInternal(VOID);
288
289 VOID
290 NTAPI
291 PiKillMostProcesses(VOID);
292
293 NTSTATUS
294 STDCALL
295 PiTerminateProcess(
296 PEPROCESS Process,
297 NTSTATUS ExitStatus
298 );
299
300 VOID
301 NTAPI
302 PiInitApcManagement(VOID);
303
304 VOID
305 STDCALL
306 PiDeleteThread(PVOID ObjectBody);
307
308 VOID
309 NTAPI
310 PsReapThreads(VOID);
311
312 VOID
313 NTAPI
314 PsInitializeThreadReaper(VOID);
315
316 VOID
317 NTAPI
318 PsQueueThreadReap(PETHREAD Thread);
319
320 NTSTATUS
321 NTAPI
322 PsInitializeThread(
323 PEPROCESS Process,
324 PETHREAD* ThreadPtr,
325 POBJECT_ATTRIBUTES ObjectAttributes,
326 KPROCESSOR_MODE AccessMode,
327 BOOLEAN First
328 );
329
330 PACCESS_TOKEN
331 STDCALL
332 PsReferenceEffectiveToken(
333 PETHREAD Thread,
334 PTOKEN_TYPE TokenType,
335 PUCHAR b,
336 PSECURITY_IMPERSONATION_LEVEL Level
337 );
338
339 NTSTATUS
340 STDCALL
341 PsOpenTokenOfProcess(
342 HANDLE ProcessHandle,
343 PACCESS_TOKEN* Token
344 );
345
346 VOID
347 STDCALL
348 PspTerminateProcessThreads(
349 PEPROCESS Process,
350 NTSTATUS ExitStatus
351 );
352
353 NTSTATUS
354 NTAPI
355 PsSuspendThread(
356 PETHREAD Thread,
357 PULONG PreviousCount
358 );
359
360 NTSTATUS
361 NTAPI
362 PsResumeThread(
363 PETHREAD Thread,
364 PULONG PreviousCount
365 );
366
367 NTSTATUS
368 STDCALL
369 PspAssignPrimaryToken(
370 PEPROCESS Process,
371 HANDLE TokenHandle
372 );
373
374 VOID
375 STDCALL
376 PsExitSpecialApc(
377 PKAPC Apc,
378 PKNORMAL_ROUTINE *NormalRoutine,
379 PVOID *NormalContext,
380 PVOID *SystemArgument1,
381 PVOID *SystemArgument2
382 );
383
384 NTSTATUS
385 STDCALL
386 PspInitializeProcessSecurity(
387 PEPROCESS Process,
388 PEPROCESS Parent OPTIONAL
389 );
390
391 VOID
392 STDCALL
393 PspSystemThreadStartup(
394 PKSTART_ROUTINE StartRoutine,
395 PVOID StartContext
396 );
397
398 NTSTATUS
399 NTAPI
400 PsInitializeIdleOrFirstThread(
401 PEPROCESS Process,
402 PETHREAD* ThreadPtr,
403 PKSTART_ROUTINE StartRoutine,
404 KPROCESSOR_MODE AccessMode,
405 BOOLEAN First
406 );
407
408 VOID
409 STDCALL
410 PiDeleteProcess(PVOID ObjectBody);
411
412 VOID
413 STDCALL
414 PspReapRoutine(PVOID Context);
415
416 VOID
417 STDCALL
418 PspExitThread(NTSTATUS ExitStatus);
419
420 VOID
421 STDCALL
422 PspTerminateThreadByPointer(
423 PETHREAD Thread,
424 NTSTATUS ExitStatus
425 );
426
427 VOID
428 NTAPI
429 PsUnfreezeOtherThread(PETHREAD Thread);
430
431 VOID
432 NTAPI
433 PsFreezeOtherThread(PETHREAD Thread);
434
435 VOID
436 NTAPI
437 PsFreezeProcessThreads(PEPROCESS Process);
438
439 VOID
440 NTAPI
441 PsUnfreezeProcessThreads(PEPROCESS Process);
442
443 ULONG
444 NTAPI
445 PsEnumThreadsByProcess(PEPROCESS Process);
446
447 PEPROCESS
448 STDCALL
449 PsGetNextProcess(PEPROCESS OldProcess);
450
451 VOID
452 NTAPI
453 PsApplicationProcessorInit(VOID);
454
455 VOID
456 NTAPI
457 PsPrepareForApplicationProcessorInit(ULONG Id);
458
459 VOID
460 STDCALL
461 PsIdleThreadMain(PVOID Context);
462
463 VOID
464 STDCALL
465 PiSuspendThreadRundownRoutine(PKAPC Apc);
466
467 VOID
468 STDCALL
469 PiSuspendThreadKernelRoutine(
470 PKAPC Apc,
471 PKNORMAL_ROUTINE* NormalRoutine,
472 PVOID* NormalContext,
473 PVOID* SystemArgument1,
474 PVOID* SystemArguemnt2
475 );
476
477 VOID
478 STDCALL
479 PiSuspendThreadNormalRoutine(
480 PVOID NormalContext,
481 PVOID SystemArgument1,
482 PVOID SystemArgument2
483 );
484
485 VOID
486 NTAPI
487 PsInitialiseSuspendImplementation(VOID);
488
489 NTSTATUS
490 STDCALL
491 PspExitProcess(PEPROCESS Process);
492
493 VOID
494 STDCALL
495 PspDeleteProcess(PVOID ObjectBody);
496
497 VOID
498 STDCALL
499 PspDeleteThread(PVOID ObjectBody);
500
501
502 NTSTATUS
503 NTAPI
504 PsInitWin32Thread(PETHREAD Thread);
505
506 VOID
507 NTAPI
508 PsTerminateWin32Process(PEPROCESS Process);
509
510 VOID
511 NTAPI
512 PsTerminateWin32Thread(PETHREAD Thread);
513
514 VOID
515 NTAPI
516 PsInitialiseW32Call(VOID);
517
518 VOID
519 STDCALL
520 PspRunCreateThreadNotifyRoutines(
521 PETHREAD,
522 BOOLEAN
523 );
524
525 VOID
526 STDCALL
527 PspRunCreateProcessNotifyRoutines(
528 PEPROCESS,
529 BOOLEAN
530 );
531
532 VOID
533 STDCALL
534 PspRunLegoRoutine(IN PKTHREAD Thread);
535
536 VOID
537 NTAPI
538 INIT_FUNCTION
539 PsInitJobManagment(VOID);
540
541 VOID
542 STDCALL
543 PspInheritQuota(
544 PEPROCESS Process,
545 PEPROCESS ParentProcess
546 );
547
548 VOID
549 STDCALL
550 PspDestroyQuotaBlock(PEPROCESS Process);
551
552 NTSTATUS
553 STDCALL
554 PspMapSystemDll(
555 PEPROCESS Process,
556 PVOID *DllBase
557 );
558
559 NTSTATUS
560 STDCALL
561 PsLocateSystemDll(VOID);
562
563 NTSTATUS
564 STDCALL
565 PspGetSystemDllEntryPoints(VOID);
566
567 NTSTATUS
568 NTAPI
569 PsLockProcess(
570 PROS_EPROCESS Process,
571 BOOLEAN Timeout
572 );
573
574 VOID
575 NTAPI
576 PsUnlockProcess(PROS_EPROCESS Process);
577
578 #endif /* __INCLUDE_INTERNAL_PS_H */