ReactOS  r74622
ke_x.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define KeEnterGuardedRegionThread(_Thread)
 
#define KeEnterGuardedRegion()
 
#define KeLeaveGuardedRegionThread(_Thread)
 
#define KeLeaveGuardedRegion()
 
#define KeEnterCriticalRegionThread(_Thread)
 
#define KeEnterCriticalRegion()
 
#define KeLeaveCriticalRegionThread(_Thread)
 
#define KeLeaveCriticalRegion()
 
#define KiSatisfyMutantWait(Object, Thread)
 
#define KiSatisfyNonMutantWait(Object)
 
#define KiSatisfyObjectWait(Object, Thread)
 
#define KiAddThreadToWaitList(Thread, Swappable)
 
#define KxDelayThreadWait()
 
#define KxMultiThreadWait()
 
#define KxSingleThreadWait()
 
#define KxQueueThreadWait()
 

Functions

FORCEINLINE KPROCESSOR_MODE KeGetPreviousMode (VOID)
 
FORCEINLINE VOID KiAcquireDispatcherObject (IN DISPATCHER_HEADER *Object)
 
FORCEINLINE VOID KiReleaseDispatcherObject (IN DISPATCHER_HEADER *Object)
 
FORCEINLINE KIRQL KiAcquireDispatcherLock (VOID)
 
FORCEINLINE VOID KiReleaseDispatcherLock (IN KIRQL OldIrql)
 
FORCEINLINE VOID KiAcquireDispatcherLockAtDpcLevel (VOID)
 
FORCEINLINE VOID KiReleaseDispatcherLockFromDpcLevel (VOID)
 
FORCEINLINE VOID KiInsertDeferredReadyList (IN PKTHREAD Thread)
 
FORCEINLINE VOID KiRescheduleThread (IN BOOLEAN NewThread, IN ULONG Cpu)
 
FORCEINLINE VOID KiSetThreadSwapBusy (IN PKTHREAD Thread)
 
FORCEINLINE VOID KiAcquirePrcbLock (IN PKPRCB Prcb)
 
FORCEINLINE VOID KiReleasePrcbLock (IN PKPRCB Prcb)
 
FORCEINLINE VOID KiAcquireThreadLock (IN PKTHREAD Thread)
 
FORCEINLINE VOID KiReleaseThreadLock (IN PKTHREAD Thread)
 
FORCEINLINE BOOLEAN KiTryThreadLock (IN PKTHREAD Thread)
 
FORCEINLINE VOID KiCheckDeferredReadyList (IN PKPRCB Prcb)
 
FORCEINLINE VOID KiRequestApcInterrupt (IN BOOLEAN NeedApc, IN UCHAR Processor)
 
FORCEINLINE PKSPIN_LOCK_QUEUE KiAcquireTimerLock (IN ULONG Hand)
 
FORCEINLINE VOID KiReleaseTimerLock (IN PKSPIN_LOCK_QUEUE LockQueue)
 
FORCEINLINE VOID KiAcquireApcLock (IN PKTHREAD Thread, IN PKLOCK_QUEUE_HANDLE Handle)
 
FORCEINLINE VOID KiAcquireApcLockAtDpcLevel (IN PKTHREAD Thread, IN PKLOCK_QUEUE_HANDLE Handle)
 
FORCEINLINE VOID KiAcquireApcLockAtApcLevel (IN PKTHREAD Thread, IN PKLOCK_QUEUE_HANDLE Handle)
 
FORCEINLINE VOID KiReleaseApcLock (IN PKLOCK_QUEUE_HANDLE Handle)
 
FORCEINLINE VOID KiReleaseApcLockFromDpcLevel (IN PKLOCK_QUEUE_HANDLE Handle)
 
FORCEINLINE VOID KiAcquireProcessLock (IN PKPROCESS Process, IN PKLOCK_QUEUE_HANDLE Handle)
 
FORCEINLINE VOID KiReleaseProcessLock (IN PKLOCK_QUEUE_HANDLE Handle)
 
FORCEINLINE VOID KiReleaseProcessLockFromDpcLevel (IN PKLOCK_QUEUE_HANDLE Handle)
 
FORCEINLINE VOID KiAcquireDeviceQueueLock (IN PKDEVICE_QUEUE DeviceQueue, IN PKLOCK_QUEUE_HANDLE DeviceLock)
 
FORCEINLINE VOID KiReleaseDeviceQueueLock (IN PKLOCK_QUEUE_HANDLE DeviceLock)
 
FORCEINLINE PLARGE_INTEGER KiRecalculateDueTime (IN PLARGE_INTEGER OriginalDueTime, IN PLARGE_INTEGER DueTime, IN OUT PLARGE_INTEGER NewDueTime)
 
FORCEINLINE BOOLEAN KiCheckThreadStackSwap (IN PKTHREAD Thread, IN KPROCESSOR_MODE WaitMode)
 
FORCEINLINE NTSTATUS KiCheckAlertability (IN PKTHREAD Thread, IN BOOLEAN Alertable, IN KPROCESSOR_MODE WaitMode)
 
FORCEINLINE ULONG KiComputeTimerTableIndex (IN ULONGLONG DueTime)
 
FORCEINLINE VOID KiRemoveEntryTimer (IN PKTIMER Timer)
 
FORCEINLINE VOID KxInsertTimer (IN PKTIMER Timer, IN ULONG Hand)
 
FORCEINLINE BOOLEAN KiComputeDueTime (IN PKTIMER Timer, IN LARGE_INTEGER DueTime, OUT PULONG Hand)
 
FORCEINLINE VOID KxRemoveTreeTimer (IN PKTIMER Timer)
 
FORCEINLINE VOID KxSetTimerForThreadWait (IN PKTIMER Timer, IN LARGE_INTEGER Interval, OUT PULONG Hand)
 
FORCEINLINE VOID KxUnwaitThread (IN DISPATCHER_HEADER *Object, IN KPRIORITY Increment)
 
FORCEINLINE VOID KxUnwaitThreadForEvent (IN PKEVENT Event, IN KPRIORITY Increment)
 
FORCEINLINE VOID KxQueueReadyThread (IN PKTHREAD Thread, IN PKPRCB Prcb)
 
FORCEINLINE PKTHREAD KiSelectReadyThread (IN KPRIORITY Priority, IN PKPRCB Prcb)
 
FORCEINLINE SCHAR KiComputeNewPriority (IN PKTHREAD Thread, IN SCHAR Adjustment)
 
FORCEINLINE VOID _KeInitializeGuardedMutex (OUT PKGUARDED_MUTEX GuardedMutex)
 
FORCEINLINE VOID _KeAcquireGuardedMutexUnsafe (IN OUT PKGUARDED_MUTEX GuardedMutex)
 
FORCEINLINE VOID _KeReleaseGuardedMutexUnsafe (IN OUT PKGUARDED_MUTEX GuardedMutex)
 
FORCEINLINE VOID _KeAcquireGuardedMutex (IN PKGUARDED_MUTEX GuardedMutex)
 
FORCEINLINE VOID _KeReleaseGuardedMutex (IN OUT PKGUARDED_MUTEX GuardedMutex)
 
FORCEINLINE BOOLEAN _KeTryToAcquireGuardedMutex (IN OUT PKGUARDED_MUTEX GuardedMutex)
 
FORCEINLINE VOID KiAcquireNmiListLock (OUT PKIRQL OldIrql)
 
FORCEINLINE VOID KiReleaseNmiListLock (IN KIRQL OldIrql)
 

Macro Definition Documentation

#define KeEnterCriticalRegion ( )
Value:
{ \
}
struct _KTHREAD * PKTHREAD
Definition: nt_native.h:28
#define KeEnterCriticalRegionThread(_Thread)
Definition: ke_x.h:72
#define KeGetCurrentThread
Definition: hal.h:44

Definition at line 83 of file ke_x.h.

Referenced by _Acquires_lock_(), _ExEnterCriticalRegionAndAcquireFastMutexUnsafe(), _IRQL_requires_min_(), _KeEnterCriticalRegion(), AcquireResourceThread(), ApphelpCacheAcquireLock(), ApphelpCacheTryAcquireLock(), CcRosFlushDirtyPages(), CdfsCleanup(), CdfsCreate(), ClassDeviceControl(), ClassDispatchPnp(), ClasspCleanupProtectedLocks(), CmpLockRegistry(), CmpLockRegistryExclusive(), DxEngLockHdev(), ExAcquireTimeRefreshLock(), ExChangeHandle(), ExCompareExchangeCallBack(), ExCreateHandle(), ExCreateHandleTable(), ExDestroyHandle(), ExDupHandleTable(), ExEnterCriticalRegionAndAcquireResourceExclusive(), ExEnterCriticalRegionAndAcquireResourceShared(), ExEnterCriticalRegionAndAcquireSharedWaitForExclusive(), ExEnumHandleTable(), ExpAllocateHandleTableEntry(), ExRemoveHandleTable(), FltUnregisterFilter(), FsRecLoadFileSystem(), GDIOBJ_hInsertObject(), GDIOBJ_LockObject(), GDIOBJ_TryLockObject(), GdiPoolAllocate(), GdiPoolFree(), HfontCreate(), IntRemoveEvent(), IoEnumerateRegisteredFiltersList(), IopActionInitChildServices(), IopAttachFilterDriversCallback(), IopGetSetSecurityObject(), IopLoadUnloadDriver(), IopMountVolume(), IopParseDevice(), IopSetDeviceSecurityDescriptor(), IoRegisterFileSystem(), IoRegisterFsRegistrationChange(), IoUnregisterFileSystem(), IoUnregisterFsRegistrationChange(), KeFreezeAllThreads(), KsAcquireDeviceSecurityLock(), KspSynchronizedEventRoutine(), LpcRequestPort(), LpcRequestWaitReplyPort(), MiFindInitializationCode(), MiLoadUserSymbols(), MiProcessLoaderEntry(), MmAddVerifierThunks(), MmGetSystemRoutineAddress(), MmLoadSystemImage(), MmSessionCreate(), MmSessionDelete(), MmUnloadSystemImage(), NtLoadKeyEx(), NtRequestPort(), NtRequestWaitReplyPort(), NtSecureConnectPort(), NtSetInformationProcess(), NtSetInformationThread(), NtWaitForMultipleObjects(), ObClearProcessHandleTable(), ObKillProcess(), ObpAcquireDirectoryLockExclusive(), ObpAcquireDirectoryLockShared(), ObpAcquireObjectLock(), ObpAcquireObjectLockShared(), ObpCloseHandle(), ObpEnterObjectTypeMutex(), ObpReferenceProcessObjectByHandle(), ObpSdAcquireLock(), ObpSdAcquireLockShared(), ObQueryObjectAuditingByHandle(), ObReferenceObjectByHandle(), PciAssignSlotResources(), PciFindParentPciFdoExtension(), PciFindPdoByFunction(), PciFindPdoByLocation(), PciInsertEntryAtHead(), PciInsertEntryAtTail(), PciScanBus(), PsGetCurrentThreadWin32ThreadAndEnterCriticalRegion(), PsGetNextProcessThread(), PsLookupProcessByProcessId(), PsLookupProcessThreadByCid(), PsLookupThreadByThreadId(), PspCreateThread(), PspDeleteThread(), PspExitThread(), PspLockProcessSecurityExclusive(), PspLockProcessSecurityShared(), PspLockThreadSecurityExclusive(), PspLockThreadSecurityShared(), PsSetProcessWin32Process(), QSI_DEF(), RamdiskCreateDiskDevice(), RamdiskQueryDeviceRelations(), RamdiskRemoveBusDevice(), RtlEnterHeapLock(), RtlTryEnterHeapLock(), TestOwnerRes(), TestResourceExclusiveAccess(), TestResourceSharedAccess(), TestResourceWithOwner(), TEXTOBJ_LockText(), UserEnterExclusive(), UserEnterShared(), and UserGetDCEx().

#define KeEnterCriticalRegionThread (   _Thread)
Value:
{ \
/* Sanity checks */ \
ASSERT((_Thread->KernelApcDisable <= 0) && \
(_Thread->KernelApcDisable != -32768)); \
\
/* Disable Kernel APCs */ \
_Thread->KernelApcDisable--; \
}
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
#define KeGetCurrentThread
Definition: hal.h:44

Definition at line 72 of file ke_x.h.

#define KeEnterGuardedRegion ( )
Value:
{ \
}
struct _KTHREAD * PKTHREAD
Definition: nt_native.h:28
#define KeEnterGuardedRegionThread(_Thread)
Definition: ke_x.h:22
#define KeGetCurrentThread
Definition: hal.h:44

Definition at line 34 of file ke_x.h.

Referenced by _KeEnterGuardedRegion(), MiFindContiguousPages(), MiLockProcessWorkingSet(), MiLockProcessWorkingSetShared(), MiLockWorkingSet(), PsConvertToGuiThread(), PsGetContextThread(), PspSetQuotaLimits(), and PsSetContextThread().

#define KeEnterGuardedRegionThread (   _Thread)
Value:
{ \
/* Sanity checks */ \
ASSERT((_Thread->SpecialApcDisable <= 0) && \
(_Thread->SpecialApcDisable != -32768)); \
\
/* Disable Special APCs */ \
_Thread->SpecialApcDisable--; \
}
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
#define KeGetCurrentThread
Definition: hal.h:44
#define APC_LEVEL
Definition: env_spec_w32.h:695

Definition at line 22 of file ke_x.h.

Referenced by _KeAcquireGuardedMutex(), and _KeTryToAcquireGuardedMutex().

#define KeLeaveCriticalRegion ( )
Value:
{ \
}
#define KeLeaveCriticalRegionThread(_Thread)
Definition: ke_x.h:92
struct _KTHREAD * PKTHREAD
Definition: nt_native.h:28
#define KeGetCurrentThread
Definition: hal.h:44

Definition at line 114 of file ke_x.h.

Referenced by _ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(), _IRQL_requires_min_(), _KeLeaveCriticalRegion(), _Releases_lock_(), AcquireResourceThread(), ApphelpCacheReleaseLock(), ApphelpCacheTryAcquireLock(), CcRosFlushDirtyPages(), CdfsCleanup(), CdfsCreate(), ClassDeviceControl(), ClassDispatchPnp(), ClasspCleanupProtectedLocks(), CmpUnlockRegistry(), DxEngUnlockHdev(), ExAcquireTimeRefreshLock(), ExChangeHandle(), ExCompareExchangeCallBack(), ExCreateHandle(), ExCreateHandleTable(), ExDestroyHandle(), ExDupHandleTable(), ExEnumHandleTable(), ExpAllocateHandleTableEntry(), ExReleaseResourceAndLeaveCriticalRegion(), ExReleaseTimeRefreshLock(), ExRemoveHandleTable(), FltUnregisterFilter(), FsRecLoadFileSystem(), GDIOBJ_TryLockObject(), GDIOBJ_vDeleteObject(), GDIOBJ_vUnlockObject(), GdiPoolAllocate(), GdiPoolFree(), HfontCreate(), IntRemoveEvent(), IoEnumerateRegisteredFiltersList(), IopActionInitChildServices(), IopAttachFilterDriversCallback(), IopGetSetSecurityObject(), IopLoadUnloadDriver(), IopMountVolume(), IopParseDevice(), IopSetDeviceSecurityDescriptor(), IoRegisterFileSystem(), IoRegisterFsRegistrationChange(), IoUnregisterFileSystem(), IoUnregisterFsRegistrationChange(), KeReleaseMutant(), KeThawAllThreads(), KspSynchronizedEventRoutine(), KsReleaseDeviceSecurityLock(), LpcRequestPort(), LpcRequestWaitReplyPort(), MiFindInitializationCode(), MiLoadUserSymbols(), MiProcessLoaderEntry(), MmAddVerifierThunks(), MmGetSystemRoutineAddress(), MmLoadSystemImage(), MmSessionCreate(), MmSessionDelete(), MmUnloadSystemImage(), NtLoadKeyEx(), NtRequestPort(), NtRequestWaitReplyPort(), NtSecureConnectPort(), NtSetInformationProcess(), NtSetInformationThread(), NtWaitForMultipleObjects(), ObClearProcessHandleTable(), ObKillProcess(), ObpCloseHandle(), ObpLeaveObjectTypeMutex(), ObpReferenceProcessObjectByHandle(), ObpReleaseDirectoryLock(), ObpReleaseObjectLock(), ObpSdReleaseLock(), ObpSdReleaseLockShared(), ObQueryObjectAuditingByHandle(), ObReferenceObjectByHandle(), PciAssignSlotResources(), PciFindParentPciFdoExtension(), PciFindPdoByFunction(), PciFindPdoByLocation(), PciInsertEntryAtHead(), PciInsertEntryAtTail(), PciScanBus(), PsGetNextProcessThread(), PsLookupProcessByProcessId(), PsLookupProcessThreadByCid(), PsLookupThreadByThreadId(), PspCreateThread(), PspDeleteThread(), PspExitThread(), PspUnlockProcessSecurityExclusive(), PspUnlockProcessSecurityShared(), PspUnlockThreadSecurityExclusive(), PspUnlockThreadSecurityShared(), PsSetProcessWin32Process(), QSI_DEF(), RamdiskCreateDiskDevice(), RamdiskQueryDeviceRelations(), RamdiskRemoveBusDevice(), RtlLeaveHeapLock(), RtlTryEnterHeapLock(), TestOwnerRes(), TestResourceExclusiveAccess(), TestResourceSharedAccess(), TestResourceWithOwner(), TestSeAssignSecurity(), TEXTOBJ_UnlockText(), UserGetDCEx(), and UserLeave().

#define KeLeaveCriticalRegionThread (   _Thread)
Value:
{ \
/* Sanity checks */ \
ASSERT(_Thread->KernelApcDisable < 0); \
\
/* Enable Kernel APCs */ \
_Thread->KernelApcDisable++; \
\
/* Check if Kernel APCs are now enabled */ \
if (!(_Thread->KernelApcDisable)) \
{ \
/* Check if we need to request an APC Delivery */ \
if (!(IsListEmpty(&_Thread->ApcState.ApcListHead[KernelMode])) && \
!(_Thread->SpecialApcDisable)) \
{ \
/* Check for the right environment */ \
} \
} \
}
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
VOID NTAPI KiCheckForKernelApcDelivery(VOID)
Definition: apc.c:36
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
if(!(yy_init))
Definition: macro.lex.yy.c:704
#define KeGetCurrentThread
Definition: hal.h:44

Definition at line 92 of file ke_x.h.

#define KeLeaveGuardedRegion ( )
Value:
{ \
}
struct _KTHREAD * PKTHREAD
Definition: nt_native.h:28
#define KeLeaveGuardedRegionThread(_Thread)
Definition: ke_x.h:43
#define KeGetCurrentThread
Definition: hal.h:44

Definition at line 63 of file ke_x.h.

Referenced by _KeLeaveGuardedRegion(), MiFindContiguousPages(), MiUnlockProcessWorkingSet(), MiUnlockProcessWorkingSetShared(), MiUnlockWorkingSet(), PsConvertToGuiThread(), PsGetContextThread(), PspSetQuotaLimits(), and PsSetContextThread().

#define KeLeaveGuardedRegionThread (   _Thread)
Value:
{ \
/* Sanity checks */ \
ASSERT(_Thread->SpecialApcDisable < 0); \
\
/* Leave region and check if APCs are OK now */ \
if (!(++_Thread->SpecialApcDisable)) \
{ \
/* Check for Kernel APCs on the list */ \
if (!IsListEmpty(&_Thread->ApcState. \
ApcListHead[KernelMode])) \
{ \
/* Check for APC Delivery */ \
} \
} \
}
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
VOID NTAPI KiCheckForKernelApcDelivery(VOID)
Definition: apc.c:36
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
if(!(yy_init))
Definition: macro.lex.yy.c:704
#define KeGetCurrentThread
Definition: hal.h:44
#define APC_LEVEL
Definition: env_spec_w32.h:695

Definition at line 43 of file ke_x.h.

Referenced by _KeReleaseGuardedMutex(), and _KeTryToAcquireGuardedMutex().

#define KiAddThreadToWaitList (   Thread,
  Swappable 
)
Value:
{ \
/* Make sure it's swappable */ \
if (Swappable) \
{ \
/* Insert it into the PRCB's List */ \
InsertTailList(&KeGetCurrentPrcb()->WaitListHead, \
&Thread->WaitListEntry); \
} \
}
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1054
#define InsertTailList(ListHead, Entry)
if(!(yy_init))
Definition: macro.lex.yy.c:704
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653

Definition at line 816 of file ke_x.h.

Referenced by KeDelayExecutionThread(), KeRemoveQueue(), KeWaitForMultipleObjects(), and KeWaitForSingleObject().

#define KiSatisfyMutantWait (   Object,
  Thread 
)
Value:
{ \
/* Decrease the Signal State */ \
(Object)->Header.SignalState--; \
\
/* Check if it's now non-signaled */ \
if (!(Object)->Header.SignalState) \
{ \
/* Set the Owner Thread */ \
(Object)->OwnerThread = Thread; \
\
/* Disable APCs if needed */ \
Thread->KernelApcDisable = Thread->KernelApcDisable - \
(Object)->ApcDisable; \
\
/* Check if it's abandoned */ \
{ \
/* Unabandon it */ \
\
/* Return Status */ \
Thread->WaitStatus = STATUS_ABANDONED; \
} \
\
/* Insert it into the Mutant List */ \
InsertHeadList(Thread->MutantListHead.Blink, \
&(Object)->MutantListEntry); \
} \
}
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
Definition: Header.h:8
_In_ KPRIORITY _In_ BOOLEAN Abandoned
Definition: kefuncs.h:606
if(!(yy_init))
Definition: macro.lex.yy.c:704
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
static IUnknown Object
Definition: main.c:512
#define FALSE
Definition: numbers.c:16
#define STATUS_ABANDONED
Definition: ntstatus.h:75

Definition at line 707 of file ke_x.h.

Referenced by KeWaitForMultipleObjects(), and KeWaitForSingleObject().

#define KiSatisfyNonMutantWait (   Object)
Value:
{ \
{ \
/* Synchronization Timers and Events just get un-signaled */ \
(Object)->Header.SignalState = 0; \
} \
else if ((Object)->Header.Type == SemaphoreObject) \
{ \
/* These ones can have multiple states, so we only decrease it */ \
(Object)->Header.SignalState--; \
} \
}
Definition: Header.h:8
if(!(yy_init))
Definition: macro.lex.yy.c:704
static IUnknown Object
Definition: main.c:512
#define TIMER_OR_EVENT_TYPE
Definition: ke.h:152
else
Definition: s_aatritemp.h:84

Definition at line 741 of file ke_x.h.

Referenced by KeWaitForMultipleObjects(), and KeWaitForSingleObject().

#define KiSatisfyObjectWait (   Object,
  Thread 
)
Value:
{ \
/* Special case for Mutants */ \
if ((Object)->Header.Type == MutantObject) \
{ \
} \
{ \
} \
}
#define KiSatisfyNonMutantWait(Object)
Definition: ke_x.h:741
#define KiSatisfyMutantWait(Object, Thread)
Definition: ke_x.h:707
Definition: Header.h:8
if(!(yy_init))
Definition: macro.lex.yy.c:704
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
static IUnknown Object
Definition: main.c:512
else
Definition: s_aatritemp.h:84

Definition at line 759 of file ke_x.h.

Referenced by KeWaitForMultipleObjects(), and KiWaitTest().

#define KxDelayThreadWait ( )
Value:
\
/* Setup the Wait Block */ \
Thread->WaitBlockList = TimerBlock; \
\
/* Setup the timer */ \
\
/* Save the due time for the caller */ \
DueTime.QuadPart = Timer->DueTime.QuadPart; \
\
/* Link the timer to this Wait Block */ \
TimerBlock->NextWaitBlock = TimerBlock; \
Timer->Header.WaitListHead.Flink = &TimerBlock->WaitListEntry; \
Timer->Header.WaitListHead.Blink = &TimerBlock->WaitListEntry; \
\
/* Clear wait status */ \
Thread->WaitStatus = STATUS_SUCCESS; \
\
/* Setup wait fields */ \
Thread->Alertable = Alertable; \
Thread->WaitReason = DelayExecution; \
Thread->WaitMode = WaitMode; \
\
/* Check if we can swap the thread's stack */ \
Thread->WaitListEntry.Flink = NULL; \
Swappable = KiCheckThreadStackSwap(Thread, WaitMode); \
\
/* Set the wait time */ \
FORCEINLINE BOOLEAN KiCheckThreadStackSwap(IN PKTHREAD Thread, IN KPROCESSOR_MODE WaitMode)
Definition: ke_x.h:795
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
ULONG LowPart
Definition: ketypes.h:895
_In_ PVOID _In_ BOOLEAN Alertable
Definition: exfuncs.h:452
FORCEINLINE VOID KxSetTimerForThreadWait(IN PKTIMER Timer, IN LARGE_INTEGER Interval, OUT PULONG Hand)
Definition: ke_x.h:1025
_In_ LARGE_INTEGER DueTime
Definition: kefuncs.h:524
smooth NULL
Definition: ftsmooth.c:464
DWORD Interval
Definition: netstat.c:30
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
NTKERNELAPI volatile KSYSTEM_TIME KeTickCount
Definition: clock.c:19
UINT Timer
Definition: capclock.c:11
LONGLONG QuadPart
Definition: typedefs.h:113

Definition at line 1067 of file ke_x.h.

Referenced by KeDelayExecutionThread().

#define KxMultiThreadWait ( )

Definition at line 1098 of file ke_x.h.

Referenced by KeWaitForMultipleObjects().

#define KxQueueThreadWait ( )

Definition at line 1199 of file ke_x.h.

Referenced by KeRemoveQueue().

#define KxSingleThreadWait ( )

Definition at line 1154 of file ke_x.h.

Referenced by KeWaitForSingleObject().

Function Documentation

FORCEINLINE VOID _KeAcquireGuardedMutex ( IN PKGUARDED_MUTEX  GuardedMutex)

Definition at line 1573 of file ke_x.h.

Referenced by KeAcquireGuardedMutex().

1574 {
1576 
1577  /* Sanity checks */
1579  ASSERT(GuardedMutex->Owner != Thread);
1580 
1581  /* Disable Special APCs */
1583 
1584  /* Remove the lock */
1585  if (!InterlockedBitTestAndReset(&GuardedMutex->Count, GM_LOCK_BIT_V))
1586  {
1587  /* The Guarded Mutex was already locked, enter contented case */
1588  KiAcquireGuardedMutex(GuardedMutex);
1589  }
1590 
1591  /* Set the Owner and Special APC Disable state */
1592  GuardedMutex->Owner = Thread;
1593  GuardedMutex->SpecialApcDisable = Thread->SpecialApcDisable;
1594 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
SHORT SpecialApcDisable
Definition: ketypes.h:1052
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
#define InterlockedBitTestAndReset
Definition: interlocked.h:35
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define KeEnterGuardedRegionThread(_Thread)
Definition: ke_x.h:22
VOID FASTCALL KiAcquireGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: wait.c:122
#define KeGetCurrentThread
Definition: hal.h:44
#define GM_LOCK_BIT_V
#define APC_LEVEL
Definition: env_spec_w32.h:695
FORCEINLINE VOID _KeAcquireGuardedMutexUnsafe ( IN OUT PKGUARDED_MUTEX  GuardedMutex)

Definition at line 1508 of file ke_x.h.

Referenced by KeAcquireGuardedMutexUnsafe().

1509 {
1511 
1512  /* Sanity checks */
1514  (Thread->SpecialApcDisable < 0) ||
1515  (Thread->Teb == NULL) ||
1516  (Thread->Teb >= (PTEB)MM_SYSTEM_RANGE_START));
1517  ASSERT(GuardedMutex->Owner != Thread);
1518 
1519  /* Remove the lock */
1520  if (!InterlockedBitTestAndReset(&GuardedMutex->Count, GM_LOCK_BIT_V))
1521  {
1522  /* The Guarded Mutex was already locked, enter contented case */
1523  KiAcquireGuardedMutex(GuardedMutex);
1524  }
1525 
1526  /* Set the Owner */
1527  GuardedMutex->Owner = Thread;
1528 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
SHORT SpecialApcDisable
Definition: ketypes.h:1052
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
struct _TEB * Teb
Definition: ketypes.h:1057
#define InterlockedBitTestAndReset
Definition: interlocked.h:35
smooth NULL
Definition: ftsmooth.c:464
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define MM_SYSTEM_RANGE_START
Definition: armddk.h:18
Definition: compat.h:484
VOID FASTCALL KiAcquireGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: wait.c:122
#define KeGetCurrentThread
Definition: hal.h:44
#define GM_LOCK_BIT_V
#define APC_LEVEL
Definition: env_spec_w32.h:695
FORCEINLINE VOID _KeInitializeGuardedMutex ( OUT PKGUARDED_MUTEX  GuardedMutex)

Definition at line 1495 of file ke_x.h.

Referenced by KeInitializeGuardedMutex().

1496 {
1497  /* Setup the Initial Data */
1498  GuardedMutex->Count = GM_LOCK_BIT;
1499  GuardedMutex->Owner = NULL;
1500  GuardedMutex->Contention = 0;
1501 
1502  /* Initialize the Wait Gate */
1503  KeInitializeGate(&GuardedMutex->Gate);
1504 }
#define GM_LOCK_BIT
smooth NULL
Definition: ftsmooth.c:464
VOID FASTCALL KeInitializeGate(PKGATE Gate)
FORCEINLINE VOID _KeReleaseGuardedMutex ( IN OUT PKGUARDED_MUTEX  GuardedMutex)

Definition at line 1598 of file ke_x.h.

Referenced by KeReleaseGuardedMutex().

1599 {
1601  LONG OldValue, NewValue;
1602 
1603  /* Sanity checks */
1605  ASSERT(GuardedMutex->Owner == Thread);
1606  ASSERT(Thread->SpecialApcDisable == GuardedMutex->SpecialApcDisable);
1607 
1608  /* Destroy the Owner */
1609  GuardedMutex->Owner = NULL;
1610 
1611  /* Add the Lock Bit */
1612  OldValue = InterlockedExchangeAdd(&GuardedMutex->Count, GM_LOCK_BIT);
1613  ASSERT((OldValue & GM_LOCK_BIT) == 0);
1614 
1615  /* Check if it was already locked, but not woken */
1616  if ((OldValue) && !(OldValue & GM_LOCK_WAITER_WOKEN))
1617  {
1618  /* Update the Oldvalue to what it should be now */
1619  OldValue += GM_LOCK_BIT;
1620 
1621  /* The mutex will be woken, minus one waiter */
1622  NewValue = OldValue + GM_LOCK_WAITER_WOKEN -
1624 
1625  /* Remove the Woken bit */
1626  if (InterlockedCompareExchange(&GuardedMutex->Count,
1627  NewValue,
1628  OldValue) == OldValue)
1629  {
1630  /* Signal the Gate */
1631  KeSignalGateBoostPriority(&GuardedMutex->Gate);
1632  }
1633  }
1634 
1635  /* Re-enable APCs */
1637 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
SHORT SpecialApcDisable
Definition: ketypes.h:1052
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
#define InterlockedCompareExchange
Definition: interlocked.h:104
#define GM_LOCK_BIT
long LONG
Definition: pedump.c:60
#define GM_LOCK_WAITER_INC
smooth NULL
Definition: ftsmooth.c:464
#define InterlockedExchangeAdd
Definition: interlocked.h:181
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
VOID FASTCALL KeSignalGateBoostPriority(PKGATE Gate)
#define KeLeaveGuardedRegionThread(_Thread)
Definition: ke_x.h:43
#define KeGetCurrentThread
Definition: hal.h:44
#define APC_LEVEL
Definition: env_spec_w32.h:695
#define GM_LOCK_WAITER_WOKEN
FORCEINLINE VOID _KeReleaseGuardedMutexUnsafe ( IN OUT PKGUARDED_MUTEX  GuardedMutex)

Definition at line 1532 of file ke_x.h.

Referenced by KeReleaseGuardedMutexUnsafe().

1533 {
1534  LONG OldValue, NewValue;
1535 
1536  /* Sanity checks */
1538  (KeGetCurrentThread()->SpecialApcDisable < 0) ||
1539  (KeGetCurrentThread()->Teb == NULL) ||
1541  ASSERT(GuardedMutex->Owner == KeGetCurrentThread());
1542 
1543  /* Destroy the Owner */
1544  GuardedMutex->Owner = NULL;
1545 
1546  /* Add the Lock Bit */
1547  OldValue = InterlockedExchangeAdd(&GuardedMutex->Count, GM_LOCK_BIT);
1548  ASSERT((OldValue & GM_LOCK_BIT) == 0);
1549 
1550  /* Check if it was already locked, but not woken */
1551  if ((OldValue) && !(OldValue & GM_LOCK_WAITER_WOKEN))
1552  {
1553  /* Update the Oldvalue to what it should be now */
1554  OldValue += GM_LOCK_BIT;
1555 
1556  /* The mutex will be woken, minus one waiter */
1557  NewValue = OldValue + GM_LOCK_WAITER_WOKEN -
1559 
1560  /* Remove the Woken bit */
1561  if (InterlockedCompareExchange(&GuardedMutex->Count,
1562  NewValue,
1563  OldValue) == OldValue)
1564  {
1565  /* Signal the Gate */
1566  KeSignalGateBoostPriority(&GuardedMutex->Gate);
1567  }
1568  }
1569 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
#define InterlockedCompareExchange
Definition: interlocked.h:104
#define GM_LOCK_BIT
long LONG
Definition: pedump.c:60
#define GM_LOCK_WAITER_INC
smooth NULL
Definition: ftsmooth.c:464
#define InterlockedExchangeAdd
Definition: interlocked.h:181
#define MM_SYSTEM_RANGE_START
Definition: armddk.h:18
Definition: compat.h:484
VOID FASTCALL KeSignalGateBoostPriority(PKGATE Gate)
#define KeGetCurrentThread
Definition: hal.h:44
#define APC_LEVEL
Definition: env_spec_w32.h:695
#define GM_LOCK_WAITER_WOKEN
FORCEINLINE BOOLEAN _KeTryToAcquireGuardedMutex ( IN OUT PKGUARDED_MUTEX  GuardedMutex)

Definition at line 1641 of file ke_x.h.

Referenced by KeTryToAcquireGuardedMutex().

1642 {
1644 
1645  /* Block APCs */
1647 
1648  /* Remove the lock */
1649  if (!InterlockedBitTestAndReset(&GuardedMutex->Count, GM_LOCK_BIT_V))
1650  {
1651  /* Re-enable APCs */
1653  YieldProcessor();
1654 
1655  /* Return failure */
1656  return FALSE;
1657  }
1658 
1659  /* Set the Owner and APC State */
1660  GuardedMutex->Owner = Thread;
1661  GuardedMutex->SpecialApcDisable = Thread->SpecialApcDisable;
1662  return TRUE;
1663 }
SHORT SpecialApcDisable
Definition: ketypes.h:1052
#define TRUE
Definition: numbers.c:17
FORCEINLINE VOID YieldProcessor(VOID)
Definition: ke.h:32
#define InterlockedBitTestAndReset
Definition: interlocked.h:35
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define KeEnterGuardedRegionThread(_Thread)
Definition: ke_x.h:22
#define FALSE
Definition: numbers.c:16
#define KeLeaveGuardedRegionThread(_Thread)
Definition: ke_x.h:43
#define KeGetCurrentThread
Definition: hal.h:44
#define GM_LOCK_BIT_V
FORCEINLINE KPROCESSOR_MODE KeGetPreviousMode ( VOID  )

Definition at line 12 of file ke_x.h.

13 {
14  /* Return the current mode */
15  return KeGetCurrentThread()->PreviousMode;
16 }
#define KeGetCurrentThread
Definition: hal.h:44
FORCEINLINE VOID KiAcquireApcLock ( IN PKTHREAD  Thread,
IN PKLOCK_QUEUE_HANDLE  Handle 
)

Definition at line 600 of file ke_x.h.

Referenced by KeAlertResumeThread(), KeAlertThread(), KeAttachProcess(), KeDetachProcess(), KeFlushQueueApc(), KeForceResumeThread(), KeInsertQueueApc(), KeRemoveQueueApc(), KeResumeThread(), KeStackAttachProcess(), KeSuspendThread(), KeTestAlertThread(), KeUnstackDetachProcess(), and KeWaitForGate().

602 {
603  /* Acquire the lock and raise to synchronization level */
605 }
VOID FASTCALL KeAcquireInStackQueuedSpinLockRaiseToSynch(IN PKSPIN_LOCK SpinLock, IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:142
_In_ HANDLE Handle
Definition: extypes.h:390
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
FORCEINLINE VOID KiAcquireApcLockAtApcLevel ( IN PKTHREAD  Thread,
IN PKLOCK_QUEUE_HANDLE  Handle 
)

Definition at line 618 of file ke_x.h.

Referenced by KiDeliverApc().

620 {
621  /* Acquire the lock */
623 }
VOID FASTCALL KeAcquireInStackQueuedSpinLock(IN PKSPIN_LOCK SpinLock, IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:130
_In_ HANDLE Handle
Definition: extypes.h:390
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
FORCEINLINE VOID KiAcquireApcLockAtDpcLevel ( IN PKTHREAD  Thread,
IN PKLOCK_QUEUE_HANDLE  Handle 
)

Definition at line 609 of file ke_x.h.

Referenced by KeFreezeAllThreads(), and KeThawAllThreads().

611 {
612  /* Acquire the lock */
614 }
_In_ HANDLE Handle
Definition: extypes.h:390
VOID FASTCALL KeAcquireInStackQueuedSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock, IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:337
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
FORCEINLINE VOID KiAcquireDeviceQueueLock ( IN PKDEVICE_QUEUE  DeviceQueue,
IN PKLOCK_QUEUE_HANDLE  DeviceLock 
)

Definition at line 668 of file ke_x.h.

Referenced by KeInsertByKeyDeviceQueue(), KeInsertDeviceQueue(), KeRemoveByKeyDeviceQueue(), KeRemoveByKeyDeviceQueueIfBusy(), KeRemoveDeviceQueue(), and KeRemoveEntryDeviceQueue().

670 {
671  /* Check if we were called from a threaded DPC */
672  if (KeGetCurrentPrcb()->DpcThreadActive)
673  {
674  /* Lock the Queue, we're not at DPC level */
675  KeAcquireInStackQueuedSpinLock(&DeviceQueue->Lock, DeviceLock);
676  }
677  else
678  {
679  /* We must be at DPC level, acquire the lock safely */
681  KeAcquireInStackQueuedSpinLockAtDpcLevel(&DeviceQueue->Lock,
682  DeviceLock);
683  }
684 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1054
VOID FASTCALL KeAcquireInStackQueuedSpinLock(IN PKSPIN_LOCK SpinLock, IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:130
VOID FASTCALL KeAcquireInStackQueuedSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock, IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:337
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
FORCEINLINE VOID KiAcquireDispatcherObject ( IN DISPATCHER_HEADER Object)

Definition at line 127 of file ke_x.h.

Referenced by KeSignalGateBoostPriority(), KeWaitForGate(), and KiInsertQueueApc().

128 {
130 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:315
static IUnknown Object
Definition: main.c:512
FORCEINLINE VOID KiAcquireNmiListLock ( OUT PKIRQL  OldIrql)

Definition at line 1668 of file ke_x.h.

Referenced by KeDeregisterNmiCallback(), and KeRegisterNmiCallback().

1669 {
1671 }
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
KSPIN_LOCK KiNmiCallbackListLock
Definition: bug.c:33
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
FORCEINLINE VOID KiAcquireProcessLock ( IN PKPROCESS  Process,
IN PKLOCK_QUEUE_HANDLE  Handle 
)

Definition at line 643 of file ke_x.h.

Referenced by KeFreezeAllThreads(), KeQueryRuntimeProcess(), KeSetAffinityProcess(), KeSetPriorityAndQuantumProcess(), KeSetQuantumProcess(), KeStartThread(), KeTerminateThread(), KeThawAllThreads(), and MmSetExecuteOptions().

645 {
646  /* Acquire the lock and raise to synchronization level */
648 }
VOID FASTCALL KeAcquireInStackQueuedSpinLockRaiseToSynch(IN PKSPIN_LOCK SpinLock, IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:142
_In_ HANDLE Handle
Definition: extypes.h:390
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
FORCEINLINE PKSPIN_LOCK_QUEUE KiAcquireTimerLock ( IN ULONG  Hand)

Definition at line 280 of file ke_x.h.

Referenced by KeSetSystemTime(), KiInsertTreeTimer(), KiTimerExpiration(), KxInsertTimer(), and KxRemoveTreeTimer().

281 {
283 
284  /* Nothing to do on UP */
286  return NULL;
287 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:315
smooth NULL
Definition: ftsmooth.c:464
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
FORCEINLINE NTSTATUS KiCheckAlertability ( IN PKTHREAD  Thread,
IN BOOLEAN  Alertable,
IN KPROCESSOR_MODE  WaitMode 
)

Definition at line 833 of file ke_x.h.

Referenced by KeDelayExecutionThread(), KeWaitForMultipleObjects(), and KeWaitForSingleObject().

836 {
837  /* Check if the wait is alertable */
838  if (Alertable)
839  {
840  /* It is, first check if the thread is alerted in this mode */
841  if (Thread->Alerted[WaitMode])
842  {
843  /* It is, so bail out of the wait */
844  Thread->Alerted[WaitMode] = FALSE;
845  return STATUS_ALERTED;
846  }
847  else if ((WaitMode != KernelMode) &&
848  (!IsListEmpty(&Thread->ApcState.ApcListHead[UserMode])))
849  {
850  /* It's isn't, but this is a user wait with queued user APCs */
851  Thread->ApcState.UserApcPending = TRUE;
852  return STATUS_USER_APC;
853  }
854  else if (Thread->Alerted[KernelMode])
855  {
856  /* It isn't that either, but we're alered in kernel mode */
857  Thread->Alerted[KernelMode] = FALSE;
858  return STATUS_ALERTED;
859  }
860  }
861  else if ((WaitMode != KernelMode) && (Thread->ApcState.UserApcPending))
862  {
863  /* Not alertable, but this is a user wait with pending user APCs */
864  return STATUS_USER_APC;
865  }
866 
867  /* Otherwise, we're fine */
868  return STATUS_WAIT_0;
869 }
_In_ PVOID _In_ BOOLEAN Alertable
Definition: exfuncs.h:452
#define TRUE
Definition: numbers.c:17
#define STATUS_ALERTED
Definition: ntstatus.h:80
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define STATUS_WAIT_0
Definition: ntstatus.h:223
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define STATUS_USER_APC
Definition: ntstatus.h:78
#define FALSE
Definition: numbers.c:16
FORCEINLINE VOID KiCheckDeferredReadyList ( IN PKPRCB  Prcb)

Definition at line 262 of file ke_x.h.

Referenced by KiExitDispatcher().

263 {
264  /* There are no deferred ready lists on UP systems */
266 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:315
FORCEINLINE BOOLEAN KiCheckThreadStackSwap ( IN PKTHREAD  Thread,
IN KPROCESSOR_MODE  WaitMode 
)

Definition at line 795 of file ke_x.h.

797 {
798  /* Check the required conditions */
799  if ((WaitMode != KernelMode) &&
800  (Thread->EnableStackSwap) &&
801  (Thread->Priority >= (LOW_REALTIME_PRIORITY + 9)))
802  {
803  /* We are go for swap */
804  return TRUE;
805  }
806  else
807  {
808  /* Don't swap the thread */
809  return FALSE;
810  }
811 }
#define TRUE
Definition: numbers.c:17
#define LOW_REALTIME_PRIORITY
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define FALSE
Definition: numbers.c:16
FORCEINLINE BOOLEAN KiComputeDueTime ( IN PKTIMER  Timer,
IN LARGE_INTEGER  DueTime,
OUT PULONG  Hand 
)

Definition at line 943 of file ke_x.h.

Referenced by KeSetTimerEx(), and KiInsertTreeTimer().

946 {
947  LARGE_INTEGER InterruptTime, SystemTime, DifferenceTime;
948 
949  /* Convert to relative time if needed */
950  Timer->Header.Absolute = FALSE;
951  if (DueTime.HighPart >= 0)
952  {
953  /* Get System Time */
954  KeQuerySystemTime(&SystemTime);
955 
956  /* Do the conversion */
957  DifferenceTime.QuadPart = SystemTime.QuadPart - DueTime.QuadPart;
958 
959  /* Make sure it hasn't already expired */
960  Timer->Header.Absolute = TRUE;
961  if (DifferenceTime.HighPart >= 0)
962  {
963  /* Cancel everything */
964  Timer->Header.SignalState = TRUE;
965  Timer->Header.Hand = 0;
966  Timer->DueTime.QuadPart = 0;
967  *Hand = 0;
968  return FALSE;
969  }
970 
971  /* Set the time as Absolute */
972  DueTime = DifferenceTime;
973  }
974 
975  /* Get the Interrupt Time */
976  InterruptTime.QuadPart = KeQueryInterruptTime();
977 
978  /* Recalculate due time */
979  Timer->DueTime.QuadPart = InterruptTime.QuadPart - DueTime.QuadPart;
980 
981  /* Get the handle */
982  *Hand = KiComputeTimerTableIndex(Timer->DueTime.QuadPart);
983  Timer->Header.Hand = (UCHAR)*Hand;
984  Timer->Header.Inserted = TRUE;
985  return TRUE;
986 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
_In_ LARGE_INTEGER DueTime
Definition: kefuncs.h:524
#define TRUE
Definition: numbers.c:17
unsigned char UCHAR
Definition: xmlstorage.h:181
#define FALSE
Definition: numbers.c:16
ULONGLONG NTAPI KeQueryInterruptTime(VOID)
Definition: clock.c:203
FORCEINLINE ULONG KiComputeTimerTableIndex(IN ULONGLONG DueTime)
Definition: ke_x.h:873
LONGLONG QuadPart
Definition: typedefs.h:113
FORCEINLINE SCHAR KiComputeNewPriority ( IN PKTHREAD  Thread,
IN SCHAR  Adjustment 
)

Definition at line 1458 of file ke_x.h.

Referenced by KeSetBasePriorityThread(), KeSetEventBoostPriority(), KiAdjustQuantumThread(), KiDeferredReadyThread(), KiQuantumEnd(), and NtYieldExecution().

1460 {
1461  SCHAR Priority;
1462 
1463  /* Priority sanity checks */
1464  ASSERT((Thread->PriorityDecrement >= 0) &&
1465  (Thread->PriorityDecrement <= Thread->Priority));
1466  ASSERT((Thread->Priority < LOW_REALTIME_PRIORITY) ?
1467  TRUE : (Thread->PriorityDecrement == 0));
1468 
1469  /* Get the current priority */
1470  Priority = Thread->Priority;
1471  if (Priority < LOW_REALTIME_PRIORITY)
1472  {
1473  /* Decrease priority by the priority decrement */
1474  Priority -= (Thread->PriorityDecrement + Adjustment);
1475 
1476  /* Don't go out of bounds */
1477  if (Priority < Thread->BasePriority) Priority = Thread->BasePriority;
1478 
1479  /* Reset the priority decrement */
1480  Thread->PriorityDecrement = 0;
1481  }
1482 
1483  /* Sanity check */
1484  ASSERT((Thread->BasePriority == 0) || (Priority != 0));
1485 
1486  /* Return the new priority */
1487  return Priority;
1488 }
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
_In_ KPRIORITY Priority
Definition: kefuncs.h:516
#define TRUE
Definition: numbers.c:17
#define LOW_REALTIME_PRIORITY
_In_ KPRIORITY _In_ LONG Adjustment
Definition: kefuncs.h:451
signed char SCHAR
Definition: sqltypes.h:14
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
FORCEINLINE ULONG KiComputeTimerTableIndex ( IN ULONGLONG  DueTime)

Definition at line 873 of file ke_x.h.

Referenced by KeSetSystemTime(), KiComputeDueTime(), KiInsertTimerTable(), and KxSetTimerForThreadWait().

874 {
875  return (DueTime / KeMaximumIncrement) & (TIMER_TABLE_SIZE - 1);
876 }
ULONG KeMaximumIncrement
Definition: clock.c:20
_In_ LARGE_INTEGER DueTime
Definition: kefuncs.h:524
#define TIMER_TABLE_SIZE
Definition: ketypes.h:821
FORCEINLINE VOID KiInsertDeferredReadyList ( IN PKTHREAD  Thread)

Definition at line 179 of file ke_x.h.

Referenced by KiInsertQueueApc(), KiReadyThread(), KiScanReadyQueues(), and KiSetPriorityThread().

180 {
181  /* Set the thread to deferred state and boot CPU */
182  Thread->State = DeferredReady;
183  Thread->DeferredProcessor = 0;
184 
185  /* Make the thread ready immediately */
187 }
VOID FASTCALL KiDeferredReadyThread(IN PKTHREAD Thread)
Definition: thrdschd.c:79
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
FORCEINLINE PLARGE_INTEGER KiRecalculateDueTime ( IN PLARGE_INTEGER  OriginalDueTime,
IN PLARGE_INTEGER  DueTime,
IN OUT PLARGE_INTEGER  NewDueTime 
)

Definition at line 777 of file ke_x.h.

Referenced by KeDelayExecutionThread(), KeRemoveQueue(), KeWaitForMultipleObjects(), and KeWaitForSingleObject().

780 {
781  /* Don't do anything for absolute waits */
782  if (OriginalDueTime->QuadPart >= 0) return OriginalDueTime;
783 
784  /* Otherwise, query the interrupt time and recalculate */
785  NewDueTime->QuadPart = KeQueryInterruptTime();
786  NewDueTime->QuadPart -= DueTime->QuadPart;
787  return NewDueTime;
788 }
_In_ LARGE_INTEGER DueTime
Definition: kefuncs.h:524
ULONGLONG NTAPI KeQueryInterruptTime(VOID)
Definition: clock.c:203
LONGLONG QuadPart
Definition: typedefs.h:113
FORCEINLINE VOID KiReleaseApcLock ( IN PKLOCK_QUEUE_HANDLE  Handle)

Definition at line 627 of file ke_x.h.

Referenced by KeFlushQueueApc(), KeRemoveQueueApc(), KeSuspendThread(), KeTestAlertThread(), KeUnstackDetachProcess(), KeWaitForGate(), and KiDeliverApc().

628 {
629  /* Release the lock */
631 }
_In_ HANDLE Handle
Definition: extypes.h:390
VOID FASTCALL KeReleaseInStackQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:166
FORCEINLINE VOID KiReleaseApcLockFromDpcLevel ( IN PKLOCK_QUEUE_HANDLE  Handle)

Definition at line 635 of file ke_x.h.

Referenced by KeAlertResumeThread(), KeAlertThread(), KeDetachProcess(), KeForceResumeThread(), KeFreezeAllThreads(), KeInsertQueueApc(), KeResumeThread(), KeSuspendThread(), KeThawAllThreads(), KeUnstackDetachProcess(), KeWaitForGate(), and KiAttachProcess().

636 {
637  /* Release the lock */
639 }
_In_ HANDLE Handle
Definition: extypes.h:390
VOID FASTCALL KeReleaseInStackQueuedSpinLockFromDpcLevel(IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:369
FORCEINLINE VOID KiReleaseDeviceQueueLock ( IN PKLOCK_QUEUE_HANDLE  DeviceLock)

Definition at line 688 of file ke_x.h.

Referenced by KeInsertByKeyDeviceQueue(), KeInsertDeviceQueue(), KeRemoveByKeyDeviceQueue(), KeRemoveByKeyDeviceQueueIfBusy(), KeRemoveDeviceQueue(), and KeRemoveEntryDeviceQueue().

689 {
690  /* Check if we were called from a threaded DPC */
691  if (KeGetCurrentPrcb()->DpcThreadActive)
692  {
693  /* Unlock the Queue, we're not at DPC level */
694  KeReleaseInStackQueuedSpinLock(DeviceLock);
695  }
696  else
697  {
698  /* We must be at DPC level, release the lock safely */
701  }
702 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1054
VOID FASTCALL KeReleaseInStackQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:166
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
VOID FASTCALL KeReleaseInStackQueuedSpinLockFromDpcLevel(IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:369
FORCEINLINE VOID KiReleaseDispatcherObject ( IN DISPATCHER_HEADER Object)

Definition at line 137 of file ke_x.h.

Referenced by KeSignalGateBoostPriority(), KeWaitForGate(), and KiInsertQueueApc().

138 {
140 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:315
static IUnknown Object
Definition: main.c:512
FORCEINLINE VOID KiReleaseNmiListLock ( IN KIRQL  OldIrql)

Definition at line 1675 of file ke_x.h.

Referenced by KeDeregisterNmiCallback(), and KeRegisterNmiCallback().

1676 {
1678 }
KSPIN_LOCK KiNmiCallbackListLock
Definition: bug.c:33
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
FORCEINLINE VOID KiReleaseProcessLock ( IN PKLOCK_QUEUE_HANDLE  Handle)

Definition at line 652 of file ke_x.h.

Referenced by KeFreezeAllThreads(), KeQueryRuntimeProcess(), KeSetQuantumProcess(), KeStartThread(), and MmSetExecuteOptions().

653 {
654  /* Release the lock */
656 }
_In_ HANDLE Handle
Definition: extypes.h:390
VOID FASTCALL KeReleaseInStackQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:166
FORCEINLINE VOID KiReleaseProcessLockFromDpcLevel ( IN PKLOCK_QUEUE_HANDLE  Handle)

Definition at line 660 of file ke_x.h.

Referenced by KeFreezeAllThreads(), KeSetAffinityProcess(), KeSetPriorityAndQuantumProcess(), KeTerminateThread(), and KeThawAllThreads().

661 {
662  /* Release the lock */
664 }
_In_ HANDLE Handle
Definition: extypes.h:390
VOID FASTCALL KeReleaseInStackQueuedSpinLockFromDpcLevel(IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:369
FORCEINLINE VOID KiReleaseTimerLock ( IN PKSPIN_LOCK_QUEUE  LockQueue)

Definition at line 291 of file ke_x.h.

Referenced by KeSetSystemTime(), KiCompleteTimer(), KiInsertTreeTimer(), KiTimerExpiration(), KxInsertTimer(), and KxRemoveTreeTimer().

292 {
294 
295  /* Nothing to do on UP */
296  UNREFERENCED_PARAMETER(LockQueue);
297 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:315
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
FORCEINLINE VOID KiRemoveEntryTimer ( IN PKTIMER  Timer)

Definition at line 884 of file ke_x.h.

Referenced by KeSetSystemTime(), KiCompleteTimer(), KiInsertTreeTimer(), and KiTimerExpiration().

885 {
886  ULONG Hand;
888 
889  /* Remove the timer from the timer list and check if it's empty */
890  Hand = Timer->Header.Hand;
891  if (RemoveEntryList(&Timer->TimerListEntry))
892  {
893  /* Get the respective timer table entry */
894  TableEntry = &KiTimerTableListHead[Hand];
895  if (&TableEntry->Entry == TableEntry->Entry.Flink)
896  {
897  /* Set the entry to an infinite absolute time */
898  TableEntry->Time.HighPart = 0xFFFFFFFF;
899  }
900  }
901 
902  /* Clear the list entries on dbg builds so we can tell the timer is gone */
903 #if DBG
904  Timer->TimerListEntry.Flink = NULL;
905  Timer->TimerListEntry.Blink = NULL;
906 #endif
907 }
Definition: ketypes.h:661
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
smooth NULL
Definition: ftsmooth.c:464
ULARGE_INTEGER Time
Definition: ketypes.h:667
struct _LIST_ENTRY * Flink
Definition: typedefs.h:120
LIST_ENTRY Entry
Definition: ketypes.h:666
$ULONG HighPart
Definition: ntbasedef.h:569
KTIMER_TABLE_ENTRY KiTimerTableListHead[TIMER_TABLE_SIZE]
Definition: timerobj.c:17
_Must_inspect_result_ typedef _In_ ULONG TableEntry
Definition: iotypes.h:3913
unsigned int ULONG
Definition: retypes.h:1
FORCEINLINE VOID KiRequestApcInterrupt ( IN BOOLEAN  NeedApc,
IN UCHAR  Processor 
)

Definition at line 270 of file ke_x.h.

Referenced by KiInsertQueueApc().

272 {
273  /* We deliver instantly on UP */
274  UNREFERENCED_PARAMETER(NeedApc);
276 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:315
_In_ UCHAR Processor
Definition: kefuncs.h:695
FORCEINLINE VOID KiRescheduleThread ( IN BOOLEAN  NewThread,
IN ULONG  Cpu 
)

Definition at line 191 of file ke_x.h.

193 {
194  /* This is meaningless on UP systems */
195  UNREFERENCED_PARAMETER(NewThread);
197 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:315
FORCEINLINE PKTHREAD KiSelectReadyThread ( IN KPRIORITY  Priority,
IN PKPRCB  Prcb 
)

Definition at line 1408 of file ke_x.h.

Referenced by KiAdjustQuantumThread(), KiQuantumEnd(), KiSelectNextThread(), KiSetPriorityThread(), KiSwapThread(), and NtYieldExecution().

1410 {
1411  ULONG PrioritySet;
1412  LONG HighPriority;
1413  PLIST_ENTRY ListEntry;
1414  PKTHREAD Thread = NULL;
1415 
1416  /* Save the current mask and get the priority set for the CPU */
1417  PrioritySet = Prcb->ReadySummary >> Priority;
1418  if (!PrioritySet) goto Quickie;
1419 
1420  /* Get the highest priority possible */
1421  BitScanReverse((PULONG)&HighPriority, PrioritySet);
1422  ASSERT((PrioritySet & PRIORITY_MASK(HighPriority)) != 0);
1423  HighPriority += Priority;
1424 
1425  /* Make sure the list isn't empty at the highest priority */
1426  ASSERT(IsListEmpty(&Prcb->DispatcherReadyListHead[HighPriority]) == FALSE);
1427 
1428  /* Get the first thread on the list */
1429  ListEntry = Prcb->DispatcherReadyListHead[HighPriority].Flink;
1430  Thread = CONTAINING_RECORD(ListEntry, KTHREAD, WaitListEntry);
1431 
1432  /* Make sure this thread is here for a reason */
1433  ASSERT(HighPriority == Thread->Priority);
1434  ASSERT(Thread->Affinity & AFFINITY_MASK(Prcb->Number));
1435  ASSERT(Thread->NextProcessor == Prcb->Number);
1436 
1437  /* Remove it from the list */
1438  if (RemoveEntryList(&Thread->WaitListEntry))
1439  {
1440  /* The list is empty now, reset the ready summary */
1441  Prcb->ReadySummary ^= PRIORITY_MASK(HighPriority);
1442  }
1443 
1444  /* Sanity check and return the thread */
1445 Quickie:
1446  ASSERT((Thread == NULL) ||
1447  (Thread->BasePriority == 0) ||
1448  (Thread->Priority != 0));
1449  return Thread;
1450 }
#define PRIORITY_MASK(Id)
Definition: ke.h:149
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
_In_ KPRIORITY Priority
Definition: kefuncs.h:516
SCHAR Priority
Definition: ketypes.h:974
#define AFFINITY_MASK(Id)
Definition: ke.h:148
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:464
SCHAR BasePriority
Definition: ketypes.h:1209
struct _LIST_ENTRY * Flink
Definition: typedefs.h:120
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
LIST_ENTRY WaitListEntry
Definition: ketypes.h:1041
#define BitScanReverse
Definition: interlocked.h:6
Definition: typedefs.h:118
volatile ULONG NextProcessor
Definition: ketypes.h:977
unsigned int * PULONG
Definition: retypes.h:1
#define FALSE
Definition: numbers.c:16
GROUP_AFFINITY Affinity
Definition: ketypes.h:1233
unsigned int ULONG
Definition: retypes.h:1
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
FORCEINLINE VOID KiSetThreadSwapBusy ( IN PKTHREAD  Thread)

Definition at line 204 of file ke_x.h.

Referenced by KeDelayExecutionThread(), KeRemoveQueue(), KeTerminateThread(), KeWaitForGate(), KeWaitForMultipleObjects(), KeWaitForSingleObject(), KiExitDispatcher(), KiQuantumEnd(), and NtYieldExecution().

205 {
207 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:315
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
FORCEINLINE BOOLEAN KiTryThreadLock ( IN PKTHREAD  Thread)

Definition at line 254 of file ke_x.h.

Referenced by KeSignalGateBoostPriority().

255 {
257  return FALSE;
258 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:315
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define FALSE
Definition: numbers.c:16
FORCEINLINE VOID KxInsertTimer ( IN PKTIMER  Timer,
IN ULONG  Hand 
)

Definition at line 915 of file ke_x.h.

Referenced by KeDelayExecutionThread(), KeRemoveQueue(), KeSetTimerEx(), KeWaitForMultipleObjects(), and KeWaitForSingleObject().

917 {
918  PKSPIN_LOCK_QUEUE LockQueue;
919 
920  /* Acquire the lock and release the dispatcher lock */
921  LockQueue = KiAcquireTimerLock(Hand);
923 
924  /* Try to insert the timer */
925  if (KiInsertTimerTable(Timer, Hand))
926  {
927  /* Complete it */
928  KiCompleteTimer(Timer, LockQueue);
929  }
930  else
931  {
932  /* Do nothing, just release the lock */
933  KiReleaseTimerLock(LockQueue);
934  }
935 }
FORCEINLINE PKSPIN_LOCK_QUEUE KiAcquireTimerLock(IN ULONG Hand)
Definition: ke_x.h:280
BOOLEAN FASTCALL KiInsertTimerTable(IN PKTIMER Timer, IN ULONG Hand)
Definition: timerobj.c:63
VOID FASTCALL KiCompleteTimer(IN PKTIMER Timer, IN PKSPIN_LOCK_QUEUE LockQueue)
Definition: timerobj.c:167
FORCEINLINE VOID KiReleaseDispatcherLockFromDpcLevel(VOID)
Definition: ke_x.h:168
FORCEINLINE VOID KiReleaseTimerLock(IN PKSPIN_LOCK_QUEUE LockQueue)
Definition: ke_x.h:291
FORCEINLINE VOID KxQueueReadyThread ( IN PKTHREAD  Thread,
IN PKPRCB  Prcb 
)

Definition at line 1343 of file ke_x.h.

Referenced by KiDispatchInterrupt(), KiDpcInterruptHandler(), KiExitDispatcher(), KiQuantumEnd(), KiQueueReadyThread(), and NtYieldExecution().

1345 {
1346  BOOLEAN Preempted;
1348 
1349  /* Sanity checks */
1350  ASSERT(Prcb == KeGetCurrentPrcb());
1351  ASSERT(Thread->State == Running);
1352  ASSERT(Thread->NextProcessor == Prcb->Number);
1353 
1354  /* Check if this thread is allowed to run in this CPU */
1355 #ifdef CONFIG_SMP
1356  if ((Thread->Affinity) & (Prcb->SetMember))
1357 #else
1358  if (TRUE)
1359 #endif
1360  {
1361  /* Set thread ready for execution */
1362  Thread->State = Ready;
1363 
1364  /* Save current priority and if someone had pre-empted it */
1365  Priority = Thread->Priority;
1366  Preempted = Thread->Preempted;
1367 
1368  /* We're not pre-empting now, and set the wait time */
1369  Thread->Preempted = FALSE;
1370  Thread->WaitTime = KeTickCount.LowPart;
1371 
1372  /* Sanity check */
1373  ASSERT((Priority >= 0) && (Priority <= HIGH_PRIORITY));
1374 
1375  /* Insert this thread in the appropriate order */
1376  Preempted ? InsertHeadList(&Prcb->DispatcherReadyListHead[Priority],
1377  &Thread->WaitListEntry) :
1378  InsertTailList(&Prcb->DispatcherReadyListHead[Priority],
1379  &Thread->WaitListEntry);
1380 
1381  /* Update the ready summary */
1382  Prcb->ReadySummary |= PRIORITY_MASK(Priority);
1383 
1384  /* Sanity check */
1385  ASSERT(Priority == Thread->Priority);
1386 
1387  /* Release the PRCB lock */
1388  KiReleasePrcbLock(Prcb);
1389  }
1390  else
1391  {
1392  /* Otherwise, prepare this thread to be deferred */
1393  Thread->State = DeferredReady;
1394  Thread->DeferredProcessor = Prcb->Number;
1395 
1396  /* Release the lock and defer scheduling */
1397  KiReleasePrcbLock(Prcb);
1399  }
1400 }
ULONG LowPart
Definition: ketypes.h:895
#define PRIORITY_MASK(Id)
Definition: ke.h:149
FORCEINLINE VOID KiReleasePrcbLock(IN PKPRCB Prcb)
Definition: ke_x.h:224
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1054
_In_ KPRIORITY Priority
Definition: kefuncs.h:516
#define TRUE
Definition: numbers.c:17
VOID FASTCALL KiDeferredReadyThread(IN PKTHREAD Thread)
Definition: thrdschd.c:79
#define InsertTailList(ListHead, Entry)
LONG KPRIORITY
Definition: compat.h:454
unsigned char BOOLEAN
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
NTKERNELAPI volatile KSYSTEM_TIME KeTickCount
Definition: clock.c:19
Definition: ketypes.h:370
#define FALSE
Definition: numbers.c:16
#define HIGH_PRIORITY
FORCEINLINE VOID KxRemoveTreeTimer ( IN PKTIMER  Timer)

Definition at line 995 of file ke_x.h.

Referenced by KeCancelTimer(), KeSetTimerEx(), KiInsertQueue(), and KiUnlinkThread().

996 {
997  ULONG Hand = Timer->Header.Hand;
998  PKSPIN_LOCK_QUEUE LockQueue;
999  PKTIMER_TABLE_ENTRY TimerEntry;
1000 
1001  /* Acquire timer lock */
1002  LockQueue = KiAcquireTimerLock(Hand);
1003 
1004  /* Set the timer as non-inserted */
1005  Timer->Header.Inserted = FALSE;
1006 
1007  /* Remove it from the timer list */
1008  if (RemoveEntryList(&Timer->TimerListEntry))
1009  {
1010  /* Get the entry and check if it's empty */
1011  TimerEntry = &KiTimerTableListHead[Hand];
1012  if (IsListEmpty(&TimerEntry->Entry))
1013  {
1014  /* Clear the time then */
1015  TimerEntry->Time.HighPart = 0xFFFFFFFF;
1016  }
1017  }
1018 
1019  /* Release the timer lock */
1020  KiReleaseTimerLock(LockQueue);
1021 }
FORCEINLINE PKSPIN_LOCK_QUEUE KiAcquireTimerLock(IN ULONG Hand)
Definition: ke_x.h:280
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
Definition: ketypes.h:661
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
ULARGE_INTEGER Time
Definition: ketypes.h:667
LIST_ENTRY Entry
Definition: ketypes.h:666
$ULONG HighPart
Definition: ntbasedef.h:569
KTIMER_TABLE_ENTRY KiTimerTableListHead[TIMER_TABLE_SIZE]
Definition: timerobj.c:17
#define FALSE
Definition: numbers.c:16
unsigned int ULONG
Definition: retypes.h:1
FORCEINLINE VOID KiReleaseTimerLock(IN PKSPIN_LOCK_QUEUE LockQueue)
Definition: ke_x.h:291
FORCEINLINE VOID KxSetTimerForThreadWait ( IN PKTIMER  Timer,
IN LARGE_INTEGER  Interval,
OUT PULONG  Hand 
)

Definition at line 1025 of file ke_x.h.

1028 {
1030  LARGE_INTEGER InterruptTime, SystemTime, TimeDifference;
1031 
1032  /* Check the timer's interval to see if it's absolute */
1033  Timer->Header.Absolute = FALSE;
1034  if (Interval.HighPart >= 0)
1035  {
1036  /* Get the system time and calculate the relative time */
1037  KeQuerySystemTime(&SystemTime);
1038  TimeDifference.QuadPart = SystemTime.QuadPart - Interval.QuadPart;
1039  Timer->Header.Absolute = TRUE;
1040 
1041  /* Check if we've already expired */
1042  if (TimeDifference.HighPart >= 0)
1043  {
1044  /* Reset everything */
1045  Timer->DueTime.QuadPart = 0;
1046  *Hand = 0;
1047  Timer->Header.Hand = 0;
1048  return;
1049  }
1050  else
1051  {
1052  /* Update the interval */
1053  Interval = TimeDifference;
1054  }
1055  }
1056 
1057  /* Calculate the due time */
1058  InterruptTime.QuadPart = KeQueryInterruptTime();
1059  DueTime = InterruptTime.QuadPart - Interval.QuadPart;
1060  Timer->DueTime.QuadPart = DueTime;
1061 
1062  /* Calculate the timer handle */
1063  *Hand = KiComputeTimerTableIndex(DueTime);
1064  Timer->Header.Hand = (UCHAR)*Hand;
1065 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
_In_ LARGE_INTEGER DueTime
Definition: kefuncs.h:524
#define TRUE
Definition: numbers.c:17
DWORD Interval
Definition: netstat.c:30
uint64_t ULONGLONG
Definition: typedefs.h:66
unsigned char UCHAR
Definition: xmlstorage.h:181
#define FALSE
Definition: numbers.c:16
ULONGLONG NTAPI KeQueryInterruptTime(VOID)
Definition: clock.c:203
FORCEINLINE ULONG KiComputeTimerTableIndex(IN ULONGLONG DueTime)
Definition: ke_x.h:873
LONGLONG QuadPart
Definition: typedefs.h:113
FORCEINLINE VOID KxUnwaitThread ( IN DISPATCHER_HEADER Object,
IN KPRIORITY  Increment 
)

Definition at line 1250 of file ke_x.h.

Referenced by KeSetEvent(), KeSetProcess(), KeTerminateThread(), KiSignalTimer(), KiTimerExpiration(), and KiTimerListExpire().

1252 {
1253  PLIST_ENTRY WaitEntry, WaitList;
1254  PKWAIT_BLOCK WaitBlock;
1255  PKTHREAD WaitThread;
1256  ULONG WaitKey;
1257 
1258  /* Loop the Wait Entries */
1259  WaitList = &Object->WaitListHead;
1260  ASSERT(IsListEmpty(&Object->WaitListHead) == FALSE);
1261  WaitEntry = WaitList->Flink;
1262  do
1263  {
1264  /* Get the current wait block */
1265  WaitBlock = CONTAINING_RECORD(WaitEntry, KWAIT_BLOCK, WaitListEntry);
1266 
1267  /* Get the waiting thread */
1268  WaitThread = WaitBlock->Thread;
1269 
1270  /* Check the current Wait Mode */
1271  if (WaitBlock->WaitType == WaitAny)
1272  {
1273  /* Use the actual wait key */
1274  WaitKey = WaitBlock->WaitKey;
1275  }
1276  else
1277  {
1278  /* Otherwise, use STATUS_KERNEL_APC */
1279  WaitKey = STATUS_KERNEL_APC;
1280  }
1281 
1282  /* Unwait the thread */
1283  KiUnwaitThread(WaitThread, WaitKey, Increment);
1284 
1285  /* Next entry */
1286  WaitEntry = WaitList->Flink;
1287  } while (WaitEntry != WaitList);
1288 }
VOID FASTCALL KiUnwaitThread(IN PKTHREAD Thread, IN LONG_PTR WaitStatus, IN KPRIORITY Increment)
Definition: wait.c:89
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
struct _KTHREAD * Thread
Definition: ketypes.h:445
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define STATUS_KERNEL_APC
Definition: ntstatus.h:79
struct _LIST_ENTRY * Flink
Definition: typedefs.h:120
UCHAR WaitType
Definition: ketypes.h:449
USHORT WaitKey
Definition: ketypes.h:448
static IUnknown Object
Definition: main.c:512
Definition: typedefs.h:118
#define FALSE
Definition: numbers.c:16
unsigned int ULONG
Definition: retypes.h:1
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG Increment
Definition: CrNtStubs.h:42
FORCEINLINE VOID KxUnwaitThreadForEvent ( IN PKEVENT  Event,
IN KPRIORITY  Increment 
)

Definition at line 1295 of file ke_x.h.

Referenced by KeSetEvent(), KeSetEventBoostPriority(), KiSignalTimer(), KiTimerExpiration(), and KiTimerListExpire().

1297 {
1298  PLIST_ENTRY WaitEntry, WaitList;
1299  PKWAIT_BLOCK WaitBlock;
1300  PKTHREAD WaitThread;
1301 
1302  /* Loop the Wait Entries */
1303  WaitList = &Event->Header.WaitListHead;
1304  ASSERT(IsListEmpty(&Event->Header.WaitListHead) == FALSE);
1305  WaitEntry = WaitList->Flink;
1306  do
1307  {
1308  /* Get the current wait block */
1309  WaitBlock = CONTAINING_RECORD(WaitEntry, KWAIT_BLOCK, WaitListEntry);
1310 
1311  /* Get the waiting thread */
1312  WaitThread = WaitBlock->Thread;
1313 
1314  /* Check the current Wait Mode */
1315  if (WaitBlock->WaitType == WaitAny)
1316  {
1317  /* Un-signal it */
1318  Event->Header.SignalState = 0;
1319 
1320  /* Un-signal the event and unwait the thread */
1321  KiUnwaitThread(WaitThread, WaitBlock->WaitKey, Increment);
1322  break;
1323  }
1324 
1325  /* Unwait the thread with STATUS_KERNEL_APC */
1327 
1328  /* Next entry */
1329  WaitEntry = WaitList->Flink;
1330  } while (WaitEntry != WaitList);
1331 }
VOID FASTCALL KiUnwaitThread(IN PKTHREAD Thread, IN LONG_PTR WaitStatus, IN KPRIORITY Increment)
Definition: wait.c:89
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
struct _KTHREAD * Thread
Definition: ketypes.h:445
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define STATUS_KERNEL_APC
Definition: ntstatus.h:79
struct _LIST_ENTRY * Flink
Definition: typedefs.h:120
UCHAR WaitType
Definition: ketypes.h:449
USHORT WaitKey
Definition: ketypes.h:448
Definition: typedefs.h:118
#define FALSE
Definition: numbers.c:16
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG Increment
Definition: CrNtStubs.h:42