The KeEnterCriticalRegion routine temporarily disables the execution of normal kernel APCs, but does not prevent special kernel APCs from running.
NTKERNELAPI VOID KeEnterCriticalRegion( );
This function has no parameters.
A driver calls this routine to enter a critical region in which the execution of normal kernel APCs is deferred until this driver exits the critical region by calling the KeLeaveCriticalRegion routine. Any caller of KeEnterCriticalRegion should call KeLeaveCriticalRegion as quickly as possible after entering a critical region.
Highest-level drivers can call KeEnterCriticalRegion while running in the context of the thread that requested the current I/O operation.
A thread that is inside a critical region has both user APCs and normal kernel APCs disabled, but not special kernel APCs. For more information about these APC types, see Types of APCs.
Critical regions can be entered recursively and each call to KeEnterCriticalRegion must have a matching call to KeLeaveCriticalRegion.
A driver can use a critical region to acquire and release exclusive access to a shared resource. In this case, the ExEnterCriticalRegionAndAcquireResourceExclusive and ExReleaseResourceAndLeaveCriticalRegion routines can be used instead of the KeEnterCriticalRegion and KeLeaveCriticalRegion routines. For more information, see the code example in ExEnterCriticalRegionAndAcquireResourceExclusive.
For more information about APCs, see Asynchronous Procedure Calls.
|Windows version||Available starting with Windows 2000.|
|Header||ntddk.h (include Wdm.h, Ntddk.h, Ntifs.h)|
|DDI compliance rules||CriticalRegions, IrqlKeApcLte2, WithinCriticalRegion, HwStorPortProhibitedDDIs, WithinCriticalRegion(storport)|