1 #ifndef __INCLUDE_DDK_KEFUNCS_H
2 #define __INCLUDE_DDK_KEFUNCS_H
5 /* KERNEL FUNCTIONS ********************************************************/
7 #ifndef KeFlushIoBuffers
8 #define KeFlushIoBuffers(Mdl, ReadOperation, DmaOperation)
11 VOID STDCALL KeAttachProcess (struct _EPROCESS* Process);
13 VOID KeDrainApcQueue(VOID);
14 struct _KPROCESS* KeGetCurrentProcess(VOID);
17 * FUNCTION: Acquires a spinlock so the caller can synchronize access to
20 * SpinLock = Initialized spinlock
21 * OldIrql (OUT) = Set the previous irql on return
23 VOID STDCALL KeAcquireSpinLock (PKSPIN_LOCK SpinLock,
28 VOID STDCALL KeAcquireSpinLockAtDpcLevel (IN PKSPIN_LOCK SpinLock);
30 #define KefAcquireSpinLockAtDpcLevel KeAcquireSpinLockAtDpcLevel
34 KeReleaseSpinLockFromDpcLevel(
35 IN PKSPIN_LOCK SpinLock);
40 * FUNCTION: Brings the system down in a controlled manner when an
41 * inconsistency that might otherwise cause corruption has been detected
43 * BugCheckCode = Specifies the reason for the bug check
46 * NOTES - please use the macro KEBUGCHECK with the same argument so the end-user
47 * knows what file/line number where the bug check occured
49 VOID STDCALL KeBugCheck (ULONG BugCheckCode);
52 * FUNCTION: Brings the system down in a controlled manner when an
53 * inconsistency that might otherwise cause corruption has been detected
55 * BugCheckCode = Specifies the reason for the bug check
56 * BugCheckParameter[1-4] = Additional information about bug
59 * NOTES - please use the macro KEBUGCHECKEX with the same arguments so the end-user
60 * knows what file/line number where the bug check occured
62 VOID STDCALL KeBugCheckEx (ULONG BugCheckCode,
63 ULONG BugCheckParameter1,
64 ULONG BugCheckParameter2,
65 ULONG BugCheckParameter3,
66 ULONG BugCheckParameter4);
68 BOOLEAN STDCALL KeCancelTimer (PKTIMER Timer);
70 VOID STDCALL KeClearEvent (PKEVENT Event);
72 NTSTATUS STDCALL KeConnectInterrupt(PKINTERRUPT InterruptObject);
74 NTSTATUS STDCALL KeDelayExecutionThread (KPROCESSOR_MODE WaitMode,
76 PLARGE_INTEGER Internal);
78 BOOLEAN STDCALL KeDeregisterBugCheckCallback (
79 PKBUGCHECK_CALLBACK_RECORD CallbackRecord);
81 VOID STDCALL KeDetachProcess (VOID);
83 VOID STDCALL KeDisconnectInterrupt(PKINTERRUPT InterruptObject);
85 VOID STDCALL KeEnterCriticalRegion (VOID);
88 * FUNCTION: Enters the kernel debugger
92 VOID STDCALL KeEnterKernelDebugger (VOID);
94 KIRQL STDCALL KeGetCurrentIrql (VOID);
97 ULONG KeGetCurrentProcessorNumber(VOID);
98 ULONG KeGetDcacheFillSize(VOID);
99 ULONG STDCALL KeGetPreviousMode (VOID);
102 struct _KTHREAD* STDCALL KeGetCurrentThread (VOID);
104 VOID STDCALL KeInitializeApc (IN PKAPC Apc,
107 IN PKKERNEL_ROUTINE KernelRoutine,
108 IN PKRUNDOWN_ROUTINE RundownRoutine,
109 IN PKNORMAL_ROUTINE NormalRoutine,
116 * KeInitializeCallbackRecord (
117 * PKBUGCHECK_CALLBACK_RECORD CallbackRecord
120 #ifndef KeInitializeCallbackRecord
121 #define KeInitializeCallbackRecord(CallbackRecord) \
122 (CallbackRecord)->State = BufferEmpty
125 VOID STDCALL KeInitializeDeviceQueue (PKDEVICE_QUEUE DeviceQueue);
127 VOID STDCALL KeInitializeDpc (PKDPC Dpc,
128 PKDEFERRED_ROUTINE DeferredRoutine,
129 PVOID DeferredContext);
131 VOID STDCALL KeInitializeEvent (PKEVENT Event,
135 NTSTATUS STDCALL KeInitializeInterrupt(PKINTERRUPT InterruptObject,
136 PKSERVICE_ROUTINE ServiceRoutine,
137 PVOID ServiceContext,
138 PKSPIN_LOCK SpinLock,
141 KIRQL SynchronizeIrql,
142 KINTERRUPT_MODE InterruptMode,
144 KAFFINITY ProcessorEnableMask,
145 BOOLEAN FloatingSave);
147 VOID STDCALL KeInitializeMutant(IN PKMUTANT Mutant,
148 IN BOOLEAN InitialOwner);
150 VOID STDCALL KeInitializeMutex (PKMUTEX Mutex,
154 KeInitializeQueue(IN PKQUEUE Queue,
158 KeRundownQueue(IN PKQUEUE Queue);
160 VOID STDCALL KeInitializeSemaphore (PKSEMAPHORE Semaphore,
165 * FUNCTION: Initializes a spinlock
167 * SpinLock = Spinlock to initialize
169 VOID STDCALL KeInitializeSpinLock (PKSPIN_LOCK SpinLock);
171 VOID STDCALL KeInitializeTimer (PKTIMER Timer);
173 VOID STDCALL KeInitializeTimerEx (PKTIMER Timer,
176 BOOLEAN STDCALL KeInsertByKeyDeviceQueue (PKDEVICE_QUEUE DeviceQueue,
177 PKDEVICE_QUEUE_ENTRY QueueEntry,
180 BOOLEAN STDCALL KeInsertDeviceQueue (PKDEVICE_QUEUE DeviceQueue,
181 PKDEVICE_QUEUE_ENTRY DeviceQueueEntry);
184 KeInsertHeadQueue(IN PKQUEUE Queue,
185 IN PLIST_ENTRY Entry);
188 KeInsertQueue(IN PKQUEUE Queue,
189 IN PLIST_ENTRY Entry);
191 BOOLEAN STDCALL KeInsertQueueApc (PKAPC Apc,
192 PVOID SystemArgument1,
193 PVOID SystemArgument2,
194 KPRIORITY PriorityBoost);
196 BOOLEAN STDCALL KeInsertQueueDpc (PKDPC Dpc,
197 PVOID SystemArgument1,
198 PVOID SystemArgument2);
200 VOID STDCALL KeLeaveCriticalRegion (VOID);
202 VOID STDCALL KeLowerIrql (KIRQL NewIrql);
204 NTSTATUS STDCALL KePulseEvent (PKEVENT Event,
210 KeQueryPerformanceCounter (
211 PLARGE_INTEGER PerformanceFrequency
217 PLARGE_INTEGER CurrentTime
223 PLARGE_INTEGER TickCount
228 KeQueryTimeIncrement (
241 KeRaiseIrqlToDpcLevel (
246 * FUNCTION: Raises a user mode exception
248 * ExceptionCode = Status code of the exception
252 KeRaiseUserException (
253 IN NTSTATUS ExceptionCode
263 KeReadStateMutant(IN PKMUTANT Mutant);
266 KeReadStateMutex(IN PKMUTEX Mutex);
269 KeReadStateQueue(IN PKQUEUE Queue);
272 KeReadStateSemaphore(IN PKSEMAPHORE Semaphore);
275 KeReadStateTimer(IN PKTIMER Timer);
279 KeRegisterBugCheckCallback (
280 PKBUGCHECK_CALLBACK_RECORD CallbackRecord,
281 PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine,
291 IN KPRIORITY Increment,
306 PKSEMAPHORE Semaphore,
315 PKSPIN_LOCK Spinlock,
322 KeReleaseSpinLockFromDpcLevel (
329 KeRemoveByKeyDeviceQueue (
330 PKDEVICE_QUEUE DeviceQueue,
336 KeRemoveDeviceQueue (
337 PKDEVICE_QUEUE DeviceQueue
341 KeRemoveEntryDeviceQueue(PKDEVICE_QUEUE DeviceQueue,
342 PKDEVICE_QUEUE_ENTRY DeviceQueueEntry);
345 KeRemoveQueue(IN PKQUEUE Queue,
346 IN KPROCESSOR_MODE WaitMode,
347 IN PLARGE_INTEGER Timeout OPTIONAL);
350 KeRemoveQueueDpc(IN PKDPC Dpc);
353 KeResetEvent(IN PKEVENT Event);
356 KeSetBasePriorityThread(struct _KTHREAD* Thread,
367 KPRIORITY STDCALL KeSetPriorityThread (struct _KTHREAD* Thread,
370 BOOLEAN STDCALL KeSetTimer (PKTIMER Timer,
371 LARGE_INTEGER DueTime,
374 BOOLEAN STDCALL KeSetTimerEx (PKTIMER Timer,
375 LARGE_INTEGER DueTime,
379 VOID STDCALL KeStallExecutionProcessor (ULONG MicroSeconds);
381 BOOLEAN STDCALL KeSynchronizeExecution (PKINTERRUPT Interrupt,
382 PKSYNCHRONIZE_ROUTINE SynchronizeRoutine,
383 PVOID SynchronizeContext);
385 NTSTATUS STDCALL KeWaitForMultipleObjects (ULONG Count,
388 KWAIT_REASON WaitReason,
389 KPROCESSOR_MODE WaitMode,
391 PLARGE_INTEGER Timeout,
392 PKWAIT_BLOCK WaitBlockArray);
396 KeWaitForMutexObject (
398 KWAIT_REASON WaitReason,
399 KPROCESSOR_MODE WaitMode,
401 PLARGE_INTEGER Timeout
406 KeWaitForSingleObject (
408 KWAIT_REASON WaitReason,
409 KPROCESSOR_MODE WaitMode,
411 PLARGE_INTEGER Timeout
416 /* io permission map has a 8k size
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 ].
426 * FUNCTION: Provides the kernel with a new access map for a driver
428 * NewMap: = If FALSE the kernel's map is set to all disabled. If TRUE
429 * the kernel disables access to a particular port.
430 * IoPortMap = Caller supplies storage for the io permission map.
432 * Each bit in the IOPM corresponds to an io port byte address. The bitmap
433 * is initialized to allow IO at any port. [ all bits set ]. The IOPL determines
434 * the minium privilege level required to perform IO prior to checking the permission map.
437 Ke386SetIoAccessMap(ULONG NewMap, PULONG IoPermissionMap);
440 * FUNCTION: Queries the io permission map.
442 * NewMap: = If FALSE the kernel's map is set to all disabled. If TRUE
443 * the kernel disables access to a particular port.
444 * IoPortMap = Caller supplies storage for the io permission map.
446 * Each bit in the IOPM corresponds to an io port byte address. The bitmap
447 * is initialized to allow IO at any port. [ all bits set ]. The IOPL determines
448 * the minium privilege level required to perform IO prior to checking the permission map.
451 Ke386QueryIoAccessMap(ULONG NewMap, PULONG IoPermissionMap);
454 * FUNCTION: Set the process IOPL
456 * Eprocess = Pointer to a executive process object
457 * EnableIo = Specify TRUE to enable IO and FALSE to disable
460 Ke386IoSetAccessProcess(struct _EPROCESS* Eprocess, BOOL EnableIo);
463 * FUNCTION: Sets the contents of a gdt descriptor.
465 * Entry = The selector to set.
466 * Value1 = The value of the low dword of the descriptor.
467 * Value2 = The value of the high dword of the descriptor.
470 KeSetGdtSelector(ULONG Entry, ULONG Value1, ULONG Value2);
473 * FUNCTION: Releases a set of Global Descriptor Table Selectors
478 NTSTATUS KeI386ReleaseGdtSelectors(OUT PULONG SelArray,
479 IN ULONG NumOfSelectors);
482 * FUNCTION: Allocates a set of Global Descriptor Table Selectors
487 NTSTATUS KeI386AllocateGdtSelectors(OUT PULONG SelArray,
488 IN ULONG NumOfSelectors);
494 IN PKSPIN_LOCK SpinLock
513 IN PKSPIN_LOCK SpinLock,
518 VOID STDCALL KiDeliverApc(ULONG Unknown1,
522 VOID STDCALL KiDispatchInterrupt(VOID);
524 #endif /* __INCLUDE_DDK_KEFUNCS_H */