638e122c07b284d6c88393a5ac8679cd20e9a2b9
[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 KeSetProfileIrql(
291 _In_ KIRQL ProfileIrql
292 );
293
294 VOID
295 NTAPI
296 KeSetTimeIncrement(
297 _In_ ULONG MaxIncrement,
298 _In_ ULONG MinIncrement
299 );
300
301 NTSTATUS
302 NTAPI
303 Ke386CallBios(
304 _In_ ULONG BiosCommand,
305 _Inout_ PCONTEXT BiosArguments
306 );
307
308 //
309 // Misc. Functions
310 //
311 NTSTATUS
312 NTAPI
313 KeUserModeCallback(
314 _In_ ULONG FunctionID,
315 _In_reads_opt_(InputLength) PVOID InputBuffer,
316 _In_ ULONG InputLength,
317 _Outptr_result_buffer_(*OutputLength) PVOID *OutputBuffer,
318 _Out_ PULONG OutputLength
319 );
320
321 NTSTATUS
322 NTAPI
323 KeRaiseUserException(
324 _In_ NTSTATUS ExceptionCode
325 );
326
327 #endif
328
329 //
330 // Native Calls
331 //
332 NTSYSCALLAPI
333 NTSTATUS
334 NTAPI
335 NtContinue(
336 _In_ PCONTEXT Context,
337 _In_ BOOLEAN TestAlert
338 );
339
340 NTSYSCALLAPI
341 NTSTATUS
342 NTAPI
343 NtCallbackReturn(
344 _In_ PVOID Result,
345 _In_ ULONG ResultLength,
346 _In_ NTSTATUS Status
347 );
348
349 NTSYSCALLAPI
350 NTSTATUS
351 NTAPI
352 NtCreateProfile(
353 _Out_ PHANDLE ProfileHandle,
354 _In_ HANDLE ProcessHandle,
355 _In_ PVOID ImageBase,
356 _In_ ULONG ImageSize,
357 _In_ ULONG Granularity,
358 _Out_ PVOID Buffer,
359 _In_ ULONG ProfilingSize,
360 _In_ KPROFILE_SOURCE Source,
361 _In_ KAFFINITY ProcessorMask
362 );
363
364 NTSYSCALLAPI
365 NTSTATUS
366 NTAPI
367 NtDelayExecution(
368 _In_ BOOLEAN Alertable,
369 _In_ LARGE_INTEGER *Interval
370 );
371
372 NTSYSCALLAPI
373 NTSTATUS
374 NTAPI
375 NtFlushInstructionCache(
376 _In_ HANDLE ProcessHandle,
377 _In_ PVOID BaseAddress,
378 _In_ ULONG NumberOfBytesToFlush
379 );
380
381 ULONG
382 NTAPI
383 NtGetCurrentProcessorNumber(
384 VOID
385 );
386
387 NTSYSCALLAPI
388 NTSTATUS
389 NTAPI
390 NtGetContextThread(
391 _In_ HANDLE ThreadHandle,
392 _Out_ PCONTEXT Context
393 );
394
395 NTSYSCALLAPI
396 ULONG
397 NTAPI
398 NtGetTickCount(
399 VOID
400 );
401
402 NTSYSCALLAPI
403 NTSTATUS
404 NTAPI
405 NtQueryIntervalProfile(
406 _In_ KPROFILE_SOURCE ProfileSource,
407 _Out_ PULONG Interval
408 );
409
410 NTSYSCALLAPI
411 NTSTATUS
412 NTAPI
413 NtQueryPerformanceCounter(
414 _Out_ PLARGE_INTEGER Counter,
415 _Out_opt_ PLARGE_INTEGER Frequency
416 );
417
418 NTSYSCALLAPI
419 NTSTATUS
420 NTAPI
421 NtQuerySystemTime(
422 _Out_ PLARGE_INTEGER CurrentTime
423 );
424
425 NTSYSCALLAPI
426 NTSTATUS
427 NTAPI
428 NtQueryTimerResolution(
429 _Out_ PULONG MinimumResolution,
430 _Out_ PULONG MaximumResolution,
431 _Out_ PULONG ActualResolution
432 );
433
434 NTSYSCALLAPI
435 NTSTATUS
436 NTAPI
437 NtQueueApcThread(
438 _In_ HANDLE ThreadHandle,
439 _In_ PKNORMAL_ROUTINE ApcRoutine,
440 _In_opt_ PVOID NormalContext,
441 _In_opt_ PVOID SystemArgument1,
442 _In_opt_ PVOID SystemArgument2
443 );
444
445 NTSYSCALLAPI
446 NTSTATUS
447 NTAPI
448 NtRaiseException(
449 _In_ PEXCEPTION_RECORD ExceptionRecord,
450 _In_ PCONTEXT Context,
451 _In_ BOOLEAN SearchFrames
452 );
453
454 NTSYSCALLAPI
455 NTSTATUS
456 NTAPI
457 NtSetContextThread(
458 _In_ HANDLE ThreadHandle,
459 _In_ PCONTEXT Context
460 );
461
462 NTSYSCALLAPI
463 NTSTATUS
464 NTAPI
465 NtSetIntervalProfile(
466 _In_ ULONG Interval,
467 _In_ KPROFILE_SOURCE ClockSource
468 );
469
470 NTSYSCALLAPI
471 NTSTATUS
472 NTAPI
473 NtSetLdtEntries(
474 _In_ ULONG Selector1,
475 _In_ LDT_ENTRY LdtEntry1,
476 _In_ ULONG Selector2,
477 _In_ LDT_ENTRY LdtEntry2
478 );
479
480 NTSYSCALLAPI
481 NTSTATUS
482 NTAPI
483 NtSetSystemTime(
484 _In_ PLARGE_INTEGER SystemTime,
485 _In_opt_ PLARGE_INTEGER NewSystemTime
486 );
487
488 NTSYSCALLAPI
489 NTSTATUS
490 NTAPI
491 NtSetTimerResolution(
492 _In_ ULONG RequestedResolution,
493 _In_ BOOLEAN SetOrUnset,
494 _Out_ PULONG ActualResolution
495 );
496
497 NTSYSCALLAPI
498 NTSTATUS
499 NTAPI
500 NtStartProfile(
501 _In_ HANDLE ProfileHandle
502 );
503
504 NTSYSCALLAPI
505 NTSTATUS
506 NTAPI
507 NtStopProfile(
508 _In_ HANDLE ProfileHandle
509 );
510
511 NTSYSCALLAPI
512 NTSTATUS
513 NTAPI
514 NtTestAlert(
515 VOID
516 );
517
518 NTSYSCALLAPI
519 NTSTATUS
520 NTAPI
521 NtVdmControl(
522 _In_ ULONG ControlCode,
523 _In_ PVOID ControlData
524 );
525
526 NTSYSCALLAPI
527 NTSTATUS
528 NTAPI
529 NtW32Call(
530 _In_ ULONG RoutineIndex,
531 _In_ PVOID Argument,
532 _In_ ULONG ArgumentLength,
533 _Out_opt_ PVOID* Result,
534 _Out_opt_ PULONG ResultLength
535 );
536
537 NTSYSCALLAPI
538 NTSTATUS
539 NTAPI
540 NtYieldExecution(
541 VOID
542 );
543
544 NTSYSAPI
545 NTSTATUS
546 NTAPI
547 ZwContinue(
548 _In_ PCONTEXT Context,
549 _In_ BOOLEAN TestAlert
550 );
551
552 NTSYSAPI
553 NTSTATUS
554 NTAPI
555 ZwCallbackReturn(
556 _In_ PVOID Result,
557 _In_ ULONG ResultLength,
558 _In_ NTSTATUS Status
559 );
560
561 NTSYSAPI
562 NTSTATUS
563 NTAPI
564 ZwCreateProfile(
565 _Out_ PHANDLE ProfileHandle,
566 _In_ HANDLE ProcessHandle,
567 _In_ PVOID ImageBase,
568 _In_ ULONG ImageSize,
569 _In_ ULONG Granularity,
570 _Out_ PVOID Buffer,
571 _In_ ULONG ProfilingSize,
572 _In_ KPROFILE_SOURCE Source,
573 _In_ KAFFINITY ProcessorMask
574 );
575
576 NTSYSAPI
577 NTSTATUS
578 NTAPI
579 ZwDelayExecution(
580 _In_ BOOLEAN Alertable,
581 _In_ LARGE_INTEGER *Interval
582 );
583
584 NTSYSAPI
585 NTSTATUS
586 NTAPI
587 ZwFlushInstructionCache(
588 _In_ HANDLE ProcessHandle,
589 _In_ PVOID BaseAddress,
590 _In_ ULONG NumberOfBytesToFlush
591 );
592
593 NTSYSAPI
594 NTSTATUS
595 NTAPI
596 ZwGetContextThread(
597 _In_ HANDLE ThreadHandle,
598 _Out_ PCONTEXT Context
599 );
600
601 NTSYSAPI
602 ULONG
603 NTAPI
604 ZwGetTickCount(
605 VOID
606 );
607
608 NTSYSAPI
609 NTSTATUS
610 NTAPI
611 ZwQueryIntervalProfile(
612 _In_ KPROFILE_SOURCE ProfileSource,
613 _Out_ PULONG Interval
614 );
615
616 NTSYSAPI
617 NTSTATUS
618 NTAPI
619 ZwQueryPerformanceCounter(
620 _Out_ PLARGE_INTEGER Counter,
621 _Out_opt_ PLARGE_INTEGER Frequency
622 );
623
624 NTSYSAPI
625 NTSTATUS
626 NTAPI
627 ZwQuerySystemTime(
628 _Out_ PLARGE_INTEGER CurrentTime
629 );
630
631 NTSYSAPI
632 NTSTATUS
633 NTAPI
634 ZwQueryTimerResolution(
635 _Out_ PULONG MinimumResolution,
636 _Out_ PULONG MaximumResolution,
637 _Out_ PULONG ActualResolution
638 );
639
640 NTSYSAPI
641 NTSTATUS
642 NTAPI
643 ZwQueueApcThread(
644 _In_ HANDLE ThreadHandle,
645 _In_ PKNORMAL_ROUTINE ApcRoutine,
646 _In_opt_ PVOID NormalContext,
647 _In_opt_ PVOID SystemArgument1,
648 _In_opt_ PVOID SystemArgument2
649 );
650
651 NTSYSAPI
652 NTSTATUS
653 NTAPI
654 ZwRaiseException(
655 _In_ PEXCEPTION_RECORD ExceptionRecord,
656 _In_ PCONTEXT Context,
657 _In_ BOOLEAN SearchFrames
658 );
659
660 NTSYSAPI
661 NTSTATUS
662 NTAPI
663 ZwSetContextThread(
664 _In_ HANDLE ThreadHandle,
665 _In_ PCONTEXT Context
666 );
667
668 NTSYSAPI
669 NTSTATUS
670 NTAPI
671 ZwSetIntervalProfile(
672 _In_ ULONG Interval,
673 _In_ KPROFILE_SOURCE ClockSource
674 );
675
676 NTSYSAPI
677 NTSTATUS
678 NTAPI
679 ZwSetLdtEntries(
680 _In_ ULONG Selector1,
681 _In_ LDT_ENTRY LdtEntry1,
682 _In_ ULONG Selector2,
683 _In_ LDT_ENTRY LdtEntry2
684 );
685
686 NTSYSAPI
687 NTSTATUS
688 NTAPI
689 ZwSetSystemTime(
690 _In_ PLARGE_INTEGER SystemTime,
691 _In_opt_ PLARGE_INTEGER NewSystemTime
692 );
693
694 NTSYSAPI
695 NTSTATUS
696 NTAPI
697 ZwSetTimerResolution(
698 _In_ ULONG RequestedResolution,
699 _In_ BOOLEAN SetOrUnset,
700 _Out_ PULONG ActualResolution
701 );
702
703 NTSYSAPI
704 NTSTATUS
705 NTAPI
706 ZwStartProfile(
707 _In_ HANDLE ProfileHandle
708 );
709
710 NTSYSAPI
711 NTSTATUS
712 NTAPI
713 ZwStopProfile(
714 _In_ HANDLE ProfileHandle
715 );
716
717 NTSYSAPI
718 NTSTATUS
719 NTAPI
720 ZwTestAlert(
721 VOID
722 );
723
724 NTSYSAPI
725 NTSTATUS
726 NTAPI
727 ZwVdmControl(
728 _In_ ULONG ControlCode,
729 _In_ PVOID ControlData
730 );
731
732 NTSYSAPI
733 NTSTATUS
734 NTAPI
735 ZwW32Call(
736 _In_ ULONG RoutineIndex,
737 _In_ PVOID Argument,
738 _In_ ULONG ArgumentLength,
739 _Out_opt_ PVOID* Result,
740 _Out_opt_ PULONG ResultLength
741 );
742
743 NTSYSAPI
744 NTSTATUS
745 NTAPI
746 ZwYieldExecution(
747 VOID
748 );
749 #endif