ReactOS  0.4.14-dev-1314-gacf135d
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)
 
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:44

Definition at line 83 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:44

Definition at line 72 of file ke_x.h.

◆ KeEnterGuardedRegion

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

Definition at line 34 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:44
#define APC_LEVEL
Definition: env_spec_w32.h:695

Definition at line 22 of file ke_x.h.

◆ KeLeaveCriticalRegion

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

Definition at line 114 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:44

Definition at line 92 of file ke_x.h.

◆ KeLeaveGuardedRegion

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

Definition at line 63 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:44
#define APC_LEVEL
Definition: env_spec_w32.h:695

Definition at line 43 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:1063
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653

Definition at line 819 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); \
} \
}
Definition: Header.h:8
_In_ KPRIORITY _In_ BOOLEAN Abandoned
Definition: kefuncs.h:593
if(!(yy_init))
Definition: macro.lex.yy.c:714
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
static IUnknown Object
Definition: main.c:512
#define STATUS_ABANDONED
Definition: ntstatus.h:75

Definition at line 710 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
static IUnknown Object
Definition: main.c:512
#define TIMER_OR_EVENT_TYPE
Definition: ke.h:159

Definition at line 744 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:2653
static IUnknown Object
Definition: main.c:512

Definition at line 762 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:798
ULONG LowPart
Definition: ketypes.h:910
_In_ PVOID _In_ BOOLEAN Alertable
Definition: exfuncs.h:452
smooth NULL
Definition: ftsmooth.c:416
DWORD Interval
Definition: netstat.c:33
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
NTKERNELAPI volatile KSYSTEM_TIME KeTickCount
Definition: clock.c:19
return STATUS_SUCCESS
Definition: btrfs.c:2938

Definition at line 1071 of file ke_x.h.

◆ KxMultiThreadWait

#define KxMultiThreadWait ( )

Definition at line 1102 of file ke_x.h.

◆ KxQueueThreadWait

#define KxQueueThreadWait ( )

Definition at line 1203 of file ke_x.h.

◆ KxSingleThreadWait

#define KxSingleThreadWait ( )

Definition at line 1158 of file ke_x.h.

Function Documentation

◆ _KeAcquireGuardedMutex()

FORCEINLINE VOID _KeAcquireGuardedMutex ( IN PKGUARDED_MUTEX  GuardedMutex)

Definition at line 1577 of file ke_x.h.

1578 {
1580 
1581  /* Sanity checks */
1583  ASSERT(GuardedMutex->Owner != Thread);
1584 
1585  /* Disable Special APCs */
1587 
1588  /* Remove the lock */
1589  if (!InterlockedBitTestAndReset(&GuardedMutex->Count, GM_LOCK_BIT_V))
1590  {
1591  /* The Guarded Mutex was already locked, enter contented case */
1592  KiAcquireGuardedMutex(GuardedMutex);
1593  }
1594 
1595  /* Set the Owner and Special APC Disable state */
1596  GuardedMutex->Owner = Thread;
1597  GuardedMutex->SpecialApcDisable = Thread->SpecialApcDisable;
1598 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define InterlockedBitTestAndReset
Definition: interlocked.h:35
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#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

Referenced by KeAcquireGuardedMutex().

◆ _KeAcquireGuardedMutexUnsafe()

FORCEINLINE VOID _KeAcquireGuardedMutexUnsafe ( IN OUT PKGUARDED_MUTEX  GuardedMutex)

Definition at line 1512 of file ke_x.h.

1513 {
1515 
1516  /* Sanity checks */
1518  (Thread->SpecialApcDisable < 0) ||
1519  (Thread->Teb == NULL) ||
1520  (Thread->Teb >= (PTEB)MM_SYSTEM_RANGE_START));
1521  ASSERT(GuardedMutex->Owner != Thread);
1522 
1523  /* Remove the lock */
1524  if (!InterlockedBitTestAndReset(&GuardedMutex->Count, GM_LOCK_BIT_V))
1525  {
1526  /* The Guarded Mutex was already locked, enter contented case */
1527  KiAcquireGuardedMutex(GuardedMutex);
1528  }
1529 
1530  /* Set the Owner */
1531  GuardedMutex->Owner = Thread;
1532 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define InterlockedBitTestAndReset
Definition: interlocked.h:35
smooth NULL
Definition: ftsmooth.c:416
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define MM_SYSTEM_RANGE_START
Definition: armddk.h:18
Definition: compat.h:492
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

Referenced by KeAcquireGuardedMutexUnsafe().

◆ _KeInitializeGuardedMutex()

FORCEINLINE VOID _KeInitializeGuardedMutex ( OUT PKGUARDED_MUTEX  GuardedMutex)

Definition at line 1499 of file ke_x.h.

1500 {
1501  /* Setup the Initial Data */
1502  GuardedMutex->Count = GM_LOCK_BIT;
1503  GuardedMutex->Owner = NULL;
1504  GuardedMutex->Contention = 0;
1505 
1506  /* Initialize the Wait Gate */
1507  KeInitializeGate(&GuardedMutex->Gate);
1508 }
#define GM_LOCK_BIT
smooth NULL
Definition: ftsmooth.c:416
VOID FASTCALL KeInitializeGate(PKGATE Gate)

Referenced by KeInitializeGuardedMutex().

◆ _KeReleaseGuardedMutex()

FORCEINLINE VOID _KeReleaseGuardedMutex ( IN OUT PKGUARDED_MUTEX  GuardedMutex)

Definition at line 1602 of file ke_x.h.

1603 {
1605  LONG OldValue, NewValue;
1606 
1607  /* Sanity checks */
1609  ASSERT(GuardedMutex->Owner == Thread);
1610  ASSERT(Thread->SpecialApcDisable == GuardedMutex->SpecialApcDisable);
1611 
1612  /* Destroy the Owner */
1613  GuardedMutex->Owner = NULL;
1614 
1615  /* Add the Lock Bit */
1616  OldValue = InterlockedExchangeAdd(&GuardedMutex->Count, GM_LOCK_BIT);
1617  ASSERT((OldValue & GM_LOCK_BIT) == 0);
1618 
1619  /* Check if it was already locked, but not woken */
1620  if ((OldValue) && !(OldValue & GM_LOCK_WAITER_WOKEN))
1621  {
1622  /* Update the Oldvalue to what it should be now */
1623  OldValue += GM_LOCK_BIT;
1624 
1625  /* The mutex will be woken, minus one waiter */
1626  NewValue = OldValue + GM_LOCK_WAITER_WOKEN -
1628 
1629  /* Remove the Woken bit */
1630  if (InterlockedCompareExchange(&GuardedMutex->Count,
1631  NewValue,
1632  OldValue) == OldValue)
1633  {
1634  /* Signal the Gate */
1635  KeSignalGateBoostPriority(&GuardedMutex->Gate);
1636  }
1637  }
1638 
1639  /* Re-enable APCs */
1641 }
#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
smooth NULL
Definition: ftsmooth.c:416
#define InterlockedExchangeAdd
Definition: interlocked.h:181
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
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

Referenced by KeReleaseGuardedMutex().

◆ _KeReleaseGuardedMutexUnsafe()

FORCEINLINE VOID _KeReleaseGuardedMutexUnsafe ( IN OUT PKGUARDED_MUTEX  GuardedMutex)

Definition at line 1536 of file ke_x.h.

1537 {
1538  LONG OldValue, NewValue;
1539 
1540  /* Sanity checks */
1542  (KeGetCurrentThread()->SpecialApcDisable < 0) ||
1543  (KeGetCurrentThread()->Teb == NULL) ||
1545  ASSERT(GuardedMutex->Owner == KeGetCurrentThread());
1546 
1547  /* Destroy the Owner */
1548  GuardedMutex->Owner = NULL;
1549 
1550  /* Add the Lock Bit */
1551  OldValue = InterlockedExchangeAdd(&GuardedMutex->Count, GM_LOCK_BIT);
1552  ASSERT((OldValue & GM_LOCK_BIT) == 0);
1553 
1554  /* Check if it was already locked, but not woken */
1555  if ((OldValue) && !(OldValue & GM_LOCK_WAITER_WOKEN))
1556  {
1557  /* Update the Oldvalue to what it should be now */
1558  OldValue += GM_LOCK_BIT;
1559 
1560  /* The mutex will be woken, minus one waiter */
1561  NewValue = OldValue + GM_LOCK_WAITER_WOKEN -
1563 
1564  /* Remove the Woken bit */
1565  if (InterlockedCompareExchange(&GuardedMutex->Count,
1566  NewValue,
1567  OldValue) == OldValue)
1568  {
1569  /* Signal the Gate */
1570  KeSignalGateBoostPriority(&GuardedMutex->Gate);
1571  }
1572  }
1573 }
#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
smooth NULL
Definition: ftsmooth.c:416
#define InterlockedExchangeAdd
Definition: interlocked.h:181
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define MM_SYSTEM_RANGE_START
Definition: armddk.h:18
Definition: compat.h:492
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

Referenced by KeReleaseGuardedMutexUnsafe().

◆ _KeTryToAcquireGuardedMutex()

FORCEINLINE BOOLEAN _KeTryToAcquireGuardedMutex ( IN OUT PKGUARDED_MUTEX  GuardedMutex)

Definition at line 1645 of file ke_x.h.

1646 {
1648 
1649  /* Block APCs */
1651 
1652  /* Remove the lock */
1653  if (!InterlockedBitTestAndReset(&GuardedMutex->Count, GM_LOCK_BIT_V))
1654  {
1655  /* Re-enable APCs */
1657  YieldProcessor();
1658 
1659  /* Return failure */
1660  return FALSE;
1661  }
1662 
1663  /* Set the Owner and APC State */
1664  GuardedMutex->Owner = Thread;
1665  GuardedMutex->SpecialApcDisable = Thread->SpecialApcDisable;
1666  return TRUE;
1667 }
#define TRUE
Definition: types.h:120
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 KeLeaveGuardedRegionThread(_Thread)
Definition: ke_x.h:43
#define KeGetCurrentThread
Definition: hal.h:44
#define GM_LOCK_BIT_V

Referenced by KeTryToAcquireGuardedMutex().

◆ KeGetPreviousMode()

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

◆ KiAcquireApcLockAtSynchLevel()

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

Definition at line 611 of file ke_x.h.

613 {
614  /* Acquire the lock */
617 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
_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
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define SYNCH_LEVEL
Definition: env_spec_w32.h:704

Referenced by KeFreezeAllThreads(), and KeThawAllThreads().

◆ KiAcquireApcLockRaiseToDpc()

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

Definition at line 621 of file ke_x.h.

623 {
624  /* Acquire the lock */
626 }
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

Referenced by KiDeliverApc().

◆ KiAcquireApcLockRaiseToSynch()

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

Definition at line 602 of file ke_x.h.

604 {
605  /* Acquire the lock and raise to synchronization level */
607 }
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

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 671 of file ke_x.h.

673 {
674  /* Check if we were called from a threaded DPC */
675  if (KeGetCurrentPrcb()->DpcThreadActive)
676  {
677  /* Lock the Queue, we're not at DPC level */
678  KeAcquireInStackQueuedSpinLock(&DeviceQueue->Lock, DeviceLock);
679  }
680  else
681  {
682  /* We must be at DPC level, acquire the lock safely */
684  KeAcquireInStackQueuedSpinLockAtDpcLevel(&DeviceQueue->Lock,
685  DeviceLock);
686  }
687 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1063
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
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696

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

◆ KiAcquireDispatcherLock()

◆ KiAcquireDispatcherLockAtSynchLevel()

FORCEINLINE VOID KiAcquireDispatcherLockAtSynchLevel ( VOID  )

◆ KiAcquireDispatcherObject()

FORCEINLINE VOID KiAcquireDispatcherObject ( IN DISPATCHER_HEADER Object)

Definition at line 127 of file ke_x.h.

128 {
130 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
static IUnknown Object
Definition: main.c:512

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

◆ KiAcquireNmiListLock()

FORCEINLINE VOID KiAcquireNmiListLock ( OUT PKIRQL  OldIrql)

Definition at line 1672 of file ke_x.h.

1673 {
1675 }
#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:790

Referenced by KeDeregisterNmiCallback(), and KeRegisterNmiCallback().

◆ KiAcquirePrcbLock()

◆ KiAcquireProcessLockRaiseToSynch()

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

Definition at line 646 of file ke_x.h.

648 {
649  /* Acquire the lock and raise to synchronization level */
651 }
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

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 281 of file ke_x.h.

282 {
284 
285  /* Nothing to do on UP */
287  return NULL;
288 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
smooth NULL
Definition: ftsmooth.c:416
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696

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 836 of file ke_x.h.

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

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

◆ KiCheckDeferredReadyList()

FORCEINLINE VOID KiCheckDeferredReadyList ( IN PKPRCB  Prcb)

Definition at line 263 of file ke_x.h.

264 {
265  /* There are no deferred ready lists on UP systems */
267 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323

Referenced by KiExitDispatcher().

◆ KiCheckThreadStackSwap()

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

Definition at line 798 of file ke_x.h.

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

◆ KiComputeDueTime()

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

Definition at line 947 of file ke_x.h.

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

Referenced by KeSetTimerEx(), and KiInsertTreeTimer().

◆ KiComputeNewPriority()

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

Definition at line 1462 of file ke_x.h.

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

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

◆ KiComputeTimerTableIndex()

FORCEINLINE ULONG KiComputeTimerTableIndex ( IN ULONGLONG  DueTime)

Definition at line 876 of file ke_x.h.

877 {
878  return (DueTime / KeMaximumIncrement) & (TIMER_TABLE_SIZE - 1);
879 }
ULONG KeMaximumIncrement
Definition: clock.c:20
_In_ LARGE_INTEGER DueTime
Definition: kefuncs.h:511
#define TIMER_TABLE_SIZE
Definition: ketypes.h:836

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

◆ KiInsertDeferredReadyList()

FORCEINLINE VOID KiInsertDeferredReadyList ( IN PKTHREAD  Thread)

Definition at line 180 of file ke_x.h.

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

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 780 of file ke_x.h.

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

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

◆ KiReleaseApcLock()

FORCEINLINE VOID KiReleaseApcLock ( IN PKLOCK_QUEUE_HANDLE  Handle)

Definition at line 630 of file ke_x.h.

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

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

◆ KiReleaseApcLockFromSynchLevel()

FORCEINLINE VOID KiReleaseApcLockFromSynchLevel ( IN PKLOCK_QUEUE_HANDLE  Handle)

Definition at line 638 of file ke_x.h.

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

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 691 of file ke_x.h.

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

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

◆ KiReleaseDispatcherLock()

◆ KiReleaseDispatcherLockFromSynchLevel()

◆ KiReleaseDispatcherObject()

FORCEINLINE VOID KiReleaseDispatcherObject ( IN DISPATCHER_HEADER Object)

Definition at line 137 of file ke_x.h.

138 {
140 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
static IUnknown Object
Definition: main.c:512

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

◆ KiReleaseNmiListLock()

FORCEINLINE VOID KiReleaseNmiListLock ( IN KIRQL  OldIrql)

Definition at line 1679 of file ke_x.h.

1680 {
1682 }
KSPIN_LOCK KiNmiCallbackListLock
Definition: bug.c:33
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
#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 655 of file ke_x.h.

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

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

◆ KiReleaseProcessLockFromSynchLevel()

FORCEINLINE VOID KiReleaseProcessLockFromSynchLevel ( IN PKLOCK_QUEUE_HANDLE  Handle)

Definition at line 663 of file ke_x.h.

664 {
665  /* Release the lock without lowering IRQL */
667 }
_In_ HANDLE Handle
Definition: extypes.h:390
VOID FASTCALL KeReleaseInStackQueuedSpinLockFromDpcLevel(IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:369

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

◆ KiReleaseThreadLock()

◆ KiReleaseTimerLock()

FORCEINLINE VOID KiReleaseTimerLock ( IN PKSPIN_LOCK_QUEUE  LockQueue)

Definition at line 292 of file ke_x.h.

293 {
295 
296  /* Nothing to do on UP */
297  UNREFERENCED_PARAMETER(LockQueue);
298 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#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 887 of file ke_x.h.

888 {
889  ULONG Hand;
891 
892  /* Remove the timer from the timer list and check if it's empty */
893  Hand = Timer->Header.Hand;
894  if (RemoveEntryList(&Timer->TimerListEntry))
895  {
896  /* Get the respective timer table entry */
898  if (&TableEntry->Entry == TableEntry->Entry.Flink)
899  {
900  /* Set the entry to an infinite absolute time */
901  TableEntry->Time.HighPart = 0xFFFFFFFF;
902  }
903  }
904 
905  /* Clear the list entries on dbg builds so we can tell the timer is gone */
906 #if DBG
907  Timer->TimerListEntry.Flink = NULL;
908  Timer->TimerListEntry.Blink = NULL;
909 #endif
910 }
Definition: ketypes.h:661
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
smooth NULL
Definition: ftsmooth.c:416
KTIMER_TABLE_ENTRY KiTimerTableListHead[TIMER_TABLE_SIZE]
Definition: timerobj.c:17
_Must_inspect_result_ typedef _In_ ULONG TableEntry
Definition: iotypes.h:3947
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 271 of file ke_x.h.

273 {
274  /* We deliver instantly on UP */
275  UNREFERENCED_PARAMETER(NeedApc);
277 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
_In_ UCHAR Processor
Definition: kefuncs.h:682

Referenced by KiInsertQueueApc().

◆ KiRescheduleThread()

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

Definition at line 192 of file ke_x.h.

194 {
195  /* This is meaningless on UP systems */
196  UNREFERENCED_PARAMETER(NewThread);
198 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323

◆ KiSelectReadyThread()

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

Definition at line 1412 of file ke_x.h.

1414 {
1415  ULONG PrioritySet;
1416  LONG HighPriority;
1417  PLIST_ENTRY ListEntry;
1418  PKTHREAD Thread = NULL;
1419 
1420  /* Save the current mask and get the priority set for the CPU */
1421  PrioritySet = Prcb->ReadySummary >> Priority;
1422  if (!PrioritySet) goto Quickie;
1423 
1424  /* Get the highest priority possible */
1425  BitScanReverse((PULONG)&HighPriority, PrioritySet);
1426  ASSERT((PrioritySet & PRIORITY_MASK(HighPriority)) != 0);
1427  HighPriority += Priority;
1428 
1429  /* Make sure the list isn't empty at the highest priority */
1430  ASSERT(IsListEmpty(&Prcb->DispatcherReadyListHead[HighPriority]) == FALSE);
1431 
1432  /* Get the first thread on the list */
1433  ListEntry = Prcb->DispatcherReadyListHead[HighPriority].Flink;
1434  Thread = CONTAINING_RECORD(ListEntry, KTHREAD, WaitListEntry);
1435 
1436  /* Make sure this thread is here for a reason */
1437  ASSERT(HighPriority == Thread->Priority);
1438  ASSERT(Thread->Affinity & AFFINITY_MASK(Prcb->Number));
1439  ASSERT(Thread->NextProcessor == Prcb->Number);
1440 
1441  /* Remove it from the list */
1442  if (RemoveEntryList(&Thread->WaitListEntry))
1443  {
1444  /* The list is empty now, reset the ready summary */
1445  Prcb->ReadySummary ^= PRIORITY_MASK(HighPriority);
1446  }
1447 
1448  /* Sanity check and return the thread */
1449 Quickie:
1450  ASSERT((Thread == NULL) ||
1451  (Thread->BasePriority == 0) ||
1452  (Thread->Priority != 0));
1453  return Thread;
1454 }
#define PRIORITY_MASK(Id)
Definition: ke.h:156
_In_ KPRIORITY Priority
Definition: kefuncs.h:503
#define AFFINITY_MASK(Id)
Definition: ke.h:155
_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:416
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:120
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define BitScanReverse
Definition: interlocked.h:6
Definition: typedefs.h:118
unsigned int * PULONG
Definition: retypes.h:1
unsigned int ULONG
Definition: retypes.h:1

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

◆ KiSetThreadSwapBusy()

FORCEINLINE VOID KiSetThreadSwapBusy ( IN PKTHREAD  Thread)

Definition at line 205 of file ke_x.h.

206 {
208 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653

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

◆ KiTryThreadLock()

FORCEINLINE BOOLEAN KiTryThreadLock ( IN PKTHREAD  Thread)

Definition at line 255 of file ke_x.h.

256 {
258  return FALSE;
259 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653

Referenced by KeSignalGateBoostPriority().

◆ KxInsertTimer()

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

Definition at line 918 of file ke_x.h.

920 {
921  PKSPIN_LOCK_QUEUE LockQueue;
923 
924  /* Acquire the lock and release the dispatcher lock */
925  LockQueue = KiAcquireTimerLock(Hand);
927 
928  /* Try to insert the timer */
929  if (KiInsertTimerTable(Timer, Hand))
930  {
931  /* Complete it */
932  KiCompleteTimer(Timer, LockQueue);
933  }
934  else
935  {
936  /* Do nothing, just release the lock */
937  KiReleaseTimerLock(LockQueue);
938  }
939 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
FORCEINLINE PKSPIN_LOCK_QUEUE KiAcquireTimerLock(IN ULONG Hand)
Definition: ke_x.h:281
BOOLEAN FASTCALL KiInsertTimerTable(IN PKTIMER Timer, IN ULONG Hand)
Definition: timerobj.c:63
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
VOID FASTCALL KiCompleteTimer(IN PKTIMER Timer, IN PKSPIN_LOCK_QUEUE LockQueue)
Definition: timerobj.c:167
FORCEINLINE VOID KiReleaseDispatcherLockFromSynchLevel(VOID)
Definition: ke_x.h:169
#define SYNCH_LEVEL
Definition: env_spec_w32.h:704
FORCEINLINE VOID KiReleaseTimerLock(IN PKSPIN_LOCK_QUEUE LockQueue)
Definition: ke_x.h:292

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

◆ KxQueueReadyThread()

FORCEINLINE VOID KxQueueReadyThread ( IN PKTHREAD  Thread,
IN PKPRCB  Prcb 
)

Definition at line 1347 of file ke_x.h.

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

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

◆ KxRemoveTreeTimer()

FORCEINLINE VOID KxRemoveTreeTimer ( IN PKTIMER  Timer)

Definition at line 999 of file ke_x.h.

1000 {
1001  ULONG Hand = Timer->Header.Hand;
1002  PKSPIN_LOCK_QUEUE LockQueue;
1003  PKTIMER_TABLE_ENTRY TimerEntry;
1004 
1005  /* Acquire timer lock */
1006  LockQueue = KiAcquireTimerLock(Hand);
1007 
1008  /* Set the timer as non-inserted */
1009  Timer->Header.Inserted = FALSE;
1010 
1011  /* Remove it from the timer list */
1012  if (RemoveEntryList(&Timer->TimerListEntry))
1013  {
1014  /* Get the entry and check if it's empty */
1015  TimerEntry = &KiTimerTableListHead[Hand];
1016  if (IsListEmpty(&TimerEntry->Entry))
1017  {
1018  /* Clear the time then */
1019  TimerEntry->Time.HighPart = 0xFFFFFFFF;
1020  }
1021  }
1022 
1023  /* Release the timer lock */
1024  KiReleaseTimerLock(LockQueue);
1025 }
FORCEINLINE PKSPIN_LOCK_QUEUE KiAcquireTimerLock(IN ULONG Hand)
Definition: ke_x.h:281
_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:577
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:292

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

◆ KxSetTimerForThreadWait()

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

Definition at line 1029 of file ke_x.h.

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

◆ KxUnwaitThread()

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

Definition at line 1254 of file ke_x.h.

1256 {
1257  PLIST_ENTRY WaitEntry, WaitList;
1258  PKWAIT_BLOCK WaitBlock;
1259  PKTHREAD WaitThread;
1260  ULONG WaitKey;
1261 
1262  /* Loop the Wait Entries */
1263  WaitList = &Object->WaitListHead;
1264  ASSERT(IsListEmpty(&Object->WaitListHead) == FALSE);
1265  WaitEntry = WaitList->Flink;
1266  do
1267  {
1268  /* Get the current wait block */
1269  WaitBlock = CONTAINING_RECORD(WaitEntry, KWAIT_BLOCK, WaitListEntry);
1270 
1271  /* Get the waiting thread */
1272  WaitThread = WaitBlock->Thread;
1273 
1274  /* Check the current Wait Mode */
1275  if (WaitBlock->WaitType == WaitAny)
1276  {
1277  /* Use the actual wait key */
1278  WaitKey = WaitBlock->WaitKey;
1279  }
1280  else
1281  {
1282  /* Otherwise, use STATUS_KERNEL_APC */
1283  WaitKey = STATUS_KERNEL_APC;
1284  }
1285 
1286  /* Unwait the thread */
1287  KiUnwaitThread(WaitThread, WaitKey, Increment);
1288 
1289  /* Next entry */
1290  WaitEntry = WaitList->Flink;
1291  } while (WaitEntry != WaitList);
1292 }
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 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:120
UCHAR WaitType
Definition: ketypes.h:446
USHORT WaitKey
Definition: ketypes.h:448
static IUnknown Object
Definition: main.c:512
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: typedefs.h:118
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 1299 of file ke_x.h.

1301 {
1302  PLIST_ENTRY WaitEntry, WaitList;
1303  PKWAIT_BLOCK WaitBlock;
1304  PKTHREAD WaitThread;
1305 
1306  /* Loop the Wait Entries */
1307  WaitList = &Event->Header.WaitListHead;
1308  ASSERT(IsListEmpty(&Event->Header.WaitListHead) == FALSE);
1309  WaitEntry = WaitList->Flink;
1310  do
1311  {
1312  /* Get the current wait block */
1313  WaitBlock = CONTAINING_RECORD(WaitEntry, KWAIT_BLOCK, WaitListEntry);
1314 
1315  /* Get the waiting thread */
1316  WaitThread = WaitBlock->Thread;
1317 
1318  /* Check the current Wait Mode */
1319  if (WaitBlock->WaitType == WaitAny)
1320  {
1321  /* Un-signal it */
1322  Event->Header.SignalState = 0;
1323 
1324  /* Un-signal the event and unwait the thread */
1325  KiUnwaitThread(WaitThread, WaitBlock->WaitKey, Increment);
1326  break;
1327  }
1328 
1329  /* Unwait the thread with STATUS_KERNEL_APC */
1331 
1332  /* Next entry */
1333  WaitEntry = WaitList->Flink;
1334  } while (WaitEntry != WaitList);
1335 }
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 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:120
UCHAR WaitType
Definition: ketypes.h:446
USHORT WaitKey
Definition: ketypes.h:448
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: typedefs.h:118
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().