NtUnlockFile function (ntifs.h)
The NtUnlockFile routine unlocks a byte-range lock in a file.
Syntax
__kernel_entry NTSYSCALLAPI NTSTATUS NtUnlockFile(
[in] HANDLE FileHandle,
[out] PIO_STATUS_BLOCK IoStatusBlock,
[in] PLARGE_INTEGER ByteOffset,
[in] PLARGE_INTEGER Length,
[in] ULONG Key
);
Parameters
[in] FileHandle
A handle for the file object that represents the file whose byte range is to be unlocked.
[out] IoStatusBlock
A pointer to an IO_STATUS_BLOCK structure that contains the final status.
[in] ByteOffset
A pointer to a variable that specifies the starting byte offset for the byte range to be unlocked.
[in] Length
A pointer to a variable that specifies the length, in bytes, of the byte range to unlock.
[in] Key
The caller-assigned value used to describe groups of related locks. This value should be set to zero.
Return value
The NtUnlockFile routine returns STATUS_SUCCESS on success or an appropriate NTSTATUS value. Possible NTSTATUS values include:
Return code | Description |
---|---|
STATUS_RANGE_NOT_LOCKED | The byte range specified is not locked. |
Remarks
The NtUnlockFile 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 NtUnlockFile routine. It is not possible to unlock two previously locked adjacent ranges with a single call to NtUnlockFile. It is also not possible to unlock part of a range that was previously locked with a single call to the NtUnlockFile routine.
Callers of NtUnlockFile must be running at IRQL = PASSIVE_LEVEL and with special kernel APCs enabled**.
Note
If the call to the NtUnlockFile function occurs in kernel mode, you should use the name "ZwUnlockFile" instead of "NtUnlockFile".
For calls from kernel-mode drivers, the NtXxx and ZwXxx versions of a Windows Native System Services routine can behave differently in the way that they handle and interpret input parameters. For more information about the relationship between the NtXxx and ZwXxx versions of a routine, see Using Nt and Zw Versions of the Native System Services Routines.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 7 |
Target Platform | Universal |
Header | ntifs.h (include Ntifs.h, FltKernel.h) |
Library | NtosKrnl.lib |
DLL | NtosKrnl.exe |
IRQL | PASSIVE_LEVEL (see Remarks section) |
DDI compliance rules | HwStorPortProhibitedDDIs, PowerIrpDDis |
See also
Using Nt and Zw Versions of the Native System Services Routines