The ZwLockFile routine requests a byte-range lock for the specified file.
NTSTATUS ZwLockFile( _In_ HANDLE FileHandle, _In_opt_ HANDLE Event, _In_opt_ PIO_APC_ROUTINE ApcRoutine, _In_opt_ PVOID ApcContext, _Out_ PIO_STATUS_BLOCK IoStatusBlock, _In_ PLARGE_INTEGER ByteOffset, _In_ PLARGE_INTEGER Length, _In_ ULONG Key, _In_ BOOLEAN FailImmediately, _In_ BOOLEAN ExclusiveLock );
A handle for the file on which a byte-range lock is requested.
A handle to a caller-created event. If not NULL, the caller is placed into a wait state until the operation succeeds, at which time the event is set into the Signaled state.
A pointer to a caller-supplied APC routine that is executed after the operation completes. Can be NULL.
A pointer to a caller-specified context for the APC routine. This value is passed to the APC routine when it is executed. Can be NULL.
A pointer to an IO_STATUS_BLOCK structure that contains the final status.
A pointer to a variable that specifies the starting byte offset of the range to lock.
A pointer to a variable that specifies the length in bytes of the range to lock.
A caller-assigned value used to describe groups of related locks. This value should be set to zero.
If TRUE, immediately return if the file cannot be locked. If FALSE, wait for the lock request to be granted.
If TRUE, byte-range lock is exclusive; otherwise, shared lock.
The ZwLockFile routine returns STATUS_SUCCESS or an appropriate error NTSTATUS value. Possible NTSTATUS values include the following:
||Insufficient resources exist to grant the byte-range lock for the specified file.|
||The byte-range lock was not granted for the specified file.|
Callers of ZwLockFile must be running at IRQL = PASSIVE_LEVEL and with special kernel APCs enabled.
|Windows version||Available starting with Windows 7.|
|Header||ntifs.h (include Ntifs.h, FltKernel.h)|
|IRQL||PASSIVE_LEVEL (see Remarks section)|
|DDI compliance rules||PowerIrpDDis, HwStorPortProhibitedDDIs|