ZwUnlockFile routine

The ZwUnlockFile routine unlocks a byte-range lock in a file.

Syntax


NTSTATUS ZwUnlockFile(
  _In_   HANDLE FileHandle,
  _Out_  PIO_STATUS_BLOCK IoStatusBlock,
  _In_   PLARGE_INTEGER ByteOffset,
  _In_   PLARGE_INTEGER Length,
  _In_   ULONG Key
);

Parameters

FileHandle [in]

A handle for the file object that represents the file whose byte range is to be unlocked.

IoStatusBlock [out]

A pointer to an IO_STATUS_BLOCK structure that contains the final status.

ByteOffset [in]

A pointer to a variable that specifies the starting byte offset for the byte range to be unlocked.

Length [in]

A pointer to a variable that specifies the length, in bytes, of the byte range to unlock.

Key [in]

The caller-assigned value used to describe groups of related locks. This value should be set to zero.

Return value

The ZwUnlockFile routine returns STATUS_SUCCESS on success or an appropriate NTSTATUS value. Possible NTSTATUS values include:

Return codeDescription
STATUS_RANGE_NOT_LOCKED

The byte range specified is not locked.

 

Remarks

The ZwUnlockFile routine takes a range of bytes as specified by the ByteOffset and Length arguments. This range must be identical to a range of bytes in the file that was previously locked with a single call to the ZwLockFile routine. It is not possible to unlock two previously locked adjacent ranges with a single call to ZwUnlockFile. It is also not possible to unlock part of a range that was previously locked with a single call to the ZwLockFile routine.

Callers of ZwUnlockFile must be running at IRQL = PASSIVE_LEVEL and with special kernel APCs enabled.

Note  If the call to the ZwUnlockFile function occurs in user mode, you should use the name "NtUnlockFile" instead of "ZwUnlockFile".

Requirements

Version

Available starting with Windows 7.

Header

Ntifs.h (include Ntifs.h or FltKernel.h)

Library

Ntoskrnl.lib

IRQL

PASSIVE_LEVEL (see Remarks section)

DDI compliance rules

PowerIrpDDis, HwStorPortProhibitedDDIs

See also

ZwLockFile

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft. All rights reserved.