ReactOS  0.4.15-dev-3324-gda4e15f
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 KiAcquireDispatcherLockAtSynchLevel (VOID)
 
FORCEINLINE VOID KiReleaseDispatcherLockFromSynchLevel (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 KiAcquireApcLockRaiseToSynch (IN PKTHREAD Thread, IN PKLOCK_QUEUE_HANDLE Handle)
 
FORCEINLINE VOID KiAcquireApcLockAtSynchLevel (IN PKTHREAD Thread, IN PKLOCK_QUEUE_HANDLE Handle)
 
FORCEINLINE VOID KiAcquireApcLockRaiseToDpc (IN PKTHREAD Thread, IN PKLOCK_QUEUE_HANDLE Handle)
 
FORCEINLINE VOID KiReleaseApcLock (IN PKLOCK_QUEUE_HANDLE Handle)
 
FORCEINLINE VOID KiReleaseApcLockFromSynchLevel (IN PKLOCK_QUEUE_HANDLE Handle)
 
FORCEINLINE VOID KiAcquireProcessLockRaiseToSynch (IN PKPROCESS Process, IN PKLOCK_QUEUE_HANDLE Handle)
 
FORCEINLINE VOID KiReleaseProcessLock (IN PKLOCK_QUEUE_HANDLE Handle)
 
FORCEINLINE VOID KiReleaseProcessLockFromSynchLevel (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)
 
 _Requires_lock_held_ (Prcb->PrcbLock) _Releases_lock_(Prcb -> PrcbLock) 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

◆ KeEnterCriticalRegion

#define KeEnterCriticalRegion ( )
Value:
{ \
PKTHREAD _Thread = KeGetCurrentThread(); \
KeEnterCriticalRegionThread(_Thread); \
}
#define KeGetCurrentThread
Definition: hal.h:55

Definition at line 88 of file ke_x.h.

◆ KeEnterCriticalRegionThread

#define KeEnterCriticalRegionThread (   _Thread)
Value:
{ \
/* Sanity checks */ \
ASSERT(_Thread == KeGetCurrentThread()); \
ASSERT((_Thread->KernelApcDisable <= 0) && \
(_Thread->KernelApcDisable != -32768)); \
\
/* Disable Kernel APCs */ \
_Thread->KernelApcDisable--; \
}
#define KeGetCurrentThread
Definition: hal.h:55

Definition at line 77 of file ke_x.h.

◆ KeEnterGuardedRegion

#define KeEnterGuardedRegion ( )
Value:
{ \
PKTHREAD _Thread = KeGetCurrentThread(); \
KeEnterGuardedRegionThread(_Thread); \
}
#define KeGetCurrentThread
Definition: hal.h:55

Definition at line 39 of file ke_x.h.

◆ KeEnterGuardedRegionThread

#define KeEnterGuardedRegionThread (   _Thread)
Value:
{ \
/* Sanity checks */ \
ASSERT(KeGetCurrentIrql() <= APC_LEVEL); \
ASSERT(_Thread == KeGetCurrentThread()); \
ASSERT((_Thread->SpecialApcDisable <= 0) && \
(_Thread->SpecialApcDisable != -32768)); \
\
/* Disable Special APCs */ \
_Thread->SpecialApcDisable--; \
}
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define KeGetCurrentThread
Definition: hal.h:55
#define APC_LEVEL
Definition: env_spec_w32.h:695

Definition at line 27 of file ke_x.h.

◆ KeLeaveCriticalRegion

#define KeLeaveCriticalRegion ( )
Value:
{ \
PKTHREAD _Thread = KeGetCurrentThread(); \
KeLeaveCriticalRegionThread(_Thread); \
}
#define KeGetCurrentThread
Definition: hal.h:55

Definition at line 119 of file ke_x.h.

◆ KeLeaveCriticalRegionThread

#define KeLeaveCriticalRegionThread (   _Thread)
Value:
{ \
/* Sanity checks */ \
ASSERT(_Thread == KeGetCurrentThread()); \
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 */ \
KiCheckForKernelApcDelivery(); \
} \
} \
}
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define KeGetCurrentThread
Definition: hal.h:55

Definition at line 97 of file ke_x.h.

◆ KeLeaveGuardedRegion

#define KeLeaveGuardedRegion ( )
Value:
{ \
PKTHREAD _Thread = KeGetCurrentThread(); \
KeLeaveGuardedRegionThread(_Thread); \
}
#define KeGetCurrentThread
Definition: hal.h:55

Definition at line 68 of file ke_x.h.

◆ KeLeaveGuardedRegionThread

#define KeLeaveGuardedRegionThread (   _Thread)
Value:
{ \
/* Sanity checks */ \
ASSERT(KeGetCurrentIrql() <= APC_LEVEL); \
ASSERT(_Thread == KeGetCurrentThread()); \
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 */ \
KiCheckForKernelApcDelivery(); \
} \
} \
}
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define KeGetCurrentThread
Definition: hal.h:55
#define APC_LEVEL
Definition: env_spec_w32.h:695

Definition at line 48 of file ke_x.h.

◆ KiAddThreadToWaitList

#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:1079
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2652

Definition at line 824 of file ke_x.h.

◆ KiSatisfyMutantWait

#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 */ \
if ((Object)->Abandoned) \
{ \
/* Unabandon it */ \
\
/* Return Status */ \
Thread->WaitStatus = STATUS_ABANDONED; \
} \
\
/* Insert it into the Mutant List */ \
InsertHeadList(Thread->MutantListHead.Blink, \
&(Object)->MutantListEntry); \
} \
}
if(dx==0 &&dy==0)
Definition: linetemp.h:174
#define FALSE
Definition: types.h:117
Definition: Header.h:8
_In_ KPRIORITY _In_ BOOLEAN Abandoned
Definition: kefuncs.h:593
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2652
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
#define STATUS_ABANDONED
Definition: ntstatus.h:75

Definition at line 715 of file ke_x.h.

◆ KiSatisfyNonMutantWait

#define KiSatisfyNonMutantWait (   Object)
Value:
{ \
if (((Object)->Header.Type & TIMER_OR_EVENT_TYPE) == \
{ \
/* 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
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
#define TIMER_OR_EVENT_TYPE
Definition: ke.h:163

Definition at line 749 of file ke_x.h.

◆ KiSatisfyObjectWait

#define KiSatisfyObjectWait (   Object,
  Thread 
)
Value:
{ \
/* Special case for Mutants */ \
if ((Object)->Header.Type == MutantObject) \
{ \
KiSatisfyMutantWait((Object), (Thread)); \
} \
else \
{ \
KiSatisfyNonMutantWait(Object); \
} \
}
Definition: Header.h:8
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2652
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object

Definition at line 767 of file ke_x.h.

◆ KxDelayThreadWait

#define KxDelayThreadWait ( )
Value:
\
/* Setup the Wait Block */ \
Thread->WaitBlockList = TimerBlock; \
\
/* Setup the timer */ \
KxSetTimerForThreadWait(Timer, *Interval, &Hand); \
\
/* 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 */ \
Thread->WaitTime = KeTickCount.LowPart;
FORCEINLINE BOOLEAN KiCheckThreadStackSwap(IN PKTHREAD Thread, IN KPROCESSOR_MODE WaitMode)
Definition: ke_x.h:803
ULONG LowPart
Definition: ketypes.h:917
_In_ PVOID _In_ BOOLEAN Alertable
Definition: exfuncs.h:452
DWORD Interval
Definition: netstat.c:33
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2652
NTKERNELAPI volatile KSYSTEM_TIME KeTickCount
Definition: clock.c:19
#define NULL
Definition: types.h:112
#define STATUS_SUCCESS
Definition: shellext.h:65

Definition at line 1076 of file ke_x.h.

◆ KxMultiThreadWait

#define KxMultiThreadWait ( )

Definition at line 1107 of file ke_x.h.

◆ KxQueueThreadWait

#define KxQueueThreadWait ( )

Definition at line 1208 of file ke_x.h.

◆ KxSingleThreadWait

#define KxSingleThreadWait ( )

Definition at line 1163 of file ke_x.h.

Function Documentation

◆ _KeAcquireGuardedMutex()

FORCEINLINE VOID _KeAcquireGuardedMutex ( IN PKGUARDED_MUTEX  GuardedMutex)

Definition at line 1584 of file ke_x.h.

1585 {
1587 
1588  /* Sanity checks */
1590  ASSERT(GuardedMutex->Owner != Thread);
1591 
1592  /* Disable Special APCs */
1594 
1595  /* Remove the lock */
1596  if (!InterlockedBitTestAndReset(&GuardedMutex->Count, GM_LOCK_BIT_V))
1597  {
1598  /* The Guarded Mutex was already locked, enter contented case */
1599  KiAcquireGuardedMutex(GuardedMutex);
1600  }
1601 
1602  /* Set the Owner and Special APC Disable state */
1603  GuardedMutex->Owner = Thread;
1604  GuardedMutex->SpecialApcDisable = Thread->SpecialApcDisable;
1605 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define InterlockedBitTestAndReset
Definition: interlocked.h:35
#define ASSERT(a)
Definition: mode.c:44
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2652
#define KeEnterGuardedRegionThread(_Thread)
Definition: ke_x.h:27
VOID FASTCALL KiAcquireGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: wait.c:122
#define KeGetCurrentThread
Definition: hal.h:55
#define GM_LOCK_BIT_V
#define APC_LEVEL
Definition: env_spec_w32.h:695

Referenced by KeAcquireGuardedMutex().

◆ _KeAcquireGuardedMutexUnsafe()

FORCEINLINE VOID _KeAcquireGuardedMutexUnsafe ( IN OUT PKGUARDED_MUTEX  GuardedMutex)

Definition at line 1519 of file ke_x.h.

1520 {
1522 
1523  /* Sanity checks */
1525  (Thread->SpecialApcDisable < 0) ||
1526  (Thread->Teb == NULL) ||
1527  (Thread->Teb >= (PTEB)MM_SYSTEM_RANGE_START));
1528  ASSERT(GuardedMutex->Owner != Thread);
1529 
1530  /* Remove the lock */
1531  if (!InterlockedBitTestAndReset(&GuardedMutex->Count, GM_LOCK_BIT_V))
1532  {
1533  /* The Guarded Mutex was already locked, enter contented case */
1534  KiAcquireGuardedMutex(GuardedMutex);
1535  }
1536 
1537  /* Set the Owner */
1538  GuardedMutex->Owner = Thread;
1539 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define InterlockedBitTestAndReset
Definition: interlocked.h:35
#define ASSERT(a)
Definition: mode.c:44
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2652
#define MM_SYSTEM_RANGE_START
Definition: armddk.h:18
Definition: compat.h:694
VOID FASTCALL KiAcquireGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: wait.c:122
#define NULL
Definition: types.h:112
#define KeGetCurrentThread
Definition: hal.h:55
#define GM_LOCK_BIT_V
#define APC_LEVEL
Definition: env_spec_w32.h:695

Referenced by KeAcquireGuardedMutexUnsafe().

◆ _KeInitializeGuardedMutex()

FORCEINLINE VOID _KeInitializeGuardedMutex ( OUT PKGUARDED_MUTEX  GuardedMutex)

Definition at line 1506 of file ke_x.h.

1507 {
1508  /* Setup the Initial Data */
1509  GuardedMutex->Count = GM_LOCK_BIT;
1510  GuardedMutex->Owner = NULL;
1511  GuardedMutex->Contention = 0;
1512 
1513  /* Initialize the Wait Gate */
1514  KeInitializeGate(&GuardedMutex->Gate);
1515 }
#define GM_LOCK_BIT
#define NULL
Definition: types.h:112
VOID FASTCALL KeInitializeGate(PKGATE Gate)

Referenced by KeInitializeGuardedMutex().

◆ _KeReleaseGuardedMutex()

FORCEINLINE VOID _KeReleaseGuardedMutex ( IN OUT PKGUARDED_MUTEX  GuardedMutex)

Definition at line 1609 of file ke_x.h.

1610 {
1612  LONG OldValue, NewValue;
1613 
1614  /* Sanity checks */
1616  ASSERT(GuardedMutex->Owner == Thread);
1617  ASSERT(Thread->SpecialApcDisable == GuardedMutex->SpecialApcDisable);
1618 
1619  /* Destroy the Owner */
1620  GuardedMutex->Owner = NULL;
1621 
1622  /* Add the Lock Bit */
1623  OldValue = InterlockedExchangeAdd(&GuardedMutex->Count, GM_LOCK_BIT);
1624  ASSERT((OldValue & GM_LOCK_BIT) == 0);
1625 
1626  /* Check if it was already locked, but not woken */
1627  if ((OldValue) && !(OldValue & GM_LOCK_WAITER_WOKEN))
1628  {
1629  /* Update the Oldvalue to what it should be now */
1630  OldValue += GM_LOCK_BIT;
1631 
1632  /* The mutex will be woken, minus one waiter */
1633  NewValue = OldValue + GM_LOCK_WAITER_WOKEN -
1635 
1636  /* Remove the Woken bit */
1637  if (InterlockedCompareExchange(&GuardedMutex->Count,
1638  NewValue,
1639  OldValue) == OldValue)
1640  {
1641  /* Signal the Gate */
1642  KeSignalGateBoostPriority(&GuardedMutex->Gate);
1643  }
1644  }
1645 
1646  /* Re-enable APCs */
1648 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define InterlockedCompareExchange
Definition: interlocked.h:104
#define GM_LOCK_BIT
long LONG
Definition: pedump.c:60
#define GM_LOCK_WAITER_INC
#define InterlockedExchangeAdd
Definition: interlocked.h:181
#define ASSERT(a)
Definition: mode.c:44
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2652
VOID FASTCALL KeSignalGateBoostPriority(PKGATE Gate)
#define NULL
Definition: types.h:112
#define KeLeaveGuardedRegionThread(_Thread)
Definition: ke_x.h:48
#define KeGetCurrentThread
Definition: hal.h:55
#define APC_LEVEL
Definition: env_spec_w32.h:695
#define GM_LOCK_WAITER_WOKEN

Referenced by KeReleaseGuardedMutex().

◆ _KeReleaseGuardedMutexUnsafe()

FORCEINLINE VOID _KeReleaseGuardedMutexUnsafe ( IN OUT PKGUARDED_MUTEX  GuardedMutex)

Definition at line 1543 of file ke_x.h.

1544 {
1545  LONG OldValue, NewValue;
1546 
1547  /* Sanity checks */
1549  (KeGetCurrentThread()->SpecialApcDisable < 0) ||
1550  (KeGetCurrentThread()->Teb == NULL) ||
1552  ASSERT(GuardedMutex->Owner == KeGetCurrentThread());
1553 
1554  /* Destroy the Owner */
1555  GuardedMutex->Owner = NULL;
1556 
1557  /* Add the Lock Bit */
1558  OldValue = InterlockedExchangeAdd(&GuardedMutex->Count, GM_LOCK_BIT);
1559  ASSERT((OldValue & GM_LOCK_BIT) == 0);
1560 
1561  /* Check if it was already locked, but not woken */
1562  if ((OldValue) && !(OldValue & GM_LOCK_WAITER_WOKEN))
1563  {
1564  /* Update the Oldvalue to what it should be now */
1565  OldValue += GM_LOCK_BIT;
1566 
1567  /* The mutex will be woken, minus one waiter */
1568  NewValue = OldValue + GM_LOCK_WAITER_WOKEN -
1570 
1571  /* Remove the Woken bit */
1572  if (InterlockedCompareExchange(&GuardedMutex->Count,
1573  NewValue,
1574  OldValue) == OldValue)
1575  {
1576  /* Signal the Gate */
1577  KeSignalGateBoostPriority(&GuardedMutex->Gate);
1578  }
1579  }
1580 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define InterlockedCompareExchange
Definition: interlocked.h:104
#define GM_LOCK_BIT
long LONG
Definition: pedump.c:60
#define GM_LOCK_WAITER_INC
#define InterlockedExchangeAdd
Definition: interlocked.h:181
#define ASSERT(a)
Definition: mode.c:44
#define MM_SYSTEM_RANGE_START
Definition: armddk.h:18
Definition: compat.h:694
VOID FASTCALL KeSignalGateBoostPriority(PKGATE Gate)
#define NULL
Definition: types.h:112
#define KeGetCurrentThread
Definition: hal.h:55
#define APC_LEVEL
Definition: env_spec_w32.h:695
#define GM_LOCK_WAITER_WOKEN

Referenced by KeReleaseGuardedMutexUnsafe().

◆ _KeTryToAcquireGuardedMutex()

FORCEINLINE BOOLEAN _KeTryToAcquireGuardedMutex ( IN OUT PKGUARDED_MUTEX  GuardedMutex)

Definition at line 1652 of file ke_x.h.

1653 {
1655 
1656  /* Block APCs */
1658 
1659  /* Remove the lock */
1660  if (!InterlockedBitTestAndReset(&GuardedMutex->Count, GM_LOCK_BIT_V))
1661  {
1662  /* Re-enable APCs */
1664  YieldProcessor();
1665 
1666  /* Return failure */
1667  return FALSE;
1668  }
1669 
1670  /* Set the Owner and APC State */
1671  GuardedMutex->Owner = Thread;
1672  GuardedMutex->SpecialApcDisable = Thread->SpecialApcDisable;
1673  return TRUE;
1674 }
#define TRUE
Definition: types.h:120
FORCEINLINE VOID YieldProcessor(VOID)
Definition: ke.h:32
#define FALSE
Definition: types.h:117
#define InterlockedBitTestAndReset
Definition: interlocked.h:35
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2652
#define KeEnterGuardedRegionThread(_Thread)
Definition: ke_x.h:27
#define KeLeaveGuardedRegionThread(_Thread)
Definition: ke_x.h:48
#define KeGetCurrentThread
Definition: hal.h:55
#define GM_LOCK_BIT_V

Referenced by KeTryToAcquireGuardedMutex().

◆ _Requires_lock_held_()

_Requires_lock_held_ ( Prcb->  PrcbLock) -> PrcbLock) FORCEINLINE VOID KxQueueReadyThread(IN PKTHREAD Thread, IN PKPRCB Prcb)

Definition at line 1350 of file ke_x.h.

1356 {
1357  BOOLEAN Preempted;
1359 
1360  /* Sanity checks */
1361  ASSERT(Prcb == KeGetCurrentPrcb());
1362  ASSERT(Thread->State == Running);
1363  ASSERT(Thread->NextProcessor == Prcb->Number);
1364 
1365  /* Check if this thread is allowed to run in this CPU */
1366 #ifdef CONFIG_SMP
1367  if ((Thread->Affinity) & (Prcb->SetMember))
1368 #else
1369  if (TRUE)
1370 #endif
1371  {
1372  /* Set thread ready for execution */
1373  Thread->State = Ready;
1374 
1375  /* Save current priority and if someone had pre-empted it */
1376  Priority = Thread->Priority;
1377  Preempted = Thread->Preempted;
1378 
1379  /* We're not pre-empting now, and set the wait time */
1380  Thread->Preempted = FALSE;
1381  Thread->WaitTime = KeTickCount.LowPart;
1382 
1383  /* Sanity check */
1384  ASSERT((Priority >= 0) && (Priority <= HIGH_PRIORITY));
1385 
1386  /* Insert this thread in the appropriate order */
1387  Preempted ? InsertHeadList(&Prcb->DispatcherReadyListHead[Priority],
1388  &Thread->WaitListEntry) :
1389  InsertTailList(&Prcb->DispatcherReadyListHead[Priority],
1390  &Thread->WaitListEntry);
1391 
1392  /* Update the ready summary */
1393  Prcb->ReadySummary |= PRIORITY_MASK(Priority);
1394 
1395  /* Sanity check */
1396  ASSERT(Priority == Thread->Priority);
1397 
1398  /* Release the PRCB lock */
1399  KiReleasePrcbLock(Prcb);
1400  }
1401  else
1402  {
1403  /* Otherwise, prepare this thread to be deferred */
1404  Thread->State = DeferredReady;
1405  Thread->DeferredProcessor = Prcb->Number;
1406 
1407  /* Release the lock and defer scheduling */
1408  KiReleasePrcbLock(Prcb);
1410  }
1411 }
ULONG LowPart
Definition: ketypes.h:917
#define PRIORITY_MASK(Id)
Definition: ke.h:160
FORCEINLINE VOID KiReleasePrcbLock(IN PKPRCB Prcb)
Definition: ke_x.h:230
#define TRUE
Definition: types.h:120
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:1079
VOID FASTCALL KiDeferredReadyThread(IN PKTHREAD Thread)
Definition: thrdschd.c:79
#define InsertTailList(ListHead, Entry)
LONG KPRIORITY
Definition: compat.h:662
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
#define HIGH_PRIORITY
#define ASSERT(a)
Definition: mode.c:44
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2652
_In_ WDFINTERRUPT _In_ WDF_INTERRUPT_POLICY _In_ WDF_INTERRUPT_PRIORITY Priority
Definition: wdfinterrupt.h:651
NTKERNELAPI volatile KSYSTEM_TIME KeTickCount
Definition: clock.c:19
Definition: ketypes.h:412

◆ KeGetPreviousMode()

FORCEINLINE KPROCESSOR_MODE KeGetPreviousMode ( VOID  )

Definition at line 17 of file ke_x.h.

18 {
19  /* Return the current mode */
20  return KeGetCurrentThread()->PreviousMode;
21 }
#define KeGetCurrentThread
Definition: hal.h:55

◆ KiAcquireApcLockAtSynchLevel()

FORCEINLINE VOID KiAcquireApcLockAtSynchLevel ( IN PKTHREAD  Thread,
IN PKLOCK_QUEUE_HANDLE  Handle 
)

Definition at line 616 of file ke_x.h.

618 {
619  /* Acquire the lock */
622 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
VOID FASTCALL KeAcquireInStackQueuedSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock, IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:363
#define ASSERT(a)
Definition: mode.c:44
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2652
#define SYNCH_LEVEL
Definition: env_spec_w32.h:704
_In_ HANDLE Handle
Definition: extypes.h:390

Referenced by KeFreezeAllThreads(), and KeThawAllThreads().

◆ KiAcquireApcLockRaiseToDpc()

FORCEINLINE VOID KiAcquireApcLockRaiseToDpc ( IN PKTHREAD  Thread,
IN PKLOCK_QUEUE_HANDLE  Handle 
)

Definition at line 626 of file ke_x.h.

628 {
629  /* Acquire the lock */
631 }
VOID FASTCALL KeAcquireInStackQueuedSpinLock(IN PKSPIN_LOCK SpinLock, IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:130
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2652
_In_ HANDLE Handle
Definition: extypes.h:390

Referenced by KiDeliverApc().

◆ KiAcquireApcLockRaiseToSynch()

FORCEINLINE VOID KiAcquireApcLockRaiseToSynch ( IN PKTHREAD  Thread,
IN PKLOCK_QUEUE_HANDLE  Handle 
)

Definition at line 607 of file ke_x.h.

609 {
610  /* Acquire the lock and raise to synchronization level */
612 }
VOID FASTCALL KeAcquireInStackQueuedSpinLockRaiseToSynch(IN PKSPIN_LOCK SpinLock, IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:142
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2652
_In_ HANDLE Handle
Definition: extypes.h:390

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

◆ KiAcquireDeviceQueueLock()

FORCEINLINE VOID KiAcquireDeviceQueueLock ( IN PKDEVICE_QUEUE  DeviceQueue,
IN PKLOCK_QUEUE_HANDLE  DeviceLock 
)

Definition at line 676 of file ke_x.h.

678 {
679  /* Check if we were called from a threaded DPC */
680  if (KeGetCurrentPrcb()->DpcThreadActive)
681  {
682  /* Lock the Queue, we're not at DPC level */
683  KeAcquireInStackQueuedSpinLock(&DeviceQueue->Lock, DeviceLock);
684  }
685  else
686  {
687  /* We must be at DPC level, acquire the lock safely */
689  KeAcquireInStackQueuedSpinLockAtDpcLevel(&DeviceQueue->Lock,
690  DeviceLock);
691  }
692 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1079
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:363
#define ASSERT(a)
Definition: mode.c:44
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696

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

◆ KiAcquireDispatcherLock()

◆ KiAcquireDispatcherLockAtSynchLevel()

◆ KiAcquireDispatcherObject()

FORCEINLINE VOID KiAcquireDispatcherObject ( IN DISPATCHER_HEADER Object)

Definition at line 132 of file ke_x.h.

133 {
135 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object

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

◆ KiAcquireNmiListLock()

FORCEINLINE VOID KiAcquireNmiListLock ( OUT PKIRQL  OldIrql)

Definition at line 1679 of file ke_x.h.

1680 {
1682 }
VOID NTAPI KeAcquireSpinLock(PKSPIN_LOCK SpinLock, PKIRQL OldIrql)
Definition: spinlock.c:50
KIRQL OldIrql
Definition: mm.h:1502
KSPIN_LOCK KiNmiCallbackListLock
Definition: bug.c:30

Referenced by KeDeregisterNmiCallback(), and KeRegisterNmiCallback().

◆ KiAcquirePrcbLock()

◆ KiAcquireProcessLockRaiseToSynch()

FORCEINLINE VOID KiAcquireProcessLockRaiseToSynch ( IN PKPROCESS  Process,
IN PKLOCK_QUEUE_HANDLE  Handle 
)

Definition at line 651 of file ke_x.h.

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

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

◆ KiAcquireThreadLock()

◆ KiAcquireTimerLock()

FORCEINLINE PKSPIN_LOCK_QUEUE KiAcquireTimerLock ( IN ULONG  Hand)

Definition at line 286 of file ke_x.h.

287 {
289 
290  /* Nothing to do on UP */
292  return NULL;
293 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define ASSERT(a)
Definition: mode.c:44
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define NULL
Definition: types.h:112

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

◆ KiCheckAlertability()

FORCEINLINE NTSTATUS KiCheckAlertability ( IN PKTHREAD  Thread,
IN BOOLEAN  Alertable,
IN KPROCESSOR_MODE  WaitMode 
)

Definition at line 841 of file ke_x.h.

844 {
845  /* Check if the wait is alertable */
846  if (Alertable)
847  {
848  /* It is, first check if the thread is alerted in this mode */
849  if (Thread->Alerted[WaitMode])
850  {
851  /* It is, so bail out of the wait */
852  Thread->Alerted[WaitMode] = FALSE;
853  return STATUS_ALERTED;
854  }
855  else if ((WaitMode != KernelMode) &&
856  (!IsListEmpty(&Thread->ApcState.ApcListHead[UserMode])))
857  {
858  /* It's isn't, but this is a user wait with queued user APCs */
859  Thread->ApcState.UserApcPending = TRUE;
860  return STATUS_USER_APC;
861  }
862  else if (Thread->Alerted[KernelMode])
863  {
864  /* It isn't that either, but we're alered in kernel mode */
865  Thread->Alerted[KernelMode] = FALSE;
866  return STATUS_ALERTED;
867  }
868  }
869  else if ((WaitMode != KernelMode) && (Thread->ApcState.UserApcPending))
870  {
871  /* Not alertable, but this is a user wait with pending user APCs */
872  return STATUS_USER_APC;
873  }
874 
875  /* Otherwise, we're fine */
876  return STATUS_WAIT_0;
877 }
_In_ PVOID _In_ BOOLEAN Alertable
Definition: exfuncs.h:452
#define TRUE
Definition: types.h:120
#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:237
#define FALSE
Definition: types.h:117
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2652
#define STATUS_USER_APC
Definition: ntstatus.h:78

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

◆ KiCheckDeferredReadyList()

FORCEINLINE VOID KiCheckDeferredReadyList ( IN PKPRCB  Prcb)

Definition at line 268 of file ke_x.h.

269 {
270  /* There are no deferred ready lists on UP systems */
272 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317

Referenced by KiExitDispatcher().

◆ KiCheckThreadStackSwap()

FORCEINLINE BOOLEAN KiCheckThreadStackSwap ( IN PKTHREAD  Thread,
IN KPROCESSOR_MODE  WaitMode 
)

Definition at line 803 of file ke_x.h.

805 {
806  /* Check the required conditions */
807  if ((WaitMode != KernelMode) &&
808  (Thread->EnableStackSwap) &&
809  (Thread->Priority >= (LOW_REALTIME_PRIORITY + 9)))
810  {
811  /* We are go for swap */
812  return TRUE;
813  }
814  else
815  {
816  /* Don't swap the thread */
817  return FALSE;
818  }
819 }
#define TRUE
Definition: types.h:120
#define LOW_REALTIME_PRIORITY
#define FALSE
Definition: types.h:117
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2652

◆ KiComputeDueTime()

FORCEINLINE BOOLEAN KiComputeDueTime ( IN PKTIMER  Timer,
IN LARGE_INTEGER  DueTime,
OUT PULONG  Hand 
)

Definition at line 952 of file ke_x.h.

955 {
956  LARGE_INTEGER InterruptTime, SystemTime, DifferenceTime;
957 
958  /* Convert to relative time if needed */
959  Timer->Header.Absolute = FALSE;
960  if (DueTime.HighPart >= 0)
961  {
962  /* Get System Time */
963  KeQuerySystemTime(&SystemTime);
964 
965  /* Do the conversion */
966  DifferenceTime.QuadPart = SystemTime.QuadPart - DueTime.QuadPart;
967 
968  /* Make sure it hasn't already expired */
969  Timer->Header.Absolute = TRUE;
970  if (DifferenceTime.HighPart >= 0)
971  {
972  /* Cancel everything */
973  Timer->Header.SignalState = TRUE;
974  Timer->Header.Hand = 0;
975  Timer->DueTime.QuadPart = 0;
976  *Hand = 0;
977  return FALSE;
978  }
979 
980  /* Set the time as Absolute */
981  DueTime = DifferenceTime;
982  }
983 
984  /* Get the Interrupt Time */
985  InterruptTime.QuadPart = KeQueryInterruptTime();
986 
987  /* Recalculate due time */
988  Timer->DueTime.QuadPart = InterruptTime.QuadPart - DueTime.QuadPart;
989 
990  /* Get the handle */
991  *Hand = KiComputeTimerTableIndex(Timer->DueTime.QuadPart);
992  Timer->Header.Hand = (UCHAR)*Hand;
993  Timer->Header.Inserted = TRUE;
994  return TRUE;
995 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned char UCHAR
Definition: xmlstorage.h:181
_In_ WDFTIMER _In_ LONGLONG DueTime
Definition: wdftimer.h:187
ULONGLONG NTAPI KeQueryInterruptTime(VOID)
Definition: clock.c:203
FORCEINLINE ULONG KiComputeTimerTableIndex(IN ULONGLONG DueTime)
Definition: ke_x.h:881
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by KeSetTimerEx(), and KiInsertTreeTimer().

◆ KiComputeNewPriority()

FORCEINLINE SCHAR KiComputeNewPriority ( IN PKTHREAD  Thread,
IN SCHAR  Adjustment 
)

Definition at line 1469 of file ke_x.h.

1471 {
1472  SCHAR Priority;
1473 
1474  /* Priority sanity checks */
1475  ASSERT((Thread->PriorityDecrement >= 0) &&
1476  (Thread->PriorityDecrement <= Thread->Priority));
1477  ASSERT((Thread->Priority < LOW_REALTIME_PRIORITY) ?
1478  TRUE : (Thread->PriorityDecrement == 0));
1479 
1480  /* Get the current priority */
1481  Priority = Thread->Priority;
1483  {
1484  /* Decrease priority by the priority decrement */
1485  Priority -= (Thread->PriorityDecrement + Adjustment);
1486 
1487  /* Don't go out of bounds */
1488  if (Priority < Thread->BasePriority) Priority = Thread->BasePriority;
1489 
1490  /* Reset the priority decrement */
1491  Thread->PriorityDecrement = 0;
1492  }
1493 
1494  /* Sanity check */
1495  ASSERT((Thread->BasePriority == 0) || (Priority != 0));
1496 
1497  /* Return the new priority */
1498  return Priority;
1499 }
#define TRUE
Definition: types.h:120
#define LOW_REALTIME_PRIORITY
_In_ KPRIORITY _In_ LONG Adjustment
Definition: kefuncs.h:438
#define ASSERT(a)
Definition: mode.c:44
signed char SCHAR
Definition: sqltypes.h:14
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2652
_In_ WDFINTERRUPT _In_ WDF_INTERRUPT_POLICY _In_ WDF_INTERRUPT_PRIORITY Priority
Definition: wdfinterrupt.h:651

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

◆ KiComputeTimerTableIndex()

FORCEINLINE ULONG KiComputeTimerTableIndex ( IN ULONGLONG  DueTime)

Definition at line 881 of file ke_x.h.

882 {
883  return (DueTime / KeMaximumIncrement) & (TIMER_TABLE_SIZE - 1);
884 }
ULONG KeMaximumIncrement
Definition: clock.c:20
#define TIMER_TABLE_SIZE
Definition: ketypes.h:836
_In_ WDFTIMER _In_ LONGLONG DueTime
Definition: wdftimer.h:187

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

◆ KiInsertDeferredReadyList()

FORCEINLINE VOID KiInsertDeferredReadyList ( IN PKTHREAD  Thread)

Definition at line 185 of file ke_x.h.

186 {
187  /* Set the thread to deferred state and boot CPU */
188  Thread->State = DeferredReady;
189  Thread->DeferredProcessor = 0;
190 
191  /* Make the thread ready immediately */
193 }
VOID FASTCALL KiDeferredReadyThread(IN PKTHREAD Thread)
Definition: thrdschd.c:79
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2652

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

◆ KiRecalculateDueTime()

FORCEINLINE PLARGE_INTEGER KiRecalculateDueTime ( IN PLARGE_INTEGER  OriginalDueTime,
IN PLARGE_INTEGER  DueTime,
IN OUT PLARGE_INTEGER  NewDueTime 
)

Definition at line 785 of file ke_x.h.

788 {
789  /* Don't do anything for absolute waits */
790  if (OriginalDueTime->QuadPart >= 0) return OriginalDueTime;
791 
792  /* Otherwise, query the interrupt time and recalculate */
793  NewDueTime->QuadPart = KeQueryInterruptTime();
794  NewDueTime->QuadPart -= DueTime->QuadPart;
795  return NewDueTime;
796 }
_In_ WDFTIMER _In_ LONGLONG DueTime
Definition: wdftimer.h:187
ULONGLONG NTAPI KeQueryInterruptTime(VOID)
Definition: clock.c:203

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

◆ KiReleaseApcLock()

FORCEINLINE VOID KiReleaseApcLock ( IN PKLOCK_QUEUE_HANDLE  Handle)

Definition at line 635 of file ke_x.h.

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

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

◆ KiReleaseApcLockFromSynchLevel()

FORCEINLINE VOID KiReleaseApcLockFromSynchLevel ( IN PKLOCK_QUEUE_HANDLE  Handle)

Definition at line 643 of file ke_x.h.

644 {
645  /* Release the lock */
647 }
_In_ HANDLE Handle
Definition: extypes.h:390
VOID FASTCALL KeReleaseInStackQueuedSpinLockFromDpcLevel(IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:395

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

◆ KiReleaseDeviceQueueLock()

FORCEINLINE VOID KiReleaseDeviceQueueLock ( IN PKLOCK_QUEUE_HANDLE  DeviceLock)

Definition at line 696 of file ke_x.h.

697 {
698  /* Check if we were called from a threaded DPC */
699  if (KeGetCurrentPrcb()->DpcThreadActive)
700  {
701  /* Unlock the Queue, we're not at DPC level */
702  KeReleaseInStackQueuedSpinLock(DeviceLock);
703  }
704  else
705  {
706  /* We must be at DPC level, release the lock safely */
709  }
710 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1079
VOID FASTCALL KeReleaseInStackQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:166
#define ASSERT(a)
Definition: mode.c:44
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
VOID FASTCALL KeReleaseInStackQueuedSpinLockFromDpcLevel(IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:395

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

◆ KiReleaseDispatcherLock()

◆ KiReleaseDispatcherLockFromSynchLevel()

◆ KiReleaseDispatcherObject()

FORCEINLINE VOID KiReleaseDispatcherObject ( IN DISPATCHER_HEADER Object)

Definition at line 142 of file ke_x.h.

143 {
145 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object

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

◆ KiReleaseNmiListLock()

FORCEINLINE VOID KiReleaseNmiListLock ( IN KIRQL  OldIrql)

Definition at line 1686 of file ke_x.h.

1687 {
1689 }
KIRQL OldIrql
Definition: mm.h:1502
KSPIN_LOCK KiNmiCallbackListLock
Definition: bug.c:30
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627

Referenced by KeDeregisterNmiCallback(), and KeRegisterNmiCallback().

◆ KiReleasePrcbLock()

◆ KiReleaseProcessLock()

FORCEINLINE VOID KiReleaseProcessLock ( IN PKLOCK_QUEUE_HANDLE  Handle)

Definition at line 660 of file ke_x.h.

661 {
662  /* Release the lock and restore previous IRQL */
664 }
VOID FASTCALL KeReleaseInStackQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:166
_In_ HANDLE Handle
Definition: extypes.h:390

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

◆ KiReleaseProcessLockFromSynchLevel()

FORCEINLINE VOID KiReleaseProcessLockFromSynchLevel ( IN PKLOCK_QUEUE_HANDLE  Handle)

Definition at line 668 of file ke_x.h.

669 {
670  /* Release the lock without lowering IRQL */
672 }
_In_ HANDLE Handle
Definition: extypes.h:390
VOID FASTCALL KeReleaseInStackQueuedSpinLockFromDpcLevel(IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:395

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

◆ KiReleaseThreadLock()

◆ KiReleaseTimerLock()

FORCEINLINE VOID KiReleaseTimerLock ( IN PKSPIN_LOCK_QUEUE  LockQueue)

Definition at line 297 of file ke_x.h.

298 {
300 
301  /* Nothing to do on UP */
302  UNREFERENCED_PARAMETER(LockQueue);
303 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define ASSERT(a)
Definition: mode.c:44
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696

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

◆ KiRemoveEntryTimer()

FORCEINLINE VOID KiRemoveEntryTimer ( IN PKTIMER  Timer)

Definition at line 892 of file ke_x.h.

893 {
894  ULONG Hand;
896 
897  /* Remove the timer from the timer list and check if it's empty */
898  Hand = Timer->Header.Hand;
899  if (RemoveEntryList(&Timer->TimerListEntry))
900  {
901  /* Get the respective timer table entry */
903  if (&TableEntry->Entry == TableEntry->Entry.Flink)
904  {
905  /* Set the entry to an infinite absolute time */
906  TableEntry->Time.HighPart = 0xFFFFFFFF;
907  }
908  }
909 
910  /* Clear the list entries on dbg builds so we can tell the timer is gone */
911 #if DBG
912  Timer->TimerListEntry.Flink = NULL;
913  Timer->TimerListEntry.Blink = NULL;
914 #endif
915 }
Definition: ketypes.h:703
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
KTIMER_TABLE_ENTRY KiTimerTableListHead[TIMER_TABLE_SIZE]
Definition: timerobj.c:17
#define NULL
Definition: types.h:112
_Must_inspect_result_ typedef _In_ ULONG TableEntry
Definition: iotypes.h:4303
unsigned int ULONG
Definition: retypes.h:1

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

◆ KiRequestApcInterrupt()

FORCEINLINE VOID KiRequestApcInterrupt ( IN BOOLEAN  NeedApc,
IN UCHAR  Processor 
)

Definition at line 276 of file ke_x.h.

278 {
279  /* We deliver instantly on UP */
280  UNREFERENCED_PARAMETER(NeedApc);
282 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_In_ UCHAR Processor
Definition: kefuncs.h:682

Referenced by KiInsertQueueApc().

◆ KiRescheduleThread()

FORCEINLINE VOID KiRescheduleThread ( IN BOOLEAN  NewThread,
IN ULONG  Cpu 
)

Definition at line 197 of file ke_x.h.

199 {
200  /* This is meaningless on UP systems */
201  UNREFERENCED_PARAMETER(NewThread);
203 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317

◆ KiSelectReadyThread()

FORCEINLINE PKTHREAD KiSelectReadyThread ( IN KPRIORITY  Priority,
IN PKPRCB  Prcb 
)

Definition at line 1419 of file ke_x.h.

1421 {
1422  ULONG PrioritySet;
1423  LONG HighPriority;
1424  PLIST_ENTRY ListEntry;
1425  PKTHREAD Thread = NULL;
1426 
1427  /* Save the current mask and get the priority set for the CPU */
1428  PrioritySet = Prcb->ReadySummary >> Priority;
1429  if (!PrioritySet) goto Quickie;
1430 
1431  /* Get the highest priority possible */
1432  BitScanReverse((PULONG)&HighPriority, PrioritySet);
1433  ASSERT((PrioritySet & PRIORITY_MASK(HighPriority)) != 0);
1434  HighPriority += Priority;
1435 
1436  /* Make sure the list isn't empty at the highest priority */
1437  ASSERT(IsListEmpty(&Prcb->DispatcherReadyListHead[HighPriority]) == FALSE);
1438 
1439  /* Get the first thread on the list */
1440  ListEntry = Prcb->DispatcherReadyListHead[HighPriority].Flink;
1441  Thread = CONTAINING_RECORD(ListEntry, KTHREAD, WaitListEntry);
1442 
1443  /* Make sure this thread is here for a reason */
1444  ASSERT(HighPriority == Thread->Priority);
1445  ASSERT(Thread->Affinity & AFFINITY_MASK(Prcb->Number));
1446  ASSERT(Thread->NextProcessor == Prcb->Number);
1447 
1448  /* Remove it from the list */
1449  if (RemoveEntryList(&Thread->WaitListEntry))
1450  {
1451  /* The list is empty now, reset the ready summary */
1452  Prcb->ReadySummary ^= PRIORITY_MASK(HighPriority);
1453  }
1454 
1455  /* Sanity check and return the thread */
1456 Quickie:
1457  ASSERT((Thread == NULL) ||
1458  (Thread->BasePriority == 0) ||
1459  (Thread->Priority != 0));
1460  return Thread;
1461 }
#define PRIORITY_MASK(Id)
Definition: ke.h:160
#define AFFINITY_MASK(Id)
Definition: ke.h:159
_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
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define ASSERT(a)
Definition: mode.c:44
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2652
_In_ WDFINTERRUPT _In_ WDF_INTERRUPT_POLICY _In_ WDF_INTERRUPT_PRIORITY Priority
Definition: wdfinterrupt.h:651
#define BitScanReverse
Definition: interlocked.h:6
Definition: typedefs.h:119
unsigned int * PULONG
Definition: retypes.h:1
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1

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

◆ KiSetThreadSwapBusy()

FORCEINLINE VOID KiSetThreadSwapBusy ( IN PKTHREAD  Thread)

Definition at line 210 of file ke_x.h.

211 {
213 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2652

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

◆ KiTryThreadLock()

FORCEINLINE BOOLEAN KiTryThreadLock ( IN PKTHREAD  Thread)

Definition at line 260 of file ke_x.h.

261 {
263  return FALSE;
264 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define FALSE
Definition: types.h:117
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2652

Referenced by KeSignalGateBoostPriority().

◆ KxInsertTimer()

FORCEINLINE VOID KxInsertTimer ( IN PKTIMER  Timer,
IN ULONG  Hand 
)

Definition at line 923 of file ke_x.h.

925 {
926  PKSPIN_LOCK_QUEUE LockQueue;
928 
929  /* Acquire the lock and release the dispatcher lock */
930  LockQueue = KiAcquireTimerLock(Hand);
932 
933  /* Try to insert the timer */
934  if (KiInsertTimerTable(Timer, Hand))
935  {
936  /* Complete it */
937  KiCompleteTimer(Timer, LockQueue);
938  }
939  else
940  {
941  /* Do nothing, just release the lock */
942  KiReleaseTimerLock(LockQueue);
943  }
944 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
FORCEINLINE PKSPIN_LOCK_QUEUE KiAcquireTimerLock(IN ULONG Hand)
Definition: ke_x.h:286
BOOLEAN FASTCALL KiInsertTimerTable(IN PKTIMER Timer, IN ULONG Hand)
Definition: timerobj.c:63
#define ASSERT(a)
Definition: mode.c:44
VOID FASTCALL KiCompleteTimer(IN PKTIMER Timer, IN PKSPIN_LOCK_QUEUE LockQueue)
Definition: timerobj.c:167
FORCEINLINE VOID KiReleaseDispatcherLockFromSynchLevel(VOID)
Definition: ke_x.h:174
#define SYNCH_LEVEL
Definition: env_spec_w32.h:704
FORCEINLINE VOID KiReleaseTimerLock(IN PKSPIN_LOCK_QUEUE LockQueue)
Definition: ke_x.h:297

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

◆ KxRemoveTreeTimer()

FORCEINLINE VOID KxRemoveTreeTimer ( IN PKTIMER  Timer)

Definition at line 1004 of file ke_x.h.

1005 {
1006  ULONG Hand = Timer->Header.Hand;
1007  PKSPIN_LOCK_QUEUE LockQueue;
1008  PKTIMER_TABLE_ENTRY TimerEntry;
1009 
1010  /* Acquire timer lock */
1011  LockQueue = KiAcquireTimerLock(Hand);
1012 
1013  /* Set the timer as non-inserted */
1014  Timer->Header.Inserted = FALSE;
1015 
1016  /* Remove it from the timer list */
1017  if (RemoveEntryList(&Timer->TimerListEntry))
1018  {
1019  /* Get the entry and check if it's empty */
1020  TimerEntry = &KiTimerTableListHead[Hand];
1021  if (IsListEmpty(&TimerEntry->Entry))
1022  {
1023  /* Clear the time then */
1024  TimerEntry->Time.HighPart = 0xFFFFFFFF;
1025  }
1026  }
1027 
1028  /* Release the timer lock */
1029  KiReleaseTimerLock(LockQueue);
1030 }
FORCEINLINE PKSPIN_LOCK_QUEUE KiAcquireTimerLock(IN ULONG Hand)
Definition: ke_x.h:286
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
Definition: ketypes.h:703
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
#define FALSE
Definition: types.h:117
ULARGE_INTEGER Time
Definition: ketypes.h:709
LIST_ENTRY Entry
Definition: ketypes.h:708
$ULONG HighPart
Definition: ntbasedef.h:570
KTIMER_TABLE_ENTRY KiTimerTableListHead[TIMER_TABLE_SIZE]
Definition: timerobj.c:17
unsigned int ULONG
Definition: retypes.h:1
FORCEINLINE VOID KiReleaseTimerLock(IN PKSPIN_LOCK_QUEUE LockQueue)
Definition: ke_x.h:297

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

◆ KxSetTimerForThreadWait()

FORCEINLINE VOID KxSetTimerForThreadWait ( IN PKTIMER  Timer,
IN LARGE_INTEGER  Interval,
OUT PULONG  Hand 
)

Definition at line 1034 of file ke_x.h.

1037 {
1039  LARGE_INTEGER InterruptTime, SystemTime, TimeDifference;
1040 
1041  /* Check the timer's interval to see if it's absolute */
1042  Timer->Header.Absolute = FALSE;
1043  if (Interval.HighPart >= 0)
1044  {
1045  /* Get the system time and calculate the relative time */
1046  KeQuerySystemTime(&SystemTime);
1047  TimeDifference.QuadPart = SystemTime.QuadPart - Interval.QuadPart;
1048  Timer->Header.Absolute = TRUE;
1049 
1050  /* Check if we've already expired */
1051  if (TimeDifference.HighPart >= 0)
1052  {
1053  /* Reset everything */
1054  Timer->DueTime.QuadPart = 0;
1055  *Hand = 0;
1056  Timer->Header.Hand = 0;
1057  return;
1058  }
1059  else
1060  {
1061  /* Update the interval */
1062  Interval = TimeDifference;
1063  }
1064  }
1065 
1066  /* Calculate the due time */
1067  InterruptTime.QuadPart = KeQueryInterruptTime();
1068  DueTime = InterruptTime.QuadPart - Interval.QuadPart;
1069  Timer->DueTime.QuadPart = DueTime;
1070 
1071  /* Calculate the timer handle */
1073  Timer->Header.Hand = (UCHAR)*Hand;
1074 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
DWORD Interval
Definition: netstat.c:33
uint64_t ULONGLONG
Definition: typedefs.h:67
unsigned char UCHAR
Definition: xmlstorage.h:181
_In_ WDFTIMER _In_ LONGLONG DueTime
Definition: wdftimer.h:187
ULONGLONG NTAPI KeQueryInterruptTime(VOID)
Definition: clock.c:203
FORCEINLINE ULONG KiComputeTimerTableIndex(IN ULONGLONG DueTime)
Definition: ke_x.h:881
LONGLONG QuadPart
Definition: typedefs.h:114

◆ KxUnwaitThread()

FORCEINLINE VOID KxUnwaitThread ( IN DISPATCHER_HEADER Object,
IN KPRIORITY  Increment 
)

Definition at line 1259 of file ke_x.h.

1261 {
1262  PLIST_ENTRY WaitEntry, WaitList;
1263  PKWAIT_BLOCK WaitBlock;
1264  PKTHREAD WaitThread;
1265  ULONG WaitKey;
1266 
1267  /* Loop the Wait Entries */
1268  WaitList = &Object->WaitListHead;
1269  ASSERT(IsListEmpty(&Object->WaitListHead) == FALSE);
1270  WaitEntry = WaitList->Flink;
1271  do
1272  {
1273  /* Get the current wait block */
1274  WaitBlock = CONTAINING_RECORD(WaitEntry, KWAIT_BLOCK, WaitListEntry);
1275 
1276  /* Get the waiting thread */
1277  WaitThread = WaitBlock->Thread;
1278 
1279  /* Check the current Wait Mode */
1280  if (WaitBlock->WaitType == WaitAny)
1281  {
1282  /* Use the actual wait key */
1283  WaitKey = WaitBlock->WaitKey;
1284  }
1285  else
1286  {
1287  /* Otherwise, use STATUS_KERNEL_APC */
1288  WaitKey = STATUS_KERNEL_APC;
1289  }
1290 
1291  /* Unwait the thread */
1292  KiUnwaitThread(WaitThread, WaitKey, Increment);
1293 
1294  /* Next entry */
1295  WaitEntry = WaitList->Flink;
1296  } while (WaitEntry != WaitList);
1297 }
VOID FASTCALL KiUnwaitThread(IN PKTHREAD Thread, IN LONG_PTR WaitStatus, IN KPRIORITY Increment)
Definition: wait.c:89
struct _KTHREAD * Thread
Definition: ketypes.h:453
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define FALSE
Definition: types.h:117
#define STATUS_KERNEL_APC
Definition: ntstatus.h:79
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
UCHAR WaitType
Definition: ketypes.h:446
#define ASSERT(a)
Definition: mode.c:44
USHORT WaitKey
Definition: ketypes.h:448
Definition: typedefs.h:119
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
unsigned int ULONG
Definition: retypes.h:1
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG Increment
Definition: CrNtStubs.h:42

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

◆ KxUnwaitThreadForEvent()

FORCEINLINE VOID KxUnwaitThreadForEvent ( IN PKEVENT  Event,
IN KPRIORITY  Increment 
)

Definition at line 1304 of file ke_x.h.

1306 {
1307  PLIST_ENTRY WaitEntry, WaitList;
1308  PKWAIT_BLOCK WaitBlock;
1309  PKTHREAD WaitThread;
1310 
1311  /* Loop the Wait Entries */
1312  WaitList = &Event->Header.WaitListHead;
1313  ASSERT(IsListEmpty(&Event->Header.WaitListHead) == FALSE);
1314  WaitEntry = WaitList->Flink;
1315  do
1316  {
1317  /* Get the current wait block */
1318  WaitBlock = CONTAINING_RECORD(WaitEntry, KWAIT_BLOCK, WaitListEntry);
1319 
1320  /* Get the waiting thread */
1321  WaitThread = WaitBlock->Thread;
1322 
1323  /* Check the current Wait Mode */
1324  if (WaitBlock->WaitType == WaitAny)
1325  {
1326  /* Un-signal it */
1327  Event->Header.SignalState = 0;
1328 
1329  /* Un-signal the event and unwait the thread */
1330  KiUnwaitThread(WaitThread, WaitBlock->WaitKey, Increment);
1331  break;
1332  }
1333 
1334  /* Unwait the thread with STATUS_KERNEL_APC */
1336 
1337  /* Next entry */
1338  WaitEntry = WaitList->Flink;
1339  } while (WaitEntry != WaitList);
1340 }
VOID FASTCALL KiUnwaitThread(IN PKTHREAD Thread, IN LONG_PTR WaitStatus, IN KPRIORITY Increment)
Definition: wait.c:89
struct _KTHREAD * Thread
Definition: ketypes.h:453
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define FALSE
Definition: types.h:117
#define STATUS_KERNEL_APC
Definition: ntstatus.h:79
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
UCHAR WaitType
Definition: ketypes.h:446
#define ASSERT(a)
Definition: mode.c:44
USHORT WaitKey
Definition: ketypes.h:448
Definition: typedefs.h:119
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG Increment
Definition: CrNtStubs.h:42

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