+
#ifndef __INCLUDE_DDK_KEFUNCS_H
#define __INCLUDE_DDK_KEFUNCS_H
+#define KEBUGCHECK(a) DbgPrint("KeBugCheck (0x%X) at %s:%i\n", a, __FILE__,__LINE__), KeBugCheck(a)
/* KERNEL FUNCTIONS ********************************************************/
-VOID STDCALL KeAttachProcess (struct _EPROCESS* Process);
+NTSTATUS
+STDCALL
+KeRestoreFloatingPointState(
+ IN PKFLOATING_SAVE FloatSave);
+
+NTSTATUS
+STDCALL
+KeSaveFloatingPointState(
+ OUT PKFLOATING_SAVE FloatSave);
+
+#ifndef KeFlushIoBuffers
+#define KeFlushIoBuffers(Mdl, ReadOperation, DmaOperation)
+#endif
+
+VOID STDCALL KeAttachProcess(struct _KPROCESS *Process);
+
+BOOLEAN
+STDCALL
+KeIsAttachedProcess(VOID);
+
+VOID FASTCALL KiAcquireSpinLock(PKSPIN_LOCK SpinLock);
+
+VOID FASTCALL KiReleaseSpinLock(PKSPIN_LOCK SpinLock);
VOID KeDrainApcQueue(VOID);
-struct _KPROCESS* KeGetCurrentProcess(VOID);
+
+struct _KPROCESS* STDCALL KeGetCurrentProcess(VOID);
/*
* FUNCTION: Acquires a spinlock so the caller can synchronize access to
VOID STDCALL KeAcquireSpinLock (PKSPIN_LOCK SpinLock,
PKIRQL OldIrql);
-VOID STDCALL KeAcquireSpinLockAtDpcLevel (PKSPIN_LOCK SpinLock);
+#ifndef __USE_W32API
+static __inline
+VOID
+KeMemoryBarrier(
+ VOID)
+{
+ volatile LONG Barrier;
+ __asm__ __volatile__ ("xchg %%eax, %0" : : "m" (Barrier) : "%eax");
+}
+
+VOID STDCALL KeAcquireSpinLockAtDpcLevel (IN PKSPIN_LOCK SpinLock);
+
+#define KefAcquireSpinLockAtDpcLevel KeAcquireSpinLockAtDpcLevel
+
+VOID
+STDCALL
+KeReleaseSpinLockFromDpcLevel(
+ IN PKSPIN_LOCK SpinLock);
+
+#endif
+
/*
* FUNCTION: Brings the system down in a controlled manner when an
* inconsistency that might otherwise cause corruption has been detected
* ARGUMENTS:
* BugCheckCode = Specifies the reason for the bug check
* RETURNS: Doesn't
+ *
+ * NOTES - please use the macro KEBUGCHECK with the same argument so the end-user
+ * knows what file/line number where the bug check occured
*/
VOID STDCALL KeBugCheck (ULONG BugCheckCode);
-
/*
* FUNCTION: Brings the system down in a controlled manner when an
* inconsistency that might otherwise cause corruption has been detected
* BugCheckCode = Specifies the reason for the bug check
* BugCheckParameter[1-4] = Additional information about bug
* RETURNS: Doesn't
+ *
+ * NOTES - please use the macro KEBUGCHECKEX with the same arguments so the end-user
+ * knows what file/line number where the bug check occured
*/
VOID STDCALL KeBugCheckEx (ULONG BugCheckCode,
ULONG BugCheckParameter1,
VOID STDCALL KeClearEvent (PKEVENT Event);
+BOOLEAN STDCALL KeConnectInterrupt(PKINTERRUPT InterruptObject);
+
NTSTATUS STDCALL KeDelayExecutionThread (KPROCESSOR_MODE WaitMode,
BOOLEAN Alertable,
PLARGE_INTEGER Internal);
VOID STDCALL KeDetachProcess (VOID);
+VOID STDCALL KeDisconnectInterrupt(PKINTERRUPT InterruptObject);
+
VOID STDCALL KeEnterCriticalRegion (VOID);
-VOID KeFlushIoBuffers(PMDL Mdl, BOOLEAN ReadOperation, BOOLEAN DmaOperation);
+/*
+ * FUNCTION: Enters the kernel debugger
+ * ARGUMENTS:
+ * None
+ */
+VOID STDCALL KeEnterKernelDebugger (VOID);
KIRQL STDCALL KeGetCurrentIrql (VOID);
-ULONG KeGetCurrentProcessorNumber(VOID);
+#ifndef __USE_W32API
+#define KeGetCurrentProcessorNumber() (KeGetCurrentKPCR()->Number)
+ULONG KeGetDcacheFillSize(VOID);
+KPROCESSOR_MODE STDCALL KeGetPreviousMode (VOID);
+#endif
struct _KTHREAD* STDCALL KeGetCurrentThread (VOID);
-ULONG KeGetDcacheFillSize(VOID);
-
-ULONG STDCALL KeGetPreviousMode (VOID);
+VOID STDCALL KeInitializeApc (IN PKAPC Apc,
+ IN PKTHREAD Thread,
+ IN KAPC_ENVIRONMENT TargetEnvironment,
+ IN PKKERNEL_ROUTINE KernelRoutine,
+ IN PKRUNDOWN_ROUTINE RundownRoutine,
+ IN PKNORMAL_ROUTINE NormalRoutine,
+ IN KPROCESSOR_MODE Mode,
+ IN PVOID Context);
-VOID STDCALL KeInitializeApc (PKAPC Apc,
- struct _KTHREAD* Thread,
- UCHAR StateIndex,
- PKKERNEL_ROUTINE KernelRoutine,
- PKRUNDOWN_ROUTINE RundownRoutine,
- PKNORMAL_ROUTINE NormalRoutine,
- UCHAR Mode,
- PVOID Context);
/*
* VOID
* PKBUGCHECK_CALLBACK_RECORD CallbackRecord
* );
*/
+#ifndef KeInitializeCallbackRecord
#define KeInitializeCallbackRecord(CallbackRecord) \
(CallbackRecord)->State = BufferEmpty
+#endif
VOID STDCALL KeInitializeDeviceQueue (PKDEVICE_QUEUE DeviceQueue);
EVENT_TYPE Type,
BOOLEAN State);
+VOID STDCALL KeInitializeInterrupt(PKINTERRUPT InterruptObject,
+ PKSERVICE_ROUTINE ServiceRoutine,
+ PVOID ServiceContext,
+ PKSPIN_LOCK SpinLock,
+ ULONG Vector,
+ KIRQL Irql,
+ KIRQL SynchronizeIrql,
+ KINTERRUPT_MODE InterruptMode,
+ BOOLEAN ShareVector,
+ CHAR ProcessorNumber,
+ BOOLEAN FloatingSave);
+
+VOID STDCALL KeInitializeMutant(IN PKMUTANT Mutant,
+ IN BOOLEAN InitialOwner);
+
VOID STDCALL KeInitializeMutex (PKMUTEX Mutex,
ULONG Level);
+VOID STDCALL
+KeInitializeQueue(IN PKQUEUE Queue,
+ IN ULONG Count);
+
+PLIST_ENTRY STDCALL
+KeRundownQueue(IN PKQUEUE Queue);
+
VOID STDCALL KeInitializeSemaphore (PKSEMAPHORE Semaphore,
LONG Count,
LONG Limit);
BOOLEAN STDCALL KeInsertDeviceQueue (PKDEVICE_QUEUE DeviceQueue,
PKDEVICE_QUEUE_ENTRY DeviceQueueEntry);
-VOID STDCALL KeInsertQueueApc (PKAPC Apc,
+LONG STDCALL
+KeInsertHeadQueue(IN PKQUEUE Queue,
+ IN PLIST_ENTRY Entry);
+
+LONG STDCALL
+KeInsertQueue(IN PKQUEUE Queue,
+ IN PLIST_ENTRY Entry);
+
+BOOLEAN STDCALL KeInsertQueueApc (PKAPC Apc,
PVOID SystemArgument1,
PVOID SystemArgument2,
- UCHAR Mode);
+ KPRIORITY PriorityBoost);
BOOLEAN STDCALL KeInsertQueueDpc (PKDPC Dpc,
PVOID SystemArgument1,
VOID STDCALL KeLowerIrql (KIRQL NewIrql);
+LONG STDCALL KePulseEvent (PKEVENT Event,
+ KPRIORITY Increment,
+ BOOLEAN Wait);
+
LARGE_INTEGER
STDCALL
KeQueryPerformanceCounter (
VOID
);
+ULONGLONG
+STDCALL
+KeQueryInterruptTime(
+ VOID
+ );
+
VOID
STDCALL
KeRaiseIrql (
PKIRQL OldIrql
);
-/*
- * FUNCTION: Raises a user mode exception
- * ARGUMENTS:
- * ExceptionCode = Status code of the exception
- */
-VOID
+KIRQL
STDCALL
-KeRaiseUserException (
- IN NTSTATUS ExceptionCode
+KeRaiseIrqlToDpcLevel (
+ VOID
);
LONG
PKEVENT Event
);
-LONG
-STDCALL
-KeReadStateMutex (
- PKMUTEX Mutex
- );
+LONG STDCALL
+KeReadStateMutant(IN PKMUTANT Mutant);
-LONG
-STDCALL
-KeReadStateSemaphore (
- PKSEMAPHORE Semaphore
- );
+LONG STDCALL
+KeReadStateMutex(IN PKMUTEX Mutex);
-BOOLEAN
-STDCALL
-KeReadStateTimer (
- PKTIMER Timer
- );
+LONG STDCALL
+KeReadStateQueue(IN PKQUEUE Queue);
+
+LONG STDCALL
+KeReadStateSemaphore(IN PKSEMAPHORE Semaphore);
+
+BOOLEAN STDCALL
+KeReadStateTimer(IN PKTIMER Timer);
BOOLEAN
STDCALL
PUCHAR Component
);
+LONG
+STDCALL
+KeReleaseMutant(
+ IN PKMUTANT Mutant,
+ IN KPRIORITY Increment,
+ IN BOOLEAN Abandon,
+ IN BOOLEAN Wait
+ );
+
LONG
STDCALL
KeReleaseMutex (
KIRQL NewIrql
);
+#ifndef __USE_W32API
VOID
STDCALL
KeReleaseSpinLockFromDpcLevel (
PKSPIN_LOCK Spinlock
);
+#endif
PKDEVICE_QUEUE_ENTRY
STDCALL
PKDEVICE_QUEUE DeviceQueue
);
-BOOLEAN
-STDCALL
-KeRemoveEntryDeviceQueue (
- PKDEVICE_QUEUE DeviceQueue,
- PKDEVICE_QUEUE_ENTRY DeviceQueueEntry
- );
+BOOLEAN STDCALL
+KeRemoveEntryDeviceQueue(PKDEVICE_QUEUE DeviceQueue,
+ PKDEVICE_QUEUE_ENTRY DeviceQueueEntry);
-BOOLEAN
-STDCALL
-KeRemoveQueueDpc (
- PKDPC Dpc
- );
+PLIST_ENTRY STDCALL
+KeRemoveQueue(IN PKQUEUE Queue,
+ IN KPROCESSOR_MODE WaitMode,
+ IN PLARGE_INTEGER Timeout OPTIONAL);
-LONG
-STDCALL
-KeResetEvent (
- PKEVENT Event
- );
+BOOLEAN STDCALL
+KeRemoveQueueDpc(IN PKDPC Dpc);
+
+LONG STDCALL
+KeResetEvent(IN PKEVENT Event);
+
+VOID STDCALL
+KeRosDumpStackFrames ( PULONG Frame, ULONG FrameCount );
-LONG STDCALL KeSetBasePriorityThread (struct _KTHREAD* Thread,
- LONG Increment);
+ULONG STDCALL
+KeRosGetStackFrames ( PULONG Frames, ULONG FrameCount );
+
+NTSTATUS STDCALL
+KeSetAffinityThread(PKTHREAD Thread,
+ KAFFINITY Affinity);
+
+LONG STDCALL
+KeSetBasePriorityThread(struct _KTHREAD* Thread,
+ LONG Increment);
LONG
STDCALL
);
-/*
- * FUNCTION: Sets the current irql without altering the current processor
- * state
- * ARGUMENTS:
- * newlvl = IRQ level to set
- * NOTE: This is for internal use only
- */
-VOID KeSetCurrentIrql(KIRQL newlvl);
-
-
-// io permission map has a 8k size
-// Each bit in the IOPM corresponds to an io port byte address. The bitmap
-// is initialized to allow IO at any port. [ all bits set ].
+/* io permission map has a 8k size
+ * Each bit in the IOPM corresponds to an io port byte address. The bitmap
+ * is initialized to allow IO at any port. [ all bits set ].
+ */
typedef struct _IOPM
{
UCHAR Bitmap[8192];
* is initialized to allow IO at any port. [ all bits set ]. The IOPL determines
* the minium privilege level required to perform IO prior to checking the permission map.
*/
-VOID Ke386SetIoAccessMap(ULONG NewMap, PIOPM *IoPermissionMap);
+BOOL STDCALL
+Ke386SetIoAccessMap(ULONG NewMap, PULONG IoPermissionMap);
/*
* FUNCTION: Queries the io permission map.
* is initialized to allow IO at any port. [ all bits set ]. The IOPL determines
* the minium privilege level required to perform IO prior to checking the permission map.
*/
-VOID Ke386QueryIoAccessMap(BOOLEAN NewMap, PIOPM *IoPermissionMap);
+BOOL STDCALL
+Ke386QueryIoAccessMap(ULONG NewMap, PULONG IoPermissionMap);
/*
* FUNCTION: Set the process IOPL
* Eprocess = Pointer to a executive process object
* EnableIo = Specify TRUE to enable IO and FALSE to disable
*/
-NTSTATUS Ke386IoSetAccessProcess(struct _EPROCESS* Eprocess, BOOLEAN EnableIo);
+BOOL STDCALL
+Ke386IoSetAccessProcess(struct _EPROCESS* Eprocess, BOOL EnableIo);
/*
- * FUNCTION: Releases a set of Global Descriptor Table Selectors
+ * FUNCTION: Sets the contents of a gdt descriptor.
* ARGUMENTS:
- * SelArray =
- * NumOfSelectors =
+ * Entry = The selector to set.
+ * Value1 = The value of the low dword of the descriptor.
+ * Value2 = The value of the high dword of the descriptor.
*/
-NTSTATUS KeI386ReleaseGdtSelectors(OUT PULONG SelArray,
- IN ULONG NumOfSelectors);
+VOID
+KeSetGdtSelector(
+ ULONG Entry,
+ ULONG Value1,
+ ULONG Value2
+);
/*
- * FUNCTION: Allocates a set of Global Descriptor Table Selectors
+ * FUNCTION: Releases a set of Global Descriptor Table Selectors
* ARGUMENTS:
* SelArray =
* NumOfSelectors =
*/
-NTSTATUS KeI386AllocateGdtSelectors(OUT PULONG SelArray,
- IN ULONG NumOfSelectors);
+NTSTATUS
+KeI386ReleaseGdtSelectors(
+ OUT PULONG SelArray,
+ IN ULONG NumOfSelectors
+);
-<<<<<<< kefuncs.h
/*
- * FUNCTION: Raises a user mode exception
- * ARGUMENTS:
- * ExceptionCode = Status code of the exception
- */
-VOID KeRaiseUserException(NTSTATUS ExceptionCode);
-
-
-/*
- * FUNCTION: Enters the kernel debugger
+ * FUNCTION: Allocates a set of Global Descriptor Table Selectors
* ARGUMENTS:
- * None
+ * SelArray =
+ * NumOfSelectors =
*/
-VOID
-STDCALL
-KeEnterKernelDebugger (VOID);
+NTSTATUS
+KeI386AllocateGdtSelectors(
+ OUT PULONG SelArray,
+ IN ULONG NumOfSelectors
+);
-VOID
-STDCALL
-KeFlushWriteBuffer (
- VOID
- );
-
KIRQL
FASTCALL
KfAcquireSpinLock (
IN KIRQL NewIrql
);
+
+VOID STDCALL KiDispatchInterrupt(VOID);
+
+/* Stubs Start here */
+
+VOID
+STDCALL
+KeReleaseInterruptSpinLock(
+ IN PKINTERRUPT Interrupt,
+ IN KIRQL OldIrql
+ );
+
+BOOLEAN
+STDCALL
+KeAreApcsDisabled(
+ VOID
+ );
+
+VOID
+STDCALL
+KeFlushQueuedDpcs(
+ VOID
+ );
+
+ULONG
+STDCALL
+KeGetRecommendedSharedDataAlignment(
+ VOID
+ );
+
+ULONG
+STDCALL
+KeQueryRuntimeThread(
+ IN PKTHREAD Thread,
+ OUT PULONG UserTime
+ );
+
+BOOLEAN
+STDCALL
+KeSetKernelStackSwapEnable(
+ IN BOOLEAN Enable
+ );
+
+BOOLEAN
+STDCALL
+KeDeregisterBugCheckReasonCallback(
+ IN PKBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord
+ );
+
+BOOLEAN
+STDCALL
+KeRegisterBugCheckReasonCallback(
+ IN PKBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord,
+ IN PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine,
+ IN KBUGCHECK_CALLBACK_REASON Reason,
+ IN PUCHAR Component
+ );
+
+VOID
+STDCALL
+KeTerminateThread(
+ IN KPRIORITY Increment
+);
+
+BOOLEAN
+STDCALL
+KeIsExecutingDpc(
+ VOID
+);
+
+VOID
+STDCALL
+KeSetEventBoostPriority(
+ IN PKEVENT Event,
+ IN PKTHREAD *Thread OPTIONAL
+);
+
+PCONFIGURATION_COMPONENT_DATA
+STDCALL
+KeFindConfigurationNextEntry(
+ IN PCONFIGURATION_COMPONENT_DATA Child,
+ IN CONFIGURATION_CLASS Class,
+ IN CONFIGURATION_TYPE Type,
+ IN PULONG ComponentKey OPTIONAL,
+ IN PCONFIGURATION_COMPONENT_DATA *NextLink
+);
+
+PCONFIGURATION_COMPONENT_DATA
+STDCALL
+KeFindConfigurationEntry(
+ IN PCONFIGURATION_COMPONENT_DATA Child,
+ IN CONFIGURATION_CLASS Class,
+ IN CONFIGURATION_TYPE Type,
+ IN PULONG ComponentKey OPTIONAL
+);
+
+VOID
+STDCALL
+KeFlushEntireTb(
+ IN BOOLEAN Unknown,
+ IN BOOLEAN CurrentCpuOnly
+);
+
+VOID
+STDCALL
+KeRevertToUserAffinityThread(
+ VOID
+);
+
+VOID
+STDCALL
+KiCoprocessorError(
+ VOID
+);
+
+VOID
+STDCALL
+KiUnexpectedInterrupt(
+ VOID
+);
+
+VOID
+STDCALL
+KeSetDmaIoCoherency(
+ IN ULONG Coherency
+);
+
+VOID
+STDCALL
+KeSetProfileIrql(
+ IN KIRQL ProfileIrql
+);
+
+VOID
+STDCALL
+KeSetSystemAffinityThread(
+ IN KAFFINITY Affinity
+);
+
+NTSTATUS
+STDCALL
+KeUserModeCallback(
+ IN ULONG FunctionID,
+ IN PVOID InputBuffer,
+ IN ULONG InputLength,
+ OUT PVOID *OutputBuffer,
+ OUT PULONG OutputLength
+);
+
+VOID
+STDCALL
+KeSetTimeIncrement(
+ IN ULONG MaxIncrement,
+ IN ULONG MinIncrement
+);
+
+VOID
+STDCALL
+KeCapturePersistentThreadState(
+ IN PVOID CurrentThread,
+ IN ULONG Setting1,
+ IN ULONG Setting2,
+ IN ULONG Setting3,
+ IN ULONG Setting4,
+ IN ULONG Setting5,
+ IN PVOID ThreadState
+);
+
+BOOLEAN
+STDCALL
+KeRemoveSystemServiceTable(
+ IN ULONG TableIndex
+);
+
+NTSTATUS
+KeI386FlatToGdtSelector(
+ IN ULONG Base,
+ IN USHORT Length,
+ IN USHORT Selector
+);
+
+CCHAR
+STDCALL
+KeSetIdealProcessorThread (
+ IN PKTHREAD Thread,
+ IN CCHAR Processor
+ );
+
+typedef
+VOID
+(FASTCALL *PTIME_UPDATE_NOTIFY_ROUTINE)(
+ IN HANDLE ThreadId,
+ IN KPROCESSOR_MODE Mode
+ );
+
+VOID
+FASTCALL
+KeSetTimeUpdateNotifyRoutine(
+ IN PTIME_UPDATE_NOTIFY_ROUTINE NotifyRoutine
+ );
+
+PKDEVICE_QUEUE_ENTRY
+STDCALL
+KeRemoveByKeyDeviceQueueIfBusy (
+ IN PKDEVICE_QUEUE DeviceQueue,
+ IN ULONG SortKey
+ );
+
+KAFFINITY
+STDCALL
+KeQueryActiveProcessors (
+ VOID
+ );
+
+VOID
+FASTCALL
+KeAcquireInStackQueuedSpinLockAtDpcLevel(
+ IN PKSPIN_LOCK SpinLock,
+ IN PKLOCK_QUEUE_HANDLE LockHandle
+ );
+
+VOID
+FASTCALL
+KeReleaseInStackQueuedSpinLockFromDpcLevel(
+ IN PKLOCK_QUEUE_HANDLE LockHandle
+ );
+
+KPRIORITY
+STDCALL
+KeQueryPriorityThread (
+ IN PKTHREAD Thread
+ );
+
+KIRQL
+STDCALL
+KeAcquireInterruptSpinLock(
+ IN PKINTERRUPT Interrupt
+ );
+
+VOID
+__cdecl
+KeSaveStateForHibernate(
+ IN PVOID State
+);
+
+NTSTATUS
+STDCALL
+KeRaiseUserException(
+ IN NTSTATUS ExceptionCode
+);
+
+VOID
+FASTCALL
+KeAcquireGuardedMutex(
+ PKGUARDED_MUTEX GuardedMutex
+);
+
+VOID
+FASTCALL
+KeAcquireGuardedMutexUnsafe(
+ PKGUARDED_MUTEX GuardedMutex
+);
+
+VOID
+STDCALL
+KeEnterGuardedRegion(VOID);
+
+VOID
+STDCALL
+KeLeaveGuardedRegion(VOID);
+
+VOID
+FASTCALL
+KeInitializeGuardedMutex(
+ PKGUARDED_MUTEX GuardedMutex
+);
+
+VOID
+FASTCALL
+KeReleaseGuardedMutexUnsafe(
+ PKGUARDED_MUTEX GuardedMutex
+);
+
+VOID
+FASTCALL
+KeReleaseGuardedMutex(
+ PKGUARDED_MUTEX GuardedMutex
+);
+
+BOOL
+FASTCALL
+KeTryToAcquireGuardedMutex(
+ PKGUARDED_MUTEX GuardedMutex
+);
+
#endif /* __INCLUDE_DDK_KEFUNCS_H */