#ifndef _NTIOAPI_H
NTSYSCALLAPI
NTSTATUS
NTAPI
NtUnlockFile(
_In_ HANDLE FileHandle,
_Out_ PIO_STATUS_BLOCK IoStatusBlock,
_In_ PLARGE_INTEGER ByteOffset,
_In_ PLARGE_INTEGER Length,
_In_ ULONG Key
);
View code on GitHub
#ifndef _NTZWAPI_H
NTSYSCALLAPI
NTSTATUS
NTAPI
ZwUnlockFile(
_In_ HANDLE FileHandle,
_Out_ PIO_STATUS_BLOCK IoStatusBlock,
_In_ PLARGE_INTEGER ByteOffset,
_In_ PLARGE_INTEGER Length,
_In_ ULONG Key
);
View code on GitHub
// ntifs.h
__kernel_entry NTSYSCALLAPI NTSTATUS NtUnlockFile(
[in] HANDLE FileHandle,
[out] PIO_STATUS_BLOCK IoStatusBlock,
[in] PLARGE_INTEGER ByteOffset,
[in] PLARGE_INTEGER Length,
[in] ULONG Key
);
View the official Windows Driver Kit DDI reference
// ntifs.h
NTSYSAPI NTSTATUS ZwUnlockFile(
[in] HANDLE FileHandle,
[out] PIO_STATUS_BLOCK IoStatusBlock,
[in] PLARGE_INTEGER ByteOffset,
[in] PLARGE_INTEGER Length,
[in] ULONG Key
);
View the official Windows Driver Kit DDI reference
No description available.
The NtUnlockFile routine unlocks a byte-range lock in a file.
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.
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. |
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.
Using Nt and Zw Versions of the Native System Services Routines
The ZwUnlockFile routine unlocks a byte-range lock in a file.
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.
The ZwUnlockFile 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. |
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 ZwUnlockFile 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 ZwUnlockFile 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".
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.
This function is documented in Windows Driver Kit here and here.
HANDLE
to File Object with locked region.
IO result of function call.
Offset in file where unlock region begins.
Length of region to unlock.
Pointer to 4-bytes key associated with lock. See NtLockFile
for additional information about locking by key usage.