3 Copyright (c) Alex Ionescu. All rights reserved.
11 Functions definitions for the Kernel services.
15 Alex Ionescu (alexi@tinykrnl.org) - Updated - 27-Feb-2006
28 #ifndef NTOS_MODE_USER
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
,
50 _In_ PVOID SystemArgument1
,
51 _In_ PVOID SystemArgument2
,
52 _In_ KPRIORITY PriorityBoost
58 _In_ KPROCESSOR_MODE PreviousMode
,
60 _In_ PKEXCEPTION_FRAME ExceptionFrame
,
62 _Reserved_ PKEXCEPTION_FRAME ExceptionFrame
,
64 _In_ PKTRAP_FRAME TrapFrame
68 // Process/Thread Functions
73 _In_ KPRIORITY Increment
84 KeSetEventBoostPriority(
86 _In_opt_ PKTHREAD
*Thread
92 _Inout_ PKTHREAD Thread
,
93 _In_ KAFFINITY Affinity
104 KeAddSystemServiceTable(
105 _In_ PULONG_PTR Base
,
106 _In_opt_ PULONG Count
,
113 // Spinlock Functions
118 _Inout_ PKSPIN_LOCK SpinLock
124 _Inout_ PKSPIN_LOCK SpinLock
129 KeAcquireQueuedSpinLockRaiseToSynch(
130 _In_ KSPIN_LOCK_QUEUE_NUMBER LockNumber
135 KeTryToAcquireQueuedSpinLockRaiseToSynch(
136 _In_ KSPIN_LOCK_QUEUE_NUMBER LockNumber
,
142 KeAcquireInStackQueuedSpinLockRaiseToSynch(
143 _In_ PKSPIN_LOCK SpinLock
,
144 _In_ PKLOCK_QUEUE_HANDLE LockHandle
149 // Interrupt Functions
153 KeInitializeInterrupt(
154 _Out_ PKINTERRUPT InterruptObject
,
155 _In_ PKSERVICE_ROUTINE ServiceRoutine
,
156 _In_ PVOID ServiceContext
,
157 _In_ PKSPIN_LOCK SpinLock
,
160 _In_ KIRQL SynchronizeIrql
,
161 _In_ KINTERRUPT_MODE InterruptMode
,
162 _In_ BOOLEAN ShareVector
,
163 _In_ CHAR ProcessorNumber
,
164 _In_ BOOLEAN FloatingSave
170 _Inout_ PKINTERRUPT InterruptObject
175 KeDisconnectInterrupt(
176 _Inout_ PKINTERRUPT InterruptObject
194 KiUnexpectedInterrupt(
200 KeEnterKernelDebugger(
213 _In_ PKTRAP_FRAME TrapFrame
,
215 _In_ PKEXCEPTION_FRAME ExceptionFrame
217 _Reserved_ PKEXCEPTION_FRAME ExceptionFrame
222 // Generic DPC Routines
227 _In_ PKDEFERRED_ROUTINE Routine
,
234 _In_ PVOID SystemArgument1
239 KeSignalCallDpcSynchronize(
240 _In_ PVOID SystemArgument2
244 // ARC Configuration Functions. Only enabled if you have ARC Support
247 PCONFIGURATION_COMPONENT_DATA
249 KeFindConfigurationNextEntry(
250 _In_ PCONFIGURATION_COMPONENT_DATA Child
,
251 _In_ CONFIGURATION_CLASS Class
,
252 _In_ CONFIGURATION_TYPE Type
,
253 _In_opt_ PULONG ComponentKey
,
254 _In_ PCONFIGURATION_COMPONENT_DATA
*NextLink
257 PCONFIGURATION_COMPONENT_DATA
259 KeFindConfigurationEntry(
260 _In_ PCONFIGURATION_COMPONENT_DATA Child
,
261 _In_ CONFIGURATION_CLASS Class
,
262 _In_ CONFIGURATION_TYPE Type
,
263 _In_opt_ PULONG ComponentKey
268 // Low-level Hardware/CPU Control Functions
273 _In_ BOOLEAN Invalid
,
274 _In_ BOOLEAN AllProcessors
293 _In_ PKTRAP_FRAME TrapFrame
298 KeProfileInterruptWithSource(
299 _In_ PKTRAP_FRAME TrapFrame
,
300 _In_ KPROFILE_SOURCE Source
306 _In_ KIRQL ProfileIrql
312 _In_ ULONG MaxIncrement
,
313 _In_ ULONG MinIncrement
319 _In_ ULONG BiosCommand
,
320 _Inout_ PCONTEXT BiosArguments
329 _In_ ULONG FunctionID
,
330 _In_reads_opt_(InputLength
) PVOID InputBuffer
,
331 _In_ ULONG InputLength
,
332 _Outptr_result_buffer_(*OutputLength
) PVOID
*OutputBuffer
,
333 _Out_ PULONG OutputLength
338 KeRaiseUserException(
339 _In_ NTSTATUS ExceptionCode
351 _In_ PCONTEXT Context
,
352 _In_ BOOLEAN TestAlert
360 _In_ ULONG ResultLength
,
368 _Out_ PHANDLE ProfileHandle
,
369 _In_ HANDLE ProcessHandle
,
370 _In_ PVOID ImageBase
,
371 _In_ SIZE_T ImageSize
,
372 _In_ ULONG Granularity
,
374 _In_ ULONG ProfilingSize
,
375 _In_ KPROFILE_SOURCE Source
,
376 _In_ KAFFINITY ProcessorMask
383 _Out_ PHANDLE ProfileHandle
,
384 _In_ HANDLE ProcessHandle
,
385 _In_ PVOID ImageBase
,
386 _In_ SIZE_T ImageSize
,
387 _In_ ULONG Granularity
,
389 _In_ ULONG ProfilingSize
,
390 _In_ KPROFILE_SOURCE Source
,
391 _In_ USHORT GroupCount
,
392 _In_reads_(GroupCount
) PGROUP_AFFINITY Affinity
399 _In_ BOOLEAN Alertable
,
400 _In_ LARGE_INTEGER
*Interval
405 NtGetCurrentProcessorNumber(
413 _In_ HANDLE ThreadHandle
,
414 _Out_ PCONTEXT Context
427 NtQueryIntervalProfile(
428 _In_ KPROFILE_SOURCE ProfileSource
,
429 _Out_ PULONG Interval
435 NtQueryPerformanceCounter(
436 _Out_ PLARGE_INTEGER Counter
,
437 _Out_opt_ PLARGE_INTEGER Frequency
444 _Out_ PLARGE_INTEGER CurrentTime
450 NtQueryTimerResolution(
451 _Out_ PULONG MinimumResolution
,
452 _Out_ PULONG MaximumResolution
,
453 _Out_ PULONG ActualResolution
460 _In_ HANDLE ThreadHandle
,
461 _In_ PKNORMAL_ROUTINE ApcRoutine
,
462 _In_opt_ PVOID NormalContext
,
463 _In_opt_ PVOID SystemArgument1
,
464 _In_opt_ PVOID SystemArgument2
471 _In_ PEXCEPTION_RECORD ExceptionRecord
,
472 _In_ PCONTEXT Context
,
473 _In_ BOOLEAN SearchFrames
480 _In_ HANDLE ThreadHandle
,
481 _In_ PCONTEXT Context
487 NtSetIntervalProfile(
489 _In_ KPROFILE_SOURCE ClockSource
496 _In_ ULONG Selector1
,
497 _In_ LDT_ENTRY LdtEntry1
,
498 _In_ ULONG Selector2
,
499 _In_ LDT_ENTRY LdtEntry2
506 _In_ PLARGE_INTEGER SystemTime
,
507 _In_opt_ PLARGE_INTEGER NewSystemTime
513 NtSetTimerResolution(
514 _In_ ULONG RequestedResolution
,
515 _In_ BOOLEAN SetOrUnset
,
516 _Out_ PULONG ActualResolution
523 _In_ HANDLE ProfileHandle
530 _In_ HANDLE ProfileHandle
544 _In_ ULONG ControlCode
,
545 _In_ PVOID ControlData
552 _In_ ULONG RoutineIndex
,
554 _In_ ULONG ArgumentLength
,
555 _Out_opt_ PVOID
* Result
,
556 _Out_opt_ PULONG ResultLength
570 _In_ PCONTEXT Context
,
571 _In_ BOOLEAN TestAlert
579 _In_ ULONG ResultLength
,
587 _Out_ PHANDLE ProfileHandle
,
588 _In_ HANDLE ProcessHandle
,
589 _In_ PVOID ImageBase
,
590 _In_ ULONG ImageSize
,
591 _In_ ULONG Granularity
,
593 _In_ ULONG ProfilingSize
,
594 _In_ KPROFILE_SOURCE Source
,
595 _In_ KAFFINITY ProcessorMask
602 _In_ BOOLEAN Alertable
,
603 _In_ LARGE_INTEGER
*Interval
609 ZwFlushInstructionCache(
610 _In_ HANDLE ProcessHandle
,
611 _In_ PVOID BaseAddress
,
612 _In_ ULONG NumberOfBytesToFlush
619 _In_ HANDLE ThreadHandle
,
620 _Out_ PCONTEXT Context
633 ZwQueryIntervalProfile(
634 _In_ KPROFILE_SOURCE ProfileSource
,
635 _Out_ PULONG Interval
641 ZwQueryPerformanceCounter(
642 _Out_ PLARGE_INTEGER Counter
,
643 _Out_opt_ PLARGE_INTEGER Frequency
650 _Out_ PLARGE_INTEGER CurrentTime
656 ZwQueryTimerResolution(
657 _Out_ PULONG MinimumResolution
,
658 _Out_ PULONG MaximumResolution
,
659 _Out_ PULONG ActualResolution
666 _In_ HANDLE ThreadHandle
,
667 _In_ PKNORMAL_ROUTINE ApcRoutine
,
668 _In_opt_ PVOID NormalContext
,
669 _In_opt_ PVOID SystemArgument1
,
670 _In_opt_ PVOID SystemArgument2
677 _In_ PEXCEPTION_RECORD ExceptionRecord
,
678 _In_ PCONTEXT Context
,
679 _In_ BOOLEAN SearchFrames
686 _In_ HANDLE ThreadHandle
,
687 _In_ PCONTEXT Context
693 ZwSetIntervalProfile(
695 _In_ KPROFILE_SOURCE ClockSource
702 _In_ ULONG Selector1
,
703 _In_ LDT_ENTRY LdtEntry1
,
704 _In_ ULONG Selector2
,
705 _In_ LDT_ENTRY LdtEntry2
712 _In_ PLARGE_INTEGER SystemTime
,
713 _In_opt_ PLARGE_INTEGER NewSystemTime
719 ZwSetTimerResolution(
720 _In_ ULONG RequestedResolution
,
721 _In_ BOOLEAN SetOrUnset
,
722 _Out_ PULONG ActualResolution
729 _In_ HANDLE ProfileHandle
736 _In_ HANDLE ProfileHandle
750 _In_ ULONG ControlCode
,
751 _In_ PVOID ControlData
758 _In_ ULONG RoutineIndex
,
760 _In_ ULONG ArgumentLength
,
761 _Out_opt_ PVOID
* Result
,
762 _Out_opt_ PULONG ResultLength