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
KeInitializeMutex (PKMUTEX Mutex
,
131 VOID STDCALL
KeInitializeSemaphore (PKSEMAPHORE Semaphore
,
136 * FUNCTION: Initializes a spinlock
138 * SpinLock = Spinlock to initialize
140 VOID STDCALL
KeInitializeSpinLock (PKSPIN_LOCK SpinLock
);
142 VOID STDCALL
KeInitializeTimer (PKTIMER Timer
);
144 VOID STDCALL
KeInitializeTimerEx (PKTIMER Timer
,
147 BOOLEAN STDCALL
KeInsertByKeyDeviceQueue (PKDEVICE_QUEUE DeviceQueue
,
148 PKDEVICE_QUEUE_ENTRY QueueEntry
,
151 BOOLEAN STDCALL
KeInsertDeviceQueue (PKDEVICE_QUEUE DeviceQueue
,
152 PKDEVICE_QUEUE_ENTRY DeviceQueueEntry
);
154 VOID STDCALL
KeInsertQueueApc (PKAPC Apc
,
155 PVOID SystemArgument1
,
156 PVOID SystemArgument2
,
159 BOOLEAN STDCALL
KeInsertQueueDpc (PKDPC Dpc
,
160 PVOID SystemArgument1
,
161 PVOID SystemArgument2
);
163 VOID STDCALL
KeLeaveCriticalRegion (VOID
);
165 VOID STDCALL
KeLowerIrql (KIRQL NewIrql
);
167 NTSTATUS STDCALL
KePulseEvent (PKEVENT Event
,
173 KeQueryPerformanceCounter (
174 PLARGE_INTEGER PerformanceFrequency
180 PLARGE_INTEGER CurrentTime
186 PLARGE_INTEGER TickCount
191 KeQueryTimeIncrement (
204 KeRaiseIrqlToDpcLevel (
210 KeRaiseIrqlToSynchLevel (
215 * FUNCTION: Raises a user mode exception
217 * ExceptionCode = Status code of the exception
221 KeRaiseUserException (
222 IN NTSTATUS ExceptionCode
239 KeReadStateSemaphore (
240 PKSEMAPHORE Semaphore
251 KeRegisterBugCheckCallback (
252 PKBUGCHECK_CALLBACK_RECORD CallbackRecord
,
253 PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine
,
269 PKSEMAPHORE Semaphore
,
278 PKSPIN_LOCK Spinlock
,
284 KeReleaseSpinLockFromDpcLevel (
290 KeRemoveByKeyDeviceQueue (
291 PKDEVICE_QUEUE DeviceQueue
,
297 KeRemoveDeviceQueue (
298 PKDEVICE_QUEUE DeviceQueue
303 KeRemoveEntryDeviceQueue (
304 PKDEVICE_QUEUE DeviceQueue
,
305 PKDEVICE_QUEUE_ENTRY DeviceQueueEntry
320 LONG STDCALL
KeSetBasePriorityThread (struct _KTHREAD
* Thread
,
331 KPRIORITY STDCALL
KeSetPriorityThread (struct _KTHREAD
* Thread
,
334 BOOLEAN STDCALL
KeSetTimer (PKTIMER Timer
,
335 LARGE_INTEGER DueTime
,
338 BOOLEAN STDCALL
KeSetTimerEx (PKTIMER Timer
,
339 LARGE_INTEGER DueTime
,
343 VOID STDCALL
KeStallExecutionProcessor (ULONG MicroSeconds
);
345 BOOLEAN STDCALL
KeSynchronizeExecution (PKINTERRUPT Interrupt
,
346 PKSYNCHRONIZE_ROUTINE SynchronizeRoutine
,
347 PVOID SynchronizeContext
);
349 NTSTATUS STDCALL
KeWaitForMultipleObjects (ULONG Count
,
352 KWAIT_REASON WaitReason
,
353 KPROCESSOR_MODE WaitMode
,
355 PLARGE_INTEGER Timeout
,
356 PKWAIT_BLOCK WaitBlockArray
);
360 KeWaitForMutexObject (
362 KWAIT_REASON WaitReason
,
363 KPROCESSOR_MODE WaitMode
,
365 PLARGE_INTEGER Timeout
370 KeWaitForSingleObject (
372 KWAIT_REASON WaitReason
,
373 KPROCESSOR_MODE WaitMode
,
375 PLARGE_INTEGER Timeout
380 // io permission map has a 8k size
381 // Each bit in the IOPM corresponds to an io port byte address. The bitmap
382 // is initialized to allow IO at any port. [ all bits set ].
390 * FUNCTION: Provides the kernel with a new access map for a driver
392 * NewMap: = If FALSE the kernel's map is set to all disabled. If TRUE
393 * the kernel disables access to a particular port.
394 * IoPortMap = Caller supplies storage for the io permission map.
396 * Each bit in the IOPM corresponds to an io port byte address. The bitmap
397 * is initialized to allow IO at any port. [ all bits set ]. The IOPL determines
398 * the minium privilege level required to perform IO prior to checking the permission map.
400 VOID
Ke386SetIoAccessMap(ULONG NewMap
, PIOPM
*IoPermissionMap
);
403 * FUNCTION: Queries the io permission map.
405 * NewMap: = If FALSE the kernel's map is set to all disabled. If TRUE
406 * the kernel disables access to a particular port.
407 * IoPortMap = Caller supplies storage for the io permission map.
409 * Each bit in the IOPM corresponds to an io port byte address. The bitmap
410 * is initialized to allow IO at any port. [ all bits set ]. The IOPL determines
411 * the minium privilege level required to perform IO prior to checking the permission map.
413 VOID
Ke386QueryIoAccessMap(BOOLEAN NewMap
, PIOPM
*IoPermissionMap
);
416 * FUNCTION: Set the process IOPL
418 * Eprocess = Pointer to a executive process object
419 * EnableIo = Specify TRUE to enable IO and FALSE to disable
421 NTSTATUS
Ke386IoSetAccessProcess(struct _EPROCESS
* Eprocess
, BOOLEAN EnableIo
);
424 * FUNCTION: Releases a set of Global Descriptor Table Selectors
429 NTSTATUS
KeI386ReleaseGdtSelectors(OUT PULONG SelArray
,
430 IN ULONG NumOfSelectors
);
433 * FUNCTION: Allocates a set of Global Descriptor Table Selectors
438 NTSTATUS
KeI386AllocateGdtSelectors(OUT PULONG SelArray
,
439 IN ULONG NumOfSelectors
);
445 IN PKSPIN_LOCK SpinLock
464 IN PKSPIN_LOCK SpinLock
,
469 VOID STDCALL
KiDeliverApc(ULONG Unknown1
,
473 VOID STDCALL
KiDispatchInterrupt(VOID
);
475 #endif /* __INCLUDE_DDK_KEFUNCS_H */