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 KeQueryPerformanceCounter (
189 PLARGE_INTEGER PerformanceFrequency
195 PLARGE_INTEGER CurrentTime
201 PLARGE_INTEGER TickCount
206 KeQueryTimeIncrement (
219 KeRaiseIrqlToDpcLevel (
225 KeRaiseIrqlToSynchLevel (
230 * FUNCTION: Raises a user mode exception
232 * ExceptionCode = Status code of the exception
236 KeRaiseUserException (
237 IN NTSTATUS ExceptionCode
247 KeReadStateMutant(IN PKMUTANT Mutant);
250 KeReadStateMutex(IN PKMUTEX Mutex);
253 KeReadStateQueue(IN PKQUEUE Queue);
256 KeReadStateSemaphore(IN PKSEMAPHORE Semaphore);
259 KeReadStateTimer(IN PKTIMER Timer);
263 KeRegisterBugCheckCallback (
264 PKBUGCHECK_CALLBACK_RECORD CallbackRecord,
265 PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine,
275 IN KPRIORITY Increment,
290 PKSEMAPHORE Semaphore,
299 PKSPIN_LOCK Spinlock,
305 KeReleaseSpinLockFromDpcLevel (
311 KeRemoveByKeyDeviceQueue (
312 PKDEVICE_QUEUE DeviceQueue,
318 KeRemoveDeviceQueue (
319 PKDEVICE_QUEUE DeviceQueue
323 KeRemoveEntryDeviceQueue(PKDEVICE_QUEUE DeviceQueue,
324 PKDEVICE_QUEUE_ENTRY DeviceQueueEntry);
327 KeRemoveQueue(IN PKQUEUE Queue,
328 IN KPROCESSOR_MODE WaitMode,
329 IN PLARGE_INTEGER Timeout OPTIONAL);
332 KeRemoveQueueDpc(IN PKDPC Dpc);
335 KeResetEvent(IN PKEVENT Event);
338 KeSetBasePriorityThread(struct _KTHREAD* Thread,
349 KPRIORITY STDCALL KeSetPriorityThread (struct _KTHREAD* Thread,
352 BOOLEAN STDCALL KeSetTimer (PKTIMER Timer,
353 LARGE_INTEGER DueTime,
356 BOOLEAN STDCALL KeSetTimerEx (PKTIMER Timer,
357 LARGE_INTEGER DueTime,
361 VOID STDCALL KeStallExecutionProcessor (ULONG MicroSeconds);
363 BOOLEAN STDCALL KeSynchronizeExecution (PKINTERRUPT Interrupt,
364 PKSYNCHRONIZE_ROUTINE SynchronizeRoutine,
365 PVOID SynchronizeContext);
367 NTSTATUS STDCALL KeWaitForMultipleObjects (ULONG Count,
370 KWAIT_REASON WaitReason,
371 KPROCESSOR_MODE WaitMode,
373 PLARGE_INTEGER Timeout,
374 PKWAIT_BLOCK WaitBlockArray);
378 KeWaitForMutexObject (
380 KWAIT_REASON WaitReason,
381 KPROCESSOR_MODE WaitMode,
383 PLARGE_INTEGER Timeout
388 KeWaitForSingleObject (
390 KWAIT_REASON WaitReason,
391 KPROCESSOR_MODE WaitMode,
393 PLARGE_INTEGER Timeout
398 // io permission map has a 8k size
399 // Each bit in the IOPM corresponds to an io port byte address. The bitmap
400 // is initialized to allow IO at any port. [ all bits set ].
408 * FUNCTION: Provides the kernel with a new access map for a driver
410 * NewMap: = If FALSE the kernel's map is set to all disabled. If TRUE
411 * the kernel disables access to a particular port.
412 * IoPortMap = Caller supplies storage for the io permission map.
414 * Each bit in the IOPM corresponds to an io port byte address. The bitmap
415 * is initialized to allow IO at any port. [ all bits set ]. The IOPL determines
416 * the minium privilege level required to perform IO prior to checking the permission map.
418 VOID Ke386SetIoAccessMap(ULONG NewMap, PIOPM *IoPermissionMap);
421 * FUNCTION: Queries the io permission map.
423 * NewMap: = If FALSE the kernel's map is set to all disabled. If TRUE
424 * the kernel disables access to a particular port.
425 * IoPortMap = Caller supplies storage for the io permission map.
427 * Each bit in the IOPM corresponds to an io port byte address. The bitmap
428 * is initialized to allow IO at any port. [ all bits set ]. The IOPL determines
429 * the minium privilege level required to perform IO prior to checking the permission map.
431 VOID Ke386QueryIoAccessMap(BOOLEAN NewMap, PIOPM *IoPermissionMap);
434 * FUNCTION: Set the process IOPL
436 * Eprocess = Pointer to a executive process object
437 * EnableIo = Specify TRUE to enable IO and FALSE to disable
439 NTSTATUS Ke386IoSetAccessProcess(struct _EPROCESS* Eprocess, BOOLEAN EnableIo);
442 * FUNCTION: Releases a set of Global Descriptor Table Selectors
447 NTSTATUS KeI386ReleaseGdtSelectors(OUT PULONG SelArray,
448 IN ULONG NumOfSelectors);
451 * FUNCTION: Allocates a set of Global Descriptor Table Selectors
456 NTSTATUS KeI386AllocateGdtSelectors(OUT PULONG SelArray,
457 IN ULONG NumOfSelectors);
463 IN PKSPIN_LOCK SpinLock
482 IN PKSPIN_LOCK SpinLock,
487 VOID STDCALL KiDeliverApc(ULONG Unknown1,
491 VOID STDCALL KiDispatchInterrupt(VOID);
493 #endif /* __INCLUDE_DDK_KEFUNCS_H */