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,
139 KeRundownQueue(IN PKQUEUE Queue);
141 VOID STDCALL KeInitializeSemaphore (PKSEMAPHORE Semaphore,
146 * FUNCTION: Initializes a spinlock
148 * SpinLock = Spinlock to initialize
150 VOID STDCALL KeInitializeSpinLock (PKSPIN_LOCK SpinLock);
152 VOID STDCALL KeInitializeTimer (PKTIMER Timer);
154 VOID STDCALL KeInitializeTimerEx (PKTIMER Timer,
157 BOOLEAN STDCALL KeInsertByKeyDeviceQueue (PKDEVICE_QUEUE DeviceQueue,
158 PKDEVICE_QUEUE_ENTRY QueueEntry,
161 BOOLEAN STDCALL KeInsertDeviceQueue (PKDEVICE_QUEUE DeviceQueue,
162 PKDEVICE_QUEUE_ENTRY DeviceQueueEntry);
165 KeInsertHeadQueue(IN PKQUEUE Queue,
166 IN PLIST_ENTRY Entry);
169 KeInsertQueue(IN PKQUEUE Queue,
170 IN PLIST_ENTRY Entry);
172 VOID STDCALL KeInsertQueueApc (PKAPC Apc,
173 PVOID SystemArgument1,
174 PVOID SystemArgument2,
177 BOOLEAN STDCALL KeInsertQueueDpc (PKDPC Dpc,
178 PVOID SystemArgument1,
179 PVOID SystemArgument2);
181 VOID STDCALL KeLeaveCriticalRegion (VOID);
183 VOID STDCALL KeLowerIrql (KIRQL NewIrql);
185 NTSTATUS STDCALL KePulseEvent (PKEVENT Event,
191 KeQueryPerformanceCounter (
192 PLARGE_INTEGER PerformanceFrequency
198 PLARGE_INTEGER CurrentTime
204 PLARGE_INTEGER TickCount
209 KeQueryTimeIncrement (
222 KeRaiseIrqlToDpcLevel (
228 KeRaiseIrqlToSynchLevel (
233 * FUNCTION: Raises a user mode exception
235 * ExceptionCode = Status code of the exception
239 KeRaiseUserException (
240 IN NTSTATUS ExceptionCode
250 KeReadStateMutant(IN PKMUTANT Mutant);
253 KeReadStateMutex(IN PKMUTEX Mutex);
256 KeReadStateQueue(IN PKQUEUE Queue);
259 KeReadStateSemaphore(IN PKSEMAPHORE Semaphore);
262 KeReadStateTimer(IN PKTIMER Timer);
266 KeRegisterBugCheckCallback (
267 PKBUGCHECK_CALLBACK_RECORD CallbackRecord,
268 PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine,
278 IN KPRIORITY Increment,
293 PKSEMAPHORE Semaphore,
302 PKSPIN_LOCK Spinlock,
308 KeReleaseSpinLockFromDpcLevel (
314 KeRemoveByKeyDeviceQueue (
315 PKDEVICE_QUEUE DeviceQueue,
321 KeRemoveDeviceQueue (
322 PKDEVICE_QUEUE DeviceQueue
326 KeRemoveEntryDeviceQueue(PKDEVICE_QUEUE DeviceQueue,
327 PKDEVICE_QUEUE_ENTRY DeviceQueueEntry);
330 KeRemoveQueue(IN PKQUEUE Queue,
331 IN KPROCESSOR_MODE WaitMode,
332 IN PLARGE_INTEGER Timeout OPTIONAL);
335 KeRemoveQueueDpc(IN PKDPC Dpc);
338 KeResetEvent(IN PKEVENT Event);
341 KeSetBasePriorityThread(struct _KTHREAD* Thread,
352 KPRIORITY STDCALL KeSetPriorityThread (struct _KTHREAD* Thread,
355 BOOLEAN STDCALL KeSetTimer (PKTIMER Timer,
356 LARGE_INTEGER DueTime,
359 BOOLEAN STDCALL KeSetTimerEx (PKTIMER Timer,
360 LARGE_INTEGER DueTime,
364 VOID STDCALL KeStallExecutionProcessor (ULONG MicroSeconds);
366 BOOLEAN STDCALL KeSynchronizeExecution (PKINTERRUPT Interrupt,
367 PKSYNCHRONIZE_ROUTINE SynchronizeRoutine,
368 PVOID SynchronizeContext);
370 NTSTATUS STDCALL KeWaitForMultipleObjects (ULONG Count,
373 KWAIT_REASON WaitReason,
374 KPROCESSOR_MODE WaitMode,
376 PLARGE_INTEGER Timeout,
377 PKWAIT_BLOCK WaitBlockArray);
381 KeWaitForMutexObject (
383 KWAIT_REASON WaitReason,
384 KPROCESSOR_MODE WaitMode,
386 PLARGE_INTEGER Timeout
391 KeWaitForSingleObject (
393 KWAIT_REASON WaitReason,
394 KPROCESSOR_MODE WaitMode,
396 PLARGE_INTEGER Timeout
401 // io permission map has a 8k size
402 // Each bit in the IOPM corresponds to an io port byte address. The bitmap
403 // is initialized to allow IO at any port. [ all bits set ].
411 * FUNCTION: Provides the kernel with a new access map for a driver
413 * NewMap: = If FALSE the kernel's map is set to all disabled. If TRUE
414 * the kernel disables access to a particular port.
415 * IoPortMap = Caller supplies storage for the io permission map.
417 * Each bit in the IOPM corresponds to an io port byte address. The bitmap
418 * is initialized to allow IO at any port. [ all bits set ]. The IOPL determines
419 * the minium privilege level required to perform IO prior to checking the permission map.
421 VOID Ke386SetIoAccessMap(ULONG NewMap, PIOPM *IoPermissionMap);
424 * FUNCTION: Queries the io permission map.
426 * NewMap: = If FALSE the kernel's map is set to all disabled. If TRUE
427 * the kernel disables access to a particular port.
428 * IoPortMap = Caller supplies storage for the io permission map.
430 * Each bit in the IOPM corresponds to an io port byte address. The bitmap
431 * is initialized to allow IO at any port. [ all bits set ]. The IOPL determines
432 * the minium privilege level required to perform IO prior to checking the permission map.
434 VOID Ke386QueryIoAccessMap(BOOLEAN NewMap, PIOPM *IoPermissionMap);
437 * FUNCTION: Set the process IOPL
439 * Eprocess = Pointer to a executive process object
440 * EnableIo = Specify TRUE to enable IO and FALSE to disable
442 NTSTATUS Ke386IoSetAccessProcess(struct _EPROCESS* Eprocess, BOOLEAN EnableIo);
445 * FUNCTION: Releases a set of Global Descriptor Table Selectors
450 NTSTATUS KeI386ReleaseGdtSelectors(OUT PULONG SelArray,
451 IN ULONG NumOfSelectors);
454 * FUNCTION: Allocates a set of Global Descriptor Table Selectors
459 NTSTATUS KeI386AllocateGdtSelectors(OUT PULONG SelArray,
460 IN ULONG NumOfSelectors);
466 IN PKSPIN_LOCK SpinLock
485 IN PKSPIN_LOCK SpinLock,
490 VOID STDCALL KiDeliverApc(ULONG Unknown1,
494 VOID STDCALL KiDispatchInterrupt(VOID);
496 #endif /* __INCLUDE_DDK_KEFUNCS_H */