[CMAKE]
[reactos.git] / include / ndk / psfuncs.h
1 /*++ NDK Version: 0098
2
3 Copyright (c) Alex Ionescu. All rights reserved.
4
5 Header Name:
6
7 psfuncs.h
8
9 Abstract:
10
11 Function definitions for the Process Manager
12
13 Author:
14
15 Alex Ionescu (alexi@tinykrnl.org) - Updated - 27-Feb-2006
16
17 --*/
18
19 #ifndef _PSFUNCS_H
20 #define _PSFUNCS_H
21
22 //
23 // Dependencies
24 //
25 #include <umtypes.h>
26 #include <pstypes.h>
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 #ifndef NTOS_MODE_USER
33
34 //
35 // Win32K Process/Thread Functions
36 //
37 NTKERNELAPI
38 PVOID
39 NTAPI
40 PsGetCurrentThreadWin32Thread(
41 VOID
42 );
43
44 NTKERNELAPI
45 PVOID
46 NTAPI
47 PsGetCurrentProcessWin32Process(
48 VOID
49 );
50
51 NTKERNELAPI
52 PVOID
53 NTAPI
54 PsGetProcessWin32Process(
55 PEPROCESS Process
56 );
57
58 NTKERNELAPI
59 VOID
60 NTAPI
61 PsSetProcessWin32Process(
62 PEPROCESS Process,
63 PVOID Win32Process
64 );
65
66 NTKERNELAPI
67 VOID
68 NTAPI
69 PsSetThreadWin32Thread(
70 PETHREAD Thread,
71 PVOID Win32Thread
72 );
73
74 NTKERNELAPI
75 PVOID
76 NTAPI
77 PsGetThreadWin32Thread(
78 PETHREAD Thread
79 );
80
81 NTKERNELAPI
82 PVOID
83 NTAPI
84 PsGetProcessWin32WindowStation(
85 PEPROCESS Process
86 );
87
88 NTKERNELAPI
89 VOID
90 NTAPI
91 PsSetProcessWindowStation(
92 PEPROCESS Process,
93 PVOID WindowStation
94 );
95
96 NTKERNELAPI
97 PTEB
98 NTAPI
99 PsGetThreadTeb(
100 IN PETHREAD Thread
101 );
102
103 NTKERNELAPI
104 HANDLE
105 NTAPI
106 PsGetThreadId(
107 IN PETHREAD Thread
108 );
109
110 NTKERNELAPI
111 BOOLEAN
112 NTAPI
113 PsGetThreadHardErrorsAreDisabled(
114 PETHREAD Thread
115 );
116
117 NTKERNELAPI
118 VOID
119 NTAPI
120 PsSetThreadHardErrorsAreDisabled(
121 PETHREAD Thread,
122 IN BOOLEAN Disabled
123 );
124
125 NTKERNELAPI
126 VOID
127 NTAPI
128 PsEstablishWin32Callouts(
129 PWIN32_CALLOUTS_FPNS CalloutData
130 );
131
132 NTKERNELAPI
133 VOID
134 NTAPI
135 PsReturnProcessNonPagedPoolQuota(
136 IN PEPROCESS Process,
137 IN SIZE_T Amount
138 );
139
140 //
141 // Process Impersonation Functions
142 //
143 NTKERNELAPI
144 VOID
145 NTAPI
146 PsRevertThreadToSelf(
147 IN PETHREAD Thread
148 );
149
150 //
151 // Misc. Functions
152 //
153 NTKERNELAPI
154 NTSTATUS
155 NTAPI
156 PsLookupProcessThreadByCid(
157 IN PCLIENT_ID Cid,
158 OUT PEPROCESS *Process OPTIONAL,
159 OUT PETHREAD *Thread
160 );
161
162 BOOLEAN
163 NTAPI
164 PsIsProtectedProcess(
165 IN PEPROCESS Process
166 );
167
168 NTKERNELAPI
169 BOOLEAN
170 NTAPI
171 PsIsSystemProcess(
172 IN PEPROCESS Process
173 );
174
175 VOID
176 NTAPI
177 PsSetProcessPriorityByClass(
178 IN PEPROCESS Process,
179 IN PSPROCESSPRIORITYMODE Type
180 );
181
182 HANDLE
183 NTAPI
184 PsGetProcessInheritedFromUniqueProcessId(
185 IN PEPROCESS Process
186 );
187
188 NTKERNELAPI
189 NTSTATUS
190 NTAPI
191 PsGetProcessExitStatus(
192 PEPROCESS Process
193 );
194
195 //
196 // Quota Functions
197 //
198 NTKERNELAPI
199 VOID
200 NTAPI
201 PsChargePoolQuota(
202 IN PEPROCESS Process,
203 IN POOL_TYPE PoolType,
204 IN SIZE_T Amount
205 );
206
207 NTKERNELAPI
208 NTSTATUS
209 NTAPI
210 PsChargeProcessNonPagedPoolQuota(
211 IN PEPROCESS Process,
212 IN SIZE_T Amount
213 );
214
215 NTKERNELAPI
216 NTSTATUS
217 NTAPI
218 PsChargeProcessPagedPoolQuota(
219 IN PEPROCESS Process,
220 IN SIZE_T Amount
221 );
222
223 NTKERNELAPI
224 NTSTATUS
225 NTAPI
226 PsChargeProcessPoolQuota(
227 IN PEPROCESS Process,
228 IN POOL_TYPE PoolType,
229 IN SIZE_T Amount
230 );
231
232 NTKERNELAPI
233 VOID
234 NTAPI
235 PsReturnPoolQuota(
236 IN PEPROCESS Process,
237 IN POOL_TYPE PoolType,
238 IN SIZE_T Amount
239 );
240
241 NTKERNELAPI
242 VOID
243 NTAPI
244 PsReturnProcessNonPagedPoolQuota(
245 IN PEPROCESS Process,
246 IN SIZE_T Amount
247 );
248
249 NTKERNELAPI
250 VOID
251 NTAPI
252 PsReturnProcessPagedPoolQuota(
253 IN PEPROCESS Process,
254 IN SIZE_T Amount
255 );
256
257 #endif
258
259 //
260 // Native Calls
261 //
262 NTSYSCALLAPI
263 NTSTATUS
264 NTAPI
265 NtAlertResumeThread(
266 IN HANDLE ThreadHandle,
267 OUT PULONG SuspendCount
268 );
269
270 typedef ULONG APPHELPCACHESERVICECLASS;
271 NTSYSCALLAPI
272 NTSTATUS
273 NTAPI
274 NtApphelpCacheControl(
275 IN APPHELPCACHESERVICECLASS Service,
276 IN PVOID ServiceData
277 );
278
279 NTSYSCALLAPI
280 NTSTATUS
281 NTAPI
282 NtAlertThread(
283 IN HANDLE ThreadHandle
284 );
285
286 NTSYSCALLAPI
287 NTSTATUS
288 NTAPI
289 NtAssignProcessToJobObject(
290 HANDLE JobHandle,
291 HANDLE ProcessHandle
292 );
293
294 NTSYSCALLAPI
295 NTSTATUS
296 NTAPI
297 NtCreateJobObject(
298 PHANDLE JobHandle,
299 ACCESS_MASK DesiredAccess,
300 POBJECT_ATTRIBUTES ObjectAttributes
301 );
302
303 NTSTATUS
304 NTAPI
305 NtCreateJobSet(
306 IN ULONG NumJob,
307 IN PJOB_SET_ARRAY UserJobSet,
308 IN ULONG Flags
309 );
310
311 NTSYSCALLAPI
312 NTSTATUS
313 NTAPI
314 NtCreateProcess(
315 OUT PHANDLE ProcessHandle,
316 IN ACCESS_MASK DesiredAccess,
317 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
318 IN HANDLE ParentProcess,
319 IN BOOLEAN InheritObjectTable,
320 IN HANDLE SectionHandle OPTIONAL,
321 IN HANDLE DebugPort OPTIONAL,
322 IN HANDLE ExceptionPort OPTIONAL
323 );
324
325 NTSYSCALLAPI
326 NTSTATUS
327 NTAPI
328 NtCreateProcessEx(
329 OUT PHANDLE ProcessHandle,
330 IN ACCESS_MASK DesiredAccess,
331 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
332 IN HANDLE ParentProcess,
333 IN ULONG Flags,
334 IN HANDLE SectionHandle OPTIONAL,
335 IN HANDLE DebugPort OPTIONAL,
336 IN HANDLE ExceptionPort OPTIONAL,
337 IN BOOLEAN InJob
338 );
339
340 NTSYSCALLAPI
341 NTSTATUS
342 NTAPI
343 NtCreateThread(
344 OUT PHANDLE ThreadHandle,
345 IN ACCESS_MASK DesiredAccess,
346 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
347 IN HANDLE ProcessHandle,
348 OUT PCLIENT_ID ClientId,
349 IN PCONTEXT ThreadContext,
350 IN PINITIAL_TEB UserStack,
351 IN BOOLEAN CreateSuspended
352 );
353
354 #include "inline_ntcurrentteb.h"
355
356 NTSYSCALLAPI
357 NTSTATUS
358 NTAPI
359 NtImpersonateThread(
360 IN HANDLE ThreadHandle,
361 IN HANDLE ThreadToImpersonate,
362 IN PSECURITY_QUALITY_OF_SERVICE SecurityQualityOfService
363 );
364
365 NTSYSCALLAPI
366 NTSTATUS
367 NTAPI
368 NtIsProcessInJob(
369 IN HANDLE ProcessHandle,
370 IN HANDLE JobHandle OPTIONAL
371 );
372
373 NTSYSCALLAPI
374 NTSTATUS
375 NTAPI
376 NtOpenProcess(
377 OUT PHANDLE ProcessHandle,
378 IN ACCESS_MASK DesiredAccess,
379 IN POBJECT_ATTRIBUTES ObjectAttributes,
380 IN PCLIENT_ID ClientId
381 );
382
383 NTSYSCALLAPI
384 NTSTATUS
385 NTAPI
386 NtOpenThread(
387 OUT PHANDLE ThreadHandle,
388 IN ACCESS_MASK DesiredAccess,
389 IN POBJECT_ATTRIBUTES ObjectAttributes,
390 IN PCLIENT_ID ClientId
391 );
392
393 NTSYSCALLAPI
394 NTSTATUS
395 NTAPI
396 NtOpenThreadToken(
397 IN HANDLE ThreadHandle,
398 IN ACCESS_MASK DesiredAccess,
399 IN BOOLEAN OpenAsSelf,
400 OUT PHANDLE TokenHandle
401 );
402
403 NTSYSCALLAPI
404 NTSTATUS
405 NTAPI
406 NtOpenThreadTokenEx(
407 IN HANDLE ThreadHandle,
408 IN ACCESS_MASK DesiredAccess,
409 IN BOOLEAN OpenAsSelf,
410 IN ULONG HandleAttributes,
411 OUT PHANDLE TokenHandle
412 );
413
414 NTSYSCALLAPI
415 NTSTATUS
416 NTAPI
417 NtQueryInformationJobObject(
418 HANDLE JobHandle,
419 JOBOBJECTINFOCLASS JobInformationClass,
420 PVOID JobInformation,
421 ULONG JobInformationLength,
422 PULONG ReturnLength
423 );
424
425 #ifndef _NTDDK_
426 NTSYSCALLAPI
427 NTSTATUS
428 NTAPI
429 NtQueryInformationProcess(
430 IN HANDLE ProcessHandle,
431 IN PROCESSINFOCLASS ProcessInformationClass,
432 OUT PVOID ProcessInformation,
433 IN ULONG ProcessInformationLength,
434 OUT PULONG ReturnLength OPTIONAL
435 );
436 #endif
437
438 NTSYSCALLAPI
439 NTSTATUS
440 NTAPI
441 NtQueryInformationThread(
442 IN HANDLE ThreadHandle,
443 IN THREADINFOCLASS ThreadInformationClass,
444 OUT PVOID ThreadInformation,
445 IN ULONG ThreadInformationLength,
446 OUT PULONG ReturnLength
447 );
448
449 NTSYSCALLAPI
450 NTSTATUS
451 NTAPI
452 NtRegisterThreadTerminatePort(
453 HANDLE TerminationPort
454 );
455
456 NTSYSCALLAPI
457 NTSTATUS
458 NTAPI
459 NtResumeThread(
460 IN HANDLE ThreadHandle,
461 OUT PULONG SuspendCount
462 );
463
464 NTSYSCALLAPI
465 NTSTATUS
466 NTAPI
467 NtResumeProcess(
468 IN HANDLE ProcessHandle
469 );
470
471 NTSYSCALLAPI
472 NTSTATUS
473 NTAPI
474 NtSetInformationJobObject(
475 HANDLE JobHandle,
476 JOBOBJECTINFOCLASS JobInformationClass,
477 PVOID JobInformation,
478 ULONG JobInformationLength
479 );
480
481 NTSYSCALLAPI
482 NTSTATUS
483 NTAPI
484 NtSetInformationProcess(
485 IN HANDLE ProcessHandle,
486 IN PROCESSINFOCLASS ProcessInformationClass,
487 IN PVOID ProcessInformation,
488 IN ULONG ProcessInformationLength
489 );
490
491 NTSYSCALLAPI
492 NTSTATUS
493 NTAPI
494 NtSetInformationThread(
495 IN HANDLE ThreadHandle,
496 IN THREADINFOCLASS ThreadInformationClass,
497 IN PVOID ThreadInformation,
498 IN ULONG ThreadInformationLength
499 );
500
501 NTSYSCALLAPI
502 NTSTATUS
503 NTAPI
504 NtSuspendProcess(
505 IN HANDLE ProcessHandle
506 );
507
508 NTSYSCALLAPI
509 NTSTATUS
510 NTAPI
511 NtSuspendThread(
512 IN HANDLE ThreadHandle,
513 IN PULONG PreviousSuspendCount
514 );
515
516 NTSYSCALLAPI
517 NTSTATUS
518 NTAPI
519 NtTerminateProcess(
520 IN HANDLE ProcessHandle,
521 IN NTSTATUS ExitStatus
522 );
523
524 NTSYSCALLAPI
525 NTSTATUS
526 NTAPI
527 NtTerminateThread(
528 IN HANDLE ThreadHandle,
529 IN NTSTATUS ExitStatus
530 );
531
532 NTSYSCALLAPI
533 NTSTATUS
534 NTAPI
535 NtTerminateJobObject(
536 HANDLE JobHandle,
537 NTSTATUS ExitStatus
538 );
539
540 NTSYSAPI
541 NTSTATUS
542 NTAPI
543 ZwAlertResumeThread(
544 IN HANDLE ThreadHandle,
545 OUT PULONG SuspendCount
546 );
547
548 NTSYSAPI
549 NTSTATUS
550 NTAPI
551 ZwAlertThread(
552 IN HANDLE ThreadHandle
553 );
554
555 NTSYSAPI
556 NTSTATUS
557 NTAPI
558 ZwAssignProcessToJobObject(
559 HANDLE JobHandle,
560 HANDLE ProcessHandle
561 );
562
563 NTSYSAPI
564 NTSTATUS
565 NTAPI
566 ZwCreateJobObject(
567 PHANDLE JobHandle,
568 ACCESS_MASK DesiredAccess,
569 POBJECT_ATTRIBUTES ObjectAttributes
570 );
571
572 NTSYSAPI
573 NTSTATUS
574 NTAPI
575 ZwCreateProcess(
576 OUT PHANDLE ProcessHandle,
577 IN ACCESS_MASK DesiredAccess,
578 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
579 IN HANDLE ParentProcess,
580 IN BOOLEAN InheritObjectTable,
581 IN HANDLE SectionHandle OPTIONAL,
582 IN HANDLE DebugPort OPTIONAL,
583 IN HANDLE ExceptionPort OPTIONAL
584 );
585
586 NTSYSAPI
587 NTSTATUS
588 NTAPI
589 ZwCreateThread(
590 OUT PHANDLE ThreadHandle,
591 IN ACCESS_MASK DesiredAccess,
592 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
593 IN HANDLE ProcessHandle,
594 OUT PCLIENT_ID ClientId,
595 IN PCONTEXT ThreadContext,
596 IN PINITIAL_TEB UserStack,
597 IN BOOLEAN CreateSuspended
598 );
599
600 NTSYSAPI
601 NTSTATUS
602 NTAPI
603 ZwImpersonateThread(
604 IN HANDLE ThreadHandle,
605 IN HANDLE ThreadToImpersonate,
606 IN PSECURITY_QUALITY_OF_SERVICE SecurityQualityOfService
607 );
608
609 NTSYSAPI
610 NTSTATUS
611 NTAPI
612 ZwIsProcessInJob(
613 IN HANDLE ProcessHandle,
614 IN HANDLE JobHandle OPTIONAL
615 );
616
617 NTSYSAPI
618 NTSTATUS
619 NTAPI
620 ZwOpenProcess(
621 OUT PHANDLE ProcessHandle,
622 IN ACCESS_MASK DesiredAccess,
623 IN POBJECT_ATTRIBUTES ObjectAttributes,
624 IN PCLIENT_ID ClientId
625 );
626
627 NTSYSAPI
628 NTSTATUS
629 NTAPI
630 ZwOpenThread(
631 OUT PHANDLE ThreadHandle,
632 IN ACCESS_MASK DesiredAccess,
633 IN POBJECT_ATTRIBUTES ObjectAttributes,
634 IN PCLIENT_ID ClientId
635 );
636
637 NTSYSAPI
638 NTSTATUS
639 NTAPI
640 ZwOpenThreadToken(
641 IN HANDLE ThreadHandle,
642 IN ACCESS_MASK DesiredAccess,
643 IN BOOLEAN OpenAsSelf,
644 OUT PHANDLE TokenHandle
645 );
646
647 NTSYSAPI
648 NTSTATUS
649 NTAPI
650 ZwOpenThreadTokenEx(
651 IN HANDLE ThreadHandle,
652 IN ACCESS_MASK DesiredAccess,
653 IN BOOLEAN OpenAsSelf,
654 IN ULONG HandleAttributes,
655 OUT PHANDLE TokenHandle
656 );
657
658 NTSYSAPI
659 NTSTATUS
660 NTAPI
661 ZwQueryInformationJobObject(
662 HANDLE JobHandle,
663 JOBOBJECTINFOCLASS JobInformationClass,
664 PVOID JobInformation,
665 ULONG JobInformationLength,
666 PULONG ReturnLength
667 );
668
669 #ifndef _NTDDK_
670 NTSYSAPI
671 NTSTATUS
672 NTAPI
673 ZwQueryInformationProcess(
674 IN HANDLE ProcessHandle,
675 IN PROCESSINFOCLASS ProcessInformationClass,
676 OUT PVOID ProcessInformation,
677 IN ULONG ProcessInformationLength,
678 OUT PULONG ReturnLength OPTIONAL
679 );
680 #endif
681
682 NTSYSAPI
683 NTSTATUS
684 NTAPI
685 ZwQueryInformationThread(
686 IN HANDLE ThreadHandle,
687 IN THREADINFOCLASS ThreadInformationClass,
688 OUT PVOID ThreadInformation,
689 IN ULONG ThreadInformationLength,
690 OUT PULONG ReturnLength
691 );
692
693 NTSYSAPI
694 NTSTATUS
695 NTAPI
696 ZwRegisterThreadTerminatePort(
697 HANDLE TerminationPort
698 );
699
700 NTSYSAPI
701 NTSTATUS
702 NTAPI
703 ZwResumeThread(
704 IN HANDLE ThreadHandle,
705 OUT PULONG SuspendCount
706 );
707
708 NTSYSAPI
709 NTSTATUS
710 NTAPI
711 ZwResumeProcess(
712 IN HANDLE ProcessHandle
713 );
714
715 NTSYSAPI
716 NTSTATUS
717 NTAPI
718 ZwSetInformationJobObject(
719 HANDLE JobHandle,
720 JOBOBJECTINFOCLASS JobInformationClass,
721 PVOID JobInformation,
722 ULONG JobInformationLength
723 );
724
725 NTSYSAPI
726 NTSTATUS
727 NTAPI
728 ZwSetInformationProcess(
729 IN HANDLE ProcessHandle,
730 IN PROCESSINFOCLASS ProcessInformationClass,
731 IN PVOID ProcessInformation,
732 IN ULONG ProcessInformationLength
733 );
734
735 NTSYSAPI
736 NTSTATUS
737 NTAPI
738 ZwSetInformationThread(
739 IN HANDLE ThreadHandle,
740 IN THREADINFOCLASS ThreadInformationClass,
741 IN PVOID ThreadInformation,
742 IN ULONG ThreadInformationLength
743 );
744
745 NTSYSAPI
746 NTSTATUS
747 NTAPI
748 ZwSuspendProcess(
749 IN HANDLE ProcessHandle
750 );
751
752 NTSYSAPI
753 NTSTATUS
754 NTAPI
755 ZwSuspendThread(
756 IN HANDLE ThreadHandle,
757 IN PULONG PreviousSuspendCount
758 );
759
760 NTSYSAPI
761 NTSTATUS
762 NTAPI
763 ZwTerminateProcess(
764 IN HANDLE ProcessHandle,
765 IN NTSTATUS ExitStatus
766 );
767
768 NTSYSAPI
769 NTSTATUS
770 NTAPI
771 ZwTerminateThread(
772 IN HANDLE ThreadHandle,
773 IN NTSTATUS ExitStatus
774 );
775
776 NTSYSAPI
777 NTSTATUS
778 NTAPI
779 ZwTerminateJobObject(
780 HANDLE JobHandle,
781 NTSTATUS ExitStatus
782 );
783
784 #ifdef __cplusplus
785 }
786 #endif
787
788 #endif