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 #else /* !LIBCAPTIVE */
193 #endif /* LIBCAPTIVE */
195 KeQueryPerformanceCounter (
196 PLARGE_INTEGER PerformanceFrequency
202 PLARGE_INTEGER CurrentTime
208 PLARGE_INTEGER TickCount
213 KeQueryTimeIncrement (
226 KeRaiseIrqlToDpcLevel (
232 KeRaiseIrqlToSynchLevel (
237 * FUNCTION: Raises a user mode exception
239 * ExceptionCode = Status code of the exception
243 KeRaiseUserException (
244 IN NTSTATUS ExceptionCode
254 KeReadStateMutant(IN PKMUTANT Mutant);
257 KeReadStateMutex(IN PKMUTEX Mutex);
260 KeReadStateQueue(IN PKQUEUE Queue);
263 KeReadStateSemaphore(IN PKSEMAPHORE Semaphore);
266 KeReadStateTimer(IN PKTIMER Timer);
270 KeRegisterBugCheckCallback (
271 PKBUGCHECK_CALLBACK_RECORD CallbackRecord,
272 PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine,
282 IN KPRIORITY Increment,
297 PKSEMAPHORE Semaphore,
306 PKSPIN_LOCK Spinlock,
312 KeReleaseSpinLockFromDpcLevel (
318 KeRemoveByKeyDeviceQueue (
319 PKDEVICE_QUEUE DeviceQueue,
325 KeRemoveDeviceQueue (
326 PKDEVICE_QUEUE DeviceQueue
330 KeRemoveEntryDeviceQueue(PKDEVICE_QUEUE DeviceQueue,
331 PKDEVICE_QUEUE_ENTRY DeviceQueueEntry);
334 KeRemoveQueue(IN PKQUEUE Queue,
335 IN KPROCESSOR_MODE WaitMode,
336 IN PLARGE_INTEGER Timeout OPTIONAL);
339 KeRemoveQueueDpc(IN PKDPC Dpc);
342 KeResetEvent(IN PKEVENT Event);
345 KeSetBasePriorityThread(struct _KTHREAD* Thread,
356 KPRIORITY STDCALL KeSetPriorityThread (struct _KTHREAD* Thread,
359 BOOLEAN STDCALL KeSetTimer (PKTIMER Timer,
360 LARGE_INTEGER DueTime,
363 BOOLEAN STDCALL KeSetTimerEx (PKTIMER Timer,
364 LARGE_INTEGER DueTime,
368 VOID STDCALL KeStallExecutionProcessor (ULONG MicroSeconds);
370 BOOLEAN STDCALL KeSynchronizeExecution (PKINTERRUPT Interrupt,
371 PKSYNCHRONIZE_ROUTINE SynchronizeRoutine,
372 PVOID SynchronizeContext);
374 NTSTATUS STDCALL KeWaitForMultipleObjects (ULONG Count,
377 KWAIT_REASON WaitReason,
378 KPROCESSOR_MODE WaitMode,
380 PLARGE_INTEGER Timeout,
381 PKWAIT_BLOCK WaitBlockArray);
385 KeWaitForMutexObject (
387 KWAIT_REASON WaitReason,
388 KPROCESSOR_MODE WaitMode,
390 PLARGE_INTEGER Timeout
395 KeWaitForSingleObject (
397 KWAIT_REASON WaitReason,
398 KPROCESSOR_MODE WaitMode,
400 PLARGE_INTEGER Timeout
405 // io permission map has a 8k size
406 // Each bit in the IOPM corresponds to an io port byte address. The bitmap
407 // is initialized to allow IO at any port. [ all bits set ].
415 * FUNCTION: Provides the kernel with a new access map for a driver
417 * NewMap: = If FALSE the kernel's map is set to all disabled. If TRUE
418 * the kernel disables access to a particular port.
419 * IoPortMap = Caller supplies storage for the io permission map.
421 * Each bit in the IOPM corresponds to an io port byte address. The bitmap
422 * is initialized to allow IO at any port. [ all bits set ]. The IOPL determines
423 * the minium privilege level required to perform IO prior to checking the permission map.
425 VOID Ke386SetIoAccessMap(ULONG NewMap, PIOPM *IoPermissionMap);
428 * FUNCTION: Queries the io permission map.
430 * NewMap: = If FALSE the kernel's map is set to all disabled. If TRUE
431 * the kernel disables access to a particular port.
432 * IoPortMap = Caller supplies storage for the io permission map.
434 * Each bit in the IOPM corresponds to an io port byte address. The bitmap
435 * is initialized to allow IO at any port. [ all bits set ]. The IOPL determines
436 * the minium privilege level required to perform IO prior to checking the permission map.
438 VOID Ke386QueryIoAccessMap(BOOLEAN NewMap, PIOPM *IoPermissionMap);
441 * FUNCTION: Set the process IOPL
443 * Eprocess = Pointer to a executive process object
444 * EnableIo = Specify TRUE to enable IO and FALSE to disable
446 NTSTATUS Ke386IoSetAccessProcess(struct _EPROCESS* Eprocess, BOOLEAN EnableIo);
449 * FUNCTION: Releases a set of Global Descriptor Table Selectors
454 NTSTATUS KeI386ReleaseGdtSelectors(OUT PULONG SelArray,
455 IN ULONG NumOfSelectors);
458 * FUNCTION: Allocates a set of Global Descriptor Table Selectors
463 NTSTATUS KeI386AllocateGdtSelectors(OUT PULONG SelArray,
464 IN ULONG NumOfSelectors);
470 IN PKSPIN_LOCK SpinLock
489 IN PKSPIN_LOCK SpinLock,
494 VOID STDCALL KiDeliverApc(ULONG Unknown1,
498 VOID STDCALL KiDispatchInterrupt(VOID);
500 #endif /* __INCLUDE_DDK_KEFUNCS_H */