[NDK][NTOS]
[reactos.git] / reactos / include / ndk / kefuncs.h
1 /*++ NDK Version: 0098
2
3 Copyright (c) Alex Ionescu. All rights reserved.
4
5 Header Name:
6
7 kefuncs.h
8
9 Abstract:
10
11 Functions definitions for the Kernel services.
12
13 Author:
14
15 Alex Ionescu (alexi@tinykrnl.org) - Updated - 27-Feb-2006
16
17 --*/
18
19 #ifndef _KEFUNCS_H
20 #define _KEFUNCS_H
21
22 //
23 // Dependencies
24 //
25 #include <umtypes.h>
26 #include <ketypes.h>
27
28 #ifndef NTOS_MODE_USER
29
30 //
31 // APC Functions
32 //
33 VOID
34 NTAPI
35 KeInitializeApc(
36 _In_ PKAPC Apc,
37 _In_ PKTHREAD Thread,
38 _In_ KAPC_ENVIRONMENT TargetEnvironment,
39 _In_ PKKERNEL_ROUTINE KernelRoutine,
40 _In_opt_ PKRUNDOWN_ROUTINE RundownRoutine,
41 _In_ PKNORMAL_ROUTINE NormalRoutine,
42 _In_ KPROCESSOR_MODE Mode,
43 _In_ PVOID Context
44 );
45
46 BOOLEAN
47 NTAPI
48 KeInsertQueueApc(
49 _In_ PKAPC Apc,
50 _In_ PVOID SystemArgument1,
51 _In_ PVOID SystemArgument2,
52 _In_ KPRIORITY PriorityBoost
53 );
54
55 VOID
56 NTAPI
57 KiDeliverApc(
58 _In_ KPROCESSOR_MODE PreviousMode,
59 #ifdef _M_AMD64
60 _In_ PKEXCEPTION_FRAME ExceptionFrame,
61 #else
62 _Reserved_ PKEXCEPTION_FRAME ExceptionFrame,
63 #endif
64 _In_ PKTRAP_FRAME TrapFrame
65 );
66
67 //
68 // Process/Thread Functions
69 //
70 VOID
71 NTAPI
72 KeTerminateThread(
73 _In_ KPRIORITY Increment
74 );
75
76 BOOLEAN
77 NTAPI
78 KeIsAttachedProcess(
79 VOID
80 );
81
82 VOID
83 NTAPI
84 KeSetEventBoostPriority(
85 _In_ PKEVENT Event,
86 _In_opt_ PKTHREAD *Thread
87 );
88
89 KAFFINITY
90 NTAPI
91 KeSetAffinityThread(
92 _Inout_ PKTHREAD Thread,
93 _In_ KAFFINITY Affinity
94 );
95
96 PKPROCESS
97 NTAPI
98 KeGetCurrentProcess(
99 VOID
100 );
101
102 BOOLEAN
103 NTAPI
104 KeAddSystemServiceTable(
105 _In_ PULONG_PTR Base,
106 _In_opt_ PULONG Count,
107 _In_ ULONG Limit,
108 _In_ PUCHAR Number,
109 _In_ ULONG Index
110 );
111
112 //
113 // Spinlock Functions
114 //
115 VOID
116 FASTCALL
117 KiAcquireSpinLock(
118 _Inout_ PKSPIN_LOCK SpinLock
119 );
120
121 VOID
122 FASTCALL
123 KiReleaseSpinLock(
124 _Inout_ PKSPIN_LOCK SpinLock
125 );
126
127 KIRQL
128 FASTCALL
129 KeAcquireQueuedSpinLockRaiseToSynch(
130 _In_ KSPIN_LOCK_QUEUE_NUMBER LockNumber
131 );
132
133 BOOLEAN
134 FASTCALL
135 KeTryToAcquireQueuedSpinLockRaiseToSynch(
136 _In_ KSPIN_LOCK_QUEUE_NUMBER LockNumber,
137 _In_ PKIRQL OldIrql
138 );
139
140 VOID
141 FASTCALL
142 KeAcquireInStackQueuedSpinLockRaiseToSynch(
143 _In_ PKSPIN_LOCK SpinLock,
144 _In_ PKLOCK_QUEUE_HANDLE LockHandle
145 );
146
147
148 //
149 // Interrupt Functions
150 //
151 VOID
152 NTAPI
153 KeInitializeInterrupt(
154 _Out_ PKINTERRUPT InterruptObject,
155 _In_ PKSERVICE_ROUTINE ServiceRoutine,
156 _In_ PVOID ServiceContext,
157 _In_ PKSPIN_LOCK SpinLock,
158 _In_ ULONG Vector,
159 _In_ KIRQL Irql,
160 _In_ KIRQL SynchronizeIrql,
161 _In_ KINTERRUPT_MODE InterruptMode,
162 _In_ BOOLEAN ShareVector,
163 _In_ CHAR ProcessorNumber,
164 _In_ BOOLEAN FloatingSave
165 );
166
167 BOOLEAN
168 NTAPI
169 KeConnectInterrupt(
170 _Inout_ PKINTERRUPT InterruptObject
171 );
172
173 BOOLEAN
174 NTAPI
175 KeDisconnectInterrupt(
176 _Inout_ PKINTERRUPT InterruptObject
177 );
178
179 VOID
180 NTAPI
181 KiDispatchInterrupt(
182 VOID
183 );
184
185 VOID
186 NTAPI
187 KiCoprocessorError(
188 VOID
189 );
190
191 VOID
192 KiUnexpectedInterrupt(
193 VOID
194 );
195
196 VOID
197 NTAPI
198 KeEnterKernelDebugger(
199 VOID
200 );
201
202 BOOLEAN
203 NTAPI
204 KeIsExecutingDpc(
205 VOID
206 );
207
208 BOOLEAN
209 NTAPI
210 KiIpiServiceRoutine(
211 _In_ PKTRAP_FRAME TrapFrame,
212 #ifdef _M_AMD64
213 _In_ PKEXCEPTION_FRAME ExceptionFrame
214 #else
215 _Reserved_ PKEXCEPTION_FRAME ExceptionFrame
216 #endif
217 );
218
219 //
220 // Generic DPC Routines
221 //
222 VOID
223 NTAPI
224 KeGenericCallDpc(
225 _In_ PKDEFERRED_ROUTINE Routine,
226 _In_ PVOID Context
227 );
228
229 VOID
230 NTAPI
231 KeSignalCallDpcDone(
232 _In_ PVOID SystemArgument1
233 );
234
235 BOOLEAN
236 NTAPI
237 KeSignalCallDpcSynchronize(
238 _In_ PVOID SystemArgument2
239 );
240
241 //
242 // ARC Configuration Functions. Only enabled if you have ARC Support
243 //
244 #ifdef _ARC_
245 PCONFIGURATION_COMPONENT_DATA
246 NTAPI
247 KeFindConfigurationNextEntry(
248 _In_ PCONFIGURATION_COMPONENT_DATA Child,
249 _In_ CONFIGURATION_CLASS Class,
250 _In_ CONFIGURATION_TYPE Type,
251 _In_opt_ PULONG ComponentKey,
252 _In_ PCONFIGURATION_COMPONENT_DATA *NextLink
253 );
254
255 PCONFIGURATION_COMPONENT_DATA
256 NTAPI
257 KeFindConfigurationEntry(
258 _In_ PCONFIGURATION_COMPONENT_DATA Child,
259 _In_ CONFIGURATION_CLASS Class,
260 _In_ CONFIGURATION_TYPE Type,
261 _In_opt_ PULONG ComponentKey
262 );
263 #endif
264
265 //
266 // Low-level Hardware/CPU Control Functions
267 //
268 VOID
269 NTAPI
270 KeFlushEntireTb(
271 _In_ BOOLEAN Invalid,
272 _In_ BOOLEAN AllProcessors
273 );
274
275 VOID
276 NTAPI
277 KeSetDmaIoCoherency(
278 _In_ ULONG Coherency
279 );
280
281 VOID
282 KeSetGdtSelector(
283 _In_ ULONG Entry,
284 _In_ ULONG Value1,
285 _In_ ULONG Value2
286 );
287
288 VOID
289 NTAPI
290 KeProfileInterrupt(
291 _In_ PKTRAP_FRAME TrapFrame
292 );
293
294 VOID
295 NTAPI
296 KeProfileInterruptWithSource(
297 _In_ PKTRAP_FRAME TrapFrame,
298 _In_ KPROFILE_SOURCE Source
299 );
300
301 VOID
302 NTAPI
303 KeSetProfileIrql(
304 _In_ KIRQL ProfileIrql
305 );
306
307 VOID
308 NTAPI
309 KeSetTimeIncrement(
310 _In_ ULONG MaxIncrement,
311 _In_ ULONG MinIncrement
312 );
313
314 NTSTATUS
315 NTAPI
316 Ke386CallBios(
317 _In_ ULONG BiosCommand,
318 _Inout_ PCONTEXT BiosArguments
319 );
320
321 //
322 // Misc. Functions
323 //
324 NTSTATUS
325 NTAPI
326 KeUserModeCallback(
327 _In_ ULONG FunctionID,
328 _In_reads_opt_(InputLength) PVOID InputBuffer,
329 _In_ ULONG InputLength,
330 _Outptr_result_buffer_(*OutputLength) PVOID *OutputBuffer,
331 _Out_ PULONG OutputLength
332 );
333
334 NTSTATUS
335 NTAPI
336 KeRaiseUserException(
337 _In_ NTSTATUS ExceptionCode
338 );
339
340 #endif
341
342 //
343 // Native Calls
344 //
345 NTSYSCALLAPI
346 NTSTATUS
347 NTAPI
348 NtContinue(
349 _In_ PCONTEXT Context,
350 _In_ BOOLEAN TestAlert
351 );
352
353 NTSYSCALLAPI
354 NTSTATUS
355 NTAPI
356 NtCallbackReturn(
357 _In_ PVOID Result,
358 _In_ ULONG ResultLength,
359 _In_ NTSTATUS Status
360 );
361
362 NTSYSCALLAPI
363 NTSTATUS
364 NTAPI
365 NtCreateProfile(
366 _Out_ PHANDLE ProfileHandle,
367 _In_ HANDLE ProcessHandle,
368 _In_ PVOID ImageBase,
369 _In_ SIZE_T ImageSize,
370 _In_ ULONG Granularity,
371 _Out_ PVOID Buffer,
372 _In_ ULONG ProfilingSize,
373 _In_ KPROFILE_SOURCE Source,
374 _In_ KAFFINITY ProcessorMask
375 );
376
377 NTSYSCALLAPI
378 NTSTATUS
379 NTAPI
380 NtCreateProfileEx(
381 _Out_ PHANDLE ProfileHandle,
382 _In_ HANDLE ProcessHandle,
383 _In_ PVOID ImageBase,
384 _In_ SIZE_T ImageSize,
385 _In_ ULONG Granularity,
386 _Out_ PVOID Buffer,
387 _In_ ULONG ProfilingSize,
388 _In_ KPROFILE_SOURCE Source,
389 _In_ USHORT GroupCount,
390 _In_reads_(GroupCount) PGROUP_AFFINITY Affinity
391 );
392
393 NTSYSCALLAPI
394 NTSTATUS
395 NTAPI
396 NtDelayExecution(
397 _In_ BOOLEAN Alertable,
398 _In_ LARGE_INTEGER *Interval
399 );
400
401 NTSYSCALLAPI
402 NTSTATUS
403 NTAPI
404 NtFlushInstructionCache(
405 _In_ HANDLE ProcessHandle,
406 _In_ PVOID BaseAddress,
407 _In_ ULONG NumberOfBytesToFlush
408 );
409
410 ULONG
411 NTAPI
412 NtGetCurrentProcessorNumber(
413 VOID
414 );
415
416 NTSYSCALLAPI
417 NTSTATUS
418 NTAPI
419 NtGetContextThread(
420 _In_ HANDLE ThreadHandle,
421 _Out_ PCONTEXT Context
422 );
423
424 NTSYSCALLAPI
425 ULONG
426 NTAPI
427 NtGetTickCount(
428 VOID
429 );
430
431 NTSYSCALLAPI
432 NTSTATUS
433 NTAPI
434 NtQueryIntervalProfile(
435 _In_ KPROFILE_SOURCE ProfileSource,
436 _Out_ PULONG Interval
437 );
438
439 NTSYSCALLAPI
440 NTSTATUS
441 NTAPI
442 NtQueryPerformanceCounter(
443 _Out_ PLARGE_INTEGER Counter,
444 _Out_opt_ PLARGE_INTEGER Frequency
445 );
446
447 NTSYSCALLAPI
448 NTSTATUS
449 NTAPI
450 NtQuerySystemTime(
451 _Out_ PLARGE_INTEGER CurrentTime
452 );
453
454 NTSYSCALLAPI
455 NTSTATUS
456 NTAPI
457 NtQueryTimerResolution(
458 _Out_ PULONG MinimumResolution,
459 _Out_ PULONG MaximumResolution,
460 _Out_ PULONG ActualResolution
461 );
462
463 NTSYSCALLAPI
464 NTSTATUS
465 NTAPI
466 NtQueueApcThread(
467 _In_ HANDLE ThreadHandle,
468 _In_ PKNORMAL_ROUTINE ApcRoutine,
469 _In_opt_ PVOID NormalContext,
470 _In_opt_ PVOID SystemArgument1,
471 _In_opt_ PVOID SystemArgument2
472 );
473
474 NTSYSCALLAPI
475 NTSTATUS
476 NTAPI
477 NtRaiseException(
478 _In_ PEXCEPTION_RECORD ExceptionRecord,
479 _In_ PCONTEXT Context,
480 _In_ BOOLEAN SearchFrames
481 );
482
483 NTSYSCALLAPI
484 NTSTATUS
485 NTAPI
486 NtSetContextThread(
487 _In_ HANDLE ThreadHandle,
488 _In_ PCONTEXT Context
489 );
490
491 NTSYSCALLAPI
492 NTSTATUS
493 NTAPI
494 NtSetIntervalProfile(
495 _In_ ULONG Interval,
496 _In_ KPROFILE_SOURCE ClockSource
497 );
498
499 NTSYSCALLAPI
500 NTSTATUS
501 NTAPI
502 NtSetLdtEntries(
503 _In_ ULONG Selector1,
504 _In_ LDT_ENTRY LdtEntry1,
505 _In_ ULONG Selector2,
506 _In_ LDT_ENTRY LdtEntry2
507 );
508
509 NTSYSCALLAPI
510 NTSTATUS
511 NTAPI
512 NtSetSystemTime(
513 _In_ PLARGE_INTEGER SystemTime,
514 _In_opt_ PLARGE_INTEGER NewSystemTime
515 );
516
517 NTSYSCALLAPI
518 NTSTATUS
519 NTAPI
520 NtSetTimerResolution(
521 _In_ ULONG RequestedResolution,
522 _In_ BOOLEAN SetOrUnset,
523 _Out_ PULONG ActualResolution
524 );
525
526 NTSYSCALLAPI
527 NTSTATUS
528 NTAPI
529 NtStartProfile(
530 _In_ HANDLE ProfileHandle
531 );
532
533 NTSYSCALLAPI
534 NTSTATUS
535 NTAPI
536 NtStopProfile(
537 _In_ HANDLE ProfileHandle
538 );
539
540 NTSYSCALLAPI
541 NTSTATUS
542 NTAPI
543 NtTestAlert(
544 VOID
545 );
546
547 NTSYSCALLAPI
548 NTSTATUS
549 NTAPI
550 NtVdmControl(
551 _In_ ULONG ControlCode,
552 _In_ PVOID ControlData
553 );
554
555 NTSYSCALLAPI
556 NTSTATUS
557 NTAPI
558 NtW32Call(
559 _In_ ULONG RoutineIndex,
560 _In_ PVOID Argument,
561 _In_ ULONG ArgumentLength,
562 _Out_opt_ PVOID* Result,
563 _Out_opt_ PULONG ResultLength
564 );
565
566 NTSYSCALLAPI
567 NTSTATUS
568 NTAPI
569 NtYieldExecution(
570 VOID
571 );
572
573 NTSYSAPI
574 NTSTATUS
575 NTAPI
576 ZwContinue(
577 _In_ PCONTEXT Context,
578 _In_ BOOLEAN TestAlert
579 );
580
581 NTSYSAPI
582 NTSTATUS
583 NTAPI
584 ZwCallbackReturn(
585 _In_ PVOID Result,
586 _In_ ULONG ResultLength,
587 _In_ NTSTATUS Status
588 );
589
590 NTSYSAPI
591 NTSTATUS
592 NTAPI
593 ZwCreateProfile(
594 _Out_ PHANDLE ProfileHandle,
595 _In_ HANDLE ProcessHandle,
596 _In_ PVOID ImageBase,
597 _In_ ULONG ImageSize,
598 _In_ ULONG Granularity,
599 _Out_ PVOID Buffer,
600 _In_ ULONG ProfilingSize,
601 _In_ KPROFILE_SOURCE Source,
602 _In_ KAFFINITY ProcessorMask
603 );
604
605 NTSYSAPI
606 NTSTATUS
607 NTAPI
608 ZwDelayExecution(
609 _In_ BOOLEAN Alertable,
610 _In_ LARGE_INTEGER *Interval
611 );
612
613 NTSYSAPI
614 NTSTATUS
615 NTAPI
616 ZwFlushInstructionCache(
617 _In_ HANDLE ProcessHandle,
618 _In_ PVOID BaseAddress,
619 _In_ ULONG NumberOfBytesToFlush
620 );
621
622 NTSYSAPI
623 NTSTATUS
624 NTAPI
625 ZwGetContextThread(
626 _In_ HANDLE ThreadHandle,
627 _Out_ PCONTEXT Context
628 );
629
630 NTSYSAPI
631 ULONG
632 NTAPI
633 ZwGetTickCount(
634 VOID
635 );
636
637 NTSYSAPI
638 NTSTATUS
639 NTAPI
640 ZwQueryIntervalProfile(
641 _In_ KPROFILE_SOURCE ProfileSource,
642 _Out_ PULONG Interval
643 );
644
645 NTSYSAPI
646 NTSTATUS
647 NTAPI
648 ZwQueryPerformanceCounter(
649 _Out_ PLARGE_INTEGER Counter,
650 _Out_opt_ PLARGE_INTEGER Frequency
651 );
652
653 NTSYSAPI
654 NTSTATUS
655 NTAPI
656 ZwQuerySystemTime(
657 _Out_ PLARGE_INTEGER CurrentTime
658 );
659
660 NTSYSAPI
661 NTSTATUS
662 NTAPI
663 ZwQueryTimerResolution(
664 _Out_ PULONG MinimumResolution,
665 _Out_ PULONG MaximumResolution,
666 _Out_ PULONG ActualResolution
667 );
668
669 NTSYSAPI
670 NTSTATUS
671 NTAPI
672 ZwQueueApcThread(
673 _In_ HANDLE ThreadHandle,
674 _In_ PKNORMAL_ROUTINE ApcRoutine,
675 _In_opt_ PVOID NormalContext,
676 _In_opt_ PVOID SystemArgument1,
677 _In_opt_ PVOID SystemArgument2
678 );
679
680 NTSYSAPI
681 NTSTATUS
682 NTAPI
683 ZwRaiseException(
684 _In_ PEXCEPTION_RECORD ExceptionRecord,
685 _In_ PCONTEXT Context,
686 _In_ BOOLEAN SearchFrames
687 );
688
689 NTSYSAPI
690 NTSTATUS
691 NTAPI
692 ZwSetContextThread(
693 _In_ HANDLE ThreadHandle,
694 _In_ PCONTEXT Context
695 );
696
697 NTSYSAPI
698 NTSTATUS
699 NTAPI
700 ZwSetIntervalProfile(
701 _In_ ULONG Interval,
702 _In_ KPROFILE_SOURCE ClockSource
703 );
704
705 NTSYSAPI
706 NTSTATUS
707 NTAPI
708 ZwSetLdtEntries(
709 _In_ ULONG Selector1,
710 _In_ LDT_ENTRY LdtEntry1,
711 _In_ ULONG Selector2,
712 _In_ LDT_ENTRY LdtEntry2
713 );
714
715 NTSYSAPI
716 NTSTATUS
717 NTAPI
718 ZwSetSystemTime(
719 _In_ PLARGE_INTEGER SystemTime,
720 _In_opt_ PLARGE_INTEGER NewSystemTime
721 );
722
723 NTSYSAPI
724 NTSTATUS
725 NTAPI
726 ZwSetTimerResolution(
727 _In_ ULONG RequestedResolution,
728 _In_ BOOLEAN SetOrUnset,
729 _Out_ PULONG ActualResolution
730 );
731
732 NTSYSAPI
733 NTSTATUS
734 NTAPI
735 ZwStartProfile(
736 _In_ HANDLE ProfileHandle
737 );
738
739 NTSYSAPI
740 NTSTATUS
741 NTAPI
742 ZwStopProfile(
743 _In_ HANDLE ProfileHandle
744 );
745
746 NTSYSAPI
747 NTSTATUS
748 NTAPI
749 ZwTestAlert(
750 VOID
751 );
752
753 NTSYSAPI
754 NTSTATUS
755 NTAPI
756 ZwVdmControl(
757 _In_ ULONG ControlCode,
758 _In_ PVOID ControlData
759 );
760
761 NTSYSAPI
762 NTSTATUS
763 NTAPI
764 ZwW32Call(
765 _In_ ULONG RoutineIndex,
766 _In_ PVOID Argument,
767 _In_ ULONG ArgumentLength,
768 _Out_opt_ PVOID* Result,
769 _Out_opt_ PULONG ResultLength
770 );
771
772 NTSYSAPI
773 NTSTATUS
774 NTAPI
775 ZwYieldExecution(
776 VOID
777 );
778 #endif