ZwQuerySymbolicLinkObject function

The ZwQuerySymbolicLinkObject routine returns a Unicode string that contains the target of a symbolic link.


NTSYSAPI NTSTATUS ZwQuerySymbolicLinkObject(
  HANDLE          LinkHandle,
  PULONG          ReturnedLength



Handle to the symbolic-link object that you want to query. This handle is created by a successful call to ZwOpenSymbolicLinkObject.


Pointer to an initialized Unicode string that receives the target of the symbolic link.


contains the maximum number of bytes to copy into the Unicode string at LinkTarget. On output, the unsigned long integer contains the length of the Unicode string naming the target of the symbolic link.

Return Value

ZwQuerySymbolicLinkObject returns either STATUS_SUCCESS to indicate the routine completed without error or STATUS_BUFFER_TOO_SMALL if the Unicode string provided at LinkTarget is too small to hold the returned string.


Before calling this routine, driver writers must ensure that the Unicode string at LinkTarget has been properly initialized and a buffer for the string has been allocated. The MaximumLength and Buffer members of the Unicode string must be set before calling ZwQuerySymbolicLinkObject or the call will fail.

If ZwQuerySymbolicLinkObject returns STATUS_BUFFER_TOO_SMALL drivers should examine the value returned at ReturnedLength. The number returned in this variable indicates the maximum length that the Unicode string for the target of the symbolic link.

Note If the call to this function occurs in user mode, you should use the name "NtQuerySymbolicLinkObject" instead of "ZwQuerySymbolicLinkObject".
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.


Windows version Available in Windows 2000 and later versions of Windows.
Target Platform Universal
Header wdm.h (include Wdm.h, Ntddk.h, Ntifs.h)
Library NtosKrnl.lib
DLL NtosKrnl.exe
DDI compliance rules PowerIrpDDis, HwStorPortProhibitedDDIs

See Also

Using Nt and Zw Versions of the Native System Services Routines