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 (
203 * FUNCTION: Raises a user mode exception
205 * ExceptionCode = Status code of the exception
209 KeRaiseUserException (
210 IN NTSTATUS ExceptionCode
227 KeReadStateSemaphore (
228 PKSEMAPHORE Semaphore
239 KeRegisterBugCheckCallback (
240 PKBUGCHECK_CALLBACK_RECORD CallbackRecord
,
241 PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine
,
257 PKSEMAPHORE Semaphore
,
266 PKSPIN_LOCK Spinlock
,
272 KeReleaseSpinLockFromDpcLevel (
278 KeRemoveByKeyDeviceQueue (
279 PKDEVICE_QUEUE DeviceQueue
,
285 KeRemoveDeviceQueue (
286 PKDEVICE_QUEUE DeviceQueue
291 KeRemoveEntryDeviceQueue (
292 PKDEVICE_QUEUE DeviceQueue
,
293 PKDEVICE_QUEUE_ENTRY DeviceQueueEntry
308 LONG STDCALL
KeSetBasePriorityThread (struct _KTHREAD
* Thread
,
319 KPRIORITY STDCALL
KeSetPriorityThread (struct _KTHREAD
* Thread
,
322 BOOLEAN STDCALL
KeSetTimer (PKTIMER Timer
,
323 LARGE_INTEGER DueTime
,
326 BOOLEAN STDCALL
KeSetTimerEx (PKTIMER Timer
,
327 LARGE_INTEGER DueTime
,
331 VOID STDCALL
KeStallExecutionProcessor (ULONG MicroSeconds
);
333 BOOLEAN STDCALL
KeSynchronizeExecution (PKINTERRUPT Interrupt
,
334 PKSYNCHRONIZE_ROUTINE SynchronizeRoutine
,
335 PVOID SynchronizeContext
);
337 NTSTATUS STDCALL
KeWaitForMultipleObjects (ULONG Count
,
340 KWAIT_REASON WaitReason
,
341 KPROCESSOR_MODE WaitMode
,
343 PLARGE_INTEGER Timeout
,
344 PKWAIT_BLOCK WaitBlockArray
);
348 KeWaitForMutexObject (
350 KWAIT_REASON WaitReason
,
351 KPROCESSOR_MODE WaitMode
,
353 PLARGE_INTEGER Timeout
358 KeWaitForSingleObject (
360 KWAIT_REASON WaitReason
,
361 KPROCESSOR_MODE WaitMode
,
363 PLARGE_INTEGER Timeout
368 // io permission map has a 8k size
369 // Each bit in the IOPM corresponds to an io port byte address. The bitmap
370 // is initialized to allow IO at any port. [ all bits set ].
378 * FUNCTION: Provides the kernel with a new access map for a driver
380 * NewMap: = If FALSE the kernel's map is set to all disabled. If TRUE
381 * the kernel disables access to a particular port.
382 * IoPortMap = Caller supplies storage for the io permission map.
384 * Each bit in the IOPM corresponds to an io port byte address. The bitmap
385 * is initialized to allow IO at any port. [ all bits set ]. The IOPL determines
386 * the minium privilege level required to perform IO prior to checking the permission map.
388 VOID
Ke386SetIoAccessMap(ULONG NewMap
, PIOPM
*IoPermissionMap
);
391 * FUNCTION: Queries the io permission map.
393 * NewMap: = If FALSE the kernel's map is set to all disabled. If TRUE
394 * the kernel disables access to a particular port.
395 * IoPortMap = Caller supplies storage for the io permission map.
397 * Each bit in the IOPM corresponds to an io port byte address. The bitmap
398 * is initialized to allow IO at any port. [ all bits set ]. The IOPL determines
399 * the minium privilege level required to perform IO prior to checking the permission map.
401 VOID
Ke386QueryIoAccessMap(BOOLEAN NewMap
, PIOPM
*IoPermissionMap
);
404 * FUNCTION: Set the process IOPL
406 * Eprocess = Pointer to a executive process object
407 * EnableIo = Specify TRUE to enable IO and FALSE to disable
409 NTSTATUS
Ke386IoSetAccessProcess(struct _EPROCESS
* Eprocess
, BOOLEAN EnableIo
);
412 * FUNCTION: Releases a set of Global Descriptor Table Selectors
417 NTSTATUS
KeI386ReleaseGdtSelectors(OUT PULONG SelArray
,
418 IN ULONG NumOfSelectors
);
421 * FUNCTION: Allocates a set of Global Descriptor Table Selectors
426 NTSTATUS
KeI386AllocateGdtSelectors(OUT PULONG SelArray
,
427 IN ULONG NumOfSelectors
);
433 IN PKSPIN_LOCK SpinLock
452 IN PKSPIN_LOCK SpinLock
,
457 VOID STDCALL
KiDeliverApc(ULONG Unknown1
,
461 VOID STDCALL
KiDispatchInterrupt(VOID
);
463 #endif /* __INCLUDE_DDK_KEFUNCS_H */