1 #ifndef __INCLUDE_DDK_KEFUNCS_H
2 #define __INCLUDE_DDK_KEFUNCS_H
5 /* KERNEL FUNCTIONS ********************************************************/
7 #define KeFlushIoBuffers(Mdl, ReadOperation, DmaOperation)
9 VOID STDCALL KeAttachProcess (struct _EPROCESS* Process);
11 VOID KeDrainApcQueue(VOID);
12 struct _KPROCESS* KeGetCurrentProcess(VOID);
15 * FUNCTION: Acquires a spinlock so the caller can synchronize access to
18 * SpinLock = Initialized spinlock
19 * OldIrql (OUT) = Set the previous irql on return
21 VOID STDCALL KeAcquireSpinLock (PKSPIN_LOCK SpinLock,
24 VOID STDCALL KeAcquireSpinLockAtDpcLevel (PKSPIN_LOCK SpinLock);
27 * FUNCTION: Brings the system down in a controlled manner when an
28 * inconsistency that might otherwise cause corruption has been detected
30 * BugCheckCode = Specifies the reason for the bug check
33 VOID STDCALL KeBugCheck (ULONG BugCheckCode);
37 * FUNCTION: Brings the system down in a controlled manner when an
38 * inconsistency that might otherwise cause corruption has been detected
40 * BugCheckCode = Specifies the reason for the bug check
41 * BugCheckParameter[1-4] = Additional information about bug
44 VOID STDCALL KeBugCheckEx (ULONG BugCheckCode,
45 ULONG BugCheckParameter1,
46 ULONG BugCheckParameter2,
47 ULONG BugCheckParameter3,
48 ULONG BugCheckParameter4);
50 BOOLEAN STDCALL KeCancelTimer (PKTIMER Timer);
52 VOID STDCALL KeClearEvent (PKEVENT Event);
54 NTSTATUS STDCALL KeConnectInterrupt(PKINTERRUPT InterruptObject);
56 NTSTATUS STDCALL KeDelayExecutionThread (KPROCESSOR_MODE WaitMode,
58 PLARGE_INTEGER Internal);
60 BOOLEAN STDCALL KeDeregisterBugCheckCallback (
61 PKBUGCHECK_CALLBACK_RECORD CallbackRecord);
63 VOID STDCALL KeDetachProcess (VOID);
65 VOID STDCALL KeDisconnectInterrupt(PKINTERRUPT InterruptObject);
67 VOID STDCALL KeEnterCriticalRegion (VOID);
70 * FUNCTION: Enters the kernel debugger
74 VOID STDCALL KeEnterKernelDebugger (VOID);
76 VOID STDCALL KeFlushWriteBuffer (VOID);
78 KIRQL STDCALL KeGetCurrentIrql (VOID);
80 ULONG KeGetCurrentProcessorNumber(VOID);
82 struct _KTHREAD* STDCALL KeGetCurrentThread (VOID);
84 ULONG KeGetDcacheFillSize(VOID);
86 ULONG STDCALL KeGetPreviousMode (VOID);
88 VOID STDCALL KeInitializeApc (PKAPC Apc,
89 struct _KTHREAD* Thread,
91 PKKERNEL_ROUTINE KernelRoutine,
92 PKRUNDOWN_ROUTINE RundownRoutine,
93 PKNORMAL_ROUTINE NormalRoutine,
99 * KeInitializeCallbackRecord (
100 * PKBUGCHECK_CALLBACK_RECORD CallbackRecord
103 #define KeInitializeCallbackRecord(CallbackRecord) \
104 (CallbackRecord)->State = BufferEmpty
106 VOID STDCALL KeInitializeDeviceQueue (PKDEVICE_QUEUE DeviceQueue);
108 VOID STDCALL KeInitializeDpc (PKDPC Dpc,
109 PKDEFERRED_ROUTINE DeferredRoutine,
110 PVOID DeferredContext);
112 VOID STDCALL KeInitializeEvent (PKEVENT Event,
116 NTSTATUS STDCALL KeInitializeInterrupt(PKINTERRUPT InterruptObject,
117 PKSERVICE_ROUTINE ServiceRoutine,
118 PVOID ServiceContext,
119 PKSPIN_LOCK SpinLock,
122 KIRQL SynchronizeIrql,
123 KINTERRUPT_MODE InterruptMode,
125 KAFFINITY ProcessorEnableMask,
126 BOOLEAN FloatingSave);
128 VOID STDCALL KeInitializeMutant(IN PKMUTANT Mutant,
129 IN BOOLEAN InitialOwner);
131 VOID STDCALL KeInitializeMutex (PKMUTEX Mutex,
135 KeInitializeQueue(IN PKQUEUE Queue,
138 VOID STDCALL KeInitializeSemaphore (PKSEMAPHORE Semaphore,
143 * FUNCTION: Initializes a spinlock
145 * SpinLock = Spinlock to initialize
147 VOID STDCALL KeInitializeSpinLock (PKSPIN_LOCK SpinLock);
149 VOID STDCALL KeInitializeTimer (PKTIMER Timer);
151 VOID STDCALL KeInitializeTimerEx (PKTIMER Timer,
154 BOOLEAN STDCALL KeInsertByKeyDeviceQueue (PKDEVICE_QUEUE DeviceQueue,
155 PKDEVICE_QUEUE_ENTRY QueueEntry,
158 BOOLEAN STDCALL KeInsertDeviceQueue (PKDEVICE_QUEUE DeviceQueue,
159 PKDEVICE_QUEUE_ENTRY DeviceQueueEntry);
162 KeInsertHeadQueue(IN PKQUEUE Queue,
163 IN PLIST_ENTRY Entry);
166 KeInsertQueue(IN PKQUEUE Queue,
167 IN PLIST_ENTRY Entry);
169 VOID STDCALL KeInsertQueueApc (PKAPC Apc,
170 PVOID SystemArgument1,
171 PVOID SystemArgument2,
174 BOOLEAN STDCALL KeInsertQueueDpc (PKDPC Dpc,
175 PVOID SystemArgument1,
176 PVOID SystemArgument2);
178 VOID STDCALL KeLeaveCriticalRegion (VOID);
180 VOID STDCALL KeLowerIrql (KIRQL NewIrql);
182 NTSTATUS STDCALL KePulseEvent (PKEVENT Event,
188 #else /* !LIBCAPTIVE */
190 #endif /* LIBCAPTIVE */
192 KeQueryPerformanceCounter (
193 PLARGE_INTEGER PerformanceFrequency
199 PLARGE_INTEGER CurrentTime
205 PLARGE_INTEGER TickCount
210 KeQueryTimeIncrement (
223 KeRaiseIrqlToDpcLevel (
229 KeRaiseIrqlToSynchLevel (
234 * FUNCTION: Raises a user mode exception
236 * ExceptionCode = Status code of the exception
240 KeRaiseUserException (
241 IN NTSTATUS ExceptionCode
251 KeReadStateMutant(IN PKMUTANT Mutant);
254 KeReadStateMutex(IN PKMUTEX Mutex);
257 KeReadStateQueue(IN PKQUEUE Queue);
260 KeReadStateSemaphore(IN PKSEMAPHORE Semaphore);
263 KeReadStateTimer(IN PKTIMER Timer);
267 KeRegisterBugCheckCallback (
268 PKBUGCHECK_CALLBACK_RECORD CallbackRecord,
269 PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine,
279 IN KPRIORITY Increment,
294 PKSEMAPHORE Semaphore,
303 PKSPIN_LOCK Spinlock,
309 KeReleaseSpinLockFromDpcLevel (
315 KeRemoveByKeyDeviceQueue (
316 PKDEVICE_QUEUE DeviceQueue,
322 KeRemoveDeviceQueue (
323 PKDEVICE_QUEUE DeviceQueue
327 KeRemoveEntryDeviceQueue(PKDEVICE_QUEUE DeviceQueue,
328 PKDEVICE_QUEUE_ENTRY DeviceQueueEntry);
331 KeRemoveQueue(IN PKQUEUE Queue,
332 IN KPROCESSOR_MODE WaitMode,
333 IN PLARGE_INTEGER Timeout OPTIONAL);
336 KeRemoveQueueDpc(IN PKDPC Dpc);
339 KeResetEvent(IN PKEVENT Event);
342 KeSetBasePriorityThread(struct _KTHREAD* Thread,
353 KPRIORITY STDCALL KeSetPriorityThread (struct _KTHREAD* Thread,
356 BOOLEAN STDCALL KeSetTimer (PKTIMER Timer,
357 LARGE_INTEGER DueTime,
360 BOOLEAN STDCALL KeSetTimerEx (PKTIMER Timer,
361 LARGE_INTEGER DueTime,
365 VOID STDCALL KeStallExecutionProcessor (ULONG MicroSeconds);
367 BOOLEAN STDCALL KeSynchronizeExecution (PKINTERRUPT Interrupt,
368 PKSYNCHRONIZE_ROUTINE SynchronizeRoutine,
369 PVOID SynchronizeContext);
371 NTSTATUS STDCALL KeWaitForMultipleObjects (ULONG Count,
374 KWAIT_REASON WaitReason,
375 KPROCESSOR_MODE WaitMode,
377 PLARGE_INTEGER Timeout,
378 PKWAIT_BLOCK WaitBlockArray);
382 KeWaitForMutexObject (
384 KWAIT_REASON WaitReason,
385 KPROCESSOR_MODE WaitMode,
387 PLARGE_INTEGER Timeout
392 KeWaitForSingleObject (
394 KWAIT_REASON WaitReason,
395 KPROCESSOR_MODE WaitMode,
397 PLARGE_INTEGER Timeout
402 // io permission map has a 8k size
403 // Each bit in the IOPM corresponds to an io port byte address. The bitmap
404 // is initialized to allow IO at any port. [ all bits set ].
412 * FUNCTION: Provides the kernel with a new access map for a driver
414 * NewMap: = If FALSE the kernel's map is set to all disabled. If TRUE
415 * the kernel disables access to a particular port.
416 * IoPortMap = Caller supplies storage for the io permission map.
418 * Each bit in the IOPM corresponds to an io port byte address. The bitmap
419 * is initialized to allow IO at any port. [ all bits set ]. The IOPL determines
420 * the minium privilege level required to perform IO prior to checking the permission map.
422 VOID Ke386SetIoAccessMap(ULONG NewMap, PIOPM *IoPermissionMap);
425 * FUNCTION: Queries the io permission map.
427 * NewMap: = If FALSE the kernel's map is set to all disabled. If TRUE
428 * the kernel disables access to a particular port.
429 * IoPortMap = Caller supplies storage for the io permission map.
431 * Each bit in the IOPM corresponds to an io port byte address. The bitmap
432 * is initialized to allow IO at any port. [ all bits set ]. The IOPL determines
433 * the minium privilege level required to perform IO prior to checking the permission map.
435 VOID Ke386QueryIoAccessMap(BOOLEAN NewMap, PIOPM *IoPermissionMap);
438 * FUNCTION: Set the process IOPL
440 * Eprocess = Pointer to a executive process object
441 * EnableIo = Specify TRUE to enable IO and FALSE to disable
443 NTSTATUS Ke386IoSetAccessProcess(struct _EPROCESS* Eprocess, BOOLEAN EnableIo);
446 * FUNCTION: Releases a set of Global Descriptor Table Selectors
451 NTSTATUS KeI386ReleaseGdtSelectors(OUT PULONG SelArray,
452 IN ULONG NumOfSelectors);
455 * FUNCTION: Allocates a set of Global Descriptor Table Selectors
460 NTSTATUS KeI386AllocateGdtSelectors(OUT PULONG SelArray,
461 IN ULONG NumOfSelectors);
467 IN PKSPIN_LOCK SpinLock
486 IN PKSPIN_LOCK SpinLock,
491 VOID STDCALL KiDeliverApc(ULONG Unknown1,
495 VOID STDCALL KiDispatchInterrupt(VOID);
497 #endif /* __INCLUDE_DDK_KEFUNCS_H */