Previous Next

ZwOpenSymbolicLinkObject

The ZwOpenSymbolicLinkObject routine returns a handle to an existing symbolic link.

NTSTATUS
  ZwOpenSymbolicLinkObject(
    OUT PHANDLE  LinkHandle,
    IN ACCESS_MASK  DesiredAccess,
    IN POBJECT_ATTRIBUTES  ObjectAttributes
    );

Parameters

LinkHandle
Pointer to a returned handle for the symbolic link object specified in ObjectAttributes if the call was successful. The driver must close the handle with ZwClose once the handle is no longer in use.
DesiredAccess
Specifies the ACCESS_MASK value that represents the type of access that the caller requires to the symbolic link object. This is most commonly GENERIC_READ access such that the returned handle can be used with ZwQuerySymbolicLinkObject.
ObjectAttributes
Pointer to the initialized object attributes for the symbolic link being opened. An ObjectName string for the symbolic link must be specified. If the caller is not running in the system process context, it must set the OBJ_KERNEL_HANDLE attribute for ObjectAttributes. For details, see InitializeObjectAttributes.

Headers

Declared in ntddk.h. Include ntddk.h.

Return Value

ZwOpenSymbolicLinkObject returns STATUS_SUCCESS if the symbolic link was opened, or the appropriate error status on failure.

Comments

Driver routines that run in a process context other than that of the system process must set the OBJ_KERNEL_HANDLE attribute for the ObjectAttributes parameter of ZwOpenSymbolicLinkObject. This restricts the use of the handle returned by ZwOpenSymbolicLinkObject to processes running only in kernel mode. Otherwise, the handle can be accessed by the process in whose context the driver is running. Drivers can call InitializeObjectAttributes to set the OBJ_KERNEL_HANDLE attribute as follows.

InitializeObjectAttributes(&ObjectAttributes, NULL, OBJ_KERNEL_HANDLE, NULL, NULL);

Callers of this routine must be running at IRQL = PASSIVE_LEVEL.

See Also

ACCESS_MASK, InitializeObjectAttributes, ZwQuerySymbolicLinkObject